\hypertarget{midiport_8h}{
\section{midiport.h File Reference}
\label{midiport_8h}\index{midiport.h@{midiport.h}}
}
{\tt \#include $<$jack/types.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__jack__midi__event}{\_\-jack\_\-midi\_\-event}
\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef unsigned char \hyperlink{midiport_8h_580fcf106adb556fda49b012bd7bde1b}{jack\_\-midi\_\-data\_\-t}
\item 
typedef \hyperlink{struct__jack__midi__event}{\_\-jack\_\-midi\_\-event} \hyperlink{midiport_8h_a92f87d7c00285a62f2611668e80ca4b}{jack\_\-midi\_\-event\_\-t}
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
\hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} \hyperlink{midiport_8h_786cad06c0628a147e3aedd3eafb22c9}{jack\_\-midi\_\-get\_\-event\_\-count} (void $\ast$port\_\-buffer, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} nframes)
\item 
int \hyperlink{midiport_8h_7e4a7e78a4ce255806ea408c8aea87ca}{jack\_\-midi\_\-event\_\-get} (\hyperlink{struct__jack__midi__event}{jack\_\-midi\_\-event\_\-t} $\ast$event, void $\ast$port\_\-buffer, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} event\_\-index, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} nframes)
\item 
void \hyperlink{midiport_8h_2da477c6cde346e4ec4fd5b69b0e2cce}{jack\_\-midi\_\-clear\_\-buffer} (void $\ast$port\_\-buffer, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} nframes)
\item 
size\_\-t \hyperlink{midiport_8h_256e0480dd80fc65f47a4e099f2f0bee}{jack\_\-midi\_\-max\_\-event\_\-size} (void $\ast$port\_\-buffer, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} nframes)
\item 
\hyperlink{midiport_8h_580fcf106adb556fda49b012bd7bde1b}{jack\_\-midi\_\-data\_\-t} $\ast$ \hyperlink{midiport_8h_55b984d84da8be3c06de2f27bfa2d4b2}{jack\_\-midi\_\-event\_\-reserve} (void $\ast$port\_\-buffer, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} time, size\_\-t data\_\-size, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} nframes)
\item 
int \hyperlink{midiport_8h_3544db170af993e386b7595bc2de1c8f}{jack\_\-midi\_\-event\_\-write} (void $\ast$port\_\-buffer, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} time, const \hyperlink{midiport_8h_580fcf106adb556fda49b012bd7bde1b}{jack\_\-midi\_\-data\_\-t} $\ast$data, size\_\-t data\_\-size, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} nframes)
\item 
\hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} \hyperlink{midiport_8h_ec1e507d4822c676eaa22bb9726a6396}{jack\_\-midi\_\-get\_\-lost\_\-event\_\-count} (void $\ast$port\_\-buffer, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} nframes)
\end{CompactItemize}


\subsection{Typedef Documentation}
\hypertarget{midiport_8h_580fcf106adb556fda49b012bd7bde1b}{
\index{midiport.h@{midiport.h}!jack_midi_data_t@{jack\_\-midi\_\-data\_\-t}}
\index{jack_midi_data_t@{jack\_\-midi\_\-data\_\-t}!midiport.h@{midiport.h}}
\subsubsection[jack\_\-midi\_\-data\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef unsigned char \hyperlink{midiport_8h_580fcf106adb556fda49b012bd7bde1b}{jack\_\-midi\_\-data\_\-t}}}
\label{midiport_8h_580fcf106adb556fda49b012bd7bde1b}


Type for raw event data contained in \hyperlink{midiport_8h_a92f87d7c00285a62f2611668e80ca4b}{jack\_\-midi\_\-event\_\-t}. \hypertarget{midiport_8h_a92f87d7c00285a62f2611668e80ca4b}{
\index{midiport.h@{midiport.h}!jack_midi_event_t@{jack\_\-midi\_\-event\_\-t}}
\index{jack_midi_event_t@{jack\_\-midi\_\-event\_\-t}!midiport.h@{midiport.h}}
\subsubsection[jack\_\-midi\_\-event\_\-t]{\setlength{\rightskip}{0pt plus 5cm}typedef struct \hyperlink{struct__jack__midi__event}{\_\-jack\_\-midi\_\-event}  \hyperlink{struct__jack__midi__event}{jack\_\-midi\_\-event\_\-t}}}
\label{midiport_8h_a92f87d7c00285a62f2611668e80ca4b}


