mirror of
https://github.com/thestk/stk
synced 2026-02-02 23:56:16 +00:00
Version 4.0
This commit is contained in:
committed by
Stephen Sinclair
parent
3f126af4e5
commit
81475b04c5
146
include/RtMidi.h
146
include/RtMidi.h
@@ -1,66 +1,80 @@
|
||||
/******************************************/
|
||||
/*
|
||||
RtMidi.cpp
|
||||
Realtime MIDI I/O Object for STK,
|
||||
by Gary P. Scavone, 1998-2000.
|
||||
Based in part on code by Perry
|
||||
Cook (SGI), Paul Leonard (Linux),
|
||||
the RoseGarden team (Linux), and
|
||||
Bill Putnam (Win95/NT).
|
||||
|
||||
At the moment, this object only
|
||||
handles MIDI input, though MIDI
|
||||
output code can go here when someone
|
||||
decides they need it (and writes it).
|
||||
|
||||
This object opens a MIDI input device
|
||||
and parses MIDI messages into a MIDI
|
||||
buffer. Time stamp info is converted
|
||||
to deltaTime. MIDI data is stored as
|
||||
MY_FLOAT to conform with SKINI.
|
||||
|
||||
An optional argument to the constructor
|
||||
can be used to specify a device or card.
|
||||
When no argument is given, a default
|
||||
device is opened or a list of available
|
||||
devices is printed to allow selection
|
||||
by the user.
|
||||
*/
|
||||
/******************************************/
|
||||
|
||||
#if !defined(__RtMidi_h)
|
||||
#define __RtMidi_h
|
||||
|
||||
#include "Object.h"
|
||||
#include "StkError.h"
|
||||
|
||||
class RtMidi : public Object
|
||||
{
|
||||
protected:
|
||||
int messageType;
|
||||
int channel;
|
||||
float byteTwo;
|
||||
float byteThree;
|
||||
MY_FLOAT deltaTime;
|
||||
public:
|
||||
RtMidi(int device = -1);
|
||||
~RtMidi();
|
||||
void printMessage();
|
||||
int nextMessage();
|
||||
int getType();
|
||||
int getChannel();
|
||||
MY_FLOAT getByteTwo();
|
||||
MY_FLOAT getByteThree();
|
||||
MY_FLOAT getDeltaTime();
|
||||
};
|
||||
|
||||
#if defined(__OS_Win_)
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
static void CALLBACK midiInputCallback( HMIDIOUT hmin, UINT inputStatus,
|
||||
DWORD instancePtr, DWORD midiMessage, DWORD timestamp);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
/***************************************************/
|
||||
/*! \class RtMidi
|
||||
\brief STK realtime MIDI class.
|
||||
|
||||
At the moment, this object only handles MIDI
|
||||
input, though MIDI output code can go here
|
||||
when someone decides they need it (and writes
|
||||
it).
|
||||
|
||||
This object opens a MIDI input device and
|
||||
parses MIDI messages into a MIDI buffer. Time
|
||||
stamp info is converted to a delta-time
|
||||
value. MIDI data is stored as MY_FLOAT to
|
||||
conform with SKINI. System exclusive messages
|
||||
are currently ignored.
|
||||
|
||||
An optional argument to the constructor can be
|
||||
used to specify a device or card. When no
|
||||
argument is given, a default device is opened.
|
||||
If a device argument fails, a list of available
|
||||
devices is printed to allow selection by the user.
|
||||
|
||||
This code is based in part on work of Perry
|
||||
Cook (SGI), Paul Leonard (Linux), the
|
||||
RoseGarden team (Linux), and Bill Putnam
|
||||
(Windows).
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
/***************************************************/
|
||||
|
||||
#if !defined(__RTMIDI_H)
|
||||
#define __RTMIDI_H
|
||||
|
||||
#include "Stk.h"
|
||||
|
||||
class RtMidi : public Stk
|
||||
{
|
||||
public:
|
||||
//! Default constructor with optional device argument.
|
||||
RtMidi(int device = 0);
|
||||
|
||||
//! Class destructor.
|
||||
~RtMidi();
|
||||
|
||||
//! Print out the current message values.
|
||||
void printMessage(void) const;
|
||||
|
||||
//! Check for and parse a new MIDI message in the queue, returning its type.
|
||||
/*!
|
||||
If a new message is found, the return value is greater than zero.
|
||||
*/
|
||||
int nextMessage(void);
|
||||
|
||||
//! Return the current message type.
|
||||
int getType() const;
|
||||
|
||||
//! Return the current message channel value.
|
||||
int getChannel() const;
|
||||
|
||||
//! Return the current message byte two value.
|
||||
MY_FLOAT getByteTwo() const;
|
||||
|
||||
//! Return the current message byte three value.
|
||||
MY_FLOAT getByteThree() const;
|
||||
|
||||
//! Return the current message delta time value in seconds.
|
||||
MY_FLOAT getDeltaTime() const;
|
||||
|
||||
protected:
|
||||
int messageType;
|
||||
int channel;
|
||||
float byteTwo;
|
||||
float byteThree;
|
||||
MY_FLOAT deltaTime;
|
||||
int readIndex;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user