Hi all,
After watching Day 9 I decided to modify Casey's sine wave generator so that it plays a tone continuously as long as the F key is held down. Like a synthesizer, the sound will stop playing when F is released. I got it working, however there is a weird issue. When F is first pressed it makes a brief click sound after about 0.5 secs, but after that there is no more clicking. The click occurs only the first time F is pressed, on successive presses there is no click! I have no idea how to troubleshoot this but I'd love to know what might be causing the click!
I have posted the entire win32handmade.cpp file to
gist.github.com:
https://gist.github.com/mrennix/60384f0e86a655ba8180fa8a6c7cb3ca
If someone could download and compile the file and test it, that would be awesome. It compiles cleanly on /W4.
I have also made these other changes to Casey's code in case you are wondering:
1. I use Unicode (defines at top of file, so some lib calls use W instead of A versions).
2. For Directsound I don't stream, I just fill the buffer with 1 second of sine wave data and then play from the beginning each time F is pressed. The buffer is not modified during the game loop. I did this to simplify my understanding of how Directsound works.
3. I added a simple log file that logs to a file in the current directory, showing if Xinput and Directsound initialized ok.
Thanks guys!