New VRC7 patch set

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

Moderator: Moderators

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

New VRC7 patch set

Post by rainwarrior »

Edit: this patch set and test has been updated, see the post below.
Edit: the actual patch set was finally dumped, see the other post below.


I've spent some time over the last several days going over the VRC7 patch set with the CopyNES VRC7 tuner. This is about as close as I can get; some patches appear to be exact, but many have very minute differences which I could not reconcile. Also, there are many factors which make an exact match very hard; vibrato/tremolo don't synch with the note, so patches which use them are a bit variable, and there are some other random factors which seem to affect the onset of the note that I don't understand, but again they make some patches sound slightly different each time (just in the onset of the tone though).

This is an incremental improvement on the patch set quietust posted a few years ago. This would have taken a lot more time if it weren't for the prior work of kevtris and quietust, especially on the VRC7 tuner tool.

Code: Select all

rainwarrior's VRC7 patches:

00 00 00 00 00 00 00 00
03 21 05 06 B8 82 42 27
13 41 13 0D D8 D6 23 12
31 11 08 08 FA 9A 22 02
31 61 18 07 78 64 30 27
22 21 1E 06 F0 76 08 28
02 01 06 00 F0 F2 03 F5
21 61 1D 07 82 81 16 07
23 21 1A 17 CF 72 25 17
15 11 25 00 4F 71 00 11
85 01 12 0F 99 A2 40 02
07 C1 69 07 F3 F5 A7 12
71 23 0D 06 66 75 23 16
01 02 D3 05 A3 92 F7 52
61 63 0C 00 94 AF 34 06
21 62 0D 00 B1 A0 54 17
The USB CopyNES host I used is available here:
https://github.com/bbbradsmith/usbcopynesblue

There are some minor source code changes to the VRC7 tuner tool; the modulator volume range is fixed (only went to 32 instead of 64), and saving files is fixed, as well as adding keyboard shortcuts Q/W/E to play the tones. I haven't uploaded a build with the fixed tool, but the source code fixes are in at that repository.


Edit: attached source code an NES/NSF for the test. (Edit: I have since made a better test, however.)
Attachments
vrc7_patch_test.zip
ca65 source code, NES ROM and NSF of VRC7 path test.
(5.94 KiB) Downloaded 1080 times
Last edited by rainwarrior on Tue Mar 19, 2019 1:08 pm, edited 7 times in total.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Post by rainwarrior »

For anyone who is curious what the differences are, here's the changes in my new set, vs quietust's old one:

quietust.vrc7 > rainwarrior.vrc7:

patch 1:
Modulator output: 4 > 5
Modulator attack: 8 > 11
Modulator decay: 13 > 8
Carrier attack: 15 > 8
Carrier sustain: 1 > 2

patch 2:
Modulator output: 5 > 19
Feedback: 6 > 5
Modulator attack: 9 > 13
Modulator decay: 9 > 8
Carrier attack: 9 > 13
Modulator sustain: 6 > 2

patch 3:
Modulator output: 16 > 8
Feedback: 2 > 0
Modulator decay: 0 > 10
Carrier decay: 12 > 10
Modulator sustain: 3 > 2

patch 4:
Modulator rate scaling: 0 > 1
Modulator output: 29 > 24
Modulator attack: 9 > 7
Modulator decay: 15 > 8
Modulator sustain: 2 > 3

patch 6:
Carrier sustain: 9 > 15

patch 7:
Modulator output: 28 > 29

patch 8:
Modulator attack: 14 > 12
Carrier attack: 8 > 7
Carrier release: 5 > 7

patch 9:
Modulator sustain: 1 > 0
Modulator rate scaling: 0 > 1
Modulator output: 31 > 37
Modulator attack: 8 > 4
Modulator decay: 6 > 15
Carrier attack: 4 > 7
Modulator sustain: 2 > 0

patch 10:
Modulator output: 31 > 18
Modulator attack: 14 > 9
Modulator decay: 4 > 9
Modulator sustain: 1 > 4
Modulator release: 1 > 0
Carrier sustain: 1 > 0

