Skip to content

Commit

Permalink
loscilx example
Browse files Browse the repository at this point in the history
  • Loading branch information
jpffitch committed Apr 21, 2015
1 parent 63de73b commit 99f1dcc
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 4 deletions.
67 changes: 67 additions & 0 deletions examples-xml/loscilx.csd.xml
@@ -0,0 +1,67 @@
<programlisting>
<emphasis role="csdtag">&lt;CsoundSynthesizer&gt;</emphasis>
<emphasis role="csdtag">&lt;CsOptions&gt;</emphasis>
<emphasis role="comment">; Select audio/midi flags here according to platform</emphasis>
-odac <emphasis role="comment">;;;realtime audio out</emphasis>
<emphasis role="comment">;-iadc ;;;uncomment -iadc if realtime audio input is needed too</emphasis>
<emphasis role="comment">; For Non-realtime ouput leave only the line below:</emphasis>
<emphasis role="comment">; -o loscil.wav -W ;;; for file output any platform</emphasis>
<emphasis role="csdtag">&lt;/CsOptions&gt;</emphasis>
<emphasis role="csdtag">&lt;CsInstruments&gt;</emphasis>

<emphasis role="ohdr">sr</emphasis> <emphasis role="op">=</emphasis> 44100
<emphasis role="ohdr">kr</emphasis> <emphasis role="op">=</emphasis> 44100
<emphasis role="ohdr">ksmps</emphasis> <emphasis role="op">=</emphasis> 1
<emphasis role="ohdr">nchnls</emphasis> <emphasis role="op">=</emphasis> 2
<emphasis role="ohdr">0dbfs</emphasis> <emphasis role="op">=</emphasis> 1.0

gS_loop <emphasis role="op">=</emphasis> "kickroll.wav"
gisr <emphasis role="opc">filesr</emphasis> gS_loop
gilength <emphasis role="opc">filelen</emphasis> gS_loop
gibeats <emphasis role="op">=</emphasis> 16
gi_sampleleft <emphasis role="ohdr">ftgen</emphasis> 1, 0, 0, 1, gS_loop, 0, 4, 0

<emphasis role="oblock">instr</emphasis> 1
idur <emphasis role="op">=</emphasis> p3
iamp <emphasis role="op">=</emphasis> p4
ibeat <emphasis role="op">=</emphasis> p5
itune <emphasis role="op">=</emphasis> p6
ipos <emphasis role="op">=</emphasis> ibeat <emphasis role="op">/</emphasis> gibeats <emphasis role="op">*</emphasis> gilength <emphasis role="op">*</emphasis> gisr

aenv <emphasis role="opc">linseg</emphasis> iamp, idur <emphasis role="op">-</emphasis> 0.01, iamp, 0.01, 0
a1, a2 <emphasis role="opc">loscilx</emphasis> aenv, itune, 1, 0, 1, ipos, 0
<emphasis role="opc">outs</emphasis> a1, a2
<emphasis role="oblock">endin</emphasis>

<emphasis role="csdtag">&lt;/CsInstruments&gt;</emphasis>
<emphasis role="csdtag">&lt;CsScore&gt;</emphasis>

<emphasis role="stamnt">t</emphasis> 0 170

<emphasis role="comment">; Measure 1</emphasis>
<emphasis role="stamnt">i</emphasis> 1 0.0 0.5 0.707 0 1
<emphasis role="stamnt">i</emphasis> 1 1.0 0.5 0.707 1 1
<emphasis role="stamnt">i</emphasis> 1 2.5 0.5 0.707 0 1
<emphasis role="stamnt">i</emphasis> 1 3.0 0.5 0.707 1 1

<emphasis role="comment">; Measure 2</emphasis>
<emphasis role="stamnt">i</emphasis> 1 4.0 0.5 0.707 0 1
<emphasis role="stamnt">i</emphasis> 1 5.0 0.5 0.707 1 1
<emphasis role="stamnt">i</emphasis> 1 6.5 0.5 0.707 0 1
<emphasis role="stamnt">i</emphasis> 1 7.0 0.5 0.707 1 1

<emphasis role="comment">; Measure 3</emphasis>
<emphasis role="stamnt">i</emphasis> 1 8.0 0.5 0.707 0 1
<emphasis role="stamnt">i</emphasis> 1 9.0 0.5 0.707 1 1
<emphasis role="stamnt">i</emphasis> 1 10.5 0.5 0.707 0 1
<emphasis role="stamnt">i</emphasis> 1 11.0 0.5 0.707 1 1

<emphasis role="comment">; Measure 4</emphasis>
<emphasis role="stamnt">i</emphasis> 1 12.0 0.5 0.707 0 1
<emphasis role="stamnt">i</emphasis> 1 13.0 0.5 0.707 1 1
<emphasis role="stamnt">i</emphasis> 1 14.5 0.5 0.707 0 1
<emphasis role="stamnt">i</emphasis> 1 15.0 0.5 0.707 1 1

