Current File : //proc/self/root/kunden/usr/share/doc/alsa-lib-devel/doxygen/html/rawmidi.html |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>ALSA project - the C library reference: RawMidi interface</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">ALSA project - the C library reference
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="index.html">Index, Preamble and License</a></li> </ul>
</div>
</div><!-- top -->
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">RawMidi interface </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>RawMidi Interface is designed to write or read raw (unchanged) MIDI data over the MIDI line without any timestamps defined in interface. MIDI stands Musical Instrument Digital Interface and more information about this standard can be found at <a href="http://www.midi.org">http://www.midi.org</a>.</p>
<h1><a class="anchor" id="rawmidi_general_overview"></a>
General overview</h1>
<p>The rawmidi implementation uses ring buffers to store outgoing and incoming MIDI stream. The buffer size is tunable and drivers report underruns for incoming stream as well.</p>
<h1><a class="anchor" id="rawmidi_open"></a>
Open handling</h1>
<p>RawMidi devices are opened exclusively for a selected direction. While more than one process may not open a given MIDI device in the same direction simultaneously, separate processes may open a single MIDI device in different directions (i.e. process one opens a MIDI device in write direction and process two opens the same device in read direction).</p>
<h2><a class="anchor" id="rawmidi_open_nonblock"></a>
Nonblocking open (flag)</h2>
<p>Using <a class="el" href="group___raw_midi.html#ga31ee35659c82272382ccc3014c8a73f8">SND_RAWMIDI_NONBLOCK</a> flag for <a class="el" href="group___raw_midi.html#ga2ab783051deeb7eb37eb568b76448889" title="Opens a new connection to the RawMidi interface.">snd_rawmidi_open()</a> or <a class="el" href="group___raw_midi.html#gaa7e3daf5cf4dd36b2534d2f1d6309477" title="Opens a new connection to the RawMidi interface using local configuration.">snd_rawmidi_open_lconf()</a> instruct device driver to return the -EBUSY error when device is already occupied with another application. This flag also changes behaviour of <a class="el" href="group___raw_midi.html#ga0a30e482efec57f4ea74c533a0f9b134" title="write MIDI bytes to MIDI stream">snd_rawmidi_write()</a> and <a class="el" href="group___raw_midi.html#ga9b0952fc04facda83cdf1521325ca475" title="read MIDI bytes from MIDI stream">snd_rawmidi_read()</a> returning -EAGAIN when no more bytes can be processed.</p>
<p>Note: In opposite (default) behaviour, application is blocked until device resources are free.</p>
<h2><a class="anchor" id="rawmidi_open_append"></a>
Append open (flag)</h2>
<p>Using <a class="el" href="group___raw_midi.html#ga7060640f32abcd337239bde2c8749d23">SND_RAWMIDI_APPEND</a> flag (output only) instruct device driver to append contents of written buffer - passed by <a class="el" href="group___raw_midi.html#ga0a30e482efec57f4ea74c533a0f9b134" title="write MIDI bytes to MIDI stream">snd_rawmidi_write()</a> - atomically to output ring buffer in the kernel space. This flag also means that device is not opened exclusively, so more applications can share given rawmidi device. Note that applications must send the whole MIDI message including the running status, because another writing application might break the MIDI message in the output buffer.</p>
<h2><a class="anchor" id="rawmidi_open_sync"></a>
Sync open (flag)</h2>
<p>Using <a class="el" href="group___raw_midi.html#gab1a659b38e5174d790d5671739995894">SND_RAWMIDI_SYNC</a> flag (output only) assures that the contents of output buffer specified using <a class="el" href="group___raw_midi.html#ga0a30e482efec57f4ea74c533a0f9b134" title="write MIDI bytes to MIDI stream">snd_rawmidi_write()</a> is always drained before the function exits. This behaviour is same like '<a class="el" href="group___raw_midi.html#ga0a30e482efec57f4ea74c533a0f9b134" title="write MIDI bytes to MIDI stream">snd_rawmidi_write()</a> followed by <a class="el" href="group___raw_midi.html#gabfff7417ec957b7ee07882f91d73d7be" title="drain all bytes in the rawmidi I/O ring buffer">snd_rawmidi_drain()</a> immediately'.</p>
<h2><a class="anchor" id="rawmidi_io"></a>
I/O handling</h2>
<p>There is only standard read/write access to device internal ring buffer. Use <a class="el" href="group___raw_midi.html#ga9b0952fc04facda83cdf1521325ca475" title="read MIDI bytes from MIDI stream">snd_rawmidi_read()</a> and <a class="el" href="group___raw_midi.html#ga0a30e482efec57f4ea74c533a0f9b134" title="write MIDI bytes to MIDI stream">snd_rawmidi_write()</a> functions to obtain / write MIDI bytes.</p>
<h2><a class="anchor" id="rawmidi_dev_names"></a>
RawMidi naming conventions</h2>
<p>The ALSA library uses a generic string representation for names of devices. The devices might be virtual, physical or a mix of both. The generic string is passed to <a class="el" href="group___raw_midi.html#ga2ab783051deeb7eb37eb568b76448889">::snd_rawmidi_open()</a> or <a class="el" href="group___raw_midi.html#gaa7e3daf5cf4dd36b2534d2f1d6309477">::snd_rawmidi_open_lconf()</a>. It contains two parts: device name and arguments. Devices and arguments are described in configuration files. The usual place for default definitions is at /usr/share/alsa/alsa.conf.</p>
<h2><a class="anchor" id="rawmidi_dev_names_default"></a>
rawmidi_dev_names_default</h2>
<p>The default device is equal to hw device. The defaults are used:</p>
<p>defaults.rawmidi.card 0 defaults.rawmidi.device 0 defaults.rawmidi.subdevice -1</p>
<p>These defaults can be freely overwritten in local configuration files.</p>
<p>Example:</p>
<div class="fragment"><div class="line"><span class="keywordflow">default</span></div>
</div><!-- fragment --><h2><a class="anchor" id="rawmidi_dev_names_hw"></a>
HW device</h2>
<p>The hw device description uses the hw plugin. The three arguments (in order: CARD,DEV,SUBDEV) specify card number or identifier, device number and subdevice number (-1 means any).</p>
<p>Example:</p>
<div class="fragment"><div class="line">hw</div>
<div class="line">hw:0</div>
<div class="line">hw:0,0</div>
<div class="line">hw:supersonic,1</div>
<div class="line">hw:soundwave,1,2</div>
<div class="line">hw:DEV=1,CARD=soundwave,SUBDEV=2</div>
</div><!-- fragment --><h1><a class="anchor" id="read_mode"></a>
Read mode</h1>
<p>Optionally, incoming rawmidi bytes can be marked with timestamps. The library hides the kernel implementation (linux kernel 5.14+) and exports the <a class="el" href="group___raw_midi.html#ga581b736aa85bd0acc58070380dac122f">::snd_rawmidi_tread()</a> function which returns the midi bytes marked with the identical timestamp in one iteration.</p>
<p>The timestamping is available only on input streams.</p>
<h1><a class="anchor" id="rawmidi_examples"></a>
Examples</h1>
<p>The full featured examples with cross-links:</p>
<dl class="section user"><dt>Simple input/output test program</dt><dd><a class="el" href="_2test_2rawmidi_8c-example.html#example_test_rawmidi">example code </a> </dd></dl>
<dl class="section user"><dt></dt><dd>This example shows open and read/write rawmidi operations.</dd></dl>
<h1><a class="anchor" id="rawmidi_virt"></a>
Virtual RawMidi interface</h1>
<p>The "virtual" plugin creates a virtual RawMidi instance on the ALSA sequencer, which can be accessed through the connection of the sequencer ports. There is no connection established as default.</p>
<p>For creating a virtual RawMidi instance, pass "virtual" as its name at creation.</p>
<p>Example: </p><div class="fragment"><div class="line"><a class="code" href="group___raw_midi.html#ga2ab783051deeb7eb37eb568b76448889">snd_rawmidi_open</a>(&read_handle, &write_handle, <span class="stringliteral">"virtual"</span>, 0);</div>
<div class="ttc" id="agroup___raw_midi_html_ga2ab783051deeb7eb37eb568b76448889"><div class="ttname"><a href="group___raw_midi.html#ga2ab783051deeb7eb37eb568b76448889">snd_rawmidi_open</a></div><div class="ttdeci">int snd_rawmidi_open(snd_rawmidi_t **in_rmidi, snd_rawmidi_t **out_rmidi, const char *name, int mode)</div><div class="ttdoc">Opens a new connection to the RawMidi interface.</div><div class="ttdef"><b>Definition:</b> rawmidi.c:312</div></div>
</div><!-- fragment --><h1><a class="anchor" id="rawmidi_ump"></a>
UMP RawMidi Interface</h1>
<p>MIDI 2.0 devices have a different type of interface, communicating with UMP (Universal MIDI Packet). For those devices, ALSA-library provides API functions for accessing the raw UMP packet directly via the existing RawMidi interface.</p>
<p><a class="el" href="group___raw_midi.html#ga6aadee001a840cb241484614038143b1" title="Opens a new connection to the UMP interface.">snd_ump_open()</a> is the API function for opening a UMP RawMidi interface. It works just like <a class="el" href="group___raw_midi.html#ga2ab783051deeb7eb37eb568b76448889" title="Opens a new connection to the RawMidi interface.">snd_rawmidi_open()</a> but for UMP devices. Similarly, <a class="el" href="group___raw_midi.html#gae7d895e4b89a009bbf961d11fbaf3568" title="close UMP handle">snd_ump_close()</a> is for closing, and there are other equivalent API functions corresponding to the RawMidi ones.</p>
<p>The new stuff for UMP is UMP Endpoint and UMP Function Blocks. The information from Endpoint and Function Blocks can be obtained via <a class="el" href="group___raw_midi.html#ga1e37d1b7281227949fe7716f3f129482" title="get endpoint information about UMP handle">snd_ump_endpoint_info()</a> and <a class="el" href="group___raw_midi.html#ga2c7bb2d887e45f65c1b574d3d9d4fefc" title="get UMP block information">snd_ump_block_info()</a> API functions.</p>
<p>The objects <a class="el" href="group___raw_midi.html#gae4bdf7d93a82021264b89727aa17d87d">snd_ump_endpoint_info_t</a> and <a class="el" href="group___raw_midi.html#gaad72212008c19517279f35f5e492ab34">snd_ump_block_info_t</a> are used for creating a virtual UMP Endpoint and Function Blocks via ALSA sequencer, too. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>