Android Question Android 10 Media Player can't play Midi files

Michael Wenning

Member
Licensed User
Longtime User
my app based on MidiSystem2 and Midi Driver V2 Library from steve 05. Many thanks again to Steve for his outstanding work!!!
With the app the user creates midi files, which are then played with the media player. On Android 8 everything works perfect. With Android 10
devices is not possible to listen. i have done some research and compared the file content with a midifile created on the pc ( see attached files).
Is it possible to control the structure of the midifile with the libary? Or is there an easy solution?
Thank you for your answer
Michael
 

Attachments

  • MidiFileStudy.xlsx
    13.3 KB · Views: 170
  • MidiFiles.zip
    607 bytes · Views: 170

Michael Wenning

Member
Licensed User
Longtime User
Hello again,
i have modified the Sub WriteVarInt in MidiFileWriter.bas as suggested by KimStudio in post #19.
I elemenated the bytes not needed for the delta timing
It's only a prototype but the midi file output is OK!



Sub WriteVarInt(Value As Long) As Int:
Private Sub WriteVarInt(Value As Long) As Int
    Dim Len As Int = 1
    Dim Shift As Int = 63
    
    Dim bc As ByteConverter
    Dim val(1) As Int
    Dim i As Int
    Dim intAnzahlBytes As Int

    Log ("WriteVarInt Value: " & Value )
    
    intAnzahlBytes = Ceil( Value/ 127)
    
    intAnzahlBytes = intAnzahlBytes -1
    
    Log ("Bytes relevant: " & intAnzahlBytes)
    
    'First screen out the leading zeros
    Do While Shift > 0  And Bit.And(Value,Bit.ShiftLeft(MASK,Shift)) = 0
        Shift = Shift - 7
    Loop
    
    i = 5
    Do While Shift > 0
        i = i -1
        If i < intAnzahlBytes Then
            TdDos.WriteByte( Bit.Or( Bit.ShiftRight( Bit.And(Value, Bit.ShiftLeft(MASK,Shift)),Shift),0x80))
             Log ("i: " & i & " Written!")
            Len = Len + 1
        End If
        
        Log ("WriteVarInt TdDos 1: " & Bit.Or( Bit.ShiftRight( Bit.And(Value, Bit.ShiftLeft(MASK,Shift)),Shift),0x80)   & TAB & TAB & TAB & TAB & " Hex: " & bc.HexFromBytes(bc.IntsToBytes((val))))
        
        val(0) = Bit.Or( Bit.ShiftRight( Bit.And(Value, Bit.ShiftLeft(MASK,Shift)),Shift),0x80)
        
        Shift = Shift - 7
        'Len = Len + 1
    Loop
    
    TdDos.WriteByte(Bit.And(Value,MASK))
    
    val(0) = Bit.And(Value,MASK)
    Log ("WriteVarInt TdDos 2: " & Bit.And(Value,MASK) & TAB & TAB  & TAB &  TAB & " Hex: " & bc.HexFromBytes(bc.IntsToBytes((val))) )
    
    Return Len
End Sub

Attached are a midifile generated with the modifed code and the byte analysis of the file as well as a file example with the previous status.

Best regards
Michael
 

Attachments

  • MidiFileStudy_V3.xlsx
    15.6 KB · Views: 132
  • a6.zip
    200 bytes · Views: 123
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Thank you both, I will do some legacy testing and update when I get a chance.
 
Upvote 0
Top