The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_mixer get music play-time
Iron_Attorney


Joined: 17 Sep 2015
Posts: 5
Hi there SDL folks, this is my first post!

If I am playing a wav file, is there a way using SDL to find out how far through it is? I have looked through the documentation, including SDL_mixer docs as I am using that for wav playback, and the closest candidate I can find is the Mix_HookMusic functions. My guess would be that you set up a custom music player with HookMusic and then retrieve the play-time using GetHookMusicData.

I'm struggling to tell from the docs if that is what GetHookMusicData actually does, and I'm struggling even more to get either of these functions to work. So, is this actually what I want? Or would I be better off acquiring the help of a separate audio library?

Incase anyone happens to have any advice on music libraries to look at, I just need the functionality to play 2 wav files simultaniously and to retrieve the play-times to help me keep the timings tight... and must be cross-platform.

Thanks in advance for any help!

Pete
Iron_Attorney


Joined: 17 Sep 2015
Posts: 5
Hi, sorry to bump this, but it's been a good while, and I'm still none the wiser on this. I'll maybe simplify my requests though, save reading through my whole previous message:

1. Using SDL mixer, I want to have some way of knowing how far through my audio playback is so I can start a different piece of music at a specific time, without waiting for the first piece to finish. I want to know if the HookMusic functions are capable of this.

2. If they are, does anyone have a good simple example? The one in the docs is mighty confusing!

Thanks in advance, Pete
MrTAToad


Joined: 13 Feb 2014
Posts: 205
Location: Chichester, England
It looks as though there isn't an easy way to finding out how far through the music is - you step through a buffer, but you would need to record the initial buffer position and then calculate from that, which would be fiddly.
Iron_Attorney


Joined: 17 Sep 2015
Posts: 5
So I assume that's not possible with the hook functions then?

I may be out of my depth with that kind of caper, but any tips/resources that might help me start such an operation?