ok here is my problem

23 views
Skip to first unread message

wadfm

unread,
Jun 29, 2008, 2:10:04 PM6/29/08
to wxMax
i have written a drum and bass sequencer under blitzmax and i have got
quite far with it,

things i have in the program :-

Pattern editor for both drums and bass
Song creator panes for both drums and bass so they can run
independantly
drumkit editor so you can create your own kits
song info page
live drum playing via the qwerty keyboard
sound panel control for volume and pan of each drum sound
sound panel control for volume and pan and mute of each octave of the
bass synth (4 octaves)
and a few more things added too

my question is :

i want to add midi in support to this and i know i should be asking
this in the blitzmax forums but all i get is see bruceys midi blah
blah blah

now all i want is the midi in to play a .wav file in my program as
each sound has its own volume and pan set in the sound panel

now recently i did find a blitmax midi app source code and compiled
version of it to test midi in
the compiled version worked ok but the source code would not compile
under blitzmax for some reason

this midi app i found showed the user the note pressed in numeric
order as the keys were hit

but now i wonder is it possible to say that when that midi note is hit
can it play a wav file ?

am i making any sense

cheers

Lee Broadhurst

Brucey

unread,
Jul 1, 2008, 1:47:28 PM7/1/08
to wxMax
Hi,

There's a midi sample app available in the samples folder which might
help you get started with it. Specifically it has a section where it
polls for input from a midi device and shows the incoming data. This
you could interpret in some way to know when to play different sounds,
or the same sound at different pitches.

HTH

:o)

wadfm

