-
SDL sound.
Code:
void AudioCallback(void *userdata, Uint8 *buffer, int len)
{
for(int index = 0; index < len; index++)
buffer[index] = rand()%256;
}
That function fills the soundbuffer with random noise but what I do not understand is why
nothing can be heard at all if I change rand()%256 to always be, 205 for example, any suggestions?
In other words I can't hear any sounds if the whole buffer contains the same value.
-
Same value means that the speaker will be at that deflection for the entire time. You will hear one pop when the speaker moves and then nothing. Sound is created by the speaker mimicing the crests and valleys of the wave. In your case you don't have one.
No vibrations=no sound.
-
Well if you are using SDL simply because it is easier and allows you to skip the low-level DirectX stuff that you don't understand or care to take the time to then you are using it for the wrong reason.
If you are using it because you understand the low-level stuff
but want to focus more on your game, then you are using it as a tool instead of a scapegoat
If you use SDL for the wrong reason know that it will catch up to you and you will code yourself into a corner. Learn the APIs then decide on your tool of choice. Anything else is flying blind.
Instead of SDL for Direct3D I would use the Microsoft provided Direct3D framework. It will help you with the nitty gritty and will help you understand how it all works. Eventually you will probably code your own DirectX wrapper classes. As always if you code it, you know what you need and you can tailor it to your needs. If you are using someone else's code, it may not be exactly tailored to your specific needs.
-
How do you know he is using SDL to set up D3D? BTW: SDL_Mixer or even the standard SDL audio functions are the worst. Try another.
-
The truth is that i'm a complete newbie when it comes to game programming and I simply thought that an SDL book could be a good start, I'm reading Focus On SDL by Ernest Pazera.
I do plan to learn more about the low level stuff but not atm. I don't know but maybe it would be better to do it the other way around and start with the scary stuff.
Anyway thanks for your replies, now I see the logic in why I didn't hear much at all.
-
SDL is fine to learn with. Ignore what I said about the audio functions if your just learning. Keep reading about SDL. I just started reading a DX9 book but I have put that on hold for the moment because I have a new GP2X on order. I plan on developing for it so I'm back to using SDL again.
-
Yeah, I'll do just that (keep reading), I've seen one of those GP2X and they seem really nice.