NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
|
Typedef, functions, enums and preprocessor labels globally defined. More...
Macros | |
#define | DRIVER_USES_MIDIMATRIX 0 |
This item only affects AllNotesOff() function. More... | |
Typedefs | |
typedef unsigned long | MIDIClockTime |
The type of a variable which can hold a time in MIDI ticks. More... | |
typedef unsigned long long | tMsecs |
The type of a variable which can hold the elapsed time in milliseconds. More... | |
typedef void() | MIDITick(tMsecs, void *) |
This is the typedef of the callback functions which are called at every timer tick. More... | |
Enumerations | |
enum | SMPTE_RATE { SMPTE_RATE_24 = 0 , SMPTE_RATE_25 , SMPTE_RATE_2997 , SMPTE_RATE_2997DF , SMPTE_RATE_30 , SMPTE_RATE_30DF } |
The smpte rates (determine the frames/sec rate) More... | |
enum | SAMPLE_RATE { SAMPLE_32000 = 0 , SAMPLE_44056 , SAMPLE_44100 , SAMPLE_47952 , SAMPLE_48000 , SAMPLE_48048 } |
The sample rates (determine the sample/sec rate) More... | |
enum | tPriority { PR_FIRST , PR_PRE_SEQ , PR_SEQ , PR_POST_SEQ , PR_LAST } |
enum | tInsMode { INSMODE_DEFAULT , INSMODE_INSERT , INSMODE_REPLACE , INSMODE_INSERT_OR_REPLACE , INSMODE_INSERT_OR_REPLACE_BUT_NOTE } |
Defines the default behavior of the methods MIDITrack::InsertEvent() and MIDITrack::InsertNote() when inserting events. More... | |
enum | { COMPMODE_EQUAL , COMPMODE_SAMEKIND , COMPMODE_TIME } |
Defines the behaviour of the method MIDITrack::FindEventNumber() when searching events. More... | |
MIDI Clock related constants | |
const MIDIClockTime | TIME_INFINITE = 0xffffffff |
A constant which represents an infinite time. More... | |
const unsigned int | DEFAULT_CLKS_PER_BEAT = 120 |
The default clocks per beat parameter when initializing a MIDIMultiTrack. More... | |
Default constants when initializing messages and classes | |
const int | MIDI_DEFAULT_TIMESIG_NUMERATOR = 4 |
Timesig numerator. More... | |
const int | MIDI_DEFAULT_TIMESIG_DENOMINATOR = 4 |
Timesig denominator. More... | |
const double | MIDI_DEFAULT_TEMPO = 120.0 |
Musical tempo. More... | |
const int | MIDI_DEFAULT_KEYSIG_KEY = 0 |
Keysig key (C) More... | |
const int | MIDI_DEFAULT_KEYSIG_MODE = 0 |
Keysig mode (major) More... | |
Helper functions for viewing messages content | |
void | SetChanFrom (unsigned char c=0) |
Sets the numbering of MIDI channels when messages are printed. More... | |
void | DumpMIDITimedMessage (MIDITimedMessage *const msg, std::ostream &ost=std::cout) |
Prints a readable string describing the contents of the given MIDIMessage (or MIDITimedMessage). More... | |
void | DumpMIDITrack (MIDITrack *const trk, std::ostream &ost=std::cout) |
Prints a list of all the MIDI messages in the given MIDItrack. More... | |
int | DumpMIDITrackAttr (MIDITrack *const trk, int num, std::ostream &ost=std::cout) |
Prints the main properties of the given MIDItrack. More... | |
int | DumpMIDITrackAttrVerbose (MIDITrack *const trk, int num, std::ostream &ost=std::cout) |
Prints all the properties of the given MIDItrack. More... | |
void | DumpAllTracks (MIDIMultiTrack *const mlt, std::ostream &ost=std::cout) |
Prints a list of all MIDI messages in the given MIDIMultiTrack, a track at once. More... | |
void | DumpMIDIMultiTrack (MIDIMultiTrack *const mlt, std::ostream &ost=std::cout) |
Prints a list of all MIDI messages in the given MIDIMultiTrack in temporal order. More... | |
Other helper functions | |
void | CheckMIDIMatrix (const MIDIMatrix &matrix, std::ostream &ost=std::cout) |
Helper function which shows the contents of a MIDIMatrix. More... | |
Functions for Loading MIDI files | |
MIDIFileHeader & | GetMIDIFileHeader (const char *filename) |
Returns the header of the MIDI file specified by filename. More... | |
MIDIFileHeader & | GetMIDIFileHeader (const std::string &filename) |
Returns the header of the MIDI file specified by filename. More... | |
bool | LoadMIDIFile (const char *filename, MIDIMultiTrack *tracks, MIDIFileHeader *const head=0) |
Loads a MIDI file into a MIDIMultiTrack object. More... | |
bool | LoadMIDIFile (const std::string &filename, MIDIMultiTrack *tracks, MIDIFileHeader *const head=0) |
Loads a MIDI file into a MIDIMultiTrack object. More... | |
Functions for saving MIDI files | |
bool | WriteMIDIFile (const char *filename, int format, const MIDIMultiTrack *tracks, bool strip=false) |
Writes the given MIDIMultiTrack object into a MIDI file. More... | |
bool | WriteMIDIFile (const std::string &filename, int format, const MIDIMultiTrack *tracks, bool strip=false) |
Writes the given MIDIMultiTrack object into a MIDI file. More... | |
Helper functions for MIDI and music | |
const char * | GetChanMsgName (unsigned char status) |
Returns a readable name for the given channel message status. More... | |
const char * | GetChanModeMsgName (unsigned char number) |
Returns a readable name for the given channel mode (Control change with controller number between 0x78 ... 0x7f). More... | |
const char * | GetSysMsgName (unsigned char status) |
Returns a readable name for the given sys message status. More... | |
const char * | GetMetaMsgName (unsigned char type) |
Returns a readable name for the given meta message status. More... | |
const char * | GetGMProgramName (unsigned char number, int format=0) |
Returns a readable name for a GM program number. More... | |
const char * | GetGMDrumkitName (unsigned char number, int format=0) |
Returns a readable name for a GM program number on channel 10 (drumkit). More... | |
bool | IsNoteWhite (unsigned char note) |
Returns true if the MIDI number of the note denotes a white key. More... | |
bool | IsNoteBlack (unsigned char note) |
Returns true if the MIDI number of the note denotes a black key. More... | |
int | GetNoteOctave (unsigned char note) |
MIDI note number to standard octave conversion. More... | |
const char * | KeyName (signed char sharp_flats, unsigned char major_minor, bool uppercase=true, bool space=false, bool use_Mm=true) |
Converts a MIDI key signature into a readable form. More... | |
Typedef, functions, enums and preprocessor labels globally defined.
#define DRIVER_USES_MIDIMATRIX 0 |
#include <driver.h>
This item only affects AllNotesOff() function.
All modern MIDI devices should respond to all notes off messages so usually there is no need to stop notes sending Note off messages. If you set this to 1 the driver will keep track of all sounding notes and, if the AllNotesOff() method is called, will send a Note Off message for each one, plus a damper off message for every channel. This is quite expensive, so turn this on only if you experience notes sounding when you stop a sequencer.
typedef unsigned long MIDIClockTime |
#include <midi.h>
The type of a variable which can hold a time in MIDI ticks.
The MIDI tick is the basis for MIDI clocking: a quarter note is assigned a number of MIDI ticks (see DEFAULT_CLKS_PER_BEAT), and a MIDITimedMessage object has its time measured in MIDI ticks.
typedef unsigned long long tMsecs |
#include <timer.h>
The type of a variable which can hold the elapsed time in milliseconds.
typedef void() MIDITick(tMsecs, void *) |
#include <timer.h>
This is the typedef of the callback functions which are called at every timer tick.
See the MIDITickComponent class. .
enum SMPTE_RATE |
#include <smpte.h>
The smpte rates (determine the frames/sec rate)
enum SAMPLE_RATE |
#include <smpte.h>
The sample rates (determine the sample/sec rate)
Enumerator | |
---|---|
SAMPLE_32000 | 32000 samples/sec |
SAMPLE_44056 | 44056 samples/sec |
SAMPLE_44100 | 44100 samples/sec |
SAMPLE_47952 | 47952 samples/sec |
SAMPLE_48000 | 48000 samples/sec |
SAMPLE_48048 | 48048 samples/sec |
enum tPriority |
#include <tick.h>
These are the available priorities for a MIDITickComponent. When you add a component to the MIDIManager queue with the MIDIManager::SetComponent() method the order in the queue reflects the priority of the components.
enum tInsMode |
#include <track.h>
Defines the default behavior of the methods MIDITrack::InsertEvent() and MIDITrack::InsertNote() when inserting events.
If they are trying to insert an event into a track and find an equal or similar event at same MIDI time (see MIDITimedMessage::IsSameKind()) they can replace it with the new event or insert it without deleting the older. This is determined by a static attribute of the class MIDITrack and can be changed by the MIDITrack::SetInsertMode() method (the default is INSMODE_INSERT_OR_REPLACE). When the above methods are called with default argument *_ins_mode* they follow the default behavior, this can be overriden giving them one of the other values as last parameter
Enumerator | |
---|---|
INSMODE_DEFAULT | follow the default behaviour (only used as default argument in methods MIDITrack::InsertEvent() and MIDITrack::InsertNote() |
INSMODE_INSERT | always insert events, if a same kind event was found keep both. |
INSMODE_REPLACE | replace if a same kind event was found, otherwise do nothing. |
INSMODE_INSERT_OR_REPLACE | replace if a same kind event was found, otherwise insert. |
INSMODE_INSERT_OR_REPLACE_BUT_NOTE | as above, but allow two same note events at same time (don't replace, insert a new note). |
anonymous enum |
#include <track.h>
Defines the behaviour of the method MIDITrack::FindEventNumber() when searching events.
Enumerator | |
---|---|
COMPMODE_EQUAL | the method searches for an event matching equal operator. |
COMPMODE_SAMEKIND | the method searches for an event matching the MIDITimedMessage::IsSameKind() method. |
COMPMODE_TIME | the method searches for the first event with time equal to the event time. |
void SetChanFrom | ( | unsigned char | c = 0 | ) |
#include <dump_tracks.h>
Sets the numbering of MIDI channels when messages are printed.
If c == 0 channels will be numbered 0 ... 15, else 1 ... 16. This will affect all the functions of this file. See Numbering conventions.
void DumpMIDITimedMessage | ( | MIDITimedMessage *const | msg, |
std::ostream & | ost = std::cout |
||
) |
#include <dump_tracks.h>
Prints a readable string describing the contents of the given MIDIMessage (or MIDITimedMessage).
void DumpMIDITrack | ( | MIDITrack *const | trk, |
std::ostream & | ost = std::cout |
||
) |
#include <dump_tracks.h>
Prints a list of all the MIDI messages in the given MIDItrack.
int DumpMIDITrackAttr | ( | MIDITrack *const | trk, |
int | num, | ||
std::ostream & | ost = std::cout |
||
) |
#include <dump_tracks.h>
Prints the main properties of the given MIDItrack.
It prints the track name, its type (see MIDITrack::GetType()), the number of events and the end time. Use DumpMIDITrack() for printing the track messages.
trk | a pointer to the track |
num | will be printed in the first line as track number. |
ost | the output stream |
int DumpMIDITrackAttrVerbose | ( | MIDITrack *const | trk, |
int | num, | ||
std::ostream & | ost = std::cout |
||
) |
#include <dump_tracks.h>
Prints all the properties of the given MIDItrack.
It prints the track name, its type (see MIDITrack::GetType()) with a detailed description, the in and out ports, the recording channel, the time shift amount, the number of events and the end time. Use DumpMIDITrack() for printing the track messages.
trk | a pointer to the track |
num | will be printed in the first line as track number. |
ost | the output stream |
void DumpAllTracks | ( | MIDIMultiTrack *const | mlt, |
std::ostream & | ost = std::cout |
||
) |
#include <dump_tracks.h>
Prints a list of all MIDI messages in the given MIDIMultiTrack, a track at once.
void DumpMIDIMultiTrack | ( | MIDIMultiTrack *const | mlt, |
std::ostream & | ost = std::cout |
||
) |
#include <dump_tracks.h>
Prints a list of all MIDI messages in the given MIDIMultiTrack in temporal order.
void CheckMIDIMatrix | ( | const MIDIMatrix & | matrix, |
std::ostream & | ost = std::cout |
||
) |
#include <dump_tracks.h>
Helper function which shows the contents of a MIDIMatrix.
MIDIFileHeader & GetMIDIFileHeader | ( | const char * | filename | ) |
#include <filereadmultitrack.h>
Returns the header of the MIDI file specified by filename.
You can then inspect the format, (0, 1 or 2), the number of tracks and the division (MIDI ticks per quarter note) of the file. If the header cannot be read these are all 0.
MIDIFileHeader & GetMIDIFileHeader | ( | const std::string & | filename | ) |
#include <filereadmultitrack.h>
Returns the header of the MIDI file specified by filename.
You can then inspect the format, (0, 1 or 2), the number of tracks and the division (MIDI ticks per quarter note) of the file. If the header cannot be read these are all 0.
bool LoadMIDIFile | ( | const char * | filename, |
MIDIMultiTrack * | tracks, | ||
MIDIFileHeader *const | head = 0 |
||
) |
#include <filereadmultitrack.h>
Loads a MIDI file into a MIDIMultiTrack object.
If the file is in SMF 0 (with only a track) splits it into a master track with only system messages and 16 channel tracks (if you want to remember the original file format you can set the default parameter head). This is the fastest way to put a file into a multitrack, without worrying with intermediate reader objects.
[in] | filename | the name of the file |
[out] | tracks | the MIDIMultiTrack to be loaded |
[out] | head | if you give the address of a MIDIFileHeader object this will be filled with the original file parameters (format, number of tracks, division, name) which you could reuse if you want to save the file. |
bool LoadMIDIFile | ( | const std::string & | filename, |
MIDIMultiTrack * | tracks, | ||
MIDIFileHeader *const | head = 0 |
||
) |
#include <filereadmultitrack.h>
Loads a MIDI file into a MIDIMultiTrack object.
bool WriteMIDIFile | ( | const char * | filename, |
int | format, | ||
const MIDIMultiTrack * | tracks, | ||
bool | strip = false |
||
) |
#include <filewritemultitrack.h>
Writes the given MIDIMultiTrack object into a MIDI file.
filename | the file name |
format | the MIDI file format (only 0 and 1 are supported) |
tracks | the MIDIMultiTrack to be written |
strip | if the format is 1 (many tracks) and this is true, empty tracks are skipped |
bool WriteMIDIFile | ( | const std::string & | filename, |
int | format, | ||
const MIDIMultiTrack * | tracks, | ||
bool | strip = false |
||
) |
#include <filewritemultitrack.h>
Writes the given MIDIMultiTrack object into a MIDI file.
const char * GetChanMsgName | ( | unsigned char | status | ) |
#include <midi.h>
Returns a readable name for the given channel message status.
const char * GetChanModeMsgName | ( | unsigned char | number | ) |
#include <midi.h>
Returns a readable name for the given channel mode (Control change with controller number between 0x78 ... 0x7f).
const char * GetSysMsgName | ( | unsigned char | status | ) |
#include <midi.h>
Returns a readable name for the given sys message status.
const char * GetMetaMsgName | ( | unsigned char | type | ) |
#include <midi.h>
Returns a readable name for the given meta message status.
const char * GetGMProgramName | ( | unsigned char | number, |
int | format = 0 |
||
) |
#include <midi.h>
Returns a readable name for a GM program number.
number | the program number |
format | if it is 1 prints the program number before its name. |
const char * GetGMDrumkitName | ( | unsigned char | number, |
int | format = 0 |
||
) |
#include <midi.h>
Returns a readable name for a GM program number on channel 10 (drumkit).
number | the program number |
format | if it is 1 prints the program number before its name. |
bool IsNoteWhite | ( | unsigned char | note | ) |
#include <midi.h>
Returns true if the MIDI number of the note denotes a white key.
bool IsNoteBlack | ( | unsigned char | note | ) |
#include <midi.h>
Returns true if the MIDI number of the note denotes a black key.
|
inline |
#include <midi.h>
MIDI note number to standard octave conversion.
const char * KeyName | ( | signed char | sharp_flats, |
unsigned char | major_minor, | ||
bool | uppercase = true , |
||
bool | space = false , |
||
bool | use_Mm = true |
||
) |
#include <midi.h>
Converts a MIDI key signature into a readable form.
sharp_flats | the number of accidents as coded in a MIDI keysig mera messge |
major_minor | the mode as coded in a MIDI keysig messages |
uppercase | if true the key name (A, B, C, ...) is uppercase |
space | if true puts a space between the key and the mode (es. A m) |
use_Mm | if true the mode is M or m, otherwise maj or min |
const MIDIClockTime TIME_INFINITE = 0xffffffff |
#include <midi.h>
A constant which represents an infinite time.
Used by some functions which search for specific events in a time interval.
const unsigned int DEFAULT_CLKS_PER_BEAT = 120 |
#include <midi.h>
The default clocks per beat parameter when initializing a MIDIMultiTrack.
This is the number of MIDI ticks for a quarter note in all the tracks of the multitrack when it is constructed. You can change it with the MIDIMultiTrack::SetClksPerBeat() method.
const int MIDI_DEFAULT_TIMESIG_NUMERATOR = 4 |
#include <midi.h>
Timesig numerator.
const int MIDI_DEFAULT_TIMESIG_DENOMINATOR = 4 |
#include <midi.h>
Timesig denominator.
const double MIDI_DEFAULT_TEMPO = 120.0 |
#include <midi.h>
Musical tempo.
const int MIDI_DEFAULT_KEYSIG_KEY = 0 |
#include <midi.h>
Keysig key (C)
const int MIDI_DEFAULT_KEYSIG_MODE = 0 |
#include <midi.h>
Keysig mode (major)