Files
Work/midiseq/midiblck.cpp
2024-08-07 09:16:27 -04:00

62 lines
1.7 KiB
C++

#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<MaxTracks;itemIndex++)
mMIDIBlock[itemIndex]=((MIDIBlock&)someMIDIBlock)[itemIndex];
return *this;
}
bool MIDIBlock::getTrackInfo(TrackInfos &trackInfos)
{
trackInfos.remove();
for(int trIndex=0;trIndex<MaxTracks;trIndex++)
{
if(mMIDIBlock[trIndex].size())
{
trackInfos.insert(&TrackInfo());
TrackInfo &trackInfo=trackInfos[trackInfos.size()-1];
trackInfo.setTrackNo(trIndex);
trackInfo.setEventCount(mMIDIBlock[trIndex].size());
}
}
return trackInfos.size()?true:false;
}
/*inline
bool MIDIBlock::getTracks(Block<PureWORD> &tracks)
{
tracks.remove();
for(int trackIndex=0;trackIndex<MaxTracks;trackIndex++)
{
if(mMIDIBlock[trackIndex].size())tracks.insert(&PureWORD(trackIndex));
}
return tracks.size()?true:false;
}
*/
void MIDIBlock::printBlock(const String &pathFileName)
{
FileHandle writeFile(pathFileName,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite);
String eventString;
if(!writeFile.isOkay())return;
for(short channel=0;channel<MaxTracks;channel++)
{
EventBlock &eventBlock=(mMIDIBlock[channel]);
WORD eventCount(eventBlock.size());
for(short eventIndex=0;eventIndex<eventCount;eventIndex++)
{
String eventString(String("Track:")+String().fromInt(channel+1)+String(" ")+eventBlock[eventIndex].toString());
writeFile.writeLine(eventString);
}
writeFile.writeLine("****************************************************************************");
}
}