<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>codehop &#187; user-defined opcode</title>
	<atom:link href="http://codehop.com/tag/user-defined-opcode/feed/" rel="self" type="application/rss+xml" />
	<link>http://codehop.com</link>
	<description>#code #art #music</description>
	<lastBuildDate>Mon, 23 Apr 2012 18:37:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.38</generator>
	<item>
		<title>Additive Synth Legacy Code</title>
		<link>http://codehop.com/additive-synth-legacy-code/</link>
		<comments>http://codehop.com/additive-synth-legacy-code/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 16:20:39 +0000</pubDate>
		<dc:creator><![CDATA[Jacob Joaquin]]></dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[additive]]></category>
		<category><![CDATA[csound journal]]></category>
		<category><![CDATA[steven yi]]></category>
		<category><![CDATA[user-defined opcode]]></category>

		<guid isPermaLink="false">http://csound.noisepages.com/?p=350</guid>
		<description><![CDATA[Let&#8217;s set the way back machine to January 2001. This is around the time I took my first steps into designing an additive synthesizer. I&#8217;m not sure when user-defined opcodes were introduced, though there is a good chance they had &#8230; <a href="http://codehop.com/additive-synth-legacy-code/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Let&#8217;s set the way back machine to January 2001. This is around the time I took my first steps into designing an additive synthesizer. I&#8217;m not sure when user-defined opcodes were introduced, though there is a good chance they had not existed then. And if they did, I had no idea of their existence. Same goes for the event series of opcodes. In my legacy code, each overtone, along with supporting envelopes and transfer functions, were written explicitly. I was a perl junky at the time, so I wrote scripts that would generate the instruments for me.</p>
<p>The example I&#8217;m posting today is the legacy code from 2001. I did not change the code, except for converting tabs to spaces and placing the orc/sco pair into a csd.</p>
<object height="81" width="100%"><param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F2871360&amp;g=1&amp;auto_play=false&amp;show_comments=true&amp;color=&amp;theme_color="></param><param name="allowscriptaccess" value="always"></param><embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F2871360&amp;g=1&amp;auto_play=false&amp;show_comments=true&amp;color=&amp;theme_color=" type="application/x-shockwave-flash" width="100%"> </embed></object>
<p><strong>Download:</strong> <a href="http://www.thumbuki.com/TheCsoundBlog/add_synth_legacy.csd">add_synth_legacy.csd</a></p>
<p>In my new additive synth, I&#8217;m employing a recursive user-defined opcode technique, which I first read about in Steven Yi&#8217;s Csound Journal articles Control Flow <a href="http://www.csounds.com/journal/2006spring/controlFlow.html">Part I</a> and <a href="http://www.csounds.com/journal/2006summer/controlFlow_part2.html">Part II</a>.</p>
<p>If you look at part 2, Steven actually demos an additive synth, which is eerily similar to the core design of the one I&#8217;m in the process of making. Which means I either independently came up with a similar design, or more likely, I&#8217;m suffering from a bout of <a href="http://en.wikipedia.org/wiki/Cryptomnesia">cryptomnesia</a>. Either way, if you haven&#8217;t studied up on these two articles, then perhaps it&#8217;s time you make a weekend project out of it; They are pure gold.</p>
]]></content:encoded>
			<wfw:commentRss>http://codehop.com/additive-synth-legacy-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making Records</title>
		<link>http://codehop.com/making-records/</link>
		<comments>http://codehop.com/making-records/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 21:00:40 +0000</pubDate>
		<dc:creator><![CDATA[Jacob Joaquin]]></dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[abstraction]]></category>
		<category><![CDATA[data structure]]></category>
		<category><![CDATA[ftable]]></category>
		<category><![CDATA[record]]></category>
		<category><![CDATA[user-defined opcode]]></category>

		<guid isPermaLink="false">http://csound.noisepages.com/?p=176</guid>
		<description><![CDATA[Not of the vinyl variety, but the computer science data structure. Csound comes with a few ways of generating, storing and retrieving data, with function tables being the primary data structure. Data can also be placed into global variables and &#8230; <a href="http://codehop.com/making-records/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Not of the vinyl variety, but the computer science <a href="http://en.wikipedia.org/wiki/Data_structure">data structure</a>.</p>
<p>Csound comes with a few ways of generating, storing and retrieving data, with function tables being the primary data structure. Data can also be placed into global variables and chn busses. In terms of data <a href="http://en.wikipedia.org/wiki/Abstraction_(computer_science)">abstractions</a>, there isn&#8217;t a whole lot of choice. However, custom data abstractions and structures can be built from within a Csound orchestra.</p>
<p>In my blog <a href="http://csound.noisepages.com/2009/12/simple-keys-modularized-key-mapping/">Simple Keys &#8212; Modularized Key Mapping</a>, I toyed with storing multiple key bindings, frequencies, amplitudes and function table numbers within a single ftable by treating the ftable as if it were an array of <a href="http://en.wikipedia.org/wiki/Record_(computer_science)">records</a>, albeit a fairly clumsy one. Over the weekend, I continued along this line and distilled it even further.</p>
<p><strong>Download:</strong> <a href="http://www.thumbuki.com/TheCsoundBlog/simple_record.csd">simple_record.csd</a></p>
<p>So far, I&#8217;m very happy with the results. Though the implementation maybe a bit hackish, the user-interface isn&#8217;t bad. This new system of making records is composed of five user-defined opcodes: <em>RecordType</em>, <em>RecordField</em>, <em>Record</em>, <em>RecordSet</em> and <em>RecordGet</em>. I additionally wrote wrapper GEN instruments, so they could be accessed from the score.</p>
<p>The first two, <em>RecordType</em> and <em>RecordField</em>, are used to create record abstractions. <em>RecordType</em> creates a new record type, while <em>RecordField</em> appends data fields to the record type. A record type is built from an ftable, thus shares the function table number space. The following score snippet creates a record type as ftable 100, and appends three fields: amp, freq and ftable.</p>
<pre>i $RecordType  0 1 100           ; Record type stored at fn 100
i $RecordField 0 1 100 "amp"     ; Append field "amp"
i $RecordField 0 1 100 "freq"    ; Append field "freq"
i $RecordField 0 1 100 "ftable"  ; Append field "ftable"</pre>
<p>For a record type to be useful, an instance of it must be created with <em>Record</em>. A record is also an ftable, and requires its own unique function table index. The following line creates a record from record type 100, and stores it in ftable 200:</p>
<pre>i $Record 0 1 200 100  ; Instantiate record 200 from type 100</pre>
<p>Once a record is created, the values of each field can be set with <em>RecordSet</em>:</p>
<pre>i $RecordSet 0 1 200 "amp"    0.5  ; Set field "amp"
i $RecordSet 0 1 200 "freq"   440  ; Set field "freq"
i $RecordSet 0 1 200 "ftable" 1    ; Set field "ftable"</pre>
<p>That&#8217;s just one record created from a single record type. In the <a href="http://www.thumbuki.com/TheCsoundBlog/simple_record.csd">csd</a>, you&#8217;ll see I create two more records from the same record type.</p>
<h4>Example</h4>
<p>The Synth instrument is provided to show a simple example on how to use a record. Instead of passing amplitude, frequency and the function number of a stored single cycle wave as pfield data, a record number is passed to Synth with pfield 4. The user-defined opcode <em>RecordGet</em> is used to pull data from the record. The data is then passed to <em>oscil</em>.</p>
<pre>instr $Synth
    irecord = p4  ; Record function number</pre>
<pre>    iamp RecordGet "amp", irecord        ; Get amplitude from record
    ifreq RecordGet "freq", irecord      ; Get frequency from record
    iftable RecordGet "ftable", irecord  ; Get ftable from record</pre>
<pre>    a1 oscil iamp, ifreq, iftable, -1
    out a1
endin</pre>
<pre>...</pre>
<pre>i $Synth 0 1 200  ; Feed synth record 200</pre>
<p>More on all of this later.</p>
]]></content:encoded>
			<wfw:commentRss>http://codehop.com/making-records/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
