Dn-Programming-Core-Management / Dn-FamiTracker

modifications and improvements for 0CC-FamiTracker (based on j0CC-FamiTracker 0.6.3)
Other
372 stars 23 forks source link

[Feature Request] Where's the Raw PCM?! #158

Closed SumisuBushido closed 1 year ago

SumisuBushido commented 1 year ago

I'm sure a lot of people have been begging for this to be a feature in FamiTracker (plus it's many addon variants like this one) for a LONG time already, but like seriously; where's the raw PCM? Raw PCM clearly exists in plenty of NES games, such as Skate or Die 2, Battletoads, Monopoly, etc.

Yet with this new variant that's taken over 0CC-Famitracker, we still have no raw PCM. I know you're probably gonna lie to me and say that it's impossible, but it clearly isn't. If Deflemask and Musetracker could incorporate Raw PCM into their NES trackers with no problem (Musetracker could do both DPCM and Raw PCM; the only downfall was that your songs were stuck on loop), so can you.

Also, for raw PCM, you can clearly choose from the 7-bit PCM that used the CPU, or the 8-bit PCM from the Nintendo MMC5 chip. A lot of people, especially me, have been dying for this feature for a really long time; and if you ever include the feature of importing NSFs, I would like to be able to import the Skate or Die 2 title theme with the raw PCM intact (unlike in normal FamiTracker, where it doesn't really exist).

If you're still working on the project, I hope that you're able to consider this as a new feature that would make a lot of chiptune artists happy. Plus, with my soundtrack, I even wanna have one song that uses raw PCM in it (just like Skate or Die 2 did).

Gumball2415 commented 1 year ago

If you are aware of the amount of people asking for PCM, then you must also be aware of the amount of reasons why PCM is not implemented. And there are similar sentiments regarding MMC5 PCM.

There are requirements that must be met before PCM playback is possible:

  1. The tracker must be reworked to allow PCM playback, preferably as close as the NSF implementation as possible. Historically, the tracker program's paradigm and principles revolve around the NSF driver, and I intend to keep it that way as much as possible.
  2. The NSF driver must be reworked to be as quick as possible in order to have enough CPU overhead to manually play samples. This means no expansion audio, no modules faster than NMI (or 60.01), and practically have all the playback routines be rewritten to be non-returning. As the current driver stands (Dn-0CC v.2.13), it's bulky and inefficient (some 400Hz NSFs struggle with perfect playback). Even the original vanilla driver does not have enough overhang to allow PCM playback.

I hope this enlightens you why PCM is historically not supported in Famitracker, and also not in my interests at the moment. I'm sure you're already aware of alternatives, such as Deflemask, or SuperNSF, but if you're adamant about PCM in Dn-FT, pull requests are welcome. :)

pinobatch commented 1 year ago

A little more background about NSF drivers:

Most games' sound drivers are structured as an "init function" that starts a song and a "play function" that the game calls every frame to read the patterns, tick the instruments, and update the APU registers. A typical play function uses 1 to 10 percent of the CPU time before returning to the game. NSF is designed for this use case, providing addresses of an init function and play function in an emulated NES's memory.

If a game plays PCM, this usually causes the action to stop momentarily while the game's play function continuously writes new PCM values to the APU. If there is any animation, it's limited to something very simple between one sample and the next, such as a palette change (Skate or Die 2) or a Muppet's mouth opening and closing (Big Bird's Hide & Speak).

In theory, NSF supports a play function that runs longer than the 29780 CPU cycles of one frame. This models the use of samples in many of these games. However, many NSF players do not correctly handle a long play function. For example, on the PowerPak's NSF player, a long play function causes the player to disregard input from the controller. This prevents the user from pressing Left or Right changing to another song in the module or pressing Select to close the module and return to the menu.

In order to add raw PCM to a tracker, I'm interested in how you plan to incorporate it into an NES game that is not turn-based. That might give us some clues as to how to build the NSF driver.

SumisuBushido commented 1 year ago

Well, for my game (which doesn't have a defined genre tbh), raw PCM will be used for like the names of a move that the player would perform (sorta like in the Street Fighter series), and as I mentioned before, only ONE song in the entire soundtrack, just to push the limits of the Famicom. All of the other SFXs and songs used DPCM to save a lil bit of memory.

If you have any questions regarding this, feel free to contact me on Discord at SumisuBushido#9853 Other than that, have a nice day!

(Also, I think the envelope shape feature thingy for the Sunsoft 5B broke with Dn-Famitracker (a.k.a what makes sawtooth like sounds and stuff I guess))