Skip to content

Commit

Permalink
✨ Properly create and return scenes and tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
leolabs committed Nov 6, 2023
1 parent e6bf99b commit dc550f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions midi-script/Song.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def create_midi_track(self, ns, index):
def create_return_track(self, ns):
return Track.serialize_track(ns.create_return_track())

def create_scene(self, ns, index):
return Scene.serialize_scene(ns.create_scene(index))

def get_clip_trigger_quantization(self, ns):
return str(ns.clip_trigger_quantization)

Expand Down
3 changes: 3 additions & 0 deletions src/ns/scene.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Ableton } from "..";
import { Namespace } from ".";
import { ClipSlot, RawClipSlot } from "./clip-slot";
import { Color } from "../util/color";

export interface GettableProperties {
clip_slots: RawClipSlot[];
Expand All @@ -13,6 +14,7 @@ export interface GettableProperties {
}

export interface TransformedProperties {
color: Color;
clip_slots: ClipSlot[];
}

Expand Down Expand Up @@ -48,6 +50,7 @@ export class Scene extends Namespace<
super(ableton, "scene", raw.id);

this.transformers = {
color: (c) => new Color(c),
clip_slots: (clip_slots) =>
clip_slots.map((c) => new ClipSlot(this.ableton, c)),
};
Expand Down
18 changes: 11 additions & 7 deletions src/ns/song.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,20 +230,24 @@ export class Song extends Namespace<
return this.sendCommand("continue_playing");
}

public async createAudioTrack(index?: number) {
return this.sendCommand("create_audio_track", { index });
public async createAudioTrack(index = -1) {
const result = await this.sendCommand("create_audio_track", { index });
return new Track(this.ableton, result);
}

public async createMidiTrack(index?: number) {
return this.sendCommand("create_midi_track", { index });
public async createMidiTrack(index = -1) {
const result = await this.sendCommand("create_midi_track", { index });
return new Track(this.ableton, result);
}

public async createReturnTrack() {
return this.sendCommand("create_return_track");
const result = await this.sendCommand("create_return_track");
return new Track(this.ableton, result);
}

public async createScene(index?: number) {
return this.sendCommand("create_scene", [index ?? -1]);
public async createScene(index = -1) {
const result = await this.sendCommand("create_scene", { index });
return new Scene(this.ableton, result);
}

public async deleteReturnTrack(index: number) {
Expand Down

0 comments on commit dc550f1

Please sign in to comment.