20 Jun '13 - 00:23 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Question about dummy streams  (Read 327 times)
nadia
Posts: 273


« on: 30 Dec '11 - 14:21 »
Reply with quoteQuote

Hello  Grin

I know that when a stream has been created through the BASS_StreamCreate having the STREAMPROC_DUMMY flag set, it will be possible to apply FX and DSP effects to an audio buffer through the BASS_ChannelGetData function. I was wondering if in the same situation it would be possible to calculate FFT data of the audio buffer using the same call to the BASS_ChannelGetData function and the appropriate flag (for example BASS_DATA_FFT2048).

If this shouldn't be possible, which would be the fastest solution to calculate the corresponding FFT on the audio buffer?

Thanks and Happy 2012  Grin

Nadia
Logged
Ian @ un4seen
Administrator
Posts: 15366


« Reply #1 on: 30 Dec '11 - 16:43 »
Reply with quoteQuote

The FFT processing uses a separate buffer for the sample data rather than the user-provided buffer because a different amount of sample data may be required. For example, a 2048 sample FFT performed on a stereo 16-bit stream will require 8192 bytes (2048x2x2) of sample data, while the FFT result (and therefore the user-provided buffer to receive it) will only be 4096 bytes (1024x4). So the FFT processing gets data from the source into a temporary buffer and then performs the FFT and places the result in the user-provided buffer. Dummy streams don't provide any data of their own, so FFT processing doesn't work properly with them, ie. the FFT processing doesn't get any data from the dummy stream and it's left to process whatever randomness is sitting in the temporary buffer Smiley

You could instead use a push stream, ie. give it the sample data via BASS_StreamPutData and get back the FFT data from BASS_ChannelGetData. It could look something like this...

fftstream=BASS_StreamCreate(freq, chans, BASS_STREAM_DECODE, STREAMPROC_PUSH, 0); // create push stream with same format as the sample data

...

// perform 2048 sample FFT
BASS_StreamPutData(fftstream, data, 2048*chans*2); // feed sample data to the push stream
float fft[1024];
BASS_ChannelGetData(fftstream, fft, BASS_DATA_FFT2048); // get back the FFT
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines