• Advertisement
Sign in to follow this  

SDL_mixer: Current point in music?

This topic is 1883 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

I am using SDL with C. Instead of editing my audio to fit the game, I would like to edit the game to fit the audio. I know there is a way to jump to a certain point in an audio file (using Mix_SetMusicPosition), but how do I tell the length of the music and the current position? I would like to do something like this:[code]if(Mix_MusicLength()-Mix_MusicPosition()<=3) Mix_SetMusicPosition(0);[/code]To say that if the music position is three seconds from the end, skip to the beginning. I would edit my audio files, but the program I am exporting music compositions from adds a precise number of seconds to the end of each file. Instead of having to remove this and try with trial and error to get the looping set up properly again each time, I would like to just edit my music playing system in my project to ignore the last three (or whatever number I specify) seconds of the music.

If there is a better way to do this, please share. Thank you!

Share this post


Link to post
Share on other sites
Advertisement
If your audio files have a constant bitrate, you can find that from a alen member (see Mix_Chunk).

Share this post


Link to post
Share on other sites
I am using Mix_Music for this instead of Mix_Chunk. I tried music.alen, but that doesn't work. Is there an alternative to this so using Mix_Chunk for my music is not necessary? Thank you for your response!

Share this post


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

  • Advertisement