I'm using Microsoft Visual C++ 2008. How would i play a sound file? Either .wav, .mp3, or .midi hopefully.
nokeekon
0
Newbie Poster
Recommended Answers
Jump to Postyou can use SDL_mixer http://www.libsdl.org/projects/SDL_mixer/
Jump to PostIf you want a good deal of control over the sound, you might want to consider DirectSound (though using it can be very annoying and complex). If not, I believe there is a simple Windows function that you can use to play sounds asynchronously, but I can't remember it on …
Jump to PostSDL_mixer program playing music.mp3
#include <SDL/SDL_mixer.h> int main(int argc, char **argv) { setbuf(stdout, 0); setbuf(stderr, 0); if (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 4096) != 0) { fprintf(stdout, "Unable to initialize audio: %s\n", Mix_GetError()); exit(1); } Mix_Music *music = Mix_LoadMUS("music.mp3"); if (!music) { printf("Mix_LoadMUS(\"music.mp3\"): %s\n", Mix_GetError()); exit(1); } if (Mix_PlayMusic(music, …
All 11 Replies
ivailosp
11
Junior Poster
CoolGamer48
65
Posting Pro in Training
ivailosp
11
Junior Poster
nokeekon
0
Newbie Poster
CoolGamer48
65
Posting Pro in Training
nokeekon
0
Newbie Poster
marco93
-87
Junior Poster
mitrmkar
1,056
Posting Virtuoso
CoolGamer48
65
Posting Pro in Training
nokeekon
0
Newbie Poster
CoolGamer48
65
Posting Pro in Training
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.