Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
channel.h
Go to the documentation of this file.
1 // * This file is part of the COLOBOT source code
2 // * Copyright (C) 2012, Polish Portal of Colobot (PPC)
3 // *
4 // * This program is free software: you can redistribute it and/or modify
5 // * it under the terms of the GNU General Public License as published by
6 // * the Free Software Foundation, either version 3 of the License, or
7 // * (at your option) any later version.
8 // *
9 // * This program is distributed in the hope that it will be useful,
10 // * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // * GNU General Public License for more details.
13 // *
14 // * You should have received a copy of the GNU General Public License
15 // * along with this program. If not, see http://www.gnu.org/licenses/.
16 
22 #pragma once
23 
24 #include "sound/sound.h"
25 
26 #include "sound/oalsound/buffer.h"
27 #include "sound/oalsound/check.h"
28 
29 #include <string>
30 #include <deque>
31 #include <cassert>
32 
33 #include <al.h>
34 #include <alc.h>
35 
36 struct SoundOper
37 {
38  float finalAmplitude;
39  float finalFrequency;
40  float totalTime;
41  float currentTime;
42  SoundNext nextOper;
43 };
44 
45 
46 class Channel
47 {
48 public:
49  Channel();
50  ~Channel();
51 
52  bool Play();
53  bool Stop();
54 
55  bool SetPan(Math::Vector);
56  void SetPosition(Math::Vector);
57  Math::Vector GetPosition();
58 
59  bool SetFrequency(float);
60  float GetFrequency();
61 
62  float GetCurrentTime();
63  void SetCurrentTime(float);
64  float GetDuration();
65 
66  bool SetVolume(float);
67  float GetVolume();
68  void SetVolumeAtrib(float);
69  float GetVolumeAtrib();
70 
71  bool IsPlaying();
72  bool IsReady();
73  bool IsLoaded();
74 
75  bool SetBuffer(Buffer *);
76  bool FreeBuffer();
77 
78  bool HasEnvelope();
79  SoundOper& GetEnvelope();
80  void PopEnvelope();
81 
82  int GetPriority();
83  void SetPriority(int);
84 
85  void SetStartAmplitude(float);
86  void SetStartFrequency(float);
87  void SetChangeFrequency(float);
88 
89  float GetStartAmplitude();
90  float GetStartFrequency();
91  float GetChangeFrequency();
92  float GetInitFrequency();
93 
94  void AddOper(SoundOper);
95  void ResetOper();
96  Sound GetSoundType();
97  void SetLoop(bool);
98  void Mute(bool);
99  bool IsMuted();
100 
101 private:
102  Buffer *m_buffer;
103  ALuint m_source;
104 
105  int m_priority;
106  float m_startAmplitude;
107  float m_startFrequency;
108  float m_changeFrequency;
109  float m_initFrequency;
110  float m_volume;
111  std::deque<SoundOper> m_oper;
112  bool m_ready;
113  bool m_loop;
114  bool m_mute;
115  Math::Vector m_position;
116 };
117 
Sound plugin interface.
SoundNext
Enum representing operation that will be performend on a sound at given time.
Definition: sound.h:135
Definition: channel.h:36
Sound
Sound enum representing sound file.
Definition: sound.h:42
OpenAL buffer.
Definition: buffer.h:36
3D (3x1) vector
Definition: vector.h:49
Definition: channel.h:46