Handmade Hero»Forums»Code
8 posts
Hobbyist programmer, focused on making games. Thinking about what "handmade" means for my own code.
Sound Code fading to silence through HDMI
Edited by SteelGolem on Reason: update
I've gotten to the point where we got our sound buffer working and we're filling it with a square wave, but I have this odd behavior: The volume fades to zero over about 5 seconds! I went over the code, and even tried replacing my win32_handmade.cpp with day008 archived CaseyCode to be absolutely sure, and I get the same result.

It's worth noting that I have two audio devices - the standard PC line-out, as well as my HDTV's audio over HDMI. When I switched default audio to standard PC, there's no issue, it works as expected. Does anyone have any clue why this might be happening? I would say it's an issue if the sound code is acting up in this way.

UPDATE:
The code for day009 doesn't have the audio fading problem over HDMI. Talk about wierd!
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Sound Code fading to silence through HDMI
That is very odd! I have no idea why that would be happening, although admittedly there are often driver problems with HDMI audio. This doesn't sound like what a driver bug typically looks like, though...

- Casey
Sound Code fading to silence through HDMI
Try (pseudo)randomizing the wave. In the for loop for generating a square wave, randomize all the variable every time you enter an iteration of the loop. It shouldn't affect the performance too much (there are some good RNGs in the standard library).

I suspect the unvarying nature of the wave may be triggering a 'This is static so I'm going to remove it' response from one of the Audio Devices. Probably not, but well worth a try.