mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
device: add DeviceAudio dispatcher
This commit is contained in:
parent
fb99128650
commit
c78b2dc9de
3 changed files with 62 additions and 34 deletions
43
crates/device/src/device.rs
Normal file
43
crates/device/src/device.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use crate::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Device {
|
||||
#[cfg(feature = "sequencer")] Sequencer(MidiPlayer),
|
||||
#[cfg(feature = "sampler")] Sampler(Sampler),
|
||||
#[cfg(feature = "lv2")] Lv2(Lv2), // TODO
|
||||
#[cfg(feature = "vst2")] Vst2, // TODO
|
||||
#[cfg(feature = "vst3")] Vst3, // TODO
|
||||
#[cfg(feature = "clap")] Clap, // TODO
|
||||
#[cfg(feature = "sf2")] Sf2, // TODO
|
||||
}
|
||||
|
||||
impl Device {
|
||||
pub fn name (&self) -> &str {
|
||||
match self {
|
||||
Self::Sampler(sampler) => sampler.name.as_ref(),
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DeviceAudio<'a>(pub &'a mut Device);
|
||||
|
||||
audio!(|self: DeviceAudio<'a>, client, scope|{
|
||||
use Device::*;
|
||||
match self.0 {
|
||||
#[cfg(feature = "sequencer")] Sequencer(sequencer) =>
|
||||
{ Control::Continue /* TODO */ },
|
||||
#[cfg(feature = "sampler")] Sampler(sampler) =>
|
||||
SamplerAudio(sampler).process(client, scope),
|
||||
#[cfg(feature = "lv2")] Lv2(lv2) =>
|
||||
{ todo!() }, // TODO
|
||||
#[cfg(feature = "vst2")] Vst2 =>
|
||||
{ todo!() }, // TODO
|
||||
#[cfg(feature = "vst3")] Vst3 =>
|
||||
{ todo!() }, // TODO
|
||||
#[cfg(feature = "clap")] Clap =>
|
||||
{ todo!() }, // TODO
|
||||
#[cfg(feature = "sf2")] Sf2 =>
|
||||
{ todo!() }, // TODO
|
||||
}
|
||||
});
|
||||
|
|
@ -15,6 +15,9 @@ pub(crate) use ::tek_engine::midi::{u7, LiveEvent, MidiMessage};
|
|||
pub(crate) use ::tek_engine::jack::{Control, ProcessScope, MidiWriter, RawMidi};
|
||||
pub(crate) use ratatui::{prelude::Rect, widgets::{Widget, canvas::{Canvas, Line}}};
|
||||
|
||||
mod device;
|
||||
pub use self::device::*;
|
||||
|
||||
#[cfg(feature = "clock")] mod clock;
|
||||
#[cfg(feature = "clock")] pub use self::clock::*;
|
||||
|
||||
|
|
@ -38,23 +41,3 @@ pub(crate) use ratatui::{prelude::Rect, widgets::{Widget, canvas::{Canvas, Line}
|
|||
|
||||
#[cfg(feature = "clap")] mod clap;
|
||||
#[cfg(feature = "clap")] pub use self::clap::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Device {
|
||||
#[cfg(feature = "sequencer")] Sequencer(MidiPlayer),
|
||||
#[cfg(feature = "sampler")] Sampler(Sampler),
|
||||
#[cfg(feature = "lv2")] Lv2(Lv2), // TODO
|
||||
#[cfg(feature = "vst2")] Vst2, // TODO
|
||||
#[cfg(feature = "vst3")] Vst3, // TODO
|
||||
#[cfg(feature = "clap")] Clap, // TODO
|
||||
#[cfg(feature = "sf2")] Sf2, // TODO
|
||||
}
|
||||
|
||||
impl Device {
|
||||
pub fn name (&self) -> &str {
|
||||
match self {
|
||||
Self::Sampler(sampler) => sampler.name.as_ref(),
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue