pub struct Score { /* private fields */ }Expand description
A song of up to eight channels of notes, at one tempo.
Build it in code with Score::channel, or parse the text format described in
the module documentation with Score::parse. Both give equal scores.
Implementations§
Source§impl Score
impl Score
Sourcepub fn render(&self, sample_rate: u32) -> Result<Audio>
pub fn render(&self, sample_rate: u32) -> Result<Audio>
Renders the song once through, followed by the release of its last notes.
Sourcepub fn render_with(
&self,
sample_rate: u32,
options: &RenderOptions,
) -> Result<Audio>
pub fn render_with( &self, sample_rate: u32, options: &RenderOptions, ) -> Result<Audio>
Renders the song into mono audio. Equal to concatenating every chunk of a Synth.
Sourcepub fn render_stereo(&self, sample_rate: u32) -> Result<Audio>
pub fn render_stereo(&self, sample_rate: u32) -> Result<Audio>
Renders stereo, preserving synthwave unison spread and pan. Legacy channels are duplicated to left/right. No automatic limiting is applied.
pub fn render_stereo_with( &self, sample_rate: u32, options: &RenderOptions, ) -> Result<Audio>
Source§impl Score
impl Score
Sourcepub fn new(tempo: u16, ticks_per_quarter: u16) -> Result<Self>
pub fn new(tempo: u16, ticks_per_quarter: u16) -> Result<Self>
tempo in quarter notes per minute, 1..=999, and a time base of 1..=960 ticks per quarter.
pub fn with_limits( tempo: u16, ticks_per_quarter: u16, limits: ScoreLimits, ) -> Result<Self>
pub fn tempo(&self) -> u16
pub fn ticks_per_quarter(&self) -> u16
pub fn limits(&self) -> &ScoreLimits
pub fn instruments(&self) -> &[(String, Instrument)]
pub fn instrument_index(&self, name: &str) -> Option<usize>
pub fn channels(&self) -> &[Channel]
Sourcepub fn loop_tick(&self) -> Option<u64>
pub fn loop_tick(&self) -> Option<u64>
The tick where the song restarts after its end. Without one, it restarts at 0.
Sourcepub fn length_ticks(&self) -> u64
pub fn length_ticks(&self) -> u64
The song’s length in ticks: the longest channel.
pub fn duration_seconds(&self) -> f64
Sourcepub fn add_instrument(
&mut self,
name: impl Into<String>,
instrument: Instrument,
) -> Result<usize>
pub fn add_instrument( &mut self, name: impl Into<String>, instrument: Instrument, ) -> Result<usize>
Adds a named instrument and returns its index.
Sourcepub fn channel(&mut self, name: &str) -> Result<ChannelWriter<'_>>
pub fn channel(&mut self, name: &str) -> Result<ChannelWriter<'_>>
Writes to the named channel, creating it after the existing ones. Writing to it again continues where it ended, with the same instrument, volume and gate.
Source§impl Score
impl Score
Sourcepub fn parse(text: &str) -> Result<Score, ParseError>
pub fn parse(text: &str) -> Result<Score, ParseError>
Parses score text with the default ScoreLimits.