patch 11:
Modulator level scale: 0 > 1
Modulator output: 43 > 41
Carrier level scale: 1 > 0
Feedback: 5 > 7
Modulator attack: 11 > 15
Modulator decay: 4 > 3
Carrier decay: 1 > 5
Modulator sustain: 2 > 10
Modulator release: 4 > 7
Carrier sustain: 15 > 1
Carrier release: 4 > 2

patch 12:
Modulator rate scaling: 0 > 1
Modulator output: 17 > 13
Modulator attack: 9 > 6
Carrier attack: 9 > 7
Carrier decay: 6 > 5
Modulator sustain: 1 > 2

patch 13:
Modulator attack: 8 > 10
Modulator decay: 2 > 3
Carrier attack: 10 > 9
Modulator sustain: 3 > 15
Modulator release: 1 > 7
Carrier release: 1 > 2

patch 14:
Carrier vibrato: 0 > 1
Carrier multiplier: 2 > 3
Modulator output: 13 > 12
Feedback: 2 > 0
Modulator attack: 12 > 9
Modulator decay: 3 > 4
Carrier attack: 7 > 10
Modulator sustain: 2 > 3
Carrier release: 5 > 6

patch 15:
Modulator output: 14 > 13
Modulator attack: 10 > 11
Modulator sustain: 4 > 5
Last edited by rainwarrior on Sun Sep 02, 2018 11:47 am, edited 1 time in total.
User avatar
Disch
Posts: 1848
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch »

I haven't compared side-by-side with actual recordings yet... but it sounds great to me at first listen!

Nice work. :)
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: New VRC7 patch set

Post by rainwarrior »

Just realized I never published the ROM/NSF of the test, or its source code. Added to OP.
ap9
Posts: 43
Joined: Sat Jun 01, 2013 11:55 am
Location: Maine, U.S.A.
Contact:

Re: New VRC7 patch set

Post by ap9 »

I found a few sustain, decay and release values are slightly off according to the waveforms in the patch test recording (internal patch first, approximated second). The set is very close, of course— I found only three instances one point off.

It was in the process of updating my emulator that I made the following adjustments to achieve close results to the h/w recording:

Patch #1:
Carrier decay 2 > 1
Carrier sustain 2 > 3
$"03 21 05 06 B8 81 42 37"

Patch #14:
Carrier release 6 > 7
$"61 63 0C 00 94 AF 34 07"

Patch #15:
Carrier release 7 > 8
$"21 62 0D 00 B1 A0 54 18"

(Also: thanks for your work, rainwarrior.)
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: New VRC7 patch set

Post by rainwarrior »

Sorry it took me a year to find the time to review this.

On patch 1 and 15 I think both of these are closer to the original. (I suspect we could even bump up that patch 15 release one more notch, will check soon.)

Patch 14 looks like a regression to me. The release is now too short. You should check too, yourself, but take a look at the image below, showing my patch #14 at the top right, yours at the bottom, built-in on left.

This is from a recording of the patch_vrc7 test from: https://github.com/bbbradsmith/nes-audio-tests

(This is a slight improvement over my old patch set test, as the timing is now cycle-counted rather than polling the PPU, so different recordings can still be very precisely synchronized now.)
Attachments
patch14_envelope_rainwarrior_vs_ap9.png
patch14_envelope_rainwarrior_vs_ap9.png (9.02 KiB) Viewed 26237 times
Last edited by rainwarrior on Sun Sep 02, 2018 12:24 pm, edited 1 time in total.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: New VRC7 patch set

Post by rainwarrior »

Did some more investigation in the VRC7 tuner. I forgot how much of a pain the LFO is, since it's free-run and not synched with anything you have to test the sounds over and over.

Looking more closely at ap9's changes:
  • Patch 1 carrier decay: Yes, this is a good change.
  • Patch 1 carrier sustain: No, keep at 2. 3 goes too quiet. This instrument has a long decay so it takes several seconds to hit sustain, but once it does it's clearly 2 and not 3.
  • Patch 14 carrier release: No, keep at 6. 7 is too fast.
  • Patch 15 carrier release: Revised. This was a step in the right direction, some of the releases were too long, but looking at it again I think the missing ingredient was carrier key rate scaling. With KRS and carrier release of 6, I think the release is now correct.
I also adjusted the modulator decay of patch 12 (should be slightly faster), and modulator attack of patch 15 (also slightly faster).

Having the opportunity to go over these again but with a lot less difference between the current state and the goal was a big help here. Those LFO instruments were wearing me out when I worked on this 6 years ago, and I think I was able to approach them a lot more carefully with this more refined problem to deal with. Ap9's adjustment to patch 15 really helped me see what was missing there, could never get the opening of the attack right across all octaves before, but with KRS it seems to match very well now. (I actually don't really have any glaring problems in this set after going over it... it feels extremely close now in a way that it didn't last time.)

Here's my new changes vs my previous set above and ap9's:

Patch 1
Carrier decay: 2 > 1 (agree with ap9)
Carrier sustain: 2 (stays)
03 21 05 06 B8 81 42 27

Patch 12
Modulator decay: 6 > 7
71 23 0D 06 67 75 23 16

Patch 14
Carrier release: 6 (stays, 7 is too fast)
61 63 0C 00 94 AF 34 06

Patch 15
Carrier KRS: off > on
Modulator attack: B > C
Carrier release: 7 > 6
21 72 0D 00 C1 A0 54 16


As always, would love any verification I could get on this, but I do know how few people have the necessary tools to really go into it (it even took me a year to get around to this one). The hotswap test I linked in my last post is a useful survey of the set, but it only does 3 octaves, with release on 1 them (just as a test of release). To really verify you need to use something like the CopyNES VRC7 tuner and try out lots of octaves, etc. Like the Patch 1 sustain wasn't something that that test could catch because the notes aren't long enough for that decay length. Well, maybe someday someone will finish staining that decap and we can know for sure. :S

Edit: I downloaded the demo of plgDavid's program, which actually has a set of VRC7 patches of its own stored in some text files. Surprisingly there's a lot of differences from all the patch sets I have archived from over the years. I guess this is a completely independent reverse engineering. Despite there being a lot of bits that are different, these patches also sound pretty close. (Though there's probably a lot of stuff that don't make a difference to the sound...)
plgDavid
Posts: 27
Joined: Tue Aug 07, 2012 11:01 am

Re: New VRC7 patch set

Post by plgDavid »

rainwarrior wrote: Edit: I downloaded the demo of plgDavid's program, which actually has a set of VRC7 patches of its own stored in some text files. Surprisingly there's a lot of differences from all the patch sets I have archived from over the years. I guess this is a completely independent reverse engineering. Despite there being a lot of bits that are different, these patches also sound pretty close. (Though there's probably a lot of stuff that don't make a difference to the sound...)
I suspect we will never get them 100% short of a more aggressive pass on the chip die (doable but very tricky apparently to delayer the protected section)
Especially exact EG settings of the modulator, which is the trickiest to fix imho (the exact EG settings of the carrier can be found really just with counting samples)
Yes our set was gathered from scratch using waveform comparison, spectrum comparison and rapid toggling between instrument 0 and x (listening for glitches or anything not smooth)

Here it is the block of code from our app (was also published in my video), and yes they are also in separate preset xml files in the synth:

// May 15th 2015 Hubert Lamontagne & David Viens
const uint8_t ROM_VRC7[OPLL_INST_MAX][OPLL_INST_SIZE]={
OPLL_USER_INIT_PATCH,
{0x03, 0x21, 0x05, 0x06, 0xC8, 0x81, 0x42, 0x27}, // Buzzy Bell
{0x13, 0x41, 0x14, 0x0D, 0xF8, 0xF7, 0x23, 0x12}, // Guitar
{0x31, 0x11, 0x08, 0x08, 0xFA, 0xC2, 0x28, 0x22}, // Wurly
{0x31, 0x61, 0x0C, 0x07, 0xF8, 0x64, 0x60, 0x27}, // Flute
{0x22, 0x21, 0x1E, 0x06, 0xFF, 0x76, 0x00, 0x28}, // Clarinet
{0x02, 0x01, 0x05, 0x00, 0xAC, 0xF2, 0x03, 0x02}, // Synth
{0x21, 0x61, 0x1D, 0x07, 0x82, 0x8F, 0x10, 0x07}, // Trumpet
{0x23, 0x21, 0x22, 0x17, 0xFF, 0x73, 0x00, 0x17}, // Organ
{0x15, 0x11, 0x25, 0x00, 0x41, 0x71, 0x00, 0xF1}, // Bells
{0x95, 0x01, 0x10, 0x0F, 0xB8, 0xAA, 0x50, 0x02}, // Vibes
{0x17, 0xC1, 0x5E, 0x07, 0xFA, 0xF8, 0x22, 0x12}, // Vibraphone
{0x71, 0x23, 0x11, 0x06, 0x65, 0x74, 0x10, 0x16}, // Tutti
{0x01, 0x02, 0xD3, 0x05, 0xF3, 0x92, 0x83, 0xF2}, // Fretless
{0x61, 0x63, 0x0C, 0x00, 0xA4, 0xFF, 0x30, 0x06}, // Synth Bass
{0x21, 0x62, 0x0D, 0x00, 0xA1, 0xFF, 0x50, 0x08} // Sweep
};
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: New VRC7 patch set

Post by rainwarrior »

Ah, thanks for posting that set here. I wasn't sure whether it was OK to share that. Here's the differences between your set (left) and the one I posted yesterday (right):

Code: Select all

Patch 1
12 11 M attack

Patch 2
20 19 M output
15 13 M attack
15 13 C attack
 7  6 C decay

Patch 3
12  9 C attack
 2 10 C decay
 8  2 M release
 2  0 C sustain

Patch 4
12 24 M output
15  7 M attack
 6  3 M sustain

Patch 5
15  0 M decay
 0  8 M release

Patch 6
 5  6 M output
10 15 M attack
12  0 M decay
 0 15 C sustain
 2  5 C release

Patch 7
15  1 C decay
 0  6 M release

Patch 8
34 26 M output
15 12 M attack
 3  2 C decay
 0  2 M sustain
 0  5 M release

Patch 9
 1 15 M decay
15  1 C sustain

Patch 10
 1  0 M key rate scale
16 18 M output
11  9 M attack
 8  9 M decay
10  2 C decay
 5  4 M sustain

Patch 11
 1  0 M key rate scale
30 41 M output
10  3 M decay
 8  5 C decay
 2 10 M sustain
 2  7 M release

Patch 12
17 13 M output
 5  7 M decay
 4  5 C decay
 1  2 M sustain
 0  3 M release

Patch 13
15 10 M attack
 8 15 M sustain
 3  7 M release
15  5 C sustain

Patch 14
10  9 M attack
15 10 C attack
 0  4 M release

Patch 15
 0  1 C key rate scale
10 12 M attack
15 10 C attack
15  0 C decay
 0  4 M release
 0  1 C sustain
 8  6 C release
I'll take a closer look at how these differ later.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: New VRC7 patch set

Post by rainwarrior »

Exciting news! Apparently a debug mode for the VRC7 was found via pin 15, and a few days ago Nuke.YKT used this to read out the VRC7 patch set:
https://siliconpr0n.org/archive/doku.ph ... nstruments

Code: Select all

1: $03 $21 $05 $06 $E8 $81 $42 $27
2: $13 $41 $14 $0D $D8 $F6 $23 $12
3: $11 $11 $08 $08 $FA $B2 $20 $12
4: $31 $61 $0C $07 $A8 $64 $61 $27
5: $32 $21 $1E $06 $E1 $76 $01 $28
6: $02 $01 $06 $00 $A3 $E2 $F4 $F4
7: $21 $61 $1D $07 $82 $81 $11 $07
8: $23 $21 $22 $17 $A2 $72 $01 $17
9: $35 $11 $25 $00 $40 $73 $72 $01
A: $B5 $01 $0F $0F $A8 $A5 $51 $02
B: $17 $C1 $24 $07 $F8 $F8 $22 $12
C: $71 $23 $11 $06 $65 $74 $18 $16
D: $01 $02 $D3 $05 $C9 $95 $03 $02
E: $61 $63 $0C $00 $94 $C0 $33 $F6
F: $21 $72 $0D $00 $C1 $D5 $56 $06
I have verified this myself using the hotswap patch test ROM I wrote. I'm willing to call this a complete and correct patch dump.

The only thing that doesn't match perfectly in my side by side recordings is the patches using the vibrato LFO, which don't match phase. I thought I could reset LFO by writing $40 then $00 to $E000 (with some delays in between), but I'm not sure if this affects the vibrato LFO? It does seem to work for tremolo... unless I'm just getting incredibly lucky with timings... at any rate I don't think that matters in terms of patch correctness, since LFO phase is normally free running and not something that would be affected by patch data anyway. Edit: investigated further and discovered you can only reset tremolo LFO, but not vibrato LFO, so getting vibrato phase to match in a recording would be difficult... maybe some very carefully timed delays could align them?

Here's the parameterized diff vs. my last set. (Mine on the left, the new dump on the right.)

Code: Select all

A: rainwarrior_2.vrc7
B: nukeykt.vrc7

Patch 1
11 14 M attack

Patch 2
19 20 M output
13 15 C attack

Patch 3
 1  0 M hold sustain
 9 11 C attack
10  2 C decay
 2  0 M release
 0  1 C sustain

Patch 4
24 12 M output
 7 10 M attack
 3  6 M sustain
 0  1 M release

Patch 5
 0  1 M key rate scale
15 14 M attack
 0  1 M decay
 8  1 M release

Patch 6
15 10 M attack
 0  3 M decay
15 14 C attack
 0 15 M sustain
 3  4 M release
 5  4 C release

Patch 7
 6  1 M release

Patch 8
26 34 M output
12 10 M attack
15  2 M decay
 2  0 M sustain
 5  1 M release

Patch 9
 0  1 M hold sustain
15  0 M decay
 1  3 C decay
 0  7 M sustain
 0  2 M release
 1  0 C sustain

Patch 10
 0  1 M hold sustain
 0  1 M key rate scale
18 15 M output
 9 10 M attack
 9  8 M decay
 2  5 C decay
 4  5 M sustain
 0  1 M release

Patch 11
 0  1 M key rate scale
 1  0 M key level scale
41 36 M output
 3  8 M decay
 5  8 C decay
10  2 M sustain
 7  2 M release

Patch 12
13 17 M output
 7  5 M decay
 5  4 C decay
 2  1 M sustain
 3  8 M release

Patch 13
10 12 M attack
 3  9 M decay
 2  5 C decay
15  0 M sustain
 7  3 M release
 5  0 C sustain

Patch 14
10 12 C attack
15  0 C decay
 4  3 M release
 0 15 C sustain

Patch 15
10 13 C attack
 0  5 C decay
 4  6 M release
 1  0 C sustain
Last edited by rainwarrior on Thu Mar 21, 2019 10:17 am, edited 4 times in total.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: New VRC7 patch set

Post by NewRisingSun »

Wonderful! Now the only impediment to perfect VRC7 bliss is correct emu2413's annoying "ladder" effect that exaggerates the quantization noise compared to the available hardware recordings.
Rahsennor
Posts: 479
Joined: Thu Aug 20, 2015 3:09 am

Re: New VRC7 patch set

Post by Rahsennor »

HELL. YEAH. :twisted:

