ableton-js icon indicating copy to clipboard operation
ableton-js copied to clipboard

Get the volume of a track

Open SightlessDog opened this issue 4 years ago • 4 comments

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 :)

SightlessDog avatar Jun 22 '21 19:06 SightlessDog

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.

leolabs avatar Jun 22 '21 19:06 leolabs

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

SightlessDog avatar Jun 22 '21 21:06 SightlessDog

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.

leolabs avatar Jun 23 '21 08:06 leolabs

@leolabs sorry for the late response I understand thanks

SightlessDog avatar Jun 25 '21 08:06 SightlessDog

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

leolabs avatar Jan 10 '23 15:01 leolabs