fix: resolve compilation errors in plugin and engine code
Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
@@ -476,11 +476,13 @@ mod tests {
|
|||||||
fn test_engine_get_clip_reuses_existing() {
|
fn test_engine_get_clip_reuses_existing() {
|
||||||
let mut engine = test_engine();
|
let mut engine = test_engine();
|
||||||
|
|
||||||
let clip1 = engine.get_clip(60);
|
// Get the clip once
|
||||||
let clip2 = engine.get_clip(60);
|
engine.get_clip(60);
|
||||||
|
|
||||||
// Both should point to the same clip
|
// Get it again - should reuse the same clip
|
||||||
assert_eq!(clip1 as *const _, clip2 as *const _);
|
let clip = engine.get_clip(60);
|
||||||
|
|
||||||
|
assert_eq!(clip.state, ClipState::Empty);
|
||||||
assert_eq!(engine.clips.len(), 1);
|
assert_eq!(engine.clips.len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
32
src/lib.rs
32
src/lib.rs
@@ -1,14 +1,14 @@
|
|||||||
use nih_plug::prelude::*;
|
use nih_plug::prelude::*;
|
||||||
|
|
||||||
mod engine;
|
mod engine;
|
||||||
use engine::{Engine, ClipState};
|
use engine::Engine;
|
||||||
|
|
||||||
/// The main plugin struct
|
/// The main plugin struct
|
||||||
pub struct ClipLauncher {
|
pub struct ClipLauncher {
|
||||||
/// The engine managing clips
|
/// The engine managing clips
|
||||||
engine: Engine,
|
engine: Engine,
|
||||||
/// Pending MIDI output events
|
/// Pending MIDI output events
|
||||||
pending_midi: Vec<NoteEvent>,
|
pending_midi: Vec<NoteEvent<f32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ClipLauncher {
|
impl Default for ClipLauncher {
|
||||||
@@ -50,7 +50,7 @@ impl Plugin for ClipLauncher {
|
|||||||
_context: &mut impl InitContext<Self>,
|
_context: &mut impl InitContext<Self>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
self.engine = Engine::new(
|
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,
|
buffer_config.sample_rate,
|
||||||
);
|
);
|
||||||
true
|
true
|
||||||
@@ -71,23 +71,25 @@ impl Plugin for ClipLauncher {
|
|||||||
// Process MIDI input events
|
// Process MIDI input events
|
||||||
while let Some(event) = context.next_event() {
|
while let Some(event) = context.next_event() {
|
||||||
match event {
|
match event {
|
||||||
NoteEvent::NoteOn { timing, note, velocity, channel } => {
|
NoteEvent::NoteOn { timing, note, velocity, channel, voice_id } => {
|
||||||
let output_velocity = self.engine.process_midi_note(note, velocity, true);
|
let output_velocity = self.engine.process_midi_note(note, velocity as u8, true);
|
||||||
// Queue output MIDI event
|
// Queue output MIDI event
|
||||||
self.pending_midi.push(NoteEvent::NoteOn {
|
self.pending_midi.push(NoteEvent::NoteOn {
|
||||||
timing,
|
timing,
|
||||||
note,
|
note,
|
||||||
velocity: output_velocity,
|
velocity: output_velocity as f32,
|
||||||
channel,
|
channel,
|
||||||
|
voice_id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
NoteEvent::NoteOff { timing, note, velocity, channel } => {
|
NoteEvent::NoteOff { timing, note, velocity, channel, voice_id } => {
|
||||||
let output_velocity = self.engine.process_midi_note(note, velocity, false);
|
let output_velocity = self.engine.process_midi_note(note, velocity as u8, false);
|
||||||
self.pending_midi.push(NoteEvent::NoteOff {
|
self.pending_midi.push(NoteEvent::NoteOff {
|
||||||
timing,
|
timing,
|
||||||
note,
|
note,
|
||||||
velocity: output_velocity,
|
velocity: output_velocity as f32,
|
||||||
channel,
|
channel,
|
||||||
|
voice_id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -96,7 +98,7 @@ impl Plugin for ClipLauncher {
|
|||||||
|
|
||||||
// Process audio
|
// Process audio
|
||||||
for channel_samples in buffer.iter_samples() {
|
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();
|
let num_samples = input.len();
|
||||||
|
|
||||||
// Process this block
|
// Process this block
|
||||||
@@ -118,11 +120,17 @@ impl Plugin for ClipLauncher {
|
|||||||
|
|
||||||
/// Empty params struct (no parameters needed for this plugin)
|
/// Empty params struct (no parameters needed for this plugin)
|
||||||
#[derive(Params)]
|
#[derive(Params)]
|
||||||
struct ClipLauncherParams;
|
struct ClipLauncherParams {
|
||||||
|
/// Placeholder parameter to satisfy the derive macro
|
||||||
|
#[id = "dummy"]
|
||||||
|
dummy: BoolParam,
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for ClipLauncherParams {
|
impl Default for ClipLauncherParams {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self
|
Self {
|
||||||
|
dummy: BoolParam::new("Dummy", false),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user