Sound

From MiniScript Wiki
Revision as of 20:20, 26 January 2023 by JoeStrout (talk | contribs) (→‎Methods and properties used with Sound objects)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

In Mini Micro, the Sound class both represents individual audio clips that can be played, and a handful of global sound-related properties and methods.

Methods and properties called on Sound

Use the following properties and methods directly on the Sound class itself.

Method or Property Purpose
Sound.sineWave represents a sine wave (pure tone)
Sound.triangleWave represents a triangle wave (almost pure)
Sound.sawtoothWave represents a sawtooth wave (slightly "buzzier")
Sound.squareWave represents a square wave (most buzzy/retro sound)
Sound.noiseWave creates a pseudo-random "static" waveform
Sound.stopAll stops all currently playing sounds

Methods and properties used with Sound objects

Use these methods on Sound instances, created with new Sound or file.loadSound.

Method or Property Purpose
Sound.duration length of the sound, in seconds
Sound.freq sound frequency, i.e. how many times the waveform is repeated per second
Sound.envelope volume over time (0 to 1)
Sound.waveform shape of waveform over an audio cycle
Sound.fadeIn length of the fade-in period when the sound begins, in seconds
Sound.fadeOut length of the fade-out period when the sound ends, in seconds
Sound.loop true (1) to set the sound to repeat indefinitely until stopped
Sound.init duration,freq,envelope,waveform initialize a sound with the given parameters
Sound.mix sound2,level add another synthesized sound into this one
Sound.play volume,pan,speed play this sound (looping if .loop is true)
Sound.adjust volume,pan,speed change volume/pan/speed of a playing sound
Sound.stop stop playing this sound

See also: file.loadSound; noteFreq