Skip to main content

Score

Struct Score 

Source
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

Source

pub fn render(&self, sample_rate: u32) -> Result<Audio>

Renders the song once through, followed by the release of its last notes.

Source

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.

Source

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.

Source

pub fn render_stereo_with( &self, sample_rate: u32, options: &RenderOptions, ) -> Result<Audio>

Source§

impl Score

Source

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.

Source

pub fn with_limits( tempo: u16, ticks_per_quarter: u16, limits: ScoreLimits, ) -> Result<Self>

Source

pub fn tempo(&self) -> u16

Source

pub fn ticks_per_quarter(&self) -> u16

Source

pub fn limits(&self) -> &ScoreLimits

Source

pub fn instruments(&self) -> &[(String, Instrument)]

Source

pub fn instrument_index(&self, name: &str) -> Option<usize>

Source

pub fn channels(&self) -> &[Channel]

Source

pub fn loop_tick(&self) -> Option<u64>

The tick where the song restarts after its end. Without one, it restarts at 0.

Source

pub fn length_ticks(&self) -> u64

The song’s length in ticks: the longest channel.

Source

pub fn duration_seconds(&self) -> f64

Source

pub fn add_instrument( &mut self, name: impl Into<String>, instrument: Instrument, ) -> Result<usize>

Adds a named instrument and returns its index.

Source

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

Source

pub fn parse(text: &str) -> Result<Score, ParseError>

Parses score text with the default ScoreLimits.

Source

pub fn parse_with_limits( text: &str, limits: &ScoreLimits, ) -> Result<Score, ParseError>

Trait Implementations§

Source§

impl Clone for Score

Source§

fn clone(&self) -> Score

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Score

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for Score

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(text: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Score

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Freeze for Score

§

impl RefUnwindSafe for Score

§

impl Send for Score

§

impl Sync for Score

§

impl Unpin for Score

§

impl UnsafeUnpin for Score

§

impl UnwindSafe for Score

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.