Skip to content

Commit a23201f

Browse files
author
faradox
committed
rewrite to use nendo
1 parent ed3c969 commit a23201f

10 files changed

+653
-823
lines changed

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
input
2+
nendo_library
3+
library
4+
processed
5+
separated
6+
polymath_library
7+
polymath_input
8+
polymath_output
9+
.python-version
10+
polymath.egg-info
11+
__pycache__
12+
models

.gitignore

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
input/
2-
library/
3-
processed/
4-
separated/
1+
input
2+
nendo_library
3+
library
4+
processed
5+
separated
6+
polymath_library
7+
polymath_input
8+
polymath_output
9+
.python-version
10+
polymath.egg-info
11+
__pycache__
12+
models

Dockerfile

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
FROM python:3.10-bullseye
1+
FROM python:3.8-slim-buster
22

3-
RUN apt update
4-
RUN apt install -y rubberband-cli make automake gcc g++ python3-dev gfortran build-essential wget libsndfile1 ffmpeg
3+
RUN apt-get update \
4+
&& apt-get -y install rubberband-cli \
5+
libasound-dev portaudio19-dev \
6+
libportaudio2 libportaudiocpp0 git gcc \
7+
&& rm -rf /var/lib/apt/lists/*
58

6-
RUN pip install --upgrade pip
9+
RUN pip install git+https://github.com/CPJKU/madmom.git@0551aa8
710

8-
COPY . /polymath
911
WORKDIR /polymath
12+
COPY . .
13+
RUN pip install -r ./requirements.txt
1014

11-
RUN pip install -r requirements.txt
12-
13-
RUN mkdir -p input processed separated library
14-
15+
# fixes for some dependency conflicts
16+
RUN pip uninstall -y soundfile
17+
RUN pip install soundfile
18+
RUN pip install soundfile==0.12.1
19+
RUN pip install numpy==1.22.4
20+
RUN pip uninstall -y essentia essentia-tensorflow
21+
RUN pip install essentia-tensorflow

README.md

Lines changed: 96 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,59 @@
1-
21
# Polymath
32

4-
Polymath uses machine learning to convert any music library (*e.g from Hard-Drive or YouTube*) into a music production sample-library. The tool automatically separates songs into stems (*beats, bass, etc.*), quantizes them to the same tempo and beat-grid (*e.g. 120bpm*), analyzes musical structure (*e.g. verse, chorus, etc.*), key (*e.g C4, E3, etc.*) and other infos (*timbre, loudness, etc.*), and converts audio to midi. The result is a searchable sample library that streamlines the workflow for music producers, DJs, and ML audio developers.
3+
Polymath uses machine learning to convert any music library (*e.g from Hard-Drive or YouTube*) into a music production sample-library. The tool automatically separates tracks into stems (_drums, bass, etc._), quantizes them to the same tempo and beat-grid (*e.g. 120bpm*), analyzes tempo, key (_e.g C4, E3, etc._) and other infos (*timbre, loudness, etc.*) and cuts loop out of them. The result is a searchable sample library that streamlines the workflow for music producers, DJs, and ML audio developers.
4+
5+
Try it in colab:
6+
<a target="_blank" href="https://colab.research.google.com/drive/1TjRVFdh1BPdQ_5_PL5EsfS278-EUYt90?usp=sharing">
7+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
8+
</a>
59

6-
<p align="center"><img alt="Polymath" src="https://samim.io/static/upload/illustration3.688a510b-bocuz8wh.png" /></p>
10+
![Polymath](docs/images/polymath.png)
711

812
## Use-cases
9-
Polymath makes it effortless to combine elements from different songs to create unique new compositions: Simply grab a beat from a Funkadelic track, a bassline from a Tito Puente piece, and fitting horns from a Fela Kuti song, and seamlessly integrate them into your DAW in record time. Using Polymath's search capability to discover related tracks, it is a breeze to create a polished, hour-long mash-up DJ set. For ML developers, Polymath simplifies the process of creating a large music dataset, for training generative models, etc.
13+
14+
Polymath makes it effortless to combine elements from different tracks to create unique new compositions: Simply grab a beat from a Funkadelic track, a bassline from a Tito Puente piece, and fitting horns from a Fela Kuti song, and seamlessly integrate them into your DAW in record time. Using Polymath's search capability to discover related tracks, it is a breeze to create a polished, hour-long mash-up DJ set. For ML developers, Polymath simplifies the process of creating a large music dataset, for training generative models, etc.
1015

1116
## How does it work?
12-
- Music Source Separation is performed with the [Demucs](https://github.com/facebookresearch/demucs) neural network
13-
- Music Structure Segmentation/Labeling is performed with the [sf_segmenter](https://github.com/wayne391/sf_segmenter) neural network
14-
- Music Pitch Tracking and Key Detection are performed with [Crepe](https://github.com/marl/crepe) neural network
15-
- Music to MIDI transcription is performed with [Basic Pitch](https://github.com/spotify/basic-pitch) neural network
16-
- Music Quantization and Alignment are performed with [pyrubberband](https://github.com/bmcfee/pyrubberband)
17-
- Music Info retrieval and processing is performed with [librosa](https://github.com/librosa/librosa)
17+
18+
- Import tracks from youtube or directly from your google drive
19+
- Process selected (or all) tracks with a configurable selection of nendo plugins:
20+
- Apply the [classification plugin](https://github.com/okio-ai/nendo-plugin-classify-core) to compute _volume_, _tempo_ (bpm), _key_, _intensity_, _frequency_, and _loudness_ for each track
21+
- Apply the [stemification plugin](https://github.com/okio-ai/nendo-plugin-stemify-demucs) to separate each track into four source signals: _vocals_, _drum_, _bass_, and _other_
22+
- Apply the [quantization plugin](https://github.com/okio-ai/nendo-plugin-quantize-core) to quantize each track to a specified target _bpm_
23+
- Apply the [loopification plugin](https://github.com/okio-ai/nendo-plugin-loopify) to automatically detect and extract loops from each sample
24+
- Export the results of the processing with informative file names to your google drive in _wav_, _mp3_ or _ogg_ format.
1825

1926
## Community
2027

2128
Join the Polymath Community on [Discord](https://discord.gg/gaZMZKzScj)
2229

2330
## Requirements
2431

25-
You need to have the following software installed on your system:
32+
**Polymath requires Python version 3.8, 3.9 or 3.10.**
33+
34+
> It is recommended to use a [virtual environment](https://docs.python.org/3/library/venv.html), in order to avoid dependency conflicts. You can use your favorite virtual environment management system, like [conda](https://docs.conda.io/en/latest/), [poetry](https://python-poetry.org/), or [pyenv](https://github.com/pyenv/pyenv) for example.
35+
36+
Furthermore, the following software packages need to be installed in your system:
2637

27-
- ``ffmpeg``
38+
- **Ubuntu**: `sudo apt-get install ffmpeg libsndfile1 libportaudio2 rubberband-cli libmpg123-dev`
39+
- **Mac OS**: `brew install ffmpeg libsndfile portaudio rubberband mpg123`
40+
- **Windows**
41+
42+
> Windows support is currently under development. For the time being, we highly recommend using [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/install) and then following the linux instructions.
2843
2944
## Installation
3045

31-
You need python version `>=3.7` and `<=3.10`. From your terminal run:
46+
You need python version `>=3.8` and `<=3.10`. From your terminal run:
47+
3248
```bash
49+
pip install git+https://github.com/CPJKU/madmom.git@0551aa8
3350
git clone https://github.com/samim23/polymath
3451
cd polymath
3552
pip install -r requirements.txt
53+
pip uninstall -y essentia essentia-tensorflow && pip install essentia-tensorflow
3654
```
3755

38-
If you run into an issue with basic-pitch while trying to run Polymath, run this command after your installation:
39-
```bash
40-
pip install git+https://github.com/spotify/basic-pitch.git
41-
```
56+
The last line is a fix that's needed to avoid a dependency conflict among the plugins.
4257

4358
## GPU support
4459

@@ -54,114 +69,119 @@ docker build -t polymath ./
5469

5570
In order to exchange input and output files between your hosts system and the polymath docker container, you need to create the following four directories:
5671

57-
- `./input`
58-
- `./library`
59-
- `./processed`
60-
- `./separated`
72+
- `./polymath_input`
73+
- `./polymath_library`
74+
- `./polymath_output`
75+
- `./models`
76+
77+
E.g. run `mkdir -p ./polymath_input ./polymath_library ./polymath_output ./models`.
6178

62-
Now put any files you want to process with polymath into the `input` folder.
79+
Now put any files you want to process with polymath into the `polymath_input` folder.
6380
Then you can run polymath through docker by using the `docker run` command and pass any arguments that you would originally pass to the python command, e.g. if you are in a linux OS call:
6481

6582
```bash
6683
docker run \
67-
-v "$(pwd)"/processed:/polymath/processed \
68-
-v "$(pwd)"/separated:/polymath/separated \
69-
-v "$(pwd)"/library:/polymath/library \
70-
-v "$(pwd)"/input:/polymath/input \
71-
polymath python /polymath/polymath.py -a ./input/song1.wav
84+
-v "$(pwd)"/models:/polymath/models \
85+
-v "$(pwd)"/polymath_input:/polymath/polymath_input \
86+
-v "$(pwd)"/polymath_library:/polymath/polymath_library \
87+
-v "$(pwd)"/polymath_output:/polymath/polymath_output \
88+
polymath \
89+
python polymath.py -i ./polymath_input/song1.wav -p -e
7290
```
7391

7492
## Run Polymath
7593

76-
### 1. Add songs to the Polymath Library
94+
To print the help for the python command line arguments:
95+
96+
```bash
97+
python polymath.py -h
98+
```
99+
100+
### 1. Add tracks to the Polymath Library
77101

78102
##### Add YouTube video to library (auto-download)
103+
79104
```bash
80-
python polymath.py -a n6DAqMFe97E
105+
python polymath.py -i n6DAqMFe97E
81106
```
107+
82108
##### Add audio file (wav or mp3)
109+
83110
```bash
84-
python polymath.py -a /path/to/audiolib/song.wav
111+
python polymath.py -i /path/to/audiolib/song.wav
85112
```
113+
86114
##### Add multiple files at once
87-
```bash
88-
python polymath.py -a n6DAqMFe97E,eaPzCHEQExs,RijB8wnJCN0
89-
python polymath.py -a /path/to/audiolib/song1.wav,/path/to/audiolib/song2.wav
90-
python polymath.py -a /path/to/audiolib/
91-
```
92-
Songs are automatically analyzed once which takes some time. Once in the database, they can be access rapidly. The database is stored in the folder "/library/database.p". To reset everything, simply delete it.
93115

94-
### 2. Quantize songs in the Polymath Library
95-
##### Quantize a specific songs in the library to tempo 120 BPM (-q = database audio file ID, -t = tempo in BPM)
96-
```bash
97-
python polymath.py -q n6DAqMFe97E -t 120
98-
```
99-
##### Quantize all songs in the library to tempo 120 BPM
100116
```bash
101-
python polymath.py -q all -t 120
117+
python polymath.py -i n6DAqMFe97E,eaPzCHEQExs,RijB8wnJCN0
118+
python polymath.py -i /path/to/audiolib/song1.wav,/path/to/audiolib/song2.wav
119+
python polymath.py -i /path/to/audiolib/
120+
# you can even mix imports:
121+
python polymath.py -i /path/to/audiolib/,n6DAqMFe97E,/path/to/song2.wav
102122
```
103-
##### Quantize a specific songs in the library to the tempo of the song (-k)
104-
```bash
105-
python polymath.py -q n6DAqMFe97E -k
106-
```
107-
Songs are automatically quantized to the same tempo and beat-grid and saved to the folder “/processed”.
108123

109-
### 3. Search for similar songs in the Polymath Library
110-
##### Search for 10 similar songs based on a specific songs in the library (-s = database audio file ID, -sa = results amount)
124+
Once in the database, they can be searched through, processed and exported. The database is stored by default in the folder "./polymath_library". To change the library folder use the `--library_path` console argument. To reset everything, simply delete that directory.
125+
126+
### 2. Quantize tracks in the Polymath Library
127+
128+
##### Find a specific song in the library and quantize it to tempo 120 BPM (-f = find ID in library, -q = quantize to tempo in BPM)
129+
111130
```bash
112-
python polymath.py -s n6DAqMFe97E -sa 10
131+
python polymath.py -f n6DAqMFe97E -q 120
113132
```
114-
##### Search for similar songs based on a specific songs in the library and quantize all of them to tempo 120 BPM
133+
134+
##### Quantize all tracks in the library to tempo 120 BPM
135+
115136
```bash
116-
python polymath.py -s n6DAqMFe97E -sa 10 -q all -t 120
137+
python polymath.py -q 120
117138
```
118-
##### Include BPM as search criteria (-st)
139+
140+
### 3. Search for specific tracks in the Polymath Library
141+
142+
##### Find tracks with specific search keys in the library and export them
143+
119144
```bash
120-
python polymath.py -s n6DAqMFe97E -sa 10 -q all -t 120 -st -k
145+
python polymath.py -f n6DAqMFe97E,my_song.mp3 -e
121146
```
122-
Similar songs are automatically found and optionally quantized and saved to the folder "/processed". This makes it easy to create for example an hour long mix of songs that perfectly match one after the other.
123147

124-
### 4. Convert Audio to MIDI
125-
##### Convert all processed audio files and stems to MIDI (-m)
148+
The default export directory is `./polymath_output`. To specify a different directory, use the `-o /path/to/my/output/dir` flag.
149+
150+
##### Find tracks in specific BPM range as search criteria (-bmin and -bmax) and also export loops (-fl)
151+
126152
```bash
127-
python polymath.py -a n6DAqMFe97E -q all -t 120 -m
153+
python polymath.py -bmin 80 -bmax 100 -fl -e
128154
```
129-
Generated Midi Files are currently always 120BPM and need to be time adjusted in your DAW. This will be resolved [soon](https://github.com/spotify/basic-pitch/issues/40). The current Audio2Midi model gives mixed results with drums/percussion. This will be resolved with additional audio2midi model options in the future.
130-
131155

132156
## Audio Features
133157

134158
### Extracted Stems
135-
The Demucs Neural Net has settings that can be adjusted in the python file
159+
160+
Stems are extracted with the [nendo stemify plugin](https://github.com/okio-ai/nendo_plugin_stemify_demucs/). Extracted stem types are:
161+
136162
```bash
137163
- bass
138164
- drum
139-
- guitare
140-
- other
141-
- piano
142165
- vocals
166+
- other
143167
```
168+
144169
### Extracted Features
145-
The audio feature extractors have settings that can be adjusted in the python file
170+
171+
Music Information Retrieval features are computed using the [nendo classify plugin](https://github.com/okio-ai/nendo_plugin_classify_core/). Extracted features are:
172+
146173
```bash
147174
- tempo
148175
- duration
149-
- timbre
150-
- timbre_frames
151-
- pitch
152-
- pitch_frames
153176
- intensity
154-
- intensity_frames
155-
- volume
156177
- avg_volume
157178
- loudness
158-
- beats
159-
- segments_boundaries
160-
- segments_labels
161-
- frequency_frames
162179
- frequency
163180
- key
164181
```
165182

166183
## License
184+
167185
Polymath is released under the MIT license as found in the [LICENSE](https://github.com/samim23/polymath/blob/main/LICENSE) file.
186+
187+
As for [nendo core](https://github.com/okio-ai/nendo) and the [plugins used in polymath](#how-does-it-work), see their respective repositories for information about their license.

__init__.py

Whitespace-only changes.

docs/images/polymath.png

881 KB
Loading

0 commit comments

Comments
 (0)