Adjust Audio Play Rate
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Adjust Audio Play Rate
Hi.
Can someone tell me if it is possible to adjust the playspeed of a player
so that the speed will slow and then speed up? Sort of like the playspeed is on a curve?
Many thanks
Bidge
Can someone tell me if it is possible to adjust the playspeed of a player
so that the speed will slow and then speed up? Sort of like the playspeed is on a curve?
Many thanks
Bidge
Re: Adjust Audio Play Rate
Hi Bidge,
check "playtrate" (= speed) in the docs!
Setting the playrate of a player to 1 = "normal" speed
2 = double speed
You can use fractions like 1.3 etc...
Using negative values = playing the sound backwards
Hint!
Keep in mind that this does also change the pitch of your sounds!
Although QuickTime is capable to keep the pitch while changing the playrate,
RunRev did not (yet?) implement this QT API call in the player obhjects!
Best
Klaus
check "playtrate" (= speed) in the docs!
Setting the playrate of a player to 1 = "normal" speed
2 = double speed
You can use fractions like 1.3 etc...
Using negative values = playing the sound backwards

Hint!
Keep in mind that this does also change the pitch of your sounds!
Although QuickTime is capable to keep the pitch while changing the playrate,
RunRev did not (yet?) implement this QT API call in the player obhjects!
Best
Klaus
Re: Adjust Audio Play Rate
G'day Bidge,
I believe this can be achieved in AppleScript. Please refer this link on macosxhints dot com http://www.macosxhints.com/article.php? ... 3000452805, in reference to changing the playback speed of the player without changing pitch.
I hope this helps my fellow Australian.
Kind regards, Andrew
I believe this can be achieved in AppleScript. Please refer this link on macosxhints dot com http://www.macosxhints.com/article.php? ... 3000452805, in reference to changing the playback speed of the player without changing pitch.
I hope this helps my fellow Australian.
Kind regards, Andrew
Re: Adjust Audio Play Rate
I'm sure Bidge wants to use this inside of Rev 

Re: Adjust Audio Play Rate
Hey. Thanks for all the responses 
Could it be possible to adjust the playrate so that they are different as the audio plays? Say that at the start of an audio file the playrate is 1.6, the middle, .7, and the end 1.9 ?
Cheers
Bidge

Could it be possible to adjust the playrate so that they are different as the audio plays? Say that at the start of an audio file the playrate is 1.6, the middle, .7, and the end 1.9 ?
Cheers
Bidge
Re: Adjust Audio Play Rate
Bidge,
regards
Bernd
try this in the script of a player you want to play at different playrates during playing:bidgeeman wrote:... Say that at the start of an audio file the playrate is 1.6, the middle, .7, and the end 1.9 ?
Code: Select all
local tIsPlaying, tDuration, tPlayRateAtBegin, tPlayRateMiddle, tPlayRateEnd
on playstarted
put true into tIsPlaying
put the duration of me into tDuration
put 1.6 into tPlayRateAtBegin -- adjust for start rate
put 0.7 into tPlayRateMiddle -- adjust for middle rate
put 1.9 into tPlayRateEnd -- adjust for end rate
send adJustPlayrate to me in 1 milliseconds
end playstarted
on adJustPlayrate
if not tIsPlaying then exit adJustPlayrate
put the currenttime of me into tCurrent
put trunc (tCurrent / tDuration * 100) into tPercent
if tPercent < 50 then
put tplayRateMiddle+((tPlayRateAtBegin-tplayRateMiddle)* (1-(tPercent*2/100))) into tplayRateNow
set the playrate of me to tplayRateNow
else
put tplayRateMiddle+((tPlayRateEnd-tplayRateMiddle)* ((tPercent/100 -.5)*2)) into tplayRateNow
set the playrate of me to tplayRateNow
end if
if adJustPlayrate is not in the pendingmessages then
send adjustPlayrate to me in 10 milliseconds
end if
end adJustPlayrate
on playstopped
put false into tIsPlaying
repeat for each line aline in the pendingmessages
if aline contains "adJustPlayrate" then cancel item 1 of aLine
end repeat
end playstopped
on mouseDown
if tIsplaying then put false into tIsPlaying
end mouseDown
Bernd
Re: Adjust Audio Play Rate
Oh that's great Bernd! Love the effect of the sliding change in speed.
I know that's exactly what you wanted to achieve Bidge, but just to add another angle, you can also use callbacks at certain points - so this is an alternative where the playRate stays constant until it reaches the callback trigger time. So the first third will play at the constant rate of 1.6, the middle third at 0.7 and the final third at 1.9 - jumping from one rate to another, rather than sliding. I offer this only as an illustration of the use of callbacks, which I know is not appropriate for tackling this particular task. Sorry!
In your initialisation:In the player:
I know that's exactly what you wanted to achieve Bidge, but just to add another angle, you can also use callbacks at certain points - so this is an alternative where the playRate stays constant until it reaches the callback trigger time. So the first third will play at the constant rate of 1.6, the middle third at 0.7 and the final third at 1.9 - jumping from one rate to another, rather than sliding. I offer this only as an illustration of the use of callbacks, which I know is not appropriate for tackling this particular task. Sorry!
In your initialisation:
Code: Select all
put the duration of player "Player" into tDuration
put tDuration / 3 into tInt
put "0,adjustRate 1.0" into tCallbacks
--just to reset for tidiness
put cr & "1,adjustRate 1.6" after tCallbacks
put cr & round (tInt) & ",adjustRate 0.7" after tCallbacks
put cr & round ((2 * tInt)) & ",adjustRate 1.9" after tCallbacks
put cr & (tDuration - 1) & ",adjustRate 1.0" after tCallbacks
--just to reset for tidiness
set the callbacks of player "Player" to tCallbacks
start player "Player"
Code: Select all
on adjustRate pRate
set the playRate of me to pRate
end adjustRate
Re: Adjust Audio Play Rate
great Sparkout,
I didn't even think of callbacks since I like "send in time" too much
If one wants to go with callbacks, (which at times are very handy) one could do the sliding pitch / rate like this in a separate buttonin the player would be the code you provided
Now if someone could offer a better algorithm to replace my cheesy calculation of the playrate, I wonder if there are any mathematicians around
regards
Bernd
I didn't even think of callbacks since I like "send in time" too much

