Jump to content
  • Advertisement
Sign in to follow this  
Decrius

[SDL] SDL_sound does not work...?

This topic is 4089 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, When trying this piece of code from a tutorial:
#include "SDL_sound.h"

int main(int argc, char **argv)
{
    Sound_MixInit(NULL);  // start the mixer; don't care what format.
    Sound_Sample *hello = Sound_NewSampleFromFile("hello.wav", NULL, 10240);
    Sound_MixPlay(hello);
    while (Sound_MixPlaying(hello))
        SDL_Delay(100);  // wait around; mixing is in a seperate thread!
    Sound_FreeSample(hello);
    Sound_MixDeinit();
    return(0);
}
I get these errors (CodeBlocks, Windows XP): F:\C\sound\main.cpp:: In function `int SDL_main(int, char**)': F:\C\sound\main.cpp:49: error: `Sound_MixInit' undeclared (first use this function) F:\C\sound\main.cpp:49: error: (Each undeclared identifier is reported only once for each function it appears in.) F:\C\sound\main.cpp:51: error: `Sound_MixPlay' undeclared (first use this function) F:\C\sound\main.cpp:52: error: `Sound_MixPlaying' undeclared (first use this function) F:\C\sound\main.cpp:55: error: `Sound_MixDeinit' undeclared (first use this function) :: === Build finished: 5 errors, 0 warnings === (different line numbers because I tried it in a SDL project of CodeBlocks itself, which includes some libraries and headers automaticly + drawing a .bmp onscreen) What could be the problem? What other header files do I need? Thanks! Decrius PS: This forum really needs a seperate SDL help forum! :) Lots of SDL posts in here.

Share this post


Link to post
Share on other sites
Advertisement
First I would suggest using [ some source tags] when writing code, and errors out just hit reply for this message to see how it is done


#include "SDL_sound.h"

int main(int argc, char **argv)
{
Sound_MixInit(NULL); // start the mixer; don't care what format.
Sound_Sample *hello = Sound_NewSampleFromFile("hello.wav", NULL, 10240);
Sound_MixPlay(hello);
while (Sound_MixPlaying(hello))
SDL_Delay(100); // wait around; mixing is in a seperate thread!
Sound_FreeSample(hello);
Sound_MixDeinit();
return(0);
}









Quote:
I get these errors (CodeBlocks, Windows XP):



F:\C\sound\main.cpp:: In function `int SDL_main(int, char**)':
F:\C\sound\main.cpp:49: error: `Sound_MixInit' undeclared (first use this function)
F:\C\sound\main.cpp:49: error: (Each undeclared identifier is reported only once for each function it appears in.)
F:\C\sound\main.cpp:51: error: `Sound_MixPlay' undeclared (first use this function)
F:\C\sound\main.cpp:52: error: `Sound_MixPlaying' undeclared (first use this function)
F:\C\sound\main.cpp:55: error: `Sound_MixDeinit' undeclared (first use this function)
:: === Build finished: 5 errors, 0 warnings ===







Well usually when you get the errors of undeclared function this or that it is probably either you are not referencing the header file correctly, or it doesn't exist.

So, I looked at the latest SDL library that I have and the only one I saw is SDL_audio, and I do for reasons of playing sound have SDL_mixer which can be found

Here

here is a tutorial that can teach you very basic functions in SDL_mixer using SDL how to load up audio files, and play them hope this is helpful for you.
here

Hope this was helpful!

If you ever need help, or would like to start a project with me. Please feel free to contact me

IM: finch17@hotmail.com
Email: cfinch86@gmail.com

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!