From 98e1c1994b8bd75113ffe971eebbfb0acf0d2e81 Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Mon, 24 Sep 2018 02:00:09 -0500 Subject: Completely blind guess to fix compression score --- tools/mid2agb/midi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/mid2agb/midi.cpp') diff --git a/tools/mid2agb/midi.cpp b/tools/mid2agb/midi.cpp index c7a4389b9..744ef42e8 100644 --- a/tools/mid2agb/midi.cpp +++ b/tools/mid2agb/midi.cpp @@ -836,7 +836,7 @@ int CalculateCompressionScore(std::vector& events, int index) } else { - score += 2; + score++; } } @@ -900,7 +900,7 @@ void Compress(std::vector& events) return; } - if (CalculateCompressionScore(events, i) > 6) + if (CalculateCompressionScore(events, i) >= 6) { CompressWholeNote(events, i); } -- cgit v1.2.3 From 48b65eecee4675415605b2734fe32f3048382a9c Mon Sep 17 00:00:00 2001 From: Diegoisawesome Date: Tue, 25 Sep 2018 01:26:09 -0500 Subject: Match compression behavior, for real --- tools/mid2agb/midi.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'tools/mid2agb/midi.cpp') diff --git a/tools/mid2agb/midi.cpp b/tools/mid2agb/midi.cpp index 744ef42e8..1458a32b3 100644 --- a/tools/mid2agb/midi.cpp +++ b/tools/mid2agb/midi.cpp @@ -773,14 +773,16 @@ void CalculateWaits(std::vector& events) } } +// This code is (purposely) buggy as shit, to mimic how the real mid2agb worked int CalculateCompressionScore(std::vector& events, int index) { int score = 0; - std::uint8_t lastParam1 = events[index].param1; + std::uint8_t lastParam1 = (std::uint8_t)events[index].type; std::uint8_t lastVelocity = 0x80u; EventType lastType = events[index].type; std::int32_t lastDuration = 0x80000000; std::uint8_t lastNote = 0x80u; + std::int32_t lastParam2; if (events[index].time > 0) score++; @@ -791,10 +793,11 @@ int CalculateCompressionScore(std::vector& events, int index) { int val = 0; - if (events[i].note != lastNote) + // BUG: uses type instead of note + if ((std::uint8_t)events[i].type != lastNote) { val++; - lastNote = events[i].note; + lastNote = (std::uint8_t)events[i].type; } if (events[i].param1 != lastVelocity) @@ -840,7 +843,10 @@ int CalculateCompressionScore(std::vector& events, int index) } } - lastParam1 = events[i].param1; + // BUG: uses type instead of param1 + lastParam1 = (std::uint8_t)events[i].type; + // unused + lastParam2 = events[i].param2; lastType = events[i].type; if (events[i].time) -- cgit v1.2.3