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 Pause();
54  bool Stop();
55 
56  bool SetPosition(const Math::Vector &);
57 
58  bool SetFrequency(float);
59  float GetFrequency();
60 
61  float GetCurrentTime();
62  void SetCurrentTime(float);
63  float GetDuration();
64 
65  bool SetVolume(float);
66  float GetVolume();
67  void SetVolumeAtrib(float);
68  float GetVolumeAtrib();
69 
70  bool IsPlaying();
71  bool IsReady();
72  bool IsLoaded();
73 
74  bool SetBuffer(Buffer *);
75  bool FreeBuffer();
76 
77  bool HasEnvelope();
78  SoundOper& GetEnvelope();
79  void PopEnvelope();
80 
81  int GetPriority();
82  void SetPriority(int);
83 
84  void SetStartAmplitude(float);
85  void SetStartFrequency(float);
86  void SetChangeFrequency(float);
87 
88  float GetStartAmplitude();
89  float GetStartFrequency();
90  float GetChangeFrequency();
91  float GetInitFrequency();
92 
93  void AddOper(SoundOper);
94  void ResetOper();
95  Sound GetSoundType();
96  void SetLoop(bool);
97  void Mute(bool);
98  bool IsMuted();
99 
100  void Reset();
101  int GetId();
102 
103 private:
104  Buffer *m_buffer;
105  ALuint m_source;
106 
107  int m_priority;
108  int m_id;
109  float m_startAmplitude;
110  float m_startFrequency;
111  float m_changeFrequency;
112  float m_initFrequency;
113  float m_volume;
114  std::deque<SoundOper> m_oper;
115  bool m_ready;
116  bool m_loop;
117  bool m_mute;
118  Math::Vector m_position;
119 };
120 
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