Skip to content

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

@conversy

Description

@conversy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions