Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sending MIDI notes to/from QB64PE to a real MIDI keyboard plugged into the PC?
#6
I do recall @SpriggsySpriggs used a callback in his webcam code, I think these bits provide what we would need for the callback, but also maybe for that array definition inside the type? I'm including the whole mess at the bottom of this message.

I am not well-versed on these _Offset types and padding, but think that's the way we can approximate the type definitions that would be native to C++ but aren't directly supported in QB64PE. 
That array being declared inside the type 
    dwReserved2(3) as long
is 0-based, right? So 0..3, that's 4 long integers, which are 4 bytes each, so we need to reserve 16 bytes? 
Is there any additional "overhead" for the array we need to add? 
I see the webcam code has definitions in the Type MSG like
Code: (Select All)
    $If 64BIT Then
        As String * 4 padding1
    $End If
    As _Unsigned _Offset wParam
    As _Offset lParam
but I really don't know when to use _Offset or _Unsigned _Offset or String * 4 (what even is that?)
Spriggsy if you're there, I need you pal! Big Grin

also I see you have a custom type library with 

    Declare CustomType Library 
        ...
        Function GetProcAddress%& (ByVal hModule As _Offset, lpProcName As String)
    End Declare

and I see Sub SetupDriver calls  GetProcAddress to get the callback address, I guess I'll just add in that whole block? 

This whole thing is possible, I can smell it, but I'm like that monkey contemplating the monolith, to whom a simple bone club is cutting edge... oook! oook!

[Image: 51b1224d716b61e33a69a35010365bdc.jpg]


Code: (Select All)
Type MSG
    As _Offset hwnd
    As _Unsigned Long message
    $If 64BIT Then
        As String * 4 padding1
    $End If
    As _Unsigned _Offset wParam
    As _Offset lParam
    As _Unsigned Long time
    $If 64BIT Then
        As String * 4 padding2
    $End If
    As POINT pt
    As _Unsigned Long lPrivat
End Type

Declare Dynamic Library "Avicap32"
    Function CreateCaptureWindow& Alias "capCreateCaptureWindowA" (ByVal lpszWindowName As _Offset, ByVal dwStyle As _Unsigned Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hwndParent As _Offset, ByVal nId As Long)
End Declare

Declare CustomType Library
    Sub SendMessage Alias "SendMessageA" (ByVal hWnd As _Offset, ByVal Msg As _Unsigned Long, ByVal wParam As _Offset, ByVal lParam As _Offset)
    Function SendMessage& Alias "SendMessageA" (ByVal hWnd As _Offset, ByVal Msg As _Unsigned Long, ByVal wParam As _Offset, ByVal lParam As _Offset)
    Function PeekMessage& Alias "PeekMessageA" (ByVal lpMsg As _Offset, ByVal hWnd As _Offset, ByVal wMsgFilterMin As _Unsigned Long, ByVal wMsgFilterMax As _Unsigned Long, ByVal wRemoveMsg As _Unsigned Long)
    Sub TranslateMessage (ByVal lpMsg As _Offset)
    Sub DispatchMessage (ByVal lpMsg As _Offset)
    Sub DestroyWindow (ByVal hWnd As _Offset)
    Function mmioStringToFOURCC& (sz As String, ByVal uFlags As _Unsigned Long)
    Function OpenClipboard& (ByVal hWndNewOwner As _Offset)
    Function GetClipboardData%& (ByVal uFormat As _Unsigned Long)
    Sub CloseClipboard ()
    Function GlobalLock%& (ByVal hMem As _Offset)
    Function GlobalUnlock& (ByVal hMem As _Offset)
    Function LoadLibrary%& (lpLibFileName As String)
    Function GetProcAddress%& (ByVal hModule As _Offset, lpProcName As String)
End Declare

Declare Library ".\internal\c\c_compiler\include\vfw"
End Declare

Declare Library "framecallback"
End Declare

Declare CustomType Library
    Sub SendMessage Alias "SendMessageA" (ByVal hWnd As _Offset, ByVal Msg As _Unsigned Long, ByVal wParam As _Offset, ByVal lParam As _Offset)
    Function SendMessage& Alias "SendMessageA" (ByVal hWnd As _Offset, ByVal Msg As _Unsigned Long, ByVal wParam As _Offset, ByVal lParam As _Offset)
    Function PeekMessage& Alias "PeekMessageA" (ByVal lpMsg As _Offset, ByVal hWnd As _Offset, ByVal wMsgFilterMin As _Unsigned Long, ByVal wMsgFilterMax As _Unsigned Long, ByVal wRemoveMsg As _Unsigned Long)
    Sub TranslateMessage (ByVal lpMsg As _Offset)
    Sub DispatchMessage (ByVal lpMsg As _Offset)
    Sub DestroyWindow (ByVal hWnd As _Offset)
    Function mmioStringToFOURCC& (sz As String, ByVal uFlags As _Unsigned Long)
    Function OpenClipboard& (ByVal hWndNewOwner As _Offset)
    Function GetClipboardData%& (ByVal uFormat As _Unsigned Long)
    Sub CloseClipboard ()
    Function GlobalLock%& (ByVal hMem As _Offset)
    Function GlobalUnlock& (ByVal hMem As _Offset)
    Function LoadLibrary%& (lpLibFileName As String)
    Function GetProcAddress%& (ByVal hModule As _Offset, lpProcName As String)
End Declare

Declare Library ".\internal\c\c_compiler\include\vfw"
End Declare

Sub SetupDriver (hwnd As _Offset, defaultSource As _Byte)
    Dim As _Offset libload: libload = LoadLibrary(Command$(0))
    Dim As _Offset myCallback: myCallback = GetProcAddress(libload, "CapVideoCallback")
    If myCallback = 0 Then
        Print "Can't find callback pointer"
        End
    End If
...
    SendMessage hwnd, WM_CAP_GET_VIDEOFORMAT, 0, _Offset(format)
    SendMessage hwnd, WM_CAP_SET_CALLBACK_FRAME, 0, myCallback
End Sub

Function CapVideoCallback%& (hWnd As _Offset, lpVHdr As _Offset)
    Type VIDEOHDR
        As _Offset lpData
        As _Unsigned Long dwBufferLength, dwBytesUsed, dwTimeCaptured
        As String * 4 padding1
        As _Unsigned _Offset dwUser
        As _Unsigned Long dwFlags
        As String * 4 padding2
        As _Offset dwReserved1, dwReserved2, dwReserved3, dwReserved4
    End Type
...
End Function

(11 hours ago)grymmjack Wrote: This is sweet @bplus - FYI @a740g
This only works for Windows, but @a740g is working on (among many other things!) MIDI input support in addition to MIDI output support, and we've got some good tests working already.
(11 hours ago)grymmjack Wrote: I added this thread to the GitHub issue we've been tracking some MIDI threads here:
https://github.com/QB64-Phoenix-Edition/...issues/592
FYI @a740g
Well that's encouraging! Can you keep us updated? 

PS One "feature" I would maybe request for QB64PE, would be supporting arrays inside types, or at least an easier way to declare these API functions and the types they use and callbacks inside QB64, without having to be a brain surgeon, LOL.
Reply


Messages In This Thread
RE: sending MIDI notes to/from QB64PE to a real MIDI keyboard plugged into the PC? - by madscijr - 10 hours ago



Users browsing this thread: 3 Guest(s)