Difference between revisions of "Sound.play"

From MiniScript Wiki
Jump to navigation Jump to search
m (Added note that the "speed" parameter will change both the pitch and duration of the sound being played.)
m
Line 17: Line 17:
 
=== Usage Notes ===
 
=== Usage Notes ===
 
The sound will automatically stop if [[Sound.loop|.loop]] is false, but will repeat until explicitly
 
The sound will automatically stop if [[Sound.loop|.loop]] is false, but will repeat until explicitly
stopped if [[Sound.loop|.loop]] is true. Note that ''speed'' will change both the duration and pitch of the sound, due to the addition/removal of waveform cycles.
+
stopped if [[Sound.loop|.loop]] is true. Note that ''speed'' will change both the duration and pitch of the sound, due to changing the speed of the waveforms being played.
  
 
== Example ==
 
== Example ==

Revision as of 03:44, 30 April 2020

Sound.play plays a sound. Call this on a Sound object initialized either Sound.init, or loaded via file.loadSound.

Arguments

Parameter Name Type Default Value Meaning
volume number 1 volume (0-1) of the sound
pan number 0 left (-1) to right (1) stereo pan of the sound
speed number 1 speed multiplier (1 == standard speed)

Usage Notes

The sound will automatically stop if .loop is false, but will repeat until explicitly stopped if .loop is true. Note that speed will change both the duration and pitch of the sound, due to changing the speed of the waveforms being played.

Example

s = file.loadSound("/sys/sounds/bonus.wav")
s.play