Can M4L do that? Python pseudocode
Hi, Ableton newbie here (Standard Edition), thinking about getting into Max for Live.
I posted this in the Ableton forum a while back, but didn't get a real answer. I now skip the whole "why" explanation.
Here is a pythonic "pseudocode" of what I'd like to do to conform MIDI tracks in the arrangement based on audio tracks. Is it feasible with M4L (and proper syntax, of course) ?
## All the MIDI clips are parked on track 0, muted. It's the only MIDI track. The others are audio tracks.
## The arrangement playback uses audio clips only. The sample in each audio clip was recorded from one of the track 0 MIDI clips, sent to one of several external instruments.
## The goal is to create MIDI tracks targeting the original external instruments, with the exact same arrangement (same time positions and lengths) of MIDI clips as their audio counterparts.
## Both corresponding clips in each pair have the same name, except that the MIDI clip name starts with "M", and the audio clip name starts with "A".
## Clips naming scheme: A/M + instrument + patch + counter.
audio_tracks = []
for t in arranger.tracks:
if t.id == 0:
MIDI_clips = [t.clips] # create list of MIDI clips
else:
audio_tracks.append(t) # create list of audio tracks
for t in audio_tracks:
first_loop = 1
for audio_clip in t.clips:
target_clip_name = 'M' + audio_clip.name[1:] # replace 'A' by 'M'
for MIDI_clip in MIDI_clips:
if (MIDI_clip.name != '') and (MIDI_clip.name == target_clip_name):
if first_loop:
new_MIDI_track = arranger.create_MIDI_track(target_clip_name[1:4], MIDI channel, I/O) # create MIDI track with instrument name etc. M4L 'create track' function?
first_loop = 0
MIDI_clip.length = audio_clip.length
new_MIDI_track.clips.append(MIDI_clip, audio_clip.time)
target_clip_name = '' # skip rest of MIDI clip list
break # look up next audio clip