Skip to content

Commit dae3da2

Browse files
committed
Fix MIDI progress bar accuracy
I eventually realised the reason the progress bar is a bit weird to start with, is because the playhead at the start of the song is actually negative for a short while, so offsetting the value properly fixes this.
1 parent 68d2c7d commit dae3da2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ fn encode_midi(cmd: &Args) {
6565
let mut encoding = Encoding::new(&midi.config.video_file_out);
6666
let mut frame = RgbImage::new(*SCREEN_WIDTH, *SCREEN_HEIGHT);
6767

68-
let pb = generate_progressbar((midi.get_song_duration() * 1000.0) as u64);
68+
let pb = generate_progressbar(((midi.get_song_duration() + (*SCREEN_DURATION_SECS / 2.0)) * 1000.0) as u64);
6969

7070
// Step 2: Render waveforms
7171
println!("\nStarting render");
7272
loop {
7373
let result = midi.draw(&mut frame, &mut encoding);
7474

75-
pb.set_position((midi.playhead_secs * 1000.0) as u64);
75+
pb.set_position(((midi.playhead_secs + (*SCREEN_DURATION_SECS / 2.0)) * 1000.0) as u64);
7676

7777
// `err` can either be the end of the song, or a genuine fault.
7878
// Either way, stop execution.

0 commit comments

Comments
 (0)