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
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.
nice :t
maybe i can learn from it :P
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)
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.
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
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().
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
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 (http://home.roadrunner.com/~jgglatt/tech/lowmidi.htm)
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.
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
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?
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
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
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.
i think MPU-401 is really just a driver that provides support for legacy sound
i seem to recall an MPU-401 chip being used on SoundBlaster cards in days of old
likely that it uses the same hardware device
i am wondering if the device you select by this method must be the one selected in the control panel
meaning that - whatever device (i.e. driver) the user selects is the only one that the mixer sees
it would make sense because it would mean the MPU-401 driver
that everyone seems to have installed actually works :P
Wasn't MPU-401 a port to connect an external midi device to? From what I remember, if you had a keyboard (musical, not typing) you would plug it into the
game port on a Soundblaster and the computer could send MIDI messages to it and control it.
Nowadays your new musical instrument will have a USB port, that's why the MPU-401 is obsolete. Even your old one will get by with a MIDI-USB adapter.
QuoteWasn't MPU-401 a port to connect an external midi device to?
i knew it was old stuff :P
NO C FOR ME:
Very impressive initial attempt,...
A number of MIDI capable devices (especially those provided in commercial audio editing programs) are implemented as Direct Show plug-ins,...in older versions of DirectX. These are registered on your system as COM DLLs,...which means they can be enumerated by DirectX.
I know,...this concept sounds wrong,...I am referring not to audio hardware,...but, to software audio drivers (catagorized as DirectShow filters).
This accounts for the difference in enumerated MIDI devices returned from midiOutGetNumDevs,...and the actual number of MIDI capable devices that exist on your system. The vast majority of Direct Show filters are not audio devices,...and, it's a complete pain in the ass to enumerate them all,...and, then check their individual properties to locate the MIDI capable components.
In all honesty,...it's confusing as hell (especially if you are not familiar with COM activation).
Here are a number of MSDN references:
DirectShow Filters (http://msdn.microsoft.com/en-us/library/windows/desktop/dd375464(v=vs.85).aspx)
The Filter Graph and Its Components (http://msdn.microsoft.com/en-us/library/windows/desktop/dd407188(v=vs.85).aspx)
Alphabetical List of DirectShow Interfaces (http://msdn.microsoft.com/en-us/library/windows/desktop/dd373420(v=vs.85).aspx)
Quote from: dedndave on July 20, 2012, 06:14:34 AM
i am wondering if the device you select by this method must be the one selected in the control panel
meaning that - whatever device (i.e. driver) the user selects is the only one that the mixer sees
Don't think so. On my computah (Win2K Pro), you can select the "preferred" device for MIDI playback (i.e., a MIDI-out device) in Control Panel--> Sounds and Multimedia--> Audio tab. However, this has no effect on which devices you can select with my program (and presumably any other software that uses a similar selection method).
However, there is a checkbox titled "Use only preferred devices" (unchecked on my system), which may be able to limit the devices seen by external software to only the selected device; don't know.