Skip to main content

Device

Struct Device 

Source
pub struct Device { /* private fields */ }
Expand description

An open connection to one synth, through its driver’s session.

A worker thread serving several devices loops: Device::submit new commands, Device::pump every device, then wait on one bell that every device (Device::ring_on_input) and the command sender ring, until the earliest time a pump returned. run_all is that loop for a fixed set of ops.

Implementations§

Source§

impl Device

Source

pub fn open(c: &Candidate) -> Result<Device, Error>

Open a candidate’s port and confirm the synth by the device inquiry.

Source

pub fn simulated(driver: &'static dyn Driver) -> Result<Device, Error>

The driver’s simulator as a device, for tests and demo mode.

Source

pub fn demo(driver: &'static dyn Driver) -> Result<Device, Error>

The driver’s demo simulator (Driver::demo_simulator) as a device, for demo mode.

Source

pub fn connect( driver: &'static dyn Driver, link: Box<dyn Link>, port_name: String, ) -> Result<Device, Error>

Send the device inquiry on link and wait for an answer driver recognises. Our own inquiry coming back means a looping port.

Source

pub fn driver(&self) -> &'static dyn Driver

Source

pub fn port_name(&self) -> &str

Source

pub fn channel(&self) -> u8

The MIDI channel from the identity reply. 0 also when the synth listens on all channels (it answered on 7F); either way requests sent on it reach the synth.

Source

pub fn firmware(&self) -> Option<String>

The firmware version the synth named, for people.

Source

pub fn send(&mut self, msg: &[u8]) -> Result<(), Error>

Send one complete MIDI message outside the session (a live parameter change from Driver::live_messages).

Source

pub fn recv_until( &mut self, deadline: Instant, ) -> Result<Option<Vec<u8>>, Error>

The next complete SysEx message from the synth outside the session, or None once deadline passes (protocol probes). Only while idle.

Source

pub fn open_xd(port: Option<&str>) -> Result<Device, Error>

The minilogue xd on port (the first one found when None), for probes and hardware tests.

Source

pub fn close(&mut self)

Close the port now, ending its link; the device answers nothing until replaced. A minilogue xd asked for a program while it boots stops answering SysEx until its port has been closed.

Source

pub fn poll_selected(&mut self) -> Option<u16>

The next program slot the synth’s panel picked (see Driver::program_slot).

Source

pub fn poll_control(&mut self) -> Option<(u8, u8)>

The next Control Change the synth’s panel sent (a knob turned), for a oscyl_driver::PanelListener.

Source

pub fn ring_on_input(&mut self, bell: Sender<()>)

Ring bell whenever this device’s synth sends something.

Source

pub fn submit(&mut self, op: SessionOp) -> Result<(), Error>

Queue an op; it runs on the following pumps (after the unit ops queued before it).

Source

pub fn submit_units(&mut self, op: UnitOp) -> Result<(), Error>

Queue a logue unit op (logue synths only). It runs once the ops queued before it are done; its events come from Device::poll_unit_event. The first time, the driver session reads the edit buffer first, so a logue session’s reply-lag check has cleared the firmware fault before unit reads.

Source

pub fn poll_unit_event(&mut self) -> Option<UnitEvent>

The next event of the unit ops.

Source

pub fn is_idle(&self) -> bool

Nothing queued or in flight.

Source

pub fn cancel(&mut self, on_event: &mut dyn FnMut(&SessionEvent))

End every queued and in-flight op at once, each reported as OpError::Cancelled (e.g. hotplug says the synth is gone). The device starts afresh; the caller may drop it.

Source

pub fn pump( &mut self, on_event: &mut dyn FnMut(&SessionEvent), ) -> Result<Option<Instant>, Error>

One non-blocking round: send what the session allows, handle input that has arrived and expired deadlines, report events. Returns when to pump again at the latest (input rings sooner), or None when idle.

Source

pub fn run_units( &mut self, op: UnitOp, on_event: impl FnMut(&UnitEvent), ) -> Result<(), Error>

Run a logue unit op to completion, blocking (the CLI); see Device::submit_units. A failed op is an Error::Op.

Source

pub fn run_xd( &mut self, op: Op, on_event: impl FnMut(&Event), ) -> Result<(), Error>

Probes and xd session tests: run any minilogue xd op (programs too, outside the driver session) to completion on this device’s link, blocking. Apps use Device::submit_units instead. Only while idle, so no reply of a session op can be taken for one of this op. The first time, a SessionOp::ReadCurrent runs first, so the xd session’s reply-lag check has cleared the firmware fault before these reads.

Source

pub fn run( &mut self, op: SessionOp, on_event: impl FnMut(&SessionEvent), ) -> Result<(), Error>

Run op (and anything queued before it) to completion. A failed op is an Error::Op.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Device

§

impl !Sync for Device

§

impl !UnwindSafe for Device

§

impl Freeze for Device

§

impl Send for Device

§

impl Unpin for Device

§

impl UnsafeUnpin for Device

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.