Commit 33784813 authored by Aske Simon Christensen's avatar Aske Simon Christensen
Browse files

Test interleaved processing and parameter changes

parent a61234eb
......@@ -6,6 +6,7 @@ authors = ["Aske Simon Christensen <blueberry@loonies.dk>"]
[dependencies]
vst2 = { path = "../../rust-vst2" }
#vst2 = { git = "https://github.com/overdrivenpotato/rust-vst2.git" }
rand = "0.3"
[lib]
name = "Oidos"
......
......@@ -3,12 +3,15 @@
#[macro_use]
extern crate vst2;
extern crate rand;
mod cache;
mod generate;
mod oidos_generate;
mod synth;
#[cfg(test)] use rand::{thread_rng, Rng};
use vst2::plugin::Info;
#[cfg(test)] use vst2::buffer::AudioBuffer;
#[cfg(test)] use vst2::event::Event;
......@@ -41,22 +44,41 @@ plugin_main!(OidosPlugin);
#[test]
fn test_oidos_plugin() {
let mut plugin = OidosPlugin::default();
plugin.set_sample_rate(44100.0);
plugin.get_info();
let event = Event::Midi {
data: [0x90, 45, 127],
delta_frames: 100,
live: true,
note_length: None,
note_offset: None,
detune: 0,
note_off_velocity: 0
};
plugin.process_events(vec![event]);
let mut left = [0f32; 300];
let mut right = [0f32; 300];
let buffer = AudioBuffer::new(vec![], vec![&mut left, &mut right]);
plugin.process(buffer);
plugin.set_sample_rate(500.0);
let nump = plugin.get_info().parameters;
let mut r = thread_rng();
for _it in 0..100 {
for _p in 0..r.gen_range(0, 2) {
plugin.set_parameter(r.gen_range(0, nump), r.gen_range(0f32, 1f32));
}
let block_size: usize = r.gen_range(100, 200);
let mut events = Vec::new();
for _e in 0..r.gen_range(0, 3) {
let on = r.gen_weighted_bool(3);
let event = Event::Midi {
data: [if on { 0x90u8 } else { 0x80u8 }, r.gen_range(60, 65), 127],
delta_frames: r.gen_range(0, block_size as i32),
live: true,
note_length: None,
note_offset: None,
detune: 0,
note_off_velocity: 0
};
events.push(event);
}
events.sort_by_key(|e| {
if let Event::Midi { delta_frames, ..} = *e {
delta_frames
} else {
0
}});
plugin.process_events(events);
let mut left = vec![0f32; block_size];
let mut right = vec![0f32; block_size];
let buffer = AudioBuffer::new(vec![], vec![&mut left, &mut right]);
plugin.process(buffer);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment