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