Artifact
c4b42be4bf6e4cd84516aefc90a6710e8a07a2a6ae9bc0154879234526676763:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Early Attempts — Bitrhythm's literate documentation</title>
<link href="_static/css/theme.css" rel="stylesheet" />
<link href="_static/css/index.c5995385ac14fb8791e8eb36b4908be2.css" rel="stylesheet" />
<link rel="stylesheet"
href="_static/vendor/fontawesome/5.13.0/css/all.min.css">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/sphinx-book-theme.e8e5499552300ddf5d7adccae7cc3b70.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/custom.css" />
<link rel="preload" as="script" href="_static/js/index.1c5a1a01449ed65a7b51.js">
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/sphinx-book-theme.12a9622fbb08dcb3a2a40b2c02b83a57.js"></script>
<script src="_static/analytics.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Changelog" href="changelog.html" />
<link rel="prev" title="Core Features" href="tweaking.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="en" />
</head>
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
<div class="container-fluid" id="banner"></div>
<div class="container-xl">
<div class="row">
<div class="col-12 col-md-3 bd-sidebar site-navigation show" id="site-navigation">
<div class="navbar-brand-box">
<a class="navbar-brand text-wrap" href="index.html">
<h1 class="site-logo" id="site-title">Bitrhythm's literate documentation</h1>
</a>
</div><nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
<div class="bd-toc-item active">
<p class="caption">
<span class="caption-text">
Table of Contents
</span>
</p>
<ul class="current nav bd-sidenav">
<li class="toctree-l1">
<a class="reference internal" href="what.html">
What is bitrhythm about ?
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="source-code.html">
Source Code and License
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="demo.html">
Getting Started
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="samples.html">
Samples
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="tweaking.html">
Core Features
</a>
</li>
<li class="toctree-l1 current active">
<a class="current reference internal" href="#">
Early Attempts
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="changelog.html">
Changelog
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="main.html">
Code Walkthrough
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="alternate-implementation.html">
Alternate Implementations
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="saving.html">
Saving / Recording / Streaming
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="credits.html">
Credits
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="bookmarks.html">
Bookmarks
</a>
</li>
</ul>
</div>
</nav> <!-- To handle the deprecated key -->
<div class="navbar_extra_footer">
<a target="_blank" href="/">Bitrhythm App Home</a><br>
<a target="_blank" href="https://xyzzyapps.link">Xyzzy Apps Home</a><br>
<p class='custom-nav-footer'>(c) Xyzzy Apps, 2021</p>
</div>
</div>
<main class="col py-md-3 pl-md-4 bd-content overflow-auto" role="main">
<div class="topbar container-xl fixed-top">
<div class="topbar-contents row">
<div class="col-12 col-md-3 bd-topbar-whitespace site-navigation show"></div>
<div class="col pl-md-4 topbar-main">
<button id="navbar-toggler" class="navbar-toggler ml-0" type="button" data-toggle="collapse"
data-toggle="tooltip" data-placement="bottom" data-target=".site-navigation" aria-controls="navbar-menu"
aria-expanded="true" aria-label="Toggle navigation" aria-controls="site-navigation"
title="Toggle navigation" data-toggle="tooltip" data-placement="left">
<i class="fas fa-bars"></i>
<i class="fas fa-arrow-left"></i>
<i class="fas fa-arrow-up"></i>
</button>
<!-- Source interaction buttons -->
<!-- Full screen (wrap in <a> to have style consistency -->
<a class="full-screen-button"><button type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip"
data-placement="bottom" onclick="toggleFullScreen()" aria-label="Fullscreen mode"
title="Fullscreen mode"><i
class="fas fa-expand"></i></button></a>
<!-- Launch buttons -->
</div>
<!-- Table of contents -->
<div class="d-none d-md-block col-md-2 bd-toc show">
</div>
</div>
</div>
<div id="main-content" class="row">
<div class="col-12 col-md-9 pl-md-3 pr-md-0">
<div>
<div class="section" id="early-attempts">
<h1>Early Attempts<a class="headerlink" href="#early-attempts" title="Permalink to this headline">ΒΆ</a></h1>
<p>My first attempt at this project was called bang256 ~ 2016, meant to mess with Renoiseβs OSC. Its still usable.</p>
<p>The music loop for OSC sequencing. You need to install osc and nanotimer. Alternatively you can use portmidi</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">var</span> <span class="n">fs</span> <span class="o">=</span> <span class="n">require</span><span class="p">(</span><span class="s2">"fs"</span><span class="p">);</span>
<span class="n">var</span> <span class="n">osc</span> <span class="o">=</span> <span class="n">require</span><span class="p">(</span><span class="s2">"osc"</span><span class="p">);</span>
<span class="n">var</span> <span class="n">NanoTimer</span> <span class="o">=</span> <span class="n">require</span><span class="p">(</span><span class="s1">'nanotimer'</span><span class="p">);</span>
<span class="n">var</span> <span class="n">timer</span> <span class="o">=</span> <span class="n">new</span> <span class="n">NanoTimer</span><span class="p">();</span>
<span class="n">function</span> <span class="n">bang256</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">port</span><span class="p">,</span> <span class="n">tempo</span><span class="p">,</span> <span class="n">lines_per_beat</span><span class="p">,</span> <span class="n">measure</span><span class="p">,</span> <span class="n">tracks</span><span class="p">,</span> <span class="n">title</span><span class="p">)</span> <span class="p">{</span>
<span class="n">var</span> <span class="n">udpPort</span> <span class="o">=</span> <span class="n">new</span> <span class="n">osc</span><span class="o">.</span><span class="n">UDPPort</span><span class="p">({</span>
<span class="n">remoteAddress</span><span class="p">:</span> <span class="n">host</span><span class="p">,</span>
<span class="n">remotePort</span><span class="p">:</span> <span class="n">port</span>
<span class="p">});</span>
<span class="n">udpPort</span><span class="o">.</span><span class="n">open</span><span class="p">();</span>
<span class="n">var</span> <span class="n">beat</span> <span class="o">=</span> <span class="mf">60.0</span> <span class="o">/</span> <span class="n">tempo</span><span class="p">;</span>
<span class="n">var</span> <span class="n">lines_per_measure</span> <span class="o">=</span> <span class="n">lines_per_beat</span> <span class="o">*</span> <span class="n">measure</span><span class="p">;</span>
<span class="n">var</span> <span class="n">tick</span> <span class="o">=</span> <span class="n">beat</span> <span class="o">/</span> <span class="n">lines_per_beat</span><span class="p">;</span>
<span class="n">var</span> <span class="n">bangs</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="n">var</span> <span class="n">count</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="n">timer</span><span class="o">.</span><span class="n">setInterval</span><span class="p">(</span><span class="n">function</span><span class="p">()</span> <span class="p">{</span>
<span class="n">var</span> <span class="n">bang</span> <span class="o">=</span> <span class="p">(</span><span class="n">bangs</span> <span class="o">%</span> <span class="n">lines_per_measure</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">bang</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
<span class="n">count</span><span class="o">++</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">for</span> <span class="p">(</span><span class="n">var</span> <span class="n">t</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">t</span> <span class="o"><=</span> <span class="n">tracks</span><span class="p">;</span> <span class="n">t</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="n">var</span> <span class="n">path</span> <span class="o">=</span> <span class="n">title</span> <span class="o">+</span> <span class="s2">"/"</span> <span class="o">+</span> <span class="n">t</span><span class="p">;</span>
<span class="k">if</span> <span class="p">(</span><span class="n">fs</span><span class="o">.</span><span class="n">existsSync</span><span class="p">(</span><span class="n">path</span><span class="p">))</span> <span class="p">{</span>
<span class="n">var</span> <span class="n">code</span> <span class="o">=</span> <span class="n">fs</span><span class="o">.</span><span class="n">readFileSync</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="p">{</span><span class="n">encoding</span><span class="p">:</span> <span class="s1">'utf-8'</span><span class="p">});</span>
<span class="n">var</span> <span class="n">f</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="n">code</span><span class="p">);</span>
<span class="n">f</span><span class="p">(</span><span class="n">udpPort</span><span class="p">,</span> <span class="n">bang</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">bangs</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="n">bangs</span><span class="o">++</span><span class="p">;</span>
<span class="p">},</span> <span class="s1">''</span><span class="p">,</span> <span class="n">tick</span> <span class="o">+</span> <span class="s2">"s"</span><span class="p">);</span>
<span class="p">}</span>
<span class="n">var</span> <span class="n">argv</span> <span class="o">=</span> <span class="n">require</span><span class="p">(</span><span class="s1">'minimist'</span><span class="p">)(</span><span class="n">process</span><span class="o">.</span><span class="n">argv</span><span class="o">.</span><span class="n">slice</span><span class="p">(</span><span class="mi">2</span><span class="p">));</span>
<span class="n">var</span> <span class="n">bang256</span> <span class="o">=</span> <span class="n">require</span><span class="p">(</span><span class="s2">"bang256"</span><span class="p">)</span><span class="o">.</span><span class="n">bang256</span><span class="p">;</span>
<span class="n">var</span> <span class="n">host</span> <span class="o">=</span> <span class="n">argv</span><span class="p">[</span><span class="s2">"host"</span><span class="p">]</span> <span class="o">||</span> <span class="s2">"127.0.0.1"</span><span class="p">;</span>
<span class="n">var</span> <span class="n">port</span> <span class="o">=</span> <span class="n">argv</span><span class="p">[</span><span class="s2">"port"</span><span class="p">]</span> <span class="o">||</span> <span class="mi">8000</span><span class="p">;</span>
<span class="n">var</span> <span class="n">tempo</span> <span class="o">=</span> <span class="n">argv</span><span class="p">[</span><span class="s2">"tempo"</span><span class="p">];</span>
<span class="n">var</span> <span class="n">lines_per_beat</span> <span class="o">=</span> <span class="n">argv</span><span class="p">[</span><span class="s2">"lpb"</span><span class="p">]</span> <span class="o">||</span> <span class="mi">4</span><span class="p">;</span>
<span class="n">var</span> <span class="n">measure</span> <span class="o">=</span> <span class="n">argv</span><span class="p">[</span><span class="s2">"measure"</span><span class="p">]</span> <span class="o">||</span> <span class="mi">4</span><span class="p">;</span>
<span class="n">var</span> <span class="n">tracks</span> <span class="o">=</span> <span class="n">argv</span><span class="p">[</span><span class="s2">"tracks"</span><span class="p">]</span> <span class="o">||</span> <span class="mi">4</span><span class="p">;</span>
<span class="n">var</span> <span class="n">title</span> <span class="o">=</span> <span class="n">argv</span><span class="p">[</span><span class="s2">"title"</span><span class="p">];</span>
<span class="n">bang256</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">port</span><span class="p">,</span> <span class="n">tempo</span><span class="p">,</span> <span class="n">lines_per_beat</span><span class="p">,</span> <span class="n">measure</span><span class="p">,</span> <span class="n">tracks</span><span class="p">,</span> <span class="n">title</span><span class="p">);</span>
</pre></div>
</div>
<p>To run,</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">node</span> <span class="o">./</span><span class="n">bang256</span> <span class="o">-</span><span class="n">host</span> <span class="s2">"127.0.0.1"</span> <span class="o">--</span><span class="n">tempo</span><span class="o">=</span><span class="mi">120</span> <span class="o">--</span><span class="n">lpb</span><span class="o">=</span><span class="mi">4</span> <span class="o">--</span><span class="n">measure</span><span class="o">=</span><span class="mi">4</span> <span class="o">--</span><span class="n">tracks</span><span class="o">=</span><span class="mi">4</span> <span class="o">--</span><span class="n">title</span><span class="o">=</span><span class="n">foo</span>
</pre></div>
</div>
<p>Edit files in foo/1 and foo/2 and foo/3 and foo/4 to create live music with an OSC compatible synthesizer.</p>
<p>Inside the file <code class="docutils literal notranslate"><span class="pre">foo/1</span></code></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="n">function</span> <span class="p">(</span><span class="n">osc</span><span class="p">,</span> <span class="n">bang</span><span class="p">,</span> <span class="n">count</span><span class="p">,</span> <span class="n">bangs</span><span class="p">,</span> <span class="n">thread</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">([</span><span class="mi">4</span><span class="p">,</span> <span class="mi">12</span><span class="p">]</span><span class="o">.</span><span class="n">indexOf</span><span class="p">(</span><span class="n">bang</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
<span class="n">var</span> <span class="n">msg</span> <span class="o">=</span> <span class="p">{</span>
<span class="n">address</span><span class="p">:</span> <span class="s2">"/renoise/trigger/note_on"</span><span class="p">,</span>
<span class="n">args</span><span class="p">:</span> <span class="p">[</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">38</span><span class="p">,</span> <span class="mi">127</span><span class="p">],</span>
<span class="p">};</span>
<span class="n">osc</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">msg</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">})</span>
</pre></div>
</div>
<p><a class="reference external" href="https://www.perl.com/pub/2004/08/31/livecode.html/">https://www.perl.com/pub/2004/08/31/livecode.html/</a> also uses the ticks approach but uses a message bus for events.<br />
<a class="reference external" href="https://github.com/psenough/teach_yourself_demoscene_in_14_days">https://github.com/psenough/teach_yourself_demoscene_in_14_days</a></p>
</div>
</div>
<div class='prev-next-bottom'>
<a class='left-prev' id="prev-link" href="tweaking.html" title="previous page">Core Features</a>
<a class='right-next' id="next-link" href="changelog.html" title="next page">Changelog</a>
</div>
</div>
</div>
<footer class="footer mt-5 mt-md-0">
<div class="container">
<p>
By Xyzzy Apps<br/>
© Copyright (c) Xyzzy Apps, 2021.<br/>
</p>
</div>
</footer>
</main>
</div>
</div>
<script src="_static/js/index.1c5a1a01449ed65a7b51.js"></script>
</body>
</html>