diff --git a/python_payload/drums_and_notes.py b/python_payload/drums_and_notes.py new file mode 100644 index 0000000000000000000000000000000000000000..c63be1534315b407669eef3fead56ed10ced0f27 --- /dev/null +++ b/python_payload/drums_and_notes.py @@ -0,0 +1,40 @@ +from synth import tinysynth +from hardware import * + +synths = [] +notes = [2,5,9,12,16] +drums = [1800,4000,6000,12000,16000] + + +def run(): + global synths + for i in range(10): + if(get_captouch(i)): + if(synths[i][0] == 0): + synths[i][0] = 1 + synths[i][1].start() + else: + if(synths[i][0] == 1): + synths[i][0] = 0 + synths[i][1].stop() + +def init(): + global synths + global notes + for i in range(10): + synth = tinysynth(440,0) + synth.attack(1) + if i % 2: + synth.tone(notes[int(i/2)]) + synth.waveform(4) + else: + synth.waveform(8) + synth.decay(3) + synth.freq(drums[int(i/2)]) + if i == 8: + synth.freq(16000) + synth.decay(50) + synths += [[0, synth]] + +def foreground(): + display_scope_start() diff --git a/python_payload/main.py b/python_payload/main.py index 1990ee51cb8001f4ccb25734fab8c94f9a2cdf13..cd877609f0b23beeea09758782beb99cb2eeb901 100644 --- a/python_payload/main.py +++ b/python_payload/main.py @@ -5,10 +5,11 @@ import harmonic_demo import melodic_demo import demo_worms import cap_touch_demo +import drums_and_notes MODULES = [ harmonic_demo, - melodic_demo, + drums_and_notes, demo_worms, cap_touch_demo, ]