<emphasis role="csdtag">&lt;/CsScore&gt;</emphasis>
<emphasis role="csdtag">&lt;/CsoundSynthesizer&gt;</emphasis>
</programlisting>
66 changes: 66 additions & 0 deletions examples/loscilx.csd
@@ -0,0 +1,66 @@
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac ;;;realtime audio out
;-iadc ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o loscil.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
kr = 44100
ksmps = 1
nchnls = 2
0dbfs = 1.0
gS_loop = "kickroll.wav"
gisr filesr gS_loop
gilength filelen gS_loop
gibeats = 16
gi_sampleleft ftgen 1, 0, 0, 1, gS_loop, 0, 4, 0
instr 1
idur = p3
iamp = p4
ibeat = p5
itune = p6
ipos = ibeat / gibeats * gilength * gisr
aenv linseg iamp, idur - 0.01, iamp, 0.01, 0
a1, a2 loscilx aenv, itune, 1, 0, 1, ipos, 0
outs a1, a2
endin
</CsInstruments>
<CsScore>
t 0 170
; Measure 1
i 1 0.0 0.5 0.707 0 1
i 1 1.0 0.5 0.707 1 1
i 1 2.5 0.5 0.707 0 1
i 1 3.0 0.5 0.707 1 1
; Measure 2
i 1 4.0 0.5 0.707 0 1
i 1 5.0 0.5 0.707 1 1
i 1 6.5 0.5 0.707 0 1
i 1 7.0 0.5 0.707 1 1
; Measure 3
i 1 8.0 0.5 0.707 0 1
i 1 9.0 0.5 0.707 1 1
i 1 10.5 0.5 0.707 0 1
i 1 11.0 0.5 0.707 1 1
; Measure 4
i 1 12.0 0.5 0.707 0 1
i 1 13.0 0.5 0.707 1 1
i 1 14.5 0.5 0.707 0 1
i 1 15.0 0.5 0.707 1 1
</CsScore>
</CsoundSynthesizer>

2 changes: 1 addition & 1 deletion opcodes/loscil.xml
Expand Up @@ -110,7 +110,7 @@ a1, a2 <emphasis role="opc">loscil</emphasis> 10000, 1, 1, 1 ,1</programlisting>
<refsect1>
<title>Examples</title>
<para>
Here is an example of the loscil opcode. It uses the file <ulink url="examples/loscil.csd"><citetitle>loscil.csd</citetitle></ulink>, <ulink url="examples/mary.wav"><citetitle>mary.wav</citetitle></ulink> and <ulink url="examples/kickroll.wav"><citetitle>kickroll.wav</citetitle></ulink>.
Here is an example of the loscil opcode. It uses the files <ulink url="examples/loscil.csd"><citetitle>loscil.csd</citetitle></ulink>, <ulink url="examples/mary.wav"><citetitle>mary.wav</citetitle></ulink> and <ulink url="examples/kickroll.wav"><citetitle>kickroll.wav</citetitle></ulink>.
<example>
<title>Example of the loscil opcode.</title>
<para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para>
Expand Down
50 changes: 47 additions & 3 deletions opcodes/loscilx.xml
Expand Up @@ -38,7 +38,7 @@
</para>

<para>
<emphasis>iwsize</emphasis> (optiomal) --
<emphasis>iwsize</emphasis> (optiomal) -- window size used in interpolation.
</para>

<para>
Expand All @@ -51,7 +51,9 @@
<emphasis>kcps</emphasis>.
</para>

<para><emphasis>istrt</emphasis> (optional) --
<para><emphasis>istrt</emphasis> (optional, default 0) -- Frame to
start reading the data. If this is not an integer the the data is
interpolated (see <emphasis>iwsize</emphasis>).
</para>

<para><emphasis>imod</emphasis> (optional, default -1) -- play mode
Expand All @@ -71,7 +73,49 @@
the whole length.
</para>
</refsect1>


<refsect1>
<title>Performance</title>

<para>
<emphasis>ar1, ar2, ...</emphasis> -- the output at audio-rate.
The number of outputs must match the number of channels in the
sample file.
</para>

<para>
<emphasis>xamp</emphasis> -- the amplitude of the output signal.
</para>

<para>
<emphasis>kcps</emphasis> -- the factor to read the file. For
example, a value of 1 has no pitch change, 1.5 is up a fifth and
2 an octave.
</para>
<para>
<emphasis>loscilx</emphasis> samples the ftable audio at a rate determined by <emphasis>kcps</emphasis>, then multiplies the result by <emphasis>xamp</emphasis>. The sampling increment for <emphasis>kcps</emphasis> is dependent on the table's base-note frequency <emphasis>ibas</emphasis>, and is automatically adjusted if the orchestra <emphasis>sr</emphasis> value differs from that at which the source was recorded. In this unit, ftable is always sampled with interpolation.
</para>
<para>
If sampling reaches the <emphasis>sustain loop</emphasis> endpoint and looping is in effect, the point of sampling will be modified and <emphasis>loscil</emphasis> will continue reading from within that loop segment. Once the instrument has received a <emphasis>turnoff</emphasis> signal (from the score or from a MIDI noteoff event), the next sustain endpoint encountered will be ignored and sampling will continue towards the <emphasis>release loop</emphasis> end-point, or towards the last sample (henceforth to zeros).
</para>

<para>
If you want to loop the whole file, specify a looping mode in <emphasis>imod</emphasis> and do not enter any values for <emphasis>ibeg</emphasis> and <emphasis>iend</emphasis>.
</para>

</refsect1>
<refsect1>
<title>Examples</title>
<para>
Here is an example of the loscilx opcode. It uses the files <ulink url="examples/loscil.csd"><citetitle>loscil.csd</citetitle></ulink> and <ulink url="examples/kickroll.wav"><citetitle>kickroll.wav</citetitle></ulink>.
<example>
<title>Example of the loscilx opcode.</title>
<para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para>
<xi:include href="examples-xml/loscilx.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</example>
</para>
</refsect1>

<refsect1>
<title>See Also</title>
<para><link linkend="loscil"><citetitle>loscil</citetitle></link></para>
Expand Down

0 comments on commit 99f1dcc

Please sign in to comment.