mirror of
https://github.com/dredozubov/polyrhythmix.git
synced 2024-11-22 11:57:43 +00:00
Add Midi text message to output file
This commit is contained in:
parent
07fea4b393
commit
9f98c5a4da
2 changed files with 6 additions and 65 deletions
|
@ -796,66 +796,7 @@ fn flatten_and_merge(
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_flatten_and_merge() {
|
fn test_flatten_and_merge() {
|
||||||
let kick_events = vec![
|
let kick_events = vec![Event { tick: Tick(0), event_type: NoteOn(KickDrum) }, Event { tick: Tick(12), event_type: NoteOff(KickDrum) }, Event { tick: Tick(12), event_type: NoteOn(KickDrum) }, Event { tick: Tick(24), event_type: NoteOff(KickDrum) }, Event { tick: Tick(36), event_type: NoteOn(KickDrum) }, Event { tick: Tick(48), event_type: NoteOff(KickDrum) }, Event { tick: Tick(60), event_type: NoteOn(KickDrum) }, Event { tick: Tick(72), event_type: NoteOff(KickDrum) }, Event { tick: Tick(72), event_type: NoteOn(KickDrum) }, Event { tick: Tick(84), event_type: NoteOff(KickDrum) }]; let snare_events = [Event { tick: Tick(24), event_type: NoteOn(SnareDrum) }, Event { tick: Tick(48), event_type: NoteOff(SnareDrum) }, Event { tick: Tick(96), event_type: NoteOn(SnareDrum) }, Event { tick: Tick(120), event_type: NoteOff(SnareDrum) }];
|
||||||
Event {
|
|
||||||
tick: Tick(0),
|
|
||||||
event_type: NoteOn(KickDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(12),
|
|
||||||
event_type: NoteOff(KickDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(12),
|
|
||||||
event_type: NoteOn(KickDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(24),
|
|
||||||
event_type: NoteOff(KickDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(36),
|
|
||||||
event_type: NoteOn(KickDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(48),
|
|
||||||
event_type: NoteOff(KickDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(60),
|
|
||||||
event_type: NoteOn(KickDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(72),
|
|
||||||
event_type: NoteOff(KickDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(72),
|
|
||||||
event_type: NoteOn(KickDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(84),
|
|
||||||
event_type: NoteOff(KickDrum),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
let snare_events = [
|
|
||||||
Event {
|
|
||||||
tick: Tick(24),
|
|
||||||
event_type: NoteOn(SnareDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(48),
|
|
||||||
event_type: NoteOff(SnareDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(96),
|
|
||||||
event_type: NoteOn(SnareDrum),
|
|
||||||
},
|
|
||||||
Event {
|
|
||||||
tick: Tick(120),
|
|
||||||
event_type: NoteOff(SnareDrum),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
let four_fourth = TimeSignature::from_str("4/4").unwrap();
|
let four_fourth = TimeSignature::from_str("4/4").unwrap();
|
||||||
// let kick_event_grid = EventGrid { events, length: Tick(48 * 4) };
|
// let kick_event_grid = EventGrid { events, length: Tick(48 * 4) };
|
||||||
let flattened_kick = flatten_and_merge(
|
let flattened_kick = flatten_and_merge(
|
||||||
|
@ -882,6 +823,9 @@ fn test_flatten_and_merge() {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
flattened_kick
|
flattened_kick
|
||||||
|
.iter()
|
||||||
|
.all(|x| flattened_kick_and_snare.contains(x)) &&
|
||||||
|
flattened_snare
|
||||||
.iter()
|
.iter()
|
||||||
.all(|x| flattened_kick_and_snare.contains(x)),
|
.all(|x| flattened_kick_and_snare.contains(x)),
|
||||||
true
|
true
|
||||||
|
@ -977,8 +921,7 @@ fn create_tracks<'a>(
|
||||||
)),
|
)),
|
||||||
});
|
});
|
||||||
|
|
||||||
// println!("{:?}", text_event.as_bytes());
|
drums.push(TrackEvent { delta: 0.into(), kind: TrackEventKind::Meta(MetaMessage::Text(text_event.as_bytes())) });
|
||||||
// drums.push(TrackEvent { delta: 0.into(), kind: TrackEventKind::Meta(MetaMessage::Text("!!!!!!!".as_bytes())) });
|
|
||||||
|
|
||||||
for event in event_grid.events {
|
for event in event_grid.events {
|
||||||
let midi_message = match event.event_type {
|
let midi_message = match event.event_type {
|
||||||
|
|
|
@ -96,7 +96,6 @@ fn test_cmp_time_signature() {
|
||||||
|
|
||||||
impl KnownLength for TimeSignature {
|
impl KnownLength for TimeSignature {
|
||||||
fn to_128th(&self) -> u32 {
|
fn to_128th(&self) -> u32 {
|
||||||
println!("{}", self.denominator.to_128th());
|
|
||||||
self.denominator.to_128th() * self.numerator as u32
|
self.denominator.to_128th() * self.numerator as u32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +108,6 @@ fn test_time_signature_known_length() {
|
||||||
impl TimeSignature {
|
impl TimeSignature {
|
||||||
pub fn converges<T: KnownLength, I: IntoIterator<Item = T>>(&self, multiple: I) -> Result<u32, String> {
|
pub fn converges<T: KnownLength, I: IntoIterator<Item = T>>(&self, multiple: I) -> Result<u32, String> {
|
||||||
let bar_len = self.to_128th();
|
let bar_len = self.to_128th();
|
||||||
println!("bar_len: {}", bar_len);
|
|
||||||
let result = multiple
|
let result = multiple
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.fold(bar_len, |acc, t| lowest_common_divisor(t.to_128th(), acc));
|
.fold(bar_len, |acc, t| lowest_common_divisor(t.to_128th(), acc));
|
||||||
|
|
Loading…
Reference in a new issue