Create new audio track with input set to current selected track

Learn about building and using Max for Live devices.
Post Reply
agent314
Posts: 1458
Joined: Wed Apr 07, 2010 3:07 am

Create new audio track with input set to current selected track

Post by agent314 » Fri Jan 29, 2021 12:55 am

I am trying to build a utility device that will let me quickly do the following:
1. Create a new audio track
2. Set the input of the new track to be the output of the currently selected track
3. Arm the new track
4. Leave the currently selected track selected.

Ideally the Max device could live on the Master channel and be MIDI mapped, such that no matter where I was in the set, I could quickly do all of the above with a single button press.

Even MORE ideally, this would be a native function in Live, but for now, Max seems like the next best thing.

I've been able to create a device that creates a new audio track, and I've been able to assign the input of a given track to a pre-determined item, but I don't know how to go about dynamically setting the new track's input based on the currently selected track, as there doesn't seem to be a way to match the name/index/identifier of the current track to the list of input sources.

Any ideas?

agent314
Posts: 1458
Joined: Wed Apr 07, 2010 3:07 am

Re: Create new audio track with input set to current selected track

Post by agent314 » Fri Jan 29, 2021 9:26 am

Okay, so I figured out how to do this pretty easily using the JavaScript API.

Basically, you make a simple Max device that calls into a JS file, and then you can use JavaScript and the Live Object Model to grab whatever pieces of information you need.

Code: Select all

function makeNewTrack() {

	var liveSet = new LiveAPI('live_set');

	var liveView = new LiveAPI('live_set view');

	var currentTrack = new LiveAPI('live_set view selected_track');

	currentName = currentTrack.get('name'); 

	liveSet.call("create_audio_track");
	var newTrack = new LiveAPI('live_set view selected_track');

	var newName = ">>"+currentName; 
	newTrack.set('current_input_routing',currentName);
	newTrack.set('name',newName);
	newTrack.set('arm',1);

	liveView.set('selected_track', 'id', currentTrack.id);
}

chapelier fou
Posts: 6025
Joined: Mon May 15, 2006 12:15 pm

Re: Create new audio track with input set to current selected track

Post by chapelier fou » Fri Jan 29, 2021 12:58 pm

I want to learn JavaScript so much.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1


agent314
Posts: 1458
Joined: Wed Apr 07, 2010 3:07 am

Re: Create new audio track with input set to current selected track

Post by agent314 » Fri Jan 29, 2021 7:27 pm

Did not know BiP even existed - seems like a good device to have in the toolkit

I like to set up a synth/instrument as a source track and record clips into Session view in real time and then chop/chunk/arrange with them later - being able to combine the (admittedly simple) 4-step process into a one-click/one-button solution is a nice little workflow improvement when things are really cooking
I want to learn JavaScript so much.
It may seem daunting/opaque because the syntax is unfamiliar, but it's honestly much less complicated than it may appear at first.

Once you know some of the basics of creating variables, setting up iteration/For loops, and the idea of what an Object is and how to create it, you can do a lot without needing a ton of background knowledge

Post Reply