• Stars
    star
    310
  • Rank 134,401 (Top 3 %)
  • Language Max
  • License
    Other
  • Created over 2 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

banner

Demonstration video

RAVE x nn~

Installation

Grab the latest release of nn~ ! Be sure to download the correct version for your installation.

Mac users, you should download the arm64 version if and only if your Mac is a M1-2, and your installation of Max/MSP or PureData is not using Rosetta !

Windows users, for now it is required that all .dll files in the nn~ package are copied next to the ห‹Max.exeห‹ executable.

MaxMSP

Uncompress the .tar.gz file in the Package folder of your Max installation, i.e. in Documents/Max 8/Packages/.

You can then instantiate an nn~ object. Depending on your installation, you might get a quarantine warning, such as this one

In most cases, proceeding with the removal will disable this warning until the next update of nn~. If MacOS continues to block the external, you might have to compile it yourself.

Right click on the nn~ object to open the help patch, and follow the tabs to learn more about this project.

PureData

Uncompress the .tar.gz file in the Package folder of your Pd installation, i.e. in Documents/Pd/externals/. You can then add a new path in the Pd/File/Preferences/Path menu pointing to the nn_tilde folder.

On MacOS, unlike Max/MSP, PureData doesn't include an automatic quarantine removal procedure. Therefore we have to do it manually. Fire up a terminal, and cd to the nn_tilde folder. The following command will fix the issue

xattr -r -d com.apple.quarantine .

Usage

Pretrained models

At its core, nn~ is a translation layer between Max/MSP or PureData and the libtorch c++ interface for deep learning. Alone, nn~ is like an empty shell, and requires pretrained models to operate. You can find a few RAVE models here, or a few vschaos2 models here.

Pretrained model for nn~ are torchscript files, with a .ts extension. Create a folder somewhere on your computer, for example in

Documents/pretrained_models/

and add this path to Max or PureData include path (Max: Options/File Preferences, PureData: File/Preferences/Path).

Loading a model

Once this is done, you can load a model using the following syntax (here to load a pretrained model located in Documents/pretrained_models/decoder_only.ts)

Max / MSP PureData

Note that you have to include the .ts extension in the PureData version. Depending on the model loaded, there will be a different number of inlets / outlets, corresponding to the different inputs and outputs of the model.

Selecting a method

A given pretrained model might have several different methods, with different effects and usage. For example, the RAVE model has three different methods, corresponding to different subparts of the model. For the sake of the example, we will describe them in the following table:

Method name Description Inputs Outputs
encode Encodes an audio signal into a latent trajectory audio signal multiple latent trajectories
decode Decodes a latent trajectory into an audio signal multiple latent trajectories audio signal
forward (default) Encodes and decodes an audio signal audio signal audio signal

The user can switch between methods during instanciation by adding a second argument to nn~ calling the desired method.

Max / MSP PureData

Using attributes

It is possible to configure models after their initialization using special attributes, whose type and effect is entirely defined by the model itself, with the exception of the enable attribute which can be set to either 0 or 1 to enable or disable the model, potentially saving up computation.

Model attributes can be set using messages, with the following syntax:

set ATTRIBUTE_NAME ATTRIBUTE_VAL_1 ATTRIBUTE_VAL_2

Using Max/MSP and PureData graphical objects, this can lead to an intuitive way to modify the behavior of the model, as shown below where we have two model attributes (i.e. generation temperature and generation mode), and the special enable attribute.

Max / MSP PureData

The attribute list and values are again model dependant and should retrieved in the documentation of the model.

Buffer configuration

Internally, nn~ has a circular buffer mechanism that helps maintain a reasonable computational load. You can modify its size through the use of an additional integer after the method declaration, as shown below

Max / MSP PureData

Multicanal (Max/MSP)

The Max/MSP release of nn~ includes additional externals, namely mc.nn~ and mcs.nn~, allowing the use of the multicanal abilities of Max 8+ to simplify the patching process with nn~ and optionally decrease the computational load.

In the following examples, two audio files are being encoded then decoded by the same model in parallel

regular

This patch can be improved both visually and computationally speaking by using mc.nn~ and using batch operations

mc

Using mc.nn~ we build the multicanal signals over the different batches. In the example above, each multicanal signal will have 2 different canals. We also propose the mcs.nn~ external that builds multicanal signals over the different dimensions, as shown in the example below

mcs

In the example above, the two multicanals signals yielded by the nn~ rave encode 2 object have 16 canals each, corresponding to the 16 latent dimensions. This can help patching, while keeping the batching abilities of mc.nn~ by creating an explicit number of inlets / oulets corresponding to the number of examples we want to process in parallel.

