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