Now if I could just find the time to update my damn emulator...
Lord Nightmare
Posts: 131
Joined: Wed Apr 05, 2006 10:12 am
Location: PA, USA
Contact:

Re: New VRC7 patch set

Post by Lord Nightmare »

Nuke.KYT also dumped the 3 drum patches from the VRC7 (yes, the vrc7 has drums in debug mode, but before you get excited, they don't seem to produce any sound on any of the pins, since it seems like the VRC7 doesn't have an RO pin like the YM2413/OPLL does, but if you try to trigger the drums their patches do show up in the debug registers, so the VRC7 must still be trying to play them. Maybe the VRC7 still has the YM2413/OPLL's instrument vs rhythm analog multiplexer, just with the rhythm output either connected nowhere, or to an unbonded pad inside the package. The drum patches are probably the same ones that the YM2413/OPLL has.)

The patches are:

Code: Select all

BD   : $01 $01 $18 $0F $DF $F8 $6A $6D
HH,SD: $01 $01 $00 $00 $C8 $D8 $A7 $68
TM,TC: $05 $01 $00 $00 $F8 $AA $59 $55
(side note: if you ground pin 15 of the VRC7 to enable the debug mode, it enables all 9 channels, so you get an extra 3 FM-only channels which DO produce sound!)


Another random thing that was discovered by ValleyBell in the past day or so, in a forum post that's been sitting around since 2007: https://www.msx.org/forum/development/m ... sic?page=1
This explains what two bits in the 0x0F 'TEST' register do:

Code: Select all

TEST (0x0F)
	76543210
	|||||||\- DAC test enable (enables DAC output from the top 4 bits of address 0x10 (0x10 is normally the frequency LSB bits for channel 0)
	||||||\-- ?
	|||||\--- ?
	||||\---- This bit, if set, silences the FM sound output. How exactly is unknown. (On YM2151 at least, this bit freezes the phase counters and lfo counters)
	|||\----- ?
	||\------ ?
	|\------- ?
	\-------- ?
Whether this works on the VRC7 or not (since the post is targeting the YM2413/OPLL) is unclear, but I'm guessing it probably does.

Questions I have:
Does TEST bit 0 make the other DAC bits accessible in 4 bit blocks on 0x11, 0x12, etc? Does it change anything else?
What do the other TEST bits do? On YM2151, TEST bit 1 halts the LFO if high, and resets the LFO to zero on a 1->0 transition, so this may be worth checking if it does the same thing here (perhaps this is the 'real' way to reset the AM LFO?)

LN
"When life gives you zombies... *CHA-CHIK!* ...you make zombie-ade!"
Great Hierophant
Posts: 780
Joined: Tue Nov 23, 2004 9:35 pm

Re: New VRC7 patch set

Post by Great Hierophant »

How difficult do you think it would be to adopt Nukey's method for the original YM2413? That chip's patch set has yet to be dumped. It seems like, according to the wiki, that grounding the debug pin on the VRC7 seems to turn some of it's other pins into the bus control lines available on the YM2413. If that is the case, then the YM2413's test mode should be just as easy to access as the VRC7's.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: New VRC7 patch set

Post by rainwarrior »

Lord Nightmare thanks for that info! I will definitely give it a test in the future. Actually looking again at the YM2413 datasheet and it really does list $0F as "T E S T" / "OPLL test data", though it doesn't give any more information than that. Very interesting!
Great Hierophant wrote:How difficult do you think it would be to adopt Nukey's method for the original YM2413? That chip's patch set has yet to be dumped. It seems like, according to the wiki, that grounding the debug pin on the VRC7 seems to turn some of it's other pins into the bus control lines available on the YM2413. If that is the case, then the YM2413's test mode should be just as easy to access as the VRC7's.
The YM2413 doesn't have any suspicious free pins like the VRC7 did though, so if there does exist an equivalent "debug" mode, it might be trickier to figure out how to activate it. It sounded like nobody's decapped a YM2413 yet...
Post Reply