Your shopping cart is empty.

Save the position of the pressed drum pad

Submitted by verdeal on Tue, 12/28/2021 - 17:55
verdeal
Pro User
Control Surface Studio User

Hello! I've been trying this for a few days and I'm not able to. I hope you can help me.

I would like to save in a modifier the number corresponding to the last drum pad pressed. The reason is that I have an encoder, which depending on which drum pad is pressed, will do a different thing (it will change different modes according to a modifier).

In summary. A modifier with the numbers 1 to 16 according to the last drum pad that was pressed in a drum rack (Kick, Rim, Snare, HH ...)

THANK YOU!

Topic Category: 

21 Responses

Comments

Christian Björklund
Control Surface Studio User
#1

Hello! I'd do this:

Create a Reaction, and set the first pad as a listener (I use buttons in my example cause that's what I have, hopefully it's all the same)

Listener - the first button

Condition - if the button's latest velocity is greater than 0

Action - Set value of modifier m1 to 1

Action - Display value in status bar - m1 (for testing)

...then duplicate the reaction, but change button and set m1 to 2 instead.

This works for me, when I hit the buttons I get 1 or 2 printed in the Live's status bar

To do all this is in one single reaction, I assume you can make all the buttons listeners ("or when this happens..") and then have an action block for each button, setting m1 to 1, 2, 3 and so on

Hope it works - Cheers!

Christian Björklund
Control Surface Studio User
#2

..or if you want to use a custom script, create a reaction with all the buttons as listeners again, but instead of condition do a script that do it all. When I do this I get the lines from the previous blocks to see how it should be formatted, and use if and elif (else if) like this:

if self.midi_note_ch_0_val_87.cur_val > 0:
self.set_modifier_value("m1", 1)
elif self.midi_note_ch_0_val_88.cur_val > 0:
self.set_modifier_value("m1", 2)
elif self.midi_note_ch_0_val_91.cur_val > 0:
self.set_modifier_value("m1", 3)

If I do that, then have another action after that prints m1 to the display, I can see it changing with the buttons. (the values 87,88,91 are just my personal setup at the moment of course.)

Christian Björklund
Control Surface Studio User
#3

Actually it doesn't matter if you just use "if", so it can look like this too.

if self.midi_note_ch_0_val_87.cur_val > 0:
self.set_modifier_value("m1", 1)

if self.midi_note_ch_0_val_88.cur_val > 0:
self.set_modifier_value("m1", 2)

if self.midi_note_ch_0_val_91.cur_val > 0:
self.set_modifier_value("m1", 3)

Christian Björklund
Control Surface Studio User
#4

OH by the way, I just thought of something while brushing my teeth here. =)

If those pads only sends a note on when hit (but don't go back to velocity 0 like my buttons when I release them do) this last stuff won't work, since every single pad will have "last velocity greater than 0" so.. well the first version with a reaction per pad should be fine still.

John C
Forum Admin
#5

Hi guys,

Just chiming in on this, I believe Christian's approach is the way to do it - meaning, you will need to use button/pad presses on your midi controller as listeners. Drumpads themselves don't have listeners...

I was thinking 'live object model > song > selected parameter' could do the job, until I tested it and realised - doh, drumpads aren't parameters.
Then I thought - what about using 'selected drumpad > name changed' as the listener, then checked and - doh again, drumpads don't have a 'selected drum pad' option.

Christian Björklund
Control Surface Studio User
#6

Ah, I missed the "drum rack" part!

Well, as a listener, I get it to respond by using "Rack Device's selected drum pad value has changed". (> device > rack) then either using the selected track and device or a specific one.
It looks like this: self.song().tracks[0].devices[0].view.add_selected_drum_pad_listener

The "Auto select" (lower left corner) of the drum rack needs to be active so that it selects the latest played pad.

Well, it works like that on a specific track and device number, but when I changed to selected track and device, it's not really stable,.. works until I added another device and then it just won't respond anymore even when selected... odd.

Now how to check what pad has been pressed I'm not sure, but I'm guessing you could get whatever MIDI the drum racks gets or sends and use that to check?

Christian Björklund
Control Surface Studio User
#7

Yup, got it to work!

Listener:
self.song().tracks[0].devices[0].view.add_selected_drum_pad_listener

Action to print the notes coming out of the racks:
self.show_message(str(self.song().tracks[0].devices[0].view.selected_drum_pad.note))

So, this action, followed by one that prints m1 worked for me when selecting the drum rack pads (or playing from keyboard)

if self.song().tracks[0].devices[0].view.selected_drum_pad.note == 36:
self.set_modifier_value("m1", 1)

if self.song().tracks[0].devices[0].view.selected_drum_pad.note == 37:
self.set_modifier_value("m1", 2)

if self.song().tracks[0].devices[0].view.selected_drum_pad.note == 38:
self.set_modifier_value("m1", 3)

verdeal
Pro User
#8

First of all, say that I am infinitely grateful for your time and dedication, you are incredible.
Christian / Jhon THANK YOU!!

[...]
Listener:
self.song().tracks[0].devices[0].view.add_selected_drum_pad_listener

Action to print the notes coming out of the racks:
self.show_message(str(self.song().tracks[0].devices[0].view.selected_drum_pad.note))

So, this action, followed by one that prints m1 worked for me when selecting the drum rack pads (or playing from keyboard)
[...]

This part is working like a charm.
I almost screamed sitting here.

But if i add a action like:
if self.song().tracks[0].devices[0].view.selected_drum_pad.note == 36:
self.set_modifier_value("m1", 1)
Breaks the complete script.

I'm sure I'm doing something wrong, since I've never pasted the code directly. I hope you can help me. Thanks!
attached screenshot :)

verdeal
Pro User
#9

