mirror of
https://github.com/thestk/stk
synced 2026-01-14 05:21:53 +00:00
312 lines
19 KiB
HTML
312 lines
19 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>The Synthesis ToolKit in C++ (STK)</TITLE>
|
|
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#FFFFFF">
|
|
<CENTER>
|
|
<img src="princeton.gif"> <img src="ccrma.gif"> <img src="mcgill.gif"><P>
|
|
<a class="qindex" href="index.html">Home</a> <a class="qindex" href="information.html">Information</a> <a class="qindex" href="classes.html">Classes</a> <a class="qindex" href="download.html">Download</a> <a class="qindex" href="usage.html">Usage</a> <a class="qindex" href="maillist.html">Mail List</a> <a class="qindex" href="system.html">Requirements</a> <a class="qindex" href="links.html">Links</a> <a class="qindex" href="faq.html">FAQ</a> <a class="qindex" href="tutorial.html">Tutorial</a></CENTER>
|
|
<HR>
|
|
<!-- Generated by Doxygen 1.5.8 -->
|
|
<div class="navpath"><a class="el" href="namespacestk.html">stk</a>::<a class="el" href="classstk_1_1Granulate.html">Granulate</a>
|
|
</div>
|
|
<div class="contents">
|
|
<h1>stk::Granulate Class Reference</h1><!-- doxytag: class="stk::Granulate" --><!-- doxytag: inherits="stk::Generator" -->STK granular synthesis class.
|
|
<a href="#_details">More...</a>
|
|
<p>
|
|
<code>#include <<a class="el" href="Granulate_8h-source.html">Granulate.h</a>></code>
|
|
<p>
|
|
<div class="dynheader">
|
|
Inheritance diagram for stk::Granulate:</div>
|
|
<div class="dynsection">
|
|
|
|
<p><center><img src="classstk_1_1Granulate.png" usemap="#stk::Granulate_map" border="0" alt=""></center>
|
|
<map name="stk::Granulate_map">
|
|
<area href="classstk_1_1Generator.html" alt="stk::Generator" shape="rect" coords="0,56,90,80">
|
|
<area href="classstk_1_1Stk.html" alt="stk::Stk" shape="rect" coords="0,0,90,24">
|
|
</map>
|
|
</div>
|
|
|
|
<p>
|
|
<a href="classstk_1_1Granulate-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
|
<tr><td></td></tr>
|
|
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="78af615a331de9b643dfabb8e106883f"></a><!-- doxytag: member="stk::Granulate::Granulate" ref="78af615a331de9b643dfabb8e106883f" args="(void)" -->
|
|
</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#78af615a331de9b643dfabb8e106883f">Granulate</a> (void)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. <br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="aff22b306824e885191892bbab35b9f6"></a><!-- doxytag: member="stk::Granulate::Granulate" ref="aff22b306824e885191892bbab35b9f6" args="(unsigned int nVoices, std::string fileName, bool typeRaw=false)" -->
|
|
</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#aff22b306824e885191892bbab35b9f6">Granulate</a> (unsigned int nVoices, std::string fileName, bool typeRaw=false)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor taking input audio file and number of voices arguments. <br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="42eb1f39bd88eb8d4ca55972e7711313"></a><!-- doxytag: member="stk::Granulate::~Granulate" ref="42eb1f39bd88eb8d4ca55972e7711313" args="(void)" -->
|
|
</td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#42eb1f39bd88eb8d4ca55972e7711313">~Granulate</a> (void)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Class destructor. <br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#6227f127a77b4fc581028033cd7658d8">openFile</a> (std::string fileName, bool typeRaw=false)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Load a monophonic soundfile to be "granulated". <a href="#6227f127a77b4fc581028033cd7658d8"></a><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#9b7b17ae856f3a9ece6ec462285f456c">reset</a> (void)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Reset the file pointer and all existing grains to the file start. <a href="#9b7b17ae856f3a9ece6ec462285f456c"></a><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#735f3ebe8fa2cacfba2c4722a56fd417">setVoices</a> (unsigned int nVoices=1)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the number of simultaneous grain "voices" to use. <a href="#735f3ebe8fa2cacfba2c4722a56fd417"></a><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#abd711f2b71bbcd28412d5cb73c085d6">setStretch</a> (unsigned int stretchFactor=1)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the stretch factor used for grain playback (1 - 1000). <a href="#abd711f2b71bbcd28412d5cb73c085d6"></a><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#9b7c15080256f920646d36bfa0ed3734">setGrainParameters</a> (unsigned int duration=30, unsigned int rampPercent=50, int offset=0, unsigned int delay=0)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set global grain parameters used to determine individual grain settings. <a href="#9b7c15080256f920646d36bfa0ed3734"></a><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#02b7b85f21999d4b350beff6a925bd25">setRandomFactor</a> (StkFloat randomness=0.1)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">This factor is used when setting individual grain parameters (0.0 - 1.0). <a href="#02b7b85f21999d4b350beff6a925bd25"></a><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top">StkFloat </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#60db060a365fc32fe789cb9bcd042dd3">lastOut</a> (unsigned int channel=0)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the specified channel value of the last computed frame. <a href="#60db060a365fc32fe789cb9bcd042dd3"></a><br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="0f8b162c9c309b3cbec3802138a53c24"></a><!-- doxytag: member="stk::Granulate::tick" ref="0f8b162c9c309b3cbec3802138a53c24" args="(unsigned int channel=0)" -->
|
|
StkFloat </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#0f8b162c9c309b3cbec3802138a53c24">tick</a> (unsigned int channel=0)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Compute one sample frame and return the specified <code>channel</code> value. <br></td></tr>
|
|
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classstk_1_1Granulate.html#a9cc119b1515c5596a95d72f4b65b0c0">tick</a> (<a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> &frames, unsigned int channel=0)</td></tr>
|
|
|
|
<tr><td class="mdescLeft"> </td><td class="mdescRight">Fill the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object with computed sample frames, starting at the specified channel. <a href="#a9cc119b1515c5596a95d72f4b65b0c0"></a><br></td></tr>
|
|
</table>
|
|
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
|
STK granular synthesis class.
|
|
<p>
|
|
This class implements a real-time granular synthesis algorithm that operates on an input soundfile. Multi-channel files are supported. Various functions are provided to allow control over voice and grain parameters.<p>
|
|
The functionality of this class is based on the program MacPod by Chris Rolfe and Damian Keller, though there are likely to be a number of differences in the actual implementation.<p>
|
|
by Gary Scavone, 2005 - 2009. <hr><h2>Member Function Documentation</h2>
|
|
<a class="anchor" name="6227f127a77b4fc581028033cd7658d8"></a><!-- doxytag: member="stk::Granulate::openFile" ref="6227f127a77b4fc581028033cd7658d8" args="(std::string fileName, bool typeRaw=false)" -->
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void stk::Granulate::openFile </td>
|
|
<td>(</td>
|
|
<td class="paramtype">std::string </td>
|
|
<td class="paramname"> <em>fileName</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">bool </td>
|
|
<td class="paramname"> <em>typeRaw</em> = <code>false</code></td><td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="memdoc">
|
|
|
|
<p>
|
|
Load a monophonic soundfile to be "granulated".
|
|
<p>
|
|
An <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> will be thrown if the file is not found, its format is unknown or unsupported, or the file has more than one channel.
|
|
</div>
|
|
</div><p>
|
|
<a class="anchor" name="9b7b17ae856f3a9ece6ec462285f456c"></a><!-- doxytag: member="stk::Granulate::reset" ref="9b7b17ae856f3a9ece6ec462285f456c" args="(void)" -->
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void stk::Granulate::reset </td>
|
|
<td>(</td>
|
|
<td class="paramtype">void </td>
|
|
<td class="paramname"> </td>
|
|
<td> ) </td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="memdoc">
|
|
|
|
<p>
|
|
Reset the file pointer and all existing grains to the file start.
|
|
<p>
|
|
Multiple grains are offset from one another in time by grain duration / nVoices.
|
|
</div>
|
|
</div><p>
|
|
<a class="anchor" name="735f3ebe8fa2cacfba2c4722a56fd417"></a><!-- doxytag: member="stk::Granulate::setVoices" ref="735f3ebe8fa2cacfba2c4722a56fd417" args="(unsigned int nVoices=1)" -->
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void stk::Granulate::setVoices </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned int </td>
|
|
<td class="paramname"> <em>nVoices</em> = <code>1</code> </td>
|
|
<td> ) </td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="memdoc">
|
|
|
|
<p>
|
|
Set the number of simultaneous grain "voices" to use.
|
|
<p>
|
|
Multiple grains are offset from one another in time by grain duration / nVoices. For this reason, it is best to set the grain parameters before calling this function (during initialization).
|
|
</div>
|
|
</div><p>
|
|
<a class="anchor" name="abd711f2b71bbcd28412d5cb73c085d6"></a><!-- doxytag: member="stk::Granulate::setStretch" ref="abd711f2b71bbcd28412d5cb73c085d6" args="(unsigned int stretchFactor=1)" -->
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void stk::Granulate::setStretch </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned int </td>
|
|
<td class="paramname"> <em>stretchFactor</em> = <code>1</code> </td>
|
|
<td> ) </td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="memdoc">
|
|
|
|
<p>
|
|
Set the stretch factor used for grain playback (1 - 1000).
|
|
<p>
|
|
Granular synthesis allows for time-stetching without affecting the original pitch of a sound. A stretch factor of 4 will produce a resulting sound of length 4 times the orignal sound. The default parameter of 1 produces no stretching.
|
|
</div>
|
|
</div><p>
|
|
<a class="anchor" name="9b7c15080256f920646d36bfa0ed3734"></a><!-- doxytag: member="stk::Granulate::setGrainParameters" ref="9b7c15080256f920646d36bfa0ed3734" args="(unsigned int duration=30, unsigned int rampPercent=50, int offset=0, unsigned int delay=0)" -->
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void stk::Granulate::setGrainParameters </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned int </td>
|
|
<td class="paramname"> <em>duration</em> = <code>30</code>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">unsigned int </td>
|
|
<td class="paramname"> <em>rampPercent</em> = <code>50</code>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">int </td>
|
|
<td class="paramname"> <em>offset</em> = <code>0</code>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">unsigned int </td>
|
|
<td class="paramname"> <em>delay</em> = <code>0</code></td><td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="memdoc">
|
|
|
|
<p>
|
|
Set global grain parameters used to determine individual grain settings.
|
|
<p>
|
|
Each grain is defined as having a length of <em>duration</em> milliseconds which must be greater than zero. For values of <em>rampPercent</em> (0 - 100) greater than zero, a linear envelope will be applied to each grain. If <em>rampPercent</em> = 100, the resultant grain "window" is triangular while <em>rampPercent</em> = 50 produces a trapezoidal window. In addition, each grain can have a time delay of length <em>delay</em> and a grain pointer increment of length <em>offset</em>, which can be negative, before the next ramp onset (in milliseconds). The <em>offset</em> parameter controls grain pointer jumps between enveloped grain segments, while the <em>delay</em> parameter causes grain calculations to pause between grains. The actual values calculated for each grain will be randomized by a factor set using the <a class="el" href="classstk_1_1Granulate.html#02b7b85f21999d4b350beff6a925bd25" title="This factor is used when setting individual grain parameters (0.0 - 1.0).">setRandomFactor()</a> function.
|
|
</div>
|
|
</div><p>
|
|
<a class="anchor" name="02b7b85f21999d4b350beff6a925bd25"></a><!-- doxytag: member="stk::Granulate::setRandomFactor" ref="02b7b85f21999d4b350beff6a925bd25" args="(StkFloat randomness=0.1)" -->
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void stk::Granulate::setRandomFactor </td>
|
|
<td>(</td>
|
|
<td class="paramtype">StkFloat </td>
|
|
<td class="paramname"> <em>randomness</em> = <code>0.1</code> </td>
|
|
<td> ) </td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="memdoc">
|
|
|
|
<p>
|
|
This factor is used when setting individual grain parameters (0.0 - 1.0).
|
|
<p>
|
|
This random factor is applied when all grain state durations are calculated. If set to 0.0, no randomness occurs. When randomness = 1.0, a grain segment of length <em>duration</em> will be randomly augmented by up to +- <em>duration</em> seconds (i.e., a 30 millisecond length will be augmented by an extra length of up to +30 or -30 milliseconds).
|
|
</div>
|
|
</div><p>
|
|
<a class="anchor" name="60db060a365fc32fe789cb9bcd042dd3"></a><!-- doxytag: member="stk::Granulate::lastOut" ref="60db060a365fc32fe789cb9bcd042dd3" args="(unsigned int channel=0)" -->
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">StkFloat stk::Granulate::lastOut </td>
|
|
<td>(</td>
|
|
<td class="paramtype">unsigned int </td>
|
|
<td class="paramname"> <em>channel</em> = <code>0</code> </td>
|
|
<td> ) </td>
|
|
<td><code> [inline]</code></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="memdoc">
|
|
|
|
<p>
|
|
Return the specified channel value of the last computed frame.
|
|
<p>
|
|
The <code>channel</code> argument must be less than the number of output channels, which can be determined with the <a class="el" href="classstk_1_1Generator.html#9f9de4c495217ef8490a9d2d1fdabe11" title="Return the number of output channels for the class.">channelsOut()</a> function (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception. <dl class="see" compact><dt><b>See also:</b></dt><dd><a class="el" href="classstk_1_1Generator.html#499ad65aa6d939983863ffb922008654" title="Return an StkFrames reference to the last output sample frame.">lastFrame()</a> </dd></dl>
|
|
|
|
</div>
|
|
</div><p>
|
|
<a class="anchor" name="a9cc119b1515c5596a95d72f4b65b0c0"></a><!-- doxytag: member="stk::Granulate::tick" ref="a9cc119b1515c5596a95d72f4b65b0c0" args="(StkFrames &frames, unsigned int channel=0)" -->
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> & stk::Granulate::tick </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="classstk_1_1StkFrames.html">StkFrames</a> & </td>
|
|
<td class="paramname"> <em>frames</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">unsigned int </td>
|
|
<td class="paramname"> <em>channel</em> = <code>0</code></td><td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td><td><code> [inline, virtual]</code></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="memdoc">
|
|
|
|
<p>
|
|
Fill the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> object with computed sample frames, starting at the specified channel.
|
|
<p>
|
|
The <code>channel</code> argument plus the number of output channels must be less than the number of channels in the <a class="el" href="classstk_1_1StkFrames.html" title="An STK class to handle vectorized audio data.">StkFrames</a> argument (the first channel is specified by 0). However, range checking is only performed if _STK_DEBUG_ is defined during compilation, in which case an out-of-range value will trigger an <a class="el" href="classstk_1_1StkError.html" title="STK error handling class.">StkError</a> exception.
|
|
<p>Implements <a class="el" href="classstk_1_1Generator.html#86bb0421223cf27e25704d5f27b97425">stk::Generator</a>.</p>
|
|
|
|
</div>
|
|
</div><p>
|
|
<hr>The documentation for this class was generated from the following file:<ul>
|
|
<li><a class="el" href="Granulate_8h-source.html">Granulate.h</a></ul>
|
|
</div>
|
|
<HR>
|
|
|
|
<table>
|
|
<tr><td><A HREF="http://ccrma.stanford.edu/software/stk/"><I>The Synthesis ToolKit in C++ (STK)</I></A></td></tr>
|
|
<tr><td>©1995-2009 Perry R. Cook and Gary P. Scavone. All Rights Reserved.</td></tr>
|
|
</table>
|
|
|
|
</BODY>
|
|
</HTML>
|