I'm doing a project that require the user to type in the phonetic sounds

for example, "th". then the program will play a wave file that produce th sounds.
As there are many different wave files for a phonetic sounds, i decided to group them into separate files, which means it would not be in the same folder of the .exe directory. In this case how do i play the sound that is from another file?

Here is the segment that i thought could work but it didnt.. please help me!

FILENAME1 = strcat(text_data, ".wav");
FILENAME2 = strcat("wav" ,FILENAME1);
printf ("%s", FILENAME2);
PlaySound(TEXT(FILENAME2), NULL, SND_SYNC);

The text_data contains what the user type. such as "th". so it will play the wave file. th.wav. Is it possible to play it from another folder? so i can group various wav files into categories.

so it will be somthing like this:;

... ... Debug (contains the .exe file) --> consonants --> th.wav (this is the one i want to play but it will not be in the same directory as the .exe file.

please help me. thanks a lot!

Recommended Answers

All 3 Replies

this is on done on visual studio 2010

FILENAME1 = strcat(text_data, ".wav");
FILENAME2 = strcat("consonants\\", FILENAME1);
printf ("%s", FILENAME2);
PlaySound(TEXT(FILENAME2), NULL, SND_SYNC);

i've changed to this but the .exe when run, still stops working. could anyone help me with this? thank you!

Hello Kenneth!

I believe your problem is that you're not sending a filepath.

Try this:

PlaySound("C:\\user\\desktop\\sound.WAV", NULL, SND_FILENAME | SND_SYNC);

Any luck?

Edit:
Please note:

#include <windows.h>
#include <mmsystem.h>

is required. It is also neccesary for wimm.lib to be in your project library path if you haven't already.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.