Hello again !
I almost have it but in the last step something fails. I have done a test with the first 4 pads (out of a total of 16).

- I have four reactions. Each one saves the last pad pressed to m1 (that works)

- If you see the screenshot "test1" it works but not how I want it, this is just a test to test the modifier.Switches between parameters 1, 2, 3 and 4

- If you see the screenshot "test2" it works as I want, without using modifiers

- If you see the screenshot "test3" (this is what I want) it doesn't work. For some reason, it is always playing on chain 5 of the Drum Rack and it does not change.

- Screenshot "Drum Rack" displays the Drum Rack configuration

Do you have any idea what i'm doing wrong?

Thanks in advance!!!

Christian Björklund
Control Surface Studio User
#10

Oh no, so close!

Yeah no worries this is a part of learning process for me, finding little challenges. I just got back getting my stuff over from the laptop to the main computer and realized I missed a ton of warnings in the log I completely missed before so, still not really know what I'm doing. =)

Hm! You could try to make it a separate action block instead, using a custom "Condition" saying

self.song().tracks[0].devices[0].view.selected_drum_pad.note == 36

..and then just set the modifier in the Action after, that works just the same, it's just that you'd have to set up a block like that for every single pad then.

Anyway I'll attach an image the action I used before just in case, but I can't see anything wrong with yours.

Christian Björklund
Control Surface Studio User
#11

Ah missed your last post! :) Will check out the device selector thing later, haven't used that part yet but I will need it.

verdeal
Pro User
#12

Thank you very much again :) I see that I am close to achieving something that I am really looking forward to, thanks to you. It's amazing.

I just read my last answer, written last night, and I saw that there is an error in the screenshot "test3". I am attaching the correct one (I am not on that computer now, so I have edited it by hand) with the real problem that it does not work.

This is the last step, which I do not understand what I am doing wrong.

Thank you very much friends, awesome.

upload files: 
Christian Björklund
Control Surface Studio User
#13

Hey man! I tested and got the same as you, if I choose chain using a number it works, but when I change to m1 it seems to be a bit strange.. oh wait... ah.

So, the numbering is actually starting from 0 (zero) not 1, but the interface use numbers from 1 so it's a bit misleading.

At the first note, set m1 to 0, the second set it to 1 etc.. this works for me at least.

if self.song().tracks[0].devices[0].view.selected_drum_pad.note == 36:
self.set_modifier_value("m1", 0)

if self.song().tracks[0].devices[0].view.selected_drum_pad.note == 37:
self.set_modifier_value("m1", 1)

if self.song().tracks[0].devices[0].view.selected_drum_pad.note == 38:
self.set_modifier_value("m1", 2)

if self.song().tracks[0].devices[0].view.selected_drum_pad.note == 39:
self.set_modifier_value("m1", 3)

Another thing to be careful with is if you start rearranging the pads, then the "receive" note has bo be adjusted in the rack chain list. I don't see any problem there in your screenshot though, just mentioning it cause I had done that and it cought me off track for a little while, haha.

Christian Björklund
Control Surface Studio User
#14

Hey John, by the way shouldn't selected_chain be accessible some way? I couldn't get it from the action hand thingie so tried to hack it and do this... which doesn't work, but technically something like this should be able to set a parameter inside a chain without modifiers at all, or am I wrong?

self.song().tracks[0].devices[0]view.selected_chain.devices[0].parameters[0].value = self.midi_cc_ch_0_val_16.cur_val

John C
Forum Admin
#15

I'm not 100% sure on the code for selected chain but if it exists, you're close, but missing a full stop before 'view'
Try this: self.song().tracks[0].devices[0].view.selected_chain.devices[0].parameters[0].value = self.midi_cc_ch_0_val_16.cur_val

Christian Björklund
Control Surface Studio User
#16

Ah damn, thanks!

Well no, it was worth a try but it only reaches the first chain in the list no matter what. Actually it's the same if I just put a number there .chains[4]. it still goes to nr zero so I guess that's not how it works.

verdeal
Pro User
#17

With your help I am achieving unthinkable things.
I have finally managed to do what I wanted and I am very happy and very excited.
Thank you both very much.

Christian,
your advice to change the modifiers starting counting from "0" was the soulción. Cool!

Your last comment leads me to a new question.
Is there a way that by pressing a button on my controller (it has 16 buttons), I directly select a drum pad?

Thank you guys so much. Remotify (and you) is awesome.

John C
Forum Admin
#18

I don't think there's a way to map selecting a drum pad (I could be wrong on this tho)...
Possibly selecting a device which is located inside the drumpad will make it selected?

I quickly tested it with internal mapping mode and selecting a device makes the parent drumpad semi highlighted (but not fully highlighted like when you click it with the cursor), So I'm not sure if Live treats that as selected.

Christian Björklund
Control Surface Studio User
#19

Do you mean without playing them? Otherwise if you just map the buttons to the pads and play them (with auto select active) shouldn't that already do the trick with the setup you have now?

verdeal
Pro User
#20

Sorry I didn't answer you before. Happy New Year !

In this case I cannot make your idea, since the same controller controls 4 tracks that are 4 different Drum racks, but it is not a major problem.

The important things ... are done!
Thank you. Now I am fixing small details, but the important things are WORKING <3

Remotify, and you, you are amazing.

Christian Björklund
Control Surface Studio User
#21

Yeah happy new year! =)

Ah, I was just about to say well you can always use modes and redirect midi to selected channel or something but the remembered you use modes for the chains already. The most logic would be to just let the controller do the same thing but for "selected channel" but that didn't really work, which I think turned out to be a bug.

Aanyway, there are always ways, but it gets over complicated pretty fast and I agree, whatever works works I need to remind myself of that too and not just keep trying to build the perfect setup. Have to play some music too!