Release and Sustain control

R
Reza Yazdi posted Sep 9, 05:21:

Hi Joseph,

I installed your file into RPi 3 and connected my MIDI keyboard + my own sampled wav files as instructed on the website. However there was not enough release and the notes were played very short. Note that I don't have the DAC module yet and using the onboard headphone jack.
I don't have any keys attached to the GPIO header as well.

In the script, there is a way to sustain the playback even when it get a “note off”. Please see code in red below for detail (they are in line 213).
But, in the real case, It always reach to the “else” branch and never enter “sustain” branch which is the one I want it to be.

elif messagetype == 8:  # Note off
    midinote += globaltranspose
    if midinote in playingnotes:
        for n in playingnotes[midinote]:
            if sustain:
                sustainplayingnotes.append(n)
            else:
                n.fadeout(50)
        playingnotes[midinote] = []

Because I am not familiar with python, I just swap the action in those 2 branches to make it work. Maybe you can help on how to make it work in a proper way.

elif messagetype == 8:  # Note off
    midinote += globaltranspose
    if midinote in playingnotes:
        for n in playingnotes[midinote]:
            if sustain:
                n.fadeout(50)
            else:
                sustainplayingnotes.append(n)
        playingnotes[midinote] = []

Now the notes are played much longer but there is a lot of background noise.
Do you know why? Is this the right way to add release/sustain?

R
Reza Yazdi posted Sep 16, 00:55:

Any comments\Suggestion\Help?

...

  (not published)
  I want to post as guest
 

Post