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
902 stars 66 forks source link

How would I make a synth? #160

Closed Conundroy closed 1 year ago

Conundroy commented 1 year ago

Excuse my extreme lack of audio engineering knowledge, I'm a total music beginner and I'm making a synth using Dawdreamer. I hook up a VST plugin to a piano UI wrapper, clicking a key would play sounds via sounddevice. The problem is the audio is not multiprocessing, I'd have to wait the first note to finish playing before it can start playing the next one.

Apologies if this isn't the right place to ask. Appreciate any support I can get.

DBraun commented 1 year ago

It sounds like polyphony is not enabled for the synthesizer. Is it a VST plugin? Which one? You might need to use synth.open_editor() to enable polyphony. Faust Processors have a num_voices integer parameter.

Conundroy commented 1 year ago

It sounds like polyphony is not enabled for the synthesizer. Is it a VST plugin? Which one? You might need to use synth.open_editor() to enable polyphony. Faust Processors have a num_voices integer parameter.

Any VST, the test one I'm using is TAL-BassLine piped through a plugin processor. Does the editor have to stay on?

DBraun commented 1 year ago

Can you try code like this

import dawdreamer as daw
from scipy.io import wavfile

PLUGIN_PATH="plugins/TAL-NoiseMaker.vst"
OUTPUT_PATH="my_output.wav"
SAMPLE_RATE=44100
DURATION = 10.
BLOCK_SIZE=128

engine = daw.RenderEngine(SAMPLE_RATE, BLOCK_SIZE)

synth = engine.make_plugin_processor("synth", PLUGIN_PATH)
synth.open_editor()

# Test polyphony with 3 overlapping notes
# (MIDI note, velocity, start sec, duration sec)
synth.add_midi_note(72, 40, 0.1, 5)
synth.add_midi_note(76, 40, 1.1, 3)
synth.add_midi_note(79, 40, 2.1, 1)

graph = [(synth, [])]

engine.load_graph(graph)
engine.render(DURATION)
audio = engine.get_audio()

wavfile.write(OUTPUT_PATH, SAMPLE_RATE, audio.transpose())

When the synth UI opens you'd have to make sure polyphony is enabled. On macos, I'm using theTAL-NoiseMaker.vst in the plugins folder and if I enable polyphony it's working correctly.

Conundroy commented 1 year ago

I managed to have polyphony now. But what I want is a synth with real time render essentially. From what I read, I don't think I can achieve this with the current version of Dawdreamer just yet. Or maybe there's something I'm missing?

DBraun commented 1 year ago

Right. It’s not a feature currently.