085.txt updated with full VRC7 audio details

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Post by Bregalad »

Oh this clear things up so they'll be running at almost the same frequency.

I think a 5 cent detune between channels would not have any negative effects on music on the other side it could make it sound better.
It's a very common method on the NES to detune slightly Square 1 and Square 2 channels.
Useless, lumbering half-wits don't scare us.
Grapeshot
Posts: 85
Joined: Thu Apr 14, 2011 9:27 pm
Contact:

Post by Grapeshot »

I have a few VRC7 test roms if anyone wants to record them on real hardware. (They're Famitracker files exported to NSF and then compiled with the Vegaplay NSF engine with the actual menu disabled.)

https://dl.dropbox.com/u/26864173/vrc7.rar

None of these work in Nintendulator, probably banking issues.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Post by rainwarrior »

Grapeshot, FYI, Famitracker had a bug (until yesterday) in the VRC7 driver code that prevents it from playing properly on hardware. The code that updates the instrument registers was failing to delay between writes.
jrlepage
Posts: 24
Joined: Wed Apr 04, 2012 2:15 am

Post by jrlepage »

Grapeshot wrote:I have a few VRC7 test roms if anyone wants to record them on real hardware. (They're Famitracker files exported to NSF and then compiled with the Vegaplay NSF engine with the actual menu disabled.)

https://dl.dropbox.com/u/26864173/vrc7.rar

None of these work in Nintendulator, probably banking issues.
I'd love to test those for you, but I have 2 problems:

a) I can only play NSFs on hardware (with the TNS-HFC3),
b) Those files won't play properly unless you re-export to NSF using the current 0.3.8 beta (as rainwarrior said),
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Post by rainwarrior »

Alright, I've had some time to get my CopyNES working, and I can now use the VRC7 tuner program with my Lagrange Point cart.

I'm currently going over the patch set; probably in a week or two I'll have a slightly more refined version of the set by quietust that most emulators currently use.

Update: did patch 1 so far, keeping a WIP version here: http://code.google.com/p/usbcopynesblue ... rrior.vrc7

