Jump to content

[ask] how to create midi file with vb.net 2003

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
saint_xaver

saint_xaver

    Newbie

  • Members
  • PipPip
  • 15 posts
hi all, I need help. I make code to create midi file with vb.net 2003. it's work but when i play it with windows media player can't play it although it has the same ascii data with the real midi.
thx for the help.
  Dim writer As StreamWriter = New StreamWriter("Doremi.mid")
            Dim hexData(1000000) As String
            For x = 0 To 3
                If x = 0 Then
                    hexData(x) = "4D54686400000006000000010080"
                ElseIf x = 1 Then
                    hexData(x) = "4D54726B0000002E"
                ElseIf x = 2 Then
                    hexData(x) = "00C1180091376000903C6081003C00003E6081003E000040600091370000913960810090400000913900"
                ElseIf x = 3 Then
                    hexData(x) = "00FF2F00"
                End If
                writer.Write(Frm.hex2ascii(hexData(x)))
            Next
            writer.Close()



Public Function hex2ascii(ByVal hextext As String) As String
        Dim Panjang As Integer
        Dim num, value As String
        For Panjang = 1 To Len(hextext) Step 2
            num = Mid(hextext, Panjang, 2)
            value = value & Chr(Val("&h" & num))
            'y += 1
        Next
        Return value
    End Function
i make code using mci api but it can't work and system error say sistem overflow exception, arithmetic resulted in overflow, I don't know what's wrong.
 Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim play As Integer
        play = mciSendString("open C:\Windows\Media\flourish.mid type sequencer alias passport", 0, 0, 0)
        play = mciSendString("play passport", 0, 0, 0)
    End Sub

Edited by saint_xaver, 25 May 2010 - 10:42 PM.


#2
saint_xaver

saint_xaver

    Newbie

  • Members
  • PipPip
  • 15 posts
can anyone help me plz?