Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sndPlaySound works for A.wav not for B.wav

Posted on 2010-09-22
13
Medium Priority
?
1,057 Views
Last Modified: 2013-12-13
Have an app in C++ and I call sndPlaySound to play wav files.   Has worked fine on hundreds
of PCs.  Now I have it on one particluar PC, running windows 7, and my code will play one wave file just fine, but won't play another wav file -- instead emits a little strange beep.  That is,
it plays "A.wav" just fine but won't play "B.wav".  If I go out to windows on this PC and play the
files with the windows media player, they both play fine.  Playing from my code on other PCs they both play fine.  So, its driving me nuts.  What can it be?  Maybe the wav files use different codecs and although windows media player can use both, my app (via winmm.lib) does not have access to one of the codecs?  Just a guess - how can I tell if a differnt codec is in use?
0
Comment
Question by:tullhead
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +2
13 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 33740966
Well I thought it might of been codec but if it plays outside your app, I was not sure that might be the case.
Not sure how winmm.lib works, maybe it does work with certain codecs or possibly format of wav file ie number of bits etc

you can have a look at avicodec to help you determine whats in use http://avicodec.duby.info/
0
 
LVL 5

Expert Comment

by:marcodalzotto
ID: 33741538
As a first thing, I would check the file audio difference between A.wav and B.wav by going on the files properties. There you can find the Audio Format, Bit speed etc... Please post the properties.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 33741598
Are A and B in the same directory?  Put another way is the directory that B is in available (User Access Control) to your app.  (I assume you use the full path to specify which file to play, otherwise check the path is correct as well).



From help files:
Remarks
If the specified sound cannot be found, sndPlaySound plays the system  default sound.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tullhead
ID: 33741604
A.wav that plays from my app:

Bit Rate: 1411 kbps
Audio Sample Size:  16 bit
Channels: 2 (stereo)
Audio Sample Rate: 44 khz
Audio Format: PCM

B.wav that plays in windows but not in my app:

Bit Rate: 177 kbps
Audio Sample Size:  4 bit
Channels: 1 (mono)
Audio Sample Rate: 44 khz
Audio Format: IMA ADPCM

Wow - that was a good suggestion - because I thought they were similar, but they are quite different.
But what does it mean, and is there a way I can get my app to play B.wav -- or should I try to convert format of B to be similar to A ?
0
 

Author Comment

by:tullhead
ID: 33741615
AndyAinscow -- yes I have them both in same directory.  Even renamed them to the identical file name at one point - so that is not the issue...
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33741753
A and B are different: stereo and mono, different bit rate and sample size, different audio format.

B:
"Windows supports IMA ADPCM ".wav" files in 4-bit format only and at sample rates between 8 and 41KHz"
http://www.xentec.be/products/vox_studio/help/ima_adpcm_format.htm
http://wiki.multimedia.cx/index.php?title=IMA_ADPCM
http://www.free-codecs.com/guides/How_to_install_default_codecs_in_Windows_XP_2000.htm

I think, the question is not about MFC or Windows API or a programming language, but about audio codecs.
Maybe it makes a sense to test another wav-file in the same format on this computer.
 
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 33741796
>> If I go out to windows on this PC and play the files with the windows media player, they both play fine.

Odd.  Everything to support 'B' seems to be in place, and the paths to A and B are in order.  Please make certain with the paths not that you have something like the following

PlaySound("C:\mysounds\test\A.wav") and PlaySound("B.wav")

where the system then plays a beep because B isn't being found.



0
 
LVL 5

Expert Comment

by:marcodalzotto
ID: 33742145
0
 
LVL 5

Accepted Solution

by:
marcodalzotto earned 1500 total points
ID: 33742159
Sorry, the the suggestion I gave before, is because I guess you miss the IMA ADPCM codec.
I am not secure but I think Windows Media Player use his own codecs.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33744590
marcodalzotto, you having some personal problems? since you say you are not secure

:D
0
 
LVL 5

Expert Comment

by:marcodalzotto
ID: 33744709
Yep! I do!

My personal problem is that my english is bad, and most of the time I translate italian saying to english!!
Please be patient with me...

:P
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33745100
lol.
0
 

Author Closing Comment

by:tullhead
ID: 33759660
I think the key must be that windows media player must have "its own codecs" rather than relying on codecs that are installed on the PC.  Thats the only explanation that makes sense.  I tried and failed trying to install gobs of codecs, so I reformatted the audio files into a more common (apparently) codec, and now they play everywhere, including the formerly-troublesome computer.
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question