# Track position in looped audio with reduced playback rate?

Get help using Construct 2

### » Fri Aug 28, 2015 9:08 pm

Howdy,

I'm playing an audio track and I have it set to looping. Over the life-cycle of the audio track I also change the audio playback rate at different points.

I need to find out my position in the track during any given loop. I don't think I can use the system PlaybackTime because this just shows the amount of time since the start of the loop. Does anyone have any suggestions on how to achieve this?

Any help would be most appreciated,

Thanks
Last edited by unplugged on Sun Aug 30, 2015 5:07 pm, edited 2 times in total.
B
18
S
4
G
2
Posts: 77
Reputation: 1,588

### » Fri Aug 28, 2015 11:09 pm

just a thought......if you set your audio track to not looping?

B
67
S
24
G
7
Posts: 1,519
Reputation: 11,104

### » Sat Aug 29, 2015 8:29 am

@korbaach, thanks for the suggestion.

I have already tried setting the track to not looping and then restarting it every time it finishes. Unfortunately (on PhoneGap) there's an obvious gap between the end of one track and the start of the next one.

I need seamless looping for the project I'm working on. So I have to find a way to work out how far I am through the track, while it's looping.

Thanks anyway.
B
18
S
4
G
2
Posts: 77
Reputation: 1,588

### » Sun Aug 30, 2015 5:04 pm

Hi again,

I've managed to work out that you can measure your position in a looping audio tack by using modulo. The formula is Audio.PlaybackTime % Audio.Duration.

This works well at a normal playback rate. But I need to reduce tempo of the audio track over time (by changing the playback rate). And unfortunately, as I change the playback rate, it seems to throw the calculation off.

Can any of the maths geniuses out there, provide any ideas on how I can incorporate a changing playback rate into the formula. My rate goes down by a set amount every second until it reaches the desired goal.

Thanks for any advice you can offer
B
18
S
4
G
2
Posts: 77
Reputation: 1,588