139 lines
8.3 KiB
HTML
139 lines
8.3 KiB
HTML
|
<!doctype html><html lang='en'><head><title>PlayBuf | SuperCollider 3.9.3 Help</title>
|
||
|
<link rel='stylesheet' href='./../scdoc.css' type='text/css' />
|
||
|
<link rel='stylesheet' href='./../frontend.css' type='text/css' />
|
||
|
<link rel='stylesheet' href='./../custom.css' type='text/css' />
|
||
|
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
|
||
|
<script>
|
||
|
var helpRoot = './..';
|
||
|
var scdoc_title = 'PlayBuf';
|
||
|
var scdoc_sc_version = '3.9.3';
|
||
|
</script>
|
||
|
<script src='./../scdoc.js' type='text/javascript'></script>
|
||
|
<script src='./../docmap.js' type='text/javascript'></script>
|
||
|
<script src='./../prettify.js' type='text/javascript'></script>
|
||
|
<script src='./../lang-sc.js' type='text/javascript'></script>
|
||
|
</head>
|
||
|
<body onload='fixTOC();prettyPrint()'>
|
||
|
<div id='toc'>
|
||
|
<div id='toctitle'>PlayBuf:</div>
|
||
|
<span class='toc_search'>Filter: <input id='toc_search'></span><ul class='toc'><li class='toc1'><a href='#description'>Description</a></li>
|
||
|
<ul class='toc'></ul><li class='toc1'><a href='#classmethods'>Class methods</a></li>
|
||
|
<ul class='toc'><li class='toc3'><a href='#*ar'>ar</a> <a href='#*kr'>kr</a> </li>
|
||
|
<li class='toc2'><a href='#Inherited%20class%20methods'>Inherited class methods</a></li>
|
||
|
</ul><li class='toc1'><a href='#instancemethods'>Instance methods</a></li>
|
||
|
<ul class='toc'><li class='toc2'><a href='#Inherited%20instance%20methods'>Inherited instance methods</a></li>
|
||
|
</ul><li class='toc1'><a href='#examples'>Examples</a></li>
|
||
|
<ul class='toc'></ul></ul></div><div class='contents'>
|
||
|
<div id='menubar'></div>
|
||
|
<div class='header'>
|
||
|
<div id='label'>
|
||
|
<span id='folder'>Classes</span>
|
||
|
| <span id='categories'><a href='./../Browse.html#UGens'>UGens</a> > <a href='./../Browse.html#UGens>Buffer'>Buffer</a></span>
|
||
|
</div><h1>PlayBuf<span id='superclasses'> : <a href="../Classes/MultiOutUGen.html">MultiOutUGen</a> : <a href="../Classes/UGen.html">UGen</a> : <a href="../Classes/AbstractFunction.html">AbstractFunction</a> : <a href="../Classes/Object.html">Object</a></span>
|
||
|
</h1>
|
||
|
<div id='summary'>Sample playback oscillator.</div>
|
||
|
</div>
|
||
|
<div class='subheader'>
|
||
|
<div id='filename'>Source: <a href='file:///Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/Common/Audio/BufIO.sc' title='/Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/Common/Audio/BufIO.sc'>BufIO.sc</a></div><div id='related'>See also: <a href="./../Classes/RecordBuf.html">RecordBuf</a>, <a href="./../Classes/DiskIn.html">DiskIn</a>, <a href="./../Classes/BufRd.html">BufRd</a></div>
|
||
|
</div>
|
||
|
<h2><a class='anchor' name='description'>Description</a></h2>
|
||
|
|
||
|
<p>Plays back a sample resident in memory.<h2><a class='anchor' name='classmethods'>Class Methods</a></h2>
|
||
|
<h3 class='method-code'><span class='method-prefix'>PlayBuf.</span><a class='method-name' name='*ar' href='./../Overviews/Methods.html#ar'>ar</a>(<span class='argstr'>numChannels</span>, <span class='argstr'>bufnum: 0</span>, <span class='argstr'>rate: 1</span>, <span class='argstr'>trigger: 1</span>, <span class='argstr'>startPos: 0</span>, <span class='argstr'>loop: 0</span>, <span class='argstr'>doneAction: 0</span>)</h3>
|
||
|
<h3 class='method-code'><span class='method-prefix'>PlayBuf.</span><a class='method-name' name='*kr' href='./../Overviews/Methods.html#kr'>kr</a>(<span class='argstr'>numChannels</span>, <span class='argstr'>bufnum: 0</span>, <span class='argstr'>rate: 1</span>, <span class='argstr'>trigger: 1</span>, <span class='argstr'>startPos: 0</span>, <span class='argstr'>loop: 0</span>, <span class='argstr'>doneAction: 0</span>)</h3>
|
||
|
<div class='method'>
|
||
|
<p><h4>Arguments:</h4>
|
||
|
<table class='arguments'>
|
||
|
<tr><td class='argumentname'>numChannels<td class='argumentdesc'>
|
||
|
<p>Number of channels that the buffer will be. This must be a fixed integer. The architecture of the SynthDef cannot change after it is compiled.<tr><td class='argumentname'>bufnum<td class='argumentdesc'>
|
||
|
<p>The index of the buffer to use.<div class='note'><span class='notelabel'>NOTE:</span> If you supply a bufnum of a buffer with a differing number of channels than the one specified in this PlayBuf, it will post a warning and output the channels it can.</div><tr><td class='argumentname'>rate<td class='argumentdesc'>
|
||
|
<p>1.0 is the server's sample rate, 2.0 is one octave up, 0.5 is one octave down -1.0 is backwards normal rate… etc. Interpolation is cubic.<tr><td class='argumentname'>trigger<td class='argumentdesc'>
|
||
|
<p>A trigger causes a jump to the startPos. A trigger occurs when a signal changes from negative value to positive value.<tr><td class='argumentname'>startPos<td class='argumentdesc'>
|
||
|
<p>Sample frame to start playback.<tr><td class='argumentname'>loop<td class='argumentdesc'>
|
||
|
<p>1 means true, 0 means false. This is modulateable.<tr><td class='argumentname'>doneAction<td class='argumentdesc'>
|
||
|
<p>an integer representing an action to be executed when the buffer is finished playing. This can be used to free the enclosing synth, etc. See <a href="./../Classes/Done.html">Done</a> for more detail. <code class='code prettyprint lang-sc'>doneAction</code> is only evaluated if loop is 0.</table></div><h3><a class='anchor' name='Inherited%20class%20methods'>Inherited class methods</a></h3>
|
||
|
<div id='inheritedclassmets'></div><h2><a class='anchor' name='instancemethods'>Instance Methods</a></h2>
|
||
|
<h3><a class='anchor' name='Inherited%20instance%20methods'>Inherited instance methods</a></h3>
|
||
|
<div id='inheritedinstmets'></div><h2><a class='anchor' name='examples'>Examples</a></h2>
|
||
|
<pre class='code prettyprint lang-sc'>s.boot // Boot the server, if you need to
|
||
|
|
||
|
// read a whole sound into memory
|
||
|
// note: not *that* columbia, the first one
|
||
|
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav"); // remember to free the buffer later.
|
||
|
|
||
|
SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
|
||
|
Out.ar(out,
|
||
|
PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), doneAction: Done.freeSelf)
|
||
|
)
|
||
|
}).play(s, [\out, 0, \bufnum, b]);</pre>
|
||
|
|
||
|
<p>In the above example, note how the <code class='code prettyprint lang-sc'>doneAction: Done.freeSelf</code> causes the synth to free itself when the buffer reaches its end.
|
||
|
<p>Note again that the number of channels must be fixed for the SynthDef. It cannot vary depending on which buffer you use.<pre class='code prettyprint lang-sc'>// loop is true
|
||
|
SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
|
||
|
Out.ar(out,
|
||
|
PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), loop: 1.0)
|
||
|
)
|
||
|
}).play(s, [\out, 0, \bufnum, b]);
|
||
|
|
||
|
|
||
|
// trigger one shot on each pulse
|
||
|
SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
|
||
|
var trig;
|
||
|
trig = Impulse.kr(2.0);
|
||
|
Out.ar(out,
|
||
|
PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), trig, 0, 0)
|
||
|
)
|
||
|
}).play(s, [\out, 0, \bufnum, b]);
|
||
|
|
||
|
|
||
|
// trigger one shot on each pulse
|
||
|
SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
|
||
|
var trig;
|
||
|
trig = Impulse.kr(XLine.kr(0.1, 100, 30));
|
||
|
Out.ar(out,
|
||
|
PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), trig, 5000, 0)
|
||
|
)
|
||
|
}).play(s, [\out, 0, \bufnum, b]);
|
||
|
|
||
|
|
||
|
// mouse control of trigger rate and startpos
|
||
|
SynthDef(\help_PlayBuf, { arg out=0, bufnum=0;
|
||
|
var trig;
|
||
|
trig = Impulse.kr(MouseY.kr(0.5, 200, 1));
|
||
|
Out.ar(out,
|
||
|
PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), trig, MouseX.kr(0, BufFrames.kr(bufnum)), 1)
|
||
|
)
|
||
|
}).play(s, [\out, 0, \bufnum, b]);
|
||
|
|
||
|
|
||
|
// accelerating pitch
|
||
|
SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
|
||
|
var rate;
|
||
|
rate = XLine.kr(0.1, 100, 60);
|
||
|
Out.ar(out,
|
||
|
PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum)*rate, 1.0, 0.0, 1.0)
|
||
|
)
|
||
|
}).play(s, [\out, 0, \bufnum, b]);
|
||
|
|
||
|
|
||
|
// sine wave control of playback rate. negative rate plays backwards
|
||
|
SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
|
||
|
var rate;
|
||
|
rate = FSinOsc.kr(XLine.kr(0.2, 8, 30), 0, 3, 0.6);
|
||
|
Out.ar(out,
|
||
|
PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum) * rate, 1, 0, 1)
|
||
|
)
|
||
|
}).play(s, [\out, 0, \bufnum, b]);
|
||
|
|
||
|
|
||
|
// zig zag around sound
|
||
|
SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
|
||
|
var rate;
|
||
|
rate = LFNoise2.kr(XLine.kr(1, 20, 60), 2);
|
||
|
Out.ar(out,
|
||
|
PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum) * rate, 1, 0, 1)
|
||
|
)
|
||
|
}).play(s, [\out, 0, \bufnum, b]);
|
||
|
|
||
|
b.free;</pre>
|
||
|
<div class='doclink'>helpfile source: <a href='file:///Applications/SuperCollider.app/Contents/Resources/HelpSource/Classes/PlayBuf.schelp'>/Applications/SuperCollider.app/Contents/Resources/HelpSource/Classes/PlayBuf.schelp</a><br>link::Classes/PlayBuf::<br></div></div></body></html>
|