Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen to master output level #4

Closed
patryk-kawalarz opened this issue Mar 2, 2020 · 19 comments
Closed

Listen to master output level #4

patryk-kawalarz opened this issue Mar 2, 2020 · 19 comments

Comments

@patryk-kawalarz
Copy link

Can your framework check the actual master volume level? But not the fader lever but real-time output level.
I want to create some simple visualization app.

@leolabs
Copy link
Owner

leolabs commented Mar 2, 2020

That's possible. You can get the master volume like this:

const ab = new Ableton();
const master = await ab.song.get("master_track");
master.addListener("output_meter_level", console.log);

It does seem, however, that Ableton has some problems outputting a constant stream of values. I'm not sure yet if that's a problem with Ableton.js' Python script or Ableton itself. Please do report back if this works well for you :)

@patryk-kawalarz
Copy link
Author

Thank you for your prompt reply! I will check it out today :)

@patryk-kawalarz
Copy link
Author

Ok, it works. I get the actual value of master track. Unfortunately, the data does not refresh often enough to create real-time visualizations.

@leolabs
Copy link
Owner

leolabs commented Mar 2, 2020

Do you also get some values all at once and then no values for about half a second?

Screen Recording 2020-03-02 at 11 10 18 PM

@patryk-kawalarz
Copy link
Author

Yep, I had the same.

@leolabs
Copy link
Owner

leolabs commented Mar 3, 2020

I think I found a solution. Ableton's output_meter_level listener seems to be a bit broken, but listening to output_meter_left and/or output_meter_right seems to work fine:

Screen Recording 2020-03-03 at 1 46 12 PM

@patryk-kawalarz
Copy link
Author

patryk-kawalarz commented Mar 3, 2020

:O Whoa, looks like a huge number of values per second! That's what I needed! Will check it tomorrow :) Btw. do you have sometimes timeout errors while connecting to Ableton?

@leolabs
Copy link
Owner

leolabs commented Mar 3, 2020

I haven't experienced any errors yet in my setup. When Ableton.js connects to the Python script, it requests the current song time as a kind of check if the connection really exists. If that request takes longer than 2 seconds to respond, the connection will fail.

Could you elaborate more on what your setup looks like? Which OS do you use and when do you get those timeouts?

@patryk-kawalarz
Copy link
Author

patryk-kawalarz commented Mar 4, 2020

This is the error I often get when I try to restart node app:

(node:14148) UnhandledPromiseRejectionWarning: Error: Timeout at Timeout._onTimeout (D:\Music data\Dropbox\Workspace\visual\node_modules\ableton-js\index.js:163:77)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
(node:14148) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14148) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@leolabs
Copy link
Owner

leolabs commented Mar 4, 2020

Hmm, that's weird. It might be due to the midi script in Ableton not being able to receive or send messages on the specified ports. Some Native Instruments apps use the same ports for example. I've updated the default ports in v1.7.0 and improved the timeout errors in v1.7.2. Could you update your ableton-js and the midi script to the latest version and report on whether it works better for you now?

@patryk-kawalarz
Copy link
Author

Hello. Now it doesn't work at all. Windows 10 here.

(node:24724) UnhandledPromiseRejectionWarning: Error: The command internal.get_prop({"prop":"version"}) timed out after 2000 ms
at Timeout._onTimeout (D:\Music data\Dropbox\Workspace\visual\node_modules\ableton-js\index.js:175:33)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
(node:24724) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:24724) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:24724) UnhandledPromiseRejectionWarning: Error: The command song.get_prop({"prop":"master_track"}) timed out after 2000 ms
at Timeout._onTimeout (D:\Music data\Dropbox\Workspace\visual\node_modules\ableton-js\index.js:175:33)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
(node:24724) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

@leolabs
Copy link
Owner

leolabs commented Mar 4, 2020

Have you updated both the js library and the Python midi script?

@timothywisdom
Copy link

The error "Error: Timeout at Timeout._onTimeout" can be caused because the Python script has encountered an error whilst running inside Ableton. It doesn't respond to Node and Node proclaims a timeout error.

@leolabs
Copy link
Owner

leolabs commented Mar 5, 2020

Normally, every error encountered in the midi script should be sent back to the JS library. But I've improved the error message by adding some troubleshooting tips in v1.8.1. @patryk-kawalarz please report back if it works for you :)

@patryk-kawalarz
Copy link
Author

You were right, I forgot to update python files :O I will check everything again as soon as I find a moment (which is very difficult lately).

One thing I know for sure - output_meter_left works like a charm :)

Thank you for your commitment! :)

@leolabs
Copy link
Owner

leolabs commented Mar 5, 2020

Awesome! You're welcome, and I'm glad that it's useful to you :)
I'll close this issue for now, but feel free to reopen it or open a new one when you run into any problems.

@leolabs leolabs closed this as completed Mar 5, 2020
@rushjs1
Copy link

rushjs1 commented Nov 10, 2021

Im very sorry that Im back again.. but is there any way to access any sort of frequency data from the master channel? Or any other data that could help with creating a visualizer other than the master_output_left/right. My understanding after reading the docs you have linked would be that there is not. Is that correct? Any information is appreciated, thank you.

@leolabs
Copy link
Owner

leolabs commented Nov 10, 2021

No worries, I'm always happy to help :)

I don't think that Ableton exposes any sort of frequency data through their Python API. Maybe you can try using a M4L Audio Effect as that has access to the raw audio data and can extract frequency information.

@rushjs1
Copy link

rushjs1 commented Nov 11, 2021

Ahh okay. Thank you I will definitely look into it! For now the output_left/right will work just fine. Thanks again for an awesome library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants