using System;
using System.Runtime.InteropServices;
namespace NAudio.Midi
{
///
/// class representing the capabilities of a MIDI out device
/// MIDIOUTCAPS: http://msdn.microsoft.com/en-us/library/dd798467%28VS.85%29.aspx
///
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MidiOutCapabilities
{
Int16 manufacturerId;
Int16 productId;
int driverVersion;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxProductNameLength)]
string productName;
Int16 wTechnology;
Int16 wVoices;
Int16 wNotes;
UInt16 wChannelMask;
MidiOutCapabilityFlags dwSupport;
const int MaxProductNameLength = 32; // max product name length (including NULL)
[Flags]
enum MidiOutCapabilityFlags
{
///
/// MIDICAPS_VOLUME
///
Volume = 1,
///
/// separate left-right volume control
/// MIDICAPS_LRVOLUME
///
LeftRightVolume = 2,
///
/// MIDICAPS_CACHE
///
PatchCaching = 4,
///
/// MIDICAPS_STREAM
/// driver supports midiStreamOut directly
///
Stream = 8,
}
///
/// Gets the manufacturer of this device
///
public Manufacturers Manufacturer
{
get
{
return (Manufacturers)manufacturerId;
}
}
///
/// Gets the product identifier (manufacturer specific)
///
public short ProductId
{
get
{
return productId;
}
}
///
/// Gets the product name
///
public String ProductName
{
get
{
return productName;
}
}
///
/// Returns the number of supported voices
///
public int Voices
{
get
{
return wVoices;
}
}
///
/// Gets the polyphony of the device
///
public int Notes
{
get
{
return wNotes;
}
}
///
/// Returns true if the device supports all channels
///
public bool SupportsAllChannels
{
get
{
return wChannelMask == 0xFFFF;
}
}
///
/// Queries whether a particular channel is supported
///
/// Channel number to test
/// True if the channel is supported
public bool SupportsChannel(int channel)
{
return (wChannelMask & (1 << (channel - 1))) > 0;
}
///
/// Returns true if the device supports patch caching
///
public bool SupportsPatchCaching
{
get
{
return (dwSupport & MidiOutCapabilityFlags.PatchCaching) != 0;
}
}
///
/// Returns true if the device supports separate left and right volume
///
public bool SupportsSeparateLeftAndRightVolume
{
get
{
return (dwSupport & MidiOutCapabilityFlags.LeftRightVolume) != 0;
}
}
///
/// Returns true if the device supports MIDI stream out
///
public bool SupportsMidiStreamOut
{
get
{
return (dwSupport & MidiOutCapabilityFlags.Stream) != 0;
}
}
///
/// Returns true if the device supports volume control
///
public bool SupportsVolumeControl
{
get
{
return (dwSupport & MidiOutCapabilityFlags.Volume) != 0;
}
}
///
/// Returns the type of technology used by this MIDI out device
///
public MidiOutTechnology Technology
{
get
{
return (MidiOutTechnology)wTechnology;
}
}
}
}