132 lines
3.1 KiB
C++
132 lines
3.1 KiB
C++
#ifndef _MIDISEQ_MIDITRACK_HPP_
|
|
#define _MIDISEQ_MIDITRACK_HPP_
|
|
#ifndef _COMMON_WINDOWS_HPP_
|
|
#include <common/windows.hpp>
|
|
#endif
|
|
#ifndef _COMMON_FILEIO_HPP_
|
|
#include <common/fileio.hpp>
|
|
#endif
|
|
#ifndef _MIDISEQ_PUREHEADER_HPP_
|
|
#include <midiseq/purehdr.hpp>
|
|
#endif
|
|
#ifndef _MIDISEQ_PUREEVENT_HPP_
|
|
#include <midiseq/pureevnt.hpp>
|
|
#endif
|
|
#ifndef _MIDISEQ_EVENTTYPE_HPP_
|
|
#include <midiseq/evnttype.hpp>
|
|
#endif
|
|
#ifndef _MIDISEQ_MIDICHANNELMESSAGE_HPP_
|
|
#include <midiseq/midimsg.hpp>
|
|
#endif
|
|
#ifndef _MIDISEQ_METAEVENTTYPE_HPP_
|
|
#include <midiseq/metaevnt.hpp>
|
|
#endif
|
|
#ifndef _MIDISEQ_TIMEINFO_HPP_
|
|
#include <midiseq/timeinfo.hpp>
|
|
#endif
|
|
#ifndef _MIDISEQ_SMPTEFORMAT_HPP_
|
|
#include <midiseq/smpte.hpp>
|
|
#endif
|
|
#ifndef _MIDISEQ_NOTE_HPP_
|
|
#include <midiseq/note.hpp>
|
|
#endif
|
|
|
|
class MidiTrack
|
|
{
|
|
public:
|
|
MidiTrack(FileIO &someMidiFile);
|
|
virtual ~MidiTrack();
|
|
void setMethod(PureHeader::Method timingMethod);
|
|
bool readTrack(void);
|
|
DWORD lengthData(void)const;
|
|
protected:
|
|
virtual void midiChannelMessage(PureEvent &channelEvent);
|
|
virtual void setTempo(DWORD microsecondsPerQtrNote);
|
|
virtual void smpteFormat(const SMPTEFormat &someSMPTEFormat);
|
|
virtual void timeSignature(const TimeInfo &someTimeInfo);
|
|
virtual void textMessage(const String &strText);
|
|
virtual void endOfTrack(void);
|
|
private:
|
|
enum {TrackIDLen=4,TempoEventLength=3,TimeSignatureEventLength=4};
|
|
void readTime(void);
|
|
WORD handleEvent(void);
|
|
WORD handleMetaEvent(void);
|
|
WORD handleMIDIChannelMessage(void);
|
|
WORD handleGenericMetaEvent(void);
|
|
WORD handleSystemExclusiveEvent(void);
|
|
WORD handleMetaTextEvent(void);
|
|
WORD handleMetaSequenceNumberEvent(void);
|
|
WORD handleTimeSignatureEvent(void);
|
|
WORD handleSetTempoEvent(void);
|
|
WORD handleSMPTEFormatEvent(void);
|
|
WORD handleChannelPrefix(void);
|
|
WORD processMIDIChannelMessage(void);
|
|
WORD isChannelMessage(BYTE eventType)const;
|
|
WORD isRunningStatus(BYTE eventType)const;
|
|
DWORD readVarLength(void);
|
|
void lengthData(DWORD lengthData);
|
|
void operator=(const MidiTrack &someMidiTrack);
|
|
void outDebug(const String &message,BYTE data)const;
|
|
void outDebug(const String &message)const;
|
|
|
|
char mTrack[TrackIDLen];
|
|
DWORD mLengthData;
|
|
BYTE mEventType;
|
|
BYTE mLastEventType;
|
|
BYTE mLastChannel;
|
|
BYTE mLastData;
|
|
BYTE mRunningEvent;
|
|
DWORD mEventLength;
|
|
DWORD mBytesRead;
|
|
DWORD mDeltaTime;
|
|
FileIO &mMidiFile;
|
|
PureHeader::Method mTimingMethod;
|
|
NoteOn mNoteOn;
|
|
NoteOff mNoteOff;
|
|
bool mIsDebug;
|
|
};
|
|
|
|
inline
|
|
MidiTrack::MidiTrack(FileIO &someMidiFile)
|
|
: mLengthData(0), mEventType(NullEvent), mLastEventType(NullEvent),
|
|
mRunningEvent(NullEvent), mEventLength(0), mMidiFile(someMidiFile),
|
|
mTimingMethod(PureHeader::Unset), mDeltaTime(0), mIsDebug(false)
|
|
{
|
|
}
|
|
|
|
inline
|
|
MidiTrack::~MidiTrack()
|
|
{
|
|
}
|
|
|
|
inline
|
|
void MidiTrack::setMethod(PureHeader::Method timingMethod)
|
|
{
|
|
mTimingMethod=timingMethod;
|
|
}
|
|
|
|
inline
|
|
DWORD MidiTrack::lengthData(void)const
|
|
{
|
|
return mLengthData;
|
|
}
|
|
|
|
inline
|
|
void MidiTrack::lengthData(DWORD lengthData)
|
|
{
|
|
mLengthData=lengthData;
|
|
}
|
|
|
|
inline
|
|
WORD MidiTrack::isRunningStatus(BYTE eventType)const
|
|
{
|
|
return (!(eventType&0x80));
|
|
}
|
|
|
|
inline
|
|
void MidiTrack::operator=(const MidiTrack &/*someMidiTrack*/)
|
|
{
|
|
return;
|
|
}
|
|
#endif
|