use midix::prelude::*;
use super::MidiSongBuilder;
pub struct ChannelBuilder<'a> {
pub(crate) builder: &'a mut MidiSongBuilder,
pub(crate) channel: Channel,
}
impl ChannelBuilder<'_> {
pub fn program_change(&mut self, time: u64, program: Program) -> &mut Self {
self.builder.add(Timed::new(
time,
ChannelVoiceMessage::new(self.channel, VoiceEvent::program_change(program)),
));
self
}
pub fn note_on(&mut self, time: u64, note: Note, velocity: Velocity) -> &mut Self {
self.builder.add(Timed::new(
time,
ChannelVoiceMessage::new(self.channel, VoiceEvent::note_on(note, velocity)),
));
self
}
pub fn note_off(&mut self, time: u64, note: Note, velocity: Velocity) -> &mut Self {
self.builder.add(Timed::new(
time,
ChannelVoiceMessage::new(self.channel, VoiceEvent::note_off(note, velocity)),
));
self
}
pub fn after_touch(&mut self, time: u64, note: Note, velocity: Velocity) -> &mut Self {
self.builder.add(Timed::new(
time,
ChannelVoiceMessage::new(self.channel, VoiceEvent::after_touch(note, velocity)),
));
self
}
pub fn control_change(&mut self, time: u64, controller: Controller) -> &mut Self {
self.builder.add(Timed::new(
time,
ChannelVoiceMessage::new(self.channel, VoiceEvent::control_change(controller)),
));
self
}
pub fn channel_after_touch(&mut self, time: u64, velocity: Velocity) -> &mut Self {
self.builder.add(Timed::new(
time,
ChannelVoiceMessage::new(self.channel, VoiceEvent::channel_after_touch(velocity)),
));
self
}
pub fn pitch_bend(&mut self, time: u64, pitch_bend: PitchBend) -> &mut Self {
self.builder.add(Timed::new(
time,
ChannelVoiceMessage::new(self.channel, VoiceEvent::pitch_bend(pitch_bend)),
));
self
}
}