<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Devin Lane]]></title><description><![CDATA[Devin Lane]]></description><link>https://blog.devinlane.com</link><generator>RSS for Node</generator><lastBuildDate>Sat, 16 May 2026 16:52:01 GMT</lastBuildDate><atom:link href="https://blog.devinlane.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Phase Music]]></title><description><![CDATA[Listen to the result here
What is Phase Music?
Following inspiration from Tero Parviainen's writing on "systems music", I've created phase music in the spirit of Steve Reich's It's Gonna Rain.
"Systems Music" explores how a process applied to sound c...]]></description><link>https://blog.devinlane.com/phase-music</link><guid isPermaLink="true">https://blog.devinlane.com/phase-music</guid><category><![CDATA[Web Audio]]></category><category><![CDATA[audio]]></category><category><![CDATA[music]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Devin Lane]]></dc:creator><pubDate>Wed, 04 Jan 2023 22:15:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/138648c9054ad724f554715b83f28178.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a target="_blank" href="https://phase-music.netlify.app/">Listen to the result here</a></p>
<h2 id="heading-what-is-phase-music">What is Phase Music?</h2>
<p>Following inspiration from <a target="_blank" href="https://teropa.info/blog/2016/07/28/javascript-systems-music.html">Tero Parviainen's</a> writing on <a target="_blank" href="https://en.wikipedia.org/wiki/Systems_music">"systems music"</a>, I've created <a target="_blank" href="https://en.wikipedia.org/wiki/Phase_music">phase music</a> in the spirit of Steve Reich's <a target="_blank" href="https://en.wikipedia.org/wiki/It%27s_Gonna_Rain">It's Gonna Rain.</a></p>
<p>"Systems Music" explores how a process applied to sound creates slowly evolving changes. Phase music explores how two identical musical phrases played with a steady, but slightly different, tempo on two different instruments creates new rhythms and harmonies over time.</p>
<p>I discovered Tero's work when he was a judge for <a target="_blank" href="https://bitrate.devpost.com/">BitRate</a>, <a target="_blank" href="https://magenta.tensorflow.org/">Google Magenta</a>'s music and machine learning hackathon. My team won the contest for our work on <a target="_blank" href="https://deardiary.ai/">Dear Diary</a> in 2020, which I detailed <a target="_blank" href="https://magenta.tensorflow.org/dear-diary">here</a>.</p>
<h2 id="heading-why-make-this">Why make this?</h2>
<p>I'm interested in exploring web audio as a compositional tool. This includes, for example, systems music, generative music, data sonification, and effects processing--viewing code as a musical instrument and the web as a musical medium.</p>
<p>I intend tools like these to enable new musical expression for both experienced and novice musicians.</p>
<h2 id="heading-how-does-it-work">How does it work?</h2>
<ul>
<li><p>I wrote a piece of music and took a small snippet as a loop.</p>
</li>
<li><p>Two identical loops of this piece are played, one panned to your left speaker, and one panned to your right speaker (because of this, the effects will be more pronounced on headphones or two individual stereo speakers.)</p>
</li>
<li><p>The playback speeds differ slightly between the two loops, which causes their <a target="_blank" href="https://en.wikipedia.org/wiki/Phase_(waves)">phase</a> to shift over time, resulting in new harmonies and rhythms as they grow out of alignment and back again.</p>
</li>
</ul>
<h2 id="heading-how-did-you-make-it">How did you make it?</h2>
<p>The Web Audio API and JavaScript play central roles here. As previously mentioned, <a target="_blank" href="https://teropa.info/blog/2016/07/28/javascript-systems-music.html">Tero's blog</a> was an invaluable resource in building this.</p>
<ol>
<li><p>We set up an <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/AudioContext"><code>AudioContext()</code></a></p>
</li>
<li><p>When <code>play</code> is pressed, a function <code>getSound</code> is called, which uses the Fetch API to grab the audio file.</p>
</li>
<li><p>The audio file is fed into a raw <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer"><code>ArrayBuffer</code></a> object, then we call the <code>decodeAudioData()</code> method to decode the audio data from the <code>ArrayBuffer</code>. This is our <code>audioBuffer</code>.</p>
</li>
<li><p>We call a separate function <code>startLoop</code> twice, panning one loop hard left, one hard right. We set the playback speed of one loop ~0.005 faster than the other.</p>
</li>
<li><p>Within <code>startLoop</code> we call <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode"><code>AudioBufferSourceNode</code></a>, which reads our <code>audioBuffer</code>.</p>
</li>
<li><p>We then set up our panning, our loop points, and we connect the nodes to the destination of our <code>AudioContext</code>.</p>
</li>
<li><p>Importantly, we build a <code>stop</code> button, which calls the <code>.stop()</code> method on our <code>sourceNode</code>.</p>
</li>
</ol>
<h2 id="heading-what-optimizations-would-you-build-with-more-time">What optimizations would you build with more time?</h2>
<p>Some features that I haven't built that would be nice:</p>
<ul>
<li><p>Allow users to upload audio files</p>
</li>
<li><p>Add user control for the loop start and stop points</p>
</li>
<li><p>Add user control for the audio playback speed</p>
</li>
<li><p>Add user control for the panning</p>
</li>
<li><p>Add a record feature, allowing downloadable audio files</p>
</li>
<li><p>Allow users to create accounts and save their work</p>
</li>
<li><p>Allow users to share their work with a link to the site</p>
</li>
</ul>
<h2 id="heading-where-can-i-hear-the-result">Where can I hear the result?</h2>
<p><a target="_blank" href="https://phase-music.netlify.app/">The website with the audio is here</a>.</p>
<h2 id="heading-can-i-see-the-code">Can I see the code?</h2>
<p><a target="_blank" href="https://github.com/DevinCLane/phase-music">The source code is here</a>.</p>
]]></content:encoded></item></channel></rss>