You can indeed fill the buffer with "square waves". But well let me explain what happens:
when you open the stream in maxmod, you have to provide a callback:
Code: Select all
mystream.callback = on_stream_request;
Maxmod will call this callback function to get some new samples. So essentially what this function should do, is giving maxmod new samples to play.
So a simple callback which writes zeroes could look like:
Code: Select all
mm_word on_stream_request( mm_word length, mm_addr dest, mm_stream_formats format ) {
s16 *outBuf = dest; // Maxmod passes a pointer to a buffer you should write to
/* We'll write the requested amount of samples to this buffer.
* This should be done in an upward direction
*/
int len = length;
for( ; len; len-- )
{
/* This function simply writes zeroes, you should add your own code to write squares here */
*outBuf++ = 0;
}
/* You should return the amount of samples you've written, that doesn't have to be equal to length,
* it could be less
*/
return length;
}
I don't know what the minimum buffer size is (that maxmod can handle), so you may not be able to write one period of your square wave. This shouldn't be a big problem though as you can write multiple square waves in the callback.
Does the size of the buffer will change the sound i'll hear if I stream this buffer ?
Yes it can change the sound you'll be hearing. If an underrun occurs (the samples aren't written fast enough to the buffer), you'll hear noise. When I was streaming OGG files with maxmod, my initial buffer was too small and that caused maxmod to run out of samples before I could write new samples.