pub struct Device { /* private fields */ }Expand description
Handle to the engine thread. Cheap methods; nothing blocks except the recv* calls.
Implementations§
Source§impl Device
impl Device
Sourcepub fn spawn(config: Config) -> Device
pub fn spawn(config: Config) -> Device
Start the engine with no wake-up callback (poll or block on recv).
Sourcepub fn spawn_with_waker(
config: Config,
wake: impl Fn() + Send + Sync + 'static,
) -> Device
pub fn spawn_with_waker( config: Config, wake: impl Fn() + Send + Sync + 'static, ) -> Device
Start the engine; wake runs after every batch of updates (e.g. to repaint a GUI).
pub fn command(&self, c: Command)
pub fn try_recv(&self) -> Result<Update, TryRecvError>
pub fn recv(&self) -> Result<Update, RecvError>
pub fn recv_timeout( &self, timeout: Duration, ) -> Result<Update, RecvTimeoutError>
Sourcepub fn drain(&self) -> impl Iterator<Item = Update> + '_
pub fn drain(&self) -> impl Iterator<Item = Update> + '_
Every update available right now, without blocking.
pub fn connect(&self, port: impl Into<String>)
pub fn disconnect(&self)
pub fn resync(&self)
pub fn set_sync(&self, on: bool)
pub fn replay(&self, path: impl Into<PathBuf>, speed: f32)
pub fn stop_replay(&self)
Sourcepub fn write(&self, msgs: Vec<Vec<u8>>)
pub fn write(&self, msgs: Vec<Vec<u8>>)
Queue messages behind any pending SysEx (writes wait for their ack).
Sourcepub fn select_preset(&self, index: u8)
pub fn select_preset(&self, index: u8)
Select preset index (0-based, P01 = 0).
Sourcepub fn set_head(&self, m: Module, model: u8, on: bool)
pub fn set_head(&self, m: Module, model: u8, on: bool)
Set a module’s model and on/off. Ignored for LOOP/DRUM (no head CC).
Sourcepub fn set_param(&self, m: Module, slot: usize, value: u8)
pub fn set_param(&self, m: Module, slot: usize, value: u8)
Set a module parameter by slot (app display order). Ignored for slots the module lacks.
pub fn set_volume(&self, value: u8)
Press a looper button (host::LOOP_*).
Sourcepub fn save_preset(&self, source_slot: u8, preset: &Preset)
pub fn save_preset(&self, source_slot: u8, preset: &Preset)
Store preset in slot preset.index (with its name) and select it, using the official
app’s sequence. source_slot is the active preset the edits were made on.
Sourcepub fn import_user_amp(
&self,
slot: u8,
name: &str,
data: &[f32],
factor: f32,
) -> Result<(), UploadError>
pub fn import_user_amp( &self, slot: u8, name: &str, data: &[f32], factor: f32, ) -> Result<(), UploadError>
Import converted NAM data into user AMP slot (0–9) the way the official app does: select
the slot’s amp model, write the slot-info record (name, factor), then the 2048 floats.
Converting a .nam file into those floats is not implemented yet (docs/05).
Sourcepub fn import_nam_file(
&self,
slot: u8,
path: impl AsRef<Path>,
) -> Result<Converted, Box<dyn Error + Send + Sync>>
pub fn import_nam_file( &self, slot: u8, path: impl AsRef<Path>, ) -> Result<Converted, Box<dyn Error + Send + Sync>>
Convert a .nam file with the best conversion, Measure::Optimised
(closer to the model on hardware than the official app’s) at a normalised level
(crate::nam::convert::normalise_level), and import it into user AMP
slot (0–9), named after the file like the official app does. Never reads the official app
(see crate::nam::convert::official_excitation to opt in). The conversion runs on the
calling thread and takes about a minute (optimised build); Device::import_nam_file_with
with Measure::App gives the official algorithm in a few seconds. Returns the conversion.
Sourcepub fn import_nam_file_with(
&self,
slot: u8,
path: impl AsRef<Path>,
measure: Measure,
) -> Result<Converted, Box<dyn Error + Send + Sync>>
pub fn import_nam_file_with( &self, slot: u8, path: impl AsRef<Path>, measure: Measure, ) -> Result<Converted, Box<dyn Error + Send + Sync>>
Device::import_nam_file with a choice of conversion
(Measure): Optimised (the default, about a minute),
App (the official algorithm, a few seconds) or Clean. Keeps the model’s own level, as
the official app does; Device::import_nam_file_as can normalise it.
Sourcepub fn import_nam_file_as(
&self,
slot: u8,
path: impl AsRef<Path>,
measure: Measure,
normalise: bool,
) -> Result<Converted, Box<dyn Error + Send + Sync>>
pub fn import_nam_file_as( &self, slot: u8, path: impl AsRef<Path>, measure: Measure, normalise: bool, ) -> Result<Converted, Box<dyn Error + Send + Sync>>
Device::import_nam_file_with, optionally normalising the output level
(crate::nam::convert::normalise_level: every model plays at the same level, like NAM
plugins do; a pure volume change).
Sourcepub fn delete_user_amp(&self, slot: u8) -> Result<(), UploadError>
pub fn delete_user_amp(&self, slot: u8) -> Result<(), UploadError>
Delete user AMP slot and re-read its info, like the official app.
Sourcepub fn rename_user_amp(&self, slot: u8, name: &str) -> Result<(), UploadError>
pub fn rename_user_amp(&self, slot: u8, name: &str) -> Result<(), UploadError>
Rename user AMP slot (0–9) without touching its sound: write only the slot-info record
(the import’s first step, factor 1.0 like every import) with the new name, then re-read it.
The official app has no rename; this was confirmed on the pedal (the slot’s response is
unchanged within 0.1 dB, docs/05). Names are cut to 31 characters.
Sourcepub fn import_user_ir(
&self,
slot: u8,
name: &str,
data: &[f32],
) -> Result<(), UploadError>
pub fn import_user_ir( &self, slot: u8, name: &str, data: &[f32], ) -> Result<(), UploadError>
Import IR data into user IR slot (0–9) the way the official app does: show the CAB page,
select the slot’s cab model, write the 2048 floats, then the name. Only slot 0 has been
captured; other slots are assumed to work the same way.
Sourcepub fn rename_user_ir(&self, slot: u8, name: &str) -> Result<(), UploadError>
pub fn rename_user_ir(&self, slot: u8, name: &str) -> Result<(), UploadError>
Rename user IR slot (0–9) without touching its sound: write only the 0x09 name record
(the import’s last step), then re-read it. Confirmed on the pedal like
Device::rename_user_amp. Names are cut to 31 characters; the official app’s imports use
at most 16 (crate::ir::slot_name).
Sourcepub fn import_ir_file(
&self,
slot: u8,
path: impl AsRef<Path>,
) -> Result<ConvertedIr, Box<dyn Error + Send + Sync>>
pub fn import_ir_file( &self, slot: u8, path: impl AsRef<Path>, ) -> Result<ConvertedIr, Box<dyn Error + Send + Sync>>
Convert an IR audio file (WAV, any sample rate) with the best conversion,
crate::ir::convert_optimised (a 384-tap filter fitted to the whole IR: the pedal only
plays 384 taps, so this is much closer to the real IR than the official app’s), and import
it into user IR slot (0–9), named after the file like the official app does (first 16
characters). Device::import_ir_file_with with Method::App gives exactly the official
conversion. Returns the conversion.
Sourcepub fn import_ir_file_with(
&self,
slot: u8,
path: impl AsRef<Path>,
method: Method,
) -> Result<ConvertedIr, Box<dyn Error + Send + Sync>>
pub fn import_ir_file_with( &self, slot: u8, path: impl AsRef<Path>, method: Method, ) -> Result<ConvertedIr, Box<dyn Error + Send + Sync>>
Device::import_ir_file with a choice of conversion (crate::ir::Method).
Sourcepub fn write_settings(&self, settings: &Settings)
pub fn write_settings(&self, settings: &Settings)
Write the global settings (read-modify-write: start from the pedal’s current record).