If one wants to go with callbacks, (which at times are very handy) one could do the sliding pitch / rate like this in a separate button
Code: Select all
on mouseUp
put the duration of player 2 into tDuration
put 1.6 into tPlayRateAtBegin -- adjust for start rate
put 0.7 into tPlayRateMiddle -- adjust for middle rate
put 1.9 into tPlayRateEnd -- adjust for end rate
put trunc (tDuration / 100) into tIntervall
put 0 into tSetCallbackAt
put "" into tmyCallbacks
repeat with i = 1 to 100
if i < 50 then
put tplayRateMiddle+((tPlayRateAtBegin-tplayRateMiddle)* (1-(i*2/100))) into tplayRateNow
put tSetCallbackAt & ",adjustRate" && tPlayRateNow & return after tmyCallbacks
else
put tplayRateMiddle+((tPlayRateEnd-tplayRateMiddle)* ((i/100 -.5)*2)) into tplayRateNow
put tSetCallbackAt & ",adjustRate" && tPlayRateNow & return after tmyCallbacks
end if
add tIntervall to tSetCallbackAt
end repeat
delete char - 1 of tmyCallbacks
set the callbacks of player 2 to tmyCallbacks
end mouseUp
Code: Select all
on adjustRate pRate
set the playRate of me to pRate
end adjustRate

regards
Bernd
Re: Adjust Audio Play Rate
WOW! That's fantastic! Thanks guys but there is one major problem I have now realized 
When I tried to save out the .wav file using QT External the playrate data is not saved with
the .wav. Dammit!
Cheers
Bidge

When I tried to save out the .wav file using QT External the playrate data is not saved with
the .wav. Dammit!
Cheers
Bidge
Re: Adjust Audio Play Rate
Bidge,
I dont see a way in the quicktime external or with Revs sound recording capabilities to create a sound file with the change of pitch/rate preserved. (I did record a sound file via the internal microphone on a MacBook Pro with pictch changes with Rev's " record sound file theFile" but that is quite lossy/low quality and probably not what you want)
regards
Bernd
I dont see a way in the quicktime external or with Revs sound recording capabilities to create a sound file with the change of pitch/rate preserved. (I did record a sound file via the internal microphone on a MacBook Pro with pictch changes with Rev's " record sound file theFile" but that is quite lossy/low quality and probably not what you want)
regards
Bernd
Re: Adjust Audio Play Rate
Hi Bernd.
Thanks for trying. It's a pity that you can't save the soundfile preserved. The lack of audio control really limits Rev fom being a useful tool for creating sound applications.
Cheers mate
David
Thanks for trying. It's a pity that you can't save the soundfile preserved. The lack of audio control really limits Rev fom being a useful tool for creating sound applications.
Cheers mate

David