jack2 codebase
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.

103 lines
3.3KB

  1. /*
  2. Copyright (C) 2010 Devin Anderson
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #ifndef __JackMidiUtil__
  16. #define __JackMidiUtil__
  17. #include "JackMidiPort.h"
  18. namespace Jack {
  19. /**
  20. * Use this function to optimize MIDI output by omitting unnecessary status
  21. * bytes. This can't be used with all MIDI APIs, so before using this
  22. * function, make sure that your MIDI API doesn't require complete MIDI
  23. * messages to be sent.
  24. *
  25. * To start using this function, call this method with pointers to the
  26. * `size` and `buffer` arguments of the MIDI message you want to send, and
  27. * set the `running_status` argument to '0'. For each subsequent MIDI
  28. * message, call this method with pointers to its `size` and `buffer`
  29. * arguments, and set the `running_status` argument to the return value of
  30. * the previous call to this function.
  31. *
  32. * Note: This function will alter the `size` and `buffer` of your MIDI
  33. * message for each message that can be optimized.
  34. */
  35. SERVER_EXPORT jack_midi_data_t
  36. ApplyRunningStatus(size_t *size, jack_midi_data_t **buffer,
  37. jack_midi_data_t running_status=0);
  38. /**
  39. * A wrapper function for the above `ApplyRunningStatus` function.
  40. */
  41. SERVER_EXPORT jack_midi_data_t
  42. ApplyRunningStatus(jack_midi_event_t *event,
  43. jack_midi_data_t running_status);
  44. /**
  45. * Gets the estimated current time in frames. This function has the same
  46. * functionality as the JACK client API function `jack_frame_time`.
  47. */
  48. SERVER_EXPORT jack_nframes_t
  49. GetCurrentFrame();
  50. /**
  51. * Gets the estimated frame that will be occurring at the given time. This
  52. * function has the same functionality as the JACK client API function
  53. * `jack_time_to_frames`.
  54. */
  55. SERVER_EXPORT jack_nframes_t
  56. GetFramesFromTime(jack_time_t time);
  57. /**
  58. * Gets the precise time at the start of the current process cycle. This
  59. * function has the same functionality as the JACK client API function
  60. * `jack_last_frame_time`.
  61. */
  62. SERVER_EXPORT jack_nframes_t
  63. GetLastFrame();
  64. /**
  65. * Returns the expected message length for the status byte. Returns 0 if
  66. * the status byte is a system exclusive status byte, or -1 if the status
  67. * byte is invalid.
  68. */
  69. SERVER_EXPORT int
  70. GetMessageLength(jack_midi_data_t status_byte);
  71. /**
  72. * Gets the estimated time at which the given frame will occur. This
  73. * function has the same functionality as the JACK client API function
  74. * `jack_frames_to_time`.
  75. */
  76. SERVER_EXPORT jack_time_t
  77. GetTimeFromFrames(jack_nframes_t frames);
  78. };
  79. #endif