Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

super_simple_synth_sub_20_lines.py: do not capture midi event-related variables #4

Open
conversy opened this issue Nov 4, 2024 · 0 comments

Comments

@conversy
Copy link

conversy commented Nov 4, 2024

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 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant