13 #pragma interface "wxMidi.cpp" 16 #ifndef __WXMIDI_H__ //to avoid nested includes 20 #include "wx/wxprec.h" 45 #define wxMIDI_VERSION _T("2.0") 46 #define wxMIDI_MAJOR 2 47 #define wxMIDI_MINOR 0 50 #define wxMidiDeviceID PmDeviceID 51 #define wxMidiTimestamp PmTimestamp 52 #define wxMidiPmMessage PmMessage 53 #define wxMidiPmEvent PmEvent 168 #define wxMIDI_CHANNEL(channel) (1<<(channel)) 233 DECLARE_EVENT_TYPE(wxEVT_MIDI_INPUT, -1)
246 class wxControlWithItems;
274 virtual void SetTimestamp(wxMidiTimestamp timestamp) = 0;
276 virtual wxMidiTimestamp GetTimestamp() = 0;
344 m_buffer.message = (((data2) << 16) & 0xFF0000) |
345 (((data1) << 8) & 0xFF00) |
347 m_buffer.timestamp = 0;
352 void SetTimestamp(wxMidiTimestamp timestamp) { m_buffer.timestamp = timestamp; }
353 wxMidiTimestamp GetTimestamp() {
return m_buffer.timestamp; }
356 wxByte
GetStatus() {
return ((m_buffer.message) & 0xFF); }
360 wxByte
GetData1() {
return (((m_buffer.message) >> 8) & 0xFF); }
364 wxByte
GetData2() {
return (((m_buffer.message) >> 16) & 0xFF); }
367 PmEvent* GetBuffer() {
return &m_buffer; }
402 void SetTimestamp(wxMidiTimestamp timestamp) { m_timestamp = timestamp; }
403 wxMidiTimestamp GetTimestamp() {
return m_timestamp; }
451 void SetBuffer(wxByte* pBuffer) { m_pMessage = pBuffer; }
465 wxMidiTimestamp m_timestamp;
520 const wxString DeviceName();
525 const wxString InterfaceUsed();
555 const PmDeviceInfo* m_pInfo;
556 PortMidiStream* m_stream;
597 wxMidiError Open(
long latency,
void* pDriverInfo=NULL);
619 wxMidiError Write(wxByte* msg, wxMidiTimestamp when=0);
625 return (
wxMidiError)Pm_Write(m_stream, buffer, length);
665 wxMidiError NoteOn(
int channel,
int note,
int velocity);
676 wxMidiError NoteOff(
int channel,
int note,
int velocity);
688 wxMidiError ProgramChange(
int channel,
int instrument);
757 wxMidiError Open(
void *pDriverInfo = NULL,
int buffersize=4096);
774 wxMidiError Read(wxMidiPmEvent *buffer,
long* length);
795 {
return (
wxMidiError)Pm_SetFilter(m_stream, filters); }
802 {
return (
wxMidiError)Pm_SetChannelMask(m_stream, mask); }
827 wxMidiError StartListening(wxWindow* pWindow,
unsigned long nPollingRate=50);
835 bool MoveDataToSysExBuffer(PmMessage message);
836 bool too_much_time_without_receiving_bytes();
837 bool too_much_reads_without_receiving_bytes();
838 bool should_report_timeout();
840 inline void reset_timeout_counters() { m_timeCounter=time_t(0); m_numNullReads=0; }
841 inline bool use_time_algorithm() {
return m_fUseTimeAlgorithm; }
842 inline void switch_to_alternate_algorithm() { m_fUseTimeAlgorithm =
false; }
848 bool m_fUseTimeAlgorithm;
849 time_t m_timeCounter;
850 double m_timeoutSeconds;
854 long m_SizeOfSysexBuffer;
855 wxByte* m_SysexBuffer;
856 wxByte* m_CurSysexDataPtr;
857 bool m_fReadingSysex;
858 wxMidiTimestamp m_timestamp;
859 bool m_fEventPending;
969 void PopulateWithInstruments(wxControlWithItems* pCtrol,
int nSection,
int nInstr=0,
970 bool fAddNumber=
false);
1014 void PopulateWithPercusionInstr(wxControlWithItems* pCtrol,
int iSel=0);
1016 #define PopulateWithPercussionInstr PopulateWithPercusionInstr 1033 int PopulateWithSections(wxControlWithItems* pCtrol,
int nSelInstr=-1);
1057 void PopulateWithAllInstruments(wxControlWithItems* pCtrol,
int nInstr=0);
1066 int GetNumSections();
1079 int GetNumInstrumentsInSection(
int nSect);
1118 int GetInstrFromSection(
int nSect,
int i);
1131 wxString GetInstrumentName(
int nInstr);
1145 wxString GetSectionName(
int nSect);
1156 int m_nSectInstr[NUM_SECTIONS][NUM_INSTRS];
1157 int m_nNumInstrInSection[NUM_SECTIONS];
1158 wxString m_sSectName[NUM_SECTIONS];
1183 wxMidiTimestamp GetTime() {
return Pt_Time(); }
1187 const wxString GetErrorText(
wxMidiError errnum );
1191 wxString GetHostErrorText();
1266 wxWindow* m_pWindow;
1267 unsigned long m_nMilliseconds;
1272 #endif // __WXMIDI_H__ Filter reset messages (0xFF).
Definition: wxMidi.h:191
virtual wxByte GetStatus()=0
Returns the status byte of the message.
Filter all real-time messages.
Definition: wxMidi.h:195
wxMidiError Poll()
Check if there is a received MIDI message waiting to be Read().
Definition: wxMidi.h:808
A database for Midi GM (General MIDI Standard) instruments.
Definition: wxMidi.h:868
PortMidi reports a `Bad pointer error'.
Definition: wxMidi.h:95
Filter Control Change messages (0xB0-0xBF).
Definition: wxMidi.h:209
void SetTimestamp(wxMidiTimestamp timestamp)
Set the message timestamp value.
Definition: wxMidi.h:352
Filter both channel and poly aftertouch.
Definition: wxMidi.h:205
Filter Program change messages (0xC0-0xCF).
Definition: wxMidi.h:207
wxMidiMessage()
Constructor.
Definition: wxMidi.h:262
wxMidiError Error()
Returns the error code for the wxMidiSysExMessage constructor.
Definition: wxMidi.h:431
wxByte GetData1()
Returns the first data byte of the message or 0x00 if the type of message only has the status byte...
Definition: wxMidi.h:360
Represents a MIDI stream on which MIDI data traffic can be sent.
Definition: wxMidi.h:562
int HasHostError()
Check if the wxMidiDevice has a pending host error to be reported.
Definition: wxMidi.h:548
virtual ~wxMidiMessage()
Destructor.
Definition: wxMidi.h:264
Short message (wxMidiShortMessage)
Definition: wxMidi.h:239
wxMidiError Close()
Closes a MIDI stream, flushing any pending messages.
Definition: wxMidi.h:513
Filter undefined 0xFD messages.
Definition: wxMidi.h:187
wxMidiError SetFilter(long filters)
Sets filters on an open wxMidiInDevice to drop selected input types.
Definition: wxMidi.h:794
#define wxMidiDeviceID
Rename some data types inherited from portmidi.
Definition: wxMidi.h:50
Filter per-note aftertouch messages (Ensoniq holds a patent on generating these messages on keyboards...
Definition: wxMidi.h:202
virtual void SetTimestamp(wxMidiTimestamp timestamp)=0
Set the message timestamp value.
~wxMidiOutDevice()
Destructor.
Definition: wxMidi.h:573
Filter play messages (start 0xFA, stop 0xFC, continue 0xFB).
Definition: wxMidi.h:183
SysEx message (wxMidiSysExMessage)
Definition: wxMidi.h:240
Portmidi reported an 'Internal Error'.
Definition: wxMidi.h:99
wxMidiFilter
Filter codes, renamed from portmidi.
Definition: wxMidi.h:172
long Length()
Returns the length (number of bytes) of the message returned by GetMessage().
Definition: wxMidi.h:437
Invalid device ID.
Definition: wxMidi.h:79
void SetBuffer(wxByte *pBuffer)
This method is mainly intended for internal use of wxMidi.
Definition: wxMidi.h:451
Filter Song Select messages (0xF3).
Definition: wxMidi.h:217
The wxByte string received as parameter to create a wxMidiSysExMessage object does not start with 0xF...
Definition: wxMidi.h:126
Filter Song Position messages (0xF2).
Definition: wxMidi.h:215
Filter Tuning request messages (0xF6).
Definition: wxMidi.h:219
Represents a system-exclusive MIDI message.
Definition: wxMidi.h:394
wxByte GetStatus()
Returns the status byte of the message.
Definition: wxMidi.h:406
PortMidi reported a 'Buffer overflow'.
Definition: wxMidi.h:90
int CountDevices()
Returns the number of MIDI devices present in the system.
Definition: wxMidi.h:1237
Filter real-time clock messages (0xF8 only, does not filter clock start, etc.).
Definition: wxMidi.h:181
Filetr Pitch Bender messages (0xE0-0xEF).
Definition: wxMidi.h:211
wxByte * GetMessage()
Returns a wxByte string containing the raw MIDI message.
Definition: wxMidi.h:416
wxMidiMsgType GetType()
Returns either wxMIDI_SHORT_MSG, or wxMIDI_SYSEX_MSG, identifying the type of the message object...
Definition: wxMidi.h:280
You called method wxMidiInDevice::Read but there is no message waiting to be delivered.
Definition: wxMidi.h:134
Filter system exclusive messages (0xF0).
Definition: wxMidi.h:179
Undefined (invalid wxMidiMessage object)
Definition: wxMidi.h:238
Insufficient memory.
Definition: wxMidi.h:80
wxMidiOutDevice(wxMidiDeviceID nDevice)
Constructor.
Definition: wxMidi.h:570
wxByte GetData2()
Returns the second data byte of the message or 0x00 if the type of message only has one data byte...
Definition: wxMidi.h:364
An error ocurred during a call to wxMidiInDevice::StartListening.
Definition: wxMidi.h:114
Abstract class representing a MIDI device.
Definition: wxMidi.h:495
Represents a MIDI stream on which MIDI data traffic can be read.
Definition: wxMidi.h:714
Portmidi reported a host error.
Definition: wxMidi.h:71
Filter undefined real-time messages = (wxMIDI_FILT_F9 | wxMIDI_FILT_FD).
Definition: wxMidi.h:189
Filter active sensing messages (0xFE).
Definition: wxMidi.h:177
No filter. All MIDI messages will be delivered to user application.
Definition: wxMidi.h:175
Helper class for internal use.
Definition: wxMidi.h:1252
wxMidiError Abort()
Terminates any outgoing message immediately; this call may result in a partial transmission of a MIDI...
Definition: wxMidi.h:704
Portmidi informs that 'buffer is already as large as it can be'.
Definition: wxMidi.h:103
wxMidiShortMessage(wxByte status, wxByte data1, wxByte data2)
Constructor.
Definition: wxMidi.h:340
An error ocurred during a call to wxMidiInDevice::StartListening.
Definition: wxMidi.h:120
Class wxMidiSystem is the entry point to the wxMidi library.
Definition: wxMidi.h:1170
wxByte GetStatus()
Returns the status byte of the message.
Definition: wxMidi.h:356
void SetTimestamp(wxMidiTimestamp timestamp)
Set the message timestamp value.
Definition: wxMidi.h:402
PortMidi reported an 'Invalid MIDI message Data' such as illegal MIDI data or a missing EOX...
Definition: wxMidi.h:97
Abstract class representing a MIDI message.
Definition: wxMidi.h:258
void SetLength(long lenght)
This method is mainly intended for internal use of wxMidi.
Definition: wxMidi.h:460
wxMidiError
Error codes from portmidi and additional errors from wxMidi.
Definition: wxMidi.h:58
Informative error.
Definition: wxMidi.h:109
Filter undefined 0xF9 messages (some equipment uses this as a 10ms 'tick').
Definition: wxMidi.h:185
Filter channel aftertouch (most MIDI controllers use this) (0xD0-0xDF).
Definition: wxMidi.h:199
wxMidiMsgType
Identifies the MIDI message type.
Definition: wxMidi.h:236
wxMidiShortMessage represents a MIDI short message.
Definition: wxMidi.h:335
wxMidiError SetChannelMask(long mask)
SetChannelMask() filters incoming messages based on channel.
Definition: wxMidi.h:801
Filter note-on and note-off messages (0x90-0x9F and 0x80-0x8F).
Definition: wxMidi.h:197
No error.
Definition: wxMidi.h:66
PortMidi reports a 'Buffer too small' error.
Definition: wxMidi.h:85
Filter MIDI Time Code messages (0xF1).
Definition: wxMidi.h:213
wxMidiError Write(PmEvent *buffer, long length)
This method is just a wrapper for the portmidi native Write function.
Definition: wxMidi.h:624
Filter all System Common messages (MTC, song position, song select, tune request).
Definition: wxMidi.h:223