Skip to main content

PianoRoll

Struct PianoRoll 

Source
pub struct PianoRoll {
    pub items: Vec<TimedNote>,
    pub lanes: Vec<PianoRollLane>,
    pub time: TimeGrid,
}
Expand description

A piano roll: a set of timed lanes over a shared timing grid.

Holds the note projection in items alongside the full lanes, all keyed to a single TimeGrid.

Fields§

§items: Vec<TimedNote>

Note projection across all lanes, in stable order.

§lanes: Vec<PianoRollLane>

Lanes making up the roll, sorted by id then kind.

§time: TimeGrid

Timing grid shared by every lane.

Implementations§

Source§

impl PianoRoll

Source

pub fn new(items: Vec<TimedNote>) -> Result<Self, MusicError>

Builds a roll from notes, placing them on a single note lane.

Uses the default TimeGrid; an empty input yields a roll with no lanes.

Source

pub fn from_lanes(lanes: Vec<PianoRollLane>) -> Result<Self, MusicError>

Builds a roll from prepared lanes using the default TimeGrid.

Source

pub fn from_lanes_with_time( lanes: Vec<PianoRollLane>, time: TimeGrid, ) -> Result<Self, MusicError>

Builds a roll from prepared lanes over an explicit timing grid.

Validates time, sorts the lanes, and derives the note projection in stable order.

Source

pub fn from_note_events(events: Vec<NoteEvent>) -> Result<Self, MusicError>

Builds a roll from note events on a single performance note lane.

Converts each event’s tick timing to grid time with normal articulation.

Source

pub fn from_performance_take(take: &PerformanceTake) -> KernelResult<Self>

Builds a roll from a performance take’s extracted note events.

Surfaces extraction or validation failures as a kernel evaluation error.

Source

pub fn cells(&self) -> impl Iterator<Item = &PianoRollCell>

Iterates over every cell across all lanes.

Source

pub fn note_slices(&self) -> Vec<NoteSlice>

Splits the roll at every note onset and release into exact sounding windows.

Silent spans and zero-duration notes do not produce slices. Equal pitches in different cells remain separate SlicedNote entries.

Source

pub fn to_expr(&self) -> Expr

Renders the roll, its grid, and its lanes as an expression.

Trait Implementations§

Source§

impl Clone for PianoRoll

Source§

fn clone(&self) -> PianoRoll

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 PianoRoll

Source§

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

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

impl Eq for PianoRoll

Source§

impl MusicObject for PianoRoll

Source§

fn kind(&self) -> &'static str

Returns a stable, human-readable tag for this object kind.
Source§

fn duration(&self) -> Time

Returns the total duration this object occupies.
Source§

fn voices<'a>(&'a self, offset: Time, out: &mut Vec<TimedAtom<'a>>)

Appends the timed atoms produced by this object, shifted by offset.
Source§

fn clone_box(&self) -> Box<dyn MusicObject>

Clones this object into a fresh boxed trait object.
Source§

fn as_any(&self) -> &dyn Any

Returns this object as a &dyn Any for downcasting.
Source§

impl PartialEq for PianoRoll

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PianoRoll

Auto Trait Implementations§

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.