1 |
schoenebeck |
53 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
|
|
* LinuxSampler - modular, streaming capable sampler * |
4 |
|
|
* * |
5 |
|
|
* Copyright (C) 2003 by Benno Senoner and Christian Schoenebeck * |
6 |
|
|
* * |
7 |
|
|
* This program is free software; you can redistribute it and/or modify * |
8 |
|
|
* it under the terms of the GNU General Public License as published by * |
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
10 |
|
|
* (at your option) any later version. * |
11 |
|
|
* * |
12 |
|
|
* This program is distributed in the hope that it will be useful, * |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
15 |
|
|
* GNU General Public License for more details. * |
16 |
|
|
* * |
17 |
|
|
* You should have received a copy of the GNU General Public License * |
18 |
|
|
* along with this program; if not, write to the Free Software * |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
20 |
|
|
* MA 02111-1307 USA * |
21 |
|
|
***************************************************************************/ |
22 |
|
|
|
23 |
|
|
#ifndef __LS_AUDIOCHANNEL_H__ |
24 |
|
|
#define __LS_AUDIOCHANNEL_H__ |
25 |
|
|
|
26 |
|
|
#include <string.h> |
27 |
|
|
#include "../common/global.h" |
28 |
|
|
|
29 |
|
|
namespace LinuxSampler { |
30 |
|
|
|
31 |
|
|
/** Audio Channel (always mono) |
32 |
|
|
* |
33 |
|
|
* This class is used for routing audio signals between arbitrary sources |
34 |
|
|
* and destinations. You can either create a normal channel like: |
35 |
|
|
* |
36 |
|
|
* AudioChannel c1(512); // create unnamed channel |
37 |
|
|
* AudioChannel c2(512, "Effect send mono channel"); // create named channel |
38 |
|
|
* |
39 |
|
|
* Or you can create a mix channel, e.g. the following would create a |
40 |
|
|
* normal channel first, and the second channel is just a copy of the |
41 |
|
|
* first channel: |
42 |
|
|
* |
43 |
|
|
* AudioChannel mono_chan(512, "Effect send channel"); // real channel |
44 |
|
|
* AudioChannel mix_chan(&mono_chan, "Effect send mono channel"); // mix channel |
45 |
|
|
* |
46 |
|
|
* So in the last example, when writing to 'mix_chan' the signal will |
47 |
|
|
* actually be mixed to the 'mono_chan' channel, so this is an easy way |
48 |
|
|
* to downmix a signal source which has more audio channels than the |
49 |
|
|
* signal destination can offer. |
50 |
|
|
*/ |
51 |
|
|
class AudioChannel { |
52 |
|
|
public: |
53 |
|
|
// attributes |
54 |
|
|
String Name; ///< Arbitrary name of this audio channel |
55 |
|
|
|
56 |
|
|
// constructors / destructor |
57 |
|
|
AudioChannel(uint BufferSize, String Name = "unnamed"); |
58 |
|
|
AudioChannel(float* pBuffer, uint BufferSize, String Name = "unnamed"); |
59 |
|
|
AudioChannel(AudioChannel* pMixChannel, String Name = "unnamed"); |
60 |
|
|
~AudioChannel(); |
61 |
|
|
|
62 |
|
|
// methods |
63 |
|
|
inline float* Buffer() { return pBuffer; } ///< Audio signal buffer |
64 |
|
|
inline AudioChannel* MixChannel() { return pMixChannel; } ///< In case this channel is a mix channel, then it will return a pointer to the real channel this channel refers to, NULL otherwise. |
65 |
|
|
inline void Clear() { memset(pBuffer, 0, uiBufferSize * sizeof(float)); } ///< Reset audio buffer with silence |
66 |
|
|
private: |
67 |
|
|
float* pBuffer; |
68 |
|
|
uint uiBufferSize; |
69 |
|
|
AudioChannel* pMixChannel; |
70 |
|
|
bool UsesExternalBuffer; |
71 |
|
|
}; |
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
#endif // __LS_AUDIOCHANNEL_H__ |