12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- //| Copyright: (C) 2019-2020 Kevin Larke <contact AT larke DOT org>
- //| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
- #include "cmPrefix.h"
- #include "cmGlobal.h"
- #include "cmFloatTypes.h"
- #include "cmRpt.h"
- #include "cmErr.h"
- #include "cmCtx.h"
- #include "cmTime.h"
- #include "cmMidi.h"
- #include "cmGr.h"
- #include "gvHashFunc.h"
-
- void gvRoundHashValueFunc( void* arg, cmChar_t* label, unsigned labelCharCnt, cmGrV_t value )
- {
- snprintf(label,labelCharCnt,"%i",(int)round(value));
- }
-
- void gvMidiSciPitchValueFunc( void* arg, cmChar_t* label, unsigned labelCharCnt, cmGrV_t value )
- {
- assert( label != NULL && labelCharCnt > 0 );
-
- if( labelCharCnt > 0 )
- label[0] = 0;
-
- if( 0 <= value && value <= 127 )
- cmMidiToSciPitch((cmMidiByte_t)floor(value), label, labelCharCnt );
- else
- {
- if( labelCharCnt > 3 )
- strcpy(label,"?");
- }
- }
- void gvMinSecMsHashValueFunc( void* arg, cmChar_t* label, unsigned labelCharCnt, cmGrV_t value )
- {
- gvHashFuncArg* p = (gvHashFuncArg*)arg;
-
- int min=0,sec=0,ms=0;
-
- double smpPerMin = p->sampleRate() * 60.0;
- double smpPerMs = p->sampleRate() / 1000.0;
-
- if( value > smpPerMin )
- {
- min = (int)floor( value / smpPerMin );
- value -= min * smpPerMin;
- }
-
- if( value > p->sampleRate() )
- {
- sec = (int)floor( value / p->sampleRate() );
- value -= sec * p->sampleRate();
- }
-
-
- if( value > smpPerMs )
- {
- ms = (int)floor( value / smpPerMs );
- value -= ms * smpPerMs;
- }
-
- snprintf(label,labelCharCnt,"%i:%2i:%2i",min,sec,ms);
- }
|