DBraun / DawDreamer

Digital Audio Workstation with Python; VST instruments/effects, parameter automation, FAUST, JAX, Warp Markers, and JUCE processors
GNU General Public License v3.0
863 stars 66 forks source link

I can't get a simple open-source synth (Surge) to make any sounds #120

Open turian opened 1 year ago

turian commented 1 year ago

I'm trying to use dawdreamer to create a large-scale corpus of synth sounds and their parameters, for large-scale ML experiments.

However, I cannot even load an open source VST3 (Surge synth) and generate a single sound :(

Here is a minimal example:

#!/usr/bin/env python
# coding: utf-8

import dawdreamer as daw
import numpy as np
from scipy.io import wavfile

SAMPLE_RATE = 44100
BUFFER_SIZE = 128  # Parameters will undergo automation at this buffer/block size.
PPQN = 960  # Pulses per quarter note.

SYNTH_PLUGIN = "/Library/Audio/Plug-Ins/VST3/Surge XT.vst3"

engine = daw.RenderEngine(SAMPLE_RATE, BUFFER_SIZE)

# Make a processor and give it the unique name "my_synth", which we use later.
synth = engine.make_plugin_processor("my_synth", SYNTH_PLUGIN)
assert synth.get_name() == "my_synth"

synth.load_state(
    "/Library/Application Support/Surge XT/patches_factory/Winds/Flute 1.fxp"
)

# We can also add one note at a time, specifying a start time and duration, both in seconds
synth.add_midi_note(60, 127, 0.5, 0.25)  # (MIDI note, velocity, start, duration)

# For any processor type, we can get the number of inputs and outputs
print("synth num inputs: ", synth.get_num_input_channels())
print("synth num outputs: ", synth.get_num_output_channels())

# don't do reverb
graph = [
    (synth, []),  # synth takes no inputs, so we give an empty list.
]

engine.load_graph(graph)
engine.render(5)

output = engine.get_audio()
wavfile.write("foo.wav", SAMPLE_RATE, output.transpose())

print(np.mean(np.abs(output)))

The file is empty

How can I generate sounds using dawdreamer?

DBraun commented 1 year ago

Thanks for reporting this. I'm observing the same issue with Surge XT 1.1.1. I had previously confirmed that Surge works on Windows, probably with version 1.9. I will investigate what's going on.

One minor thing in your code is that load_state is only meant to load binary objects created from save_state. If you already have fxp files, you should use load_preset. However, I tried this and it didn't lead to audio.

turian commented 1 year ago

@DBraun Is there a list of VST / plugins that are known to work (or not work) on OSX or Linux?

I want to start playing with the code! <3

DBraun commented 1 year ago

The most definitive list is what's listed in the tests because those get continuously tested.

https://github.com/DBraun/DawDreamer/blob/afd49899a6150507d0a3e72aa6546272dc0c4042/tests/dawdreamer_utils.py#L85

I put some effort into https://github.com/DBraun/DawDreamer/wiki/Plugin-Compatibility but it's missing stuff. Hopefully what's described is correct though.

turian commented 1 year ago

Related to #86

DBraun commented 1 year ago

Commenting out enableAllBuses() helps a bit with Surge. https://github.com/DBraun/DawDreamer/blob/bdc8947dc7aa99e141c0a081d4ba5bf0ccfd73b3/Source/PluginProcessor.cpp#L101

But I'm seeing that if a note is played in the first ~256 samples of a render, then it gets cut off early. The remaining notes play fine.

turian commented 1 year ago

Commenting out enableAllBuses() helps a bit with Surge.

What is the effect of that?

DBraun commented 1 year ago

Audio renders correctly but not if the MIDI note starts at sample < 257

turian commented 1 year ago

@DBraun hmmm weird. Is that just for surge or all synths? Any idea why?

I guess this is something that should go in the test suite.

(BTW, for Surge, I can generate sounds using their Python API. So one test we could write is that you generate the same sound using the same preset and f0 and note on and duration. And then we make sure the two audio files have low mean-absolute-error.)

DBraun commented 1 year ago

I fixed it, but I'm trying to get multiple things merged at once before the next release, so it may take another few days.

In Surge, there's an issue where I was sending it a MIDI CC message for clearing all notes, then I was playing a note, but then this section was entered, apparently a side-effect of the earlier MIDI CC message. Then this section got entered, and that turned off the note. The solution was to not send the MIDI CC message, but I think it's weird that the CC message has a side-effect that affects the note on that hasn't happened yet.

The other issue was related to buses.

turian commented 1 year ago

Okay. Thank you @DBraun . I am excited about this project and eager to build on it and share back what I've done.

DBraun commented 1 year ago

I tested Surge XT on Windows with DawDreamer 0.6.11 and the problem went away. Can you run your test again?

dimashenme commented 1 year ago

where do I report synths that actually work? I have just tested Diva and Repro on Linux and they successfully rendered several notes

DBraun commented 1 year ago

@dimashenme Thanks for that! I updated here https://github.com/DBraun/DawDreamer/wiki/Plugin-Compatibility I'm thinking about shifting to some other doc for managing it...

turian commented 1 year ago

@DBraun Perhaps just make github pages for the project and then people can submit PRs to add new synths that work