mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
155 lines
5.1 KiB
Rust
155 lines
5.1 KiB
Rust
mod engine_deps; pub use self::engine_deps::*;
|
|
mod time; pub use self::time::*;
|
|
mod note; pub use self::note::*;
|
|
mod jack; pub use self::jack::*;
|
|
mod midi; pub use self::midi::*;
|
|
|
|
//pub trait MaybeHas<T>: Send + Sync {
|
|
//fn get (&self) -> Option<&T>;
|
|
//}
|
|
|
|
//impl<T, U: Has<Option<T>>> MaybeHas<T> for U {
|
|
//fn get (&self) -> Option<&T> {
|
|
//Has::<Option<T>>::get(self).as_ref()
|
|
//}
|
|
//}
|
|
|
|
pub trait HasN<T>: Send + Sync {
|
|
fn get_nth (&self, key: usize) -> &T;
|
|
fn get_nth_mut (&mut self, key: usize) -> &mut T;
|
|
}
|
|
|
|
pub trait Gettable<T> {
|
|
/// Returns current value
|
|
fn get (&self) -> T;
|
|
}
|
|
|
|
pub trait Mutable<T>: Gettable<T> {
|
|
/// Sets new value, returns old
|
|
fn set (&mut self, value: T) -> T;
|
|
}
|
|
|
|
pub trait InteriorMutable<T>: Gettable<T> {
|
|
/// Sets new value, returns old
|
|
fn set (&self, value: T) -> T;
|
|
}
|
|
|
|
impl Gettable<bool> for AtomicBool {
|
|
fn get (&self) -> bool { self.load(Relaxed) }
|
|
}
|
|
|
|
impl InteriorMutable<bool> for AtomicBool {
|
|
fn set (&self, value: bool) -> bool { self.swap(value, Relaxed) }
|
|
}
|
|
|
|
impl Gettable<usize> for AtomicUsize {
|
|
fn get (&self) -> usize { self.load(Relaxed) }
|
|
}
|
|
|
|
impl InteriorMutable<usize> for AtomicUsize {
|
|
fn set (&self, value: usize) -> usize { self.swap(value, Relaxed) }
|
|
}
|
|
|
|
#[cfg(test)] #[test] fn test_time () -> Usually<()> {
|
|
// TODO!
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(test)] #[test] fn test_midi_range () {
|
|
let model = MidiRangeModel::from((1, false));
|
|
|
|
let _ = model.get_time_len();
|
|
let _ = model.get_time_zoom();
|
|
let _ = model.get_time_lock();
|
|
let _ = model.get_time_start();
|
|
let _ = model.get_time_axis();
|
|
let _ = model.get_time_end();
|
|
|
|
let _ = model.get_note_lo();
|
|
let _ = model.get_note_axis();
|
|
let _ = model.get_note_hi();
|
|
}
|
|
|
|
//macro_rules! impl_port {
|
|
//($Name:ident : $Spec:ident -> $Pair:ident |$jack:ident, $name:ident|$port:expr) => {
|
|
//#[derive(Debug)] pub struct $Name {
|
|
///// Handle to JACK client, for receiving reconnect events.
|
|
//jack: Jack<'static>,
|
|
///// Port name
|
|
//name: Arc<str>,
|
|
///// Port handle.
|
|
//port: Port<$Spec>,
|
|
///// List of ports to connect to.
|
|
//conn: Vec<PortConnect>
|
|
//}
|
|
//impl AsRef<Port<$Spec>> for $Name {
|
|
//fn as_ref (&self) -> &Port<$Spec> { &self.port }
|
|
//}
|
|
//impl $Name {
|
|
//pub fn new ($jack: &Jack, name: impl AsRef<str>, connect: &[PortConnect])
|
|
//-> Usually<Self>
|
|
//{
|
|
//let $name = name.as_ref();
|
|
//let jack = $jack.clone();
|
|
//let port = $port?;
|
|
//let name = $name.into();
|
|
//let conn = connect.to_vec();
|
|
//let port = Self { jack, port, name, conn };
|
|
//port.connect_to_matching()?;
|
|
//Ok(port)
|
|
//}
|
|
//pub fn name (&self) -> &Arc<str> { &self.name }
|
|
//pub fn port (&self) -> &Port<$Spec> { &self.port }
|
|
//pub fn port_mut (&mut self) -> &mut Port<$Spec> { &mut self.port }
|
|
//pub fn into_port (self) -> Port<$Spec> { self.port }
|
|
//pub fn close (self) -> Usually<()> {
|
|
//let Self { jack, port, .. } = self;
|
|
//Ok(jack.with_client(|client|client.unregister_port(port))?)
|
|
//}
|
|
//}
|
|
//impl HasJack<'static> for $Name {
|
|
//fn jack (&self) -> &'static Jack<'static> { &self.jack }
|
|
//}
|
|
//impl JackPort<'static> for $Name {
|
|
//type Port = $Spec;
|
|
//type Pair = $Pair;
|
|
//fn port (&self) -> &Port<$Spec> { &self.port }
|
|
//}
|
|
//impl ConnectTo<'static, &str> for $Name {
|
|
//fn connect_to (&self, to: &str) -> Usually<PortConnectStatus> {
|
|
//self.with_client(|c|if let Some(ref port) = c.port_by_name(to.as_ref()) {
|
|
//self.connect_to(port)
|
|
//} else {
|
|
//Ok(Missing)
|
|
//})
|
|
//}
|
|
//}
|
|
//impl ConnectTo<'static, &Port<Unowned>> for $Name {
|
|
//fn connect_to (&self, port: &Port<Unowned>) -> Usually<PortConnectStatus> {
|
|
//self.with_client(|c|Ok(if let Ok(_) = c.connect_ports(&self.port, port) {
|
|
//Connected
|
|
//} else if let Ok(_) = c.connect_ports(port, &self.port) {
|
|
//Connected
|
|
//} else {
|
|
//Mismatch
|
|
//}))
|
|
//}
|
|
//}
|
|
//impl ConnectTo<'static, &Port<$Pair>> for $Name {
|
|
//fn connect_to (&self, port: &Port<$Pair>) -> Usually<PortConnectStatus> {
|
|
//self.with_client(|c|Ok(if let Ok(_) = c.connect_ports(&self.port, port) {
|
|
//Connected
|
|
//} else if let Ok(_) = c.connect_ports(port, &self.port) {
|
|
//Connected
|
|
//} else {
|
|
//Mismatch
|
|
//}))
|
|
//}
|
|
//}
|
|
//impl ConnectAuto<'static> for $Name {
|
|
//fn connections (&self) -> &[PortConnect] {
|
|
//&self.conn
|
|
//}
|
|
//}
|
|
//};
|
|
//}
|