News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MIDI testbed program

Started by NoCforMe, July 16, 2012, 07:44:49 AM

Previous topic - Next topic

NoCforMe

In our last episode, I asked questions here about implementing simple MIDI capabilities, and also about handling simple controls.

All of this has been resolved. I present you the results of my research, a small MIDI testbed program which may be interesting to some of you who are working on related issues. Source and executable attached below.

It's a simple testbed that allows you to select a MIDI device installed on your computer and play a simple tune through it, with controls to set the volume, tempo, "velocity" and the MIDI "patch" (the voice used to render the sound, from a list of the 128 available "patches"). It has "go" and "stop" buttons. (You might recognize the tune, which is a couple variations on a well-known 4-note American TV series theme.)

I'm particularly fond of how easily I was able to implement my homemade "dialog", which is nothing more than a collection of controls (trackbars, comboboxes, etc.) simply placed within the client area of my program's main window. Very simple to do, all driven by a structure, so little or no code need be added for new controls.

Anyhow, enjoy and let us know what you think. (Couldn't stop the comments if I wanted to!)

Note: Don't download this attachment (left some things out). Use the one in the following reply.

-  Little C 4 me

NoCforMe

Whoops--left a couple of needed files (BMPs for buttons) out of the zip archive, plus had some unnecessary crap in the .rc file (a no-longer-used dialog). New zip attached below.

dedndave

nice   :t
maybe i can learn from it   :P

NoCforMe

Thanks, Dave.

One slightly interesting thing to do with it is to change the "voice" while the tune is playing (if you have the combobox open, you can use the cursor-up and -down keys to cruise through the list) and see what the various MIDI "patches" sound like.  (Some of them are truly awful.)  Also, try varying "Velocity". On my system, all it seems to do is raise or lower the volume, which is disappointing as I had hoped it would change the attack/decay setting.

I'm curious: what MIDI devices do you see on your computah?  I have 3:
  • MPU-401 (which doesn't work on my system,  produces no sound)
  • Microsoft GS Wavetable SW Synth
  • Aureal Wavetable
(the last one  may be from a Sound Blaster installation, not sure)

FORTRANS

Quote from: NoCforMe on July 18, 2012, 02:49:03 PM
One slightly interesting thing to do with it is to change the "voice" while the tune is playing

Hi,

   Yes, that works nicely.  But it started up with no MIDI
selected here, so no sound when started.

Quote(if you have the combobox open, you can use the cursor-up and -down keys
to cruise through the list) and see what the various MIDI "patches" sound like.

   Will have to try that.  Didn't occur to me.

Quote
I'm curious: what MIDI devices do you see on your computah?

   Your program shows "SoundFusion(tm) External Midi",
which does not play and "Microsoft Wavetable SW Sy"
which does work.  Control Panel seems to indicate a Crystal
SoundFusion(tm) (not external per say),  and a CD-ROM
player, and software.

Cheers,

Steve N.

dedndave

oops - i spoke too soon
in my first reply, i opened the asm file and browsed the code
i just assumed the thing would work - lol
the code looked great   :biggrin:

when i run the program, i only see one midi device
Microsoft GW Wavetable SW Synth
this matches the list for MIDI devices in Control Panel - Sounds

but - i get no sound   :(
i mashed all the buttons - checked the mute - etc - no luck

i am running XP MCE2005 SP3
i am able to play midi files using wmp11 - no prob

later today, i may mod the program to spit out error messages to see if i can track it down

NoCforMe

Quote from: FORTRANS on July 18, 2012, 09:57:06 PM
Quote from: NoCforMe on July 18, 2012, 02:49:03 PM
One slightly interesting thing to do with it is to change the "voice" while the tune is playing

Hi,

   Yes, that works nicely.  But it started up with no MIDI
selected here, so no sound when started.

That's actually by design. I try to build good user interfaces. When the program starts, it  finds all available MIDI devices. However, I don't make any assumptions about which one the user wants to use. In my case, if I used the first device by default, it would be one that doesn't play at all on my system (the MPU-4010.

Quote
Your program shows "SoundFusion(tm) External Midi",
which does not play and "Microsoft Wavetable SW Sy"
which does work.  Control Panel seems to indicate a Crystal
SoundFusion(tm) (not external per say),  and a CD-ROM
player, and software.

Well, I only look for MIDI devices specifically (using midiOutGetNumDevs() and midiOutGetDevCaps().

dedndave

everything works great....
except 2 little things

i had to add:
include \masm32\include\winmm.inc
includelib \masm32\lib\winmm.lib

otherwise, i got these errors:
MIDItest2.asm(581) : error A2006: undefined symbol : midiOutGetDevCaps
MIDItest2.asm(753) : error A2006: undefined symbol : timeSetEvent
MIDItest2.asm(785) : error A2006: undefined symbol : midiOutClose
MIDItest2.asm(788) : error A2006: undefined symbol : midiOutOpen
MIDItest2.asm(807) : error A2006: undefined symbol : timeSetEvent
MIDItest2.asm(833) : error A2006: undefined symbol : timeKillEvent
MIDItest2.asm(878) : error A2006: undefined symbol : timeKillEvent
MIDItest2.asm(938) : error A2006: undefined symbol : timeSetEvent
MIDItest2.asm(1004) : error A2006: undefined symbol : midiOutShortMsg
MIDItest2.asm(567) : error A2006: undefined symbol : midiOutGetNumDevs


when the combobox returns from CB_GETCURSEL, it returns a zero-based index into the listbox
INVOKE SendMessage, DevCboxHandle, CB_GETCURSEL, 0, 0
CMP EAX, MIDIdevSelection ;Did it change?
; JE dodefault ;Nope, nothin' doin'.

so - if your first choice from the list is the first device listed, it does not get selected
seeing as i only have one MIDI device...   :P

dedndave

i might add....

this program really makes a great "how to MIDI" tutorial   :t

the only thing i might change would be...
the user selects default MIDI devices for input and output in the control panel (sounds or MM snap-in)
there must be a way to find out what the default output device is and
make it first in the combo and selected by default

http://home.roadrunner.com/~jgglatt/tech/lowmidi.htm

NoCforMe

So I take it you were able to get it to make sounds, correct? What was the problem?

Yes, it would be useful to be able to detect if there was a default MIDI-out device already selected  and use it. If you find a solution, though, it prolly won't work in my antique setup (Windows 2000).

==================================================

Ah, a little more research (i.e., reading the article you linked to) reveals that what a guy would probably want to do would be to use the MIDI Mapper device,  which apparently brings out whatever connections the user makes through Control Panel.

Also, Dave, yes, my bad: I modified my copy of masm32rt.inc to include those multimedia include files you mentioned (hey, it's my my computer and I can do what I like with it!). Shoulda realized that when I published the program.

dedndave

yah - modifying the Masm32rt.inc file isn't as good as it sounds
just for that reason - you are no longer compatible with other forum members
i made a copy of it and named it MyMasm32rt.inc - modify away   :t
but - i found a better way
i made a template file and added it to the right-click context   :P

QuoteSo I take it you were able to get it to make sounds, correct? What was the problem?
see reply number 7 - i added a semicolon to comment out the JZ
(the message returns a zero-based index)

i thought some of initializing MIDIdevSelection to -1 - but that may affect other parts of the program
i will let you come up with the appropriate changes

NoCforMe

Quote from: dedndave on July 19, 2012, 12:02:51 PM
i made a copy of it and named it MyMasm32rt.inc - modify away   :t

Heh--I called my modified copy "my_masm32rt.inc".

Great minds run in similar gutters?

dedndave

i am curious to see if some devices that others have tried will work if the program is updated   :P
if you try to select the first device in the list, as the first selection, it will fail
if you have more than one device, you can select one of the others first
then select the first one - then it may work

but - i see members saying they have devices that don't work - maybe they will

qWord

Quote from: dedndave on July 18, 2012, 10:56:48 PMwhen i run the program, i only see one midi device
Microsoft GW Wavetable SW Synth
[...]
but - i get no sound   :(
The same applies to Win7, x64
MREAL macros - when you need floating point arithmetic while assembling!

NoCforMe

Quote from: dedndave on July 20, 2012, 01:15:56 AM
i am curious to see if some devices that others have tried will work if the program is updated   :P
if you try to select the first device in the list, as the first selection, it will fail
if you have more than one device, you can select one of the others first
then select the first one - then it may work

but - i see members saying they have devices that don't work - maybe they will

Nope. Makes no difference in my case: the first device in my list (MPU-401) still doesn't play, even though it's getting selected successfully.

What you found was indeed a bug--but only if you there was just one MIDI device installed. If you have more than one, as I do, then it simply prevents you from re-selecting the same device. No real advantage to that check, so I took it out, but my MPU-401 still doesn't work.