/[svn]/linuxsampler/trunk/src/drivers/audio/AudioChannel.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/drivers/audio/AudioChannel.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 331 - (show annotations) (download)
Thu Dec 30 04:00:03 2004 UTC (19 years, 3 months ago) by senkov
File size: 4453 byte(s)
* Fixed bug with mixed channel creation

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

  ViewVC Help
Powered by ViewVC