Official FamiStudio Sound Engine

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
bleubleu
Posts: 99
Joined: Wed Apr 04, 2018 7:29 pm
Location: Montreal, Canada

Official FamiStudio Sound Engine

Post by bleubleu » Mon Sep 07, 2020 4:39 am

Hello!

I usually stick to the music forum for my announcements, but this is something NES devs in general might be interested in : an official FamiStudio sound engine.

If you have been living under a rock, FamiStudio is a DAW-style NES music editor, it has tons of features:
  • Modern DAW-style UI with sequencer and piano roll, no hexadecimal anywhere
  • Instrument & Envelope edition
  • Full Undo/Redo support
  • Copy & Paste support
  • Note drag & drop with audio preview
  • NSF import
  • Import from FamiTracker FTM & Text (official 0.4.6)
  • Export to various formats (WAV, ROM, FDS, NSF, FamiTone2, FamiStudio Text, FamiTracker Text)
  • Volume, fine pitch, vibrato effect tracks
  • Slide notes (portamento)
  • Arpeggios
  • NES sound engine (CA65, NESASM, ASM6)
  • MIDI input support
  • Audio expansions supported: VRC6, VRC7, FDS, MMC5, Namco 163 & Sunsoft S5B.
  • Windows, MacOS and Linux versions.
Image

Sound Engine

FamiStudio started with FamiTone2 as its sound engine for NSF/ROM export. At each versions more features were added to it to maintain feature parity with the app.

With the release of version 2.2.0, I finally took the time to cleanup the code (its still a bit messy), port it to all 3 assemblers, make a little demo ROM and write some documentation for it so that other devs can start using it. Just to be super clear, this is still very much a FamiTone2-derivative, I am not trying to steal Shiru's work in any way, just building on the solid foundations he laid down.

The best reason to use this engine is its seamless integration with one of more polished and actively developed NES music tool.

Features

The engine has a basic set of features, as well as a few extra toggeable features that you may wish to disable to same CPU/RAM.

The basic feature set that is always available in engine is:
  • Support for the first four 2A03 channels (2 squares, triangle and noise channel).
  • Support for the full 96 notes (C0 to B7).
  • Instruments with duty cycle, volume, pitch and arpeggio envelopes.
  • Absolute and relative pitch envelopes.
  • Looping sections in envelopes.
  • Release points for volume envelopes.
  • Ability to change the speed (FamiTracker tempo mode only).
  • Ability to loop over a portion of the song.
  • Up to 64 instruments per export, an export can consist of as little as 1 song, or as many as 17.
Features that can be toggled on/off depending on the needs of your projects:
  • Audio expansions chips (at most one can be enabled) : VRC6, VRC7, FDS, S5B and N163.
  • PAL/NTSC playback support.
  • DPCM sample support
  • Sound effect support (with configurable number of streams)
  • Blaarg Smooth Vibrato technique to eliminate "pops" on square channels (incompatible with SFX at the moment)
  • FamiTracker/FamiStudio tempo mode.
  • Volume track support.
  • Fine pitch track support.
  • Slide notes.
  • Vibrato effect.
  • Arpeggios (not to be confused with arpeggio instrument envelopes which are always enabled).
RAM/CODE usage

Enabling more features will make the sound engine code larger and use more RAM. The zeropage usage is 7 bytes and can be easily aliased with some of your ZP variables as they are only used as temporary variables inside the famistudio_xxx subroutines.

Here is a table to give a rough idea of the best/worst cast of RAM/CODE usage. These tables where generated with only NTSC support, DPCM support enabled and no SFX streams.
Note that each column includes all features of the columns on the left. So the rightmost column has every feature enabled. In reality, you can toggle features individually and these tables would have dozens of columns.
Code size

Image

RAM usage

Image

Demo

A small demo is included with the engine sound code. The demo is available for all 3 major assemblers and they will all generate binary identical ROMs.

Image

Documentation & Download

The engine can be downloaded from famistudio.org. Be sure to checkout the documentation for more in-depth information.

-Mat

User avatar
LightStruk
Posts: 45
Joined: Sat May 04, 2013 6:44 am

Re: Official FamiStudio Sound Engine

Post by LightStruk » Mon Sep 14, 2020 8:38 am

I'm going to download this right away!

User avatar
bleubleu
Posts: 99
Joined: Wed Apr 04, 2018 7:29 pm
Location: Montreal, Canada

Re: Official FamiStudio Sound Engine

Post by bleubleu » Mon Sep 14, 2020 8:02 pm

LightStruk wrote:
Mon Sep 14, 2020 8:38 am
I'm going to download this right away!
Thanks for the support. Send any feedback (either about the app or the sound engine itself) my way!

-Mat

User avatar
Banshaku
Posts: 2393
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Re: Official FamiStudio Sound Engine

Post by Banshaku » Mon Sep 14, 2020 8:10 pm

So the basic 20A3 need in memory is like 150 bytes? Other parts are added if the songs uses some specific features? how does it work? Does it include part for sfx too?

User avatar
bleubleu
Posts: 99
Joined: Wed Apr 04, 2018 7:29 pm
Location: Montreal, Canada

Re: Official FamiStudio Sound Engine

Post by bleubleu » Tue Sep 15, 2020 2:51 am

Banshaku wrote:
Mon Sep 14, 2020 8:10 pm
So the basic 20A3 need in memory is like 150 bytes? Other parts are added if the songs uses some specific features? how does it work? Does it include part for sfx too?
Hi.

I'm not sure where you got the 150 from? Looking at the tables, if you use the minimal feature set, I read 129 bytes (that includes DPCM which you can disable too). Oh maybe you mean with all the features turned on? That would be a VERY complex song! The only song I have right now that uses everything is that silver surfer song. Which is insane! :mrgreen: Actually, even that song does not even use the fine pitch track. Also, note that each feature can be toggled individually, so a full table would have 32 columns.

As mentioned in the post, the tables were generated without SFX support. Each SFX stream adds 15 bytes (this is the same as FamiTone2). Having 1 or 2 SFX streams would make sense for a game.

With the basic feature set you can probably make almost every song from Megaman, Castlevania, etc.

EDIT: Also, if you ever get confused, FamiStudio will tell you which features you need to turn on as you export.
Capture.JPG
Documentation with more detail: https://famistudio.org/doc/soundengine/

-Mat

Post Reply