Skip to content

Commit fbb580a

Browse files
committed
initial commit
0 parents  commit fbb580a

File tree

6 files changed

+164
-0
lines changed

6 files changed

+164
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.zip
2+
demucs/

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist:
2+
mkdir demucs && cp README.md demucs/README.txt && cp demucs.amxd demucs/ && cp *.js demucs/ && zip -r demucs demucs/*
3+
clean:
4+
rm -r demucs/ && rm *.zip

README.md

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# demucs for max (native version)
2+
3+
ableton max device for separating a clip into stems (vocals, bass, drums,
4+
other) using https://github.com/facebookresearch/demucs.
5+
6+
## download link
7+
8+
TBD
9+
10+
## before you start
11+
12+
all instructions were tested with Max 8.1 / Ableton 10.1 and will not work for earlier versions. this is beta software and may not work with all operating systems.
13+
14+
### windows steps:
15+
16+
1. install the latest **python 3.9** windows installer from https://www.python.org/downloads/. in the installer, make sure to enable the setting that adds Python to your path and disable the "path length variable limit" option when you get to the end of the install process.
17+
18+
> :white_check_mark: to test, run `python -V` or `py -V` in CMD.exe, if there is no output or something other than `Python 3.9.X` then something is wrong
19+
20+
2. open windows environment variable editor and remove `.JS;` from PATHEXT follwing [these instructions](https://web.archive.org/web/20201111203134/https://support.shotgunsoftware.com/hc/en-us/articles/114094235653-Setting-global-environment-variables-on-Windows). on some systems you may need to restart for these changes to take effect.
21+
22+
> :white_check_mark: to test, run `echo %pathext%` in CMD.exe and make sure `.JS` is not there
23+
24+
3. open CMD.exe and type `python3 -m pip install -U demucs` (hit enter)
25+
26+
### macOS steps:
27+
28+
1. install homebrew: https://brew.sh/
29+
30+
2. open terminal and install python3/demucs with the following commands:
31+
```
32+
brew install [email protected]
33+
brew link --force [email protected]
34+
python3 -m pip install -U demucs
35+
```
36+
37+
## running
38+
39+
1. unzip demucs.zip and add the `demucs/` folder to your Places menu in Ableton
40+
2. put `demucs.amxd` onto any audio channel
41+
3. select any audio clip in Ableton by clicking on it
42+
4. press the start button in the demucs device and wait.
43+
44+
## troubleshooting and FAQs
45+
46+
TBD
47+
48+
## license (MIT)
49+
50+
Copyright 2022 Yan Zhu
51+
52+
Permission is hereby granted, free of charge, to any person obtaining a copy of
53+
this software and associated documentation files (the "Software"), to deal in
54+
the Software without restriction, including without limitation the rights to
55+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
56+
of the Software, and to permit persons to whom the Software is furnished to do
57+
so, subject to the following conditions:
58+
59+
The above copyright notice and this permission notice shall be included in all
60+
copies or substantial portions of the Software.
61+
62+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
63+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
64+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
65+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
66+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
67+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
68+
SOFTWARE.
69+
70+
## credits
71+
72+
https://github.com/facebookresearch/demucs

demucs.amxd

16.9 KB
Binary file not shown.

demucs.js

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
const path = require('path')
2+
const Max = require('max-api')
3+
const { exec, execSync } = require('child_process')
4+
const done = () => {
5+
Max.outlet('spleeterDone')
6+
}
7+
8+
const modelName = 'mdx_extra_q'
9+
10+
Max.post(`Loaded the ${path.basename(__filename)} script`)
11+
// Docker's default path may not be in Max Node's env path
12+
process.env.PATH = [process.env.PATH, '/usr/local/bin'].join(':')
13+
Max.outlet('bang')
14+
15+
// Use the 'addHandler' function to register a function for a particular
16+
// message
17+
Max.addHandlers({
18+
onFile: (filename) => {
19+
if (!filename) {
20+
Max.post('No audio file found.')
21+
done()
22+
return
23+
}
24+
runSpleeter(filename)
25+
}
26+
})
27+
28+
const showDir = (dir) => {
29+
// Since LOM has no way to load these files automatically into new tracks,
30+
// just open a file dialog and let the user drag-and-drop them.
31+
let opener
32+
if (process.platform === 'darwin') {
33+
opener = 'open'
34+
} else if (process.platform === 'win32') {
35+
opener = 'start ""'
36+
} else {
37+
Max.post(`Unsupported platform: ${process.platform}`)
38+
}
39+
execSync(`${opener} "${dir}"`)
40+
Max.outlet('set', `Select a clip; then press the button to start.`)
41+
}
42+
43+
const runSpleeter = (filename) => {
44+
const cmd = `demucs "${filename}"`
45+
Max.outlet('set', `Demucs is running. This may take a minute...`)
46+
Max.post(cmd)
47+
48+
// Calls the spleeter python process
49+
exec(cmd, (err, stdout, stderr) => {
50+
if (err) {
51+
Max.outlet('set', `Error: ${err.message}`)
52+
Max.post(`Error: ${err.message}`)
53+
Max.post(`Spleeter stderr: ${stderr}`)
54+
Max.post(`Spleeter stdout: ${stdout}`)
55+
done()
56+
return
57+
}
58+
if (stderr) {
59+
Max.post(`Spleeter stderr: ${stderr}`)
60+
}
61+
if (stdout) {
62+
Max.post(`Spleeter stdout: ${stdout}`)
63+
}
64+
const correctFilename = path.basename(filename).split('.').slice(0, -1).join('.')
65+
const outputFilename = path.join(__dirname, 'separated', modelName, correctFilename)
66+
showDir(outputFilename)
67+
done()
68+
})
69+
}

main.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
outlets = 2
2+
3+
function log (msg, obj) {
4+
post(msg)
5+
post(JSON.stringify(obj))
6+
post('\n')
7+
}
8+
9+
function bang () {
10+
const clip = new LiveAPI('live_set view detail_clip')
11+
const filePath = clip.get('file_path')
12+
outlet(0, 'onFile', filePath)
13+
}
14+
15+
function spleeterDone() {
16+
outlet(1, 'bang')
17+
}

0 commit comments

Comments
 (0)