Tuesday, March 29, 2011

Sound 2

I've looked into SDL and CSound (thanks, Matt) but I think I'll just DL the Windows SDK and try to use the PlaySound() function. I need a .lib file that doesn't come with Windows.

I'm genuinely surprised that playing sound is this hard. Yes, I know it's tough to manage bit depth, voltage range, sampling rate, etc, but I'd have figured there would be "one way" to just get a sound out with minimal difficulty. Maybe Linux/OSX is simpler, but I need to stay in Windows-land for this project.

EDIT: I have had some success.

PlaySound("C:\\Program Files (x86)\\Steam\\resource\\warning.wav", NULL, SND_FILENAME);

I had to download the Windows SDK to link the file WinMM.lib (which must have the PlaySound implementation in it).

Ok, good. Now what? I have no idea if this will be fast enough to do what I need it to do. I'll have to generate a very tiny impulse - like a square wave 100 uS wide. Ok. Crap, I hate making such progress this late at night. It's past 10PM already and I'm trying to go to bed at a reasonable time so that I can get up early and go for a run. Healthy body healthy mind, right?

EDIT 2: I will write up a quick how-to on this topic. It's like three lines of code but NOBODY ON THE FREAKING INTERNET has written how to do what I just did succinctly and accurately.

No comments:

Post a Comment