1 |
/*************************************************************************** |
2 |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
5 |
* Copyright (C) 2003, 2004 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 |
#include "AudioChannel.h" |
24 |
|
25 |
namespace LinuxSampler { |
26 |
|
27 |
/** |
28 |
* Create real channel. |
29 |
* |
30 |
* @param ChannelNr - channel number of this new channel |
31 |
* @param BufferSize - desired audio data buffer size |
32 |
*/ |
33 |
AudioChannel::AudioChannel(uint ChannelNr, uint BufferSize) { |
34 |
this->ChannelNr = ChannelNr; |
35 |
this->pBuffer = new float[BufferSize]; |
36 |
this->uiBufferSize = BufferSize; |
37 |
this->pMixChannel = NULL; |
38 |
this->UsesExternalBuffer = false; |
39 |
|
40 |
Parameters["NAME"] = new ParameterName("Channel " + ToString(ChannelNr)); |
41 |
Parameters["IS_MIX_CHANNEL"] = new ParameterIsMixChannel(false); |
42 |
|
43 |
Clear(); |
44 |
} |
45 |
|
46 |
/** |
47 |
* Create channel with external (already existing) audio buffer. |
48 |
* |
49 |
* @param ChannelNr - channel number of this new channel |
50 |
* @param pBuffer - external audio buffer |
51 |
* @param BufferSIze - size of the external buffer |
52 |
*/ |
53 |
AudioChannel::AudioChannel(uint ChannelNr, float* pBuffer, uint BufferSize) { |
54 |
this->ChannelNr = ChannelNr; |
55 |
this->pBuffer = pBuffer; |
56 |
this->uiBufferSize = BufferSize; |
57 |
this->pMixChannel = NULL; |
58 |
this->UsesExternalBuffer = true; |
59 |
|
60 |
Parameters["NAME"] = new ParameterName("Channel " + ToString(ChannelNr)); |
61 |
Parameters["IS_MIX_CHANNEL"] = new ParameterIsMixChannel(false); |
62 |
|
63 |
Clear(); |
64 |
} |
65 |
|
66 |
/** |
67 |
* Create mix channel. |
68 |
* |
69 |
* @param ChannelNr - channel number of this new channel |
70 |
* @param pMixChannelDestination - a real audio channel this new mix |
71 |
* channel refers to |
72 |
*/ |
73 |
AudioChannel::AudioChannel(uint ChannelNr, AudioChannel* pMixChannelDestination) { |
74 |
this->ChannelNr = ChannelNr; |
75 |
this->pBuffer = pMixChannel->Buffer(); |
76 |
this->uiBufferSize = pMixChannel->uiBufferSize; |
77 |
this->pMixChannel = pMixChannel; |
78 |
this->UsesExternalBuffer = true; |
79 |
|
80 |
Parameters["NAME"] = new ParameterName("Channel " + ToString(ChannelNr)); |
81 |
Parameters["IS_MIX_CHANNEL"] = new ParameterIsMixChannel(true); |
82 |
//TODO: Parameters["MIX_CHANNEL_DESTINATION"] = new ParameterMixChannelDestination(dest_chan); |
83 |
|
84 |
Clear(); |
85 |
} |
86 |
|
87 |
/** |
88 |
* Destructor |
89 |
*/ |
90 |
AudioChannel::~AudioChannel() { |
91 |
std::map<String,DeviceRuntimeParameter*>::iterator iter = Parameters.begin(); |
92 |
while (iter != Parameters.end()) { delete iter->second; iter++; } |
93 |
if (!UsesExternalBuffer) delete[] pBuffer; |
94 |
} |
95 |
|
96 |
std::map<String,DeviceRuntimeParameter*> AudioChannel::ChannelParameters() { |
97 |
return Parameters; |
98 |
} |
99 |
} |