0
0

Hi, I have been reading some other posts about this and even came a across the usefull description of using the DSP functionality to generate tones, but my program is going to run better if I can create the sounds like in the usercreatedsounds example. Here’s what my callback function looks like.

[code:28v35qh9]static float x1 = 350.0f6.28f/SAMPLE_RATE;
static float x2 = 440.0f
6.28f/SAMPLE_RATE;
signed short *stereo16bitbuffer = (signed short *)data;

for (count=0; count<datalen; count++) {
stereo16bitbuffer++ = (signed short)(((sin((float)(countx1)) + sin((float)(countx2)))32767.0f)/2);
}
[/code:28v35qh9]

I changed the number of channels from 2 to 1, and in the loop there, it loops datalen times, as opposed to half that. Now correct me if I am wrong, but isnt this the same as what is done in the example but with mono sound instead? because I dont see why this is crashing when I try it.
I had these values working in stereo, but my program may require more than 2 tones to be combined for the sound. So I just want to add them together and divide by however many there are for each sample.

  • You must to post comments
0
0

oops, I figured it out, it needs to be datalen/2 for the limit in the for loop.

note to self, (datalen>>2) != (datalen/2)

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.