Lingo Dictionary > O-R > rateShift |  |

rateShift

Syntax

    sound(channelNum).queue(#member: member(whichMember), {#rateShift: shiftAmount})
    sound(channelNum).play(#member: member(whichMember), {#rateShift: shiftAmount})
    sound(channelNum).rateShift

Description

Sound property; determines the rate of playback of a sound. If the `rateShift` is zero, the sound plays normally. Setting the `rateShift` to a postive integer plays the sound faster, causing its pitch to go up and its duration to decrease. Setting the `rateShift` to a negative integer plays the sound more slowly, causing its pitch to go down and its duration to increase. Each integer increment changes the pitch by one half step (semitone), so a `rateShift` of 12 corresponds to an increase in pitch of one octave.

This property can be tested and set. Set the `rateShift` with a `queue()`, `play()`, or `setPlaylist()` command.

Example

This statement queues the sound Explosion to play 2 half-steps lower than its normal pitch in sound channel 1:

    sound(1).queue(#member: member("Explosion"), #rateShift: -2)

Example

This statement queues the sound Explosion, preloads 1500 milliseconds of it, and sets it to loop twice and to play 3 half-steps lower than its normal pitch:

    sound(1).queue(#member: member("Explosion"), #preloadTime: 1500, #loopCount: 2, #rateShift: -3)

Example

This handler queues and plays two sounds. The first sound, cast member Chimes, is played in its entirety. The second sound, cast member introMusic, is played starting at its 3-second point, with a loop repeated 5 times from the 8-second point to the 8.9 second point, and stopping at the 10-second point. 4 seconds of the sound will be preloaded and it will be played back with a rateShift of 1, or at one half-step higher pitch than normal.

    on playMusic
    	sound(2).queue([#member: member("Chimes")])
    	sound(2).queue([#member: member("introMusic"), #startTime: 3000,\
    	#endTime: 10000, #loopStartTime: 8000, #loopEndTime: 8900, #loopCount: 5, \
    	preloadTime: 4000, rateShift: 1])
    	sound(2).play()
    end

Example

This statement tests the `rateShift` value of the sound currently playing in sound channel 2 and displays it in the Message window:

    put sound(2).rateShift

See also

`queue(), play() (sound), setPlaylist(), getPlaylist()`