Skip to content

Commit

Permalink
Expose raw lilv objects. (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmedrano authored Jan 15, 2023
1 parent ec37409 commit a9bb40f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT"
name = "livi"
readme = "README.md"
repository = "https://github.com/wmedrano/livi-rs"
version = "0.5.7"
version = "0.6.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ pub use features::{Features, FeaturesBuilder};
pub use plugin::{Instance, Plugin};
pub use port::{EmptyPortConnections, Port, PortConnections, PortCounts, PortIndex, PortType};

/// The underlying `lilv` library.
pub use lilv;

/// Contains all the error types for the `livi` crate.
pub mod error;
/// Contains utility for dealing with `LV2` events.
Expand All @@ -54,6 +57,7 @@ mod port;

/// Contains all plugins.
pub struct World {
world: lilv::World,
livi_plugins: Vec<Plugin>,
}

Expand Down Expand Up @@ -82,10 +86,16 @@ impl World {
.collect();

World {
world,
livi_plugins: plugins,
}
}

/// Get the underlying lilv world.
pub fn raw(&self) -> &lilv::World {
&self.world
}

/// Creates a new world that includes all plugins that are found and return
/// `true` for `predicate.
#[must_use]
Expand Down Expand Up @@ -172,6 +182,7 @@ impl World {
.inspect(|p| info!("Found plugin {}: {}", p.name(), p.uri()))
.collect();
World {
world,
livi_plugins: plugins,
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ impl Plugin {
}
}

/// Get the underlying `lilv::plugin::Plugin`.
pub fn raw(&self) -> &lilv::plugin::Plugin {
&self.inner
}

/// A unique identifier for the plugin.
#[must_use]
pub fn uri(&self) -> String {
Expand Down Expand Up @@ -379,6 +384,16 @@ impl Instance {
Ok(())
}

/// Get the underlying `lilv::instance::ActiveInstance`.
pub fn raw(&self) -> &lilv::instance::ActiveInstance {
&self.inner
}

/// Get the underlying `lilv::instance::ActiveInstance`.
pub fn raw_mut(&mut self) -> &mut lilv::instance::ActiveInstance {
&mut self.inner
}

/// Get the value of the control port at `index`. If `index` is not a valid
/// control port index, then `None` is returned.
pub fn control_output(&self, index: PortIndex) -> Option<f32> {
Expand Down
14 changes: 14 additions & 0 deletions src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ where
CVInputs: ExactSizeIterator + Iterator<Item = &'a [f32]>,
CVOutputs: ExactSizeIterator + Iterator<Item = &'a mut [f32]>,
{
/// Returns the number of ports supported by type.
pub fn port_counts(&self) -> PortCounts {
PortCounts {
control_inputs: 0,
control_outputs: 0,
audio_inputs: self.audio_inputs.len(),
audio_outputs: self.audio_outputs.len(),
atom_sequence_inputs: self.atom_sequence_inputs.len(),
atom_sequence_outputs: self.atom_sequence_outputs.len(),
cv_inputs: self.cv_inputs.len(),
cv_outputs: self.cv_outputs.len(),
}
}

/// Create an instance of `PortConnections` with the given audio inputs.
pub fn with_audio_inputs<I>(
self,
Expand Down

0 comments on commit a9bb40f

Please sign in to comment.