Problems getting Magenta.amxd to work in Ableton Live 10 Suite

Carl Caulkett's icon

https://magenta.tensorflow.org/studio/ableton-live

Hello, I am trying to get the Magenta M4L device to work under macOS 10.14 Mojave. I'm running Ableton Live with the preferences set to use the external Max app rather than the built in one, and I'm currently using Max 8.02.

When I use the amxd device, it is able to find the Magenta applets correctly but when the MIDI clips are generated they are always empty. My instincts tell me that the M4L code is not communicating properly with the underlying TensorFlow.js code, but I am not very skilled in JS/Node so I'm not sure what's going on.

I installed TensorFlow.js using...
brew install yarn
yarn add @tensorflow/tfjs-node-gpu
npm install @tensorflow/tfjs-node-gpu


I then ran...
node test.js
where `test.js` consisted of the following code...

const tf = require('@tensorflow/tfjs');

// Load the binding:
require('@tensorflow/tfjs-node');

// Use '@tensorflow/tfjs-node-gpu' if running with GPU.

// Train a simple model:
const model = tf.sequential();
model.add(tf.layers.dense({units: 100, activation: 'relu', inputShape: [10]})); model.add(tf.layers.dense({units: 1, activation: 'linear'}));
model.compile({optimizer: 'sgd', loss: 'meanSquaredError'});
const xs = tf.randomNormal([100, 10]);
const ys = tf.randomNormal([100, 1]);
model.fit(xs, ys, {
epochs: 100,
callbacks: {
onEpochEnd: async (epoch, log) => {
console.log(`Epoch ${epoch}: loss = ${log.loss}`);
}
}
});


This seemed to produce some kind of output, suggesting that the TensorFlow had been installed okay. I then located the Javascript code which the Magenta applets presumably call.

These seem to consist of four .js files under a folder called srcas shown in the Finder screenshot below...

When I tried executing, say, Launch.js using node Client.js...
I got the following error message...

internal/modules/cjs/loader.js:605
    throw err;
    ^
Error: Cannot find module 'max-api'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Volumes/OS2/Ableton/Freebies/Magenta/src/launch.js:18:13)
    at Module._compile (internal/modules/cjs/loader.js:722:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)

I'm not sure if this highlights the problem with Magenta not working, though, because I notice elsewhere in the forum that Max uses some trickery to allow access to max-api. I also notice from searching for max-api, that it seems to be held within the Max application itself as a piece of TypeScript.

It's at this point that my already limited Javascript and indeed Max knowledge really runs out, but like I say it does seem like the magenta.amxd device is going through the motions okay, but somehow the four apps are not connecting with the underlying Javascript stuff.

I've been in communication with the Magenta folks but they don't seem to have an answer for me. I've tried to get them to give me some debugging tips, but they've not responded for almost a week. So, I thought I'd attack the problem from the other side, by contacting you guys!

Thanks in advance for any help you can give me!

Cheers,
Carl

Florian Demmer's icon

Hey Carl,

have you followed the Installation instructions for Magenta’s amxd as listed here https://magenta.tensorflow.org/studio/ableton-live/ ? They should somewhat “just work” once you set up the correct Max application path in Live and all the CLI Node installs, tensorflow usage etc you are doing isn’t necessary. On top of that mingling with Magenta’s contained .js files is highly discouraged and can lead to undesired behavior. but yeah, you are right, they won’t execute from the CLI as “max-api” isn’t available unless you are running the code from within Max.

I’d encourage you to download the devices again from the Magenta website, follow their instructions closely and see if they “just” work. Following your description everything does seem to work and MIDI clips do in fact get generated, which hints at a working communication etc. the fact that they are empty might be a different story..

once you have a clean install of the Magenta stuff we can pick it up from there but as said, mingling with the content makes that tough to understand. Also the installs of tensorflow are not necessary and its not clear to me where you installed them either. On a diff note, yarn and npm are both CLI tools to manage package installs and dependencies. Generally u should decide per-project, which one u/ur team wants to use and not install using both (as u were showing above), which might cause issues and lead to unexpected behavior.

Thanks
florian

Carl Caulkett's icon

Hi Florian, thanks for the reply. I've just downloaded the Magenta package again, and deleted everything that was there before. I've followed the instruction exactly (there's not a lot to go wrong!) and started a new test project. I chose the Generate applet, and accepted the default selection. Again, I generated 8 entirely empty clips, which would be fine if I was aiming for a reinterpretation of 4'33", but otherwise not so good!

I should point out that I have a slightly unusual machine, in that I'm running a Mac Pro (early 2009) with the firmware flashed from 4,1 to 5,1. I then recently used the DosDude1 patch to upgrade the OS to Mojave and am now running 10.14.2. Interestingly, I've not run across any compatibility issues with Ableton Live/Max unless this is due to OS issues...