pub struct Loop<S: SignalMut, F: Mut<S>> { /* private fields */ }Expand description
Changes a signal according to a specified function, at specified times. These times are looped.
Although it is not undefined behavior to initialize an empty loop, doing so will lead to panics in other methods.
See the module docs for more information.
Implementations§
Source§impl<K: Eq + Hash + Clone, D: Clone, F: Map<Input = D>> Loop<Polyphony<K, <F as Map>::Output>, NoteReader<K, D, F>>
impl<K: Eq + Hash + Clone, D: Clone, F: Map<Input = D>> Loop<Polyphony<K, <F as Map>::Output>, NoteReader<K, D, F>>
Sourcepub fn new_note_reader(
times: Vec<Time>,
note_reader: NoteReader<K, D, F>,
) -> Self
pub fn new_note_reader( times: Vec<Time>, note_reader: NoteReader<K, D, F>, ) -> Self
Turns a NoteReader into a [MelodyLoop].
Sourcepub fn new_melody(melody: Melody<K, D>, func: F) -> Self
pub fn new_melody(melody: Melody<K, D>, func: F) -> Self
Initializes a new [MelodyLoop] from a Melody.
The passed function builds signals from the given note data.
Sourcepub const fn note_reader(&self) -> &NoteReader<K, D, F>
pub const fn note_reader(&self) -> &NoteReader<K, D, F>
Returns a reference to the underlying NoteReader.
Sourcepub fn note_reader_mut(&mut self) -> &mut NoteReader<K, D, F>
pub fn note_reader_mut(&mut self) -> &mut NoteReader<K, D, F>
Returns a mutable reference to the underlying NoteReader.
Source§impl<S: SignalMut, F: Mut<S>> Loop<S, F>
impl<S: SignalMut, F: Mut<S>> Loop<S, F>
Sourcepub const fn index(&self) -> usize
pub const fn index(&self) -> usize
The current event index.
This index should, as a runtime invariant, always be less than the length of the loop, unless the loop is empty.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether there are no events in the loop.
Note that such a loop might cause other methods to panic.
Sourcepub fn current_time(&self) -> Time
pub fn current_time(&self) -> Time
Sourcepub fn func_mut(&mut self) -> &mut F
pub fn func_mut(&mut self) -> &mut F
Returns a mutable reference to the function modifying the signal.
Sourcepub fn total_time(&self) -> Time
pub fn total_time(&self) -> Time
The total time this loop takes to complete.
This method is expensive, as it must add all the times together.
Source§impl<S: Frequency> Loop<S, Arp>
impl<S: Frequency> Loop<S, Arp>
Trait Implementations§
Source§impl<S: SignalMut, F: Mut<S>> Signal for Loop<S, F>
impl<S: SignalMut, F: Mut<S>> Signal for Loop<S, F>
Source§fn _get(&self) -> Self::Sample
fn _get(&self) -> Self::Sample
rust-analyzer trips up sometimes that get is called, confusing it with
Array::get. This hack bypasses this.