To recap, the regular nn~ operates on a single example, and has as many inlets / outlets as the model has inputs / outputs. The mc.nn~ external is like nn~, but can process multiple examples at the same time. The mcs.nn~ variant is a bit different, and can process mulitple examples at the same time, but will have one inlet / outlet per examples.

Special messages

enable [0 / 1]

Enable / Disable computation to save up computation without deleting the model. Similar to how a bypass function would work.

reload

Dynamically reloads the model. Can be useful if you want to periodically update the state of a model during a training.

Build Instructions

macOS

  • Download the latest libtorch (CPU) here and unzip it to a known directory
  • Run the following commands:
git clone https://github.com/acids-ircam/nn_tilde --recursive
cd nn_tilde
mkdir build
cd build
cmake ../src/ -DCMAKE_PREFIX_PATH=/path/to/libtorch -DCMAKE_BUILD_TYPE=Release
make
  • Copy the produced .mxo external inside ~/Documents/Max 8/Packages/nn_tilde/externals/

You can build nn~ for PureData by adding -DPUREDATA_INCLUDE_DIR=/Applications/Pd-X.XX-X.app/Contents/Resources/src/ to the cmake call.

Windows

  • Download Libtorch (CPU) and dependencies here and unzip to a known directory.
  • Install Visual Studio and the C++ tools
  • Run the following commands:
git clone https://github.com/acids-ircam/nn_tilde --recurse-submodules
cd nn_tilde
mkdir build
cd build
cmake ..\src -A x64 -DCMAKE_PREFIX_PATH="<unzipped libtorch directory>"
cmake --build . --config Release

Raspberry Pi

While nn~ can be compiled and used on Raspberry Pi, you may have to consider using lighter deep learning models. We currently only support 64bit OS.

Install nn~ย for PureData using

curl -s https://raw.githubusercontent.com/acids-ircam/nn_tilde/master/install/raspberrypi.sh | bash

Funding

This work is led at IRCAM, and has been funded by the following projects

More Repositories

1

RAVE

Official implementation of the RAVE model: a Realtime Audio Variational autoEncoder
Python
1,283
star
2

diffusion_models

A series of tutorial notebooks on denoising diffusion probabilistic models in PyTorch
Jupyter Notebook
607
star
3

ddsp_pytorch

Implementation of Differentiable Digital Signal Processing (DDSP) in Pytorch
C
434
star
4

creative_ml

Creative Machine Learning course and notebook tutorials in JAX, PyTorch and Numpy
Jupyter Notebook
206
star
5

rave_vst

C++
186
star
6

pytorch_flows

Implementation and tutorials of normalizing flows with the novel distributions module
Jupyter Notebook
158
star
7

flow_synthesizer

Universal audio synthesizer control learning with normalizing flows
Max
132
star
8

neurorack

Python
108
star
9

variational-timbre

Generative timbre spaces by perceptually regularizing variational auto-encoders
Python
56
star
10

vschaos2

vintage neural synthesis with spectral auto-encoders
Python
48
star
11

cached_conv

Python
44
star
12

wavae

Realtime Variational Autoencoder built on top of libtorch and PureData
Python
36
star
13

timbre_exploration

Additional materials for "TIMBRE LATENT SPACE: EXPLORATION AND CREATIVE ASPECTS"
SCSS
20
star
14

lottery_mir

Ultra-light MIR models with a structured lottery ticket hypothesis approach
Python
13
star
15

lottery_generative

Lottery ticket hypothesis for deep generative models
Python
11
star
16

Expressive_WAE_FADER

companion repository to the DAFx-19 paper "Assisted Sound Sample Generation with Musical Conditioning in Adversarial Auto-Encoders" by Adrien Bitton, Philippe Esling et al.
9
star
17

Timbre_MoVE

Modulated Variational Auto-Encoders for Many-to-Many Musical Timbre Transfer
8
star
18

cml

Library for the Creative Machine Learning course
Python
6
star
19

projective_orchestration

Automatic projective orchestration using neural networks.
Python
5
star
20

PianoTranscriptionTransposition

Automatic Music Transcription and Instrument Transposition with Differentiable Rendering @ The 2020 Joint Conference on AI Music Creativity
SCSS
3
star
21

waveflow

Python
3
star
22

acids-ircam.github.io

HTML
3
star
23

live_orchestral_piano

Max/MSP patch for live projective orchestration
2
star