Need advice on NTSC/PAL support

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

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

Need advice on NTSC/PAL support

Post by bleubleu » Tue Jan 28, 2020 3:17 am

Hi!

I need advice from some of the NSF/audio engine gurus.

One feature i've been delaying for too long in FamiStudio is proper PAL support. But by "PAL support" I mean more than just running at 50Hz with different note lookup tables. I mean having proper tempo/speed management while maintaining the ability to still have control over things that need to run at a frame-level, like note cuts (stop notes).

Let me try to explain as best I can...

The way FamiTracker (and other sound engines, I assume) are able to support both PAL and NTSC for the same song, is by having the song described at a coarser level than frames. This essentially abstracts the notion of a frame from the composer, leaving the engine free to scroll through the song at different rates. In FamiTracker, the "speed" is essentially how many frames a note will last on NTSC (assuming the default tempo 150 for this discussion). The default speed of 6 means that on NTSC a note is 6 frames, while on PAL it is 5.
For the rest of this post, a note will refer to this 6 or 5 frames (a row in FamiTracker) and a frame will refer to 1/60th or 1/50th of a second.
Writing a song at a speed of 1 (1 note = 1 frame) give you amazing control over everything, but makes it impossible to run on both PAL and NTSC while sounding the same.

One thing that is used in lots of songs are 1-frame note cuts before another note. To do this in FamiTracker, you add a cut delayed by 5 frames (S05 effect):
FamiTracker1.JPG
FamiTracker1.JPG (30.8 KiB) Viewed 2993 times
Visually, in FamiStudio at a speed of 1, this would look like this (triangles are stop notes). Imagine the dark lines would be notes, and the lighter lines would be frames.
FamiStudio1.JPG
FamiStudio1.JPG (20.76 KiB) Viewed 2993 times
But how do you automatically convert this to PAL now? Even FamiTracker seems to fall short here. Running this song in PAL mode simply ignores the cuts since every note is only 5 frames now. The last cut will still work since there is no note after.

Seems to me that what someone would want on PAL is something like this (where the cut happens on the 5th frame):
FamiStudio2.jpg
FamiStudio2.jpg (21.86 KiB) Viewed 2993 times
FamiTracker has the same issue with the note delay (Gxx) effect.

So, my question(s) are:
  • Is there a general (and user-friendly) way that you can thing of supporting both NTSC and PAL, while maintaining some sort of fine-grained control over note cuts and the occasional note delay?
  • Were games actually using the same exact music data for both regions, or do you think some of the composer would just manually convert the songs?
Thanks.

-Mat

User avatar
rainwarrior
Posts: 7812
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Need advice on NTSC/PAL support

Post by rainwarrior » Wed Jan 29, 2020 7:05 pm

bleubleu wrote:
Tue Jan 28, 2020 3:17 am
So, my question(s) are:
  • Is there a general (and user-friendly) way that you can thing of supporting both NTSC and PAL, while maintaining some sort of fine-grained control over note cuts and the occasional note delay?
  • Were games actually using the same exact music data for both regions, or do you think some of the composer would just manually convert the songs?
The easiest general solution IMO is to call the PLAY routine twice on every 5th frame on PAL. Mr. Gimmick actually did this for its PAL region port. If you don't have pitch-tuned DPCM samples, then this is enough to entirely reuse the same data for both. You don't really even need to have separate pitch tables for your notes, the pitch would be different of course but still relatively in tune with itself. (Conversely you could compose for PAL and simply skip the PLAY every 6th frame.)

Every possible solution here is a compromise, ultimately you just can't make the same thing on both systems and something has to change somewhere, but this option is relatively simple and fairly robust. There's a potential for sounds that only last 1 frame to get skipped over occasionally, but in practice it hasn't seemed like a major issue in any place I've employed it.

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

Re: Need advice on NTSC/PAL support

Post by bleubleu » Wed Jan 29, 2020 9:29 pm

Thanks man.

This is exactly the kind of insight i need. I haven't reversed engineered enough songs to know all these tricks.

