Advertisement
Guest User

Meters

a guest
Feb 24th, 2022
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. void FaderportFunctions::SendTextToScribble(int scribbleId, int lineNumber, int alignment, std::string txt) {
  2. if (m_midiout == NULL) return;
  3.  
  4. const char* text = txt.c_str();
  5.  
  6. struct
  7. {
  8. MIDI_event_t evt;
  9. char data[512];
  10. }
  11. poo;
  12.  
  13. poo.evt.frame_offset = 0;
  14. poo.evt.size = 0;
  15. poo.evt.midi_message[poo.evt.size++] = 0xF0;
  16. poo.evt.midi_message[poo.evt.size++] = 0x00;
  17. poo.evt.midi_message[poo.evt.size++] = 0x01;
  18. poo.evt.midi_message[poo.evt.size++] = 0x06;
  19. poo.evt.midi_message[poo.evt.size++] = m_states->GetIsFP8() ? FP8 : FP16;
  20.  
  21. //<SysExHdr> 12, xx, yy, zz, tx,tx,tx,... F7
  22. poo.evt.midi_message[poo.evt.size++] = SCRIBBLE_SEND_STRING;
  23. poo.evt.midi_message[poo.evt.size++] = 0x00 + scribbleId; // xx strip id
  24. poo.evt.midi_message[poo.evt.size++] = 0x00 + lineNumber; // yy line number 0-3
  25. poo.evt.midi_message[poo.evt.size++] = 0x0000000 + alignment; // zz alignment flag 0000000=centre
  26.  
  27. int length = strlen(text);
  28.  
  29. if (length > 200) length = 200;
  30.  
  31. int cnt = 0;
  32.  
  33. while (cnt < length)
  34. {
  35. poo.evt.midi_message[poo.evt.size++] = *text++; // tx text in ASCII format
  36. cnt++;
  37. }
  38.  
  39. poo.evt.midi_message[poo.evt.size++] = END;
  40. m_midiout->SendMsg(&poo.evt, -1);
  41. }
  42.  
  43.  
  44. int CSurf_Faderport::CalculateMeter(MediaTrack* track, int surface_displayid, int VU_BOTTOM, double decay) {
  45. if (!(GetPlayState() & 1)) return -1;
  46.  
  47. double pp = VAL2DB((Track_GetPeakInfo(track, 0) + Track_GetPeakInfo(track, 1)) * 0.5);
  48.  
  49. if (m_mcu_meterpos[surface_displayid] > -VU_BOTTOM * 2) m_mcu_meterpos[surface_displayid] -= decay;
  50.  
  51. if (pp < m_mcu_meterpos[surface_displayid]) return -1;
  52.  
  53. m_mcu_meterpos[surface_displayid] = pp;
  54.  
  55. //int v = 0xd; // 0xe turns on clip indicator, 0xf turns it off
  56. int v = 0x0;
  57.  
  58. if (pp < 0.0) pp < -VU_BOTTOM ? v = 0x0 : v = (int)((pp + VU_BOTTOM) * 13.0 / VU_BOTTOM) * 10;
  59.  
  60. return v;
  61. }
  62.  
  63. // Update the meterbar on the display
  64. void CSurf_Faderport::UpdateSurfaceMeter(int surface_displayid, int v) {
  65. (surface_displayid > 7) ? m_midiout->Send(PEAK_METER_9_16 + (surface_displayid & 7), v, 0, -1) : m_midiout->Send(PEAK_METER_1_8 + surface_displayid, v, 0, -1);
  66. }
  67.  
  68. #define PEAK_METER_1_8 0xD0
  69. #define PEAK_METER_9_16 0xC0
  70. #define REDUCTION_METER_1_8 0xD9
  71. #define REDUCTION_METER_9_16 0xC9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement