Skip to content

Commit

Permalink
Fix usage docs for clack-host-cpal
Browse files Browse the repository at this point in the history
  • Loading branch information
prokopyl committed May 16, 2024
1 parent 3811e2b commit d767d42
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions host/examples/cpal/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# clack-host-cpal

An example of a functional CLAP host based on the `clack-host` crate,
using [CPAL](https://github.com/RustAudio/cpal) for audio output.

Expand All @@ -13,7 +14,7 @@ output at the same time), this host only connects to one single audio output and
handle any input.

This means audio effects plugins that process an incoming signal, while technically functional
in this host, will only receive silence as an input. In practice, synthesizers and other
in this host, will only receive silence as an input. In practice, synthesizers and other
audio-generating plugins are better suited to test this example with.

## Features
Expand Down Expand Up @@ -43,7 +44,7 @@ At least one of the `--plugin-id` (`-p`) or the `--bundle-path` (`-b`) parameter
Usage: clack-host-cpal [OPTIONS]
Options:
-f, --bundle-path <BUNDLE_PATH>
-b, --bundle-path <BUNDLE_PATH>
Loads the plugin found in the CLAP bundle at the given path.
If the bundle contains multiple plugins, this should be used in
Expand Down
2 changes: 1 addition & 1 deletion host/examples/cpal/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ enum MainError {

impl Display for MainError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self { MainError::UnspecifiedOptions => f.write_str("Please specify a plugin to load using the -p option or the -f option. Use --help for documentation."),
match self { MainError::UnspecifiedOptions => f.write_str("Please specify a plugin to load using the -p option or the -b option. Use --help for documentation."),
MainError::NoPluginInPath(path) => write!(f,
"No plugins found in CLAP bundle at {}. Stopping.",
path.display()
Expand Down
9 changes: 9 additions & 0 deletions host/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl<H: HostHandlers> PluginAudioProcessor<H> {
}
}

#[inline]
pub fn use_handler<'s, R>(
&'s self,
access: impl for<'a> FnOnce(&'s <H as HostHandlers>::AudioProcessor<'a>) -> R,
Expand All @@ -82,6 +83,7 @@ impl<H: HostHandlers> PluginAudioProcessor<H> {
}
}

#[inline]
pub fn use_handler_mut<'s, R>(
&'s mut self,
access: impl for<'a> FnOnce(&'s mut <H as HostHandlers>::AudioProcessor<'a>) -> R,
Expand All @@ -92,6 +94,7 @@ impl<H: HostHandlers> PluginAudioProcessor<H> {
}
}

#[inline]
pub fn is_started(&self) -> bool {
match self {
Stopped(_) => false,
Expand Down Expand Up @@ -123,6 +126,7 @@ impl<H: HostHandlers> PluginAudioProcessor<H> {
}
}

#[inline]
pub fn ensure_processing_started(
&mut self,
) -> Result<&mut StartedPluginAudioProcessor<H>, PluginInstanceError> {
Expand All @@ -132,6 +136,7 @@ impl<H: HostHandlers> PluginAudioProcessor<H> {
}
}

#[inline]
pub fn start_processing(
&mut self,
) -> Result<&mut StartedPluginAudioProcessor<H>, PluginInstanceError> {
Expand All @@ -152,6 +157,7 @@ impl<H: HostHandlers> PluginAudioProcessor<H> {
})
}

#[inline]
pub fn ensure_processing_stopped(&mut self) -> &mut StoppedPluginAudioProcessor<H> {
let inner = match self {
Stopped(s) => return s,
Expand All @@ -168,6 +174,7 @@ impl<H: HostHandlers> PluginAudioProcessor<H> {
}
}

#[inline]
pub fn stop_processing(
&mut self,
) -> Result<&mut StoppedPluginAudioProcessor<H>, PluginInstanceError> {
Expand All @@ -186,13 +193,15 @@ impl<H: HostHandlers> PluginAudioProcessor<H> {
})
}

#[inline]
pub fn into_started(self) -> Result<StartedPluginAudioProcessor<H>, ProcessingStartError<H>> {
match self {
Started(s) => Ok(s),
Stopped(s) => s.start_processing(),
}
}

#[inline]
pub fn into_stopped(self) -> StoppedPluginAudioProcessor<H> {
match self {
Started(s) => s.stop_processing(),
Expand Down

0 comments on commit d767d42

Please sign in to comment.