Audio Signal Processing using Directshow(ISampleGrabber) - 2
-
Hello , I wanted to re-ask my previos question , since I made some progress. And I want to clear some stuff in my head. 1. BUFFERING "STEREO" STREAMS : I use the code below . Generally 8000 bytes passed to callback function. Since my each sampleis 16bit , that is about 4000 samples for each call. So I defined CHANNEL_SIZE as 2048 which is approriatefor total sample count. I made it 2048 as power of 2 because I will implement FFT . What do you think about that buffering approach ? ................................................. #define CHANNEL_SIZE 2048 double leftChannel[CHANNEL_SIZE] ; double rightChannel[CHANNEL_SIZE] ; .................................................................. STDMETHODIMP BufferCB( double SampleTime, BYTE * pBuffer, long BufferSize ) { unsigned int nSampleCount = BufferSize/2 ; short* pStream = (short *) pBuffer ; for( i = 0;i<nSampleCount/2 ; i++) { leftChannel[i] = ((double)(*pStream)) ; pStream++ ; rightChannel[i] = ((double)(*pStream)) ; pStream++ ; } } 2. MULTITHREADING : Can you compare using sample grabber and creating threads for signal processing for performance (especially CPU usage ) ? In my first approach , I created thread for FFT since my FFT task didnt include changing samples , it was just about spectral analysis. 3. DATA FORMATS, CONVERSIONS : I get my each sample as 16 bit. When I looked some DXSDK9 audio samples , they declare "signed" shorts for samples. So I am confused about declaring sample variables as signed , since they can store negative values. Also I have question marks about getting double or float values from shorts , and replacing shorts with new floats or doubles after making some signal processing. I can understand dividing short values by 32768(2^16 / 2 ). But what about "vice-versa" ? Thank you very much for reading, BEST REGARDS, Akin Ocal