Holding notes as if using sustain pedal

R_Gol's icon

I build a polyphonic synth that can play non 12tet scales

I would like to add it a function such as when using a sustain pedal - so if I'm pressing a toggle it will hold the note/s that is playing.

right now the note is held whenever the key is pressed and released when releasing the key. how can I make it hold as if I was pressing sustain pedal?

schlam's icon

hello.
Did you look at [sustain] ?

R_Gol's icon

I did not know about that object. seems what I need. I will check it asap. will it work in poly environment as well ?

R_Gol's icon

I try using [sustain] but it did not helped in my case. here is my main patch:

Max Patch
Copy patch and select New From Clipboard in Max.

and here is the poly~ patch:

p_microfunction.maxpat
Max Patch

how can I sustain the notes that are held as long I'm pressing the key "m"

Roman Thilenius's icon

you have already built your own envelope using zl reg, so i think you are on the right path.

make sure that you internalize what "ADSR" means in relation to time/value pairs, and which value(s) have to be modulated to "hold" when the "pedal" is pressed, then you have it.

R_Gol's icon

I need to remember which notes are held when pressing the "pedal" then send those notes to [s ---midi] along side the number 0 for the velocity . Meanwhile I have used the letter 'm' to act as my sustain pedal

R_Gol's icon

ok, Its really ugly but I think I manage to solve it!

