Programmable real-time audio signal processing application
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

gvHashFunc.cpp 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "cmPrefix.h"
  2. #include "cmGlobal.h"
  3. #include "cmFloatTypes.h"
  4. #include "cmRpt.h"
  5. #include "cmErr.h"
  6. #include "cmCtx.h"
  7. #include "cmTime.h"
  8. #include "cmMidi.h"
  9. #include "cmGr.h"
  10. #include "gvHashFunc.h"
  11. void gvRoundHashValueFunc( void* arg, cmChar_t* label, unsigned labelCharCnt, cmGrV_t value )
  12. {
  13. snprintf(label,labelCharCnt,"%i",(int)round(value));
  14. }
  15. void gvMidiSciPitchValueFunc( void* arg, cmChar_t* label, unsigned labelCharCnt, cmGrV_t value )
  16. {
  17. assert( label != NULL && labelCharCnt > 0 );
  18. if( labelCharCnt > 0 )
  19. label[0] = 0;
  20. if( 0 <= value && value <= 127 )
  21. cmMidiToSciPitch((cmMidiByte_t)floor(value), label, labelCharCnt );
  22. else
  23. {
  24. if( labelCharCnt > 3 )
  25. strcpy(label,"?");
  26. }
  27. }
  28. void gvMinSecMsHashValueFunc( void* arg, cmChar_t* label, unsigned labelCharCnt, cmGrV_t value )
  29. {
  30. gvHashFuncArg* p = (gvHashFuncArg*)arg;
  31. int min=0,sec=0,ms=0;
  32. double smpPerMin = p->sampleRate() * 60.0;
  33. double smpPerMs = p->sampleRate() / 1000.0;
  34. if( value > smpPerMin )
  35. {
  36. min = (int)floor( value / smpPerMin );
  37. value -= min * smpPerMin;
  38. }
  39. if( value > p->sampleRate() )
  40. {
  41. sec = (int)floor( value / p->sampleRate() );
  42. value -= sec * p->sampleRate();
  43. }
  44. if( value > smpPerMs )
  45. {
  46. ms = (int)floor( value / smpPerMs );
  47. value -= ms * smpPerMs;
  48. }
  49. snprintf(label,labelCharCnt,"%i:%2i:%2i",min,sec,ms);
  50. }