(Also there were bugs in the USB CopyNES VRC7 tuner; I almost lost my work on the patch when the save function didn't work! I wonder if anyone has actually used this program in the past few years...)

vrc7_testing_0.jpg (dropbox link removed, image lost)
vrc7_testing_1.jpg (dropbox link removed, image lost)
Last edited by rainwarrior on Mon Aug 07, 2017 3:08 pm, edited 1 time in total.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Post by rainwarrior »

I've finished tweaking my patch set. My results are here:

http://nesdev.com/bbs/viewtopic.php?p=97361
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Post by rainwarrior »

I'm curious about the relationship between 1<<23 and 48db. By my reasoning, 48db = 10 ^ (48 / 10) = ~63096 which would suggest 16 bits of precision to me, not 23. Could you explain your reasoning?

The channels are output in series, according to the Yamaha datasheet, though the diagram shows them unevenly clustered in groups of 3; it's kind of unclear about the actual timing output. As you said this is not significant if trying to emulate the audio, since the consequences are above the audible frequency range.

A note about note-off for "percussive" envelopes; if the sustain flag is off for the envelope, note-off appears to generate a release equivalent to a release setting of 7. You mentioned this in your notes (based on emu2413.c?), and I had noticed/verified this independently when testing the hardware patches, but I can't seem to find this described in the YM2413 datasheet. The only thing I found was a little line on the percussive envelope diagram showing a faster release.

One more note that I'm sure must be borne out by the formulae in your description, but I think is worth saying explicitly, is the relationship between the sustain level (4-bit value) and output level (6-bit value) of the modulator. These have an exact 4:1 ratio, i.e. ignoring the attack, +1 to the sustain level is equivalent to +4 to the modulator output level. This was an extremely important property to know when trying to tweak the patches, because if I need to increase the effect of the attack, I can put -1 on the sustain value and +4 on the modulator output, resulting in the exact same effective sustain level, but now the attack level goes higher because I increased the modulator output.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Assuming constant impedance, doubling the voltage implies doubling the current, which quadruples the output power, and quadruple the power means about 6 dB more. Thus 48 dB is 48 / 6 = 8 doublings.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Post by rainwarrior »

Hmm, actually that makes sense, since I'm used to 16-bit audio programs telling me it has a 96db noise floor. Thanks for straightening that out.

So, does this mean the envelope only has 8 bits of precision? Even if they happen to distributed logarithmically during amplification, that seems low... but maybe not.

I've got a fair bit of hardware testing ahead of me to figure these things out.
Grapeshot
Posts: 85
Joined: Thu Apr 14, 2011 9:27 pm
Contact:

Post by Grapeshot »

He's just using 23 bits for the envelope attenuation value because on the lowest envelope speed the envelope will change by one LSB every time it's clocked (so a separate divider isn't needed for low rates).

According to the SpritesMind forums, who have decapped and studied a YM2612, the envelope generator output is actually 9 bits which is then shifted to produce a 12 bit (plus sign bit) attenuation value. The actual attenuation value table in the chip, which has been extracted as well, works with 1<<12 = 48db of attenuation. So to be accurate, only the high 9 bits of the envelope generator output should be considered.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: 085.txt updated with full VRC7 audio details

Post by rainwarrior »

Grapeshot, that's very interesting. Do you have a link you could share where this information is gathered?
Grapeshot
Posts: 85
Joined: Thu Apr 14, 2011 9:27 pm
Contact:

Re: 085.txt updated with full VRC7 audio details

Post by Grapeshot »

I posted it on the previous page, actually, but I don't blame you for not wanting to read a 40 page thread for relevant info.

Here's the important diagram for the envelope bit widths.
http://nemesis.hacking-cult.org/MegaDri ... erator.png

The only thing about this image is that is probably not correct for the YM2413 or the VRC7 is the DAC at the end. Elsewhere in the thread it's determined that the DAC used on the YM2413 is an 8 bit linear resistor ladder which connects the output pin to VCC or GND depending on the sign bit. (Some variants of the Genesis sound chip use this DAC and some use a completely different design, which is one of the reasons Genesis sound quality varied so much between models.)

e: Another thing that is missing in Disch's documentation is the fact that the attack portion of the envelope increases exponentially, not linearly. This is mentioned in the OPLL programmer's manual, but the actual method of calculating it is mentioned in a patent and discussed at http://gendev.spritesmind.net/forum/vie ... ope+attack as well as in that other thread.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: 085.txt updated with full VRC7 audio details

Post by rainwarrior »

Ah, I missed them on the first page. Thanks for the links; this will be good reading...
GreyRogue
Posts: 51
Joined: Fri Dec 08, 2017 5:12 pm

Re: 085.txt updated with full VRC7 audio details

Post by GreyRogue »

Disch wrote: **** SIDE NOTE ****
Writing to Regs R:00 through R:07 do NOT seem to have an immediate effect on channels using
instrument 0. Lagrange Point (Track 2 of the NSF) will write to these regs while a channel
using instrument 0 is still keyed on and audible, resulting in an ugly and very noticable
"blurp" noise at the end of a note. This is not heard on the real hardware, so instrument
data must be cached somehow. Perhaps it only takes effect when the channel is keyed on,
or when R:3x is written to? Don't know exactly.
Does anyone have any more information on this?
Do the six channels each have a copy of their active instrument patch? If so, when does it get updated?

Possible tests:
- Set up custom patch (preferably with long sustain)
- Set a channel to use the custom patch
- Change custom patch
- Does sound change here?
- Write note on R:2x.
- Does sound change here?
- Write note off R:2x.
- Write note on R:2x.
- Does sound change here?
- Write R:3x to resend instrument.
- Does sound change here?
- Write note off then on R:2x.
- Does sound change here?

Anything else I missed?
Post Reply