$Header: /MidiComp/MidiOut.pas 2 10/06/97 7:33 Davec $ } { Written by David Churcher ,
released to the public domain. } { Thanks very much to Fred Kohler for the Technology code. TMidiOutput - -------------------------------------------------------------------
Register - -------------------------------------------------------------------
midioutputState
OutPortTech
TechNameMap
TechName
procedure Register;
-------------------------------------------------------------------
midioutputState = (mosOpen, mosClosed);
MIDI Output component.
Properties:
DeviceID: Windows numeric device ID for the MIDI output device.
Between 0 and (midioutGetNumDevs-1), or MIDI_MAPPER (-1).
Special value MIDI_MAPPER specifies output to the Windows MIDI mapper
Read-only while device is open, exception if changed while open
MIDIHandle: The output handle to the MIDI device.
0 when device is not open
Read-only, runtime-only
ProductName: Name of the output device product that corresponds to the
DeviceID property (e.g. 'MPU 401 out').
You can write to this while the device is closed to select a particular
output device by name (the DeviceID property will change to match).
Exception if this property is changed while the device is open.
Numdevs: Number of MIDI output devices installed on the system. This
is the value returned by midiOutGetNumDevs. It's included for
completeness.
Technology: Type of technology used by the MIDI device. You can set this
property to one of the values listed for OutportTech (below) and the component
will find an appropriate MIDI device. For example:
MidiOutput.Technology := opt_FMSynth;
will set MidiInput.DeviceID to the MIDI device ID of the FM synth, if one
is installed. If no such device is available an exception is raised,
see MidiOutput.SetTechnology.
See the MIDIOUTCAPS entry in MMSYSTEM.HLP for descriptions of the
following properties:
DriverVersion
Voices
Notes
ChannelMask
Support
Error: The error code for the last MMSYSTEM error. See the MMSYSERR_
entries in MMSYSTEM.INT for possible values.
Methods:
Open: Open MIDI device specified by DeviceID property for output
Close: Close device
PutMidiEvent(Event:TMyMidiEvent): Output a note or sysex message to the
device. This method takes a TMyMidiEvent object and transmits it.
Notes:
1. If the object contains a sysex event the OnMidiOutput event will
be triggered when the sysex transmission is complete.
2. You can queue up multiple blocks of system exclusive data for
transmission by chucking them at this method; they will be
transmitted as quickly as the device can manage.
3. This method will not free the TMyMidiEvent object, the caller
must do that. Any sysex data in the TMyMidiEvent is copied before
transmission so you can free the TMyMidiEvent immediately after
calling PutMidiEvent, even if output has not yet finished.
PutShort(MidiMessage: Byte; Data1: Byte; Data2: Byte): Output a short
MIDI message. Handy when you can't be bothered to build a TMyMidiEvent.
If the message you're sending doesn't use Data1 or Data2, set them to 0.
PutLong(TheSysex: Pointer; msgLength: Word): Output sysex data.
SysexPointer: Pointer to sysex data to send
msgLength: Length of sysex data.
This is handy when you don't have a TMyMidiEvent.
SetVolume(Left: Word, Right: Word): Set the volume of the
left and right channels on the output device (only on internal devices?).
0xFFFF is maximum volume. If the device doesn't support separate
left/right volume control, the value of the Left parameter will be used.
Check the Support property to see whether the device supports volume
control. See also other notes on volume control under midiOutSetVolume()
in MMSYSTEM.HLP.
Events:
OnMidiOutput: Procedure called when output of a system exclusive block
is completed.
Notes:
I haven't implemented any methods for midiOutCachePatches and
midiOutCacheDrumpatches, mainly 'cause I don't have any way of testing
them. Does anyone really use these?
OutPortTech = (
opt_None, { none }
opt_MidiPort, { output port }
opt_Synth, { generic internal synth }
opt_SQSynth, { square wave internal synth }
opt_FMSynth, { FM internal synth }
opt_Mapper);
These are the equivalent of constants prefixed with mod_
as defined in MMSystem. See SetTechnology
TechNameMap = array[OutPortTech] of string[18];
MIDI mapper
TechName = (
'None','MIDI Port','Generic Synth','Square Wave Synth',
'FM Synth','MIDI Mapper')