CodeBlocks 13.12 adding sound - c++

Hello I just started learning c++, and my teacher wants us to create a game for our final exam.
I am using CodeBlocks 13.12 and can't seem to be able to add any game sound. I just need to play a simple .wav file if you guys could show me how that would look I'd greatly appreciate it.
The teacher made adding sound extra credit because he didn't actually show us how to do that. I have no clue as to how to do it so please show if I have to change anything in the settings.

I haven't worked much with audio files either, but a quick search turned up the following links:
StackOverflow: Playing a wav file
CodeProject: Audio files in c++
It looks that (for Windows at least) you can use
PlaySound
Check out the Windows documentation for PlaySound and make sure to include windows.h!
#include <windows.h>
Note: I should expand on AdamS's comment. CodeBlocks is your Integrated Development Environment (IDE). Your question is specific to the language C++ but not to the IDE CodeBlocks. If your code is correct but you still can't hear the sounds, then it could be an issue with your IDE or your computer.

Related

Configure wxwidgets with Codeblocks

I want to build C++ GUI programs using Codeblocks+Wxwidgets+cmake. I tried to configure Wxwidgets with codeblocks IDE following the instructions given in the wxWidgets Discussion Forum as well as other Youtube tutorials.
I followed the youtube tutorials below.
Youtube tutorial
But, when 'DEBUG' and 'RELEASE' are being built, it keeps showing some kind of errors. As a result, the building was failed.
Please help me to solve this or suggest another easy way to do C++ GUI projects.
Thank you!
There is an excellent document explaining how to set up C::B with wxWidgets. It can be found here.
It is not about CMake-thingy, but it is written with enough details to help people understand how to setup the IDE.
So I suggest to delete C::B, delete wxWidgets, delete all projects you setup before and start all over, following the instructions from PB to a T.
If you hit a wall or something will not work - please comeback with the exact explanation.

How can I open my project in DevC++ to edit its code?

Hi there I am a beginner and I am learning C++ using IDE DevC++
Till now I was just creating simple files by choosing the source file in the upleft corner.
And it was easy to run them and edit them.
But now, for the first time, I have created a project in it. It was a graphics project; it ran well
But now I don't know how to open its code, so I can edit it and make it better.
Hope the problem is clear
Help needed.

Error code 0xc0000135 in Qt Creator with OpenCV

Im a novice coder, that needs to make a simple UI - i've chosen to do it in Qt Creator.
As i need to incorporate a webcam feed, i've been advised to use OpenCV.
I've followed the following guide: https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows
However im running into the problem "Error code 0xc0000135" when i try to debug my code.
I've added the different PATHs to the Enviromental Variables as requested in the guide. Anyone with a kind idea of where the issue might lie, or can it be anywhere in the process?
Cheers!
I am going to suggest that unless you are going to do a lot of computer vision stuff, that you leave OpenCV for the native Qt approach which is QMediaPlayer.
In QtCreator the example is built in, just select "Welcome" -> "Examples" -> "search for video player" -> "select example.
Or if you prefer browsing online, here it is.
If you still want to use OpenCV, please add more details to the question so it is easier to help you!

How to Include a sound clip in a release build

Now that I had some feedback, I see I need to change my question. I would like know how to embed audio into an EXE using console C++ so that anyone can hear the sound when it's on any computer.
At the moment I got a working program that play sounds but the audio file is not embedded in it.
It souldn't be any difference from debug and release mode.

SFML Audio not Working

I was using SFML earlier and I decided to play around with the audio settings. I made an instance of sf::Music and tried to play a sound. However I got an error that came up saying
"The program can't start because openal32.dll is missing from your computer. Try reinstalling the program to fix this problem." I am making this as a project for the Ludum Dare so if this is a common problem I don't really want to have to use this. First off, where do I get openal32.dll? Is this a common problem? And what is an alternative that I can use in c++ for playing audio? Thanks!
OpenAL is an audio API that SFML is using internally. You have to make users install the OpenAL dlls, but the official site appears to be offline. You can try googling for a working link to download the OpenAL package.
You can use OpenAL-Soft instead:
http://kcat.strangesoft.net/openal.html
It also supports HRTF for binaural headphones. You can also package it with your application (LGPL). You might have to rename soft_oal.dll to OpenAL.dll.