-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCreatingAudioDriver.html
More file actions
143 lines (141 loc) · 13.9 KB
/
CreatingAudioDriver.html
File metadata and controls
143 lines (141 loc) · 13.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!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>libfluidsynth: Creating the audio driver</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="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.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" />
<link href="custom.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">libfluidsynth
 <span id="projectnumber">2.5.4</span>
</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>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('CreatingAudioDriver.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- 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 class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">Creating the audio driver </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The synthesizer itself does not write any audio to the audio output. This allows application developers to manage the audio output themselves if they wish. The next section describes the use of the synthesizer without an audio driver in more detail.</p>
<p>Creating the audio driver is straightforward: set the <code>audio.driver</code> settings and create the driver object. Because the FluidSynth has support for several audio systems, you may want to change which one you want to use. The list below shows the audio systems that are currently supported. It displays the name, as used by the fluidsynth library, and a description.</p>
<ul>
<li>jack: JACK Audio Connection Kit (Linux, Mac OS X, Windows)</li>
<li>alsa: Advanced Linux Sound Architecture (Linux)</li>
<li>oss: Open Sound System (primarily needed on BSD, rarely also Linux and Unix in general)</li>
<li>pulseaudio: PulseAudio (Linux, Mac OS X, Windows)</li>
<li>coreaudio: Apple CoreAudio (Mac OS X)</li>
<li>dsound: Microsoft DirectSound (Windows)</li>
<li>wasapi: Windows Audio Session API (Windows Vista and later)</li>
<li>waveout: Microsoft WaveOut, alternative to DirectSound (Windows CE x86, Windows Mobile 2003 for ARMv5, Windows 98 SE, Windows NT 4.0, Windows XP and later)</li>
<li>portaudio: PortAudio Library (Mac OS 9 & X, Windows, Linux)</li>
<li>sndman: Apple SoundManager (Mac OS Classic)</li>
<li>dart: DART sound driver (OS/2)</li>
<li>opensles: OpenSL ES (Android)</li>
<li>oboe: Oboe (Android)</li>
<li>sdl3*: Simple DirectMedia Layer (Linux, Windows, Mac OS X, iOS, Android, FreeBSD, Haiku, etc.)</li>
<li>pipewire**: PipeWire (Linux)</li>
<li>file: Driver to output audio to a file</li>
</ul>
<p>The default audio driver depends on the settings with which FluidSynth was compiled. You can get the default driver with <a class="el" href="group__settings.html#ga5acb5b788aae89b556dd69f2f6d667eb" title="Get the default value of a string setting.">fluid_settings_getstr_default()</a>. To get the list of available drivers use the <a class="el" href="group__settings.html#ga27b468f705be56657281b07fbe4e0398" title="Iterate the available options for a named string setting, calling the provided callback function for ...">fluid_settings_foreach_option()</a> function. Finally, you can set the driver with <a class="el" href="group__settings.html#ga58cbabbb8990c2934b3eeea925e01804" title="Set a string value for a named setting.">fluid_settings_setstr()</a>. In most cases, the default driver should work out of the box.</p>
<p>Additional audio driver options that define the audio quality and latency include <a class="el" href="settings_audio.html#settings_audio_sample-format">audio.sample-format</a>, <a class="el" href="settings_audio.html#settings_audio_period-size">audio.period-size</a>, and <a class="el" href="settings_audio.html#settings_audio_periods">audio.periods</a>. The synthesizer's <a class="el" href="settings_synth.html#settings_synth_sample-rate">synth.sample-rate</a> is also involved. The details are described later.</p>
<p>Important: Configure the synthesizer before creating the audio driver. In particular, set <a class="el" href="settings_synth.html#settings_synth_sample-rate">synth.sample-rate</a> before instantiating the synth with <a class="el" href="group__synth.html#ga2aab8e0b82dc9fd086849efacb3c1b1b" title="Create new FluidSynth instance.">new_fluid_synth()</a>. After the synth has been created, changing <a class="el" href="settings_synth.html#settings_synth_sample-rate">synth.sample-rate</a> in the settings object may not change the sample rate used by the synthesizer, while audio drivers created later may use the updated setting value and cause the audio to be played out of tune. If you need to change the sample rate, recreate both the synthesizer and the audio driver using settings with the new sample rate.</p>
<p>You can create the audio driver with the <a class="el" href="group__audio__driver.html#ga7c66ef86f0008807bdd955770fca6925" title="Create a new audio driver.">new_fluid_audio_driver()</a> function. This function takes the settings and synthesizer object as arguments. For example:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> init() </div>
<div class="line">{</div>
<div class="line"> <a class="code" href="group__Types.html#gaa363402d3c77333b0f070ba531d034ba">fluid_settings_t</a>* settings;</div>
<div class="line"> <a class="code" href="group__Types.html#gae265f10ae174a13afe010de50d87e1a4">fluid_synth_t</a>* synth;</div>
<div class="line"> <a class="code" href="group__Types.html#gac3706330ce49cac5b7dd079e90d376d8">fluid_audio_driver_t</a>* adriver;</div>
<div class="line"> settings = <a class="code" href="group__settings.html#ga7623af35fb3d1abace21ef7d5b4f4781">new_fluid_settings</a>();</div>
<div class="line"> </div>
<div class="line"> <span class="comment">/* Set the synthesizer settings, if necessary */</span></div>
<div class="line"> synth = <a class="code" href="group__synth.html#ga2aab8e0b82dc9fd086849efacb3c1b1b">new_fluid_synth</a>(settings);</div>
<div class="line"> </div>
<div class="line"> <a class="code" href="group__settings.html#ga58cbabbb8990c2934b3eeea925e01804">fluid_settings_setstr</a>(settings, <span class="stringliteral">"audio.driver"</span>, <span class="stringliteral">"jack"</span>);</div>
<div class="line"> adriver = <a class="code" href="group__audio__driver.html#ga7c66ef86f0008807bdd955770fca6925">new_fluid_audio_driver</a>(settings, synth);</div>
<div class="line">}</div>
<div class="ttc" id="agroup__Types_html_gaa363402d3c77333b0f070ba531d034ba"><div class="ttname"><a href="group__Types.html#gaa363402d3c77333b0f070ba531d034ba">fluid_settings_t</a></div><div class="ttdeci">struct _fluid_hashtable_t fluid_settings_t</div><div class="ttdoc">Configuration settings instance.</div><div class="ttdef"><b>Definition:</b> types.h:37</div></div>
<div class="ttc" id="agroup__Types_html_gac3706330ce49cac5b7dd079e90d376d8"><div class="ttname"><a href="group__Types.html#gac3706330ce49cac5b7dd079e90d376d8">fluid_audio_driver_t</a></div><div class="ttdeci">struct _fluid_audio_driver_t fluid_audio_driver_t</div><div class="ttdoc">Audio driver instance.</div><div class="ttdef"><b>Definition:</b> types.h:45</div></div>
<div class="ttc" id="agroup__Types_html_gae265f10ae174a13afe010de50d87e1a4"><div class="ttname"><a href="group__Types.html#gae265f10ae174a13afe010de50d87e1a4">fluid_synth_t</a></div><div class="ttdeci">struct _fluid_synth_t fluid_synth_t</div><div class="ttdoc">Synthesizer instance.</div><div class="ttdef"><b>Definition:</b> types.h:38</div></div>
<div class="ttc" id="agroup__audio__driver_html_ga7c66ef86f0008807bdd955770fca6925"><div class="ttname"><a href="group__audio__driver.html#ga7c66ef86f0008807bdd955770fca6925">new_fluid_audio_driver</a></div><div class="ttdeci">fluid_audio_driver_t * new_fluid_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth)</div><div class="ttdoc">Create a new audio driver.</div><div class="ttdef"><b>Definition:</b> fluid_adriver.c:343</div></div>
<div class="ttc" id="agroup__settings_html_ga58cbabbb8990c2934b3eeea925e01804"><div class="ttname"><a href="group__settings.html#ga58cbabbb8990c2934b3eeea925e01804">fluid_settings_setstr</a></div><div class="ttdeci">int fluid_settings_setstr(fluid_settings_t *settings, const char *name, const char *str)</div><div class="ttdoc">Set a string value for a named setting.</div><div class="ttdef"><b>Definition:</b> fluid_settings.c:962</div></div>
<div class="ttc" id="agroup__settings_html_ga7623af35fb3d1abace21ef7d5b4f4781"><div class="ttname"><a href="group__settings.html#ga7623af35fb3d1abace21ef7d5b4f4781">new_fluid_settings</a></div><div class="ttdeci">fluid_settings_t * new_fluid_settings(void)</div><div class="ttdoc">Create a new settings object.</div><div class="ttdef"><b>Definition:</b> fluid_settings.c:261</div></div>
<div class="ttc" id="agroup__synth_html_ga2aab8e0b82dc9fd086849efacb3c1b1b"><div class="ttname"><a href="group__synth.html#ga2aab8e0b82dc9fd086849efacb3c1b1b">new_fluid_synth</a></div><div class="ttdeci">fluid_synth_t * new_fluid_synth(fluid_settings_t *settings)</div><div class="ttdoc">Create new FluidSynth instance.</div><div class="ttdef"><b>Definition:</b> fluid_synth.c:711</div></div>
</div><!-- fragment --><p>As soon as the audio driver is created, it will start playing. The audio driver creates a separate thread that receives audio samples from the synthesizer object and transfers them to an audio endpoint to generate sound.</p>
<p>There are a number of general audio driver settings. The audio.driver settings define the audio subsystem that will be used. The <a class="el" href="settings_audio.html#settings_audio_periods">audio.periods</a> and <a class="el" href="settings_audio.html#settings_audio_period-size">audio.period-size</a> settings define the latency and robustness against scheduling delays. There are additional settings for the audio subsystems used. For a full list of available <b>audio driver settings</b>, please refer to the <a class="el" href="settings_audio.html">Audio driver settings</a> documentation.</p>
<p><b>*Note:</b> In order to use sdl3 as audio driver, the application is responsible for initializing SDL (e.g. with SDL_Init()). This must be done <b>before</b> the first call to <code><a class="el" href="group__settings.html#ga7623af35fb3d1abace21ef7d5b4f4781" title="Create a new settings object.">new_fluid_settings()</a></code>! Also make sure to call SDL_Quit() after all fluidsynth instances have been destroyed. A warning may be printed if sdl3 is available, but no such call has been made.</p>
<p><b>**Note:</b> In order to use pipeiwre as audio driver, the application is responsible for initializing PipeWire (e.g. with pw_init()). This must be done <b>before</b> the first call to <code><a class="el" href="group__settings.html#ga7623af35fb3d1abace21ef7d5b4f4781" title="Create a new settings object.">new_fluid_settings()</a></code>! Also make sure to call pw_deinit() after all fluidsynth instances have been destroyed.</p>
<p>Warnings raised by audio drivers during initialization via <a class="el" href="group__settings.html#ga7623af35fb3d1abace21ef7d5b4f4781" title="Create a new settings object.">new_fluid_settings()</a> can be suppressed by disabling those audio drivers with <a class="el" href="group__audio__driver.html#gadb6794858c4a18bf3ebe51c60ccb8605" title="Registers audio drivers to use.">fluid_audio_driver_register()</a>. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
</body>
</html>