unread,
Jul 3, 2008, 11:50:33 AM7/3/08
to wxMax
i would be very grateful if you could send it to us via my email or
post a link here to get it as i dont have it any more i lost my hard
drive and that was on it :(

cheers

Lee B
> > Lee Broadhurst- Hide quoted text -
>
> - Show quoted text -

Bruce Henderson

unread,
Jul 4, 2008, 3:06:08 AM7/4/08
to wx...@googlegroups.com
What are you looking for exactly?

If it's the wxMidi stuff, it comes with wxMax, which you can svn from
the googlecode site. There hasn't been a .zip release of it yet
(officially).

Or are you talking about a different package altogether?


Brucey

wadfm

unread,
Jul 4, 2008, 10:39:42 AM7/4/08
to wxMax
i think its a different package which was put on the blitzmax site but
all it did as you said in your last post was display the note pressed
etc.....

firstly it asks you to enter a number in for the sound device you are
using and then it says debug mode midi open

then when you press a key on the midi keyboard the data shows up

i think it was before wxmax or wxmidi though

but there was a comiled version of this midi in program and the source
code for it but as i said before i had trouble with compiling the
source under blitzmax 1.26 but now i have 1.28 i thought i would give
it a try again but as i also said i lost a lot of data recently.

the compiled exe i think was called midiin.debug.exe , i maybe am
getting confuzed with this it may not be you but some other person in
the forums that posted it but it was a good little start to what i
want. Oh well if its not you then i must keep looking and then maybe
one day i will finish this dammed project lol

Also i am having a lot of trouble getting wxmax to compile i keep
getting errors like glue.cpp not found and i followed the instructions
to the letter on the wxmax page.

Thanks Bruce for listening mate

i will have a look at your sample in wxmidi but i dont think thats the
one because i feel it was before wxmidi was around in my eyes so to
speak

Lee Broadhurst
> > Lee B- Hide quoted text -

wadfm

unread,
Jul 4, 2008, 11:04:18 PM7/4/08
to wxMax
I think this is the routine

but is it yours ?

here is the source and this compiles with no wx midi or portmidi
etccccc and this works but it exits after 1 press

Lee



' Alpha MIDI In Test

Type MIDIINCAPS
Field wMid:Short
Field wPid:Short
Field vDriverVersion:Short'MMVERSION
Field szPname_0,szPname_1,szPname_2,szPname_3
Field szPname_4,szPname_5,szPname_6,szPname_7
Field dwSupport:Int
EndType

Type MidiHdr
Field lpData:Byte Ptr ' tbank ptr 'LPSTR ptr
Field dwBufferLength:Int
Field dwBytesRecorded:Int
Field dwUser:Int
Field dwFlags:Int
Field lpNext:Int 'midihdr_tag ptr
Field reserved:Int
Field dwOffset:Int
Field dwReserved1:Int
Field dwReserved2:Int
Field dwReserved3:Int
Field dwReserved4:Int
Field dwReserved5:Int
Field dwReserved6:Int
Field dwReserved7:Int
Field dwReserved8:Int
EndType


Extern "Win32"

Function midiInOpen(lphMidiIn:Int Var, uDeviceID:Int,
dwCallback:Int , dwInstance:Int, dwFlags:Int)
Function midiInPrepareHeader(hMidiIn:Int, lpMidiInHdr:Byte Ptr ,
uSize:Int)
Function midiInAddBuffer(hMidiIn:Int, lpMidiInHdr:Byte Ptr,
uSize:Int)
Function midiInClose(hMidiIn:Int)
Function midiInMessage(hMidiIn:Int, msg:Int, dw1:Int, dw2:Int)
Function midiInGetNumDevs()
Function midiInStart(hMidiIn:Int)
Function midiInStop(hMidiIn:Int)

End Extern

Const CF = $30000

Global MM_MIM_OPEN =$3C1
Global MM_MIM_CLOSE =$3C2
Global MM_MIM_DATA =$3C3
Global MM_MIM_LONGDATA =$3C4
Global MM_MIM_ERROR =$3C5
Global MM_MIM_LONGERROR =$3C6

Global ControllerType$[128]

ControllerType$(0) = "Bank Select (coarse)"
ControllerType$(1) = "Modulation Wheel (coarse)"
ControllerType$(2) = "Breath controller (coarse)"
ControllerType$(4) = "Foot Pedal (coarse)"
ControllerType$(5) = "Portamento Time (coarse)"
ControllerType$(6) = "Data Entry (coarse)"
ControllerType$(7) = "Volume (coarse)"
ControllerType$(8) = "Balance (coarse)"
ControllerType$(10) = "Pan position (coarse)"
ControllerType$(11) = "Expression (coarse)"
ControllerType$(12) = "Effect Control 1 (coarse)"
ControllerType$(13) = "Effect Control 2 (coarse)"
ControllerType$(16) = "General Purpose Slider 1"
ControllerType$(17) = "General Purpose Slider 2"
ControllerType$(18) = "General Purpose Slider 3"
ControllerType$(19) = "General Purpose Slider 4"
ControllerType$(32) = "Bank Select (fine)"
ControllerType$(33) = "Modulation Wheel (fine)"
ControllerType$(34) = "Breath controller (fine)"
ControllerType$(36) = "Foot Pedal (fine)"
ControllerType$(37) = "Portamento Time (fine)"
ControllerType$(38) = "Data Entry (fine)"
ControllerType$(39) = "Volume (fine)"
ControllerType$(40) = "Balance (fine)"
ControllerType$(42) = "Pan position (fine)"
ControllerType$(43 ) = "Expression (fine)"
ControllerType$(44 ) = "Effect Control 1 (fine)"
ControllerType$(45 ) = "Effect Control 2 (fine)"
ControllerType$(64 ) = "Hold Pedal (on/off)"
ControllerType$(65 ) = "Portamento (on/off)"
ControllerType$(66 ) = "Sustenuto Pedal (on/off)"
ControllerType$(67 ) = "Soft Pedal (on/off)"
ControllerType$(68 ) = "Legato Pedal (on/off)"
ControllerType$(69 ) = "Hold 2 Pedal (on/off)"
ControllerType$(70 ) = "Sound Variation"
ControllerType$(71 ) = "Sound Timbre"
ControllerType$(72 ) = "Sound Release Time"
ControllerType$(73 ) = "Sound Attack Time"
ControllerType$(74 ) = "Sound Brightness"
ControllerType$(75 ) = "Sound Control 6"
ControllerType$(76 ) = "Sound Control 7"
ControllerType$(77 ) = "Sound Control 8"
ControllerType$(78 ) = "Sound Control 9"
ControllerType$(79 ) = "Sound Control 10"
ControllerType$(80 ) = "General Purpose Button 1 (on/off)"
ControllerType$(81 ) = "General Purpose Button 2 (on/off)"
ControllerType$(82 ) = "General Purpose Button 3 (on/off)"
ControllerType$(83 ) = "General Purpose Button 4 (on/off)"
ControllerType$(91 ) = "Effects Level"
ControllerType$(92 ) = "Tremulo Level"
ControllerType$(93 ) = "Chorus Level"
ControllerType$(94 ) = "Celeste Level"
ControllerType$(95 ) = "Phaser Level"
ControllerType$(96 ) = "Data Button increment"
ControllerType$(97 ) = "Data Button decrement"
ControllerType$(98 ) = "Non-registered Parameter (fine)"
ControllerType$(99 ) = "Non-registered Parameter (coarse)"
ControllerType$(100) = "Registered Parameter (fine)"
ControllerType$(101) = "Registered Parameter (coarse)"
ControllerType$(120) = "All Sound Off"
ControllerType$(121) = "All Controllers Off"
ControllerType$(122) = "Local Keyboard (on/off)"
ControllerType$(123) = "All Notes Off"
ControllerType$(124) = "Omni Mode Off"
ControllerType$(125) = "Omni Mode On"
ControllerType$(126) = "Mono Operation"
ControllerType(127) = "Poly Operation"

Global StatusType$[16]
StatusType(8) = "(Note Off)"
StatusType(9) = "(Note On)"
StatusType(10) = "(AfterTouch / key pressure)"
StatusType(11) = "(Control Change)"
StatusType(12) = "(Program (Patch) change)"
StatusType(13) = "(Channel Pressure)"
StatusType(14) = "(Pitch Wheel)"
Global LinePos

Function MidiCallBackBM:Int(hmIN:Int, wMsg:Int, dwInstance:Int,
dwParam1:Int, dwParam2:Int)"Win32"

If hmIN > 0 Then
seperator$ = ","
time=dwParam2/1000
hours = Int(time/360)
time =time-(hours*360)
mins = Int(time/60)
secs =time-(hours*60)
partsec = dwParam2 - (( (hours*360)+(mins*60)+secs) *1000)
MidiTimeStamp$ = (hours) +":"+(mins) +":"+(secs) +"."+Right("0"+
(partsec),3)
MidiNote$ = ""
MidiVel$ = ""
MidiChannel$ = ""

Select wMsg
Case MM_MIM_OPEN
Midifunct$ = "Open Midi"

Case MM_MIM_CLOSE
Midifunct$ = "Close Midi"
Case MM_MIM_DATA
' MessageRequester("","MIDI data",0)
Midifunct$ = Hex$((dwParam1 & $000000F0) Shr 4)
MidiStatus$ = StatusType$((dwParam1 & $000000F0) Shr 4 )
MidiChannel$ = Hex$(dwParam1 & $0000000F)
MidiNote$ =Hex$( (dwParam1 Shr 8) & $000000FF)
If Midifunct$ ="B"
ct$ = ControllerType((dwParam1 Shr 8) & $000000FF)
If ct > ""
MidiController$ = " ("+ct$+")"
EndIf
EndIf
MidiVel$ = Hex$((dwParam1 Shr 16) & $000000FF)

Case MM_MIM_ERROR
Midifunct$ = "Midi Error"
Case MM_MIM_LONGERROR
Midifunct$ = "Long Midi Error"
End Select
output$=MidiTimeStamp$ + " "+Midifunct$+" "+MidiStatus$+ "
"+MidiChannel$+ " "+MidiNote$+MidiController$+ " "+MidiVel$
DebugLog output$

LinePos:+1
If LinePos > 30 Then
LinePos = 0
Cls
EndIf
DrawText(output$,20,LinePos*18)
Flip
EndIf
EndFunction

Global MidiIn:Int ,Callback :Int , MidiDevice
Global MidiInHandle:Int '

' MidiInHandle = Varptr MidiIn
Global midiHeader:MidiHdr = New MidiHdr
'Global MidiINhandle

Global BufferSize
BufferSize = 4096 ' 1024
'global SysXBuffer:byte(BufferSize)
SysXBuffer:TBank = CreateBank(BufferSize)

CallBack = Int(Byte Ptr(MidiCallBackBM))

DebugLog " Callback = "+Int(Callback)

Print "Select Input Device: 1 - " + midiInGetNumDevs() ' + " Byte
Ptr(MyCallBack) = "+int(Byte Ptr(MyCallBack))

MidiDevice = Int(Input( ">"))





ok = MidiInOpen(MidiInHandle,MidiDevice-1,CallBack,2778,CF)

DrawText ok + " MidiInHandle = " + MidiInHandle,0,0
If ok=0 Then
midiHeader.lpData = BankBuf(SysXBuffer)

' Store its size in the MIDIHDR
midiHeader.dwBufferLength = BufferSize

' Flags must be set to 0
midiHeader.dwFlags = 0

' Prepare the buffer and MIDIHDR
err = midiInPrepareHeader(MidiInHandle,Varptr(midiHeader.lpData),
BufferSize)

If (err=0) Then
' ; Queue MIDI input buffer
err = midiInAddBuffer(MidiInHandle,Varptr(midiHeader.lpData),
BufferSize)
' ; debug( midiHeader\lpData)
If (err=0)
' ; Start recording Midi
err = midiInStart(MidiInHandle)
DrawText "Midi in " + err + " Opened",0,10
Else
DrawText "Midi buffer " + err + " NOT Opened",0,10
EndIf
Else
DrawText "Midi PrepareHeader " + err + " Failed" + "
varptr(midiHeader) "+Int(Varptr(midiHeader)),0,10
EndIf

While Not KeyDown(KEY_ESCAPE)
Wend

midiInStop(MIDI)
MidiInClose(MidiInHandle)
DrawText"Midi in " + MIDI + " Closed",0,20
EndIf
End
Reply all
Reply to author
Forward
0 new messages