cmMidiFile.h/c : Added cmMidiFileNoteTimeDensity().
This commit is contained in:
parent
19b90719aa
commit
780abd5e74
32
cmMidiFile.c
32
cmMidiFile.c
@ -1907,6 +1907,38 @@ void cmMidiFilePrintTracks( cmMidiFileH_t h, unsigned trkIdx, cmRpt_t* rpt )
|
|||||||
void cmMidiFileTestPrint( void* printDataPtr, const char* fmt, va_list vl )
|
void cmMidiFileTestPrint( void* printDataPtr, const char* fmt, va_list vl )
|
||||||
{ vprintf(fmt,vl); }
|
{ vprintf(fmt,vl); }
|
||||||
|
|
||||||
|
cmMidiFileDensity_t* cmMidiFileNoteDensity( cmMidiFileH_t h, unsigned* cntRef )
|
||||||
|
{
|
||||||
|
int msgN = cmMidiFileMsgCount(h);
|
||||||
|
const cmMidiTrackMsg_t** msgs = cmMidiFileMsgArray(h);
|
||||||
|
cmMidiFileDensity_t* dV = cmMemAllocZ(cmMidiFileDensity_t,msgN);
|
||||||
|
|
||||||
|
int i,j,k;
|
||||||
|
for(i=0,k=0; i<msgN && k<msgN; ++i)
|
||||||
|
if( msgs[i]->status == kNoteOnMdId && msgs[i]->u.chMsgPtr->d1 > 0 )
|
||||||
|
{
|
||||||
|
dV[k].uid = msgs[i]->uid;
|
||||||
|
dV[k].amicro = msgs[i]->amicro;
|
||||||
|
|
||||||
|
for(j=i; j>=0; --j)
|
||||||
|
{
|
||||||
|
if( msgs[i]->amicro - msgs[j]->amicro > 1000000 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
dV[k].density += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
k += 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if( cntRef != NULL )
|
||||||
|
*cntRef = k;
|
||||||
|
|
||||||
|
return dV;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cmMfRC_t cmMidiFileGenPlotFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outFn )
|
cmMfRC_t cmMidiFileGenPlotFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outFn )
|
||||||
{
|
{
|
||||||
cmMfRC_t rc = kOkMfRC;
|
cmMfRC_t rc = kOkMfRC;
|
||||||
|
13
cmMidiFile.h
13
cmMidiFile.h
@ -212,11 +212,22 @@ extern "C" {
|
|||||||
|
|
||||||
void cmMidiFilePrintMsgs( cmMidiFileH_t h, cmRpt_t* rpt );
|
void cmMidiFilePrintMsgs( cmMidiFileH_t h, cmRpt_t* rpt );
|
||||||
void cmMidiFilePrintTrack( cmMidiFileH_t h, unsigned trkIdx, cmRpt_t* rpt );
|
void cmMidiFilePrintTrack( cmMidiFileH_t h, unsigned trkIdx, cmRpt_t* rpt );
|
||||||
void cmMidiFileTest( const char* fn, cmCtx_t* ctx );
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned uid;
|
||||||
|
unsigned long long amicro;
|
||||||
|
unsigned density;
|
||||||
|
|
||||||
|
} cmMidiFileDensity_t;
|
||||||
|
cmMidiFileDensity_t* cmMidiFileNoteTimeDensity( cmMidiFileH_t h, unsigned* cntRef );
|
||||||
|
|
||||||
// Generate a piano-roll plot description file which can be displayed with cmXScore.m
|
// Generate a piano-roll plot description file which can be displayed with cmXScore.m
|
||||||
cmMfRC_t cmMidiFileGenPlotFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outFn );
|
cmMfRC_t cmMidiFileGenPlotFile( cmCtx_t* ctx, const cmChar_t* midiFn, const cmChar_t* outFn );
|
||||||
|
|
||||||
|
void cmMidiFileTest( const char* fn, cmCtx_t* ctx );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//)
|
//)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user