Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
// examples.js
const example_snippets = [{
d:"Download and run a <b>pattern sequencer</b>",
c:`
tulip.download_and_run('tracks')
`},{
d:"Run a drum machine",
c:`
run('drums')
`},{
d:"Set up a MIDI channel to play a piano",
c:`
midi.config.reset()
midi.config.add_synth(synth.PatchSynth(6, 256))
# Now set your MIDI device on this page and play a note!
`},{
d:"Move a sprite around the screen with the keyboard",
c:`
# Use control-Q to exit
run("planet_boing")
`},{
d:"Chat on the Tulip World BBS",
c:`
# Set your own username!!
world.username="anonymous"
run('worldui')
`},{
d:"Play a complex FM synthesis example",
c:`
run('xanadu')
`},{
d:"Scrolling backgrounds",
c:`
# Use control-Q to exit
run('parallax')
`},{
d:"Buttons, sliders and entry widgets",
c:`
run("buttons")
`},{
d:"Load a .wav sample and play a chord",
c:`
# some stuart dempster in your browser
import music
amy.load_sample('../sys/ex/bcla3.wav', patch=50)
s = synth.OscSynth(wave=amy.PCM, patch=50)
for i,note in enumerate(music.Chord('F:min7').midinotes()):
s.note_on(note+24, 1, time=i*4000)
s.note_off(note+24, time=20000)
`},{
d:"Load a small holiday animation with music",
c:`
tulip.download_and_run('xmas')
`},{
d:"Construct a custom FM synth and play a progression",
c:`
import midi, music
# WOOD PIANO amy setup, 4-op FM synth
midi.config.reset()
amy.start_store_patch()
amy.send(osc=1, bp0="0,1,5300,0,0,0", phase=0.25, ratio=1, amp="0.3,0,0,1,0,0")
amy.send(osc=2, bp0="0,1,3400,0,0,0", phase=0.25, ratio=0.5, amp="1.68,0,0,1,0,0")
amy.send(osc=3, bp0="0,1,6700,0,0,0", phase=0.25, ratio=1, amp="0.23,0,0,1,0,0")
amy.send(osc=4, bp0="0,1,3400,0,0,0", phase=0.25, ratio=0.5, amp="1.68,0,0,1,0,0")
amy.send(osc=0, wave=amy.ALGO, algorithm=5, algo_source="1,2,3,4", bp0="0,1,147,0", bp1="0,1,179,1", freq="0,1,0,0,1,1")
amy.stop_store_patch(1024)
s = synth.PatchSynth(8, 1024)
p = music.Progression(["I", "vi", "IV", "V"], music.Key("E:maj"))
chord_len = 2000
note_len = 500
start = 1000
for x,chord in enumerate(p.chords):
# Play a chord
chord_time = (x*chord_len)
for i,note in enumerate(chord.midinotes()):
s.note_on(note-12, 1, time=start+chord_time)
s.note_off(note-12, time=start+chord_time+chord_len-100)
# And a little arp over it
for i,note in enumerate(chord.midinotes()):
note_time = (x*chord_len)+(i*note_len)
s.note_on(note, 1, time=start+note_time)
s.note_off(note, time=start+note_time+100)
`
}
]654f5d77fThis file is pinned to the selected release. Download the original to open it in your design tool.