cmMidiFile.h/c Added cmMIdiFileTickToSamples()
This commit is contained in:
parent
bf8fceead1
commit
37c2599982
24
cmMidiFile.c
24
cmMidiFile.c
@ -796,6 +796,30 @@ void cmMidiFileTickToMicros( cmMidiFileH_t h )
|
||||
|
||||
}
|
||||
|
||||
void cmMidiFileTickToSamples( cmMidiFileH_t h, double srate, bool absFl )
|
||||
{
|
||||
_cmMidiFile_t* p;
|
||||
unsigned mi;
|
||||
//bool fl = true;
|
||||
|
||||
if((p = _cmMidiFileHandleToPtr(h)) == NULL )
|
||||
return;
|
||||
|
||||
cmMidiFileTickToMicros(h);
|
||||
|
||||
unsigned absSmp = 0;
|
||||
|
||||
for(mi=0; mi<p->msgN; ++mi)
|
||||
{
|
||||
cmMidiTrackMsg_t* mp = p->msgV[mi];
|
||||
unsigned delta = floor((mp->dtick*srate)/1000000.0);
|
||||
|
||||
mp->dtick = absFl ? absSmp : delta;
|
||||
|
||||
absSmp += delta;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct _cmMidiVoice_str
|
||||
{
|
||||
const cmMidiTrackMsg_t* mp;
|
||||
|
@ -152,6 +152,10 @@ double cmMidiFileDurSecs( cmMidiFileH_t h );
|
||||
// Convert the track message 'dtick' field to delta-microseconds.
|
||||
void cmMidiFileTickToMicros( cmMidiFileH_t h );
|
||||
|
||||
// Convert the track message 'dtick' field to samples.
|
||||
// If the absFl is set then the delta times are converted to absolute time.
|
||||
void cmMidiFileTickToSamples( cmMidiFileH_t h, double srate, bool absFl );
|
||||
|
||||
// Calculate Note Duration
|
||||
void cmMidiFileCalcNoteDurations( cmMidiFileH_t h );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user