SDL_mixer: Current point in music?

Started by
1 comment, last by Tolito 11 years, 5 months ago
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:if(Mix_MusicLength()-Mix_MusicPosition()<=3) Mix_SetMusicPosition(0);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!
Advertisement
If your audio files have a constant bitrate, you can find that from a alen member (see Mix_Chunk).
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!

This topic is closed to new replies.

Advertisement