<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[The 1-Bit Forum — Tutorial: How to Write a 1-Bit Music Routine]]></title>
		<link>http://randomflux.info/1bit/viewtopic.php?id=21</link>
		<atom:link href="https://randomflux.info/1bit/extern.php?action=feed&amp;tid=21&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Tutorial: How to Write a 1-Bit Music Routine.]]></description>
		<lastBuildDate>Sat, 07 Oct 2023 08:22:37 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2926#p2926</link>
			<description><![CDATA[<p>Hi Krzysztof,</p><p>Not sure what Chris Walsh means, I don&#039;t see any errors in the first routine.</p><p>Good point about RAM contention from Simon N Goodwin though. I&#039;ll add a little note on that. IO contention is mentioned in Part 5, I don&#039;t think readers need to be overly concerned about it before that point.</p><p>Anyway, thanks for passing on the feedback.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Sat, 07 Oct 2023 08:22:37 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2926#p2926</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2925#p2925</link>
			<description><![CDATA[<p>UTZ,</p><p>Before sharing the document here, I have shared in on FB in <a href="https://www.facebook.com/groups/z80asm/,">https://www.facebook.com/groups/z80asm/,</a> where I got suggestions to actually contact you via this forum.</p><p>In the meantime, I have received following feedback, that might be interesting for you:</p><p>* Chris Walsh<br />Hiya, just looking at the very first routine, and something isn&#039;t right about the A (&quot;state&quot;) register and the OUT commands. For example, you&#039;re setting A to 0 (XOR A) on the first line before the channel 1 loop but then setting it to 10h after the look and just after the OUT. The same issue occurs in the channel 2 routine. Are you missing two more OUTs after setting the A register? Thanks for the docs BTW.</p><p>* from Simon N Goodwin:<br />Thanks for sharing.<br />In the context of the Spectrum (the focus of this group) it would be wise to remind readers that RAM as well as I/O is contended so loops like this should be in ROM (the only option for a 16K Spectrum) or the top 32K of 48K Spectrum RAM, or the right 64K half (which varies by model) of RAM on a Spectrum 128. If you haven’t altered the default paging, RAM addresses from 32768 to 49151 are always uncontended.<br />As regards source readability, the comments need rewrapping - they run off the edge of the PDF pages.</p>]]></description>
			<author><![CDATA[null@example.com (krzysztof.kielak)]]></author>
			<pubDate>Thu, 05 Oct 2023 19:29:34 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2925#p2925</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2923#p2923</link>
			<description><![CDATA[<p>Excellent, thanks a lot. I originally had the tutorial in an .org file, but gave up on it somewhere down the line. This&#039;ll be a good opportunity to get things in order on my side, hehe.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Wed, 04 Oct 2023 15:33:59 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2923#p2923</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2921#p2921</link>
			<description><![CDATA[<p>Here you are! I have attached .tgz file with all .tex sources - for building I&#039;m using pdflatex command from TeX Live system (executed twice to build ToC etc.). The file main.tex includes structure.tex and tutorial.tex (that is actually exported from Emacs .org file).</p><p>I have also included the .org file that I have originally used to copy paste from the forum and then used Emacs export to LaTeX functionality (only body export using following mouthful chord:&nbsp; C c C e C b l l). I think at this point you can update only .tex files, and discard tutoria.org file.</p>]]></description>
			<author><![CDATA[null@example.com (krzysztof.kielak)]]></author>
			<pubDate>Mon, 02 Oct 2023 21:27:45 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2921#p2921</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2919#p2919</link>
			<description><![CDATA[<p>This is great</p>]]></description>
			<author><![CDATA[null@example.com (AtariTufty)]]></author>
			<pubDate>Mon, 02 Oct 2023 19:36:51 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2919#p2919</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2916#p2916</link>
			<description><![CDATA[<p>Thanks, looks great! Do you happen to have *tex sources for this? I&#039;m updating the tutorial every now and then, and I don&#039;t want to burden you with updating the pdf every time that happens.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Mon, 02 Oct 2023 19:13:48 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2916#p2916</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2915#p2915</link>
			<description><![CDATA[<p>Hi, I have converted this fantastic tutorial by UTZ to PDF format. Have fun!</p>]]></description>
			<author><![CDATA[null@example.com (krzysztof.kielak)]]></author>
			<pubDate>Mon, 02 Oct 2023 08:59:39 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2915#p2915</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2898#p2898</link>
			<description><![CDATA[<p>D&#039;oh! I was looking at a different part of the tutorial. Thanks for your patience, I&#039;ve corrected the error now.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Wed, 09 Aug 2023 19:41:20 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2898#p2898</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2896#p2896</link>
			<description><![CDATA[<p>Hi, I didn&#039;t mean to move <strong>LD A, IXH/L</strong> for saving the T-states, I meant to move the instructions for reading the current speaker states back into <strong>A</strong> register because checking if IX is zero changes <strong>A</strong> and would completely destroy the sound. And even if <strong>A</strong> wouldn&#039;t be changed when checking if IX is zero the routine wouldn&#039;t update the speaker states of channel1 and channel2 when <strong>JR NZ</strong> jumps are taken which is most of the time. This is what I meant:</p><div class="codebox"><pre><code>            ld h,0
            ld l,0
soundloop   dec b
            ld a,h                  ; I moved this above JR NZ
            jr nz,skip1
            xor #10
            ld h,a
            ld b,c
skip1       out (#fe),a
            dec d
            ld a,l                  ; I moved this above JR NZ
            jr nz,skip2
            xor #10
            ld l,a
            ld d,e
skip2       out (#fe),a
            dec ix
            ld a,ixh                ; These destroy A register which is holding the speaker state in...
            or ixl                  ; ...case of both JR NZ jumps are taken which is most of the time
            jr nz,soundloop</code></pre></div><p>How exactly did you mean to move <strong>LD A, IXH/L</strong> to save 8 T-states?</p>]]></description>
			<author><![CDATA[null@example.com (chupo_cro)]]></author>
			<pubDate>Tue, 08 Aug 2023 20:56:19 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2896#p2896</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2893#p2893</link>
			<description><![CDATA[<p>Thanks for spotting and reporting these! I&#039;ve corrected No. 2 and 3.</p><p>I&#039;m inclined to leave the part on Pulse Interleaving as is. You are of course correct in that moving the ld a,ixh/l up would save 8t here, but I&#039;m concerned that it might make it harder to see the connection with the pseudo-code on the left. In the end a proper player should not be written like this anyway, because you&#039;d still end up with an all-too-large, 10t timing difference between the skip-taken and skip-not-taken paths.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Tue, 08 Aug 2023 10:55:25 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2893#p2893</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2892#p2892</link>
			<description><![CDATA[<p>Hi, excellent tutorial!</p><p>While I was reading I noticed a few things that might or might not have to be corrected. In <strong>Pulse Interleaving</strong> routine most of the time the loop would jump through both <strong>JR NZ,SKIPx</strong> jumps and at the end the <strong>A</strong> register would be changed to <strong>IXH OR IXL</strong> and then output to port 254. That could be avoided by moving <strong>LD A,H</strong> and <strong>LD A,L</strong> above <strong>JR NZ,SKIPx</strong> instructions.</p><p>In <strong>Variable Pulse Width</strong> routine I think the state would be changed when couter wraps from <strong>#7FFF to #8000</strong> and not when it wraps from #8000 to #8001 because carry is 1 when H goes from #00 to #7F and when H becomes #80 then carry becomes zero. The other reason why the state can&#039;t be changed when counter wraps from #8000 to #8001 is because we are checking only high byte so the state can&#039;t be changed when the change is in only low byte.</p><p>In <strong>Achieving Simple PCM with Wavetable Synthesis</strong> there are multiple <strong>RCLA</strong> instructions where there should be <strong>RLCA</strong></p>]]></description>
			<author><![CDATA[null@example.com (chupo_cro)]]></author>
			<pubDate>Tue, 08 Aug 2023 04:28:45 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2892#p2892</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2218#p2218</link>
			<description><![CDATA[<p>From what I remember of my experiments back in the day, there is no noticable benefit to distributing the 1s like this, except for many consecutive 1s - eg. 11101110 is sometimes a bit cleaner than 11111100. I&#039;d say it&#039;s not worth spending extra CPU cylces on, though.</p><p>Part 10 is actually a bit outdated, in part 12 you will find a better synthesis method that can also be adapted to PCM playback. In a sense, the same caveat about consecutive 1s applies to that, though, e.g. having two 3-bit outputs will be cleaner than having one 4-bit output, but having one 4-bit output saves 24 cycles...</p><p>In any case there are some interesting effects that can be observed in this regard. This is because the expansion of a speaker diaphragm isn&#039;t linear, so at volumes &gt;50% it will react differently than &lt;50%. So far nobody has been able to really make use of that, though.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Wed, 02 Dec 2020 20:08:08 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2218#p2218</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2217#p2217</link>
			<description><![CDATA[<p>Hello. I have a question about Part 10 (&quot;PCM replay&quot;):<br />Proposed scheme uses five volume levels:<br />&nbsp; 0%&nbsp; &nbsp; 00000000&nbsp; #00<br /> 25%&nbsp; &nbsp; 00010000&nbsp; #10<br /> 50%&nbsp; &nbsp; 00011000&nbsp; #18<br /> 75%&nbsp; &nbsp; 00011100&nbsp; #1c<br />100%&nbsp; &nbsp; 00011110&nbsp; #1e <br />I am wondering if the quality will improve, if we will use more delicate on/off scheme, I mean, if &quot;0&quot; and &quot;1&quot; are placed more uniformly:<br />00010000<br />00010100&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />00010101<br />00011110<br />Does it makes sense?</p>]]></description>
			<author><![CDATA[null@example.com (perevalovds)]]></author>
			<pubDate>Wed, 02 Dec 2020 03:55:33 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2217#p2217</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=1335#p1335</link>
			<description><![CDATA[<p>Hmm, I believe in most cases, especially with engines with few channels, there is actually at least one change every row. Also, as you know I always use a per-row speed setting. In that case it&#039;s something that should be handled on the tracker/converter end - if there is no change, simply increase the previous row length. Nevertheless, I&#039;m sure there will be other cases where this &quot;store only changes&quot; approach is useful. In either way, it&#039;s a good reminder to keep thinking about song data structure. Got kind of sloppy with that myself. I&#039;m perhaps too content with my current stack-read/skip-on-flag approach.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Sun, 18 Jun 2017 20:13:08 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=1335#p1335</guid>
		</item>
		<item>
			<title><![CDATA[Re: Tutorial: How to Write a 1-Bit Music Routine]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=1334#p1334</link>
			<description><![CDATA[<p>Thought to make a note on the row transition noise. There is a way to minimize it. The idea is to avoid row transitions as is. Rather than storing song as a set of rows, with constant skipping of empty fields, store delays between any actual changes that is taking place. This should keep the sound loop tight, and longer gaps when actual changes happens will be masked by the fact that these changes actually change/restart a note, or trigger a drum, i.e. introduce a major change in the sound anyway.</p><p>I.e., rather than:</p><p>C-1 ...<br />... ...<br />... ...<br />... ...<br />... C-2<br />... ...<br />C-1 E-2</p><p>have:</p><p>C-1 ... &gt; run sound loop for four rows without parsing anything<br />... C-2 &gt; run sound loop for two rows<br />C-1 E-2</p>]]></description>
			<author><![CDATA[null@example.com (Shiru)]]></author>
			<pubDate>Sun, 18 Jun 2017 13:46:49 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=1334#p1334</guid>
		</item>
	</channel>
</rss>
