playNote()
Purpose
Play a musical note
Description
Play a note of the specified frequency, volume and speed on the specified channel
Syntax
playNote( channel, wave, frequency, volume, speed, pan )
Arguments
channel audio channel from 0 to 15
wave wave type (0 = Square, 1 = Saw, 2 = Triangle, 3 = Sine, 4 = Noise )
frequency frequency 10Hz to 20Khz (10 - 20000)
volume volume from 0 to 1
speed speed to reach peak volume (higher is faster)
pan stereo pan from left (0) to right (1)
Example
pan = 0.5
vol = 0.5
for f = 10 to 20000 step 10 loop
clear()
printAt( 0, 0, "Left joypad: left right to pan, up down to raise lower volume" )
printAt( 0, 1, "Frequency: ", f, " Pan: ", pan, " Volume: ", vol )
c = controls( 0 )
if c.left then // left to pan left
pan = pan - 0.01
endIf
if c.right then // right to pan right
pan = pan + 0.01
endIf
if c.up then // up to increase volume
vol = vol + 0.01
endIf
if c.down then // down to decrease volume
vol = vol - 0.01
endIf
pan = max( pan, 0 )
pan = min( pan, 1 )
vol = max( vol, 0 )
vol = min( vol, 1 )
playNote( 0, 0, f, vol, 0.5, pan )
sleep( 0.05 )
update()
repeat
Associated Commands
audioLength(), getChannelStatus(), loadAudio(), note2Freq(), playAudio(), setClipper(), setFilter(), setPan(), setVolume(), startChannel(), stopChannel()