Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
turian opened this issue Sep 11, 2022 · 14 comments
Open

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

turian opened this issue Sep 11, 2022 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@turian
Copy link

turian commented Sep 11, 2022

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 DBraun self-assigned this Sep 11, 2022
@DBraun DBraun added the bug Something isn't working label Sep 11, 2022
@DBraun
Copy link
Owner

DBraun commented Sep 11, 2022

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
Copy link
Author

turian commented Sep 11, 2022

@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
Copy link
Owner

DBraun commented Sep 11, 2022

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

if platform.system() == "Darwin":

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
Copy link
Author

turian commented Sep 11, 2022

Related to #86

@DBraun
Copy link
Owner

DBraun commented Sep 12, 2022

Commenting out enableAllBuses() helps a bit with Surge.

myPlugin->enableAllBuses();

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
Copy link
Author

turian commented Sep 12, 2022

Commenting out enableAllBuses() helps a bit with Surge.

What is the effect of that?

@DBraun
Copy link
Owner

DBraun commented Sep 12, 2022

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

@turian
Copy link
Author

turian commented Sep 12, 2022

@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
Copy link
Owner

DBraun commented Sep 13, 2022

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
Copy link
Author

turian commented Sep 13, 2022

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

@DBraun
Copy link
Owner

DBraun commented Sep 14, 2022

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

@dimashenme
Copy link

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

@DBraun
Copy link
Owner

DBraun commented Feb 10, 2023

@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
Copy link
Author

turian commented Feb 10, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants