/[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 361 - (show annotations) (download)
Wed Feb 9 01:22:18 2005 UTC (19 years, 2 months ago) by schoenebeck
File size: 4652 byte(s)
* bunch of fixes for OSX (patch by Stephane Letz)

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

  ViewVC Help
Powered by ViewVC