I've wasted 5 hours trying to figure out how to implement sound in my C++ program.

Started by
27 comments, last by boogyman19946 12 years, 11 months ago

[quote name='EDEV' timestamp='1305393214' post='4810751']
[quote name='boogyman19946' timestamp='1305393130' post='4810748']
TEXT() is a macro so it should stay like it is :) yourfile.wav I imagine is the path to the wav file so you should replace it with the directory.


Alright, I tried following this guide:

http://sfml-dev.org/....6/start-vc.php

To add a library to the project, but when I go there it says its been deprecated and now its in a user sheet....

What the heck does that mean?!
[/quote]

http://ctp.social.ms...02-998bb6747829 This should be more helpful.

I believe you can open the project properties by right-clicking on your project and selecting the properties option from the drop down menu (I don't know how 2010 is organized. I'm trying to install it atm)
[/quote]

Okay followed that guide and added winmm.lib in the linker...

When I compile I get this:

1>c:\users\edgar\documents\visual studio 2010\projects\test\test\test2.cpp(75): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\users\edgar\documents\visual studio 2010\projects\test\test\test2.cpp(108): error C2065: 'SND_FILENAME' : undeclared identifier
1>c:\users\edgar\documents\visual studio 2010\projects\test\test\test2.cpp(108): error C3861: 'PlaySound': identifier not found
1>c:\users\edgar\documents\visual studio 2010\projects\test\test\test2.cpp(108): error C3861: 'TEXT': identifier not found
1>c:\users\edgar\documents\visual studio 2010\projects\test\test\test2.cpp(1065): warning C4390: ';' : empty controlled statement found; is this the intent?


Do I have to type something in the beginnign like #include <winmm>?
Advertisement
You should have #include <Windows.h> according to MSDN.

Yo dawg, don't even trip.


You should have #include <Windows.h> according to MSDN.


Alright well that's progress, the program started, but no sound...hmmm...
I GOT IT WORKING!!!!

OMG THANK YOU ALL SO MUCH!!!

I appreciate all your patience and help with a complete C++ noob, you guys helped and responded much faster than I expected! I finally feel like I am understanding libraries.

Thanks for everything!

That being said...I have another problem...of course. XD

The song plays, but the program does not continue running, I want the song to run in the background while the game continues...right now it seems to stop...play the whole song, then move on.

Anyone know what I can do about that?
You have to pass SND_ASYNC as the last argument according to the good ol' MSDN. :D

EDIT: I realized you're passing SND_FILENAME as well. You'll have to use the binary OR operator and pass SND_ASYNC | SND_FILENAME as argument.

Yo dawg, don't even trip.


You have to pass SND_ASYNC as the last argument according to the good ol' MSDN. :D

EDIT: I realized you're passing SND_FILENAME as well. You'll have to use the binary OR operator and pass SND_ASYNC | SND_FILENAME as argument.


It's working, JUST AS I HAD HOPED!!!

THANKS TO EVERYONE WHO HELPED! You just took a frustrated noob C++ programmer and made him a very happy one. :D

This is a very helpful and friendly site, I will be sure to come here for help and discussion from now on.

Thanks again!!! I seriously was thinking about giving up on getting working sound...and almost C++....I feel reinvigorated! :D
No problem. That's what we're here for :)

Yo dawg, don't even trip.

Ah the joys of learning to program. Utter frustration followed by a EUREKA! moment. It's what keeps the profession interesting, I doubt accountants yell EUREKA! when they balance a spreadsheet, do they? :D

Glad to have helped, good luck.
Haha, yes, those moments where I want to rip my hair out and then suddenly find the simplest solution which makes me do a mario jump is what keeps me going in this nerve wracking activity called programming :D

Yo dawg, don't even trip.

This topic is closed to new replies.

Advertisement