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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC