Who wants access to Ableton's Python API? .. You? .. Ok!

Discuss music production with Ableton Live.
jah
Posts: 93
Joined: Mon Jun 28, 2004 6:53 pm

Post by jah » Sat Jun 09, 2007 12:07 am

I just did some livetelnet hacking and testing... incredibly cool.

Some questions regarding devices:
- Can I reach a parameter of a midi device inside a midi rack in a live set and change this state? For example, if I'd like to change the Out Hi parameter of a Velocity device in a MIDI Rack, can I do this?
- Can I also retrieve this parameter and add a listener to it, so it can be sent out by osc?

If this is possible I think I'll be able to port my ableton live / monome step sequencer (livestep48) from max/msp to python and add some really nice functionality.

See
http://forum.monome.org/topic/919
and
http://www.hornquist.se/monome
for more info.

This is currently a max/msp and ableton live 6 combo.

Nathan Ramella
Posts: 128
Joined: Wed Jun 06, 2007 10:48 am

Post by Nathan Ramella » Sat Jun 09, 2007 12:25 am

jah wrote: Some questions regarding devices:
- Can I reach a parameter of a midi device inside a midi rack in a live set and change this state? For example, if I'd like to change the Out Hi parameter of a Velocity device in a MIDI Rack, can I do this?
I believe so.
jah wrote: - Can I also retrieve this parameter and add a listener to it, so it can be sent out by osc?
Absolutely.
jah wrote: If this is possible I think I'll be able to port my ableton live / monome step sequencer (livestep48) from max/msp to python and add some really nice functionality.
I cannot wait to see this!
remix.net - versus / liveapi / hangthedj / ammobox

3dot...
Posts: 9996
Joined: Tue Feb 20, 2007 11:10 pm

Post by 3dot... » Sat Jun 09, 2007 12:47 am

LET THE GAMES BEGIN !!!
You guys are rocking our worlds right now !!!
The USERS here are the reason live is where it's at...
You guys are helping us get What we need....ableton support or not!!!
I guess this is the compensation for last week's Forum mayhem...
really... I just want to thank you again...

Angstrom
Posts: 14987
Joined: Mon Oct 04, 2004 2:22 pm
Contact:

Post by Angstrom » Sat Jun 09, 2007 12:52 am

Nathan Ramella wrote:Here's a really simple example of how to use the API. Install LiveTelnet, load up a project, select 'LiveTelnet' from the remote surfaces menu.

Telnet to localhost, you will be greeted with the LiveTelnet banner.. Then type in the following commands:

doc=Live.Application().get_application().get_document

'doc' is now an object that contains all the information about your song, all the tracks, clips, etc.. There's a lot of nesting in the objects but for a really simple example..

Type:

doc.tempo = 80
You've just set your project tempo to 80.
hmm, I'm an idiot somehow.
I can't even get Hello world to function!

here's what happens

Code: Select all

Welcome to the Ableton Live Python Interpreter (Python 2.2.1)
Brought to by LiveAPI.org
>>> doc=Live.Application().get_application().get_document
>>> doc.tempo=80
Traceback (most recent call last):
  File "<console>", line 1, in ?
NameError: name 'doc' is not defined
>>>


any clues where I am going wrong?

Nathan Ramella
Posts: 128
Joined: Wed Jun 06, 2007 10:48 am

Post by Nathan Ramella » Sat Jun 09, 2007 1:01 am

Angstrom wrote:
here's what happens

Code: Select all

Welcome to the Ableton Live Python Interpreter (Python 2.2.1)
Brought to by LiveAPI.org
>>> doc=Live.Application().get_application().get_document
>>> doc.tempo=80
Traceback (most recent call last):
  File "<console>", line 1, in ?
NameError: name 'doc' is not defined
>>>


any clues where I am going wrong?
My mistake, correct command is..

doc=Live.Application().get_application().get_document()

I updated my original 'hello world' post as well. Thanks for bringing this to my attention!
remix.net - versus / liveapi / hangthedj / ammobox

Angstrom
Posts: 14987
Joined: Mon Oct 04, 2004 2:22 pm
Contact:

Post by Angstrom » Sat Jun 09, 2007 1:13 am

hmm,
sadly not much closer with that.

Code: Select all

Welcome to the Ableton Live Python Interpreter (Python 2.2.1)
Brought to by LiveAPI.org
>>> doc=Live.Application().get_application().get_document()
>>> doc.tempo=80
Traceback (most recent call last):
  File "<console>", line 1, in ?
NameError: name 'doc' is not defined
>>>
I've allowed Live and Telnet on my firewall BTW

Nokatus
Posts: 1068
Joined: Fri Jul 01, 2005 7:06 am

Post by Nokatus » Sat Jun 09, 2007 1:16 am

8O

...

8O

I noticed this whole thing just now.

This is beautiful.

It's one of those rare moments when a piece of news hits you at 4 am and immediately space invaders start playing pong inside your head.

I really, really hope (and kind of expect) that the Ableton bunch will see the huge implications, and that they'll keep this door open in all the future versions as well. Live is just the right application for this kind of low-level customization.

Thank you!

Angstrom
Posts: 14987
Joined: Mon Oct 04, 2004 2:22 pm
Contact:

Post by Angstrom » Sat Jun 09, 2007 1:46 am

Ok, a little furter investigation.

the functions defined in LiveUtils work fine, EG:

Code: Select all

>>> trackName(1,"a test")
u'a test'
>>>
I just renamed track 2 to 'a test', and all the other functions defined in there work great.

But if I take something out of there and try and address the API with my own monkey fingers, like this.

Code: Select all

Live.Application.get_appliction().get_document().tracks[1].name="monkey_fingers"
Traceback (most recent call last):
  File "<console>", line 1, in ?
AttributeError: 'module' object has no attribute 'get_appliction'
>>>
I get that error there.

any ideas why the same code would work from the API function set, but not from my CMD window?

3dot...
Posts: 9996
Joined: Tue Feb 20, 2007 11:10 pm

Post by 3dot... » Sat Jun 09, 2007 2:06 am

Angstrom wrote:Ok, a little furter investigation.

the functions defined in LiveUtils work fine, EG:

Code: Select all

>>> trackName(1,"a test")
u'a test'
>>>
I just renamed track 2 to 'a test', and all the other functions defined in there work great.

But if I take something out of there and try and address the API with my own monkey fingers, like this.


Code: Select all

Live.Application.get_appliction().get_document().tracks[1].name="monkey_fingers"
Traceback (most recent call last):
  File "<console>", line 1, in ?
AttributeError: 'module' object has no attribute 'get_appliction'
>>>
I get that error there.

any ideas why the same code would work from the API function set, but not from my CMD window?
TYPO 'get_appliction'

Angstrom
Posts: 14987
Joined: Mon Oct 04, 2004 2:22 pm
Contact:

Post by Angstrom » Sat Jun 09, 2007 2:25 am

thanks,
monkey fingers and tired brain. I managed to get my own longhand calls to work now.

I've been fiddling with the functions included though.
It's great, too good to go to bed.

I know it's stupid but typing " launchClip(0,1) "
and hearing a beat start just makes me happy. Not because I like it the hard way , but because I am within touching distance of the old "set the master tempo from th efirst thing you record" holy grail

Code: Select all

>>> clip=getClip(0,1)
>>> print clip.length
16.0
that's actually 8 seconds, because that particular clip is 4 bars of 120 bpm
(8/4)*60 = 120

so I think to set the master tempo off the first thing you record... whatever length it may be

doc.tempo = ((clip.length/2)/4)*60

or something like that. (assuming you have assigned doc to be the Live document)

:)

right, bed

longjohns
Posts: 9088
Joined: Mon Dec 22, 2003 3:42 pm
Location: seattle

Post by longjohns » Sat Jun 09, 2007 5:33 am

But doesn't this assume some predefined clip length (in bars)

as in, "i'm going to play a 2 bar loop, and when I get to the end of it then you tell me how fast I played it and set your tempo accordingly"

Not that this is a bad thing, i'm just trying to get clear on what youre saying

ryansupak
Posts: 429
Joined: Wed Aug 18, 2004 7:23 pm

Post by ryansupak » Sat Jun 09, 2007 7:50 am

Thank you, thank you, thank you!
rs

noisetonepause
Posts: 4938
Joined: Sat Dec 28, 2002 3:38 pm
Location: Sticks and stones

Re: Scary cool!

Post by noisetonepause » Sat Jun 09, 2007 8:27 am

Tone Deft wrote:MAX vs. Python
- Python is free, no need to buy MAX
- Which is ultimately easier to program in? I'm leaning towards MAX, but I'm a n00b at both.
- MAX has visual tools (buttons, GUIs)
- Python has more latency, but that be worked on and for controls 60mS is fine.
- can't think, I'm in shock...
You can easily write GUI apps in Python... There'll even be a PythonCocoa bridge in next version of OS X so you can easily write native OS X apps in Python (yet another reason to learn it!). It's obviously not as easy as Max, but I was big on Reaktor for a while, and besides the crashes and the non-workingness of it, what put me off was the dragging of wires. It seems like a good idea at first, but then you have to patch up 8 16 output objects to corresponding input objects, or whatever. 100+ wires, just to see how one thing works... and two minutes later you realise that you actually need to insert a Log module or multiply by 10 or whatever. You delete your 8*16 wires, insert 8*16 objects (well, you insert 16 and the copy/paste 7 times - still tedious!), and draw 8*16*2 new ones... trust me, at some point you'll wish you were working with CSound!
Suit #1: I mean, have you got any insight as to why a bright boy like this would jeopardize the lives of millions?
Suit #2: No, sir, he says he does this sort of thing for fun.

jah
Posts: 93
Joined: Mon Jun 28, 2004 6:53 pm

Post by jah » Sat Jun 09, 2007 8:51 am

Nathan Ramella wrote:
jah wrote: Some questions regarding devices:
- Can I reach a parameter of a midi device inside a midi rack in a live set and change this state? For example, if I'd like to change the Out Hi parameter of a Velocity device in a MIDI Rack, can I do this?
I believe so.
Can you help me a bit. Download this example .ALS project:
http://www.hornquist.se/monome/midieffe ... locity.als

Open the project - that's simply a velocity effect within a midi effect rack in a midi track. Now, I'd like to reach the velocity device. In livetelnet I tried this (to retrieve the name of the velocity device):

>>> track = getTrack(0)
>>> track.devices[0].name
u'MIDI Effect Rack'
>>> track.devices[0].devices[0].name
Traceback (most recent call last):
File "<console>", line 1, in ?
AttributeError: 'Device' object has no attribute 'devices'
>>>

Didn't work that way.. It found the midi effect rack but not the velocity device. Is it impossible to reach devices which are contained within other devices (that is, they reside inside racks of some kind, like this velocity device)?

Thanks for the help.
Nathan Ramella wrote:
jah wrote: - Can I also retrieve this parameter and add a listener to it, so it can be sent out by osc?
Absolutely.
Sounds brilliant!
Nathan Ramella wrote:
jah wrote: If this is possible I think I'll be able to port my ableton live / monome step sequencer (livestep48) from max/msp to python and add some really nice functionality.
I cannot wait to see this!
I hope I can get it to work. I already have a version of this running with max/msp and live!

Kind regards

Nathan Ramella
Posts: 128
Joined: Wed Jun 06, 2007 10:48 am

Post by Nathan Ramella » Sat Jun 09, 2007 9:18 am

jah wrote:
Can you help me a bit. Download this example .ALS project:
http://www.hornquist.se/monome/midieffe ... locity.als

Open the project - that's simply a velocity effect within a midi effect rack in a midi track. Now, I'd like to reach the velocity device. In livetelnet I tried this (to retrieve the name of the velocity device):
Ok. So as far as devices contained inside racks, I don't think you can 'reach inside' the rack, however if you've assigned a macro value to one of the inside values, then you can poke things internal to the rack. At least thats what I'm currently seeing. Not ideal, yeah.. But. It's life. Basically as long as you map a macro to the setting you want to change you can then poke it like so:

Code: Select all

doc=Live.Application().get_application().get_document()

t=doc.tracks[0]

device=t.devices[0]

>>> for param in device.parameters: print param.name
...

Device On
Macro 1
Macro 2
Macro 3
Macro 4
Macro 5
Macro 6
Macro 7
Macro 8
Chain Selector

>>> for param in device.parameters: print param

...
on
0
0
0
52 <-- I mapped that to velocity drive, you could now set it by manipulating the 5th param device in the list
0
0
0
0
0

remix.net - versus / liveapi / hangthedj / ammobox

Post Reply