fix: resolve compilation errors in plugin and engine code

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-04-30 23:38:29 +00:00
parent b3ab709a7e
commit 34ccba7fd1
2 changed files with 26 additions and 16 deletions

View File

@@ -476,11 +476,13 @@ mod tests {
fn test_engine_get_clip_reuses_existing() {
let mut engine = test_engine();
let clip1 = engine.get_clip(60);
let clip2 = engine.get_clip(60);
// Get the clip once
engine.get_clip(60);
// Both should point to the same clip
assert_eq!(clip1 as *const _, clip2 as *const _);
// Get it again - should reuse the same clip
let clip = engine.get_clip(60);
assert_eq!(clip.state, ClipState::Empty);
assert_eq!(engine.clips.len(), 1);
}

View File

@@ -1,14 +1,14 @@
use nih_plug::prelude::*;
mod engine;
use engine::{Engine, ClipState};
use engine::Engine;
/// The main plugin struct
pub struct ClipLauncher {
/// The engine managing clips
engine: Engine,
/// Pending MIDI output events
pending_midi: Vec<NoteEvent>,
pending_midi: Vec<NoteEvent<f32>>,
}
impl Default for ClipLauncher {
@@ -50,7 +50,7 @@ impl Plugin for ClipLauncher {
_context: &mut impl InitContext<Self>,
) -> bool {
self.engine = Engine::new(
_audio_io_layout.main_input_channels.map(|c| c.get()).unwrap_or(2),
_audio_io_layout.main_input_channels.map(|c| c.get() as usize).unwrap_or(2),
buffer_config.sample_rate,
);
true
@@ -71,23 +71,25 @@ impl Plugin for ClipLauncher {
// Process MIDI input events
while let Some(event) = context.next_event() {
match event {
NoteEvent::NoteOn { timing, note, velocity, channel } => {
let output_velocity = self.engine.process_midi_note(note, velocity, true);
NoteEvent::NoteOn { timing, note, velocity, channel, voice_id } => {
let output_velocity = self.engine.process_midi_note(note, velocity as u8, true);
// Queue output MIDI event
self.pending_midi.push(NoteEvent::NoteOn {
timing,
note,
velocity: output_velocity,
velocity: output_velocity as f32,
channel,
voice_id,
});
}
NoteEvent::NoteOff { timing, note, velocity, channel } => {
let output_velocity = self.engine.process_midi_note(note, velocity, false);
NoteEvent::NoteOff { timing, note, velocity, channel, voice_id } => {
let output_velocity = self.engine.process_midi_note(note, velocity as u8, false);
self.pending_midi.push(NoteEvent::NoteOff {
timing,
note,
velocity: output_velocity,
velocity: output_velocity as f32,
channel,
voice_id,
});
}
_ => {}
@@ -96,7 +98,7 @@ impl Plugin for ClipLauncher {
// Process audio
for channel_samples in buffer.iter_samples() {
let (input, mut output) = channel_samples;
let (input, mut output) = channel_samples.split();
let num_samples = input.len();
// Process this block
@@ -118,11 +120,17 @@ impl Plugin for ClipLauncher {
/// Empty params struct (no parameters needed for this plugin)
#[derive(Params)]
struct ClipLauncherParams;
struct ClipLauncherParams {
/// Placeholder parameter to satisfy the derive macro
#[id = "dummy"]
dummy: BoolParam,
}
impl Default for ClipLauncherParams {
fn default() -> Self {
Self
Self {
dummy: BoolParam::new("Dummy", false),
}
}
}