Shoutbox

What is the best way to play sounds using C++? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: What is the best way to play sounds using C++? (/showthread.php?tid=18278)

What is the best way to play sounds using C++? by RaceProUK on 11-18-2003 at 12:28 AM

I want to write a small family of similar Msg+ plugins, all of which play sounds based on commands. Each plugin will have a different set of sounds.

At the moment, I am playing with a small, one-sound plugin, which will form the basis of the others. When I exclude the code to play the sound, the plugin compiles and runs correctly. However, when I use the PlaySound() function, it won't compile, even though I have got all the correct #include's as specified by the VC++6 online documentation and MSDN. I keep on getting error LNK2001.

Am I doing the right thing? Or should I use a different method? I can post the function call, complete with arguments, if that'll help.


RE: What is the best way to play sounds using C++? by optimism_ on 11-18-2003 at 09:39 PM

Link errors: are you linking to the right library as well? check the docs for PlaySound as to which lib this would be


RE: What is the best way to play sounds using C++? by RaceProUK on 11-18-2003 at 10:50 PM

I'm sure Im using the correct header files, as specified in the VC++ documentation, and the MSDN. However, I just cannot get it to compile. Have you got any tricks or hacks to get it to work properly?


RE: What is the best way to play sounds using C++? by optimism_ on 11-18-2003 at 10:53 PM

not just the header files, the libraries as well. as far as i recall, you set these in project options (alt+f7) on the linker tab - the name of the lib to use will be in the docs at the same place as it says what headers to use


RE: What is the best way to play sounds using C++? by RaceProUK on 11-18-2003 at 11:04 PM

Bloody documentation.

Thanks: I've not used VC++ much: in fact, I've only just started using it so I can write the plugins I want to write. I would have used Visual Basic, but plugins vreated using VB require a fancy installation or they won't work.

(Note to self: RTFM!)

EDIT: Pity you can't do a /sdoh in the forum :D


RE: What is the best way to play sounds using C++? by Patchou on 11-19-2003 at 02:18 AM

from memory.. try
#pragma comment(lib, "winmm.lib")

it should help :)
Patchou


RE: What is the best way to play sounds using C++? by optimism_ on 11-19-2003 at 08:41 AM

if it doesnt, go to the project settings (alt+f7) linker tab and add winmm.lib (?) to the list of thinks like user32.lib etc


RE: What is the best way to play sounds using C++? by RaceProUK on 11-19-2003 at 03:24 PM

Adding winmm.lib to the link list in the (alt-f7) dialog worked, but now I just have to figure out how to use pointers properly. Hopefully, I'll have the first of the plugins ready by the end of the month.