Skip to content

Commit

Permalink
[fix] fix infer_params file extension bug, rename test audio
Browse files Browse the repository at this point in the history
  • Loading branch information
gudgud96 committed Nov 2, 2022
1 parent ba19ed2 commit 207d177
Show file tree
Hide file tree
Showing 21 changed files with 256 additions and 496 deletions.
47 changes: 38 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Syntheon
![syntheon_logo](docs/syntheon-logo.png)

Syntheon - the Pantheon (temple of gods) for music synthesizers.
# Syntheon

DX7 patches: https://yamahablackboxes.com/collection/yamaha-dx7-synthesizer/patches/
Syntheon - [Pantheon]() for music synthesizers.

## Testing
Syntheon aims to provide **parameter inference** for major music synthesizers using *deep learning models* to simplify sound design process. For now [Vital](https://vital.audio/) is supported, and [Dexed](https://asb2m10.github.io/dexed/) is on its way.

```
python3 -m inferencer.vital.vital_inferencer
**Check out [this presentation](https://docs.google.com/presentation/d/1PA4fom6QvCW_YG8L0MMVumrAluljcymndNlaK2HW5t0/edit?usp=sharing) on the recent advances of synth parameter inference.

python3 -m inferencer.dexed.dexed_inferencer
## Installation

python3 -m pytest
Syntheon needs `python 3.9`. Clone this repo and install the dependencies using:

```
python3 -m pip install -r requirements.txt
```

## Usage
Expand All @@ -25,4 +26,32 @@ output_params_file, eval_dict = infer_params(
"vital",
enable_eval=True
)
```
```

## Testing

```
python3 -m pytest
```

## Structure

For each synthesizer, we need to define:

- **converter** for preset format conversion:
- `serializeToDict`: convert preset file to a Python dictionary to be handled by inferencer
- `parseToPluginFile`: convert Python dictionary back to preset file, to be loaded by the synthesizer

- **inferencer** for model inference:
- `convert`: define the workflow of `load_model` -> `inference` -> `convert_to_preset`

## Contribution

Syntheon is actively under development, and contributions are welcomed. Some TODOs we have in mind include:

- Replicating state-of-the-art approaches
- Improving current model performance
- Incorporating new synthesizers
- Code refactoring 😅

This repo will only host the serving code, training code shall be released on a separate repo.
Binary file added docs/syntheon-logo-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/syntheon-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions syntheon/converter/dexed/dexed_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Credits to source: https://github.com/Nintorac/NeuralDX7/blob/master/scratch/dx7_constants.py
DX7 specification: https://github.com/asb2m10/dexed/blob/master/Documentation/sysex-format.txt
DX7 patches: DX7 patches: https://yamahablackboxes.com/collection/yamaha-dx7-synthesizer/patches/
"""
import bitstruct

Expand Down
1 change: 0 additions & 1 deletion syntheon/inferencer/dexed/models/ddx7/loss_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ddx7.core as core
import torch
import torch.nn as nn
import torchcrepe
from functools import partial


Expand Down
3 changes: 3 additions & 0 deletions syntheon/inferencer/inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ def inference(self, model, audio_fname):
return NotImplementedError

def convert_to_preset(self, inference_output):
"""
Output a Python dictionary to be handled by the converter.
"""
return NotImplementedError
Binary file not shown.
45 changes: 2 additions & 43 deletions syntheon/inferencer/vital/models/adsr_envelope.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
ADSR envelope shaper
Differentiable ADSR envelope shaper.
"""
import numpy as np
import torch
Expand Down Expand Up @@ -177,7 +177,7 @@ def forward(self,

attack_ratio = attack_secs / total_secs
decay_ratio = decay_secs / total_secs
# TODO: parameteize release_ratio
# TODO: parameterize release_ratio
release_ratio = torch.tensor([0.]).repeat(attack_secs.size(0), 1, 1)
if device == "cuda":
release_ratio = release_ratio.cuda()
Expand All @@ -200,47 +200,6 @@ def get_amp_shaper(
sustain_level,
offsets=None):
"""
implement case with no offset first.
"""
if offsets is None:
# if offset not specified, take next onset as offset
offsets = onsets[1:]
onsets = onsets[:len(onsets) - 1]

start_offset = int(onsets[0] * 100) # TODO: 100 is block size
onsets, offsets = torch.tensor(onsets), torch.tensor(offsets)
if device == "cuda":
onsets, offsets = onsets.cuda(), offsets.cuda()
dur_vec = offsets - onsets
lst = []

# append zeros first before first onset
if device == "cuda":
lst.append(torch.zeros(start_offset).cuda())
else:
lst.append(torch.zeros(start_offset))

for dur in dur_vec:
dur = round(dur.item(), 2)
adsr = shaper(
attack_secs=torch.tensor([0.2, 0.1]),
decay_secs=torch.tensor([0.1, 0.2]),
sustain_level=torch.tensor([0.9, 0.2]),
total_secs=dur)
lst.append(adsr[0].squeeze()) # TODO: fix the batch size case

final_signal = torch.cat(lst, dim=0)
return final_signal


def get_amp_shaper_v2(
shaper,
onsets,
attack_secs,
decay_secs,
sustain_level,
offsets=None):
"""
implement case with no offset first. enable batches
"""
if offsets is None:
Expand Down
Loading

0 comments on commit 207d177

Please sign in to comment.