Over the weekend I wrote a music engine that runs in a constant number of cycles per frame. The intention was to have an engine that could be hidden in timing-critical code such as parallax effects, and also to avoid the dreaded lag spikes. Currently, the cycle count is 766, which makes it far faster than other open-source engines. For comparison, Famitone peaks at 3000+ cycles and GGSound peaks at 5000+. I think Pently peaks at 2500+, but I'm not sure.

The converter converts from Famitracker and supports instruments with Pitch/Volume/Arpeggio/Duty. Nothing else is supported; no effects nor volume columns. DMC is not supported, nor are sound effects or PAL pitches.

It uses 12 bytes of zeropage and $100-$156 in stack space. The converted songs are not as space efficient as other engines, but they're small enough for my purposes.

Cool, the idea of running the sound code at times you'd otherwise not do anything (e.g. while waiting for raster effects) is very interesting. And 766 cycles is pretty fast, about 7 scanlines only. Will take a better look at this when I get to my PC.

PAL pitches are usually as simple as adapting the pitch table to PAL values.

As for sound effects, the lack of them would really make your engine unsuitable for a game, although the concept of a constance-cycle music engine still apply.

Personally I was wondering how feasible was a fully constant-cycle game engine feasible. This could ease raster split a lot, perhaps impressive parallax scrolling could be done in-game without even needed neither sprite-zero hits nor IRQs.

Sound effects were implemented as one-off instruments that play single notes. This makes them zero-cost; memory and cycles were not increased. PAL pitches on the other hand added 24 cycles and 2 bytes zeropage. The current cycle count is now 790 per frame.

PAL pitches on the other hand added 24 cycles and 2 bytes zeropage. The current cycle count is now 790 per frame.

They should come at zero costs, really. All you need is to change the pitch table's values. Sound engines needs not supporting PAL or NTSC pitches at runtimes - they should just be configured at compile time to run either version.

Yes, technically you *could* have a runtime check and this comes with some advantages (only one version of the ROM), however that's not how it's typically done - most of the time you'd want to have one NTSC version and one PAL version of the ROM, and all the difference is made compile-time only.

I finally got around to using this, and found a few bugs along the way. The repo has been updated.

I forgot to mention, but it does support the full range of pitches and duty cycles, which Famitone does not. The ROM usage is pretty bad though; about 2x that of Famitone. Maybe one day I'll optimize it better.

this piece of BGM was written with the intention to comply with your driver, just thought i'd let you know. . Sadly, the mini game got shelved indefinitely as elseyf needed to tend to other things. It is meant to use the cycle constancy to reliably time a few scroll splits without irq support.

Well, this is humbling! By the time ggsound burns 760 cycles, it has just had its coffee and is still waking up in the morning. Ah, time to actually make sounds now! I can really learn something from this code. Thanks for sharing.

this piece of BGM was written with the intention to comply with your driver, just thought i'd let you know.

Cool! That sounds really, really good.

GradualGames wrote:

:shock: Well, this is humbling! By the time ggsound burns 760 cycles, it has just had its coffee and is still waking up in the morning. Ah, time to actually make sounds now! I can really learn something from this code. Thanks for sharing.

The biggest optimization comes from dividing the work out across multiple frames. I divided it into 4, and well, that's why it's 4x faster than famitone.

The biggest optimization comes from dividing the work out across multiple frames. I divided it into 4, and well, that's why it's 4x faster than famitone.

I've considered doing some of that in my own engine, checking for loop commands during downtime on frames that are not the start of a row. But to compensate for the lack of Sxx and Gxx, someone might need to use speed 3 to get (say) thirty-second-note resolution at 150 BPM. How would an engine that splits work over four frames cope with speed 3?

Division of workload across frames - that ought to be a good technique for any future driver aspiring to drive INL:s expansion audio project. More channels = more burden (and potentially more data, depending on how the extra channels are facilitated).

Who is online

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum