APC40 - Step Sequencer, Note Mode, 2nd Device Control, etc.

Discuss music production with Ableton Live.
flippo
Posts: 486
Joined: Fri Feb 05, 2010 6:06 am
Location: Melbourne

Re: Note Mode for the APC40 - Python Scripts

Post by flippo » Wed May 26, 2010 3:23 pm

it's probably got something to do with inappropriately using multiple ifs?

flippo
Posts: 486
Joined: Fri Feb 05, 2010 6:06 am
Location: Melbourne

Re: Note Mode for the APC40 - Python Scripts

Post by flippo » Wed May 26, 2010 3:56 pm

flippo wrote:rightio.

Python (and coding) noob here.

I'm trying to achieve a note grid that uses the full 8 columns, as apposed to two groups of 4.

like so


36 37 38 39 40 41 42 43
44 45 46 47 48 49 50 51
52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67
68 69 70 71 72 73 74 75


and, I also want the lights to look like this (the ones with white bars over them are flashing)

Image


with my rudimentary coding skills I had a go and this is what I came up with. However, when I use this Live fails to connect with the APC40 at all.

Code: Select all

    def _on_note_mode_changed(self):
        if not self._master_button != None:
            raise AssertionError
        if self.is_enabled() and self._invert_assignment == self._toggle_pressed:
            if self._note_mode_active:
                self._master_button.turn_on()
                for scene_index in range(5):
                    #TODO: re-map scene_launch buttons to note velocity...
                    scene = self._session.scene(scene_index)
                    for track_index in range(8):
                        clip_slot = scene.clip_slot(track_index)
                        button = self._matrix.get_button(track_index, scene_index)
                        clip_slot.set_launch_button(None)                        
                        button.set_enabled(False)
                        button.set_channel(9) #remap all Note Mode notes to channel 10
                        if track_index < 8:
                            button.set_identifier(36 + (8 * scene_index)  + track_index))
                            if (scene_index == 4):
                                button.send_value(6)
                            if ((scene_index < 4) and (scene_index > 0)) and (track_index < 3):
                                button.send_value(5)
                            if (scene_index ==  0 and track_index == 2):
                                button.send_value(5)
                            if (scene_index < 1) and ((track_index == 3) or (track_index == 4) or (track_index == 5)):
                                button.send_value(2)
                            if (scene_index > 1 and scene_index < 4) and (track_index > 3 and track_index < 7):
                                button.send_value(1)
                            if (scene_index > 1 and track_index < 2):
                                button.send_value(3)
                            if (scene_index == 2 or scene_index == 3) and (track_index == 7):
                                button.send_value(4)
                            else:
                                button.send_value(0)
                self._rebuild_callback()
            else:
                self._master_button.turn_off()
        return None
I assumed, rightly or wrongly, from looking at the existing code that the top-most scene and the left-most track = 0, not 1?

I'm sure I've done some very basic coding error. I will do some more reading on python, but I thought in the meantime someone might be able to shortcut me :)


Just fixed the code a bit with the help of a friend (see edited version above), but it still dosen't work :(

Hanz_Petrov
Posts: 119
Joined: Sat Feb 06, 2010 2:39 pm
Contact:

Re: Note Mode for the APC40 - Python Scripts

Post by Hanz_Petrov » Thu May 27, 2010 1:07 am

You're almost there flippo. You want to be using the elif statement here, to check for a True condition. Here's how the relevant part should look (some bugs in your colour assignment math have also been fixed):

Code: Select all

                    for track_index in range(8):
                        clip_slot = scene.clip_slot(track_index)
                        button = self._matrix.get_button(track_index, scene_index)
                        clip_slot.set_launch_button(None)                       
                        button.set_enabled(False)
                        button.set_channel(9) #remap all Note Mode notes to channel 10
                        button.set_identifier(36 + (8 * scene_index) + track_index)
                        if (scene_index == 4):
                            button.send_value(6)
                        elif (scene_index > 0) and (track_index < 3) or (scene_index ==  0 and track_index == 2):
                            button.send_value(5)
                        elif (scene_index < 2) and ((track_index == 3) or (track_index == 4) or (track_index == 5)):
                            button.send_value(2)
                        elif (scene_index > 1) and (track_index > 2 and track_index < 7):
                            button.send_value(1)
                        elif (scene_index < 2 and track_index > 5):
                            button.send_value(3)
                        elif (scene_index == 2 or scene_index == 3) and (track_index == 7):
                            button.send_value(4)
                        else:
                            button.send_value(0)   
Best,

Hanz
http://remotescripts.blogspot.com/ - an introduction to the Framework classes

flippo
Posts: 486
Joined: Fri Feb 05, 2010 6:06 am
Location: Melbourne

Re: Note Mode for the APC40 - Python Scripts

Post by flippo » Thu May 27, 2010 1:16 am

legend :) (I thought there would be some bad maths, I was half asleep :oops: )

