Sign in to follow this  
Followers 0
Architerion

Midi In Example

10 posts in this topic

#1 ·  Posted (edited)

Howdy All

Im wanting to use Cubase SX/Midi (via loopmidi virtual cable) to drive usb 8 channel (FTD2XX.dll_UDF.au3). So far, the FTD udf is working great. Now I simply want to use the midi udf to trap midi in.

ie Any note on/off event will have its channel (0-7) used to add/sub bit operations to address the relay number and note velocity to turn on and off.

Does anyone have a simple example??? Scoured without success

I was thinking of something like (incomplete snippet to give an idea) this to send to the controller board

Func SetRelayState($NoteChan, $NoteVel)
    If ($NoteVel > 0) Then
        $RelayState = BitOR ($RelayState, $NoteChan)
    Else
        ;0 velocity = note off
        $RelayState = BitXOR ($RelayState, $NoteChan)
    Endif

    ;Set inits for serial write to control relay
    DllStructSetData($lpBuffer, 1, Chr($RelState))
    $dwBytesToWrite = StringLen(Chr($RelState))
    ; this uses 8 bits to set each relay eg 00000001 = relay 1 etc
    $Do = _FT_Write($FT_HANDLE, $lpBuffer, $dwBytesToWrite, $lpdwBytesWritten)
EndFunc

So, in abstract I just want to do something like this (snippet from old vbs > midiox I did)

Sub Sink_MidiInput( ts, port, stat, dat1, dat2) 'ts = timestamp, port, stat = status eg note, ctrl etc
    'Divide  notes into appropriate subs 'notenum on #13 
    If Port = FCBIn Then
        'Sort MsgType and Chn here
        Chn = stat AND &h0F
        mMsgType = stat AND &hF0 
        Select Case Stat
            ' ---- notes on chan1
            Case &h90
                            ' Call SetRelayState from here

                End Select
        End If
End Sub

In other words, an example of code showing reading midi input, is it a sink/event driven structure or is it a loop reading the stream etc

Hope that make sense

Many thanks for any input

Edited by Architerion

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

So absolutely no help???

All that time spent making beautiful UDFs and no examples on the deeper level stuff...hmm shame but ok...will move on I guess and use something a bit more supported.

Edited by Architerion

Share this post


Link to post
Share on other sites

Architerion,

If no-one has answered it is because no-one knows the solution or no-one is interested enough to work on it - it does look like a very niche request. Remember that what is important to you is not necessarily so to others - and also that you paid nothing to use AutoIt or to post here, so no-one among the volunteer responders here has any obligation to offer you any help at all. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Architerion,

If no-one has answered it is because no-one knows the solution or no-one is interested enough to work on it - it does look like a very niche request. Remember that what is important to you is not necessarily so to others - and also that you paid nothing to use AutoIt or to post here, so no-one among the volunteer responders here has any obligation to offer you any help at all. ;)

M23

I guess you are right. It just seems a waste of others time when many people have gone to a lot of trouble to do the midi udf work and there doesnt seem to be one example of its use. 

The examples I gave obscure a very simple request, on second look...but the question remains; Is there one example of using midi in? Specifically the use of a callback.

Im happy to pay someone for their example script...

Thanks

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I think part of the problem is that not many people have 'midi out' capable instruments, so testing a 'midi in' example is (perhaps) somewhat problematic. I suggest you look at examples on music coding forums and search MSDN.

Edited by czardas

Share this post


Link to post
Share on other sites

I think part of the problem is that not many people have 'midi out' capable instruments, so testing a 'midi in' example is (perhaps) somewhat problematic. I suggest you look at examples on music coding forums and search MSDN.

Hi czardas,

thanks for your reply. A test input can be easily achieved by using a free prog eg midiox and a virtual midi loop back eg loopbe. Have had a look at the resources but its handling dlls and I want to stay with the simple syntax of autoit rather than spending my time wading through another level. Hence why its better use of resource to simply pay someone for the startup info.

Cheers

mark

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

If I didn't have such a backlog to clear I would spend time looking into this (it's most unfortunate). I wasn't sure that testing could be done any other way, but now I understand that it can. Thanks for the information you provided. :)

Edited by czardas

Share this post


Link to post
Share on other sites

What is $RelState?  I ask because of its similarities to $RelayState.  Is it a poorly named global?

Sorry...typo...I cut and pasted from different test scripts. It is the same variable.

Share this post


Link to post
Share on other sites

Here is a working midi_in example, BUT it doesn't work for SYSEX. I wish I could figure it out though.

You do need to compile for 32 bit for it to work, under 64-bit it crashes.

It shows callback and other things. However, I'm looking to receive SYSEX which doesn't work.

MIDI.au3

MidiIn Example.au3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0