So, I just started learning C++ (coming from Java, primarily), and as a learning project I've built a snake game with ASCII graphics. I wanted to add simple sound to my game using window's Beep() function, and for the most part it works. However, short beeps (100ms or less) do not play. Ex:
1 2 3
int middleC = 261;
Beep(middleC,100); //I just hear a bit of static and beep doesn't fully start
Beep(middleC,200); //Beep plays fine, though is preceded by same static
I'm on Windows 10, running an Acer Aspire E15.
Curious if anyone has similar problems.
While I realize this may be a hardware issue, I'm curious if anyone has any insight.
Not that I have used Beep() much, but it did work fine on my Dell Toshiba running Windows 10 and using VS 2015.
My first though was that 261 may have been to low of a frequency, but that did not hold true. So, maybe it is a hardware issue with your computer. I am not familiar with your type of computer, so I can not say what might be happening.
If you have not tried this yet, use some higher frequency numbers and see what happens. Or try a for loop with the last parameter as "i += 25" for a quicker step through the loop and see what happens.
After some more experimentation, I find it to be kind of random on my system. Sometimes it'll initiate the beeps early and play even the short ones, other times anything under 100ms or so won't play at all. I guess it's just a hardware thing.
Changing the frequency doesn't appear to help much either.