/[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 319 - (hide annotations) (download)
Mon Dec 13 00:46:42 2004 UTC (19 years, 4 months ago) by schoenebeck
File size: 4420 byte(s)
* introduced 'synthesis mode' to reduce the amount of code and conditionals
  for the current synthesis case in the main synthesis loop
* support for MMX and SSE(1) in the core synthesis algorithms (CPU feature
  detection at runtime, only x86 so far)

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

  ViewVC Help
Powered by ViewVC