CLAM-Development
1.1
|
00001 #include "AudioSource.hxx" 00002 #include "ProcessingFactory.hxx" 00003 #include "Audio.hxx" 00004 00005 namespace CLAM 00006 { 00007 namespace Hidden 00008 { 00009 static const char* metadata[] = { 00010 "key", "AudioSource", 00011 "category", "Audio I/O", 00012 "description", "AudioSource", 00013 "icon", "source.svg", 00014 "embedded_svg", "source.svg", 00015 0 00016 }; 00017 static FactoryRegistrator<ProcessingFactory, AudioSource> reg = metadata; 00018 } 00019 00020 bool AudioSource::Do() 00021 { 00022 CLAM::Audio& so=mOut.GetAudio(); 00023 CLAM_DEBUG_ASSERT(mFloatBuffer, "No float buffer"); 00024 CLAM_DEBUG_ASSERT(!mDoubleBuffer, "There should not be double buffer"); 00025 CLAM_DEBUG_ASSERT(mBufferSize>0, "internal buffer size must be greater than 0"); 00026 CLAM::TData * audioBuffer = so.GetBuffer().GetPtr(); 00027 for (unsigned i=0; i<mBufferSize; i++) 00028 audioBuffer[i] = mFloatBuffer[i]; 00029 mOut.Produce(); 00030 return true; 00031 } 00032 00033 void AudioSource::SetExternalBuffer( float* buf, unsigned nframes) 00034 { 00035 mFloatBuffer = buf; 00036 mBufferSize = nframes; 00037 mDoubleBuffer = 0; 00038 mOut.SetSize(nframes); 00039 mOut.SetHop(nframes); 00040 } 00041 void AudioSource::SetExternalBuffer( double* buf, unsigned nframes) 00042 { 00043 mDoubleBuffer = buf; 00044 mBufferSize = nframes; 00045 mFloatBuffer = 0; 00046 mOut.SetSize(nframes); 00047 mOut.SetHop(nframes); 00048 } 00049 00050 } //namespace CLAM 00051