leolabs / ableton-js

Control Ableton Live with Node.js
MIT License
368 stars 46 forks source link

Get the volume of a track #31

Closed SightlessDog closed 1 year ago

SightlessDog commented 3 years ago

Hello, I have a small problem and I would be grateful if you could help me. I want to set the volume of tracks. But apparently for some reason I can do that with the library, I wrote track.get("mixer_device") which grants me access to the volume right? but then when I do mixer.get("volume") I get an error saying: mixer.get is not a function, thanks in advance :)

leolabs commented 3 years ago

Hey @SightlessDog!

Most functions in AbletonJS are async, so your code might look more like this:

import { Ableton } from "ableton-js";

const ableton = new Ableton();

const test = async () => {
  const tracks = await ableton.song.get("tracks");
  const mixer = await tracks[0].get("mixer_device");
  const volume = await mixer.get("volume");
  console.log("Volume:", volume);
};

test();

However, I think I haven't implemented the mixer device property yet. Maybe I'll find some time to do that in the near future :)

Generally, I can recommend you use AbletonJS with TypeScript to find out which properties are available and which aren't.

SightlessDog commented 3 years ago

yes, I still get the same problem. In the source files I didn't find mixer_device in the gettable properties, but I found in the documentation https://structure-void.com/PythonLiveAPI_documentation//Live10.0.2.xml. However, when I do .get("mixer_device") I get an object back <MixerDevice.MixerDevice object at .....> so I guess it works

leolabs commented 3 years ago

Generally, the Python plugin can return all properties of a given object, but if it doesn't know better it will just convert it to a string. That's why you see the <MixerDevice.MixerDevice object ...> when you request mixer_device. For this to become a usable object, the Python plugin needs to know what to do with it. Here's an example of other track properties: midi-script/Track.py.

SightlessDog commented 3 years ago

@leolabs sorry for the late response I understand thanks

leolabs commented 1 year ago

Hey @SightlessDog! I've recently pushed a new version that allows you to access the mixer device and read the volume and other properties.