pub struct MonoMidiReceiver { /* private fields */ }
Expand description
A Monophonic MIDI receiver is represented here.
Implementations§
Source§impl MonoMidiReceiver
impl MonoMidiReceiver
Sourcepub fn new(channel: u8) -> Self
pub fn new(channel: u8) -> Self
MonoMidiReceiver::new(c)
is a new Monophonic MIDI receiver which accepts messages on MIDI channel c
§Arguments
channel
- The zero-based MIDI channel to listen to in[0..15]
. All other MIDI channels are ignored.
The channel is clamped to [0..15]
Sourcepub fn parse(&mut self, byte: u8)
pub fn parse(&mut self, byte: u8)
mr.parse(b)
parses incoming MIDI data in the form of sequential bytes b
and updates its internal state
It is expected to call this function every time a new MIDI byte is received.
§Examples
use synth_utils::mono_midi_receiver::MonoMidiReceiver;
let mut mr = MonoMidiReceiver::new(1);
mr.parse(0x91); // note-on on channel 1
mr.parse(42); // note number 42
mr.parse(127); // max velocity
assert_eq!(mr.note_num(), 42);
assert_eq!(mr.velocity(), 1.0);
Sourcepub fn note_num(&self) -> u8
pub fn note_num(&self) -> u8
mr.note_num()
is the current MIDI note number held by the MIDI receiver
Sourcepub fn pitch_bend(&self) -> f32
pub fn pitch_bend(&self) -> f32
mr.pitch_bend()
is the current MIDI pitch-bend value held by the MIDI receiver, in [-1.0, 1.0]
Typically a value of -1 means “bend 2 semitones down”, 0 means “don’t bend at all”, and +1 means “bend 2 semitones up”, but this behavior can be tweaked by the end user.
Sourcepub fn velocity(&self) -> f32
pub fn velocity(&self) -> f32
mr.velocity()
is the current MIDI velocity value held by the MIDI receiver, in [0.0, 1.0]
Sourcepub fn mod_wheel(&self) -> f32
pub fn mod_wheel(&self) -> f32
mr.mod_wheel()
is the current MIDI mod-wheel value held by the MIDI receiver, in [0.0, 1.0]
Sourcepub fn volume(&self) -> f32
pub fn volume(&self) -> f32
mr.volume()
is the current MIDI volume value held by the MIDI receiver, in [0.0, 1.0]
Sourcepub fn vcf_cutoff(&self) -> f32
pub fn vcf_cutoff(&self) -> f32
mr.vcf_cutoff()
is the current MIDI VCF-cutoff value held by the MIDI receiver, in [0.0, 1.0]
Sourcepub fn vcf_resonance(&self) -> f32
pub fn vcf_resonance(&self) -> f32
mr.vcf_resonance()
is the current MIDI VCF-resonance value held by the MIDI receiver, in [0.0, 1.0]
Sourcepub fn portamento_time(&self) -> f32
pub fn portamento_time(&self) -> f32
mr.portamento_time()
is the current MIDI portamento-time value held by the MIDI receiver, in [0.0, 1.0]
Sourcepub fn portamento_enabled(&self) -> bool
pub fn portamento_enabled(&self) -> bool
mr.portamento_enabled()
is true if MIDI portamento is currently enabled
Sourcepub fn sustain_enabled(&self) -> bool
pub fn sustain_enabled(&self) -> bool
mr.sustain_enabled()
is true if MIDI sustain is currently enabled
Sourcepub fn rising_gate(&mut self) -> bool
pub fn rising_gate(&mut self) -> bool
mr.rising_gate()
is true if a new note has been triggered. Self clearing.
When retrigger is not allowed a rising gate is only triggered when a new note is played after all other notes have been lifted.
When retrigger is allowed a rising gate is triggered any time a new note-on message is received.
Sourcepub fn falling_gate(&mut self) -> bool
pub fn falling_gate(&mut self) -> bool
mr.falling_gate()
is true if all notes have been released after at least one note was played. Self clearing.
Sourcepub fn set_retrigger_mode(&mut self, mode: RetriggerMode)
pub fn set_retrigger_mode(&mut self, mode: RetriggerMode)
mr.set_retrigger_mode(m)
sets the retrigger mode to the given mode m
Sourcepub fn set_note_priority(&mut self, priority: NotePriority)
pub fn set_note_priority(&mut self, priority: NotePriority)
mr.set_note_priority(p)
sets the note priority to p