AudioSink.cxx

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

Generated on Tue Aug 12 22:33:42 2008 for CLAM by  doxygen 1.5.5