Help with Kslider in Max 5.0

skiesbleed's icon

Hello,
I've recently started learning Max/MSP 5.0, and while working on a bit of a project, I've run into an issue. I'm trying to create a program that, among other things, allows someone to input the notes they want played in a chord by selecting them with the mouse, and then trigger them with a keypress. I almost have the functionality working, but I'm stuck. The keyboard is in polyphonic mode, and the keypress sends the message chord to the left inlet of the kslider. This results in the chord being played, as desired, but it also causes the highlighted notes to be clear from the kslider after the chord is played. I've tried so many things, from automatically updating presets to trying to work in some means of feeding the value back into itself only once, but all to no avail. Is there something simple that I'm missing?

Any and all help would be very much so appreciated.

Thank you!
-Jack

Luke Hall's icon

Are you using the [makenote] object? Or sending the "flush" message to [kslider] at any point? It seems like you're sending it note-off messages but without seeing your patch I can only guess how this is coming about. You can post your patch to the forum by highlighting it in max and then selecting "copy compressed" from the edit menu and simply pasting the nonsensical code here.

lh

skiesbleed's icon

Alright, thanks. Here is the code. The issue I'm having is in the subpatch midi. I'm not using flush or makenote at any point; just a chord message triggered by a key press. By the way, the key is being pressed on a USB device, which is why the system prefix is there, etc. All of that is working fine for what I'm testing now; it's just that the notes that I put on the kslider with mouse clicks are taken away after pressing the key and hearing the chord. Thanks again for helping me out!

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

Luke Hall's icon

Everytime you receive something via [r midi_out] you are triggering the "chord" message to the [kslider]. If you look in the [kslider] help file it says that the "chord" message sends note-offs for all currently held notes before it does anything else. So this is why your [kslider] is being cleared each time.

You might want to use two seperate [kslider]s, one for chord input and one to display the currently playing notes.

lh

skiesbleed's icon

Thanks for taking a look and helping me out. I tried that, but the problem that arose was the fact that sending a bang to the [kslider] that stored chord input would only resend the last note, so I ended up with one keyboard featuring the whole chord but unable to transfer it, and the other empty. I tried to fix this by appending the notes that were added to the chord message itself, so that it would resend those notes each time. This came close, but the problem I have now is that if I take a note away without using my clear message, it doesn't take it out of the chord message, so it still gets sent. I'll keep playing around with this to see if I can find a solution. Thanks again.

Luke Hall's icon

Here's one method I've put together quite quickly. I'm sure there are much better ways to do this but hopefully it will help you a bit. You can store three chords: open the [gate] to a location then add notes on the top [kslider]. The numbers 1, 2 and 3 on your keyboard should then trigger the chords and display properly on the lower [kslider].

lh

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

skiesbleed's icon

Thank you very much! It looks like I can learn a lot from this. I appreciate it!

Luke Hall's icon

My pleasure. Another hint: you might want to look at the [coll] object for storing your chords all in one place. It might simplify things.

lh

skiesbleed's icon

I just wanted to thank you again; this part of my program is now complete, for the most part. I'm mapping a total of 56 chords, so now I'm working on an interface for keeping them all accessible without having 56 boxes with parameters, haha. I'll look into the [coll] object to see if that will help with this. Onwards and upwards!