User remote scripts question

Discuss music production with Ableton Live.
Post Reply
djdiskmachine
Posts: 7
Joined: Mon Jan 09, 2012 6:35 pm

User remote scripts question

Post by djdiskmachine » Tue Dec 17, 2013 8:51 am

Hello!
I'm trying to expand the great work done by ModernDJ with the red box interface provided in this script: http://djnsm.com/wp-content/uploads/201 ... ern_dj.zip This is a script for Ableton 9 to improve versatility of a simple midi controller.

I'd like to start out small and just add some track arm, solo and mute buttons, and I'm pretty sure I've found the right place to add some code.

There's a method called _setup_mixer_control where some interesting things are going on, I'll post some code.

# volume control specific, will move with red box
# Set up mixer locally / object
def _setup_mixer_control(self):
self.mixer = CustomMixerComponent(self.box_width, self) # essentially grab the super class
self.mixer.name = 'Mixer' # sure, why not
self.mixer.set_track_offset(0) # not sure if needed, seems not to hurt.
# check box width and tuple size. Forward compatibility
if len(self.track_volume) == self.box_width: # error checking per established app standard
# loop on the CCs and create strip/volume control

for index in range(self.box_width): # @todo kill this and count in reverse via decrement (performance)
strip = self.mixer.channel_strip(index)
strip.set_volume_control(self.slider(midi_channel, self.track_volume[index]))

strip_arm_button = ButtonElement(True, MIDI_NOTE_TYPE, index, arm_button[index]) #These three lines is what I added expecting it to work flawlessly
strip.arm_button.name = str(index) + '_Arm_Button'
strip.set_arm_button(strip_arm_button)

However, the final line, strip.set_arm_button(strip_arm_button) causes the compilation to crash and the script to not work. This implementation is a very similar method of doing it copied from another remote script, namely the one for APC40.

AFAIK the only way to debug a script is to read the log.txt which really is a wall of compact logging messages. Please do tell if you have any advice for my problem!

Regards /M

fishmonkey
Posts: 4479
Joined: Wed Oct 24, 2007 4:50 am

Re: User remote scripts question

Post by fishmonkey » Tue Dec 17, 2013 10:10 am

having a squizz at the code for STC and Kimidi might be enlightening:

http://stc.wiffbi.com/

djdiskmachine
Posts: 7
Joined: Mon Jan 09, 2012 6:35 pm

Re: User remote scripts question

Post by djdiskmachine » Fri Dec 20, 2013 1:02 am

Didn't find it too enlightening actually, the comments don't strike me as very helpful.
However, I did some digging around and also had some happy accidents.
Seems to me that it might be necessary to delete all the .pyc-files before rebooting (not very surprising I guess) but also it seems that the Log.txt needs to be removed for the compilation to succeed. Strange.

Short follow up-statement. If one wants to add send knobs to each track, I was trying to use the method call:
self.mixer.channel_strip(index).set_send_controls(EncoderElement(MIDI_CC_TYPE,midi_channel,send_a[index],Live.MidiMap.MapMode.relative_two_compliment))
Whew!
This resulted in an error of the following message:
*method call* TypeError: 'EncoderElement' is not iterable.
I was like.. What's that supposed to mean, I'm assigning the volume faders in the same manner successfully.
Seems like the send controls call takes two parameters of the same type, eg:
self.mixer.channel_strip(index).set_send_controls((EncoderElement(MIDI_CC_TYPE,midi_channel,send_a[index],Live.MidiMap.MapMode.relative_two_compliment),EncoderElement(MIDI_CC_TYPE,midi_channel,send_b[index],Live.MidiMap.MapMode.relative_two_compliment)))

Just if anyone stumbles upon the same problem...
Now for making the sends selectable in another red box! ;)

dynamiiic
Posts: 56
Joined: Sat Apr 16, 2011 1:39 pm

Re: User remote scripts question

Post by dynamiiic » Mon Dec 30, 2013 6:27 pm

djdiskmachine wrote:Didn't find it too enlightening actually, the comments don't strike me as very helpful.
However, I did some digging around and also had some happy accidents.
Seems to me that it might be necessary to delete all the .pyc-files before rebooting (not very surprising I guess) but also it seems that the Log.txt needs to be removed for the compilation to succeed. Strange.
Hey! You do not need to remove the pyc files, everytime you change in the preferences from a script to none and back to the script I think Live recompiles it (not sure) but i'm certain that when you restart Live the py files are compiled to pyc. Log.txt is just dumped the log of Live, also not needed to delete.

About the sends: they must be sent as an array for each track, even if you only want to use just a send knob.
Here's my script for the NanoKontrol2. I've done what you seek to achieve and a lot more, go and have a look at the code!

Good luck

dynamiiic
Posts: 56
Joined: Sat Apr 16, 2011 1:39 pm

Re: User remote scripts question

Post by dynamiiic » Mon Dec 30, 2013 6:27 pm

djdiskmachine wrote:Didn't find it too enlightening actually, the comments don't strike me as very helpful.
However, I did some digging around and also had some happy accidents.
Seems to me that it might be necessary to delete all the .pyc-files before rebooting (not very surprising I guess) but also it seems that the Log.txt needs to be removed for the compilation to succeed. Strange.
Hey! You do not need to remove the pyc files, everytime you change in the preferences from a script to none and back to the script I think Live recompiles it (not sure) but i'm certain that when you restart Live the py files are compiled to pyc even with the old pyc there. Log.txt is just dumped the log of Live, also not needed to delete.

About the sends: they must be sent as an array for each track, even if you only want to use just a send knob.
Here's my script for the NanoKontrol2. I've done what you seek to achieve and a lot more, go and have a look at the code!

Good luck

Post Reply