Playing raw audio samples
-
How do I? Or, to be a little more precise, I would like to suck homemade audio samples from an buffer (e.g., noise might be a gaussian distribution of integers between + -32K)and feed them at the right rate to a soundcard (audio device) for real-time play. (I'm not trying to play an existing, saved wav file.) A simple application would be a VCO (oscillator with a slider controlling the frequency). In the .net world, is this done by DirectX? By the WINAPI? wavePlay? Magic? Not at all? Background note: a wavetable might contain one complete waveform of a sample, and the buffer might have as many repetitions of the sample as maching performance allows.
-
How do I? Or, to be a little more precise, I would like to suck homemade audio samples from an buffer (e.g., noise might be a gaussian distribution of integers between + -32K)and feed them at the right rate to a soundcard (audio device) for real-time play. (I'm not trying to play an existing, saved wav file.) A simple application would be a VCO (oscillator with a slider controlling the frequency). In the .net world, is this done by DirectX? By the WINAPI? wavePlay? Magic? Not at all? Background note: a wavetable might contain one complete waveform of a sample, and the buffer might have as many repetitions of the sample as maching performance allows.
Have a look at my article http://www.codeproject.com/useritems/nBASS.asp[^]. That is one feature I havent tested yet, but the BASS API can do that. (just had a look, and I havent done that yet :( havent had a need really, but you can load from a short[](16-bit) and play that. It is something I have been playing with recently, so it mite not be in the version on CP. Give me shout if its not there. Look for these functions:
nBASS.BASS.LoadStream
that takes a short[] as a parameter. Cheers :) PS: If you can mail me a "RAW" audio file, I will try make it work. :) Before you criticize a man, walk a mile in his shoes. That way, when you do criticize him, you'll be a mile away and have his shoes.