I'm looking to contrib to rust-vst2 by providing a simple sinewave instrument example.
I've gotten fairly far, having daws recognise the plugin as an instrument and everything is compiling okay, however, when any midi signals are sent to the plugin, it crashes.
Using mrswatson yields the following output:
rob@Robs-MacBook ~/P/vst-simplesynth> mrswatson64 --verbose -p "simplesynth" -m bass.mid -o "out.wav"
- 00000000 000001 MrsWatson version 0.9.8 initialized, build 20150122
D 00000000 000009 Host platform is Mac OS X (Mac OS XVersion 10.12.4 (Build 16E195))
D 00000000 000009 Application is 32-bit
D 00000000 000009 Launched with options: --verbose -p simplesynth -m bass.mid -o out.wav
D 00000000 000009 Trying to find plugin 'simplesynth'
D 00000000 000009 Looking for plugin 'simplesynth' in '/Users/rob/Projects/vst-simplesynth'
D 00000000 000011 Looking for plugin 'simplesynth' in '/Library/Audio/Plug-Ins/VST'
D 00000000 000012 Looking for plugin 'simplesynth' in '/Users/rob/Library/Audio/Plug-Ins/VST'
- 00000000 000013 Plugin 'simplesynth' is of type VST2.x
D 00000000 000013 Looking for plugin 'simplesynth' in '/Users/rob/Projects/vst-simplesynth'
D 00000000 000014 Looking for plugin 'simplesynth' in '/Library/Audio/Plug-Ins/VST'
D 00000000 000015 Looking for plugin 'simplesynth' in '/Users/rob/Library/Audio/Plug-Ins/VST'
- 00000000 000016 Opening VST2.x plugin 'simplesynth'
D 00000000 000017 Plugin location is '/Users/rob/Library/Audio/Plug-Ins/VST/simplesynth.vst'
D 00000000 000022 Plugin '' called host dispatcher with 1, 0, 0
D 00000000 000023 Initializing VST2.x plugin 'simplesynth'
D 00000000 000025 Time division is 96
D 00000000 000025 MIDI file is type 0, has 1 tracks, and time division 96 (type 1)
D 00000000 000025 Ignoring MIDI meta event of type 0x3 at 0
D 00000000 000025 Parsed MIDI meta event of type 0x58 at 0
D 00000000 000025 Parsed MIDI meta event of type 0x58 at 0
D 00000000 000025 MIDI event of type 0x90 parsed at 0
D 00000000 000025 MIDI event of type 0x80 parsed at 11025
D 00000000 000025 MIDI event of type 0x90 parsed at 11025
D 00000000 000025 MIDI event of type 0x80 parsed at 22050
...
00000000 000026 MIDI event of type 0x80 parsed at 352800
D 00000000 000026 Parsed MIDI meta event of type 0x2f at 352800
D 00000000 000027 Opened audiofile 16-bit, little-endian for writing
D 00000000 000027 Resuming plugin 'simplesynth'
- 00000000 000027 Starting processing input source
D 00000000 000027 Sample rate: 44100
D 00000000 000027 Blocksize: 512
D 00000000 000027 Channels: 2
D 00000000 000027 Tempo: 120.00
D 00000000 000030 Processing delay frames: 0
D 00000000 000030 Time signature: 4/4
D 00000000 000030 Read 1024 samples from silence source
D 00000000 000030 Scheduling MIDI event 0x58 (0, 0) in 0 frames
D 00000000 000030 Scheduling MIDI event 0x58 (0, 0) in 0 frames
D 00000000 000030 Scheduling MIDI event 0x90 (3d, 62) in 0 frames
D 00000000 000030 Processing plugin chain MIDI events
ERROR: Sent signal 11, exiting
MrsWatson (or one of its hosted plugins) has encountered a serious error and
crashed.
If you believe this to be a bug in MrsWatson, please re-run the program with
the --error-report option to generate a diagnostic report to send to support.
I can upload the entire source if required, but so far my lib.rs is as follows:
#[macro_use]
extern crate vst2;
use vst2::buffer::AudioBuffer;
use vst2::plugin::{Category, Plugin, Info};
use vst2::event::{Event};
struct SimpleSynth {
delta: f32
}
impl Default for SimpleSynth {
fn default() -> SimpleSynth {
SimpleSynth {
delta: 0.0
}
}
}
impl Plugin for SimpleSynth {
fn get_info(&self) -> Info {
Info {
name: "SimpleSynth".to_string(),
vendor: "DeathDisco".to_string(),
unique_id: 6667,
category: Category::Synth,
// inputs: 0,
// outputs: 2,
parameters: 0,
..Default::default()
}
}
fn process_events(&mut self, events: Vec<Event>) {
for event in events {
match event {
Event::Midi { .. } => println!("midi"),
_ => println!("sysex"),
}
}
}
fn process(&mut self, buffer: AudioBuffer<f32>) {
// Split out the input and output buffers into two vectors
let (inputs, outputs) = buffer.split();
// For each buffer, transform the samples
for (input_buffer, output_buffer) in inputs.iter().zip(outputs) {
for (input_sample, output_sample) in input_buffer.iter().zip(output_buffer) {
*output_sample = 0.5
}
}
}
}
plugin_main!(SimpleSynth);
Is there something obvious I'm missing, or is rust-vst2 not properly supporting Instruments yet?