Difference between revisions of "Sound.freq"

From MiniScript Wiki
Jump to navigation Jump to search
m
m (Removed unnecessary parentheses from function calls)
Line 4: Line 4:
  
 
<ms>snd = new Sound
 
<ms>snd = new Sound
snd.init(2)
+
snd.init 2
 
snd.freq = 261.626
 
snd.freq = 261.626
 
snd.play</ms>
 
snd.play</ms>
Line 11: Line 11:
  
 
<ms>snd = new Sound
 
<ms>snd = new Sound
snd.init(2)
+
snd.init 2
 
snd.freq = [noteFreq(58), noteFreq(43)]
 
snd.freq = [noteFreq(58), noteFreq(43)]
 
snd.play</ms>
 
snd.play</ms>
  
 
See also: <c>[[Sound.init]]</c>; <c>[[noteFreq]]</c>
 
See also: <c>[[Sound.init]]</c>; <c>[[noteFreq]]</c>

Revision as of 03:01, 28 April 2020

Sound.freq controls a Sound object's sound frequency, or how many times a second a waveform is repeated.

For example, a middle C on a piano produces a sound frequency of 261.626 times a second:

snd = new Sound
snd.init 2
snd.freq = 261.626
snd.play

It can be assigned a single frequency, or a list of frequencies, and Mini Micro will interpolate between frequencies over the duration of the sound:

snd = new Sound
snd.init 2
snd.freq = [noteFreq(58), noteFreq(43)]
snd.play

See also: Sound.init; noteFreq