You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
super_simple_synth.py works fine on macOS using Midi Keys, but not super_simple_synth_sub_20_lines.py: the sound stops as soon as a new midi event is received after the first Note On because nand vare captured and reused in the generator line #16.
To avoid variable capture, we need to create a one line function: def f(n,v): return (sin(c)*v*0.1/127 for c in count(0,(2*pi*midi.midi_to_frequency(n))/44100))
line #9, and call it in the (new) line #17 (former line #16) elif s==0x90 and n not in nd:nd[n]=f(n,v)
We might change the name of the file into super_simple_synth_20_lines.pythough :-)
The text was updated successfully, but these errors were encountered:
super_simple_synth.py works fine on macOS using Midi Keys, but not super_simple_synth_sub_20_lines.py: the sound stops as soon as a new midi event is received after the first Note On because
n
andv
are captured and reused in the generator line #16.To avoid variable capture, we need to create a one line function:
def f(n,v): return (sin(c)*v*0.1/127 for c in count(0,(2*pi*midi.midi_to_frequency(n))/44100))
line #9, and call it in the (new) line #17 (former line #16)
elif s==0x90 and n not in nd:nd[n]=f(n,v)
We might change the name of the file into
super_simple_synth_20_lines.py
though :-)The text was updated successfully, but these errors were encountered: