DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8KB

  1. function (event) {
  2. function magic () {
  3. if (event.data.magicHasHappened) {
  4. $('#pedalboard-dashboard').css({
  5. 'background': "#111 url(/img/background.jpg) repeat",
  6. });
  7. } else {
  8. $('#pedalboard-dashboard').css({
  9. 'background': "#111 url(/resources/tilesf1.jpg?uri=http%3A//distrho.sf.net/examples/Info) repeat",
  10. });
  11. }
  12. event.data.magicHasHappened = !event.data.magicHasHappened;
  13. }
  14. function handle_event (symbol, value) {
  15. switch (symbol) {
  16. case 'time_playing':
  17. case 'time_validbbt':
  18. value = value > 0.5 ? "Yes" : "No";
  19. break;
  20. case 'time_beatsperminute':
  21. value = value.toFixed(2);
  22. break;
  23. case 'time_frame': {
  24. var time = value / SAMPLERATE;
  25. var secs = time % 60;
  26. var mins = (time / 60) % 60;
  27. var hrs = (time / 3600) % 60;
  28. event.icon.find('[mod-role=time_frame_s]').text(sprintf("%02d:%02d:%02d", hrs, mins, secs));
  29. // fall-through
  30. }
  31. default:
  32. value = value.toFixed();
  33. break;
  34. }
  35. event.icon.find('[mod-role='+symbol+']').text(value);
  36. }
  37. if (event.type == 'start') {
  38. var ports = event.ports;
  39. for (var p in ports) {
  40. if (ports[p].symbol[0] == ":") {
  41. continue;
  42. }
  43. handle_event (ports[p].symbol, ports[p].value);
  44. }
  45. // special cases
  46. event.icon.find ('[mod-role=sample_rate]').text(SAMPLERATE);
  47. event.icon.find ('.mod-magic').click(magic);
  48. }
  49. else if (event.type == 'change') {
  50. handle_event (event.symbol, event.value);
  51. }
  52. }