A Jack MIDI event. 

\subsection{Function Documentation}
\hypertarget{midiport_8h_2da477c6cde346e4ec4fd5b69b0e2cce}{
\index{midiport.h@{midiport.h}!jack_midi_clear_buffer@{jack\_\-midi\_\-clear\_\-buffer}}
\index{jack_midi_clear_buffer@{jack\_\-midi\_\-clear\_\-buffer}!midiport.h@{midiport.h}}
\subsubsection[jack\_\-midi\_\-clear\_\-buffer]{\setlength{\rightskip}{0pt plus 5cm}void jack\_\-midi\_\-clear\_\-buffer (void $\ast$ {\em port\_\-buffer}, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} {\em nframes})}}
\label{midiport_8h_2da477c6cde346e4ec4fd5b69b0e2cce}


Clear an event buffer.

This should be called at the beginning of each process cycle before calling \hyperlink{midiport_8h_55b984d84da8be3c06de2f27bfa2d4b2}{jack\_\-midi\_\-event\_\-reserve} or \hyperlink{midiport_8h_3544db170af993e386b7595bc2de1c8f}{jack\_\-midi\_\-event\_\-write}. This function may not be called on an input port's buffer.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em port\_\-buffer}]Port buffer to clear (must be an output port buffer). \item[{\em nframes}]Number of valid frames this cycle. \end{description}
\end{Desc}
\hypertarget{midiport_8h_7e4a7e78a4ce255806ea408c8aea87ca}{
\index{midiport.h@{midiport.h}!jack_midi_event_get@{jack\_\-midi\_\-event\_\-get}}
\index{jack_midi_event_get@{jack\_\-midi\_\-event\_\-get}!midiport.h@{midiport.h}}
\subsubsection[jack\_\-midi\_\-event\_\-get]{\setlength{\rightskip}{0pt plus 5cm}int jack\_\-midi\_\-event\_\-get (\hyperlink{struct__jack__midi__event}{jack\_\-midi\_\-event\_\-t} $\ast$ {\em event}, void $\ast$ {\em port\_\-buffer}, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} {\em event\_\-index}, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} {\em nframes})}}
\label{midiport_8h_7e4a7e78a4ce255806ea408c8aea87ca}


Get a MIDI event from an event port buffer.

Jack MIDI is normalised, the MIDI event returned by this function is guaranteed to be a complete MIDI event (the status byte will always be present, and no realtime events will interspered with the event).

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em event}]Event structure to store retrieved event in. \item[{\em port\_\-buffer}]Port buffer from which to retrieve event. \item[{\em event\_\-index}]Index of event to retrieve. \item[{\em nframes}]Number of valid frames this cycle. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, ENODATA if buffer is empty. \end{Desc}
\hypertarget{midiport_8h_55b984d84da8be3c06de2f27bfa2d4b2}{
\index{midiport.h@{midiport.h}!jack_midi_event_reserve@{jack\_\-midi\_\-event\_\-reserve}}
\index{jack_midi_event_reserve@{jack\_\-midi\_\-event\_\-reserve}!midiport.h@{midiport.h}}
\subsubsection[jack\_\-midi\_\-event\_\-reserve]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{midiport_8h_580fcf106adb556fda49b012bd7bde1b}{jack\_\-midi\_\-data\_\-t}$\ast$ jack\_\-midi\_\-event\_\-reserve (void $\ast$ {\em port\_\-buffer}, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} {\em time}, size\_\-t {\em data\_\-size}, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} {\em nframes})}}
\label{midiport_8h_55b984d84da8be3c06de2f27bfa2d4b2}


Allocate space for an event to be written to an event port buffer.

Clients are to write the actual event data to be written starting at the pointer returned by this function. Clients must not write more than {\em data\_\-size\/} bytes into this buffer. Clients must write normalised MIDI data to the port - no running status and no (1-byte) realtime messages interspersed with other messages (realtime messages are fine when they occur on their own, like other messages).

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em port\_\-buffer}]Buffer to write event to. \item[{\em time}]Sample offset of event. \item[{\em data\_\-size}]Length of event's raw data in bytes. \item[{\em nframes}]Number of valid frames this event. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Pointer to the beginning of the reserved event's data buffer, or NULL on error (ie not enough space). \end{Desc}
\hypertarget{midiport_8h_3544db170af993e386b7595bc2de1c8f}{
\index{midiport.h@{midiport.h}!jack_midi_event_write@{jack\_\-midi\_\-event\_\-write}}
\index{jack_midi_event_write@{jack\_\-midi\_\-event\_\-write}!midiport.h@{midiport.h}}
\subsubsection[jack\_\-midi\_\-event\_\-write]{\setlength{\rightskip}{0pt plus 5cm}int jack\_\-midi\_\-event\_\-write (void $\ast$ {\em port\_\-buffer}, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} {\em time}, const \hyperlink{midiport_8h_580fcf106adb556fda49b012bd7bde1b}{jack\_\-midi\_\-data\_\-t} $\ast$ {\em data}, size\_\-t {\em data\_\-size}, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} {\em nframes})}}
\label{midiport_8h_3544db170af993e386b7595bc2de1c8f}


Write an event into an event port buffer.

This function is simply a wrapper for \hyperlink{midiport_8h_55b984d84da8be3c06de2f27bfa2d4b2}{jack\_\-midi\_\-event\_\-reserve} which writes the event data into the space reserved in the buffer. The same restrictions on the MIDI data apply.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em port\_\-buffer}]Buffer to write event to. \item[{\em time}]Sample offset of event. \item[{\em data}]Message data to be written. \item[{\em data\_\-size}]Length of {\em data\/} in bytes. \item[{\em nframes}]Number of valid frames this event. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, ENOBUFS if there's not enough space in buffer for event. \end{Desc}
\hypertarget{midiport_8h_786cad06c0628a147e3aedd3eafb22c9}{
\index{midiport.h@{midiport.h}!jack_midi_get_event_count@{jack\_\-midi\_\-get\_\-event\_\-count}}
\index{jack_midi_get_event_count@{jack\_\-midi\_\-get\_\-event\_\-count}!midiport.h@{midiport.h}}
\subsubsection[jack\_\-midi\_\-get\_\-event\_\-count]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} jack\_\-midi\_\-get\_\-event\_\-count (void $\ast$ {\em port\_\-buffer}, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} {\em nframes})}}
\label{midiport_8h_786cad06c0628a147e3aedd3eafb22c9}


\hypertarget{midiport_8h_ec1e507d4822c676eaa22bb9726a6396}{
\index{midiport.h@{midiport.h}!jack_midi_get_lost_event_count@{jack\_\-midi\_\-get\_\-lost\_\-event\_\-count}}
\index{jack_midi_get_lost_event_count@{jack\_\-midi\_\-get\_\-lost\_\-event\_\-count}!midiport.h@{midiport.h}}
\subsubsection[jack\_\-midi\_\-get\_\-lost\_\-event\_\-count]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} jack\_\-midi\_\-get\_\-lost\_\-event\_\-count (void $\ast$ {\em port\_\-buffer}, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} {\em nframes})}}
\label{midiport_8h_ec1e507d4822c676eaa22bb9726a6396}


Get the number of events that could not be written to {\em port\_\-buffer\/}.

This function returning a non-zero value implies {\em port\_\-buffer\/} is full. Currently the only way this can happen is if events are lost on port mixdown.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em port\_\-buffer}]Port to receive count for. \item[{\em nframes}]Number of valid frames this cycle. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Number of events that could not be written to {\em port\_\-buffer\/}. \end{Desc}
\hypertarget{midiport_8h_256e0480dd80fc65f47a4e099f2f0bee}{
\index{midiport.h@{midiport.h}!jack_midi_max_event_size@{jack\_\-midi\_\-max\_\-event\_\-size}}
\index{jack_midi_max_event_size@{jack\_\-midi\_\-max\_\-event\_\-size}!midiport.h@{midiport.h}}
\subsubsection[jack\_\-midi\_\-max\_\-event\_\-size]{\setlength{\rightskip}{0pt plus 5cm}size\_\-t jack\_\-midi\_\-max\_\-event\_\-size (void $\ast$ {\em port\_\-buffer}, \hyperlink{types_8h_fe9972a13782c1e282747fdb4bc46f9c}{jack\_\-nframes\_\-t} {\em nframes})}}
\label{midiport_8h_256e0480dd80fc65f47a4e099f2f0bee}


Get the size of the largest event that can be stored by the port.

This function returns the current space available, taking into account events already stored in the port.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em port\_\-buffer}]Port buffer to check size of. \item[{\em nframes}]Number of valid frames this cycle. \end{description}
\end{Desc}
