moutend / go-midi

Package midi implements reading and writing standard MIDI file.
MIT License
6 stars 2 forks source link

Stuff breaking when parsing a event that is nil #2

Open Bioblaze opened 3 months ago

Bioblaze commented 3 months ago

Example Code/w Midi file: test.zip

PS E:\Gaea\Depths\golang-games\test> go run .\midi2chiptune.go
2024/08/04 11:47:36 Reading MIDI file: E:\Gaea\Depths\golang-games\test\the-star-spangled-banner.mid
2024/08/04 11:47:36 midi: [0] start parsing 5297 bytes
2024/08/04 11:47:36 midi: [0] start parsing MThd
2024/08/04 11:47:36 midi: [4] parsing MThd completed
2024/08/04 11:47:36 midi: [4] start parsing header size
2024/08/04 11:47:36 midi: [8] parsing header size completed
2024/08/04 11:47:36 midi: [8] start parsing format type
2024/08/04 11:47:36 midi: [10] parsing format type completed (formatType=1)
2024/08/04 11:47:36 midi: [10] start parsing number of tracks
2024/08/04 11:47:36 midi: [12] parsing number of tracks completed (2)
2024/08/04 11:47:36 midi: [12] start parsing time division
2024/08/04 11:47:36 midi: [14] parsing time division completed (timeDivision = 256)
2024/08/04 11:47:36 midi: [14] start parsing MTrk
2024/08/04 11:47:36 midi: [18] parsing MTrk completed
2024/08/04 11:47:36 midi: [18] start parsing size of track
2024/08/04 11:47:36 midi: [22] parsing size of track completed (chunkSize=278)
2024/08/04 11:47:36 midi: [22] start parsing delta time
2024/08/04 11:47:36 midi: [23] parsing delta time completed (0)
2024/08/04 11:47:36 midi: [23] start parsing event type
2024/08/04 11:47:36 midi: [24] parsing event type completed (0xff)
2024/08/04 11:47:36 midi: [24] start parsing meta event type
2024/08/04 11:47:36 midi: [25] parsing meta event type completed (0x58)
2024/08/04 11:47:36 midi: [25] start parsing size of meta event
2024/08/04 11:47:36 midi: [26] parsing size of meta event completed (4)
2024/08/04 11:47:36 midi: [30] parsing event completed (event = &TimeSignatureEvent{numerator: 3, denominator: 2, metronomePulse: 24, quarterNote: 8})
2024/08/04 11:47:36 midi: [30] start parsing delta time
2024/08/04 11:47:36 midi: [31] parsing delta time completed (0)
2024/08/04 11:47:36 midi: [31] start parsing event type
2024/08/04 11:47:36 midi: [32] parsing event type completed (0xff)
2024/08/04 11:47:36 midi: [32] start parsing meta event type
2024/08/04 11:47:36 midi: [33] parsing meta event type completed (0x59)
2024/08/04 11:47:36 midi: [33] start parsing size of meta event
2024/08/04 11:47:36 midi: [34] parsing size of meta event completed (2)
2024/08/04 11:47:36 midi: [36] parsing event completed (event = <nil>)
2024/08/04 11:47:36 Failed to parse MIDI file: Event is null
2024/08/04 11:47:36 Event is null
Bioblaze commented 3 months ago

1 Added this cause it just kept crashing directly instead of throwing a error.