Edit: not exactly :(
because now I can't play other notes while holding some notes

Max Patch
Copy patch and select New From Clipboard in Max.

Andy Maskell's icon

Have you taken a look at [stripnote] and [midiflush]?

[stripnote] will remove all Note Off messages, so will give you the same effect as holding down a sustain pedal/key.

[midiflush] will hold a record of all Note messages that pass through it and if you send it a [bang] it will send Note Off messages for all the notes that are still playing, in other words, it will mimick releasing the sustain pedal/key.

Something like this perhaps?

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

it is not clear to me what really the goal is...
from initial post :

it rather looks as hold, and not sustain.
anyway - releasing "sustain" toggle should not turn any notes
that are currently held off, only "grabbed" ones


R_Gol's icon

Thanks!!10

👽'tW∆s ∆lienz👽's icon

tis the light within the lantern that shows you the path, not the lantern itself
(sorry, no relevance, i just saw everyone chime in and felt left out so i decided this would be my addition to the thread... thank you for a beautiful thread :D)

jamesway's icon

With mc.noteallowcate and mc.function, the voice can be used to trigger note on with a change object before it for one bang, and the note off 0 from noteallowcate to trigger the "next" message for release.
Easy with 3 point envelopes but to trigger second to last point in envelope is tricky. Haven't figured that out yet.
Patchywachy

R_Gol's icon

Is it possible to sustain only a certain notes from the array of notes currently playing?

for example I'm pressing midi notes 60 64, 67 and 68. Is it possible to choose to sustain only note 60 for example? or notes 60 and 67? how can I implement that?

Roman Thilenius's icon

keep a list of all running notes,
whenever a new note on is added, sort the list so that it is always sorted,
then you can access a specific one of it and process it different from the others.

Source Audio's icon

well it depends what criteria is used to include or exclude
notes from sustain process.
could be anything, related to some rules within current list,
or then by other rules.
if one knows the pitches to exclude or include in advance
simple splitter could separate them.

another issue is dealing with new notes while sustain pedal is held,
should they also join the "procesed list" or not, which would add to complexity

R_Gol's icon

how difficult is to do the following -

Assuming pressing the pedal and holding few notes - > when button is pressed keep hold all the notes until now and don't hold any new notes

R_Gol's icon

what do you think about my method?

It seems to work in that way that when I press the right hand toggle no new notes will held.
I would like to figure out how to access all nots that held and have the ability to turn off specific notes

Max Patch
Copy patch and select New From Clipboard in Max.

R_Gol's icon

what I'm trying to ask is : Is there a method to flush out only specific notes that are held?

Source Audio's icon

you should store held notes into something like coll,
and then recall them for turning them off.
But what would you use to turn specific note off ?
Same keyboard input ?

for exampe, you open the gate and collect some notes,
you close the gate and hold the notes.
than you open another gate to only pass notes into that coll,
which then turns notes off if you hit right ones ....
dump message to that coll would work same as flush





R_Gol's icon

But what would you use to turn specific note off ?
Same keyboard input ?

if each held note is store in coll with specifix index starting from 1 - it might be possible to use computer keyboard numbers to decide which notes to release from sustaining ?

so if my coll is look like this:

1, 64;
2, 55;
3, 78;
4, 42;

if I'm pressing on my computer the numbers 1 and 3 --> the notes stored in that indexes will be flushed away. notes at indexes 2 and 4 will continue to be held

Source Audio's icon

no that won't work, what do you make indexes from,
after removing few notes from coll?
how do you know which note is assigned to which index ?
I mean if this has any musical sense, and you "hear"
and decide that some note has to go ....

R_Gol's icon

I mean if this has any musical sense, and you "hear"
and decide that some note has to go ....

This is exactly the idea behind - to release any notes that not fit to my ear after already held

Max Patch
Copy patch and select New From Clipboard in Max.


the above patch has solved the idea to hold some notes while be able to play on top the already held notes. What I'm trying to add is to be able to release specific notes from the one that helds after already being held

Source Audio's icon

if you have patch that allready does all ok for you, then do what I suggested first, open "erase" gate, which allows keyboard to remove
held notes.
you just need to hit correct notes on your keyboard.

P.S. that patch you posted does not work....

R_Gol's icon

P.S. that patch you posted does not work....

My above patch do the following:

I have two toggles in my patch Left-hand and Right-hand.
when no toggle is pressed:
incoming notes will be fade out according to their duration.

when Left-hand toggle is pressed:
Any coming notes will be held as long the Left-hand toggle is pressed (imitating sustain pedal)

When Right-hand toggle is pressed and Left-hand toggle is still pressed:
old notes will keep sustaining while new notes will not sustain.

so far' so good for my needs. What I'm trying to add is that I will have the option to take out some of the already sustained notes. So if I press a note whole sustaining (left hand toggle is press) I could release only a specific notes and not stopping all the notes ...

I have hard time to understand how to do so. it seems the flush object is not able to flush only specific notes rather all the held notes at once

you just need to hit correct notes on your keyboard.

I want to have the option to erase a note without using my piano keyboard rather my computer keyboard or at least monitor the notes that is holding

Source Audio's icon

you are wrong - if you play again any hed note,
while that right hand toggle is on, note will get turned off.

That is so in your patch.

Hold either blocks held notes from being replayed,
or sends held notes to different midi destination.

If you want to erase notes using keyboard keys,
then you need to see which notes are held and maybe sort them
so that at least you know more or less what gets erased.

R_Gol's icon

Ok I understand what you mean!
I think it is working just fine..

How can I delete from the message list of holding notes the ones that are no longer sustained?

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

working just fine.. ???
how should that be working ? no chance !

turn hold on, play c3, turn that other toggle, play c3.
what do you see in lower kslider ?

R_Gol's icon

you are wrong - if you play again any hed note,
while that right hand toggle is on, note will get turned off.

Not if I press the right-hand toggle.

R_Gol's icon

working just fine.. ???
how should that be working ? no chance !

In the max patch' you are right' it seems to take the note off
but in my m4l device it seems not too:

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

I can't look at that messy patches any more, sorry.
if you send note and velocity out, you will turn held notes off.
no discussion about it.

what should that s ---midi s ---vel mean ?
you send that where ?

R_Gol's icon

I can't look at that messy patches any more, sorry.
if you send note and velocity out, you will turn held notes off.
no discussion about it.

Indeed messy. I will try to figure it out before asking again..

what should that s ---midi s ---vel mean ?
you send that where ?

It is my complicated way to handle Scala files in my synth.

Source Audio's icon

your so many midi format objects make illegal midi messages
look this


Source Audio's icon

here is a working hold patch with removal of pitches from hold using midi keyboard.

for other option,
you need to tell me how exactly you want to select which held note to remove
using what trigger source

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

I have to leave now, will be back on tuesday, so you have enough time to think about it ....

R_Gol's icon

you need to tell me how exactly you want to select which held note to remove
using what trigger source

I was thinking do it manually, just using integer with [i] and [bang] objects . something like this?

Max Patch
Copy patch and select New From Clipboard in Max.


btw - As the patch is function now, whenever I press again the sustain toggle (1 on my keyboard) it will automatically flush all the heads notes until that point. How does it possible that upon pressing again the sustain button it will add new pressed notes to the ones that is already held and only the flush button will flush the heads notes. ?


R_Gol's icon

I have noticed one very important "bug" or when ever note is sustain - is not possible to play that notes anymore (until released) how does it possible to make it be able for playing even if the note is sustained ?

edit: this was done by removing the zl.filter object between the unpack and pack objects


R_Gol's icon

Is there another suggestion for displaying the sustained notes? in my way there is too many bugs. sometime notes are not displaying and if so, alway last not is not deleted from display

edit: another bug I have is that not always the notes that held are released.
edit2: I discover when it happens - it happens in notes that are sustained and played again without sustain (I guess it related to the fact I omitted the zl. filter object?
how does it possible to play notes that are already sustained and to be able to flash them away?

edit3:

edit2 is not the case why notes are stuck . the reason I found is that if I holding a note on the keyboard and only after pressing the sustain toggle then it will not be released. if first pressing and holding the sustain toggle and after pressing the note it will be released when telling it to be released

Source Audio's icon

is typing note number and clicking on bang not too time and mouse consuming ?
why not click on bottom kslider to remove held notes ?
or use numeric keys to erase notes by position in the list ?
which can be sorted by pitch , or last played note etc ?
in any case, erasing nots like that should be done WITHOUT
need to activte eras gate.
that gate is only needed for incoming notes.
-----
here is your modified patch,
I would do erasing in a different way, as suggested.

Max Patch
Copy patch and select New From Clipboard in Max.


Source Audio's icon

I told you this allready - HOLD MUST DISABLE NOTES
THAT ARE HELD, OR SEND THEM TO DIFFERENT MIDI DESTINATION.

I am out till tomorrow...

R_Gol's icon

is typing note number and clicking on bang not too time and mouse consuming ?

Probably you are right.


or use numeric keys to erase notes by position in the list ? which can be sorted by pitch , or last played note etc ?

This sounds like a great idea - but I prefer make the system work as needed and that brings be to the below two questions:

----
Is it possible to do both?:
1) playing on top of notes that are sustained (example: MIDI note 60 is sustained but the note will also be heard if in play mode.
2) if omitting the zl filter object it is possible to playing notes that are already sustain (as asked in number one). The problem is that sustaining notes that are pressed before the sustain pedal/toggle was pressed will not be released upon flashing

Source Audio's icon

you are asking for functions that can not work
in normal midi world.
sending 44 0 will turn note 44 off no matter if it is being held by previously omitting note off.
Can you understand that?
means - held notes need different midi channel,
poly instance etc, so that HELD note numbers
do not get turned off when one plays them again.
——-
another thing is how to grab notes to hold them ?
1- to lock current sounding notes by pressing hold pedal ?
or
2- to open gate for incoming note on messages
and hold them on pedal release ?
or something else ?
I am sorry, but for me it makes no sense to try to develop something without clear infos

R_Gol's icon

When first pressing the sustain pedal and only after the notes on the keyboard - it will sustain the notes pressed and will release them upon flash of deleting specific notes.

so far so good.
When first pressing the notes on the keyboard and only after the sustain pedal - it will sustain the notes pressed but will not release them upon flash of deleting specific notes.

you tell me that the above is not possible to fixed/workaround?

Source Audio's icon

I expected such problems, because you did not really define
how hold pedal interacts with notes which were held before it acts.

Do you want me to disable any sounding notes from hold,
if they were pressed before hold gets pressed ?
and is it ok that notes which get released before hold pedal is released
keep being held or not ?

I actually need from you exact behaviour and interacion between notes comming from keyboard and hold pedal.
What happens between hold press and reease ?

R_Gol's icon

how hold pedal interacts with notes which were held before it acts.

if notes were held before sustain pedal acts they will be sustained after pressing but will be able to be deleted when flashing notes of individually delete specific notes

Do you want me to disable any sounding notes from hold, if they were pressed before hold gets pressed ?

no. they should be holding as well if the key was hold before and in the moment of pressing the pedal. but it should be flashed away after that when pressing flash button.

I actually need from you exact behaviour and interacion between notes comming from keyboard and hold pedal.

if pressing and holding notes and then pressing the sustain pedal those notes should be sustained. This happens right now but those notes are not released when flashing all notes or manually deleting notes

Source Audio's icon

ok, I will do so, means any notes that happen to be held before or
during hold is pressed will be held.
also releasing notes while hold is pressed is disabled.

I think that can simplify the whole construct.
while doing so, how about using one onscreen kslider
to erase held notes ?

it is much faster, one can see which notes are held and simply click
on any of them to erase.

R_Gol's icon

how about using one onscreen kslider
to erase held notes ?

That is sounds great!

I just want to say that notes that helds should be possible to be play in not sustained mode. I think the zl.filter blocked sustained note to be played on top. Meaning that if note 60 is sustained - if playing that note it is not heard but it should

Source Audio's icon

I will remove blocking of held notes.
then you can see what I mean, in case you output notes to any standard midi destination.
but you will have to plant it back in case you are not happy with the result

Source Audio's icon

P.S. are you aware that while hold pedal is pressed,
note offs are disabled.
repating same note will add voices of the same pitch.
I don't care, I don't have to use it.

Source Audio's icon

here is exacty what you asked for.
I added few cellblocks to visualise held notes.
Sent to midi destination, playing held notes afterwards, will turn them off,
even if they keep visible as held, which is expected behaviour.

Max Patch
Copy patch and select New From Clipboard in Max.

R_Gol's icon

Thanks for all your effort!

R_Gol's icon

ok so note that pressed before the sustain pedal are not sustained if the pedal was pressed after them (while they were hold) - I also don't see them in red on the output key slider

Source Audio's icon

you wanted to unblock held notes.
If you release held notes AFTER release of hold pedal,
they will be turned off.
Is clear or not ?

You must release them BEFORE releasing the sustain pedal.
next time you play held note it will also be turned off,
because that is the way it works.I told you that several times,
you ignore it...

R_Gol's icon

If you release held notes AFTER release of hold pedal,
they will be turned off.
Is clear or not ?

It is clear now!
I'm asking if it is possible to add those notes to the sustained notes if those notes were held before sustained pedal press and alongside the sustain pedal press?
so if notes press and I'm holding the key then pedal is pressed - those notes will be sustained as if they where press after the sustain pedal was held .

I'm sorry it is very difficult for me to explain what I mean/ what I'm looking from that system.
In any case the patch you made until now is just perfect and work great in almost all feature wanted so this is more then enough!

R_Gol's icon

I will try to explain the idea behind what I'm asking:
as I'm not trained musician I like to press on notes on the keyboard to first listen them and if I like them I want to sustain them. as the system is now I must first press the pedal and only after press the wanted note for sustain. in this case I'm not able to hear them before sustained. This is why I ask to have the option to sustain notes that press before pedal (only if still held while pedal is pressed)

Source Audio's icon

Patch allredy includes notes into sustain if they are held before or after hold press.

do you need a video to trust me ?

it works exacty like you asked for, but you did not understand how midi works before you asked.
you need different midi channel or poly instance to be able to produce same note twice.
I don't know exactly what you want, and what is destination of this
hold and played notes.
One could develop something to serve you better, but ony if you explain that the way I can undestand.

For example would retrigger of held notes be what you want ?
I mean to retrigger the ads(r) , but ignore release ?

for that one would again need to separate held notes,
like in previous patch, (with zl.fiter)



Source Audio's icon

P.S.
if all you want is to check if some notes sound good together,
then why on earh do you need them twice ???

you don't even need susain pedal,
just play notes - if played once they sustain,
if played again - they get removed from sustain

R_Gol's icon

Your video looks exactly what I look for!

Where is the final output of the pitch and the velocity? if I take the output of the pitch and velocity from the key slider object (at the button of the patch) it won't work.

Source Audio's icon

You again don't want to understand what I am saying ....
last patch I posted which is on the video, plays to noteout.
lower kslider is tripple layered kslider, visible one shows notes received from notein or top kslider, next shows only held notes in red, and frontmost one (the only one which reacts to click) can turn held notes off.

but to say it again and last time :
if you hear held note, it was sent out to midi synth
without note off.
Next time you send same note on and off, it will ge turned off.
because last note off counts !
held notes can keep sounding no matter what only if:
1- one blocks them from being replayed as long as hold is active
2- they get sent to different midi channel or device
or
3- one retriggers them, which means again to block normal
note playing, doing sort of sustain within hold.


The fact that midi note is not heard, but kslider still shows note in red is because off:
(example)

1- note 44 on - press HOLD (note 60 off is blocked)
2- release note 44 (does nothing) release HOLD
now we have 1 note 60 stored in kslider
3- play note 60 on and off
kslider received 2 on and 1 off - means 1 on is still remaining visible as red.
midi device on the other hand does not care and uses last note OFF
to kill the note, and for that reason you see it red on kslider, but it does not sound.
I will not talk about this again.
Read midi basics or whatever to get better informed, I can't repeat this
again and again.



Source Audio's icon

P.S.
max sustain object will not help you with what you want,
but there is lsustain object in lobjects externals from Peter Elsea.
If you use windows or max without arm processr, downoad link:

http://peterelsea.com/lobjects.html

for mac with arm processors:
https://cycling74.com/forums/peter-elsea's-lobjects-macos-universal-x86_64-and-arm64

or direct downad ink :
https://www.dropbox.com/s/ur286cuvubqghhh/lobjects%20macos%20universal%20220830%20TEST.zip?dl=1

----
you can read here what it can do, to see if it works for you :


R_Gol's icon

Thanks for detailed explanation. I will look at the Sustain object

Source Audio's icon

Here is one option using retrigger of held notes.
You did not answer what is your prefered way of dealing with
replaying held notes, so I picked retrigger method.
there are 2 colls, 1 stores currently played notes and dumps them into 2nd coll when hold pedal gets pressed.
Notes that are included in HOLD get retriggered,
means they get first turned off, then on with new velocity.

Max Patch
Copy patch and select New From Clipboard in Max.

I guess lsustain would be more efficient, but you have to test
messages it accepts and create good monitoring of states of notes till you get it doing what you need.


R_Gol's icon

Thanks! but the notes press before the sustain pedal are keep sustaining even after flashing
Maybe I'm taking the pitch and velocity from the wrong place? I unpack whatever was connected to the noteout object

Source Audio's icon

patch can only work with included notein and noteout objects.
if you want to integrate it into something else, you must follow midi rules.

I'l be glad to help you, but need details about both source and destination
that you want to use

R_Gol's icon

It is a part of M4L polyphonic synthesizer.
Notes in are coming from midiin object:
The use of the if statement is just because my midi keyboard is outputting random velocities, so it is a fix of that issue.

the rest of the synth is just regular polyphonic synth. the midi pitch values are used to trigger different frequency of micro tuning using the scl object:

and this is where the velocity goes:

I hope this clear some things

Source Audio's icon

I think retrigger is not working properly.
I tested the patch I posted and it works 100%
if receiver is standard midi note object.
You must adapt your synth to work properly.
you trigger midinote message when ---scl changes
because it is 1st item in pack object
$1 0, $1 $2 - this retrigger can not work.

How about timing of js to read scales and output values ?
You must make creation of midinote list follow
midi message order and timing, no matter if you only send note number or that scales or whatever.

Source Audio's icon

P.S. you don't use velocity from midi input, but make all flat 75 ?

One could reduce the patch to ignore velocitoes and
use fixed value on or off, woud brek tanrd midi function,¨but you are not using it for midi anyway.
Why then adsr as such ?

R_Gol's icon

you don't use velocity from midi input, but make all flat 75 ?

It is just because the midi keyboard I have is outputting random values for velocity. I hope to get new midi keyboard soon so that won't be a problem.

You must adapt your synth to work properly.

What do I need to change?
here is my poly patch of the synth:

Max Patch
Copy patch and select New From Clipboard in Max.


and here is the main patch:

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

Sorry, but I can't help you with that.
1- I don't use Live.
2- your polypatch has too many objects I don't have
3- all is too messy and has too many things that have nothing to do with sustaining notes.
--------------
one can reduce your patch to this :

I replaced that scales with standard note frequencies. I don't think that zl.lookup would make list creation out of order, but I can't say how that is in Live.
reduced test with simple synth shows that hold works as it should.
if you want to test it :


Source Audio's icon

P.S. kslider sometimes extends highest note to what one does not see,
depening on set range and offset.You set offset to 24 and range 61 keys.
If you play highest note at the edge, note 85 will be ouput.
I inserted split 24 84 to disable it.
blue note display was disconnected in your patch,
which drifted into my example.
This is fixed now.

HoldTester.zip
application/zip 8.26 KB








R_Gol's icon

Wow! it is working :))) thank you so much for your time and help! not obvious at all!

👽'tW∆s ∆lienz👽's icon

this is so great... i had need for a sustain patch myself(to try out supercollider-synth conversions using my keyboard... and then to alter the tuning system manually, etc...)...
here's a version of the last patch SOURCE AUDIO posted but where i made a DX7-style rhodes from some supercollider code i found, and my '(de)tuningz' subpatcher is just a way to stretch the octave by intervals defined by the golden-ratio(but i'm not even sure i do it correctly)... just having fun playing around with the patch in general tonight:

raj_sus.zip
application/zip 15.25 KB

Thank You So Much For This Amazing Patch!
♠️♥️♥️♠️