Thursday, June 22, 2017

PlaySound() and SND_FILENAME

Two big things I found out today about PlaySound() when you use it with the SND_FILENAME flag:
1. It only accepts .wav files.
2. The bitrate can't be too high. (file size can be in MB's, as I've tried, but bitrate is still big limiter)

The documentation does say the sound specified "must fit into available physical memory", but I thought that meant file size. It actually meant bit rate. I tried a "Chicken Sound.wav" (wanted to try something funny when I was trying this function for the first time). 67 KB, should've been no problem, but I was really confused/frustrated when I was only getting default beeps. 67 KB sounded really small, at least to me.

I tried a bear sound from WavSource.com, "bear_growl_y.wav". (It was listed as "Bear growl 12KB" here.) 48.9KB. And it worked. Even more confused.

I thought about it, checked the bit rate, and guessed how the huge difference in bitrate was causing the bear growl wav to play but not the chicken sound wav.

bear_growl_y.wav -> 88 kbps || Chicken Sound.wav -> 705kbps 


I exported a new wav of the chicken sound in Audacity in lower bitrate, and it worked. Found the details at superuser. I set the Project Rate in the bottom left corner to 8000 HZ, and exported to "WAV (Microsoft) signed 16-bit PCM".

Again, quite confusing what they meant by "available physical memory". Wish they could've noted that part in. Anyways, happy it's working now.

No comments:

Post a Comment