Last active
January 26, 2021 09:35
-
-
Save xorik/57ecac876385ac631baa8af6142f48c2 to your computer and use it in GitHub Desktop.
Sonic pi portamento
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| STOP_NOTE = 60 # stop on pressing the C note, you can use another MIDI or timer event to stop the synth | |
| live_loop :midi_keys do | |
| use_real_time | |
| note, velocity = sync "/midi:*:1/note_*" | |
| if velocity > 0 && note != STOP_NOTE | |
| if (get :current_note) == nil | |
| use_synth :dsaw | |
| x = play note: note, note_slide: 0.3, amp: velocity / 127.0, sustain: 300 | |
| set :current_note, x | |
| else | |
| control (get :current_note), note: note | |
| end | |
| end | |
| end | |
| live_loop :stop do | |
| use_real_time | |
| note, velocity = sync "/midi:*:1/note_*" | |
| if note == STOP_NOTE | |
| control (get :current_note), amp: 0, amp_slide: 0.5 | |
| sleep 0.5 | |
| kill (get :current_note) | |
| set :current_note, nil | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo: https://youtu.be/_P8UgGLzTWY