Skip to content

Issue with clip types #29

@jeffgca

Description

@jeffgca

Hey! First off, this project is amazing, thank you so much for doing all this heavy lifting, this is huge.

I think there's a mix-up with this ternary statement:

https://github.com/ricardomatias/ableton-live/blob/master/lib/Clip.ts#L524

constructor(ableton: AbletonLive, public raw: RawClip, path?: string) {
		super(ableton, 'clip', path ?? raw.path);

		this._id = parseInt(raw.id, 10);
		this._name = raw.name;
		this._type = raw.is_audio_clip ? ClipType.Midi : ClipType.Audio;
		this._length = raw.length;

		this.childrenTransformers = {
			clipView: () => new ClipView(this.ableton),
		};
	}

Shouldn't this:

this._type = raw.is_audio_clip ? ClipType.Midi : ClipType.Audio;

be instead:

this._type = raw.is_audio_clip ? ClipType.Audio : ClipType.Midi;

Currently when I run this code:

import _ from 'lodash-es'
import { AbletonLive } from 'ableton-live'

import WebSocket, { WebSocketServer } from 'ws'

const live = new AbletonLive()

const main = async () => {
	try {
		await live.connect()

		const tracks = await live.song.children('tracks')

		_.each(tracks, async (track) => {
			console.log(track.type, track.name)
			const clips = await track.getClips()
			console.log(
				_.map(clips, (clip) => {
					return [clip.type, clip.name]
				}),
			)
		})
		// const clips = await tracks[0].getClips()
		// const notes = await clips[0].getNotes()

		// notes.forEach((note) => console.log(note.pitch))
	} catch (error) {
		console.error(error)
	}
}

main()

I get this output:

➜ m4l node index.js
[AbletonLive] Listening on 127.0.0.1/ableton-live:9001
midi 1-MIDI
audio 2-AUDIO CLIP
[ [ 'audio', 'MIDI CLIP' ] ]
[ [ 'midi', 'AUDIO CLIP' ] ]

This is my Ableton set:

Screenshot 2024-09-28 at 09 00 41

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions