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
impl Device
Sourcepub fn open(c: &Candidate) -> Result<Device, Error>
pub fn open(c: &Candidate) -> Result<Device, Error>
Open a candidate’s port and confirm the synth by the device inquiry.
Sourcepub fn simulated(driver: &'static dyn Driver) -> Result<Device, Error>
pub fn simulated(driver: &'static dyn Driver) -> Result<Device, Error>
The driver’s simulator as a device, for tests and demo mode.
Sourcepub fn demo(driver: &'static dyn Driver) -> Result<Device, Error>
pub fn demo(driver: &'static dyn Driver) -> Result<Device, Error>
The driver’s demo simulator (Driver::demo_simulator) as a
device, for demo mode.
Sourcepub fn connect(
driver: &'static dyn Driver,
link: Box<dyn Link>,
port_name: String,
) -> Result<Device, Error>
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.
pub fn driver(&self) -> &'static dyn Driver
pub fn port_name(&self) -> &str
Sourcepub fn channel(&self) -> u8
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.
Sourcepub fn send(&mut self, msg: &[u8]) -> Result<(), Error>
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).
Sourcepub fn recv_until(
&mut self,
deadline: Instant,
) -> Result<Option<Vec<u8>>, Error>
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.
Sourcepub fn open_xd(port: Option<&str>) -> Result<Device, Error>
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.
Sourcepub fn close(&mut self)
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.
Sourcepub fn poll_selected(&mut self) -> Option<u16>
pub fn poll_selected(&mut self) -> Option<u16>
The next program slot the synth’s panel picked (see
Driver::program_slot).
Sourcepub fn poll_control(&mut self) -> Option<(u8, u8)>
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.
Sourcepub fn ring_on_input(&mut self, bell: Sender<()>)
pub fn ring_on_input(&mut self, bell: Sender<()>)
Ring bell whenever this device’s synth sends something.
Sourcepub fn submit(&mut self, op: SessionOp) -> Result<(), Error>
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).
Sourcepub fn submit_units(&mut self, op: UnitOp) -> Result<(), Error>
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.
Sourcepub fn poll_unit_event(&mut self) -> Option<UnitEvent>
pub fn poll_unit_event(&mut self) -> Option<UnitEvent>
The next event of the unit ops.
Sourcepub fn cancel(&mut self, on_event: &mut dyn FnMut(&SessionEvent))
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.
Sourcepub fn pump(
&mut self,
on_event: &mut dyn FnMut(&SessionEvent),
) -> Result<Option<Instant>, Error>
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.
Sourcepub fn run_units(
&mut self,
op: UnitOp,
on_event: impl FnMut(&UnitEvent),
) -> Result<(), Error>
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.
Sourcepub fn run_xd(
&mut self,
op: Op,
on_event: impl FnMut(&Event),
) -> Result<(), Error>
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.