synthizer/
lib.rs

1//! Bindings to [Synthizer](https://github.com/synthizer/synthizer).  For
2//! documentation of the library itself, see [the
3//! book](https://synthizer.github.io).  This documentation covers aspects
4//! specific to the Rust bindings which map to the C bindings in a relatively
5//! straightforward manner
6//!
7//! # Handles
8//!
9//!Synthizer [Handle]s are reference-counted pointers which work like `Arc`. All
10//! the objects in this library that correspond to Synthizer objects (e.g.
11//! [BufferGenerator] but not [CustomStreamDef]) impl [Clone] and internally
12//! contain a handle.  So, e.g:
13//!
14//! ```
15//! use synthizer as syz;
16//! # fn main() -> syz::Result<()> {
17//! #    let _guard = syz::initialize()?;
18//! let ctx = syz::Context::new()?;
19//! // Refers to the same context.
20//! let ctx2 = ctx.clone();
21//! #    Ok(())
22//! # }
23//! ```
24//!
25//! # Initialization
26//!
27//! To initialize the library, use either [initialize] or the [LibraryConfig]
28//! type.  These will give you a [InitializationGuard] which must be kept alive
29//! for the duration of the program.  After the [InitializationGuard] goes out
30//! of scope, Synthizer functions all error.
31//!
32//! # Properties
33//!
34//! Properties are modeled as a `property()` method which returns an
35//! intermediate object that has methods on it. For example,
36//! `obj.playback_position().set(5.0)`. Object properties aren't type checked
37//! but error if using an object of the wrong type at runtime.  An internal
38//! trait, `ToSyzHandle`, is implemented for all library types.
39//!
40//! # Common Functionality
41//!
42//! All Synthizer objects implement a set of common methods on their struct.
43//! When the Synthizer manual refers to things like `syz_pause`, this can be
44//! found as `.pause()` on all applicable objects.
45//!
46//! # Userdata
47//! Synthizer supports userdata, which can be used to tie application entities
48//! to Synthizer objects via `Arc<Any>`.  This is set by e.g.
49//! [Handle::set_userdata].  Note that unlike Synthizer itself, the Rust
50//! bindings have to put userdata behind a [std::sync::RwLock] to offer thread
51//! safety,.
52//! # Casting Objects
53//!
54//! Synthizer itself is modeled as a hierarchy of "classes".  For example
55//! [Source] is a "base class" of all sources.  This is handled in Rust via
56//! adding a `cast_to` method to all Synthizer types, which can be used to
57//! attempt to cast to other object types when possible.  For example [Source3D]
58//! to [Source], but also [Handle] to [Source3D].
59//!
60//! Where this cast is infallible, `From` impls are provided.
61//!
62//! # Custom Streams
63//!
64//! Custom streams are possible via [CustomStreamDef] and
65//! [register_stream_protocol].  See the documentation on those types for more
66//! info.  In general, it is possible to convert anything implementing
67//! [std::io::Read] and [std::io::Seek] to a custom stream by implementing
68//! [CloseStream] for that type or a wrapper struct thereof.
69//!
70//! # Optional Features
71//!
72//! Synthizer has the following optional features:
73//!
74//! - `asset_lru`: Enable support for `asset_lru` via `AssetLruDecoder`, which
75//!   implements the `asset_lru` decoding traits.
76#[macro_use]
77mod common_functionality_macros;
78#[macro_use]
79mod property_tables;
80#[macro_use]
81mod handle;
82
83mod angular_panned_source;
84#[cfg(feature = "asset_lru")]
85mod asset_lru;
86mod automation_batch;
87mod biquad;
88mod buffer;
89mod buffer_generator;
90mod casting;
91mod context;
92mod custom_streams;
93mod delete_config;
94mod direct_source;
95mod enums;
96mod errors;
97mod events;
98mod fast_sine_bank_generator;
99mod generator;
100mod global_echo;
101mod global_fdn_reverb;
102mod initialization;
103mod internal_prelude;
104mod noise_generator;
105mod properties;
106mod routes;
107mod scalar_panned_source;
108mod source;
109mod source_3d;
110mod streaming_generator;
111mod userdata;
112mod version;
113
114#[cfg(feature = "asset_lru")]
115pub use crate::asset_lru::*;
116pub use angular_panned_source::*;
117pub use automation_batch::*;
118pub use biquad::*;
119pub use buffer::*;
120pub use buffer_generator::*;
121pub use context::*;
122pub use custom_streams::*;
123pub use delete_config::*;
124pub use direct_source::*;
125pub use enums::*;
126pub use errors::*;
127pub use events::*;
128pub use fast_sine_bank_generator::*;
129pub use generator::*;
130pub use global_echo::*;
131pub use global_fdn_reverb::*;
132pub use handle::*;
133pub use initialization::*;
134pub use noise_generator::*;
135pub use properties::*;
136pub use routes::*;
137pub use scalar_panned_source::*;
138pub use source::*;
139pub use source_3d::*;
140pub use streaming_generator::*;
141pub use version::*;