It is currently Sat Oct 21, 2017 8:05 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sun Jun 18, 2017 5:15 pm 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 199
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.

Anyway, you can find the code here: https://github.com/pubby/penguin Keep in mind this is not a library; I wrote the code for myself.

I'll attach a ROM that plays Ralph 4's music.


Attachments:
penguin_demo.nes [24.02 KiB]
Downloaded 49 times


Last edited by pubby on Sun Sep 24, 2017 10:07 am, edited 1 time in total.
Top
 Profile  
 
PostPosted: Sun Jun 18, 2017 7:40 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10066
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Sun Jun 18, 2017 11:49 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7233
Location: Chexbres, VD, Switzerland
Quote:
nor are sound effects or PAL pitches.

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.


Top
 Profile  
 
PostPosted: Mon Jun 19, 2017 8:20 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3470
Location: Indianapolis
Very cool, and very impressive too! Less than 7 scanlines of time, that fits well within a row of background tiles.


Top
 Profile  
 
PostPosted: Sun Jun 25, 2017 1:02 pm 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 199
Thanks.

The newest update adds sound effects and PAL pitches.

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.


Top
 Profile  
 
PostPosted: Sun Jun 25, 2017 11:31 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7233
Location: Chexbres, VD, Switzerland
pubby wrote:
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.


Top
 Profile  
 
PostPosted: Mon Jun 26, 2017 12:20 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5730
Location: Canada
This is an interesting idea. Though it's not something I think I would ever want to do, it's always interesting to see a different approach to the problem. Thanks for sharing the source code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group