Hi everybody,
I'm new in DS programming, and I want to create a synth with maxmod. The idea is to stream sinus, triangle and square waveforms to create sound (like Moog synths if you know them).
I downloaded and ran the code found here, it works on my DS, but I don't understand how the buffer is working...
Can I fill the buffer with a period of a square (like this one but with one single period: ) ?
Does the size of the buffer will change the sound i'll hear if I stream this buffer ?
And in what direction do I write the buffer and I read it ?
Thanks for your help.
Ben
Question about streaming
Moderator: eKid
Re: Question about streaming
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:
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:
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.
when you open the stream in maxmod, you have to provide a callback:
Code: Select all
mystream.callback = on_stream_request;
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;
}
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.Does the size of the buffer will change the sound i'll hear if I stream this buffer ?
Who is online
Users browsing this forum: No registered users and 0 guests