Skip to content
Snippets Groups Projects
Select Git revision
  • 5d490af1cb6b159dda7a41b2852dab854ddc5962
  • main default protected
  • phhw
  • captouch-threshold
  • t
  • dos
  • test2
  • test
  • slewtest
  • simtest
  • view-think
  • vm-pending
  • media-buf
  • scope
  • passthrough
  • wave
  • vsync
  • dos-main-patch-50543
  • json-error
  • rahix/big-flow3r
  • pippin/media_framework
  • v1.3.0
  • v1.2.0
  • v1.2.0+rc1
  • v1.1.1
  • v1.1.0
  • v1.1.0+rc1
  • v1.0.0
  • v1.0.0+rc6
  • v1.0.0+rc5
  • v1.0.0+rc4
  • v1.0.0+rc3
  • v1.0.0+rc2
  • v1.0.0+rc1
34 results

harmonic_demo.py

Blame
  • Forked from flow3r / flow3r firmware
    1529 commits behind, 14689 commits ahead of the upstream repository.
    moon2's avatar
    moon2 authored and dx committed
    5d490af1
    History
    harmonic_demo.py 1.11 KiB
    from synth import tinysynth
    from hardware import *
    
    chords = [\
    [-4,0,3,8,10],\
    [-3,0,5,7,12],\
    [-1,2,5,7,11],\
    [0,3,7,12,14],\
    [3,7,10,14,15]\
    ]
    
    chord_index = 3
    chord = chords[3]
    synths = []
    
    def set_chord(i):
        global chord_index
        global chord
        if(i != chord_index):
            chord_index = i
            for j in range(40):
                hue = int(72*(i+0.5)) % 360
                set_led_hsv(j, hue, 1, 0.2)
            chord = chords[i]
            update_leds()
    
    
    def run():
        global chord_index
        global chord
        global synths
        for i in range(10):
            if(get_captouch(i)):
                if(i%2):
                    k = int((i-1)/2)
                    set_chord(k)
                else:
                    k = int(i/2)
                    synths[k].tone(chord[k])
                    synths[k].start()
    
    def init():
        global chord_index
        global chord
        global synths
    
        for i in range(5):
            synths += [tinysynth(440,1)]
    
        for synth in synths:
            synth.decay(100)
            synth.waveform(1)
    
    def foreground():
        global chord_index
        global chord
        global synths
        tmp = chord_index
        chord_index = -1
        set_chord(tmp)