Skip to content
Snippets Groups Projects
Select Git revision
  • 267c8f11bb1dafd76adc4b362132cd9edf89a842
  • main default protected
  • blm_dev_chan
  • release/1.4.0 protected
  • widgets_draw
  • return_of_melodic_demo
  • task_cleanup
  • mixer2
  • dx/fb-save-restore
  • dx/dldldld
  • fpletz/flake
  • dx/jacksense-headset-mic-only
  • release/1.3.0 protected
  • fil3s-limit-filesize
  • allow-reloading-sunmenu
  • wifi-json-error-handling
  • app_text_viewer
  • shoegaze-fps
  • media_has_video_has_audio
  • fil3s-media
  • more-accurate-battery
  • v1.4.0
  • 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
35 results

harmonic_demo.py

Blame
  • 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)