flippo
Posts: 486
Joined: Fri Feb 05, 2010 6:06 am
Location: Melbourne

Re: Note Mode for the APC40 - Python Scripts

Post by flippo » Thu May 27, 2010 1:26 am

awww rad it works :D

flippo
Posts: 486
Joined: Fri Feb 05, 2010 6:06 am
Location: Melbourne

Re: Note Mode for the APC40 - Python Scripts

Post by flippo » Thu May 27, 2010 2:44 am

interesting. If you enable remote on the APC output, you do get some LED feedback.

For example my looper speed reset button, which I've coded to be red, once assigned turns green. But if I use my looper speeed +12 or -12 buttons to change that value the LED turns off. Kinda usefull because I can tell if the looper speed is at 0 without looking at the screen. I do lose the red colour, though.

As for the row of notes to control the groove %, no feedback there.

My reverb preset buttons are assigned to launch midi clips that modulate my reverb parameters via Midi Yoke - when remote is enable for the APC output the lights are only on when those clips are actually playing. If I had those clips on a dedicated midi channel of their own, and set them to loop, I could use that to get visual feedback as to what my current reverb preset is - once again it has to be green though.

I wonder if there is a way to intercept the remote message and change it to another colour? that would be very handy.

I think in the meantime I'll just leave the output remote off and stick with my existing colour scheme without the feedback.

rishi
Posts: 171
Joined: Wed Jan 25, 2006 5:06 am
Location: Melbourne
Contact:

Re: Note Mode for the APC40 - Python Scripts

Post by rishi » Fri May 28, 2010 1:01 am

Hanz, thanks so much for posting these tutorials. Very informative and easy to read for such technical stuff.

I have an interest in taking the Device Control and Transport Control components of the APC40 and using them in the Launchpad script. I can make the Launchpad send the corresponding messages to emulate the APC40 as I am using BomesMT do this for other things with the Launchpad.

Am I correct in assuming that I can copy those DeviceControl and TransportControl components from the APC40 script into my new script containing all the Launchpad framework components to add device and transport control to the Launchpad?

I am thinking of using the following: (Is this correct or the Shiftable Components just for SHIFT-Features)
DetailViewControllerComponent
ShiftableDeviceComponent
ShiftableTransportComponent

I was hoping to use Bomes the components un-edited rather then editing the Python script.

Just wondering if this is possible or am I on the wrong track here? What would I need to do?

Hoping you can point me int the right direction.

Thanks :-)


PS: I shouldnt have read this before going to bed last night, as I couldnt sleep and ended up reading it all again in detail on my iphone in bed at 2:30 in the morning all excited about the possibilities!!!

flippo
Posts: 486
Joined: Fri Feb 05, 2010 6:06 am
Location: Melbourne

Re: Note Mode for the APC40 - Python Scripts

Post by flippo » Fri May 28, 2010 2:49 am

hanz,

do you think it would be easy to get the master button to fire out note 76 on channel 10 each time it is pressed, while retaining it's existing functionality?

With that, I think I could rig up some midi device racks to provide visual feedback while in user mode.

Hanz_Petrov
Posts: 119
Joined: Sat Feb 06, 2010 2:39 pm
Contact:

Re: Note Mode for the APC40 - Python Scripts

Post by Hanz_Petrov » Fri May 28, 2010 3:50 pm

@rishi: Unfortunately, it’s not quite so simple. The APC40 has rotary encoders for device control, whereas the Launchpad only has buttons and uses strips of buttons to approximate sliders - the required components are therefore quite different. Also, as the names imply, Shiftable components are designed to be used with a shift button, and are not directly compatible with Launchpad-style “pages of controls”. As I see it, you would really need to dig into the Launchpad scripts and create some new components in order to get this going (using the APC40 scripts mostly for reference). It’s possible, but definitely not simple.

@flippo: Based on your observations, I had a quick look at MIDI feedback in Note Mode. It would seem that feedback sort of works, but maps back to the original note and channel values for the various buttons, and not to the translated Note Mode values, as I suspected. So, for example, if you use the Note Mode grid to send out note 52 on channel 10, then bounce it back to the APC on channel 1, it will light up the first button of the first row (since note 52 channel 1 is the default value for this button). Not sure if the real APC20 Note Mode is any different. On the other hand, it should be possible to add code which translates incoming Note Mode notes to light up the corresponding LEDs, but this would be a lot of work. It would also be possible to have the Master button send out a MIDI note on each press, if that’s what you want, but it might be easier to forward the default note for this button, since it’s already sending out a note on each press.

Best,

Hanz
http://remotescripts.blogspot.com/ - an introduction to the Framework classes

ekalavyadas
Posts: 1
Joined: Sat May 22, 2010 10:42 am

Re: Note Mode for the APC40 - Python Scripts

Post by ekalavyadas » Sat May 29, 2010 11:55 am

Hanz, this looks exciting.

Will this work on Mac?

