Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /storage/content/49/145849/famitracker.com/public_html/forum/classes/dbHandler.php on line 29 FamiTracker
Login:
Menu:
Post: Author:
FamiTracker > General > Source and development > Raw PCM technical docs? Owner: TechEmporium New post
Page 1 of 1 Sort:  
Raw PCM technical docs? Posted: 2011-06-10 06:44  (Last Edited: 2011-06-10 06:49) Reply | Quote
TechEmporium

Avatar

Member for: 4485 days
Status: Offline

#18321
I was wondering about something involving raw PCM...

I decided to go on the hunt for some docs & could only find a small amount of information from [url=http://tuxnes.sourceforge.net/nestech100.txt]JDC's TuxNES docs. It only appears in minor detail in section 5E, as follows:

[quote=JDC's doc]E. DMC (PCM) Channel
--------------------
The DMC channel, commonly referred to as the 'PCM' channel, uses two
methods of digital audio playback: DMA and RAW.

The DMA method is most commonly used. The steps for playback are as
follows:

1) Set $4012 (DMC Address Register) to the 64-byte aligned offset
within PRG-ROM $C000-FFFF. For instance, if $8E is written here,
the sample data will be loaded from ($8E*64)+C000, or $E380.
2) Set $4013 (DMC Length Register) to the length of the sample data.
The sample length is defined as (16*x)+1, where x is the value
written.
3) Set $4010 (DMC Frequency Register) to whatever 4-bit frequency
you desire.
4) Set Bit #4 of $4015 (Channel Control) to 1, enabling the DMC
channel.

The sample data used for the DMA method is 1-bit unsigned data. The
actual format of the data is currently unknown, as is the latency of
playback.

The RAW method is used in carts such as Tengen's "Gauntlet 2," for
8-bit "high-quality" speech. The steps for playback are as follows:

1) Write the 8-bit value to $4011 (DMC Volume Register).[/quote]

And that's as far as the actual document goes before jumping to the next section.

Now, I'm assuming that step 1 of the raw PCM method is just a simple change to step 1 of the entire DMA process, all of which runs in the same DPCM channel. But I'm sure that this is an incorrect assumption.

Can anyone (either here or in any NES development community) verify this info's validity? Better yet, are there any other technical docs that cover how raw PCM's supposed to work, with respect to the 2A03? Because I'm really curious about why some emulator & NSF development projects find it difficult to implement both methods (for example, FamiTracker supports the DMA method, but not the raw method, while PornoTracker supports the exact opposite).

_______________________
Technology: the one thing that's hated & cursed at by all engineers, technologists, scientists & technicians!

(Lousy modern technology! )
Posted: 2011-06-10 07:25 Reply | Quote
Shiru



Member for: 4890 days
Location: Russia, Moscow
Status: Offline

#18322
Raw PCM is all about just sending bytes in the DAC register at certain rate. It could be done with a timed code (difficult to do anything else in the same time), or with an interrupt. You really don't need any HW-related docs for such a simple thing, but you need major amount of code to do it.

DMC DMA is completely different, it is rather complex from HW side, but very simple to program - you just write address and length of a sample into registers, and hardware does all the work.

Major difference is that DMA only works with 1-bit DPCM data, and direct access to the DMC DAC ('raw') is only works with 7-bit samples (just like 8-bit WAV files but without one bit).

NSF is originally designed to run sound update at TV frame rate, that's why there is the problem with code that needs to update sound at higher rate.

Posted: 2011-06-10 07:32 Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#18323
I believe the "manual" playback version means you are using the CPU to drive the sample playback directly rather than using the DMA. You wouldn't be able to do anything else at the same time, so you'd have to suspend your game while you're playing the sound.

Posted: 2011-06-10 07:48  (Last Edited: 2011-06-10 07:58) Reply | Quote
rainwarrior

Avatar

Member for: 4150 days
Location: Canada
Status: Offline

#18325
Also, technically Famitracker does support the "manual" mode via the Z effect.

As I recall, nicetas_c did some waveform tests with it by using high refresh rates.

So... it is supported already! Kind of. Not really. (I don't think NSFs are capable of it anyway.)

Edit: Apparently NSFs technically will support it. There's some impressive examples over at [url=http://kkfos.aspekt.fi/projects/nes/tools/pornotracker/]http://kkfos.aspekt.fi/projects/nes/tools/pornotracker/ in the comments.

Posted: 2011-06-10 20:23 Reply | Quote
Raijin

Avatar

Member for: 4123 days
Status: Offline

#18332
I've seen famicompo submissions with that Raw PCM channel in the song. For instance, I separated channels of a song (forgot which one) and for some reason the PCM channel was in there not being used. So obviously MML supports it.

_______________________
[url=http://www.youtube.com/user/ChiptunedRaijin]Youtube Channel
Posted: 2011-06-11 01:59  (Last Edited: 2011-06-11 05:32) Reply | Quote
TechEmporium

Avatar

Member for: 4485 days
Status: Offline

#18354
Yes; I believe I've already mentioned PornoTracker (which only supports raw PCM & not DMA PCM).

But thanks to Shiru, I now understand what's stopping raw PCM from being able to work with DMA PCM in most NES-based projects.

So the key is in the rate at which the DAC is being accessed, provided that there's some kind of an interrupt to base all the timing from... Which could also explain why Action 52's PCM samples play under certain conditions; Action 52's samples play after a hardware reset interrupt (i.e.: when the game is powered on or the reset button is pressed). Even in Gauntlet 2; there's an interrupt once the menu screen transitions to the first level's action screen (& that's when a voice sample starts to play).

I can just imagine the amount of code it would take just send one byte of data to the DAC, along with the amount of subroutine jumps it would need to play a sample for 1/60 seconds.

But how possible would it be to actually use the two methods of PCM sampling on the same cartridge? Considering that the DMA method isn't dependent on any interrupts or special timing codes, wouldn't it technically be possible to store both raw & DMA data on the same cart & play them at different points during the ROM's execution?

_______________________
Technology: the one thing that's hated & cursed at by all engineers, technologists, scientists & technicians!

(Lousy modern technology! )
Posted: 2011-06-11 06:55 Reply | Quote
Rushjet1
Moderator

Avatar

Member for: 5012 days
Location: Atlanta, GA
Status: Offline

#18368
"DMA PCM?"

also the famicompo submissions that use raw PCM are a new driver called SuperNSF. it's a MOD player that plays up to 4 channels (i think?) through the dpcm channel / pcm.

if you're talking about the other famicompo entry that had PCM in it but sounded glitched a lot, i don't know what engine that used.

Posted: 2011-06-11 21:32 Reply | Quote
Shiru



Member for: 4890 days
Location: Russia, Moscow
Status: Offline

#18381
Yes, it is possible to have both DPCM and raw PCM sounds in a single game, no problems there. You just have to use only one method of playing at a time, because they use the same DAC, and you'll get a mess if try to do both at once.

Posted: 2011-06-11 23:31 Reply | Quote
TechEmporium

Avatar

Member for: 4485 days
Status: Offline

#18387
That's what I thought, seeing that neither method actually writes data into the same offsets in spite of using the same DAC. The code would really be horrendous. by the looks of it.

[quote=Rushjet1]"DMA PCM?"[/quote]

My bad; what I meant to say was concerning the DMA method of DPCM, as opposed to the raw method. That SuperNSF driver system looks like it compiles IT chiptunes into NSF format; I'll check it out later (I already got my own copy).

Thanks, guys.

_______________________
Technology: the one thing that's hated & cursed at by all engineers, technologists, scientists & technicians!

(Lousy modern technology! )
Posted: 2011-07-04 12:22 Reply | Quote
Antimony



Member for: 4004 days
Status: Offline

#19415
[quote=TechEmporium]
I can just imagine the amount of code it would take just send one byte of data to the DAC, along with the amount of subroutine jumps it would need to play a sample for 1/60 seconds.
[/quote]
About thirty rows of code in the main loop, with some register setting before it. Looking at my code, it seems that it writes a byte (which only has data in seven bits, but it's easier and faster than to store, read and write the invidual bits...) to the DAC every nineteenth loop to have sample rate of 6000Hz. And only other thing in there is some moving text. And I even used some zero page addressing stuff that saves few clock cycles. I think it's not really possible to have a proper game playing constantly while playing PCM-samples.
Some interrupt system would probably take even more CPU-time, so I didn't even try it.


[url=http://www.student.oulu.fi/~lauripek/gaybar.nes]PCM-testing.nes

Page 1 of 1 Sort: