How to : use midi remote script Major Update (sparkle)

Discussion of music production, audio, equipment and any related topics, either with or without Ableton Live
Madberry
Posts: 1
Joined: Thu Jan 05, 2012 11:04 pm

Re: How to : use midi remote script Major Update (sparkle)

Post by Madberry » Tue Feb 04, 2014 7:59 am

Awesome post! There can never be enough post on making MIDI remote scripts. Keep up the good work!

Raztua
Posts: 24
Joined: Fri Dec 20, 2013 7:38 pm

Re: How to : use midi remote script Major Update (sparkle)

Post by Raztua » Sun Feb 09, 2014 9:45 pm

ttilberg wrote:That looks really helpful!

Honestly, I lost interest in hacking Live about 6 months ago after running up against so many walls of things that didn't work. In part because I was learning .py along with it, and in part because the documentation is so scattered. With these new resources, my interest has sort of been re-perked at figuring it out.

The two things that I feel would be awesome with my BCR2000:
1) Context aware synth control for more than 8 parameters, without having to shuffle pages.
i.e.: With Operator selected (blue-hand style), I can have the 24 main nobs controlling the 24 parameters I find most helpful. With Analog selected, they are different. And ideally, a way to do the same for VSTs, perhaps through config routing and saving a rack with it in there. This seems so damned straightforward in pseudo code, but I just couldn't make the right connections.

2) I always thought it would be cool to make an 808/909 style sequencer out of it -- it has 16 lights you can use, and you could map the knobs to different common drum-hit parameters like decay, etc. I have some drum racks that I've saved that would work really great, but I don't have enough control over the mapping interface to make it all work, and be contextually aware. This is where your SparkLE project piqued my interest most of all.
Wow i have checked the price of the BCR 2000.... occasion for 70 euros.
I think a friend of mine will buy this surface and i will script it for him.
That would be crazy to have a stepsequencer for this price.

ttilberg
Posts: 587
Joined: Wed Oct 05, 2011 4:55 pm
Contact:

Re: How to : use midi remote script Major Update (sparkle)

Post by ttilberg » Mon Feb 10, 2014 5:58 am

Raz, if you do, I would really appreciate you documenting your journey some more, sharing source, etc.

Thanks for your contributions!
Tim Tilberg - Duluth, MN | SoundCloud - Arsenal
2011 13" MBP w/8GB ram | Live 9 Suite, Reason 6.5, FXPansion DCAM/Etch/Maul, Izotope Ozone 5

Raztua
Posts: 24
Joined: Fri Dec 20, 2013 7:38 pm

Re: How to : use midi remote script Major Update (sparkle)

Post by Raztua » Mon Feb 10, 2014 7:34 am

ttilberg wrote:Raz, if you do, I would really appreciate you documenting your journey some more, sharing source, etc.

Thanks for your contributions!

It will be done if i find a way to get it.
By the way did you try to modify the code the way i told you ?

ttilberg
Posts: 587
Joined: Wed Oct 05, 2011 4:55 pm
Contact:

Re: How to : use midi remote script Major Update (sparkle)

Post by ttilberg » Mon Feb 10, 2014 3:44 pm

I spent some time tweaking the code to install the Live Telnet script, and started working on getting the code hooked up for BCR, but didn't get very far. I was actually messing with the BCR again this past weekend (fixing some internal hardware issues) and was going to start writing code again today, which is why I thought to come back and check this thread lol.

Programming the BCR to accept the sparkle mapping shouldn't be tricky, but I'm wanting to try writing the stuff using it's factory presets, so that other BCR2000 scripts work as well. On the factory preset, the first page is all strictly CC messages for every control. I imagine that should work out just as well, just needing to alter all of the definitions in the script you wrote.

I'll let you know if I come up with anything cool as well.
Tim Tilberg - Duluth, MN | SoundCloud - Arsenal
2011 13" MBP w/8GB ram | Live 9 Suite, Reason 6.5, FXPansion DCAM/Etch/Maul, Izotope Ozone 5

infernal.machine
Posts: 1051
Joined: Mon Oct 15, 2012 1:34 am

Re: How to : use midi remote script Major Update (sparkle)

Post by infernal.machine » Mon Feb 10, 2014 6:25 pm

Really happy to see someone posting information about this stuff on the forums! Learning how to make simple MIDI remote scripts is way more difficult than it needs to be, glad to see people talking about it!

The LiveUtils.py file, written by Rob King in that LiveTelnet package you posted, has been invaluable for me to understand the syntax needed to access Live's API. I'm currently working on a version of LiveUtils that includes ALL the commands that I know how to use, with good documentation to explain how to use them. I'm pretty much just pulling from the Live Object Model, located here: http://cycling74.com/docs/max6/dynamic/ ... ject_model

... so if you know of any other resources let me know!!

The scripts I've written look a lot different from yours, so I'm interested to dive deeper. For the most part, I write a bunch of 'if MIDI message received is X, make Live do Y', which really just serves to avoid MIDI mapping and to control Live directly with my controllers. It also gives my controllers more functionality and improves my workflow.

Raztua
Posts: 24
Joined: Fri Dec 20, 2013 7:38 pm

Re: How to : use midi remote script Major Update (sparkle)

Post by Raztua » Mon Feb 10, 2014 7:48 pm

ttilberg wrote:I spent some time tweaking the code to install the Live Telnet script, and started working on getting the code hooked up for BCR, but didn't get very far. I was actually messing with the BCR again this past weekend (fixing some internal hardware issues) and was going to start writing code again today, which is why I thought to come back and check this thread lol.

Programming the BCR to accept the sparkle mapping shouldn't be tricky, but I'm wanting to try writing the stuff using it's factory presets, so that other BCR2000 scripts work as well. On the factory preset, the first page is all strictly CC messages for every control. I imagine that should work out just as well, just needing to alter all of the definitions in the script you wrote.

I'll let you know if I come up with anything cool as well.
Ill help you with your research as much as i can : wewill try to modify the sparkle script to work with the presets of the BCR
in the const.pyfile you can find this :

Code: Select all




#button map
REC=24
STOP=25
PLAY=26
TRANSPORT_BUTTONS=(('REC',REC),
 ('STOP',STOP),
 ('PLAY',PLAY))

SELECT=20
BUTTON_18_916=21
MUTE=22
SOLO=23

SELECT_BUTTONS=(('SELECT',SELECT),
('BUTTON_18_916',BUTTON_18_916))

LOW=35
MEDIUM=34
HIGH=33
VOLUME_BUTTONS=(('LOW',LOW,35),
('MEDIUM',MEDIUM,64),
('HIGH',HIGH,127))

BANK=16
PATT=17
SEQ=18
TUNE=19

MODE_BUTTONS=(('BANK',BANK),
('PATT',PATT), 
('SEQ',SEQ), 
('TUNE',TUNE))

PATTERN_LENGTH_BUTTON=(('LESS',36),
('MORE',37))


PATTERN_BUTTONS=range(0,16)
PAD_BUTTONS=range(60,68)
PAD_LEDS=range(68,76)
you have to modify theese elements according to the BCR configuration.

Code: Select all

PAD_BUTTONS=range(60,68)
PAD_LEDS=range(68,76)  // you have to find how you light the leds

Code: Select all

BANK=16
PATT=17
SEQ=18
TUNE=19
here for the minimal use of the bcr you need to modify PATT, SEQ, TUNE. The bank button must be changed too, but we will change its role : it will be our select button:

on the Patternbutton.py try to change :

Code: Select all

    def bank_button_value(self,value):
        if value>0:
            if self.parent.actual_clipslot!=None:
                
                for element in self.parent.pattern_buttons :
                    self.turn_led_off(element.identifier)
                self.turn_led_on(self.identifier)
                self.parent.song().scenes[self.identifier].fire()
By ;

Code: Select all

   def bank_button_value(self,value):
        if value>0:
            self.status=True
            for element in self.parent.pattern_buttons :
                self.turn_led_off(element.identifier)
            self.turn_led_on(self.identifier)
            self.parent.actual_pad=self
            self.parent.update_cache()
            self.parent.update_pattern_button()
            self.parent.update_led()
Then the last thing to do is to modifie to midi CC information : you have to change MIDI_NOTE_TYPE to MIDI_CC_TYPE everywhere ;)

This might work

If i find the time i will try to write a little code that will work from scratch, even if i still don't have the BCR

------------------------------------------------------------------------------------------------------------------------
infernal.machine wrote:Really happy to see someone posting information about this stuff on the forums! Learning how to make simple MIDI remote scripts is way more difficult than it needs to be, glad to see people talking about it!
I m glad to see poeple still trying to manage to use midiremotescript.
Have you tried to use the telnet script? it is an unvaluable ressource.

Code: Select all

The LiveUtils.py file, written by Rob King in that LiveTelnet package you posted, has been invaluable for me to understand the syntax needed to access Live's API. I'm currently working on a version of LiveUtils that includes ALL the commands that I know how to use, with good documentation to explain how to use them. I'm pretty much just pulling from the Live Object Model, located here: http://cycling74.com/docs/max6/dynamic/c74_docs.html#live_object_model

... so if you know of any other resources let me know!!
i have a few other ressources
This is usefull when you try to use a script with fuctonsthat have been changed.

http://www.synnack.com/blog/post/137/


Moreover you can check this:

http://julienbayle.net/PythonLiveAPI_do ... ive9.1.xml

This is a part of the HUGE work made by Julien Bayle
and here another from hanz petrov
remotescripts.blogspot.fr/

Code: Select all

The scripts I've written look a lot different from yours, so I'm interested to dive deeper. For the most part, I write a bunch of 'if MIDI message received is X, make Live do Y', which really just serves to avoid MIDI mapping and to control Live directly with my controllers. It also gives my controllers more functionality and improves my workflow.
I think the core of the sparkle script is the dispatcher in the Spark main file:

Code: Select all

    def update_pattern_button(self):
        if self.actual_mode_button==self.mode_buttons[0]:
            for element in self.pattern_buttons:
                self.turn_led_off(element.identifier)
                element.clear_value_listeners()
                element.add_value_listener(element.bank_button_value, identify_sender= False)
        elif self.actual_mode_button==self.mode_buttons[1]:
            for element in self.pattern_buttons:
                self.turn_led_off(element.identifier)
                element.clear_value_listeners()
                element.add_value_listener(element.pattern_button_value, identify_sender= False)
            if self.actual_clipslot!=None:
                self.turn_led_on(self.actual_clipslot.identifier)       
        elif self.actual_mode_button==self.mode_buttons[2]:
            self.update_cache()
            for element in self.pattern_buttons:
                element.sparkle_sequencer_update()
                element.clear_value_listeners()
                element.add_value_listener(element.seq_button_value, identify_sender= False)
                
Here as you can see, i use both if statment, and modify the value listener. I found that this was the best way to modify the script.

By the way i have not worked on the automapping. Could you give me information ( for exemple are you able to link a fader to cutoff in a case and main volume in another case??)
Can you tell me for what hardware you are working on ???

ttilberg
Posts: 587
Joined: Wed Oct 05, 2011 4:55 pm
Contact:

Re: How to : use midi remote script Major Update (sparkle)

Post by ttilberg » Sat Feb 15, 2014 5:42 am

Hey Raz,

Tonight I tried to get the BCR-808 going, but I couldn't make things rocking.

I tried following your suggestions, but started getting lost when talking about the PAT, SEQ, TUNE, BANK stuff.

Specifically, the parts of the code that you were recommending changing:
def bank_button_value():
do not appear in the source I downloaded. As I am not totally clear what all of the different buttons and options are supposed to do in the first place, I'm not able to carry on debugging it.

I'm going to continue to try and poke at this. My first goal is to just get the 16 button lights to light up in time with the song position. I think that in itself would be kind of cool., and a good start.


I also don't understand how in your basic "light an led" code:
d)Practical example:
The aim of this example is to create a script that will light the pad 51 and write on the log file "HelloWorld" when the pad 50 is pressed

Code:
from __future__ import with_statement #compatibility for Live 9, need to be written at the first line of the script
import Live #you import Live, in order to be able to use its components
from _Framework.ControlSurface import ControlSurface
from _Framework.ButtonElement import ButtonElement
from _Framework.InputControlElement import *


IS_MOMENTARY=True

class sparkLE2(ControlSurface):
__module__=__name__
__doc__="Sparkle function"

def __init__(self, c_instance):
ControlSurface.__init__(self,c_instance)
with self.component_guard():
self.__c_instance = c_instance
self.show_message('Script initiated')
self.Pad1=ButtonElement(IS_MOMENTARY, MIDI_NOTE_TYPE, 0,60) # identifies P&d1 as a ButtonElement. IS_MOMENTARY is true if the button send a message on being released
self.Pad1.add_value_listener(self.helloworld,identify_sender= False) #adda value listener that will lauch the method self.helloworld when Pad1 is pressed

def disconnect(self): #this function is automatically called by live when the program is closed
self.turn_off_led(60)
self.turn_lef_off(61)

def helloworld(self,value):
if value>0: #value>0 when the pad is pressed
self.log_message(self,'hello world')
self.turn_led_on(61)
else:
self.turn_led_off(61)

def turn_led_on(self,value):
self._send_midi((144,value,64))
def turn_led_off(self,value):
self._send_midi((128,value,64))
Any of the values (60, 61) end up representing a control of 50? Is this just a typo?
Tim Tilberg - Duluth, MN | SoundCloud - Arsenal
2011 13" MBP w/8GB ram | Live 9 Suite, Reason 6.5, FXPansion DCAM/Etch/Maul, Izotope Ozone 5

Raztua
Posts: 24
Joined: Fri Dec 20, 2013 7:38 pm

Re: How to : use midi remote script Major Update (sparkle)

Post by Raztua » Sat Feb 15, 2014 7:21 am

Any of the values (60, 61) end up representing a control of 50? Is this just a typo?
Woops, this is a mistake, because i used for my exemple thevalue 51, and for the sparkle the first pad was the 60 ( and the second 61 instead of 51)...
i change my code :)

to have the light lighting following the beat, you can find some inspiration with the _light_follows_beat fuction present in the main file ( sparkle*.py)
I tried following your suggestions, but started getting lost when talking about the PAT, SEQ, TUNE, BANK stuff.

Specifically, the parts of the code that you were recommending changing:
def bank_button_value():
do not appear in the source I downloaded. As I am not totally clear what all of the different buttons and options are supposed to do in the first place, I'm not able to carry on debugging it.
wich version of the sparkle did you downloaded? it doesn't seems to be the latest, and many mistakes have been modified.
I suggest you to check the latest, not to learn mistake by reading the code

ttilberg
Posts: 587
Joined: Wed Oct 05, 2011 4:55 pm
Contact:

Re: How to : use midi remote script Major Update (sparkle)

Post by ttilberg » Sat Feb 15, 2014 3:29 pm

I thought I was using version 3.2, but I found the code you were referencing in version 1.3?

It would be cool if you could edit your first post with the current source code :)
Tim Tilberg - Duluth, MN | SoundCloud - Arsenal
2011 13" MBP w/8GB ram | Live 9 Suite, Reason 6.5, FXPansion DCAM/Etch/Maul, Izotope Ozone 5

Raztua
Posts: 24
Joined: Fri Dec 20, 2013 7:38 pm

Re: How to : use midi remote script Major Update (sparkle)

Post by Raztua » Sat Feb 15, 2014 7:15 pm

well that's right i have changed the way i was labelling my script.
Sorry if it has made confusion.

Raztua
Posts: 24
Joined: Fri Dec 20, 2013 7:38 pm

Re: How to : use midi remote script Major Update (sparkle)

Post by Raztua » Sat Feb 15, 2014 7:47 pm

Version 0.5 of the script avaliable here :Sources


many changes for this update !
  • Minor bug fixed
  • transport button are set
  • Select+pattern button->select the track associated to the number ( if it is a midi track)
  • button used to change level have been modified : now its the Global, slistcer and roller button
  • you can modify the volume of a volume button: if you keep the button pressed and rotate the jog wheel, you modify the value of this button
  • Tune mode has been changed-> it is no longer a piano but it is a step sequencer that works like modular sequencer works.
    to change the tone of the note keep the pattern button and use the jog wheel
  • Binary counter: je Proj., Kit, and Instr button under the jogwheel are used as a binary counter to know when to launch scene and keep a nice structure
  • Touchpad assignment modified
    as before the channel of the touchpad has the value of the pad selected
    you can use Filter, Send1/2 and Pan level to change the value of the automation -> 3 * 16 automation possible for the drumpad
A video will be added soon ( i don't have my webcam with me )

akamed
Posts: 30
Joined: Mon Sep 23, 2013 1:16 pm

Re: How to : use midi remote script Major Update (sparkle)

Post by akamed » Thu Mar 13, 2014 11:03 pm

Hello Raztua

congratulations for the posts!
I´ve been working with some of your examples and I´ve found them great.
I have one question about the "add_value_listener" function.
When I assign this:

self.Pad1.add_value_listener(self.button1,identify_sender= False)

It calls "button1" that is "def button1(self, value): ...." and works great.

But if I want to do this:

self.Pad1.add_value_listener(self.button1(99),identify_sender= False)

I want to call the "button" with (99) as a message received by "def button1(self, value, X): ....where X must received as 99.

I don´t find the way to achieve this. Do you have any ideas?

Thanks for your great work!

Buleriachk
Posts: 1257
Joined: Sat Dec 21, 2002 3:52 am
Location: Santa Barbara, CA
Contact:

Re: How to : use midi remote script Major Update (sparkle)

Post by Buleriachk » Fri Mar 14, 2014 2:03 am

What program do you use to open, edit, save, and compile your .py scripts?
Or does Live do it for you in some way? Obviously, I can't open a .py script with a text editor (well, I can, but I see a lot of compiled text, not a structured language)

So what are the actual steps to get started? Or am I missing something very simple (I used to be a C++ programmer....)

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

Re: How to : use midi remote script Major Update (sparkle)

Post by fishmonkey » Fri Mar 14, 2014 8:53 am

the .py files are Python source code files, if you set things up right (which is covered in the first post of this thread) then Live will compile the .py files down to .pyc (Python byte code).

the best editor to use is a programmer's editor that supports Python syntax. two decent free options are TextWrangler (OS X) and NotePad++ (Windows)...

Post Reply