I can see that Python is "cross platform", and windows is mentioned too.

But I have not seen any mention of mac.

Please clarify.

This may make the difference for me to purchase a APC40.

Thanks.

-- eka

Hanz_Petrov
Posts: 119
Joined: Sat Feb 06, 2010 2:39 pm
Contact:

Re: Note Mode for the APC40 - Python Scripts

Post by Hanz_Petrov » Sat May 29, 2010 4:22 pm

ekalavyadas wrote:Hanz, this looks exciting.

Will this work on Mac?
Hi eka,

Yes, it's platform independent. If you can run Live 8 [edit: 8.1 or higher], then you can use these scripts.

Best,

Hanz
Last edited by Hanz_Petrov on Sun May 30, 2010 2:43 am, edited 1 time in total.
http://remotescripts.blogspot.com/ - an introduction to the Framework classes

Markemark
Posts: 250
Joined: Mon Jun 22, 2009 3:51 pm

Re: Note Mode for the APC40 - Python Scripts

Post by Markemark » Sat May 29, 2010 11:48 pm

Hanz_Petrov wrote:
ekalavyadas wrote:Hanz, this looks exciting.

Will this work on Mac?
Hi eka,

Yes, it's platform independent. If you can run Live 8, then you can use these scripts.

Best,

Hanz
Any advise to get these to work in 8.0.9? Once selected in the midi pref the apc stays dark :cry:

flippo
Posts: 486
Joined: Fri Feb 05, 2010 6:06 am
Location: Melbourne

Re: Note Mode for the APC40 - Python Scripts

Post by flippo » Sun May 30, 2010 2:13 am

Hanz_Petrov wrote: @flippo: Based on your observations, I had a quick look at MIDI feedback in Note Mode. It would seem that feedback sort of works, but maps back to the original note and channel values for the various buttons, and not to the translated Note Mode values, as I suspected. So, for example, if you use the Note Mode grid to send out note 52 on channel 10, then bounce it back to the APC on channel 1, it will light up the first button of the first row (since note 52 channel 1 is the default value for this button). Not sure if the real APC20 Note Mode is any different. On the other hand, it should be possible to add code which translates incoming Note Mode notes to light up the corresponding LEDs, but this would be a lot of work. It would also be possible to have the Master button send out a MIDI note on each press, if that’s what you want, but it might be easier to forward the default note for this button, since it’s already sending out a note on each press.
cheers Hanz. Yes you are right about the note mode. What i intend to do is, for example with the bottom row, is to have a rack of midi effects that send notes back to the APC (original notes) in set patterns, and then use a chain selector on said rack to remote control the light feedback simultaneously to the parameter that they represent. The idea of having the master button send out a note is to toggle on/off all those LED feedback message racks in sync with toggling the note mode itself. I do something similar with my padkontrol, only using blinking speeds and patterns to represent different states instead of colours.

As for the 'but it might be easier to forward the default note for this button, since it’s already sending out a note on each press' - did not think that was thew case? When looking through midi-ox, it seems to prompt the device control knobs to send out an update of their CC values for channel 9, rather than actually sending out its own note. As these values are constantly different I cant use bomes to trigger a note :(

Time to learn some more pythonz.

Hanz_Petrov
Posts: 119
Joined: Sat Feb 06, 2010 2:39 pm
Contact:

Re: Note Mode for the APC40 - Python Scripts

Post by Hanz_Petrov » Sun May 30, 2010 2:54 am

Markemark wrote: Any advise to get these to work in 8.0.9? Once selected in the midi pref the apc stays dark :cry:
Just had a look; unfortunately, these scripts only work with 8.1 and higher, due to subtle changes made to the Live API between ver 8.0 and 8.1. Sorry if I caused any confusion.

Hanz

PS: It would in fact be possible to create a version which is compatible with ver 8.0 (or Live 7 for that matter), but a fair bit of work would be involved, and it would be a pain to maintain the code...
http://remotescripts.blogspot.com/ - an introduction to the Framework classes

Hanz_Petrov
Posts: 119
Joined: Sat Feb 06, 2010 2:39 pm
Contact:

Re: Note Mode for the APC40 - Python Scripts

Post by Hanz_Petrov » Sun May 30, 2010 3:06 am

flippo wrote: As for the 'but it might be easier to forward the default note for this button, since it’s already sending out a note on each press' - did not think that was thew case? When looking through midi-ox, it seems to prompt the device control knobs to send out an update of their CC values for channel 9, rather than actually sending out its own note. As these values are constantly different I cant use bomes to trigger a note :(
I'll try to take a look at options for implementing some kind of feedback - or alternatively, a way of forwarding the Master button's MIDI messages (since they are currently getting swallowed...), when I get a chance.

Best,

Hanz

PS: If you MIDI-map the Master button, you'll see that it is sending Note 80 (G#4) on channel 1.
http://remotescripts.blogspot.com/ - an introduction to the Framework classes

Post Reply