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-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.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 = 0.0f;
42  float finalFrequency = 0.0f;
43  float totalTime = 0.0f;
44  float currentTime = 0.0f;
45  SoundNext nextOper = SOPER_CONTINUE;
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 
79  bool HasEnvelope();
80  SoundOper& GetEnvelope();
81  void PopEnvelope();
82 
83  int GetPriority();
84  void SetPriority(int);
85 
86  void SetStartAmplitude(float);
87  void SetStartFrequency(float);
88  void SetChangeFrequency(float);
89 
90  float GetStartAmplitude();
91  float GetStartFrequency();
92  float GetChangeFrequency();
93  float GetInitFrequency();
94 
95  void AddOper(SoundOper);
96  void ResetOper();
97  SoundType GetSoundType();
98  void SetLoop(bool);
99  void Mute(bool);
100  bool IsMuted();
101 
102  void Reset();
103  int GetId();
104 
105 private:
106  Buffer *m_buffer;
107  ALuint m_source;
108 
109  int m_priority;
110  int m_id;
111  float m_startAmplitude;
112  float m_startFrequency;
113  float m_changeFrequency;
114  float m_initFrequency;
115  float m_volume;
116  std::deque<SoundOper> m_oper;
117  bool m_ready;
118  bool m_loop;
119  bool m_mute;
120  Math::Vector m_position;
121 };
122 
Sound plugin interface.
Definition: sound.h:45
SoundNext
Enum representing operation that will be performend on a sound at given time.
Definition: sound.h:43
Definition: channel.h:39
OpenAL buffer.
Definition: buffer.h:35
3D (3x1) vector
Definition: vector.h:53
Definition: channel.h:49