<?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 — In-game (during gameplay) music]]></title>
		<link>http://randomflux.info/1bit/viewtopic.php?id=154</link>
		<atom:link href="https://randomflux.info/1bit/extern.php?action=feed&amp;tid=154&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in In-game (during gameplay) music.]]></description>
		<lastBuildDate>Wed, 15 Sep 2021 18:52:34 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2420#p2420</link>
			<description><![CDATA[<p>The problem on Speccy isn&#039;t so much one of finding some free cycles to update graphics. In fact, in PFM and Phaser type engines, you can actually waste quite a few cycles with barely any drawbacks. However, on Speccy we have this thing called memory contention. Very simply said, if you write to or read from certain memory locations on the Speccy, additional wait states will be introduced. While it is possible to predict when those wait states occur, actually writing an engine that will work around these limitations is extremely challenging, so basically nobody bothers. <a href="http://randomflux.info/1bit/viewtopic.php?id=240">AMP16</a> is currently about as good as it gets when it comes to running 1-bit code in contended memory.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Wed, 15 Sep 2021 18:52:34 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2420#p2420</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2417#p2417</link>
			<description><![CDATA[<p>9 months later, and a little bit off-topic from the ZX:<br />I&#039;ve done a lot of fiddling &amp; tinkering on the VZ200 with trying an anything and everything approach with the various players that I&#039;ve got working on the VZ. Randomly select a player and try to get something (ala animated graphics) working , just as a trial and error to see &amp; take note of the differences between the engines to work out what is capable of driving a few moving graphics and what is not.<br />The VZ is somewhat nearly on par with the ZX specs. Many of the players that I&#039;ve managed to port and get running on the VZ, of course, consume or seem to consume near 100% utilisation.<br />I&#039;ve had success with quattropic with bouncing fake equaliser bars in both text mode as well as the VZ&#039;s &quot;high&quot; resolution which is 128x64. Of course this has slowed the music down a fraction - enough to notice, but still listenable.<br />Also I grabbed the ZX10 player and am using it in the background for an unfinished car moving game ; admittedly the sprite-type graphics are very few so far, but what I do have working reads the keyboard fine, moves the graphics incredibly fast and smooth with no noticeable loss in the quality or the speed of the music. <br />Both of these I have added code to where the players original check-for-keyboard-to-quit routine is. So far seems to work ok.</p><p>On the other hand, the likes of Phaser3 is so cycle intensive &amp; specific (and sounding awesome!) that changing or adding anything at all causes sound issues straight away. Took me ages and many attempts to even get it working on the VZ - with my limited knowledge.</p>]]></description>
			<author><![CDATA[null@example.com (bushy555)]]></author>
			<pubDate>Wed, 15 Sep 2021 05:38:32 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2417#p2417</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2220#p2220</link>
			<description><![CDATA[<p>Welcome back, mate! Looking forward to what you will come up with. If you have any questions we&#039;re here to help, of course.<br />I think Hikaru&#039;s new <a href="http://intenseofficial.blogspot.com/2020/09/amp16k-multichannel-sound-on-zx.html#more">AMP16k</a> might be interesting for you to study as well. Generally, the &quot;Squeaker&quot; method used there is a good candidate for in-game music because its CPU requirements are not that high, and it tolerates some deviance in timing as well. Though pin-pulse like synthesis like in Qchan should work well, too.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Fri, 11 Dec 2020 12:36:08 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2220#p2220</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2219#p2219</link>
			<description><![CDATA[<p>I&#039;ve just recently been looking for simple 2 channel engine with decay, for some in-game music, in a very simple game.</p><p>Been trying to cut QChan down to 2 channels, no drums, might be what I need. Small player and small music data.</p><p>Having been away from speccy and coding for some years, I&#039;m a bit rusty at this. And I&#039;ve never written sound routines before, just used what&#039;s available. Currently going through QChan with debugger to document the code so I know exactly what&#039;s going on.</p><p>Edit: Just seen utz tutorial on writing a routine, so I&#039;m going to do that instead. Cheers utz, very helpful that...</p>]]></description>
			<author><![CDATA[null@example.com (FrankT)]]></author>
			<pubDate>Thu, 10 Dec 2020 23:19:39 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2219#p2219</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2132#p2132</link>
			<description><![CDATA[<p>Well, Octode XL used in Rain is not really a pin pulse method, not in the usual sense of the word, because pins are at least as wide as the period of discretization loop (and are often wider). Squeeker method is also a funny mixture of two other mixing approaches. I got behind your recent work on new engines (you make too many of them, mate!!! <img src="http://randomflux.info/1bit/img/smilies/smile.png" width="15" height="15" alt="smile" /> ), but I think that the overall question of which mixing method would be more suitable for in-game music is still very much open in my mind.</p><p>I.e., the principles I covered in my write-up have nothing to do with the method of mixing. OK, I based Rain on Octode XL because it has low discretization frequency, which made it easier to interleave audio and video codes at high frequency. You can probably make similar claim about the Squeeker engine. I do not think we have any other guidance in this case, do we?</p>]]></description>
			<author><![CDATA[null@example.com (introspec)]]></author>
			<pubDate>Mon, 20 Apr 2020 20:11:33 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2132#p2132</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2126#p2126</link>
			<description><![CDATA[<p>Good writeup, introspec. I&#039;ll add that in addition to the pin pulse method, the Squeeker method also allows for some deviations in timing, and both of these methods still work (albeit with noticable degration of sound quality and of course frequency range) at fairly low update rates, as demonstrated by <a href="https://github.com/utz82/ZX-Spectrum-1-Bit-Routines/blob/master/nanobeep/main.asm">nanobeep</a>.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Sun, 19 Apr 2020 14:32:48 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2126#p2126</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=2123#p2123</link>
			<description><![CDATA[<div class="quotebox"><cite>utz wrote:</cite><blockquote><p>I don&#039;t think there is any code for the method Shiru describes, because nobody has implemented it. The idea for continuous sound would be not to call the sound generator through an ISR (because 50 Hz is too slow to make anything but the lowest audible tones), but to interleave it with the multicolour code at regular intervals. The usual restrictions with contention apply there, so it would still be quite tricky.</p></blockquote></div><p>Actually, I have implemented exactly this idea in my 1K intro <a href="https://www.pouet.net/prod.php?which=62793">&quot;Splash&quot; (2014)</a>. The beeper engine there is very simplistic, single voice, but this is purely due to the size limitations I was dealing with.</p><p>In fact, I think that it won&#039;t be a large overstatement to say that most of my beeper experiments were about trying to push the envelope of how beeper sound can be combined with other things.</p><p>Shiru&#039;s methods 1 and 2 can be found in quite a few old games with beeper music. I never liked the resulting sound, so I did not do much research on it. Hence, I am not sure if e.g. Manic Miner uses method 1 or method 2 (method 1 seems more likely, given the lack of vsync in the game). My beeper scroller in <a href="https://www.pouet.net/prod.php?which=64046">&quot;Dat Fuzz&quot; (2014)</a> is using, I guess, a variation of the method 2, with one modification: the visuals occupy small fixed time remaining after playing something like 2.5 frames of sound. So, improving the quality of sound is easy - just ensure that the sound does not get interrupted much.</p><p>Like I said, method 3 in Shiru&#039;s list can be found in <a href="https://www.pouet.net/prod.php?which=62793">&quot;Splash&quot; (2014)</a>. At the same time, outside of beeper, I am pretty sure that at least some demos with digital sound use a similar approach (e.g. <a href="https://www.pouet.net/prod.php?which=56455">&quot;Scroller&quot; (2010)</a> or <a href="https://www.pouet.net/prod.php?which=75986">&quot;Atarin&quot; (2018)</a>). In fact, I&#039;d say that the devil is in the implementation detail: visuals usually require v-sync, while beeper (or digi) need +- constant rate of updating, which does not fit well with updating visuals synchronized to vsync or, more generally, doing any non-trivial logic. Specific solutions of this clash of needs can be different and varied; what I did in Splash does not make me happy and I am currently experimenting with another approaches.</p><p>A good way to think about all these methods is to think about code responsible for visuals as something that &quot;distorts&quot; sound. Then your strategy to improve the sound quality would always be about something that reduces the distortion. The larger proportion of time you can spend on making the sound, the better sound quality you&#039;d get. This applies to all three of Shiru&#039;s methods.</p><p>However, there are other methods for reducing the distortion. Instead of trying to reduce the &quot;amplitude&quot; of the distortion (&quot;amplitude&quot; in the PWM sense would be the duration of anything that is not generating sounds), you can change the dominant frequency with which distortion occurs. E.g. the scroller in &quot;Dat Fuzz&quot; operates on the basis of one scroll every 3 frames only partly because this was the only way to significantly change the proportion of time between the work of the beeper engine and the work of the visual code. It is also important that the base frequency of the resulting distortion becomes 18.5Hz (which cannot be heard) instead of the pretty obvious 50Hz produced by engines operating on the basis of single frames logic. If taken to the extreme, some games do all drawing between the rows in the beeper engine, which tends to mask quite well even pretty significant interruptions in sound. Of course, from the point of view of visuals extremely slow updates do not work very well.</p><p>My demo <a href="https://www.pouet.net/prod.php?which=67276">&quot;Rain&quot; (2016)</a> was an attempt to see what happens at the other end of the spectrum. What would happen with the sound if the distortion was to operate at very high frequency? In &quot;Rain&quot;, the visual code occupies every 4th iteration of the sound loop running at something like 12kHz. It does distort the sound, but the nature of the distortion is such as to create &quot;spacey&quot; sound, which seems a lot more acceptable that what methods 1 or 2 can provide you with. Of course, the type of code you need to write for this mindset is not very vsync-friendly and, in fact, is not very visual-effects friendly. However, you do get surprising amount of time for doing useful work beyond making the sound, so definitely consider this approach too.</p>]]></description>
			<author><![CDATA[null@example.com (introspec)]]></author>
			<pubDate>Thu, 16 Apr 2020 00:02:07 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=2123#p2123</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=1975#p1975</link>
			<description><![CDATA[<p>Thanks, I will add only some basic sounds...</p>]]></description>
			<author><![CDATA[null@example.com (cmgonzalez)]]></author>
			<pubDate>Fri, 29 Mar 2019 00:43:52 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=1975#p1975</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=1974#p1974</link>
			<description><![CDATA[<p>I don&#039;t think there is a way to fix it. Even changing the pitch will not make the samples play as intended.<br />Interrupts and beeper sound don&#039;t mix well. And iirc Nirvana&#039;s interrupts take up almost the entire frame.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Wed, 27 Mar 2019 17:42:53 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=1974#p1974</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=1973#p1973</link>
			<description><![CDATA[<p>Thanks Utz n Shiru! But I also have desisted to do some fancy solutions, for the moment.</p><p>Beepfx have give me good results, I&#039;ve to use it without disabling interrupts, by commenting di and ei instructions. </p><p>But the problem is the pitch, as the sound now have to deal with the interruptions and nirvana the playback is slower than is supposed to work on interrupt-less enviroment.... </p><p>Do you know some way to fix it, besides changing the pitch of the samples?</p>]]></description>
			<author><![CDATA[null@example.com (cmgonzalez)]]></author>
			<pubDate>Tue, 26 Mar 2019 00:09:33 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=1973#p1973</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=1972#p1972</link>
			<description><![CDATA[<div class="quotebox"><cite>cmgonzalez wrote:</cite><blockquote><p>Do you have any code example for that obscure solution that you mention?</p></blockquote></div><p>No, if I had something, I sure would publish it already. At the moment, the only game I can think of that kind of used this approach was <a href="http://www.worldofspectrum.org/infoseekid.cgi?id=0025426">Sea Dragon</a> port, where I did beeper effects. It used very crude sample-like effects, like every so often during rendering a frame the game just read a bit from an array and outputted it. As it was 50 hz targeted, rendering speed was relatively steady, thus &#039;sample rate&#039; was steady enough too. I don&#039;t have this code around, and can&#039;t really recall how many times per frame the routine was called. I think it was the least possible number, to avoid introducing slowdowns. Maybe 8-16 updates per frame.</p>]]></description>
			<author><![CDATA[null@example.com (Shiru)]]></author>
			<pubDate>Sat, 23 Mar 2019 23:44:04 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=1972#p1972</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=1971#p1971</link>
			<description><![CDATA[<p>Hi,</p><p>Since Shiru seems to be busy, I&#039;ll try to answer in his place.</p><p>I don&#039;t think there is any code for the method Shiru describes, because nobody has implemented it. The idea for continuous sound would be not to call the sound generator through an ISR (because 50 Hz is too slow to make anything but the lowest audible tones), but to interleave it with the multicolour code at regular intervals. The usual restrictions with contention apply there, so it would still be quite tricky. Generally, PFM/pin pulse and Zilogat0r&#039;s Squeeker method would work best because they both can work with a low sample rate.</p><p>For sfx and simple melodies consisting of short blips, doing this on interrupts works fine. Avoid the Basic Beep, as it has a lot of overhead. You can achieve the same result with just three commands:</p><div class="codebox"><pre><code>  add hl,de
  ld a,h
  out (#fe),a</code></pre></div><p>Init DE with the desired frequency divider (for tests, something like #0040 will be fine), and run in a loop for something like 1000 times.</p><p>In z88dk, there&#039;s also a modified version of the Tritone engine with can be used in combination with game logic. It basically runs all the time and then periodically runs your game code on note changes. If your game logic is simple and doesn&#039;t need a lot of CPU time, it might be a good option.</p>]]></description>
			<author><![CDATA[null@example.com (utz)]]></author>
			<pubDate>Sat, 23 Mar 2019 20:24:41 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=1971#p1971</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=1968#p1968</link>
			<description><![CDATA[<div class="quotebox"><cite>Shiru wrote:</cite><blockquote><p>Third, I think is the most obscure one, is applicable to games where frame time is evenly distributed around some nearly constant-time process (rendering usually), so they can call sound routine a number of times per frame with mostly constant pace. That likely would suit well for multicolor engines such as Nirvana. They can have a short sample buffer, prepared outside the raster, then read and output value from the buffer to #FE each N scanlines (very low sample rate, but may work for some cases).</p></blockquote></div><p>Hi Shiru, first to all, I want to thank you for your mFX player that I&#039;m already using for my games Gandalf and Manic Pietro. Currently I&#039;m working on a Pacman clone and I want to target the 48, with beeper sound fx. Do you have any code example for that obscure solution that you mention?</p><br /><p>I&#039;ve run some test, this are my findings (I&#039;m a newbie on the 48 beeper)</p><p>-Sounds can be placed as long they don&#039;t mess with interruptions, for example the Basic Beep routine can be used on short intervals and also out254 based sounds seems to be work ok, with no screen flickering or corruption. </p><p>-Also I&#039;ve try to use BeepFx but it disables interrupts. <img src="http://randomflux.info/1bit/img/smilies/sad.png" width="15" height="15" alt="sad" /></p><p>-Steve Turner player works but it may be interfering with some registers that SDCC needs, as the code jumps to an unexpected place.</p><p>-I&#039;ve placed a call to tiny out254 routine on the Nirvana ISR, to make some noise each time pacman eat a dot and works ok.</p><p>What do you think, Any idea or suggestions?</p><p>Regards</p>]]></description>
			<author><![CDATA[null@example.com (cmgonzalez)]]></author>
			<pubDate>Wed, 20 Mar 2019 14:16:02 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=1968#p1968</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=1667#p1667</link>
			<description><![CDATA[<p>It will work, but basically it just inverts the idea of playing sound in spare CPU time that is left of a frame - the second apporoach I described above. Just different technical implementation.</p><p>Engines like Special FX work better with this approach, because of very short pins they&#039;re generating.</p>]]></description>
			<author><![CDATA[null@example.com (Shiru)]]></author>
			<pubDate>Fri, 09 Mar 2018 11:26:10 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=1667#p1667</guid>
		</item>
		<item>
			<title><![CDATA[Re: In-game (during gameplay) music]]></title>
			<link>http://randomflux.info/1bit/viewtopic.php?pid=1666#p1666</link>
			<description><![CDATA[<p>It may sound crazy, but if the game is simple, you can use a beeper engine that uses IM2 interrupt mode (like Special FX or Plip Plop) and run the game on interrupt.<br />Be warned that both the sound quality and game speed will be lower. This is why this must be a simple game.</p>]]></description>
			<author><![CDATA[null@example.com (abrimaal)]]></author>
			<pubDate>Thu, 08 Mar 2018 13:00:30 +0000</pubDate>
			<guid>http://randomflux.info/1bit/viewtopic.php?pid=1666#p1666</guid>
		</item>
	</channel>
</rss>
