haiku-website/static/legacy-docs/bebook/BSynth_Overview.html

89 lines
12 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Midi Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheMidiKit_Overview.html" title="The Midi Kit" /><link rel="prev" href="BSamples_Overview.html" title="BSamples" /><link rel="next" href="TheNetworkKit_Overview.html" title="The Network Kit" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BSamples_Overview.html" title="BSamples"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheMidiKit_Overview.html" title="The Midi Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="TheNetworkKit_Overview.html" title="The Network Kit"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Midi Kit</div></div><div id="headerB">Prev: <a href="BSamples_Overview.html">BSamples</a>  Up: <a href="TheMidiKit_Overview.html">The Midi Kit</a>  Next: <a href="TheNetworkKit_Overview.html">The Network Kit</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BSynth_Overview"></a>BSynth</h2></div></div></div><a id="id596850" class="indexterm"></a><p>The BeOS includes a 16-channel General MIDI software synthsizer designed
by HeadSpace Inc. The
<a class="link" href="BSynth.html" title="BSynth"><code class="classname">BSynth</code></a>
class is the interface to the synthesizer
itself. Any application that wants to use the synthesizer must include a
<a class="link" href="BSynth.html" title="BSynth"><code class="classname">BSynth</code></a>
object; however, most applications won't need to create the object directly: The
<a class="link" href="BMidiSynth.html" title="BMidiSynth"><code class="classname">BMidiSynth</code></a>,
<a class="link" href="BMidiSynthFile.html" title="BMidiSynthFile"><code class="classname">BMidiSynthFile</code></a>,
and
<a class="link" href="BSamples.html" title="BSamples"><code class="classname">BSamples</code></a>
classes create a
<a class="link" href="BSynth.html" title="BSynth"><code class="classname">BSynth</code></a>
object for you. Furthermore, since
<a class="link" href="BSynth.html" title="BSynth"><code class="classname">BSynth</code></a>
doesn't inherit from
<a class="link" href="BMidi.html" title="BMidi"><code class="classname">BMidi</code></a>,
it doesn't have any API for actually playing MIDI data. To play
MIDI data, you need an instance of
<a class="link" href="BMidiSynth.html" title="BMidiSynth"><code class="classname">BMidiSynth</code></a> or
<a class="link" href="BMidiSynthFile.html" title="BMidiSynthFile"><code class="classname">BMidiSynthFile</code></a>.</p><p>An application can have only one
<a class="link" href="BSynth.html" title="BSynth"><code class="classname">BSynth</code></a>
object at a time. The object is represented globally (within your app) as
<code class="varname">be_synth</code>.
The classes that create a
<a class="link" href="BSynth.html" title="BSynth"><code class="classname">BSynth</code></a>
for you
(<a class="link" href="BMidiSynth.html" title="BMidiSynth"><code class="classname">BMidiSynth</code></a>
and so on) won't clobber an existing
<code class="varname">be_synth</code>,
but the
<a class="link" href="BSynth.html" title="BSynth"><code class="classname">BSynth</code></a>
constructor will.</p><p>When it's created, the
<code class="varname">be_synth</code>
object tries to find an instrument
definition (or "synth") file. This is a file that contains the data
(samples and instructions) for creating General MIDI instruments. The
BeOS provides two such files (both designed by HeadSpace, and both stored
in <code class="constant">B_SYNTH_DIRECTORY</code>):</p><table class="variablelist constants"><thead><tr><th>Constant</th><th>Description</th></tr></thead><tbody><tr><td><p><span class="term"><code class="constant">B_BIG_SYNTH_FILE</code><br />
(<code class="filename">/boot/beos/etc/synth/big_synth.sy</code>)</span></p></td><td><p>Contains 16-bit, 22 kHz data. It takes about 5 Megs of memory when fully loaded.</p></td></tr><tr><td><p><span class="term"><code class="constant">B_LITTLE_SYNTH_FILE</code><br />
(<code class="filename">/boot/beos/etc/synth/little_synth.sy</code>)</span></p></td><td><p>Is 8-bit, 11 kHz data. It's a quarter the size of the big synth, but lacks the
big file's fidelity.</p></td></tr></tbody></table><p>The instrument data is read from the file as it's needed. To "pre-load"
the entire synth file, use the
<a class="link" href="BMidiSynth.html#BMidiSynth_EnableInput" title="EnableInput(), IsInputEnabled()"><code class="methodname">BMidiSynth::EnableInput()</code></a>
function.</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BSynth_Overview_BSynthAndTheAudioServer"></a>BSynth and the Audio Server</h3></div></div></div><p>The synthesizer produces sound by taking over the Audio Server's
<acronym class="acronym" title="Digital to Analogue Converter">DAC</acronym>
stream. It resets the size and number of buffers in the stream, sets the
sampling rate, and adds a <code class="classname">BSubscriber</code> to the front of the stream. If you
want to mix sound files into the MIDI synthesis, you should use the
<a class="link" href="BSamples.html" title="BSamples"><code class="classname">BSamples</code></a>
object rather than add your own DAC stream subscribers. However,
if you really want to add your own sample-generating subscribers, don't
add them to the front of the <acronym class="acronym">DAC</acronym> stream after the
<code class="varname">be_synth</code> subscriber has
been added—your subscriber's samples will be clobbered.</p><p>The interaction between the synthesizer and the Media Kit will be cleaned
up in a subsequent release.</p><p>The <acronym class="acronym">DAC</acronym> stream's previous settings are
restored when <code class="varname">be_synth</code> is
destroyed.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BSynth_Overview_SynthesisCapacity"></a>Synthesis Capacity</h3></div></div></div><p>The synthesizer can generate up to 32 voices at a time, where a "voice"
is either an individual (synthesized) note, or a stream of samples from a
<a class="link" href="BSamples.html" title="BSamples"><code class="classname">BSamples</code></a>
object. By default, it apportions 28 voice "slots" for synthesis
and 4 for samples. You can change the settings through the
<a class="link" href="BSynth.html#BSynth_SetVoiceLimits" title="SetVoiceLimits(), MaxSynthVoices(), MaxSampleVoices(), LimiterThreshhold()"><code class="methodname">SetVoiceLimits()</code></a>
function.</p><p>If you ask for more voices than there are voice slots (for example, if
you ask for a 29'th note when there are already 28 singing), the
synthesizer will try to kill an old note in order to make room for the
new note.</p><p>There's no guarantee that the synthesizer and <acronym class="acronym">DAC</acronym> stream will have enough
time to generate and process everything you ask for, even if you're
running below the 32 voice limit. On a lightly loaded, reasonably fast
machine, you shouldn't hear any glitches, but a heavy <acronym class="acronym">MIDI</acronym> command stream
(for example) could bog it down.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BSynth_Overview_RecordingAPerformance"></a>Recording a Performance</h3></div></div></div><p>There's no API for automatically writing the synthesizer's output to a
file. To record a synthesizer performance you have to create your own
<code class="classname">BSubscriber</code>,
add it to the <acronym class="acronym">DAC</acronym> stream (downstream of the synthesizer),
and write out the samples that it receives. (See the Media Kit for more
information.)</p><p>In some cases, the act of recording can be enough of a
<acronym class="acronym">CPU</acronym> drag that the
synthesizer falls behind realtime (actually, it's the synthesizer's
<code class="classname">BSubscriber</code> that's getting behind). It may not sound great while you're
monitoring the recording, but the data that's written to the file
probably won't be affected—the glitches won't be written to the
file.</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BSamples_Overview.html">BSamples</a>  Up: <a href="TheMidiKit_Overview.html">The Midi Kit</a>  Next: <a href="TheNetworkKit_Overview.html">The Network Kit</a> </div><div id="footerB"><div id="footerBL"><a href="BSamples_Overview.html" title="BSamples"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheMidiKit_Overview.html" title="The Midi Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="TheNetworkKit_Overview.html" title="The Network Kit"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>