@@ -329,22 +329,25 @@ module ReadFile =
329329
330330
331331 let voiceEvent n =
332- match n with
333- | SB( 0x80 uy, ch) -> parseMidi { do ! setRunningEvent ( NoteOff ch)
334- return ! noteOff ch }
335- | SB( 0x90 uy, ch) -> parseMidi { do ! setRunningEvent ( NoteOn ch)
336- return ! noteOn ch }
337- | SB( 0xa0 uy, ch) -> parseMidi { do ! setRunningEvent ( NoteAftertoucuh ch)
338- return ! noteAftertouch ch }
339- | SB( 0xb0 uy, ch) -> parseMidi { do ! setRunningEvent ( Control ch)
340- return ! controller ch }
341- | SB( 0xc0 uy, ch) -> parseMidi { do ! setRunningEvent ( Program ch)
342- return ! programChange ch }
343- | SB( 0xd0 uy, ch) -> parseMidi { do ! setRunningEvent ( ChannelAftertouch ch)
344- return ! channelAftertouch ch }
345- | SB( 0xe0 uy, ch) -> parseMidi { do ! setRunningEvent ( PitchBend ch)
346- return ! pitchBend ch }
347- | otherwise -> impossibleMatch ( sprintf " voiceEvent: %x " otherwise)
332+ parseMidi {
333+ match n with
334+ | SB( 0x80 uy, ch) -> do ! setRunningEvent ( NoteOff ch)
335+ return ! noteOff ch
336+ | SB( 0x90 uy, ch) -> do ! setRunningEvent ( NoteOn ch)
337+ return ! noteOn ch
338+ | SB( 0xa0 uy, ch) -> do ! setRunningEvent ( NoteAftertoucuh ch)
339+ return ! noteAftertouch ch
340+ | SB( 0xb0 uy, ch) -> do ! setRunningEvent ( Control ch)
341+ return ! controller ch
342+ | SB( 0xc0 uy, ch) -> do ! setRunningEvent ( Program ch)
343+ return ! programChange ch
344+ | SB( 0xd0 uy, ch) -> do ! setRunningEvent ( ChannelAftertouch ch)
345+ return ! channelAftertouch ch
346+ | SB( 0xe0 uy, ch) -> do ! setRunningEvent ( PitchBend ch)
347+ return ! pitchBend ch
348+ | otherwise -> return ! impossibleMatch ( sprintf " voiceEvent: %x " otherwise)
349+ }
350+
348351 let runningStatus ( event : VoiceEvent ) : ParserMonad < MidiEvent > =
349352 let mVoiceEvent e = mreturn ( VoiceEvent( MidiRunningStatus.ON, e))
350353 match event with
@@ -384,40 +387,34 @@ event = peek >>= step
384387 /// can cause fatal parse errors.
385388
386389 let event : ParserMonad < MidiEvent > =
387- let step n : ParserMonad < MidiEvent > =
388- parseMidi {
389- match n with
390- | 0xff uy ->
391- do ! dropByte
392- let! event = readByte >>= metaEvent
393- return MetaEvent event
394- | 0xf7 uy ->
395- do ! dropByte
396- let! sysexEvent = sysExEscape
397- return SysExEvent sysexEvent
398- | 0xf0 uy ->
399- do ! dropByte
400- let! sysexEvent = sysExEvent
401- return SysExEvent sysexEvent
402- | x when x >= 0xf8 uy ->
403- do ! dropByte
404- let! event = sysRealtimeEvent x
405- return SysRealtimeEvent event
406- | x when x >= 0xf1 uy ->
407- do ! dropByte
408- let! event = sysCommonEvent x
409- return SysCommonEvent event
410- | x when x >= 0x80 uy ->
411- do ! dropByte
412- let! voiceEvent = voiceEvent x
413- return VoiceEvent( MidiRunningStatus.OFF, voiceEvent)
414- | otherwise ->
415- return ! ( getRunningEvent >>= runningStatus)
416-
417- }
418390 parseMidi {
419- let! p = peek
420- return ! step p
391+ match ! peek with
392+ | 0xff uy ->
393+ do ! dropByte
394+ let! event = readByte >>= metaEvent
395+ return MetaEvent event
396+ | 0xf7 uy ->
397+ do ! dropByte
398+ let! sysexEvent = sysExEscape
399+ return SysExEvent sysexEvent
400+ | 0xf0 uy ->
401+ do ! dropByte
402+ let! sysexEvent = sysExEvent
403+ return SysExEvent sysexEvent
404+ | x when x >= 0xf8 uy ->
405+ do ! dropByte
406+ let! event = sysRealtimeEvent x
407+ return SysRealtimeEvent event
408+ | x when x >= 0xf1 uy ->
409+ do ! dropByte
410+ let! event = sysCommonEvent x
411+ return SysCommonEvent event
412+ | x when x >= 0x80 uy ->
413+ do ! dropByte
414+ let! voiceEvent = voiceEvent x
415+ return VoiceEvent( MidiRunningStatus.OFF, voiceEvent)
416+ | otherwise ->
417+ return ! ( getRunningEvent >>= runningStatus)
421418 }
422419
423420 let message =
0 commit comments