-Mat

lidnariq
Posts: 9383
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Need advice on NTSC/PAL support

Post by lidnariq » Wed Jan 29, 2020 10:48 pm

bleubleu wrote:
Tue Jan 28, 2020 3:17 am
Is there a general (and user-friendly) way that you can thing of supporting both NTSC and PAL, while maintaining some sort of fine-grained control over note cuts and the occasional note delay?
One thought specifically regarding note cuts - store the note duration relative to the speed, rather than an absolute number of ticks. So regardless of whether the speed is 6@150 or 3@125, you'll always get the shortest noticeable cut.

In contrast, for portamento, it may not be practical to re-interpolate the pitch bends given the limited precision on the NES. Only either accepting slowing down/speeding up the soundtrack, or a technique like what Rainwarrior suggests (where the 6th tick is either skipped or doubled as appropriate) will give sufficiently similar results.

Each effect probably needs to be handled differently. For example, in Scream Tracker 3, the Arpeggio effect restarts on each row, and it'll sound significantly different if it's played at 6@150 vs 4@100, despite both having the same row rate. (The former would sound 012012012012; the latter would instead sound 01200120). The obvious work-around is to not restart the Arpeggio on each row... at least if the original speed was a multiple of 3.

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

Re: Need advice on NTSC/PAL support

Post by bleubleu » Thu Jan 30, 2020 2:43 am

Thanks.

Good idea for the note cuts. Also now you are making me realize that I need to think about every effect one by one. I can definately think of examples that wont work, like slide notes (portamento). Ugh.

Also, I'm in a tough situation since I am not pushing FamiStudio as a sound engine (there is a small one for NSF export but no-one should use it). I'm mostly trying to stick to the established standard (FamiTracker) while keeping things very user-friendly (DAW-paradigm as opposed to Tracker). But here I'm in a situation where even FamiTracker doesn't have an good answer for me.

-Mat

Bananmos
Posts: 511
Joined: Wed Mar 09, 2005 9:08 am
Contact:

Re: Need advice on NTSC/PAL support

Post by Bananmos » Sat Feb 01, 2020 2:56 pm

Yeah, it's a property of music done in tracker format. I think MIDI-like music will fare better, as at least in theory you would just adjust the note lengths.

Back in the Nerdtracker2 days, I used to enforce a 50Hz "master" record in the replay engine, just naively pausing every 6th beat.

NTSC version never sounded too off to me to notice, so for many tunes I think that hack is kind of acceptable.

But then again I'm not really a musician. It took a while before I even heard any complaints... I seem to recall Chibi-Tech did, and the awesome tune Chibi-Tech made for the "Years Behind" music demo was originally intended for 60Hz IIRC, but ended up being just played at 50Hz (without any paused frames). Sounded better slower to me as I'm in the part of the world where we all tended to be raised on slower NES music anyway... ;)

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

Re: Need advice on NTSC/PAL support

Post by bleubleu » Tue Feb 04, 2020 4:55 am

Yeah, it's a property of music done in tracker format. I think MIDI-like music will fare better, as at least in theory you would just adjust the note lengths.
Yeah, Im heading towards offering a "tempo mode" that will have "Tracker-like" or "DAW-like".
  • Tracker-like: Would mainly be for compatibility with FamiTracker. Your typical tempo/speed, notes that can last different number of frames on NTSC/PAL, delayed notes, delayed cuts. Will make the app feel like a tracker and will definately not be fun to edit, but it will "work". This will be the default if you import from FamiTracker.
  • DAW-like: Like you and brad mentioned. 1 frame = 1 note. You edit in NTSC (or in your case it was PAL) and PAL will sometimes run 2 notes in 1 frames (or in your case, do nothing for 1 frame). This will be the default for new projects. MUCH more MIDI/DAW friendly. Simpler to wrap your head around for novices, imho.
I really like your idea of editing in PAL space... Would definitely avoid "spikes" of running 2 notes in 1 frame. I need to think about this some more.

-Mat

Post Reply