Sign in to follow this  

SDL_Mixer can't open wav

This topic is 679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi guys,

 

I've been following a tutorial on playing music in C++ with sdl_mixer, the program builds fine but when run I always get the error that the music couldn't load. I have copied test.wav into the project directory, is there something I am missing? Any help is appreciated

#include <iostream>
#include <SDL.h>
#include <SDL_mixer.h>
#include <stdio.h>
#include <string>


 Mix_Music *gMusic = NULL;

 Mix_Chunk *gScratch = NULL;
 Mix_Chunk *gHigh = NULL;
 Mix_Chunk *gMedium = NULL;
 Mix_Chunk *gLow = NULL;

bool loadMedia();


int main( int argc, char *argv[] )
{
    loadMedia();
    Mix_PlayMusic( gMusic, -1 );
    int a;
    std::cin >> a;
    return 0;
}

bool loadMedia()
{

     bool success = true;


     if( Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 ) < 0 )
     {
         printf( "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError() );
         success = false;
          }



      gMusic = Mix_LoadMUS( "test.wav" );
       if( gMusic == NULL )
        {
             printf( "Failed to load beat music! SDL_mixer Error: %s\n", Mix_GetError() );
       success = false;
       }
}

Share this post


Link to post
Share on other sites

it kept saying the printf error - ( "Failed to load beat music! SDL_mixer Error: %s\n", Mix_GetError() );

 

I tried an mp3 instead (which required I also put smpeg2.dll in the directory) and it worked, which as I say is better for me anyway

Share this post


Link to post
Share on other sites

This topic is 679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this