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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 319 by schoenebeck, Mon Dec 13 00:46:42 2004 UTC revision 1004 by schoenebeck, Thu Dec 28 18:05:14 2006 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6     *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 21  Line 22 
22   ***************************************************************************/   ***************************************************************************/
23    
24  #include "AudioChannel.h"  #include "AudioChannel.h"
25  #include <malloc.h>  
26    #if defined(__APPLE__)
27    # include <stdlib.h>
28    #else
29    # include <malloc.h>
30    #endif
31    
32    
33  namespace LinuxSampler {  namespace LinuxSampler {
34    
# Line 33  namespace LinuxSampler { Line 40  namespace LinuxSampler {
40       */       */
41      AudioChannel::AudioChannel(uint ChannelNr, uint BufferSize) {      AudioChannel::AudioChannel(uint ChannelNr, uint BufferSize) {
42          this->ChannelNr          = ChannelNr;          this->ChannelNr          = ChannelNr;
43            #if defined(__APPLE__)
44            this->pBuffer            = (float *) malloc(BufferSize*sizeof(float));
45            #else
46          this->pBuffer            = (float *) memalign(16,BufferSize*sizeof(float));          this->pBuffer            = (float *) memalign(16,BufferSize*sizeof(float));
47            #endif
48          this->uiBufferSize       = BufferSize;          this->uiBufferSize       = BufferSize;
49          this->pMixChannel        = NULL;          this->pMixChannel        = NULL;
50          this->UsesExternalBuffer = false;          this->UsesExternalBuffer = false;
# Line 73  namespace LinuxSampler { Line 84  namespace LinuxSampler {
84       */       */
85      AudioChannel::AudioChannel(uint ChannelNr, AudioChannel* pMixChannelDestination) {      AudioChannel::AudioChannel(uint ChannelNr, AudioChannel* pMixChannelDestination) {
86          this->ChannelNr          = ChannelNr;          this->ChannelNr          = ChannelNr;
87          this->pBuffer            = pMixChannel->Buffer();          this->pBuffer            = pMixChannelDestination->Buffer();
88          this->uiBufferSize       = pMixChannel->uiBufferSize;          this->uiBufferSize       = pMixChannelDestination->uiBufferSize;
89          this->pMixChannel        = pMixChannel;          this->pMixChannel        = pMixChannelDestination;
90          this->UsesExternalBuffer = true;          this->UsesExternalBuffer = true;
91    
92          Parameters["NAME"]           = new ParameterName("Channel " + ToString(ChannelNr));          Parameters["NAME"]           = new ParameterName("Channel " + ToString(ChannelNr));
# Line 94  namespace LinuxSampler { Line 105  namespace LinuxSampler {
105          if (!UsesExternalBuffer) free(pBuffer);          if (!UsesExternalBuffer) free(pBuffer);
106      }      }
107    
108        /**
109         * Copies audio data (unmodified) from this AudioChannel to the given
110         * destination AudioChannel.
111         *
112         * @param pDst    - destination channel
113         * @param Samples - amount of sample points to be copied
114         */
115        void AudioChannel::CopyTo(AudioChannel* pDst, const uint Samples) {
116            memcpy(pDst->Buffer(), Buffer(), Samples * sizeof(float));
117        }
118    
119        /**
120         * Copies audio data from this AudioChannel to the given destination
121         * AudioChannel and applies the given volume coefficient to the
122         * destination audio signal.
123         *
124         * @param pDst    - destination channel
125         * @param Samples - amount of sample points to be copied
126         * @param fLevel  - volume coefficient to be applied
127         */
128        void AudioChannel::CopyTo(AudioChannel* pDst, const uint Samples, const float fLevel) {
129            if (fLevel == 1.0f) CopyTo(pDst, Samples);
130            else {
131                float* pSrcBuf = Buffer();
132                float* pDstBuf = pDst->Buffer();
133                for (int i = 0; i < Samples; i++)
134                    pDstBuf[i] = pSrcBuf[i] * fLevel;
135            }
136        }
137    
138      std::map<String,DeviceRuntimeParameter*> AudioChannel::ChannelParameters() {      std::map<String,DeviceRuntimeParameter*> AudioChannel::ChannelParameters() {
139          return Parameters;          return Parameters;
140      }      }

Legend:
Removed from v.319  
changed lines
  Added in v.1004

  ViewVC Help
Powered by ViewVC