Initial
This commit is contained in:
44
midiseq/safe/#MIDIHDR.HPP
Normal file
44
midiseq/safe/#MIDIHDR.HPP
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef _MIDISEQ_MIDIHEADER_HPP_
|
||||
#define _MIDISEQ_MIDIHEADER_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_PUREHEADER_HPP_
|
||||
#include <midiseq/purehdr.hpp>
|
||||
#endif
|
||||
|
||||
class MidiHeader : public PureHeader
|
||||
{
|
||||
public:
|
||||
MidiHeader(void);
|
||||
virtual ~MidiHeader();
|
||||
WORD readHeader(FileIO &fileIO);
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
MidiHeader::MidiHeader(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
MidiHeader::~MidiHeader()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
WORD MidiHeader::readHeader(FileIO &fileIO)
|
||||
{
|
||||
return PureHeader::readHeader(fileIO);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
58
midiseq/safe/ChannelModeMessage.hpp
Normal file
58
midiseq/safe/ChannelModeMessage.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef _MIDISEQ_CHANNELMODEMESSAGE_HPP_
|
||||
#define _MIDISEQ_CHANNELMODEMESSAGE_HPP_
|
||||
#ifndef _MIDISEQ_PUREEVENT_HPP_
|
||||
#include <midiseq/pureevnt.hpp>
|
||||
#endif
|
||||
|
||||
class ChannelModeMessage
|
||||
{
|
||||
public:
|
||||
typedef enum ChannelMessage{AllNotesOff,LocalControlOff,LocalControlOn,
|
||||
Modulation,MainVolume,Pan,Expression,Sustain,ResetAllControllers};
|
||||
ChannelModeMessage(ChannelMessage channelMessage=AllNotesOff);
|
||||
virtual ~ChannelModeMessage();
|
||||
PureEvent getEvent(BYTE deltaTime=0,BYTE channel=0,BYTE value=0);
|
||||
private:
|
||||
ChannelMessage mChannelMessage;
|
||||
};
|
||||
|
||||
inline
|
||||
ChannelModeMessage::ChannelModeMessage(ChannelMessage channelMessage)
|
||||
: mChannelMessage(channelMessage)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ChannelModeMessage::~ChannelModeMessage()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
PureEvent ChannelModeMessage::getEvent(BYTE deltaTime,BYTE channel,BYTE value)
|
||||
{
|
||||
switch(mChannelMessage)
|
||||
{
|
||||
case AllNotesOff :
|
||||
return PureEvent(MIDIParameter,deltaTime,channel,123,0);
|
||||
case LocalControlOff :
|
||||
return PureEvent(MIDIParameter,deltaTime,channel,122,0);
|
||||
case LocalControlOn :
|
||||
return PureEvent(MIDIParameter,deltaTime,channel,122,127);
|
||||
case Modulation :
|
||||
return PureEvent(MIDIParameter,deltaTime,channel,1,value);
|
||||
case MainVolume :
|
||||
return PureEvent(MIDIParameter,deltaTime,channel,7,value);
|
||||
case Pan :
|
||||
return PureEvent(MIDIParameter,deltaTime,channel,10,value);
|
||||
case Expression :
|
||||
return PureEvent(MIDIParameter,deltaTime,channel,11,value);
|
||||
case Sustain :
|
||||
return PureEvent(MIDIParameter,deltaTime,channel,64,value);
|
||||
case ResetAllControllers :
|
||||
return PureEvent(MIDIParameter,deltaTime,channel,121,0);
|
||||
default :
|
||||
return PureEvent(MIDIParameter,deltaTime,channel,123,0); // default is all notes off
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
8
midiseq/safe/EVNTBLCK.HPP
Normal file
8
midiseq/safe/EVNTBLCK.HPP
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef _MIDISEQ_EVENTBLOCK_HPP_
|
||||
#define _MIDISEQ_EVENTBLOCK_HPP_
|
||||
class PureEvent;
|
||||
template <class T>
|
||||
class Block;
|
||||
typedef Block<PureEvent> EventBlock;
|
||||
#endif
|
||||
|
||||
11
midiseq/safe/EVNTTMR.CPP
Normal file
11
midiseq/safe/EVNTTMR.CPP
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <midiseq/evnttmr.hpp>
|
||||
|
||||
void EventTimer::timerStarted(void)
|
||||
{
|
||||
resetEvent();
|
||||
}
|
||||
|
||||
void EventTimer::timerStopped(void)
|
||||
{
|
||||
setEvent();
|
||||
}
|
||||
43
midiseq/safe/EVNTTMR.HPP
Normal file
43
midiseq/safe/EVNTTMR.HPP
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef _MIDISEQ_EVENTTIMER_HPP_
|
||||
#define _MIDISEQ_EVENTTIMER_HPP_
|
||||
#ifndef _COMMON_MMTIMER_HPP_
|
||||
#include <common/mmtimer.hpp>
|
||||
#endif
|
||||
#ifndef _THREAD_EVENT_HPP_
|
||||
#include <thread/event.hpp>
|
||||
#endif
|
||||
|
||||
class EventTimer : public Event, public MMTimer
|
||||
{
|
||||
public:
|
||||
EventTimer(void);
|
||||
virtual ~EventTimer();
|
||||
protected:
|
||||
EventTimer(const EventTimer &someEventTimer);
|
||||
EventTimer &operator=(const EventTimer &someEventTimer);
|
||||
virtual void timerStarted(void);
|
||||
virtual void timerStopped(void);
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
EventTimer::EventTimer(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
EventTimer::~EventTimer()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
EventTimer::EventTimer(const EventTimer &/*someEventTimer*/)
|
||||
{ // no implementation
|
||||
}
|
||||
|
||||
inline
|
||||
EventTimer &EventTimer::operator=(const EventTimer &/*someEventTimer*/)
|
||||
{ // no implementation
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
6
midiseq/safe/EVNTTYPE.HPP
Normal file
6
midiseq/safe/EVNTTYPE.HPP
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef _MIDISEQ_EVENTTYPE_HPP_
|
||||
#define _MIDISEQ_EVENTTYPE_HPP_
|
||||
|
||||
enum EventType{MetaEvent=0xFF,SystemExclusiveOne=0xF0,SystemExclusiveTwo=0xF7,NullEvent=0x00};
|
||||
|
||||
#endif
|
||||
280
midiseq/safe/MAIN.CPP
Normal file
280
midiseq/safe/MAIN.CPP
Normal file
@@ -0,0 +1,280 @@
|
||||
#include <midiseq/mididata.hpp>
|
||||
#include <sgi_stl/list>
|
||||
|
||||
void testNotes(void);
|
||||
void testFile(void);
|
||||
void testEvent(void);
|
||||
|
||||
void testSort();
|
||||
|
||||
int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/)
|
||||
{
|
||||
// testEvent();
|
||||
// testSort();
|
||||
testFile();
|
||||
// testNotes();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void testFile(void)
|
||||
{
|
||||
// String musicFileName("E:\\WORK\\SCENE\\MEDIA\\BMP\\E1M2.MID");
|
||||
// String musicFileName("E:\\WORK\\GUITAR\\MIDI\\DIANA.MID"); // OK
|
||||
// String musicFileName("E:\\WORK\\GUITAR\\MIDI\\JESU_1.MID"); // OK
|
||||
// String musicFileName("E:\\WORK\\GUITAR\\MIDI\\paco.MID"); // OK
|
||||
|
||||
|
||||
String musicFileName("E:\\WORK\\GUITAR\\MIDI\\zapatead.mid");
|
||||
// String musicFileName("C:\\WINNT\\MEDIA\\PASSPORT.MID");
|
||||
// String musicFileName("E:\\WORK\\GUITAR\\MIDI\\BUMBLEBEE.MID"); // OK
|
||||
// String musicFileName("C:\\WINNT\\MEDIA\\CANYON.MID");
|
||||
|
||||
|
||||
|
||||
MidiData midiData(musicFileName);
|
||||
midiData.play();
|
||||
while(midiData.isInPlay());
|
||||
midiData.stop();
|
||||
::MessageBox(::GetFocus(),(LPSTR)musicFileName,(LPSTR)"End Play",MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
void testEvent(void)
|
||||
{
|
||||
String musicFileName("D:\\WORK\\SCENE\\MEDIA\\BMP\\E1M2.MID");
|
||||
int requiredChannel=0;
|
||||
|
||||
|
||||
MidiData midiData(musicFileName);
|
||||
midiData.makeRealTime();
|
||||
::OutputDebugString(String("MIDI events=")+String().fromInt(midiData.getEventCount()));
|
||||
for(int index=0;index<midiData.getEventCount();index++)
|
||||
{
|
||||
PureEvent &pureEvent=midiData.getEventAt(index);
|
||||
if(144==pureEvent.eventType()&&requiredChannel==pureEvent.channel())
|
||||
{
|
||||
::OutputDebugString(pureEvent.toString()+String("\n"));
|
||||
}
|
||||
// ::OutputDebugString(pureEvent.toString()+String("\n"));
|
||||
|
||||
// eventType:144 [ MIDINoteOn] deltaTime: 31 playTime: 2323643 channel: 0 byteOne: 74 byteTwo: 62 midiTime: 0
|
||||
// midiChannelMessage(PureEvent(mEventType,mDeltaTime,channel,mNoteOn.pitch(),mNoteOn.velocity()));
|
||||
// PureEvent(BYTE eventType,DWORD deltaTime,BYTE channel,BYTE firstData,BYTE secondData);
|
||||
// pureEvent.playTime();
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#include <common/qsort.hpp>
|
||||
|
||||
void testSort()
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
list<PureEvent> lst;
|
||||
PureEvent p1;
|
||||
PureEvent p2;
|
||||
PureEvent p3;
|
||||
PureEvent p4;
|
||||
PureEvent p5;
|
||||
PureEvent p6;
|
||||
PureEvent p7;
|
||||
PureEvent p8;
|
||||
PureEvent p9;
|
||||
|
||||
p1.eventType(128);
|
||||
p2.eventType(128);
|
||||
p3.eventType(128);
|
||||
p4.eventType(144);
|
||||
p5.eventType(128);
|
||||
p6.eventType(128);
|
||||
p7.eventType(128);
|
||||
p8.eventType(128);
|
||||
p9.eventType(144);
|
||||
|
||||
lst.push_back(p1);
|
||||
lst.push_back(p2);
|
||||
lst.push_back(p3);
|
||||
lst.push_back(p4);
|
||||
lst.push_back(p5);
|
||||
lst.push_back(p6);
|
||||
lst.push_back(p7);
|
||||
lst.push_back(p8);
|
||||
lst.push_back(p9);
|
||||
lst.sort();
|
||||
|
||||
list<PureEvent>::iterator p=lst.begin();
|
||||
while(p!=lst.end())
|
||||
{
|
||||
::OutputDebugString((*p).toString()+String("\n"));
|
||||
p++;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
Array<PureEvent> pureEvents;
|
||||
QuickSort<PureEvent> eventSorter;
|
||||
PureEvent pureEvent;
|
||||
|
||||
pureEvents.size(9);
|
||||
pureEvent.eventType(128);
|
||||
pureEvents[0]=pureEvent;
|
||||
pureEvent.eventType(128);
|
||||
pureEvents[1]=pureEvent;
|
||||
pureEvent.eventType(128);
|
||||
pureEvents[2]=pureEvent;
|
||||
pureEvent.eventType(144);
|
||||
pureEvents[3]=pureEvent;
|
||||
pureEvent.eventType(128);
|
||||
pureEvents[4]=pureEvent;
|
||||
pureEvent.eventType(128);
|
||||
pureEvents[5]=pureEvent;
|
||||
pureEvent.eventType(128);
|
||||
pureEvents[6]=pureEvent;
|
||||
pureEvent.eventType(128);
|
||||
pureEvents[7]=pureEvent;
|
||||
pureEvent.eventType(144);
|
||||
pureEvents[8]=pureEvent;
|
||||
|
||||
eventSorter.sortItems(pureEvents);
|
||||
::OutputDebugString("\n");
|
||||
for(int index=0;index<pureEvents.size();index++)
|
||||
{
|
||||
::OutputDebugString(pureEvents[index].toString()+String("\n"));
|
||||
}
|
||||
|
||||
|
||||
/*eventType:128 [ MIDINoteOff] deltaTime: 1 playTime:147650742.00 channel: 0 byteOne: 56 byteTwo: 0 midiTime: 0
|
||||
eventType:128 [ MIDINoteOff] deltaTime: 0 playTime:147650742.00 channel: 0 byteOne: 59 byteTwo: 0 midiTime: 0
|
||||
eventType:128 [ MIDINoteOff] deltaTime: 0 playTime:147650742.00 channel: 0 byteOne: 64 byteTwo: 0 midiTime: 0
|
||||
eventType:144 [ MIDINoteOn] deltaTime: 0 playTime:147650742.00 channel: 0 byteOne: 64 byteTwo: 64 midiTime: 0
|
||||
eventType:128 [ MIDINoteOff] deltaTime: 0 playTime:147650742.00 channel: 0 byteOne: 53 byteTwo: 0 midiTime: 0
|
||||
eventType:128 [ MIDINoteOff] deltaTime: 0 playTime:147650742.00 channel: 0 byteOne: 57 byteTwo: 0 midiTime: 0
|
||||
eventType:128 [ MIDINoteOff] deltaTime: 0 playTime:147650742.00 channel: 0 byteOne: 60 byteTwo: 0 midiTime: 0
|
||||
eventType:128 [ MIDINoteOff] deltaTime: 0 playTime:147650742.00 channel: 0 byteOne: 64 byteTwo: 0 midiTime: 0
|
||||
eventType:144 [ MIDINoteOn] deltaTime: 0 playTime:147650742.00 channel: 0 byteOne: 59 byteTwo: 64 midiTime: 0 */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* for(DWORD index=0;index<MIDIBlock::MaxChannels;index++)maxEvents+=midiEventBlocks[(WORD)index].size();
|
||||
sortedEvents.size(maxEvents);
|
||||
for(index=0;index<MIDIBlock::MaxChannels;index++)
|
||||
{
|
||||
eventCount=midiEventBlocks[(WORD)index].size();
|
||||
if(!eventCount)continue;
|
||||
for(DWORD eventIndex=0;eventIndex<eventCount;eventIndex++)
|
||||
sortedEvents[runningCount++]=(midiEventBlocks[(WORD)index])[eventIndex];
|
||||
}
|
||||
if(!sortedEvents.size())return;
|
||||
eventSorter.sortItems(sortedEvents); */
|
||||
|
||||
|
||||
}
|
||||
|
||||
class PitchBend
|
||||
{
|
||||
public:
|
||||
enum {MinPitch=0x0000,MaxPitch=0x3FFF,CenterPitch=0x2000};
|
||||
PitchBend(void);
|
||||
PureEvent getEvent(void)const;
|
||||
void setPitch(WORD pitch);
|
||||
WORD getPitch(void)const;
|
||||
void centerWheel(void);
|
||||
private:
|
||||
BYTE getLo(void)const;
|
||||
BYTE getHi(void)const;
|
||||
|
||||
WORD mPitch;
|
||||
};
|
||||
|
||||
inline
|
||||
PitchBend::PitchBend()
|
||||
: mPitch(CenterPitch)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
void PitchBend::setPitch(WORD pitch)
|
||||
{
|
||||
if(pitch>MaxPitch)pitch=MaxPitch;
|
||||
mPitch=pitch;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD PitchBend::getPitch(void)const
|
||||
{
|
||||
return mPitch;
|
||||
}
|
||||
|
||||
inline
|
||||
void PitchBend::centerWheel(void)
|
||||
{
|
||||
mPitch=CenterPitch;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE PitchBend::getLo(void)const
|
||||
{
|
||||
return mPitch&0xFF;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE PitchBend::getHi(void)const
|
||||
{
|
||||
return mPitch>>8;
|
||||
}
|
||||
|
||||
inline
|
||||
PureEvent PitchBend::getEvent(void)const
|
||||
{
|
||||
String strPitch;
|
||||
::sprintf(strPitch.str(),"lo:0x%04lx hi:0x%04lx\n",getLo(),getHi());
|
||||
::OutputDebugString(strPitch.str());
|
||||
PureEvent pureEvent(MIDIPitchBend,0,0,getHi(),getLo());
|
||||
return pureEvent;
|
||||
}
|
||||
|
||||
void testNotes(void)
|
||||
{
|
||||
MIDIOutputDevice midiOut;
|
||||
|
||||
NoteOn noteOn(PureNote(70,60));
|
||||
PitchBend pitchBend;
|
||||
pitchBend.setPitch(0x0);
|
||||
pitchBend.setPitch(0x2000+128);
|
||||
|
||||
// pitchBend.setPitch(0x3FFF);
|
||||
NoteOff noteOff(PureNote(70,60));
|
||||
|
||||
if(!midiOut.openDevice())return;
|
||||
|
||||
midiOut.midiEvent(noteOn.getEvent());
|
||||
midiOut.midiEvent(pitchBend.getEvent());
|
||||
pitchBend.setPitch(0x2000);
|
||||
midiOut.midiEvent(pitchBend.getEvent());
|
||||
|
||||
midiOut.midiEvent(noteOn.getEvent());
|
||||
|
||||
midiOut.midiEvent(noteOff.getEvent());
|
||||
|
||||
midiOut.closeDevice();
|
||||
return;
|
||||
}
|
||||
|
||||
// String musicFileName("C:\\WORK\\SCENE\\MEDIA\\WALTHIUS\\DEMON21T.MID");
|
||||
// String musicFileName("C:\\WORK\\SCENE\\MEDIA\\CYBRBEAT.MID");
|
||||
// String musicFileName("C:\\WINDOWS\\CANYON.MID");
|
||||
// String musicFileName("C:\\WORK\\SCENE\\MEDIA\\MID\\D_STALKS.MID");
|
||||
// String musicFileName("C:\\WORK\\SCENE\\MEDIA\\MID\\E1M9.MID");
|
||||
// String musicFileName("C:\\WORK\\SCENE\\MEDIA\\EXORCIST.MID");
|
||||
// String musicFileName("C:\\WORK\\SCENE\\MEDIA\\YYZ.MID");
|
||||
// String musicFileName("C:\\WORK\\SCENE\\MEDIA\\K330-1.MID");
|
||||
// String musicFileName("C:\\WORK\\SCENE\\MEDIA\\K330-2.MID");
|
||||
8
midiseq/safe/METAEVNT.HPP
Normal file
8
midiseq/safe/METAEVNT.HPP
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef _MIDISEQ_METAEVENTTYPE_HPP_
|
||||
#define _MIDISEQ_METAEVENTTYPE_HPP_
|
||||
|
||||
enum MetaEventType{SequenceNumberEvent=0x00,TextEvent=0x01,CopyrightNotice=0x02,
|
||||
SequenceTrackName=0x03,InstrumentName=0x04,Lyric=0x05,Marker=0x06,CuePoint=0x07,
|
||||
ChannelPrefix=0x20,EndOfTrack=0x2F,SetTempo=0x51,SMPTEFormatSpec=0x54,
|
||||
TimeSignature=0x58,KeySignature=0x59,SequencerSpecificMetaEvent=0x7F};
|
||||
#endif
|
||||
32
midiseq/safe/MIDIBLCK.CPP
Normal file
32
midiseq/safe/MIDIBLCK.CPP
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <midiseq/midiblck.hpp>
|
||||
#include <midiseq/midimsg.hpp>
|
||||
#include <midiseq/pureevnt.hpp>
|
||||
#include <common/string.hpp>
|
||||
#include <common/openfile.hpp>
|
||||
|
||||
MIDIBlock &MIDIBlock::operator=(const MIDIBlock &someMIDIBlock)
|
||||
{
|
||||
for(short itemIndex=0;itemIndex<MaxChannels;itemIndex++)
|
||||
mMIDIBlock[itemIndex]=((MIDIBlock&)someMIDIBlock)[itemIndex];
|
||||
return *this;
|
||||
}
|
||||
|
||||
void MIDIBlock::printBlock(const String &pathFileName)
|
||||
{
|
||||
FileHandle writeFile(pathFileName,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite);
|
||||
String eventString;
|
||||
|
||||
if(!writeFile.isOkay())return;
|
||||
for(short itemIndex=0;itemIndex<MaxChannels;itemIndex++)
|
||||
{
|
||||
EventBlock &eventBlock=(mMIDIBlock[itemIndex]);
|
||||
WORD eventCount(eventBlock.size());
|
||||
for(short eventIndex=0;eventIndex<eventCount;eventIndex++)
|
||||
{
|
||||
String eventString(eventBlock[eventIndex].toString());
|
||||
writeFile.writeLine(eventString);
|
||||
}
|
||||
writeFile.writeLine("****************************************************************************");
|
||||
}
|
||||
}
|
||||
|
||||
48
midiseq/safe/MIDIBLCK.HPP
Normal file
48
midiseq/safe/MIDIBLCK.HPP
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _MIDISEQ_MIDIBLOCK_HPP_
|
||||
#define _MIDISEQ_MIDIBLOCK_HPP_
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_EVENTBLOCK_HPP_
|
||||
#include <midiseq/evntblck.hpp>
|
||||
#endif
|
||||
|
||||
class String;
|
||||
|
||||
class MIDIBlock
|
||||
{
|
||||
public:
|
||||
enum{MaxChannels=16};
|
||||
MIDIBlock(void);
|
||||
MIDIBlock(const MIDIBlock &someMIDIBlock);
|
||||
virtual ~MIDIBlock();
|
||||
EventBlock &operator[](WORD itemIndex);
|
||||
MIDIBlock &operator=(const MIDIBlock &someMIDIBlock);
|
||||
void printBlock(const String &pathFileName);
|
||||
private:
|
||||
EventBlock mMIDIBlock[MaxChannels];
|
||||
};
|
||||
|
||||
inline
|
||||
MIDIBlock::MIDIBlock(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
MIDIBlock::MIDIBlock(const MIDIBlock &someMIDIBlock)
|
||||
{
|
||||
*this=someMIDIBlock;
|
||||
}
|
||||
|
||||
inline
|
||||
MIDIBlock::~MIDIBlock()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
EventBlock &MIDIBlock::operator[](WORD itemIndex)
|
||||
{
|
||||
return mMIDIBlock[itemIndex];
|
||||
}
|
||||
#endif
|
||||
|
||||
120
midiseq/safe/MIDICAPS.HPP
Normal file
120
midiseq/safe/MIDICAPS.HPP
Normal file
@@ -0,0 +1,120 @@
|
||||
#ifndef _MIDISEQ_MIDIOUTCAPS_HPP_
|
||||
#define _MIDISEQ_MIDIOUTCAPS_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_MMSYSTEM_HPP_
|
||||
#include <common/mmsystem.hpp>
|
||||
#endif
|
||||
|
||||
class MIDIOutCaps : private MIDIOUTCAPS
|
||||
{
|
||||
public:
|
||||
enum Type{MIDIPort=MOD_MIDIPORT,SQSynth=MOD_SQSYNTH,FMSynth=MOD_FMSYNTH,Mapper=MOD_MAPPER};
|
||||
enum Channel{Channel0=0x0001,Channel1=0x0002,Channel2=0x0004,Channel3=0x0008,
|
||||
Channel4=0x0010,Channel5=0x0020,Channel6=0x0040,Channel7=0x0080,Channel8=0x0100,
|
||||
Channel9=0x0200,Channel10=0x0400,Channel11=0x0800,Channel12=0x1000,
|
||||
Channel13=0x2000,Channel14=0x4000,Channel15=0x8000,ChannelAll=0xFFFF};
|
||||
MIDIOutCaps(void);
|
||||
~MIDIOutCaps();
|
||||
UINT deviceID(void)const;
|
||||
UINT productID(void)const;
|
||||
WORD driverVersion(void)const;
|
||||
String productName(void)const;
|
||||
Type technology(void)const;
|
||||
WORD numVoices(void)const;
|
||||
WORD numNotes(void)const;
|
||||
WORD hasChannel(MIDIOutCaps::Channel channel)const;
|
||||
WORD hasPatchCache(void)const;
|
||||
WORD hasLeftRightVolume(void)const;
|
||||
WORD hasVolume(void)const;
|
||||
operator MIDIOUTCAPS*(void);
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
MIDIOutCaps::MIDIOutCaps(void)
|
||||
{
|
||||
::memset(this,0,sizeof(*this));
|
||||
}
|
||||
|
||||
inline
|
||||
MIDIOutCaps::~MIDIOutCaps()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
MIDIOutCaps::operator MIDIOUTCAPS*(void)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
inline
|
||||
UINT MIDIOutCaps::deviceID(void)const
|
||||
{
|
||||
return wMid;
|
||||
}
|
||||
|
||||
inline
|
||||
UINT MIDIOutCaps::productID(void)const
|
||||
{
|
||||
return wPid;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD MIDIOutCaps::driverVersion(void)const
|
||||
{
|
||||
return vDriverVersion;
|
||||
}
|
||||
|
||||
inline
|
||||
String MIDIOutCaps::productName(void)const
|
||||
{
|
||||
return szPname;
|
||||
}
|
||||
|
||||
inline
|
||||
MIDIOutCaps::Type MIDIOutCaps::technology(void)const
|
||||
{
|
||||
return (Type)wTechnology;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD MIDIOutCaps::numVoices(void)const
|
||||
{
|
||||
return wVoices;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD MIDIOutCaps::numNotes(void)const
|
||||
{
|
||||
return wNotes;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD MIDIOutCaps::hasChannel(MIDIOutCaps::Channel channel)const
|
||||
{
|
||||
return (channel&wChannelMask);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD MIDIOutCaps::hasVolume(void)const
|
||||
{
|
||||
return (WORD)(dwSupport&MIDICAPS_VOLUME);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD MIDIOutCaps::hasLeftRightVolume(void)const
|
||||
{
|
||||
return (WORD)(dwSupport&MIDICAPS_LRVOLUME);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD MIDIOutCaps::hasPatchCache(void)const
|
||||
{
|
||||
return (WORD)(dwSupport&MIDICAPS_CACHE);
|
||||
}
|
||||
#endif
|
||||
86
midiseq/safe/MIDIDATA.CPP
Normal file
86
midiseq/safe/MIDIDATA.CPP
Normal file
@@ -0,0 +1,86 @@
|
||||
#include <midiseq/mididata.hpp>
|
||||
|
||||
MidiData::MidiData(const String &midiPathFileName)
|
||||
: mTimerCallback(this,&MidiData::timerEvent),
|
||||
mMidiFile(midiPathFileName,FileIO::BigEndian), MidiTrack(mMidiFile)
|
||||
{
|
||||
insertHandler(&mTimerCallback);
|
||||
if(!readHeader(mMidiFile))return;
|
||||
::OutputDebugString(String("[MidiData::MidiData]MIDI header=")+String(MidiHeader::toString()+String("\n")).str());
|
||||
setMethod(timingMethod());
|
||||
}
|
||||
|
||||
MidiData::~MidiData()
|
||||
{
|
||||
stopTimer();
|
||||
mMIDIOutDevice.closeDevice();
|
||||
mMIDIEventVector.size(0);
|
||||
}
|
||||
|
||||
bool MidiData::play(WORD blocking)
|
||||
{
|
||||
mPlayIndex=0;
|
||||
if(!makeRealTime())return false;
|
||||
startTimer(TimerDelay);
|
||||
if(blocking)waitEvent();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MidiData::makeRealTime(void)
|
||||
{
|
||||
TimeBlock timeBlock;
|
||||
|
||||
mTempoChange.remove();
|
||||
if(!tracks())return false;
|
||||
while(readTrack());
|
||||
if(!mTempoChange.size())return false;
|
||||
timeBlock.setTempo(mTempoChange[0].microsecsPerQtrNote());
|
||||
timeBlock.setDivision(method());
|
||||
timeBlock.setStartTime(getSystemTime()+TwoSecs);
|
||||
timeBlock.fixTimeBlock(mMIDIEvents,mMIDIEventVector);
|
||||
return true;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType MidiData::timerEvent(CallbackData &/*someCallbackData*/)
|
||||
{
|
||||
DWORD currTime(getSystemTime());
|
||||
|
||||
if(!mMIDIOutDevice.hasDevice()||!mMIDIEventVector.size())return closeDevice();
|
||||
while(mMIDIEventVector[mPlayIndex].playTime()<=currTime)
|
||||
{
|
||||
if(!mMIDIOutDevice.midiEvent(mMIDIEventVector[mPlayIndex]))return closeDevice();
|
||||
if(++mPlayIndex>=mMIDIEventVector.size())return closeDevice();
|
||||
}
|
||||
return (CallbackData::ReturnType)TRUE;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType MidiData::closeDevice(void)
|
||||
{
|
||||
mMIDIOutDevice.closeDevice();
|
||||
return (CallbackData::ReturnType)FALSE;
|
||||
}
|
||||
|
||||
// virtual overloads
|
||||
|
||||
void MidiData::midiChannelMessage(PureEvent &midiEvent)
|
||||
{
|
||||
mMIDIEvents[midiEvent.channel()].insert(&midiEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
void MidiData::setTempo(DWORD microsecsPerQtrNote)
|
||||
{
|
||||
mTempoChange.insert(&TempoChange(microsecsPerQtrNote,0L));
|
||||
return;
|
||||
}
|
||||
|
||||
void MidiData::smpteFormat(const SMPTEFormat &someSMPTEFormat)
|
||||
{
|
||||
mSMPTEFormat=someSMPTEFormat;
|
||||
return;
|
||||
}
|
||||
|
||||
void MidiData::timeSignature(const TimeInfo &/*someTimeInfo*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
126
midiseq/safe/MIDIDATA.HPP
Normal file
126
midiseq/safe/MIDIDATA.HPP
Normal file
@@ -0,0 +1,126 @@
|
||||
#ifndef _MIDISEQ_MIDIDATA_HPP_
|
||||
#define _MIDISEQ_MIDIDATA_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
//#ifndef _COMMON_PUREVECTOR_HPP_
|
||||
//#include <common/pvector.hpp>
|
||||
//#endif
|
||||
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _COMMON_CALLBACK_HPP_
|
||||
#include <common/callback.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_MIDIOUTDEVICE_HPP_
|
||||
#include <midiseq/midiout.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_MIDIHEADER_HPP_
|
||||
#include <midiseq/midihdr.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_MIDITRACK_HPP_
|
||||
#include <midiseq/miditrck.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_PUREEVENT_HPP_
|
||||
#include <midiseq/pureevnt.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_TIMEBLOCK_HPP_
|
||||
#include <midiseq/timeblck.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_TIMEINFO_HPP_
|
||||
#include <midiseq/timeinfo.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_TEMPOCHANGE_HPP_
|
||||
#include <midiseq/tempo.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_SMPTEFORMAT_HPP_
|
||||
#include <midiseq/smpte.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_MIDIBLOCK_HPP_
|
||||
#include <midiseq/midiblck.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_EVENTTIMER_HPP_
|
||||
#include <midiseq/evnttmr.hpp>
|
||||
#endif
|
||||
|
||||
class String;
|
||||
|
||||
class MidiData : public MidiHeader, public MidiTrack, public EventTimer
|
||||
{
|
||||
public:
|
||||
MidiData(const String &midiPathFileName);
|
||||
virtual ~MidiData();
|
||||
bool play(WORD blocking=TRUE);
|
||||
bool stop(void);
|
||||
bool isInPlay(void)const;
|
||||
bool makeRealTime(void);
|
||||
PureEvent &getEventAt(int index);
|
||||
DWORD getEventCount(void)const;
|
||||
protected:
|
||||
void setTempo(DWORD microsecsPerQtrNote);
|
||||
void midiChannelMessage(PureEvent &channelEvent);
|
||||
void smpteFormat(const SMPTEFormat &someSMPTEFormat);
|
||||
void timeSignature(const TimeInfo &someTimeInfo);
|
||||
private:
|
||||
enum {TimerDelay=10,ThreeSecs=3000,TwoSecs=2000,OneSec=1000};
|
||||
WORD timerEvent(void);
|
||||
bool readTrack(void);
|
||||
void operator=(const MidiData &someMidiData);
|
||||
CallbackData::ReturnType timerEvent(CallbackData &someCallbackData);
|
||||
CallbackData::ReturnType closeDevice(void);
|
||||
|
||||
Callback<MidiData> mTimerCallback;
|
||||
// PureVector<PureEvent> mMIDIEventVector;
|
||||
Array<PureEvent> mMIDIEventVector;
|
||||
Block<TempoChange> mTempoChange;
|
||||
MIDIBlock mMIDIEvents;
|
||||
MIDIOutputDevice mMIDIOutDevice;
|
||||
FileIO mMidiFile;
|
||||
SMPTEFormat mSMPTEFormat;
|
||||
DWORD mPlayIndex;
|
||||
};
|
||||
|
||||
inline
|
||||
void MidiData::operator=(const MidiData &/*someMidiData*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
inline
|
||||
bool MidiData::readTrack(void)
|
||||
{
|
||||
return MidiTrack::readTrack();
|
||||
}
|
||||
|
||||
inline
|
||||
PureEvent &MidiData::getEventAt(int index)
|
||||
{
|
||||
return mMIDIEventVector[index];
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD MidiData::getEventCount(void)const
|
||||
{
|
||||
return mMIDIEventVector.size();
|
||||
}
|
||||
|
||||
inline
|
||||
bool MidiData::stop(void)
|
||||
{
|
||||
if(!isRunning())return true;
|
||||
return stopTimer();
|
||||
}
|
||||
|
||||
inline
|
||||
bool MidiData::isInPlay(void)const
|
||||
{
|
||||
return isRunning();
|
||||
}
|
||||
#endif
|
||||
|
||||
34
midiseq/safe/MIDIHDR.HPP
Normal file
34
midiseq/safe/MIDIHDR.HPP
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _MIDISEQ_MIDIHEADER_HPP_
|
||||
#define _MIDISEQ_MIDIHEADER_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_PUREHEADER_HPP_
|
||||
#include <midiseq/purehdr.hpp>
|
||||
#endif
|
||||
|
||||
class MidiHeader : public PureHeader
|
||||
{
|
||||
public:
|
||||
MidiHeader(void);
|
||||
virtual ~MidiHeader();
|
||||
WORD readHeader(FileIO &fileIO);
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
MidiHeader::MidiHeader(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
MidiHeader::~MidiHeader()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
WORD MidiHeader::readHeader(FileIO &fileIO)
|
||||
{
|
||||
return PureHeader::readHeader(fileIO);
|
||||
}
|
||||
#endif
|
||||
7
midiseq/safe/MIDIMSG.HPP
Normal file
7
midiseq/safe/MIDIMSG.HPP
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef _MIDISEQ_MIDICHANNELMESSAGE_HPP_
|
||||
#define _MIDISEQ_MIDICHANNELMESSAGE_HPP_
|
||||
|
||||
enum MidiChannelMsg{MIDIProgramChange=0xC0,MIDINoteOff=0x80,MIDINoteOn=0x90,
|
||||
MIDIKeyPressure=0xA0,MIDIParameter=0xB0,MIDIPitchBend=0xE0,
|
||||
MIDIChannelPressure=0xD0};
|
||||
#endif
|
||||
119
midiseq/safe/MIDIOUT.CPP
Normal file
119
midiseq/safe/MIDIOUT.CPP
Normal file
@@ -0,0 +1,119 @@
|
||||
#include <string.h>
|
||||
#include <midiseq/midiout.hpp>
|
||||
|
||||
MIDIOutputDevice::MIDIOutputDevice(void)
|
||||
: mHasDevice(FALSE), mMIDIDeviceID(MIDIMAPPER)
|
||||
{
|
||||
openDevice();
|
||||
}
|
||||
|
||||
WORD MIDIOutputDevice::openDevice(void)
|
||||
{
|
||||
closeDevice();
|
||||
if(!::midiOutGetNumDevs())return FALSE;
|
||||
if(::midiOutOpen(&mhMIDIOutput,mMIDIDeviceID,0,0,0))return FALSE;
|
||||
hasDevice(TRUE);
|
||||
getDeviceCapabilities();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void MIDIOutputDevice::closeDevice(void)
|
||||
{
|
||||
if(!hasDevice())return;
|
||||
::midiOutReset(mhMIDIOutput);
|
||||
::midiOutClose(mhMIDIOutput);
|
||||
hasDevice(FALSE);
|
||||
}
|
||||
|
||||
WORD MIDIOutputDevice::getDeviceCapabilities(void)
|
||||
{
|
||||
if(!hasDevice())return FALSE;
|
||||
::memset(&mMIDIOutDevCaps,0,sizeof(MIDIOutCaps));
|
||||
if(::midiOutGetDevCaps(mMIDIDeviceID,mMIDIOutDevCaps,sizeof(MIDIOutCaps)))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD MIDIOutputDevice::midiEvent(const PureEvent &somePureEvent)
|
||||
{
|
||||
union{DWORD dwData;BYTE bData[4];}unionData;
|
||||
|
||||
// String str=(String)((PureEvent&)somePureEvent)+String("\n");;
|
||||
// ::OutputDebugString(str.str());
|
||||
if(!hasDevice())return FALSE;
|
||||
unionData.bData[0]=somePureEvent.eventType();
|
||||
unionData.bData[1]=somePureEvent.firstData();
|
||||
unionData.bData[2]=somePureEvent.secondData();
|
||||
unionData.bData[3]=0;
|
||||
if(::midiOutShortMsg(mhMIDIOutput,unionData.dwData))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD MIDIOutputDevice::getLeftVolume(void)const
|
||||
{
|
||||
DWORD volumeLevel;
|
||||
|
||||
if(!hasDevice())return FALSE;
|
||||
if(!mMIDIOutDevCaps.hasVolume())return FALSE;
|
||||
#if WINVER>=0x0400
|
||||
if(::midiOutGetVolume(mhMIDIOutput,&volumeLevel))return FALSE;
|
||||
#else
|
||||
if(::midiOutGetVolume(mMIDIDeviceID,&volumeLevel))return FALSE;
|
||||
#endif
|
||||
return LOWORD(volumeLevel);
|
||||
}
|
||||
|
||||
WORD MIDIOutputDevice::getRightVolume(void)const
|
||||
{
|
||||
DWORD volumeLevel;
|
||||
|
||||
if(!hasDevice())return FALSE;
|
||||
if(!mMIDIOutDevCaps.hasVolume())return FALSE;
|
||||
#if WINVER>=0x0400
|
||||
if(::midiOutGetVolume(mhMIDIOutput,&volumeLevel))return FALSE;
|
||||
#else
|
||||
if(::midiOutGetVolume(mMIDIDeviceID,&volumeLevel))return FALSE;
|
||||
#endif
|
||||
if(!mMIDIOutDevCaps.hasLeftRightVolume())return LOWORD(volumeLevel);
|
||||
return HIWORD(volumeLevel);
|
||||
}
|
||||
|
||||
WORD MIDIOutputDevice::setRightVolume(WORD volumeRight)
|
||||
{
|
||||
DWORD volumeLevel;
|
||||
|
||||
if(!hasDevice())return FALSE;
|
||||
if(!mMIDIOutDevCaps.hasVolume())return FALSE;
|
||||
volumeLevel=volumeRight;
|
||||
if(mMIDIOutDevCaps.hasLeftRightVolume())
|
||||
{
|
||||
volumeLevel<<=8;
|
||||
volumeLevel+=getLeftVolume();
|
||||
}
|
||||
#if WINVER>=0x0400
|
||||
if(::midiOutSetVolume(mhMIDIOutput,volumeLevel))return FALSE;
|
||||
#else
|
||||
if(::midiOutSetVolume(mMIDIDeviceID,volumeLevel))return FALSE;
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD MIDIOutputDevice::setLeftVolume(WORD volumeLeft)
|
||||
{
|
||||
DWORD volumeLevel(0L);
|
||||
|
||||
if(!hasDevice())return FALSE;
|
||||
if(!mMIDIOutDevCaps.hasVolume())return FALSE;
|
||||
if(mMIDIOutDevCaps.hasLeftRightVolume())
|
||||
{
|
||||
volumeLevel=getRightVolume();
|
||||
volumeLevel<<=8;
|
||||
}
|
||||
volumeLevel+=volumeLeft;
|
||||
#if WINVER>=0x0400
|
||||
if(::midiOutSetVolume(mhMIDIOutput,volumeLevel))return FALSE;
|
||||
#else
|
||||
if(::midiOutSetVolume(mMIDIDeviceID,volumeLevel))return FALSE;
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
57
midiseq/safe/MIDIOUT.HPP
Normal file
57
midiseq/safe/MIDIOUT.HPP
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef _MIDISEQ_MIDIOUTDEVICE_HPP_
|
||||
#define _MIDISEQ_MIDIOUTDEVICE_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_MMSYSTEM_HPP_
|
||||
#include <common/mmsystem.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_PUREEVENT_HPP_
|
||||
#include <midiseq/pureevnt.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_MIDIOUTCAPS_HPP_
|
||||
#include <midiseq/midicaps.hpp>
|
||||
#endif
|
||||
|
||||
class MIDIOutputDevice
|
||||
{
|
||||
public:
|
||||
MIDIOutputDevice(void);
|
||||
virtual ~MIDIOutputDevice();
|
||||
WORD midiEvent(const PureEvent &somePureEvent);
|
||||
WORD hasDevice(void)const;
|
||||
void closeDevice(void);
|
||||
WORD openDevice(void);
|
||||
WORD getRightVolume(void)const;
|
||||
WORD getLeftVolume(void)const;
|
||||
WORD setRightVolume(WORD volumeLevel);
|
||||
WORD setLeftVolume(WORD volumeLevel);
|
||||
private:
|
||||
typedef HMIDIOUT MIDIHandle;
|
||||
void hasDevice(WORD hasDevice);
|
||||
WORD getDeviceCapabilities(void);
|
||||
|
||||
UINT mMIDIDeviceID;
|
||||
WORD mHasDevice;
|
||||
MIDIHandle mhMIDIOutput;
|
||||
MIDIOutCaps mMIDIOutDevCaps;
|
||||
};
|
||||
|
||||
inline
|
||||
MIDIOutputDevice::~MIDIOutputDevice(void)
|
||||
{
|
||||
closeDevice();
|
||||
}
|
||||
|
||||
inline
|
||||
WORD MIDIOutputDevice::hasDevice(void)const
|
||||
{
|
||||
return mHasDevice;
|
||||
}
|
||||
|
||||
inline
|
||||
void MIDIOutputDevice::hasDevice(WORD hasDevice)
|
||||
{
|
||||
mHasDevice=hasDevice;
|
||||
}
|
||||
#endif
|
||||
73
midiseq/safe/MIDISEQ.CPP
Normal file
73
midiseq/safe/MIDISEQ.CPP
Normal file
@@ -0,0 +1,73 @@
|
||||
#include <common/windows.hpp>
|
||||
#include <midiseq/mididata.hpp>
|
||||
#include <midiseq/midiseq.hpp>
|
||||
|
||||
MidiData *lpMidiData=0;
|
||||
|
||||
#if defined(__FLAT__)
|
||||
#if defined(_MSC_VER)
|
||||
BOOL _stdcall DllMain(HINSTANCE /*hInstance*/,DWORD reasonCode,LPVOID /*lpvReserved*/)
|
||||
#else
|
||||
BOOL WINAPI DllEntryPoint(HINSTANCE /*hInstance*/,DWORD reasonCode,LPVOID /*lpvReserved*/)
|
||||
#endif
|
||||
{
|
||||
switch(reasonCode)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH :
|
||||
lpMidiData=0;
|
||||
break;
|
||||
case DLL_PROCESS_DETACH :
|
||||
stop();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
int CALLBACK _export LibMain(HINSTANCE /*hInstance*/,WORD /*wDataSeg*/,WORD /*wHeapSize*/,LPSTR /*lpszCmdLine*/)
|
||||
{
|
||||
lpMidiData=0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int CALLBACK _export WEP(int /*nExitType*/)
|
||||
{
|
||||
return stop();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
short _stdcall play(String midiPathFileName)
|
||||
#else
|
||||
short CALLBACK _export play(String midiPathFileName)
|
||||
#endif
|
||||
{
|
||||
if(lpMidiData)stop();
|
||||
lpMidiData=new MidiData(midiPathFileName);
|
||||
if(!lpMidiData)return FALSE;
|
||||
lpMidiData->play();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
short _stdcall stop(void)
|
||||
#else
|
||||
short CALLBACK _export stop(void)
|
||||
#endif
|
||||
{
|
||||
if(!lpMidiData)return FALSE;
|
||||
lpMidiData->stop();
|
||||
delete lpMidiData;
|
||||
lpMidiData=0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
short _stdcall isInPlay(void)
|
||||
#else
|
||||
short CALLBACK _export isInPlay(void)
|
||||
#endif
|
||||
{
|
||||
if(!lpMidiData)return FALSE;
|
||||
return lpMidiData->isInPlay();
|
||||
}
|
||||
|
||||
30
midiseq/safe/MIDISEQ.HPP
Normal file
30
midiseq/safe/MIDISEQ.HPP
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef _MIDISEQ_MIDISEQ_HPP_
|
||||
#define _MIDISEQ_MIDISEQ_HPP_
|
||||
|
||||
#if defined(__FLAT__)
|
||||
extern "C"
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
__declspec(dllexport) BOOL _stdcall DllMain(HINSTANCE hInstance,DWORD reasonCode,LPVOID lpvReserved);
|
||||
#else
|
||||
BOOL WINAPI DllEntryPoint(HINSTANCE hInstance,DWORD reasonCode,LPVOID lpvReserved);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
extern "C"
|
||||
{
|
||||
int CALLBACK _export LibMain(HINSTANCE hInstance,WORD wDataSeg,WORD wHeapSize,LPSTR lpszCmdLine);
|
||||
int CALLBACK _export WEP(int nExitType);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
__declspec(dllexport) short _stdcall play(String midiPathFileName);
|
||||
__declspec(dllexport) short _stdcall stop(void);
|
||||
__declspec(dllexport) short _stdcall isInPlay(void);
|
||||
#else
|
||||
short CALLBACK _export play(String midiPathFileName);
|
||||
short CALLBACK _export stop(void);
|
||||
short CALLBACK _export isInPlay(void);
|
||||
#endif
|
||||
#endif
|
||||
378
midiseq/safe/MIDITRCK.CPP
Normal file
378
midiseq/safe/MIDITRCK.CPP
Normal file
@@ -0,0 +1,378 @@
|
||||
#include <common/math.hpp>
|
||||
#include <midiseq/miditrck.hpp>
|
||||
|
||||
bool MidiTrack::readTrack(void)
|
||||
{
|
||||
mBytesRead=0;
|
||||
if(PureHeader::Unset==mTimingMethod)return false;
|
||||
if(!mMidiFile.read(mTrack,sizeof(mTrack)))return false;
|
||||
if(::strncmp(mTrack,"MTrk",sizeof(mTrack)))return false;
|
||||
if(!mMidiFile.read(mLengthData))return false;
|
||||
if(!mLengthData)return false;
|
||||
readTime();
|
||||
while(mBytesRead<mLengthData)
|
||||
{
|
||||
if(!mMidiFile.read(mEventType))return true;
|
||||
mBytesRead++;
|
||||
if(!handleEvent())return true;
|
||||
if(mBytesRead>=mLengthData)break;
|
||||
if(NullEvent==mRunningEvent){readTime();mLastEventType=mEventType;}
|
||||
else mLastEventType=mRunningEvent;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MidiTrack::readTime(void)
|
||||
{
|
||||
switch(mTimingMethod)
|
||||
{
|
||||
case PureHeader::DeltaTime :
|
||||
case PureHeader::TimeCode :
|
||||
mDeltaTime=readVarLength();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleEvent(void)
|
||||
{
|
||||
WORD returnCode;
|
||||
|
||||
outDebug("[handleEvent]Event Type",mEventType);
|
||||
switch(mEventType)
|
||||
{
|
||||
case MetaEvent :
|
||||
mRunningEvent=NullEvent;
|
||||
returnCode=handleMetaEvent();
|
||||
break;
|
||||
case SystemExclusiveOne :
|
||||
case SystemExclusiveTwo :
|
||||
mRunningEvent=NullEvent;
|
||||
returnCode=handleSystemExclusiveEvent();
|
||||
break;
|
||||
default :
|
||||
returnCode=handleMIDIChannelMessage();
|
||||
break;
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
WORD MidiTrack::isChannelMessage(BYTE eventType)const
|
||||
{
|
||||
BYTE status((eventType>>4)&0x0F);
|
||||
|
||||
outDebug("[isChannelMessage]eventType",eventType);
|
||||
if((status<=0x07)||(0x0F==status))
|
||||
{
|
||||
outDebug("[isChannelMessage] FAIL",eventType);
|
||||
return false;
|
||||
}
|
||||
if((status>=0x08&&status<=0x0B)||(status==0x0E))return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleMIDIChannelMessage(void)
|
||||
{
|
||||
WORD returnCode;
|
||||
|
||||
if(isRunningStatus(mEventType))
|
||||
{
|
||||
if(NullEvent==mRunningEvent)mRunningEvent=mLastEventType;
|
||||
mEventType=mLastEventType;
|
||||
}
|
||||
else mRunningEvent=NullEvent;
|
||||
if(isChannelMessage(mEventType))returnCode=processMIDIChannelMessage();
|
||||
else returnCode=FALSE;
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleMetaEvent(void)
|
||||
{
|
||||
BYTE entryType;
|
||||
WORD returnCode(TRUE);
|
||||
|
||||
if(!mMidiFile.read(entryType))return FALSE;
|
||||
mBytesRead++;
|
||||
switch(entryType)
|
||||
{
|
||||
case SequenceNumberEvent :
|
||||
outDebug("[handleMetaEvent]SequenceNumberEvent");
|
||||
returnCode=handleMetaSequenceNumberEvent();
|
||||
break;
|
||||
case TextEvent :
|
||||
outDebug("[handleMetaEvent]TextEvent");
|
||||
returnCode=handleMetaTextEvent();
|
||||
break;
|
||||
case CopyrightNotice :
|
||||
outDebug("[handleMetaEvent]CopyrightNotice");
|
||||
returnCode=handleMetaTextEvent();
|
||||
break;
|
||||
case SequenceTrackName :
|
||||
outDebug("[handleMetaEvent]SequenceTrackName");
|
||||
handleGenericMetaEvent();
|
||||
break;
|
||||
case InstrumentName :
|
||||
outDebug("[handleMetaEvent]InstrumentName");
|
||||
handleGenericMetaEvent();
|
||||
break;
|
||||
case Lyric :
|
||||
outDebug("[handleMetaEvent]Lyric");
|
||||
handleGenericMetaEvent();
|
||||
break;
|
||||
case Marker :
|
||||
outDebug("[handleMetaEvent]Marker");
|
||||
handleGenericMetaEvent();
|
||||
break;
|
||||
case CuePoint :
|
||||
outDebug("[handleMetaEvent]CuePoint");
|
||||
handleGenericMetaEvent();
|
||||
break;
|
||||
case ChannelPrefix :
|
||||
outDebug("[handleMetaEvent]ChannelPrefix");
|
||||
handleChannelPrefix();
|
||||
break;
|
||||
case EndOfTrack :
|
||||
outDebug("[handleMetaEvent]EndOfTrack");
|
||||
handleGenericMetaEvent();
|
||||
returnCode=FALSE;
|
||||
break;
|
||||
case SetTempo :
|
||||
outDebug("[handleMetaEvent]SetTempo");
|
||||
handleSetTempoEvent();
|
||||
break;
|
||||
case SMPTEFormatSpec :
|
||||
outDebug("[handleMetaEvent]SMTPFormatSpec");
|
||||
handleSMPTEFormatEvent();
|
||||
break;
|
||||
case TimeSignature :
|
||||
outDebug("[handleMetaEvent]TimeSignature");
|
||||
handleTimeSignatureEvent();
|
||||
break;
|
||||
case KeySignature :
|
||||
outDebug("[handleMetaEvent]KeySignature");
|
||||
handleGenericMetaEvent();
|
||||
break;
|
||||
case SequencerSpecificMetaEvent :
|
||||
outDebug("[handleMetaEvent]SequencerSpecificMetaEvent");
|
||||
handleGenericMetaEvent();
|
||||
break;
|
||||
default :
|
||||
handleGenericMetaEvent();
|
||||
break;
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleSystemExclusiveEvent(void)
|
||||
{
|
||||
return handleGenericMetaEvent();
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleMetaSequenceNumberEvent(void)
|
||||
{
|
||||
WORD sequenceNumber;
|
||||
|
||||
if(!mMidiFile.read(sequenceNumber))return FALSE;
|
||||
mBytesRead++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleMetaTextEvent(void)
|
||||
{
|
||||
BYTE textLength;
|
||||
BYTE textByte;
|
||||
|
||||
if(!mMidiFile.read(textLength))return FALSE;
|
||||
mBytesRead++;
|
||||
for(short index=0;index<textLength;index++){if(!mMidiFile.read(textByte))return FALSE;mBytesRead++;}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleSetTempoEvent(void)
|
||||
{
|
||||
DWORD microsecsPerQtrNote(0L);
|
||||
BYTE tempoBytes[TempoEventLength];
|
||||
short entryLength;
|
||||
|
||||
entryLength=(short)readVarLength();
|
||||
if(sizeof(tempoBytes)!=entryLength)return FALSE;
|
||||
if(!mMidiFile.read(tempoBytes,sizeof(tempoBytes)))return FALSE;
|
||||
microsecsPerQtrNote+=(DWORD)tempoBytes[0]*65536L;
|
||||
microsecsPerQtrNote+=(DWORD)tempoBytes[1]*256L;
|
||||
microsecsPerQtrNote+=(DWORD)tempoBytes[2];
|
||||
setTempo(microsecsPerQtrNote);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleTimeSignatureEvent(void)
|
||||
{
|
||||
BYTE tsBytes[TimeInfo::LengthTimeInfo];
|
||||
|
||||
if(TimeInfo::LengthTimeInfo!=readVarLength())return FALSE;
|
||||
if(!mMidiFile.read(tsBytes,sizeof(tsBytes)))return FALSE;
|
||||
TimeInfo midiTimeSignature(tsBytes[0],Math::power(2,tsBytes[1]),tsBytes[2],tsBytes[3]);
|
||||
timeSignature(midiTimeSignature);
|
||||
outDebug("[handleTimeSignatureEvent]"+midiTimeSignature.toString());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleSMPTEFormatEvent(void)
|
||||
{
|
||||
SMPTEFormat smpteFormatInfo;
|
||||
if(SMPTEFormat::SMPTEFormatLength!=readVarLength())
|
||||
{
|
||||
outDebug("[handleSMPTEFormatEvent] Unexpected SMPTEFormatLength");
|
||||
return FALSE;
|
||||
}
|
||||
smpteFormatInfo<<mMidiFile;
|
||||
smpteFormat(smpteFormatInfo);
|
||||
outDebug("[handleSMPTEFormatEvent]"+smpteFormatInfo.toString());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleChannelPrefix(void)
|
||||
{
|
||||
BYTE charByte;
|
||||
short entryLength;
|
||||
|
||||
entryLength=readVarLength();
|
||||
for(short index=0;index<entryLength;index++){if(!mMidiFile.read(charByte))return FALSE;mBytesRead++;}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD MidiTrack::handleGenericMetaEvent(void)
|
||||
{
|
||||
BYTE charByte;
|
||||
short entryLength;
|
||||
|
||||
entryLength=(short)readVarLength();
|
||||
for(short index=0;index<entryLength;index++){if(!mMidiFile.read(charByte))return FALSE;mBytesRead++;}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WORD MidiTrack::processMIDIChannelMessage(void)
|
||||
{
|
||||
WORD returnCode(TRUE);
|
||||
BYTE channel;
|
||||
BYTE messageDataOne;
|
||||
BYTE messageDataTwo;
|
||||
BYTE requiredDataBytes;
|
||||
|
||||
channel=mEventType&0x0F;
|
||||
requiredDataBytes=isChannelMessage(mEventType);
|
||||
outDebug("[processMIDIChannelMessage]event type ",mEventType&0xF0);
|
||||
switch(mEventType&0xF0)
|
||||
{
|
||||
case MIDIProgramChange :
|
||||
mMidiFile.read(messageDataOne);
|
||||
messageDataOne&=0x7F;
|
||||
midiChannelMessage(PureEvent(mEventType,mDeltaTime,channel,messageDataOne,0));
|
||||
mBytesRead++;
|
||||
break;
|
||||
case MIDINoteOff :
|
||||
if(PureNote::PureNoteLength!=requiredDataBytes){returnCode=FALSE;break;}
|
||||
mNoteOff<<mMidiFile;
|
||||
mNoteOff.pitch(mNoteOff.pitch()&0x7F);
|
||||
mNoteOff.velocity(mNoteOff.velocity()&0x7F);
|
||||
midiChannelMessage(PureEvent(mEventType,mDeltaTime,channel,mNoteOff.pitch(),mNoteOff.velocity()));
|
||||
mBytesRead+=PureNote::PureNoteLength;
|
||||
break;
|
||||
case MIDINoteOn :
|
||||
if(PureNote::PureNoteLength!=requiredDataBytes){returnCode=FALSE;break;}
|
||||
mNoteOn<<mMidiFile;
|
||||
mNoteOn.pitch(mNoteOn.pitch()&0x7F);
|
||||
mNoteOn.velocity(mNoteOn.velocity()&0x7F);
|
||||
midiChannelMessage(PureEvent(mEventType,mDeltaTime,channel,mNoteOn.pitch(),mNoteOn.velocity()));
|
||||
mBytesRead+=PureNote::PureNoteLength;
|
||||
break;
|
||||
case MIDIKeyPressure :
|
||||
if(2!=requiredDataBytes){returnCode=FALSE;break;}
|
||||
mMidiFile.read(messageDataOne);
|
||||
mMidiFile.read(messageDataTwo);
|
||||
messageDataOne&=0x7F;
|
||||
messageDataTwo&=0x7F;
|
||||
midiChannelMessage(PureEvent(mEventType,mDeltaTime,channel,messageDataOne,messageDataTwo));
|
||||
mBytesRead+=requiredDataBytes;
|
||||
break;
|
||||
case MIDIParameter :
|
||||
if(2!=requiredDataBytes){returnCode=FALSE;break;}
|
||||
mMidiFile.read(messageDataOne);
|
||||
mMidiFile.read(messageDataTwo);
|
||||
messageDataOne&=0x7F;
|
||||
messageDataTwo&=0x7F;
|
||||
midiChannelMessage(PureEvent(mEventType,mDeltaTime,channel,messageDataOne,messageDataTwo));
|
||||
mBytesRead+=requiredDataBytes;
|
||||
break;
|
||||
case MIDIPitchBend :
|
||||
if(2!=requiredDataBytes){returnCode=FALSE;break;}
|
||||
mMidiFile.read(messageDataOne);
|
||||
mMidiFile.read(messageDataTwo);
|
||||
messageDataOne&=0x7F;
|
||||
messageDataTwo&=0x7F;
|
||||
midiChannelMessage(PureEvent(mEventType,mDeltaTime,channel,messageDataOne,messageDataTwo));
|
||||
mBytesRead+=requiredDataBytes;
|
||||
break;
|
||||
case MIDIChannelPressure :
|
||||
if(1!=requiredDataBytes){returnCode=FALSE;break;}
|
||||
mMidiFile.read(messageDataOne);
|
||||
messageDataOne&=0x7F;
|
||||
midiChannelMessage(PureEvent(mEventType,mDeltaTime,channel,messageDataOne,0));
|
||||
mBytesRead++;
|
||||
break;
|
||||
default :
|
||||
returnCode=FALSE;
|
||||
break;
|
||||
}
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
DWORD MidiTrack::readVarLength(void)
|
||||
{
|
||||
DWORD valueData(0L);
|
||||
BYTE byteValue;
|
||||
|
||||
while(TRUE)
|
||||
{
|
||||
mMidiFile.read(byteValue);
|
||||
mBytesRead++;
|
||||
valueData=(valueData*0x80)+(byteValue&0x7F);
|
||||
if(!(byteValue&0x80))break;
|
||||
}
|
||||
return valueData;
|
||||
}
|
||||
|
||||
void MidiTrack::outDebug(const String &message,BYTE data)const
|
||||
{
|
||||
if(!mIsDebug)return;
|
||||
String strData;
|
||||
::sprintf(strData.str(),"%d (0x%08lx)",data,data);
|
||||
::OutputDebugString(String("[MidiTrack]")+message+String(" DATA=")+strData+String("\n"));
|
||||
}
|
||||
|
||||
void MidiTrack::outDebug(const String &message)const
|
||||
{
|
||||
if(!mIsDebug)return;
|
||||
::OutputDebugString(String("[MidiTrack]")+message+String("\n"));
|
||||
}
|
||||
|
||||
// virtuals
|
||||
|
||||
void MidiTrack::setTempo(DWORD /*microsecondsPerQuarterNote*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void MidiTrack::midiChannelMessage(PureEvent &/*channelEvent*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void MidiTrack::timeSignature(const TimeInfo &/*someTimeInfo*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void MidiTrack::smpteFormat(const SMPTEFormat &/*someSMPTEFormat*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
127
midiseq/safe/MIDITRCK.HPP
Normal file
127
midiseq/safe/MIDITRCK.HPP
Normal file
@@ -0,0 +1,127 @@
|
||||
#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);
|
||||
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 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(true)
|
||||
{
|
||||
}
|
||||
|
||||
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
|
||||
4
midiseq/safe/MIDITRK.CPP
Normal file
4
midiseq/safe/MIDITRK.CPP
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
WORD readTrack(FILE *lpFilePointer);
|
||||
|
||||
|
||||
12
midiseq/safe/NOTE.HPP
Normal file
12
midiseq/safe/NOTE.HPP
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _MIDISEQ_NOTE_HPP_
|
||||
#define _MIDISEQ_NOTE_HPP_
|
||||
#ifndef _MIDISEQ_PURENOTE_HPP_
|
||||
#include <midiseq/purenote.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_NOTEON_HPP_
|
||||
#include <midiseq/noteon.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_NOTEOFF_HPP_
|
||||
#include <midiseq/noteoff.hpp>
|
||||
#endif
|
||||
#endif
|
||||
33
midiseq/safe/PUREEVNT.CPP
Normal file
33
midiseq/safe/PUREEVNT.CPP
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <midiseq/pureevnt.hpp>
|
||||
#include <common/stdio.hpp>
|
||||
|
||||
//PureEvent::operator String(void)
|
||||
String PureEvent::toString(void)const
|
||||
{
|
||||
String pureEventString;
|
||||
String eventString;
|
||||
|
||||
pureEventString.reserve(1024);
|
||||
switch(eventType()&0xF0)
|
||||
{
|
||||
case MIDIChannelPressure : {eventString="MIDIChannelPressure";break;}
|
||||
case MIDIProgramChange : {eventString="MIDIProgramChange";break;}
|
||||
case MIDIKeyPressure : {eventString="MIDIKeyPressure";break;}
|
||||
case MIDIParameter : {eventString="MIDIParameter";break;}
|
||||
case MIDIPitchBend : {eventString="MIDIPitchBend";break;}
|
||||
case MIDINoteOff : {eventString="MIDINoteOff";break;}
|
||||
case MIDINoteOn : {eventString="MIDINoteOn";break;}
|
||||
default : {eventString="UNKNOWN MIDICHANNEL MESSAGE";break;}
|
||||
}
|
||||
::sprintf(pureEventString,
|
||||
"eventType:%3d [% 20s] deltaTime:%5ld playTime:%d channel:%2d byteOne:%3d byteTwo:%3d midiTime:%10ld",
|
||||
(short)eventType(),
|
||||
(LPSTR)eventString,
|
||||
deltaTime(),
|
||||
playTime(),
|
||||
(short)channel(),
|
||||
(short)firstData(),
|
||||
(short)secondData(),
|
||||
midiTime());
|
||||
return pureEventString;
|
||||
}
|
||||
212
midiseq/safe/PUREEVNT.HPP
Normal file
212
midiseq/safe/PUREEVNT.HPP
Normal file
@@ -0,0 +1,212 @@
|
||||
#ifndef _MIDISEQ_PUREEVENT_HPP_
|
||||
#define _MIDISEQ_PUREEVENT_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_MIDICHANNELMESSAGE_HPP_
|
||||
#include <midiseq/midimsg.hpp>
|
||||
#endif
|
||||
|
||||
class PureEvent
|
||||
{
|
||||
public:
|
||||
PureEvent(void);
|
||||
PureEvent(const PureEvent &somePureEvent);
|
||||
PureEvent(BYTE eventType,DWORD deltaTime,BYTE channel,BYTE firstData,BYTE secondData);
|
||||
virtual ~PureEvent();
|
||||
BYTE eventType(void)const;
|
||||
DWORD deltaTime(void)const;
|
||||
DWORD playTime(void)const;
|
||||
BYTE channel(void)const;
|
||||
BYTE firstData(void)const;
|
||||
BYTE secondData(void)const;
|
||||
DWORD midiTime(void)const;
|
||||
void eventType(BYTE eventType);
|
||||
void deltaTime(DWORD deltaTime);
|
||||
void playTime(DWORD playTime);
|
||||
void channel(BYTE channel);
|
||||
void firstData(BYTE firstData);
|
||||
void secondData(BYTE secondData);
|
||||
void midiTime(DWORD midiTime);
|
||||
WORD operator==(const PureEvent &somePureEvent)const;
|
||||
WORD operator<(const PureEvent &somePureEvent)const;
|
||||
WORD operator>(const PureEvent &somePureEvent)const;
|
||||
String toString(void)const;
|
||||
PureEvent &operator=(const PureEvent &somePureEvent);
|
||||
private:
|
||||
BYTE mEventType;
|
||||
DWORD mDeltaTime;
|
||||
BYTE mChannel;
|
||||
BYTE mFirstData;
|
||||
BYTE mSecondData;
|
||||
DWORD mPlayTime;
|
||||
DWORD mMIDITime;
|
||||
};
|
||||
|
||||
inline
|
||||
PureEvent::PureEvent(void)
|
||||
: mEventType(0), mDeltaTime(0L), mChannel(0), mFirstData(0), mSecondData(0),
|
||||
mPlayTime(0L), mMIDITime(0L)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
PureEvent::PureEvent(const PureEvent &somePureEvent)
|
||||
: mEventType(somePureEvent.mEventType), mDeltaTime(somePureEvent.mDeltaTime),
|
||||
mPlayTime(somePureEvent.mPlayTime), mChannel(somePureEvent.mChannel),
|
||||
mFirstData(somePureEvent.mFirstData), mSecondData(somePureEvent.mSecondData),
|
||||
mMIDITime(somePureEvent.mMIDITime)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
PureEvent::PureEvent(BYTE eventType,DWORD deltaTime,BYTE channel,BYTE firstData,BYTE secondData)
|
||||
: mEventType(eventType), mDeltaTime(deltaTime), mChannel(channel), mFirstData(firstData),
|
||||
mSecondData(secondData), mPlayTime(0L), mMIDITime(0L)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
PureEvent::~PureEvent()
|
||||
{
|
||||
}
|
||||
|
||||
// accessors
|
||||
|
||||
inline
|
||||
BYTE PureEvent::eventType(void)const
|
||||
{
|
||||
return mEventType;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD PureEvent::deltaTime(void)const
|
||||
{
|
||||
return mDeltaTime;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD PureEvent::playTime(void)const
|
||||
{
|
||||
return mPlayTime;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD PureEvent::midiTime(void)const
|
||||
{
|
||||
return mMIDITime;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE PureEvent::channel(void)const
|
||||
{
|
||||
return mChannel;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE PureEvent::firstData(void)const
|
||||
{
|
||||
return mFirstData;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE PureEvent::secondData(void)const
|
||||
{
|
||||
return mSecondData;
|
||||
}
|
||||
|
||||
// mutators
|
||||
|
||||
inline
|
||||
void PureEvent::eventType(BYTE eventType)
|
||||
{
|
||||
mEventType=eventType;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureEvent::deltaTime(DWORD deltaTime)
|
||||
{
|
||||
mDeltaTime=deltaTime;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureEvent::playTime(DWORD playTime)
|
||||
{
|
||||
mPlayTime=playTime;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureEvent::midiTime(DWORD midiTime)
|
||||
{
|
||||
mMIDITime=midiTime;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureEvent::channel(BYTE channel)
|
||||
{
|
||||
mChannel=channel;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureEvent::firstData(BYTE firstData)
|
||||
{
|
||||
mFirstData=firstData;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureEvent::secondData(BYTE secondData)
|
||||
{
|
||||
mSecondData=secondData;
|
||||
}
|
||||
|
||||
// comparators
|
||||
|
||||
inline
|
||||
WORD PureEvent::operator==(const PureEvent &somePureEvent)const
|
||||
{
|
||||
return mPlayTime==somePureEvent.mPlayTime&&eventType()==somePureEvent.eventType();
|
||||
/* return (mEventType==somePureEvent.mEventType&&
|
||||
mChannel==somePureEvent.mChannel&&
|
||||
mFirstData==somePureEvent.mFirstData&&
|
||||
mSecondData==somePureEvent.mSecondData&&
|
||||
mDeltaTime==somePureEvent.mDeltaTime&&
|
||||
mPlayTime==somePureEvent.mPlayTime&&
|
||||
mMIDITime==somePureEvent.mMIDITime);
|
||||
*/
|
||||
}
|
||||
|
||||
inline
|
||||
PureEvent &PureEvent::operator=(const PureEvent &somePureEvent)
|
||||
{
|
||||
eventType(somePureEvent.eventType());
|
||||
deltaTime(somePureEvent.deltaTime());
|
||||
playTime(somePureEvent.playTime());
|
||||
midiTime(somePureEvent.midiTime());
|
||||
channel(somePureEvent.channel());
|
||||
firstData(somePureEvent.firstData());
|
||||
secondData(somePureEvent.secondData());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD PureEvent::operator<(const PureEvent &somePureEvent)const
|
||||
{
|
||||
if(mPlayTime==somePureEvent.mPlayTime&&eventType()==somePureEvent.eventType())return false;
|
||||
if(mPlayTime==somePureEvent.mPlayTime&&eventType()==MIDINoteOff)return true;
|
||||
else if(mPlayTime==somePureEvent.mPlayTime)return false;
|
||||
return (mPlayTime<somePureEvent.mPlayTime);
|
||||
}
|
||||
|
||||
inline
|
||||
WORD PureEvent::operator>(const PureEvent &somePureEvent)const
|
||||
{
|
||||
if(mPlayTime==somePureEvent.mPlayTime&&eventType()==somePureEvent.eventType())return false;
|
||||
if(mPlayTime==somePureEvent.mPlayTime&&eventType()==MIDINoteOn)return true;
|
||||
else if(mPlayTime==somePureEvent.mPlayTime)return false;
|
||||
return (mPlayTime>somePureEvent.mPlayTime);
|
||||
}
|
||||
#endif
|
||||
|
||||
31
midiseq/safe/PUREHDR.CPP
Normal file
31
midiseq/safe/PUREHDR.CPP
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <midiseq/purehdr.hpp>
|
||||
|
||||
WORD PureHeader::readHeader(FileIO &midiFile)
|
||||
{
|
||||
if(!midiFile.read(mHeader,sizeof(mHeader)))return FALSE;
|
||||
if(!midiFile.read(mLengthData))return FALSE;
|
||||
if(!midiFile.read(mSMFType))return FALSE;
|
||||
if(!midiFile.read(mTracks))return FALSE;
|
||||
if(!midiFile.read(mMethod))return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
String PureHeader::toString()const
|
||||
{
|
||||
String strWork;
|
||||
String strHeader;
|
||||
strHeader+=mHeader;
|
||||
strHeader+="\nLength:";
|
||||
strHeader+=String().fromInt(mLengthData);
|
||||
strHeader+="\nType:";
|
||||
if(SingleMultiChannel==MIDIFormat(mSMFType))strHeader+="SingleMultiChannel";
|
||||
else if(SimultaneousTracks==MIDIFormat(mSMFType))strHeader+="SimultaneousTracks";
|
||||
else if(SequentialTracks==MIDIFormat(mSMFType))strHeader+="Sequential";
|
||||
else strHeader+="Unknown";
|
||||
strHeader+="\nTracks:";
|
||||
strHeader+=String().fromInt(mTracks);
|
||||
strHeader+="\nMethod:";
|
||||
::sprintf(strWork," Hi:0x%04lx Lo:0x%04lx",(mMethod>>8)&0xFF,mMethod&0xFF);
|
||||
strHeader+=String().fromInt(mMethod)+strWork;
|
||||
return strHeader;
|
||||
}
|
||||
135
midiseq/safe/PUREHDR.HPP
Normal file
135
midiseq/safe/PUREHDR.HPP
Normal file
@@ -0,0 +1,135 @@
|
||||
#ifndef _MIDISEQ_PUREHEADER_HPP_
|
||||
#define _MIDISEQ_PUREHEADER_HPP_
|
||||
#include <string.h>
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FILEIO_HPP_
|
||||
#include <common/fileio.hpp>
|
||||
#endif
|
||||
|
||||
class PureHeader
|
||||
{
|
||||
public:
|
||||
enum Method{TimeCode,DeltaTime,Unset};
|
||||
enum MIDIFormat{SingleMultiChannel,SimultaneousTracks,SequentialTracks};
|
||||
PureHeader(void);
|
||||
PureHeader(const PureHeader &somePureHeader);
|
||||
virtual ~PureHeader();
|
||||
PureHeader &operator=(const PureHeader &somePureHeader);
|
||||
WORD operator==(const PureHeader &somePureHeader);
|
||||
DWORD lengthData(void)const;
|
||||
MIDIFormat smfType(void)const;
|
||||
USHORT tracks(void)const;
|
||||
USHORT method(void)const;
|
||||
Method timingMethod(void)const;
|
||||
String toString(void)const;
|
||||
protected:
|
||||
WORD readHeader(FileIO &midiFile);
|
||||
private:
|
||||
enum {MaxHeaderIDLength=4};
|
||||
void method(USHORT method);
|
||||
void lengthData(DWORD lengthData);
|
||||
void smfType(USHORT smfType);
|
||||
void tracks(USHORT smfType);
|
||||
|
||||
char mHeader[MaxHeaderIDLength];
|
||||
DWORD mLengthData;
|
||||
USHORT mSMFType;
|
||||
USHORT mTracks;
|
||||
USHORT mMethod;
|
||||
};
|
||||
|
||||
inline
|
||||
PureHeader::PureHeader(void)
|
||||
: mLengthData(0L), mSMFType(0), mTracks(0), mMethod(0)
|
||||
{
|
||||
::memset(mHeader,0,sizeof(mHeader));
|
||||
}
|
||||
|
||||
inline
|
||||
PureHeader::PureHeader(const PureHeader &somePureHeader)
|
||||
{
|
||||
*this=somePureHeader;
|
||||
}
|
||||
|
||||
inline
|
||||
PureHeader::~PureHeader()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
PureHeader &PureHeader::operator=(const PureHeader &somePureHeader)
|
||||
{
|
||||
lengthData(somePureHeader.lengthData());
|
||||
smfType(somePureHeader.smfType());
|
||||
tracks(somePureHeader.tracks());
|
||||
method(somePureHeader.method());
|
||||
::memcpy(mHeader,somePureHeader.mHeader,sizeof(mHeader));
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD PureHeader::operator==(const PureHeader &somePureHeader)
|
||||
{
|
||||
return (lengthData()==somePureHeader.lengthData()&&
|
||||
smfType()==somePureHeader.smfType()&&
|
||||
tracks()==somePureHeader.tracks()&&
|
||||
method()==somePureHeader.method()&&
|
||||
(0==::memcmp(mHeader,somePureHeader.mHeader,sizeof(mHeader))));
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD PureHeader::lengthData(void)const
|
||||
{
|
||||
return mLengthData;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureHeader::lengthData(DWORD lengthData)
|
||||
{
|
||||
mLengthData=lengthData;
|
||||
}
|
||||
|
||||
inline
|
||||
PureHeader::MIDIFormat PureHeader::smfType(void)const
|
||||
{
|
||||
return (MIDIFormat)mSMFType;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureHeader::smfType(USHORT smfType)
|
||||
{
|
||||
mSMFType=smfType;
|
||||
}
|
||||
|
||||
inline
|
||||
USHORT PureHeader::tracks(void)const
|
||||
{
|
||||
return mTracks;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureHeader::tracks(USHORT tracks)
|
||||
{
|
||||
mTracks=tracks;
|
||||
}
|
||||
|
||||
inline
|
||||
USHORT PureHeader::method(void)const
|
||||
{
|
||||
return mMethod;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureHeader::method(USHORT method)
|
||||
{
|
||||
mMethod=method;
|
||||
}
|
||||
|
||||
inline
|
||||
PureHeader::Method PureHeader::timingMethod(void)const
|
||||
{
|
||||
return ((mMethod>>15)?TimeCode:DeltaTime);
|
||||
}
|
||||
#endif
|
||||
93
midiseq/safe/PURENOTE.HPP
Normal file
93
midiseq/safe/PURENOTE.HPP
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef _MIDISEQ_PURENOTE_HPP_
|
||||
#define _MIDISEQ_PURENOTE_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FILEIO_HPP_
|
||||
#include <common/fileio.hpp>
|
||||
#endif
|
||||
|
||||
class PureNote
|
||||
{
|
||||
public:
|
||||
enum {PureNoteLength=2};
|
||||
PureNote(void);
|
||||
PureNote(BYTE pitch,BYTE velocity);
|
||||
virtual ~PureNote();
|
||||
BYTE pitch(void)const;
|
||||
void pitch(BYTE pitch);
|
||||
BYTE velocity(void)const;
|
||||
void velocity(BYTE velocity);
|
||||
PureNote &operator=(const PureNote &somePureNote);
|
||||
WORD operator==(const PureNote &somePureNote)const;
|
||||
FileIO &operator<<(FileIO &someFileIO);
|
||||
private:
|
||||
BYTE mPitch;
|
||||
BYTE mVelocity;
|
||||
};
|
||||
|
||||
inline
|
||||
PureNote::PureNote(void)
|
||||
: mPitch(0), mVelocity(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
PureNote::PureNote(BYTE pitch,BYTE velocity)
|
||||
: mPitch(pitch), mVelocity(velocity)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
PureNote::~PureNote()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE PureNote::pitch(void)const
|
||||
{
|
||||
return mPitch;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE PureNote::velocity(void)const
|
||||
{
|
||||
return mVelocity;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureNote::pitch(BYTE pitch)
|
||||
{
|
||||
mPitch=pitch;
|
||||
}
|
||||
|
||||
inline
|
||||
void PureNote::velocity(BYTE velocity)
|
||||
{
|
||||
mVelocity=velocity;
|
||||
}
|
||||
|
||||
inline
|
||||
PureNote &PureNote::operator=(const PureNote &somePureNote)
|
||||
{
|
||||
pitch(somePureNote.pitch());
|
||||
velocity(somePureNote.velocity());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD PureNote::operator==(const PureNote &somePureNote)const
|
||||
{
|
||||
return (pitch()==somePureNote.pitch()&&
|
||||
velocity()==somePureNote.velocity());
|
||||
}
|
||||
|
||||
inline
|
||||
FileIO &PureNote::operator<<(FileIO &someFileIO)
|
||||
{
|
||||
someFileIO.read(mPitch);
|
||||
someFileIO.read(mVelocity);
|
||||
return someFileIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
35
midiseq/safe/ProgramChange.hpp
Normal file
35
midiseq/safe/ProgramChange.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef _MIDISEQ_PROGRAMCHANGE_HPP_
|
||||
#define _MIDISEQ_PROGRAMCHANGE_HPP_
|
||||
#ifndef _MIDISEQ_PUREEVENT_HPP_
|
||||
#include <midiseq/pureevnt.hpp>
|
||||
#endif
|
||||
|
||||
class ProgramChange
|
||||
{
|
||||
public:
|
||||
ProgramChange();
|
||||
ProgramChange(BYTE programNumber);
|
||||
PureEvent getEvent(BYTE deltaTime=0,BYTE channel=0)const;
|
||||
private:
|
||||
BYTE mProgramNumber;
|
||||
};
|
||||
|
||||
inline
|
||||
ProgramChange::ProgramChange()
|
||||
: mProgramNumber(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
ProgramChange::ProgramChange(BYTE programNumber)
|
||||
: mProgramNumber(programNumber)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
PureEvent ProgramChange::getEvent(BYTE deltaTime,BYTE channel)const
|
||||
{
|
||||
PureEvent pureEvent(MIDIProgramChange,deltaTime,channel,mProgramNumber,0);
|
||||
return pureEvent;
|
||||
}
|
||||
#endif
|
||||
159
midiseq/safe/SMPTE.HPP
Normal file
159
midiseq/safe/SMPTE.HPP
Normal file
@@ -0,0 +1,159 @@
|
||||
#ifndef _MIDISEQ_SMPTEFORMAT_HPP_
|
||||
#define _MIDISEQ_SMPTEFORMAT_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_FILEIO_HPP_
|
||||
#include <common/fileio.hpp>
|
||||
#endif
|
||||
|
||||
class SMPTEFormat
|
||||
{
|
||||
public:
|
||||
enum {SMPTEFormatLength=5};
|
||||
SMPTEFormat(void);
|
||||
SMPTEFormat(const SMPTEFormat &someSMPTEFormat);
|
||||
virtual ~SMPTEFormat();
|
||||
SMPTEFormat &operator=(const SMPTEFormat &someSMPTEFormat);
|
||||
WORD operator==(const SMPTEFormat &someSMPTEFormat)const;
|
||||
FileIO &operator<<(FileIO &midiFile);
|
||||
BYTE hours(void)const;
|
||||
void hours(BYTE hours);
|
||||
BYTE minutes(void)const;
|
||||
void minutes(BYTE minutes);
|
||||
BYTE seconds(void)const;
|
||||
void seconds(BYTE seconds);
|
||||
BYTE frames(void)const;
|
||||
void frames(BYTE frames);
|
||||
BYTE hundredthFrames(void)const;
|
||||
void hundredthFrames(BYTE hundredthFrames);
|
||||
String toString(void)const;
|
||||
private:
|
||||
BYTE mHours;
|
||||
BYTE mMinutes;
|
||||
BYTE mSeconds;
|
||||
BYTE mFrames;
|
||||
BYTE mHundredthFrames;
|
||||
};
|
||||
|
||||
inline
|
||||
SMPTEFormat::SMPTEFormat(void)
|
||||
: mHours(0), mMinutes(0), mSeconds(0), mFrames(0), mHundredthFrames(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SMPTEFormat::SMPTEFormat(const SMPTEFormat &someSMPTEFormat)
|
||||
{
|
||||
*this=someSMPTEFormat;
|
||||
}
|
||||
|
||||
inline
|
||||
SMPTEFormat::~SMPTEFormat()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
SMPTEFormat &SMPTEFormat::operator=(const SMPTEFormat &someSMPTEFormat)
|
||||
{
|
||||
hours(someSMPTEFormat.hours());
|
||||
minutes(someSMPTEFormat.minutes());
|
||||
seconds(someSMPTEFormat.seconds());
|
||||
frames(someSMPTEFormat.frames());
|
||||
hundredthFrames(someSMPTEFormat.hundredthFrames());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD SMPTEFormat::operator==(const SMPTEFormat &someSMPTEFormat)const
|
||||
{
|
||||
return (hours()==someSMPTEFormat.hours()&&
|
||||
minutes()==someSMPTEFormat.minutes()&&
|
||||
seconds()==someSMPTEFormat.seconds()&&
|
||||
frames()==someSMPTEFormat.frames()&&
|
||||
hundredthFrames()==someSMPTEFormat.hundredthFrames());
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE SMPTEFormat::hours(void)const
|
||||
{
|
||||
return mHours;
|
||||
}
|
||||
|
||||
inline
|
||||
void SMPTEFormat::hours(BYTE hours)
|
||||
{
|
||||
mHours=hours;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE SMPTEFormat::minutes(void)const
|
||||
{
|
||||
return mMinutes;
|
||||
}
|
||||
|
||||
inline
|
||||
void SMPTEFormat::minutes(BYTE minutes)
|
||||
{
|
||||
mMinutes=minutes;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE SMPTEFormat::seconds(void)const
|
||||
{
|
||||
return mSeconds;
|
||||
}
|
||||
|
||||
inline
|
||||
void SMPTEFormat::seconds(BYTE seconds)
|
||||
{
|
||||
mSeconds=seconds;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE SMPTEFormat::frames(void)const
|
||||
{
|
||||
return mFrames;
|
||||
}
|
||||
|
||||
inline
|
||||
void SMPTEFormat::frames(BYTE frames)
|
||||
{
|
||||
mFrames=frames;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE SMPTEFormat::hundredthFrames(void)const
|
||||
{
|
||||
return mHundredthFrames;
|
||||
}
|
||||
|
||||
inline
|
||||
void SMPTEFormat::hundredthFrames(BYTE hundredthFrames)
|
||||
{
|
||||
mHundredthFrames=hundredthFrames;
|
||||
}
|
||||
|
||||
inline
|
||||
FileIO &SMPTEFormat::operator<<(FileIO &midiFile)
|
||||
{
|
||||
midiFile.read(mHours);
|
||||
midiFile.read(mMinutes);
|
||||
midiFile.read(mSeconds);
|
||||
midiFile.read(mFrames);
|
||||
midiFile.read(mHundredthFrames);
|
||||
return midiFile;
|
||||
}
|
||||
|
||||
inline
|
||||
String SMPTEFormat::toString(void)const
|
||||
{
|
||||
String string;
|
||||
String sep(", ");
|
||||
|
||||
::sprintf(string,"%02d:%02d.%02d",mHours,mMinutes,mSeconds);
|
||||
string+=" Frames="+String().fromInt(mFrames)+sep;
|
||||
string+=" HFrames="+String().fromInt(mHundredthFrames);
|
||||
return string;
|
||||
}
|
||||
#endif
|
||||
20
midiseq/safe/STDTMPL.CPP
Normal file
20
midiseq/safe/STDTMPL.CPP
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _MSC_VER
|
||||
#define _EXPAND_BLOCK_TEMPLATES_
|
||||
#define _EXPAND_VECTOR_TEMPLATES_
|
||||
#include <common/pvector.hpp>
|
||||
#include <common/pvector.tpp>
|
||||
#include <common/block.hpp>
|
||||
#include <common/block.tpp>
|
||||
#include <common/callback.hpp>
|
||||
#include <common/callback.tpp>
|
||||
#include <common/wintimer.hpp>
|
||||
#include <common/qsort.hpp>
|
||||
#include <common/qsort.tpp>
|
||||
#include <midiseq/pureevnt.hpp>
|
||||
#include <midiseq/mididata.hpp>
|
||||
|
||||
typedef Block<PureEvent> a;
|
||||
typedef PureVector<PureEvent> b;
|
||||
typedef QuickSort<PureEvent> c;
|
||||
typedef Callback<MidiData> d;
|
||||
#endif
|
||||
87
midiseq/safe/TEMPO.HPP
Normal file
87
midiseq/safe/TEMPO.HPP
Normal file
@@ -0,0 +1,87 @@
|
||||
#ifndef _MIDISEQ_TEMPOCHANGE_HPP_
|
||||
#define _MIDISEQ_TEMPOCHANGE_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
class TempoChange
|
||||
{
|
||||
public:
|
||||
TempoChange(void);
|
||||
TempoChange(DWORD microsecsPerQtrNote,DWORD eventIndex);
|
||||
TempoChange(const TempoChange &someTempoChange);
|
||||
virtual ~TempoChange();
|
||||
TempoChange &operator=(const TempoChange &someTempoChange);
|
||||
WORD operator==(const TempoChange &someTempoChange)const;
|
||||
DWORD microsecsPerQtrNote(void)const;
|
||||
void microsecsPerQtrNote(DWORD microsecsPerQtrNote);
|
||||
DWORD eventIndex(void)const;
|
||||
void eventIndex(DWORD eventIndex);
|
||||
private:
|
||||
DWORD mMicrosecsPerQtrNote;
|
||||
DWORD mEventIndex;
|
||||
};
|
||||
|
||||
inline
|
||||
TempoChange::TempoChange(void)
|
||||
: mMicrosecsPerQtrNote(0), mEventIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
TempoChange::TempoChange(DWORD microsecsPerQtrNote,DWORD eventIndex)
|
||||
: mMicrosecsPerQtrNote(microsecsPerQtrNote), mEventIndex(eventIndex)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
TempoChange::TempoChange(const TempoChange &someTempoChange)
|
||||
{
|
||||
*this=someTempoChange;
|
||||
}
|
||||
|
||||
inline
|
||||
TempoChange::~TempoChange()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
TempoChange &TempoChange::operator=(const TempoChange &someTempoChange)
|
||||
{
|
||||
microsecsPerQtrNote(someTempoChange.microsecsPerQtrNote());
|
||||
eventIndex(someTempoChange.eventIndex());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD TempoChange::operator==(const TempoChange &someTempoChange)const
|
||||
{
|
||||
return (microsecsPerQtrNote()==someTempoChange.microsecsPerQtrNote()&&
|
||||
eventIndex()==someTempoChange.eventIndex());
|
||||
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD TempoChange::microsecsPerQtrNote(void)const
|
||||
{
|
||||
return mMicrosecsPerQtrNote;
|
||||
}
|
||||
|
||||
inline
|
||||
void TempoChange::microsecsPerQtrNote(DWORD microsecsPerQtrNote)
|
||||
{
|
||||
mMicrosecsPerQtrNote=microsecsPerQtrNote;
|
||||
}
|
||||
|
||||
inline
|
||||
DWORD TempoChange::eventIndex(void)const
|
||||
{
|
||||
return mEventIndex;
|
||||
}
|
||||
|
||||
inline
|
||||
void TempoChange::eventIndex(DWORD eventIndex)
|
||||
{
|
||||
mEventIndex=eventIndex;
|
||||
}
|
||||
#endif
|
||||
83
midiseq/safe/TIMEBLCK.CPP
Normal file
83
midiseq/safe/TIMEBLCK.CPP
Normal file
@@ -0,0 +1,83 @@
|
||||
#include <common/string.hpp>
|
||||
#include <common/qsort.hpp>
|
||||
#include <common/openfile.hpp>
|
||||
#include <midiseq/timeblck.hpp>
|
||||
#include <midiseq/midimsg.hpp>
|
||||
#include <midiseq/midiblck.hpp>
|
||||
|
||||
void TimeBlock::fixTimeBlock(MIDIBlock &midiEventBlocks,Array<PureEvent> &sortedEvents)
|
||||
{
|
||||
midiEventBlocks.printBlock("MIDIEvents.DAT");
|
||||
|
||||
for(short index=0;index<MIDIBlock::MaxChannels;index++)
|
||||
{
|
||||
fixTimeBlock(midiEventBlocks[index]);
|
||||
}
|
||||
midiEventBlocks.printBlock("MIDIEvents2.DAT");
|
||||
sortBlocks(midiEventBlocks,sortedEvents);
|
||||
calculateRealTime(sortedEvents);
|
||||
printBlock("MIDITimeEvents.DAT",sortedEvents);
|
||||
}
|
||||
|
||||
void TimeBlock::fixTimeBlock(EventBlock &midiEventBlock)
|
||||
{
|
||||
size_t eventCount((size_t)midiEventBlock.size());
|
||||
DWORD eventTime(0L);
|
||||
|
||||
if(!eventCount)return;
|
||||
for(short index=0;index<eventCount;index++)
|
||||
{
|
||||
eventTime+=(midiEventBlock[index].deltaTime());
|
||||
midiEventBlock[index].playTime(eventTime);
|
||||
}
|
||||
}
|
||||
|
||||
void TimeBlock::sortBlocks(MIDIBlock &midiEventBlocks,Array<PureEvent> &sortedEvents)
|
||||
{
|
||||
DWORD maxEvents(0L);
|
||||
DWORD runningCount(0L);
|
||||
DWORD eventCount;
|
||||
QuickSort<PureEvent> eventSorter;
|
||||
|
||||
for(DWORD index=0;index<MIDIBlock::MaxChannels;index++)maxEvents+=midiEventBlocks[(WORD)index].size();
|
||||
sortedEvents.size(maxEvents);
|
||||
for(index=0;index<MIDIBlock::MaxChannels;index++)
|
||||
{
|
||||
eventCount=midiEventBlocks[(WORD)index].size();
|
||||
if(!eventCount)continue;
|
||||
for(DWORD eventIndex=0;eventIndex<eventCount;eventIndex++)
|
||||
sortedEvents[runningCount++]=(midiEventBlocks[(WORD)index])[eventIndex];
|
||||
}
|
||||
if(!sortedEvents.size())return;
|
||||
eventSorter.sortItems(sortedEvents);
|
||||
}
|
||||
|
||||
void TimeBlock::calculateRealTime(Array<PureEvent> &eventBlock)
|
||||
{
|
||||
DWORD numEvents(eventBlock.size());
|
||||
DWORD playTime;
|
||||
double realTime;
|
||||
|
||||
if(!numEvents)return;
|
||||
for(DWORD eventIndex=0;eventIndex<numEvents;eventIndex++)
|
||||
{
|
||||
playTime=eventBlock[eventIndex].playTime();
|
||||
realTime=((((double)mTempo*(double)playTime)/(double)mDivision)/1000.00)+(double)mStartTime;
|
||||
eventBlock[eventIndex].playTime((DWORD)realTime);
|
||||
}
|
||||
}
|
||||
|
||||
void TimeBlock::printBlock(String pathFileName,Array<PureEvent> &eventVector)
|
||||
{
|
||||
FileHandle writeFile(pathFileName,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite);
|
||||
WORD eventCount((WORD)eventVector.size());
|
||||
String lineBuffer;
|
||||
|
||||
::sprintf(lineBuffer,"start time:%ld",mStartTime);
|
||||
writeFile.writeLine(lineBuffer);
|
||||
for(short itemIndex=0;itemIndex<eventCount;itemIndex++)
|
||||
{
|
||||
String eventString(eventVector[itemIndex].toString());
|
||||
writeFile.writeLine(eventString);
|
||||
}
|
||||
}
|
||||
80
midiseq/safe/TIMEBLCK.HPP
Normal file
80
midiseq/safe/TIMEBLCK.HPP
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef _MIDISEQ_TIMEBLOCK_HPP_
|
||||
#define _MIDISEQ_TIMEBLOCK_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_PUREEVENT_HPP_
|
||||
#include <midiseq/pureevnt.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_EVENTBLOCK_HPP_
|
||||
#include <midiseq/evntblck.hpp>
|
||||
#endif
|
||||
|
||||
class MIDIBlock;
|
||||
|
||||
class TimeBlock
|
||||
{
|
||||
public:
|
||||
TimeBlock(void);
|
||||
virtual ~TimeBlock();
|
||||
void setStartTime(DWORD startTime);
|
||||
void setTempo(DWORD tempo);
|
||||
void setDivision(DWORD division);
|
||||
void fixTimeBlock(MIDIBlock &midiEvents,Array<PureEvent> &sortedEvents);
|
||||
void printBlock(String pathFileName,Array<PureEvent> &eventVector);
|
||||
private:
|
||||
void fixTimeBlock(EventBlock &midiEventBlock);
|
||||
void sortBlocks(MIDIBlock &midiEventBlocks,Array<PureEvent> &sortedEvents);
|
||||
void calculateRealTime(Array<PureEvent> &eventBlock);
|
||||
void dumpTimeVector(Array<PureEvent> &eventBlock,String pathFileName);
|
||||
void operator=(const TimeBlock &someTimeBlock);
|
||||
|
||||
DWORD mTempo;
|
||||
DWORD mDivision;
|
||||
DWORD mStartTime;
|
||||
};
|
||||
|
||||
inline
|
||||
TimeBlock::TimeBlock(void)
|
||||
: mStartTime(0L), mTempo(5000000L), mDivision(136L)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
TimeBlock::~TimeBlock()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
void TimeBlock::setStartTime(DWORD startTime)
|
||||
{
|
||||
mStartTime=startTime;
|
||||
}
|
||||
|
||||
inline
|
||||
void TimeBlock::setTempo(DWORD tempo)
|
||||
{
|
||||
mTempo=tempo;
|
||||
}
|
||||
|
||||
inline
|
||||
void TimeBlock::setDivision(DWORD division)
|
||||
{
|
||||
mDivision=division;
|
||||
}
|
||||
|
||||
inline
|
||||
void TimeBlock::operator=(const TimeBlock &/*someTimeBlock*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
138
midiseq/safe/TIMEINFO.HPP
Normal file
138
midiseq/safe/TIMEINFO.HPP
Normal file
@@ -0,0 +1,138 @@
|
||||
#ifndef _MIDISEQ_TIMEINFO_HPP_
|
||||
#define _MIDISEQ_TIMEINFO_HPP_
|
||||
#ifndef _COMMON_WINDOWS_HPP_
|
||||
#include <common/windows.hpp>
|
||||
#endif
|
||||
|
||||
class TimeInfo
|
||||
{
|
||||
public:
|
||||
enum {LengthTimeInfo=4};
|
||||
TimeInfo(void);
|
||||
TimeInfo(const TimeInfo &someTimeInfo);
|
||||
TimeInfo(BYTE numerator,BYTE denominator,BYTE midiClocksPerMetronome,BYTE thirtySecondNotesPerQtrNote);
|
||||
virtual ~TimeInfo();
|
||||
TimeInfo &operator=(const TimeInfo &someTimeInfo);
|
||||
WORD operator==(const TimeInfo &someTimeInfo)const;
|
||||
BYTE numerator(void)const;
|
||||
void numerator(BYTE numerator);
|
||||
BYTE denominator(void)const;
|
||||
void denominator(BYTE denominator);
|
||||
BYTE midiClocksPerMetronome(void)const;
|
||||
void midiClocksPerMetronome(BYTE midiClocksPerMetronome);
|
||||
BYTE thirtySecondNotesPerQtrNote(void)const;
|
||||
void thirtySecondNotesPerQtrNote(BYTE thirtySecondNotesPerQtrNote);
|
||||
String toString(void)const;
|
||||
private:
|
||||
enum{MidiClocksPerQtrNote=24};
|
||||
BYTE mNumerator;
|
||||
BYTE mDenominator;
|
||||
BYTE mMidiClocksPerMetronome;
|
||||
BYTE mThirtySecondNotesPerQtrNote;
|
||||
};
|
||||
|
||||
inline
|
||||
TimeInfo::TimeInfo(void)
|
||||
: mNumerator(0), mDenominator(0), mMidiClocksPerMetronome(0),
|
||||
mThirtySecondNotesPerQtrNote(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
TimeInfo::TimeInfo(BYTE numerator,BYTE denominator,BYTE midiClocksPerMetronome,BYTE thirtySecondNotesPerQtrNote)
|
||||
: mNumerator(numerator), mDenominator(denominator),
|
||||
mMidiClocksPerMetronome(midiClocksPerMetronome),
|
||||
mThirtySecondNotesPerQtrNote(thirtySecondNotesPerQtrNote)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
TimeInfo::TimeInfo(const TimeInfo &someTimeInfo)
|
||||
{
|
||||
*this=someTimeInfo;
|
||||
}
|
||||
|
||||
inline
|
||||
TimeInfo::~TimeInfo()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
TimeInfo &TimeInfo::operator=(const TimeInfo &someTimeInfo)
|
||||
{
|
||||
numerator(someTimeInfo.numerator());
|
||||
denominator(someTimeInfo.denominator());
|
||||
midiClocksPerMetronome(someTimeInfo.midiClocksPerMetronome());
|
||||
thirtySecondNotesPerQtrNote(someTimeInfo.thirtySecondNotesPerQtrNote());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD TimeInfo::operator==(const TimeInfo &someTimeInfo)const
|
||||
{
|
||||
return (numerator()==someTimeInfo.numerator()&&
|
||||
denominator()==someTimeInfo.denominator()&&
|
||||
midiClocksPerMetronome()==someTimeInfo.midiClocksPerMetronome()&&
|
||||
thirtySecondNotesPerQtrNote()==someTimeInfo.thirtySecondNotesPerQtrNote());
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE TimeInfo::numerator(void)const
|
||||
{
|
||||
return mNumerator;
|
||||
}
|
||||
|
||||
inline
|
||||
void TimeInfo::numerator(BYTE numerator)
|
||||
{
|
||||
mNumerator=numerator;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE TimeInfo::denominator(void)const
|
||||
{
|
||||
return mDenominator;
|
||||
}
|
||||
|
||||
inline
|
||||
void TimeInfo::denominator(BYTE denominator)
|
||||
{
|
||||
mDenominator=denominator;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE TimeInfo::midiClocksPerMetronome(void)const
|
||||
{
|
||||
return mMidiClocksPerMetronome;
|
||||
}
|
||||
|
||||
inline
|
||||
void TimeInfo::midiClocksPerMetronome(BYTE midiClocksPerMetronome)
|
||||
{
|
||||
mMidiClocksPerMetronome=midiClocksPerMetronome;
|
||||
}
|
||||
|
||||
inline
|
||||
BYTE TimeInfo::thirtySecondNotesPerQtrNote(void)const
|
||||
{
|
||||
return mThirtySecondNotesPerQtrNote;
|
||||
}
|
||||
|
||||
inline
|
||||
void TimeInfo::thirtySecondNotesPerQtrNote(BYTE thirtySecondNotesPerQtrNote)
|
||||
{
|
||||
mThirtySecondNotesPerQtrNote=thirtySecondNotesPerQtrNote;
|
||||
}
|
||||
|
||||
inline
|
||||
String TimeInfo::toString(void)const
|
||||
{
|
||||
String string;
|
||||
String sep(", ");
|
||||
|
||||
string+=String().fromInt(mNumerator)+String("/")+String().fromInt(mDenominator)+String(" time")+sep;
|
||||
string+=String("MIDIClocksPerMetronome=")+String().fromInt(mMidiClocksPerMetronome)+sep;
|
||||
string+=String("32nd notes per 1/4 note=")+String().fromInt(mThirtySecondNotesPerQtrNote);
|
||||
return string;
|
||||
}
|
||||
#endif
|
||||
50
midiseq/safe/noteoff.hpp
Normal file
50
midiseq/safe/noteoff.hpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef _MIDISEQ_NOTEOFF_HPP_
|
||||
#define _MIDISEQ_NOTEOFF_HPP_
|
||||
#ifndef _MIDISEQ_PURENOTE_HPP_
|
||||
#include <midiseq/purenote.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_PUREEVENT_HPP_
|
||||
#include <midiseq/pureevnt.hpp>
|
||||
#endif
|
||||
|
||||
class NoteOff : public PureNote
|
||||
{
|
||||
public:
|
||||
NoteOff(void);
|
||||
NoteOff(const PureNote &pureNote);
|
||||
NoteOff &operator=(const PureNote &pureNote);
|
||||
virtual ~NoteOff();
|
||||
PureEvent getEvent(BYTE deltaTime=0,BYTE channel=0)const;
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
NoteOff::NoteOff(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
NoteOff::NoteOff(const PureNote &pureNote)
|
||||
{
|
||||
*this=pureNote;
|
||||
}
|
||||
|
||||
inline
|
||||
NoteOff &NoteOff::operator=(const PureNote &pureNote)
|
||||
{
|
||||
(PureNote&)*this=pureNote;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
NoteOff::~NoteOff()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
PureEvent NoteOff::getEvent(BYTE deltaTime,BYTE channel)const
|
||||
{
|
||||
PureEvent pureEvent(MIDINoteOff,deltaTime,channel,pitch(),velocity());
|
||||
return pureEvent;
|
||||
}
|
||||
#endif
|
||||
50
midiseq/safe/noteon.hpp
Normal file
50
midiseq/safe/noteon.hpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef _MIDISEQ_NOTEON_HPP_
|
||||
#define _MIDISEQ_NOTEON_HPP_
|
||||
#ifndef _MIDISEQ_PURENOTE_HPP_
|
||||
#include <midiseq/purenote.hpp>
|
||||
#endif
|
||||
#ifndef _MIDISEQ_PUREEVENT_HPP_
|
||||
#include <midiseq/pureevnt.hpp>
|
||||
#endif
|
||||
|
||||
class NoteOn : public PureNote
|
||||
{
|
||||
public:
|
||||
NoteOn(void);
|
||||
NoteOn(const PureNote &pureNote);
|
||||
NoteOn &operator=(const PureNote &pureNote);
|
||||
virtual ~NoteOn();
|
||||
PureEvent getEvent(BYTE deltaTime=0,BYTE channel=0)const;
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
NoteOn::NoteOn(void)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
NoteOn::NoteOn(const PureNote &pureNote)
|
||||
{
|
||||
*this=pureNote;
|
||||
}
|
||||
|
||||
inline
|
||||
NoteOn::~NoteOn()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
NoteOn &NoteOn::operator=(const PureNote &pureNote)
|
||||
{
|
||||
(PureNote&)*this=pureNote;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
PureEvent NoteOn::getEvent(BYTE deltaTime,BYTE channel)const
|
||||
{
|
||||
PureEvent pureEvent(MIDINoteOn,deltaTime,channel,pitch(),velocity());
|
||||
return pureEvent;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user