This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

VRC7 and 5B amplifier investigation, also VRC7 LFO reset!

VRC7 and 5B amplifier investigation, also VRC7 LFO reset!
by on (#224897)
So I knew for a long time that both the VRC7 and 5B had some amplifier stuff to be worked out, and it's been on my list to investigate for a long time. I've run a few tests today that had interesting results. I haven't really fully analyzed them, but I thought I should share in case anyone has any good ideas for how to approach testing this stuff.

All mentioned test ROMs are here on github.


1. VRC7 seems to have flat clipping that begins at slightly less than 2x the full volume of 1 channel. This means if I play 2 channels at the loudest volume, there will be some distortion.

The clip_vrc7 test ROM creates a sine wave instrument, plays it on 1 channel at full volume, then 2 at once, then 3 at once, etc. In this recording we can see clipping begins on the bottom part of the wave only at 2x (an internal bias?), and then clipping on both ends at 3x and higher. Finally a triangle wave is overlaid to demonstrate that this clipping only applies to the VRC7 portion of the sound, the input audio appears to be passed through unharmed.

Recording is attached.


2. 5B is much stranger. I don't know how to describe what this is doing. I don't think there is clipping, but there seems to be some sort of compression effect?

The clip_5b test ROM creates 3 squares at 110, 220, 440hz, plays them together at volumes 9,A,B,C where they seem to mix together normally / linearly. Next it starts from 0 and gradually increases volume to 15 for each channel in turn. For the first channel, we see very nice 3db steps like expected, but the very last step to volume 15 isn't quite as wide. As the next two channels fade themselves in, the overall volume does increase a bit, but it seems to be squashed. Finally an APU triangle is overlaid at ~470Hz. This triangle is audible, but when I cut off the 5B squares, suddenly its volume grows? It seems to take about 30ms to reach its full volume after the loud squares have left.

Attachment:
triangle_returns.png
triangle_returns.png [ 5.22 KiB | Viewed 13607 times ]


So, this is a bit bizarre. I guess this is some sort of compressor, but how should I go about trying to test it and properly replicate its behaviour?

Kinda mad at myself for not digging into this sooner. I noticed the compressed look of Gimmick's audio when I recorded its soundtrack a while back, and I even adjusted the log tables in NSFPlay's 5B simulation to match the squashed volumes 15 and 14.5 I had seen in testing (yes, a real hack job for sure). Had a note to go back for it later, but my priorities had been elsewhere for a few years...

(Also, I made a revision to my audio survey test for 5B. Since the output seems reliably linear for a single channel below volume 15, I replaced the full volume test with volume 12. This also meant a revision to the new 'mixe' chunk I'd proposed, but hopefully nobody's actually using it yet.)

Wanted to stack 3 squares of the same pitch in-phase, but being able to phase reset on the 5B continues to elude me. I thought I could get it by setting the period registers to 0 or 1 to get them in a short loop and then setting the final pitch on all 3 very quickly would do it, but this didn't work like I thought it would (phases still seemed "random"). Kinda curious about how they're actually implemented internally... has there been a decap / analysis of the AY at any point?


3. It appears that it's actually possible to reset the VRC7 LFO! Edit: this only applies to tremolo LFO. The vibrato LFO is not reset by this method! Edit again: another method was found which does reset both LFO! See: this post.

lidnariq asked on the wiki what the $E000:6 audio disable bit did. I did an initial test and found that it silenced the audio, and setting that bit appeared to "clear" the custom instrument (not sure what the "clear" values are, since I can't read it back) and any playing tones. Clearing that bit makes it operate again.

Today I tried playing an instrument with tremolo following such a toggle, though, and discovered that it was reliably playing with the same tremolo phase every time!

So, that's not very useful for playing music (since you're basically flipping the whole unit off and on), but I think if I put this into the VRC7 Tuner I might be able to make better progress on the patches that use tremolo/vibratio, since their free-run nature has always made them very difficult to compare with.

I'm not sure how long it takes to go into effect. The lfo_vrc7 test waits about a frame between setting the bit and clearing it, and then another frame before playing the note. (I was being conservative.) My guess is that the delay we use for other VRC7 writes is probably about how long it takes, but at least I've discovered that it can be done.


None of this really matters for Lagrange Point or Gimmick!, since they don't use loud volumes like this. Even homebrew doesn't usually use VRC7/5B at their loudest since they overpower it anyway. This is "subtle" stuff in terms of utility, not really a big problem if an emulator is missing it, but we still want to know don't we? ^_^

(Also, in case anyone is wondering, I haven't seen an effect like this on the other 4 expansions, so I don't think there's any worry of discovering something like this with any of those.)
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#224899)
rainwarrior wrote:
2. 5B is much stranger. I don't know how to describe what this is doing. I don't think there is clipping, but there seems to be some sort of compression effect?
We do know that there's an amplifier inside the 5B. I'd be a little surprised if it's got a compressor on it, since it has an external resistor, but... your evidence is really pretty inarguable.

Quote:
So, this is a bit bizarre. I guess this is some sort of compressor, but how should I go about trying to test it and properly replicate its behaviour?
Well, the time constant from the recording shows its recovery time, right?

You should be able to switch high-volume things on and off at some rate sufficiently faster than that to figure out its minimum gain. And given the minimum gain, you can figure out the maximum gain. And ... what other properties are there to a compressor? Knee, gain, compression ratio, attack and decay times?

Quote:
has there been a decap / analysis of the AY at any point?
The same Sean Riddle who helped with the M50805 decap took pictures of an AY-3-8910 here.

MAME's source mentions some analysis from decaps, as well as links to two more decaps beyond Sean Riddle's above, in its AY-3-8910 emulation.

Quote:
lidnariq asked on the wiki what the $E000:6 audio disable bit did. I did an initial test and found that it silenced the audio, and setting that bit appeared to "clear" the custom instrument (not sure what the "clear" values are, since I can't read it back) and any playing tones. Clearing that bit makes it operate again.
If it is the same as the YM2413's /InitialClear input, that part's documentation claims it clears all the registers.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#224904)
Not understanding anything about die analysis... so this might be redundant, but I think we can safely narrow down the range of possible compressor topologies to one of these.

-feedback VCA (voltage controlled amplifier) - very straightforward, cheap, simple, often the goto solution. Seems probable. Self-adjusting based on output rather than input. Ratio, attack and decay is a function of the signal and cannot be strictly defined. An approximation in emulation can still be good enough.
-feedforward VCA - also straightforward, not much more complex than the feedback variant. Often applied when you want precise ratio, attack and decay. but this is a relatively cheap consumer product - who cares? but if this topology was used, that's also good news for emulation - it could be potentially very precise.
-feedback diode bridge (as simple as it gets, potentially passive) - if badly matched (probably our case), they will produce a DC offset to the signal. If overdriven (not necessarily the case), they can cause distortion on 3rd harmonics. For this reason, simple diode bridges-as-compressors were largely abandoned in studio-grade equipment two decades before the famicom hit the market, but that doesn't necessarily mean it wasn't ever used again where fidelity was of no importance or where audio levels could be predicted, such as in a consumer product.

In your waveform snapshot, it looks like we have a dissipating DC offset in the release stage. This might be in favour of the third option, but honestly i know to little about EE to be able to verify/falsify. Is there any other way a dc offset component could be momentarily added to the mix like that?
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#224970)
Thanks for the suggestions and thoughts. Here's day 2's update. (source code)

1. noise_vrc7

A recording of APU noise $3 (56kHz) against a high feedback "white noise" patch for VRC7. The lowpass filter for VRC7 is very clear here. A bit of highpass too I think. (Can analyze later.)

2. noise_5b

A recording of APU noise $3 (56kHz) against equivalent 5B noise (also 56kHz, same 32 CPU cycle count). Both are passing through the same filters here, and compared to the "unaltered" 2A03 noise in the VRC7 noise test above you can see evidence of a highpass, but no significant lowpass I think? (More to analyze later.)

3. clip_5v version 2

This one's more complicated to describe. I've created a table of 42 volumes, most of them roughly 1dB apart as a theoretical linear sum of the 3 channels. (0-7 apart are 3dB apart, but after that they're close to 1dB apart each, the last few are a little off from that ideal, there's an ODS with the source computing the theoretical linear sum of them all that I'll use to compare against the compressor output later when I analyze this.)

  • Step 1: Set volume of the 3 registers to output each of those 42 levels as DC. Then pop back to 0.
  • Step 2: Use a cycle counted square wave at each of those 42 levels.
  • Step 3: Step 1 with APU triangle throughout. (Shows compression release.)
  • Step 4: Step 2 with APU triangle throughout. (Shows compression release.)
  • Step 5: Full volume cycle counted tone on and off.
  • Step 6: Step 5 with APU triangle throughout.

A few notes on the compressor so far:

- The triangle indicates that compression is not affected by the slow DC offset. Assuming it applies after the highpass filter. (Step 3)
- The onset of compression seems to apply very immediately, judying by the effect on the triangle. (Final pop in step 3.)
- When the tones start to be compressed, they get extra compression at the offset, then widen out as the highpass brings them closer to 0. I theorize that the compressor is based on the peak signal after the highpass filter applies. (Later half of step 2.)
- Negative magnitude seems as effective as positive magnitude for triggering compression. (Final pop in step 3 as a positive step, step 4 onsets as negative, saw other onsets from negative in other revisions of this test I didn't publish too.)

Later I'm going to measure all the tones in step 2 and chart them against the theoretical linear mix. That should help find a suitable compression curve. We can measure the triangle's return to full volume to understand the release timing of the compressor (especially from step 6).

I think that might actually be enough to adequately describe this? Anyone have any thoughts?

I've never studied or tried to build an analog compressor, so I'm a little out of my element on my usual goal of trying to imagine what the simplest possible implementation looks like, but the stuff I mentioned above seems like it should be plausible from a relatively simple circuit? The compressor seems to roughly turning that exponential 1dB progression into a linear one just above volume 14 (31th volume in the progression), though I haven't yet charted it thoroughly. Is an approximate log to linear adjustment like that reasonable to implement?


One followup, I was asking about AY decap just because I didn't understand why I couldn't reset phase, but the MAME implementation I think makes it clear where my understanding of the results was wrong. I was trying to put them at a high frequency with the hope that when I switched to low frequency they'd restart the next wave slowly. However, the timer counter inside the AY is just a count of when to flip the bit, not a timer for the whole waveform. So, and given change could happen on either bit, so the phase wasn't random, it was randomly inverted. (This was borne out to be true by reviewing my earlier attempt.) MAME also answers my question about what period 0 does (i.e. same as period 1), which I'd assumed but was nice to have a confirmation. (This is wrong in NSFPlay's inheritend YM2149 emulation too.)
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#224979)
Quote:
Negative magnitude seems as effective as positive magnitude for triggering compression.


A typical compressor will pick up the signal as a so-called side-chain, rectify it so that all peaks have the same polarity, so the amplifier can act correctly on both poles. And it is common that it is then smoothed out with at least one slew limiting circuit to create an even control voltage to be used to diminish the amplification. It also sort of counteracts any DC offset here by averaging the peaks, if any plausible DC offset wasn't already counteracted/avoided altogether. Anyway, the slew limiter is responsible for attack and decay. A more elaborated compressor will have two different slew limiters for rising and falling signals (so you can set attack and decay separately) The capacitor will have some effect on the slew.

This article illustrates it:
http://www.audiotechnology.com.au/wp/in ... ide-chain/
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225012)
Here's some measured results from yesterday's test.

A graph of the predicted linear mix levels vs measured:
Attachment:
clip_5b_lin.png
clip_5b_lin.png [ 19.92 KiB | Viewed 13438 times ]

The same graph with logarithmic scale on both axes, cropping out some of the lower left to show the more interesting part where it diverges:
Attachment:
clip_5b_log.png
clip_5b_log.png [ 24.82 KiB | Viewed 13438 times ]

The linear mix prediction seems to match extremely well up to and including volume 14. Anything higher than that appears to be affected by compression. The measured levels were taken after the onset/highpass had settled into a symmetrical wave, so from the compressor's perspective I think it's should represent a map from a negative or positive peak that's 50% of the peak to peak difference. (As mentioned before, the onsets are more compressed, and widen back out as the highpass shifts it back to centre.)

On the logarithmic graph I threw an exponential trend line on the data points from (14,0,0) to (15,15,15). That seems to be a roughly 2.6:1 compressor if we assume a hard knee? I think the actual dB curve might be a little less straight, with the dB compression radio gradually increasing past the threshold.

As for my question about compressors, thanks for the link FrankenGraphics, though for the most part it doesn't really address the parts of this I don't understand. Like I understand that a compressor normally has an attack/release, a compression ratio, a hard or soft knee. What I don't understand is what are the analog components needed to build one, and which variation of that is most sensible to embed in an ASIC like the 5B. I can find several articles mentioning that there's variations like tube / optical / solid state / VCA / feed-back / feed-forward / etc. but I'm having a harder time finding information about the actual compression characteristics that belong to each of these.

I know it's normal for a compressor to work with both positive and negative peaks, I only mentioned the polarity because I didn't think it should be assumed as a given in this particular case, because the pre-filtered output of the 5B only lies on one side of 0. I don't know who designed this, or why they wanted a compressor in it, but skipping a rectifier seemed like a plausible possibility, so I wanted to explicitly rule it out.

Here's a digital model that these results seems to be conjuring for me:
Code:
1. A = PCM input signal
2. H = highpass(A)               ; will be used as pre-gain output, and input to the compressor sidechain
3. S = clamp(abs(H) - threshold) ; rectify H and cut off signal below threshold
4. C = lowpass(S)                ; lowpass S to generate the gradual release (will try to estimate this curve from recording later)
5. O = H * (1 - func(C))         ; output attenuates H based on strength of C, func() here is a placeholder for some approriate curve

I'm assuming there isn't a separate highpass for the compressor's control sidechain because the attack seems to be instant and match the output so closely, for similar reason I'd want to assume the lowpass is probably a very simple 1st order filter? (I'll probably need so spend some time thinking about this / experimenting, not sure if my intuition is correct here.) The remaining question is what kind of curve goes into "func" there, presumably some <1 constant raised to the power of the sample from C.

The biggest open question for me is the hard/soft knee thing. I'm assuming that there is a "typical" kind of soft knee curve that results naturally from a simple analog circuit. Is a hard knee easier or harder to make, or is there a simple/common wait to implement one? I can measure stuff as best I can and try to replicate it, but it would be nice to have a sound theory for what kind of curve I should be looking for here. (I'll try to find myself a suitable reference on compressor design... I found this one which seems pretty good so far. This article doesn't have much detail but there are some tantalizing graphs of a real analog compressor.)

...though, given the amount of data I have to work with and the amount of error there seems to be due to probably a bunch of intervening factors (in particular the assumption that all 3 channels mix equally and linearly) maybe it's splitting a little bit too fine a hair trying to determine the difference between a soft and hard knee here.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225027)
Was trying to find information and ran across this PDF and I had to laugh.
Attachment:
compressor_filter_characterization.jpg
compressor_filter_characterization.jpg [ 100.66 KiB | Viewed 13414 times ]
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225054)
A similar effect is present in SMS2, where one resistor value on the chip output is not quite right and cause flattening out of the highest levels due to way output mixing and buffering works inside the chip.

Stock : http://www.tmeeco.eu/SMS/PSGbadLevels.jpg
Ideal/with corrected resistor value : http://www.tmeeco.eu/SMS/PSGgoodLevels.jpg
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225064)
Quote:
What I don't understand is what are the analog components needed to build one


I hope i'm not wasting your time with this. I don't think you don't need to know the intricacies to make a "lazy" emulation that basically yields the same result to your ear.

Exactly what components, and in what configuration, really depends on what topology we're looking at, and i'm not too well read on all of them. So the following goes for what i do know. I'll just list some building blocks that are common.

A few concepts first that informs the rest.
-An amplifier consists at least of one or two transistors.
-A so-called operational amplifier is really a whole block of more specific amplifiers with different tasks.
-A diode and a transistor is based on the same technology (semi conduction), except diodes consist only of a passive channel and your sole mode of definition is in what direction you put it and exactly what semi-conductive material you're using, while a transistor will have an extra lead which can modify the operation of said channel.

To build a gain reducer:
At the very core, to reduce gain you need an "inverting amplifier". It will subtract one signal from the other and output the difference. This is where the (negative) feedback comes in (which you will sum with the input, while the other input is tied to ground). If both input and feedback are 1:1, gain is *0. If no feedback is provided, gain is *1. The balance is done with two resistors, one on the direct input and one on the feedback. They are joined post-resistors. The formula is -feedbackresistor/inputresistor. Again the amp will, as the name implies, invert the polarity of the signal (hence the -), so is common to place two amplifiers in a daisychain to revert it if phase is important.

Typically the job of the second amp is just to pass the input to the output with unmodified gain and just revert the phase, but since you already have two amps in place... maybe the first is used for setting the volume and the second is used for some compression, since it is there anyway.

Now, i've only built this kind of circuit with whole OpAmp IC:s (operational amplifiers). Doing a differential amplification with these looks like this:
Image

...but iirc you can build one discretely with just two "common emitter" transistors and three resistors, not counting any output buffer measures taken or such. You can look up "differential amplifier" if you want to look into it. Depending on case, you might not need extra buffer amplifiers.

A super simple/hacky way to create a threshold for gain reduction/compression (and i don't know if it was used here) is to pass the feedback through a diode. The diode must reach over a certain voltage to "break down" and start conducting. It also introduces a voltage drop, which means gain can't really be reduced to 0, but that's not what we are doing here anyway. IF this method was used, note that there'd be *some* variance on exactly what voltage the diode will conduct, from die to die. It probably also needs to be a diode with a low breakdown voltage since, i assume, audio voltage levels are quite small even within the cartridge synth? (it is generally good to keep them high. studio audio has a pvp of 1.7, consumer audio outputs 0.45, modular synthesizers anything between 5 and 12 haha. the typical silicon diode breaks at 0.7 and the typical germanium diode breaks at 0.3 - these aren't as common in consumer electronics and are more or less extinct today. You can make your audio level match the breakdown voltage by adding a "voltage divider" circuit).

About building the simplest possible compressor in the world:
For a fully passive diode bridge compressor, all you need is really 7 resistors, 4 diodes and 2 capacitors, just to point out how simple it can get. That is a little academical - you still need an active buffer stage for the signal to keep the intended volume and impedance. I'm not sure of its applicability here since i don't know how you'd add a threshold to this passive scheme, but those resistors would at least let you define ratio, attack and decay. There probably is a way to introduce a threshold, and i just don't know about it.

About building a full VCA compressor and why it probably isn't what we want:
A full-sized VCA circuit will first use two inverting amps (= 4 transistors and some resistors) to produce a control voltage (which you can easily bias or gain control in itself via the specifics of the VCA block), which can then be used to in turn to gain-control another OpAmp pair that is solely responsible for the end volume (how much goes to audio out, and how much goes down the drain). This volume is fed back into the VCA block for partial self correction in a compressing circuit.

Note that the purpose of a full-blown VCA is to be able to provide easy means to control the amount of gain reduction. You might not need all its bells and whistles. A lot of the hobbyist schematics you'll find are unnecessarily feature-heavy for our purposes even when they're labeled simple, because they're designed by someone who wanted some specific interface in the first place. Like being able to voltage control the ratio, threshold, knee or whatever. All we want to do is voltage control the volume and that's it.

Rectifiers:
All a rectifier does is nullify the negative swing. And all it takes is a diode. This is more elaborately called half wave rectification.
But if you add together two rectified signals (one for each pole), you get both polar peaks on the same 0-maxV pole. This is called full wave rectification.
It looks like this.

Partly because of the choppyness introduced by the diodes' breakdown voltage, a smoothing capacitor is used. and/or you can use germanium diodes, which have a lower breakdown voltage.

A VCA block will need this for producing a control voltage out of the rectified, smoothed signal.

I've mentioned diode bridges twice in this post. Note that their applications are different. One is to be a compressor in itself, the other is to precondition a source material for the VCA.



I'm just wondering why they might've intentionally wanted a compressor. Maybe they were worried about overdrive or just general loudness? On the other hand, the APU squares can get too loud compared to the rest as it already is. Maybe it's just a fluke effect or a hacky "well, we might aswell".
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225065)
well, i came to post the paper that i've used in the past when making compressors for DSP projects and it looks like you've already found it.

i don't think you should be worrying too much about the actual analog components, that's an incredibly difficult question when compared to the relatively simple question of how to create a black-box effect that gives similar results.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225080)
FrankenGraphics, I'm sorry to say but I don't need an explanation of what the difference between a diode and a transitor is, or how a standard op-amp circuit works, what a rectifier is, etc. I tried to say this, but maybe I didn't make it clear I'm not asking for a primer in circuits from the ground up, I'm asking only about compressors specifically. You went into great detail on things that I do know, and then very little detail on the things that I actually am having trouble finding good explanations of. (Despite it not really being what I was asking there was still some information in your post that was helpful to hear, so thank you for that anyway.)

Though also, my question is only indirectly how to build one, but more directly what the characteristics are of an analog compressor, i.e. what kind of response should I be looking to model. What I really want to know:

1. Is it practical to build an analog compressor in a mapper IC with an infinitely hard knee?
2. Is it practical to build an analog compressor in a mapper IC with a soft knee? What kind of response curve results from this?

I linked a PDF above that was a good article on DSP compressor design, but it's really about building practical digital compressors; it deliberately backs off from trying to model analog compressors. The one thing I'm most interested in knowing is how the compression curve is created in an analog sense, and that article instead just glues 3 segments together for the two log-linear portions and the soft knee portion. Yeah that's easy to do in a DSP but I want to know about the real curves that are used. I already know how to build a spline.

That second article I linked has some very interesting graphs of one particular type of analog compressor, and those curves are the closest thing to what I actually want to know most about it, but the graph is all this article has to tell me. Its last paragraph might be summarized as "there is no cookie-cutter approach to modeling of analog compressors", which seems fair enough. Maybe the reason I'm finding it hard to get information about this is because the resulting curves are actually the result of complicated interactions that are hard to model succinctly.

toggle switch wrote:
i don't think you should be worrying too much about the actual analog components, that's an incredibly difficult question when compared to the relatively simple question of how to create a black-box effect that gives similar results.
Well, what I was asking is whether there's some kind of standarad characteristics of compressors. Maybe there really isn't, or maybe there is but it's an advanced topic that's hard to find info about. What FrankenGraphics was answering about analog components isn't really what I was after; I just want to have some idea of what to model. It's not so much that I want to know the parts here, I want reference on their curves... like I'm not going to build 10 varieties of compressor to analyze their curves to understand this. Digital simulations might be easier, but like that first article I linked the approach seems to be more or less "build the curve you want" and not replicating the analog stuff.

FrankenGraphics wrote:
I'm just wondering why they might've intentionally wanted a compressor. Maybe they were worried about overdrive or just general loudness? On the other hand, the APU squares can get too loud compared to the rest as it already is. Maybe it's just a fluke effect or a hacky "well, we might aswell".
I find it pretty baffling, myself. The thing TmEE posted about a bad mix in an SMS2 looks like the kind of thing that would happen by accident. This compression effect feels more deliberate to me.


...anyhow, all of that is maybe kinda moot because I'd come to the conclusion (like toggle switch was suggesting) that a simpler model is probably good enough to get uncannily close anyway. We can put a pin in the my question about compressors, which might have been summarized as "is there a standard response curve for analog compressors that I should be looking for?" and the answer seems to be "no" on the fine details level, but "yes" on the very coarse detail level I already knew going in.

So, yesterday I came up with a rough hard knee approximation. I'm still working on the release characteristics so I wasn't going to post again until I had more on that too but here:
Attachment:
clip_5b_hard.png
clip_5b_hard.png [ 25.89 KiB | Viewed 13337 times ]

Here's a threshold set 1dB above volume 14 (or 7dB above volume 12), with a compression ratio of 2.7:1 dB. (The graph units are in dB, theoretical input on X, measured output on Y.)

That's probably a better model than whatever I'd have to do to simulate the real analog curve, and probably close enough that we would never be able to tell the difference by ear anyway.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225081)
rainwarrior wrote:
1. Is it practical to build an analog compressor in a mapper IC with an infinitely hard knee?
I suspect the answer is no, because there are basically no parts with a V-I curve that has a sharp corner without having a complete discontinuity (e.g. DIAC)
Quote:
2. Is it practical to build an analog compressor in a mapper IC with a soft knee? What kind of response curve results from this?
I don't know enough to really be able to answer the question of whether a VCA can be given a nice transfer curve like this. I kinda suspect the answer is that analog compressors weren't usually defined in this piecewise linear way.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225084)
Yeah, that was more or less my intuition about it. No graph I could find of a vintage compressor response looked like 2 straight lines, or 2 straight lines with a circular curve, like all the basic compressor theory stuff seems to teach.

What I saw in some graphs that I could find were two mostly-linear regions (in dB scale), a knee that is not really very symmetrical, and then eventually on the extreme high end the curve takes off again. I can see how this would be idealized as a 3 piece spline for a theoretical model, and in practical terms it's probably a very usable model... but there's some big simplifications being made here.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225086)
Sorry to have missed the point of your inquiry so badly! No, i think you made it clear - i should just have taken the time to read it twice.

Quote:
Is it practical to build an analog compressor in a mapper IC with an infinitely hard [my edit: or soft] knee?

Maybe. It's an anachronism, but THATcorp (which specialize in compressor-on-a-chip:s) mention and show super-hard knees and soft knees in their freely available design note PDF:s (which differ from ordinary spec sheets in that they actually want people with varied EE experiences to use their IC:s by explaining stuff in layman terms). I haven't read much of it, but it might be worth a look.
From a quick glance, this document seems to explain the schematic differences between soft-knee and hard-knee. There are more design note PDF:s like this from THATcorp.

For the "on an IC" part, you could probably make the whole thing out of standard MOSFETs for transistors which had been widely available for a long time by then (the 6502 itself being obvious proof). Since they're not current driven, but rather voltage potential driven, they have very little load on the supply while being turned on, which we want on a cartridge device especially. Switching on and off rapidly is wasteful, but that's not what we do here. I don't remember all the characteristics of the MOSFET, but iirc the forward drop is insignificant which should mean you potentially need less buffering which could equal a simpler schematic. The "coloured character" of FET compressors in studios shouldn't apply. We're not dealing with the vast dynamic range of a natural recording, nor the subtle quality of a physical instrument.

(Beyond that, i don't really know what differs in a VCA vs a FET studio compressor/limiter on a schematic level, other than FETs being the specific transistors in use. But i suspect not a lot/the specifics of each compressor product being more different? Studio equipment companies have always been keen on blowing things like these out of proportion for the sake of branding/product presentation, and in the end - for the studio engineer, unlike the game PCB engineer - it's the musical applications that matter).


Quote:
I find it pretty baffling, myself. The thing TmEE posted about a bad mix in an SMS2 looks like the kind of thing that would happen by accident. This compression effect feels more deliberate to me.

Had the threshold been a bit lower, it could maybe have been used for a pleasant kick+bass ducking effect. But this feels like an anachronism too.

Or wait - maybe it is supposed to make SFX:s punch through better and music resume more nicely? If transients for music and rythm is just below, but transients for SFX above, this should leave some space and make the music fade in a bit, rather than resume abruptly, as per normal. The threshold still seems a little too high set for my personal taste, but i could see that being the feature request that motivated the inclusion of a compressor with a bit of a release.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225095)
That's a neat document. I must admit though, I get to page 6 with Figure 8 having a really nice graph of its "soft knee", but then I try to find how this curve is defined and... "Figure 8 shows the result of a SPICE simulation". Ha ha. Still it is nice to verify what I'd gathered that an analog soft knee will have its compression gradually tend to infinity, even if it's got a more-or-less flat ratio for a little while, and seems like it might be a usable enough model of the circuit. (...in contrast to the link I posted to a graph of an optical compressor; those seem to blow out at the high end instead?)

I posted a more easily defined hard knee model above though, and in practice I think that's probably what I'm going to want to implement anyway... once I get the release worked out the next step is to write a compressor implementation for NSFPlay. If I can think of a practical way to do the more "analog" style I might go for it.

FrankenGraphics wrote:
Or wait - maybe it is supposed to make SFX:s punch through better and music resume more nicely?

Well, it could be used to increase the contrast of a loud SFX against the music without increasing the overall volume... but in the actual case of Gimmick!, no I don't think it is doing this. The SFX volumes are really no louder than those used for the music anyway.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225097)
The question is... did someone initially think it was a great idea, and then, did the composer/SFX programmer just not care? I guess the mapper was developed for Gimmick! especially, but maybe rather Gimmick! was made to fit their plan for a new mapper.

Besides, doesn't Gimmick! omit using the envelope feature?

There's a bit of an additional problem to this theory though. 5B being very loud to begin with sort of counteracts its usefulness as a voiceover-ducker a bit. The margin for practical use of this technique has got to be pretty narrow because of this. (On one hand, this could explain why it wasn't used as such, ultimately).
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225103)
Relative to the APU, the 5B is not the loudest expansion. It has a logarithmic volume control, and a wider range, but its pre-compression output for a single channel only really goes up to maybe 8 db louder than an APU square can go? VRC7 can go more like 11 dB, and N163 carts might be as much as 20 dB louder in single channel mode.

The 5B is known as the "loudest" expansion because the actual output from the console is the loudest. The other expansions use passive mixing, so the APU volume is reduced to passively mix with the expansion. With the 5B it's fed into the amplifier so the output levels are kept high.

So, in terms of output it is the loudest, but it's not really the loudest from mixing/relative viewpoint (where the idea of compression and contrast should matter).


Another theory might be that Sunsoft thought the output should be as loud as is allowed, so the higher volume will have better fidelity on various televisions, and the compressor was maybe a safety device on top of this, to keep it from accidentally going too far? The end result though ended up putting a lot of squash on the Gimmick! soundtrack (...which I will soon be able to emulate somewhat faithfully, I hope).

Where other companies thought the APU volume reduction was an acceptable compromise, Sunsoft felt it was a thing to correct? This solution seems a bit overcooked to me, but I could see it happening that way. At least, it feels like a more realistic reason than the idea that someone thought it would make the mix of Gimmick!'s soundtrack better.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225106)
thanks for clarifying it. Yeah, like you said, a somewhat hot signal has the benefit of a better signal to noise/interference ratio with the risk of being overdriven at the input stage. This would depend on the output impedance, too. But that seems plausible. Is the signal hotter than consumer audio?

Lots of useful stuff here to mind for composing for the synth. The logarithmic control should mean it lends itself well to instruments with a bit of percussion or swell, but also echo/faux bucket brigade effects, quiet layers and additive sounds better than the APU.

Best of luck on the implementation! I'm looking forward to hear what the Gimmick! soundtrack sounds like with the compression in place. I always thought it was a little messy in the mix (seems a common problem with expansion soundtracks - lots of things competing for the same space both on the dynamic and spectral plane makes it a bit muddy), and now wondering if this compression might make it a bit better or a bit worse, or whether the effect is "meh" on the notability scale.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225107)
I don't really know what the actual voltages are, and how that compares to TV audio input specs. I've only really been concerned with stuff that's relevant to reproducing the audio in emulation.

If you want to hear it straight from the cart, I recorded the sound test a long time ago for reference:
https://forums.nesdev.com/viewtopic.php?p=90245#p90245

Actually, there's a reference recording in there where I threw a bunch of different carts in my famicom without stopping. You can see there that Gimmick's peak levels are only a little louder than the un-expanded Famicom's? (SMB / Ninja Gaiden are the plain APU reference carts used, RMS of these vs Gimmick seems about 3dB louder for Gimmick)


I think the biggest advantage of log volumes for chiptune is just that you the CPU doesn't have to multiply to lower the volume proportionally. Very natural sounding exponential decay envelopes are easier, etc. The big disadvantage is that it's hard to find a tradeoff between too wide an exponential step and a good range, especially if you've only got 4 bits to represent it like the 5B and VRC7.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225109)
Hm, if there's a difference in clarity derived from changes in the dynamics, i'm not sure i can hear it. I like it more, but it seems to stem from that there's a lowpass that i think improves it, by removing all the noisy whispers that i find a little bit interfering with the emulation based soundtrack i've been listening to. If there is an effect, it downs out for me in an a/b test because of the perceived overall improvement.

Also, even the emulated songs i listened to sounds more clear than i remembered it. I take back what i wrote.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225165)
You know, after all that, maybe this isn't so much a compressor as just a nonlinearity in the amplifier. (...is it still a compressor if the attack/release is instant? A waveshaper?) I think a highpass filter followed by the curve I already described is enough to more or less duplicate the effects seen.

What looked like recovery of the triangle (see earlier picture) was probably just the property of them passing back in from the flatter part of the output range. I did some more tests like playing the triangle through a louder square tone and then stopping that square in the centre rather than high or low, and the effect basically disappears. Still working on the parameters but my emulated output is already demonstrating a pretty reasonable facsimile.

Though, I think I actually do need to model a soft knee curve here after all. ;) Without a filtered delay to smooth it out that sudden discontinuity makes some pretty audible harmonic distortion. (...though maybe not that noticeable in the usual context of square waves.) Presumably the same kind of curve an analog compressor should produce, just with a less complicated control computation component since it's immediate?


Now that this seems to be on the right track, It looks like there's a different, weaker highpass applied to the compression control than actually applies to the final output. I think this threw me off for a while, because I was seeing compressed stuff with centred DC due to this disparity. Unraveling a stack of filters through this black box might be a bit tough...

On a related note, the APU channels get their own highpass before the 5B, so they have 2 (or is this 3) layers of highpass by the time they get out of the 5B? The APU Mixer page on the wiki says that a Famicom has a much weaker highpass than the NES, but in my recordings (AV mod tapping the audio return) it has a stronger one? I've been confused about this. Is there a buffer when it goes to the RF modulator, or would it still being connected have an effect... maybe I need to review my audio mod. :(
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225173)
Quote:
(...is it still a compressor if the attack/release is instant? A waveshaper?)

I'd still call it a compressor (in effect). Or simply nonlinear, rolled off response curve just to promote the idea of it being unintentional. It could maybe still be a measure to counteract the limited utility of the highest volume settings or to solve a loudness/clipping problem they had with their speaker setup, but i don't feel so sure about that at this point.

The use of the word may mean more than i know, but usually waveshaping is associated with the extrapolation of overtones, or just plain distortion. (BTW Digital waveshaping risks sounding harsh because of aliasing artifacts, to which you might want to add countermeasures. But that's a whole other territory).

Quote:
What looked like recovery of the triangle (see earlier picture) was probably just the property of them passing back in from the flatter part of the output range


omg, yeah, that should be it. I expect it to look a bit samey even without the triangle - centering back to the resting position. Else, i think we'd be able to hear a click/pop.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225186)
Yes, that's why I wouldn't really want to call it a waveshaper. It's intended function doesn't appear to be distortion, that's just a side effect. Also with most of the inputs being square waves there's not much opportunity for it to act in that way. I suspect it's implemented like a compressor to, just with with a control signal that has no filter. Also I feel like waveshaper is exclusively a term for a digital effect... but anyway the semantics don't matter so much to me as the actual function. ;)

Quote:
omg, yeah, that should be it. I expect it to look a bit samey even without the triangle - centering back to the resting position. Else, i think we'd be able to hear a click/pop.

The resting position is 0, all of the signals the 5B generates go from 0 to negative before the highpass. The centering test I was done by leaving the channel output held at 50% on after driving it up and down so the highpass doesn't need to shift the DC when it stops. There's a click either way but this particular test helped understand the effect of the highpass by suppressing it and seeing what its absence produces.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225188)
If this is really just a highpass filter followed by a soft-clipping amplifier ...

The time constants should be a function of the RCs present. Both for compression (which should be due the RC before the amplifier, (10kΩ//1kΩ)·C3 ) and for the DC offset return (C4·{the input impedance from the cart to whatever's recording})...
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225230)
Quote:
Also I feel like waveshaper is exclusively a term for a digital effect...

Funny, I immediately think of the various analog timbre manipulating effects available to synthesizer musicians. :D Reason being, analog waveshapers got popularized* for musical use in the Serge Tcherepnin synthesizer from 1973, and others followed suit, even if it has mostly been seen as a side dish, and most stage friendly synths just followed the simple VCO->VCF->VCA formula. Analog waveshapers in different configurations naturally have a renaissance in the new wave of modular synthesizers.

Here you can hear (and see) the waveshaping by that 1973 module in action.


*if that's the correct word, considering that apparently only 20 of the system sporting a three-stage waveshaper module was produced that year.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225233)
Analog waveshapers remained popular on electric guitar effect boxes.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225241)
FrankenGraphics wrote:
Funny, I immediately think of the various analog timbre manipulating effects available to synthesizer musicians. :D Reason being, analog waveshapers got popularized* for musical use in the Serge Tcherepnin synthesizer from 1973, and others followed suit, even if it has mostly been seen as a side dish, and most stage friendly synths just followed the simple VCO->VCF->VCA formula. Analog waveshapers in different configurations naturally have a renaissance in the new wave of modular synthesizers.

Here you can hear (and see) the waveshaping by that 1973 module in action.

Ah, that's interesting. Having an oscilloscope built in to see the shaping is a really cool touch.

I don't remember encountering the word waveshaper outside of DAW programs, or in e.g. DSP modelling of distortion. Didn't realize it had been in use earlier like that. (...and of course obvious that there are analog ways to do it; do guitar "rectifier" pedals count as a simple one?)
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225280)
Ohh sorry, that's not the module itself - only its waveform representation on an old phillips oscilloscope. I could've been more clear on that! I use something similar to that guy when testing my DIY projects 'cause i got one for free off a neighborhood garage cleanout. Lately, there have been specific oscilloscope modules for synths coming onto the market, but they're LCD based.

Here is a faithful replica description. https://www.cgs.synth.net/modules/cgs85_tws.html
If you filter out the components needed for supply and other practical measures*, the actual waveshaping is basic. Mostly, you have a bunch of diodes - most notably the diode between the + and - input of the OpAmp, and on the feedback loop you can see a diode helped by a cap in parallel to it, and regulated by a trimpot. I can see why this would be a popular guitar stompbox circuit.



Emulating this in the digital realm gets more complex since primarily, the digital resolution presents aliasing problems, and secondarily, the characteristics of the sound stem in part from the components not being ideal but having lots of little real-world quirks that comes "for free".

Quote:
do guitar "rectifier" pedals count as a simple one?

I suppose so! i mean, rectification is definitely shaping the wave in an equally literal way.

The reason why these wave shapers work so well in synths is because in direct connection to the tone generation block, you have a known, constant amplitude to match against before going to a mixer or amplitude shaper. You can of course put that waveshaper somewhere else in the chain in a modular synth which opens up other interesting, often equally controllable options, but this is one of the big benefits.


*For example, having separate ac/dc coupled outputs like you can see on the module makes little sense outside the world of modular. the dc coupled one is mostly a bonus feature for using the module to experimentally modify control voltages.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225303)
Yeah, it's interesting to consider as part of a modular analog synthesizer. I'd seen "shape" on a knob controlling a simple oscillator before (i.e. pulse width, or square to triangle, stuff like that), but not something more arbitrary than that.

I don't collect or use analog synthesizers though, I much prefer digital synthesizers. I've played with some in the past, but if I'm interested in them it's more of a historical thing than something I want to try and make music with.

Especially I hadn't considered a waveshaper being used directly on an oscillator, before envelope/filter/etc. I'm used to it as an effect that comes later on, typically for a distortion effect, but in that situation the timbral effect is very amplitude dependent. For making the base waveform, though, I wouldn't really have considered it. Changing the shape of a wave like that, it at least has a continuous sound, but in terms of being able to dial up what you want to hear, it seems pretty terrible? In a similar way that drawing a waveform freehand tends to create a lot of mediocre buzzes. The ideal waveform creation tool for me was an FFT of that, letting you draw the spectrum you want, rather than the actual wave shape. That's something that's easy in a software synthesizer, not so practical on an analogue one, though.

So I get it, and I can see how cool a tool it is for a modular synth, but it wasn't something I'd ever encountered in my more casual experience with analog synthesizers. The oscilloscope output adds some interesting visual appeal to the process too, which would be a good reason to use it in a performance context, or even just to look at for fun. ;) On the other hand, I'd seen the term waveshaping in lots of DAWs, primarily used for distortion (and multi-band waveshaping seemed to be a huge turning point for tube distortion simulation when it happened)... so that's the semantic association I always had for that word.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225315)
Yeah having a multi-stage waveshaper like this for timbral manipulation is sort of a bit like having several daisychained operators in fm synthesis. It takes a while to get oriented and it is easy to get lost in the woods again. And if you'd stack enough stages, you'll reach a slope of diminishing returns for all your fiddling.

A practical application of waveshaping like this in analog synths is automate a pretty narrow slide or from point a to b to animate the timbre over the course of some function/low frequency oscillation. Going full range of the units' capability is effectful when you're just sitting and having some fun with all the parameters, but it isn't very practical, musically.

Quote:
the ideal waveform creation tool for me was an FFT of that, letting you draw the spectrum you want, rather than the actual wave shape.

Yeah just drawing the time-amplitude function for each harmonic, like on the fairlight synthesizers (which i've never seen in real life and probably never will), seems like a very intuitive way to make nice, changing pads etc.

I haven't used DAW:s for synths in a while but probably should. When i quit, my computer back then was not near capable of complex forms of synthesis and emulated studio effects at the same time, unless i froze vst channels, so i just switched to modular at that point which was starting to become more affordable, especially if you're prepared to do some DIY stuff. Also, there's something to say about all the direct, tactile interface options (my favorite being pressure sensitive ribbons and plates) and the "start from scratch each time" method - not always helpful, but it forces me to get creative.

Another circuit that's mindbogglingly simple (hardware or software) - rather than having a sub-oscillator that you might spend time and effort on tracking perfectly, you can just pass the wave through a comparator (optionally) and then through a flip-flop and there you have it. If someone would want to add a perfectly working suboctave effect to a nes/fc cartridge, it could be had for under 50 cents. Well, you probably want to at least be able to gate it, control its volume, and/or as a third-option, envelope-follow the analog volume of the source channel.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225699)
So, I wrote a frequency sweep test that approximates a sine and quasi-logarithmically increases the frequency. The APU sines are assuming the DMC is linear (which it isn't quite), and the 5B sines are making do with the logarithmic steps (trying to mitigate by summing all 3 channels). Not ideal but maybe has enough SNR to be usable?

The graph here uses an FFT to find the dominant frequency for some window in the recording, and RMS to estimate its magnitude in that window. I'm sure there's some bias in this process, but again hoping it's good enough to be usable. (Anyone better versed in filter analysis techniques than me, feel free to give me advice on doing this better.)

There's also a 10 second noise burst (APU noise / 5B noise) for each of these tests, which have spectra that seem to match these curves pretty well (but harder to read through the noise), so that seemed to verify the validity of the analysis technique. I also tried modelling a best fit to the step responses for each of these but I had a hard time duplicating the curves, and abandoned the attempt.

The result:
Attachment:
sweep_5b.png
sweep_5b.png [ 82.36 KiB | Viewed 7801 times ]

  • 1. NES APU, just for comparison.
  • 2. Famicom APU. Note that for me this has a stronger highpass than the NES. Is this normal? Wiki: APU Mixer says "The Famicom hardware instead ONLY specifies a first-order high-pass filter at 8 Hz" which is... obviously not what I'm looking at here...?
  • 3. 5B sine through the 5B amplifier. I assume this would be unaffected by the Famicom's APU highpass?
  • 4. Famicom DMC sine through the 5B amplifier. I assume this is double dipping with its own highpass and the 5Bs on top?

Additionally, I tried to measured my recording device against a cheap signal generator I had, which seemed to show a 1-pole lowpass with a corner of ~7.1Hz. (Also a sharp lowpass up near the nyquist.) So, I presume that would colour these results a little. Edit: Kind of uncertain about this, its DC filter might be lower and sharper... need to do some more tests. I don't have very good tools for meauring my tools. ;)
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225700)
In a previous topic, I posted a ROM and source for sine sweep that is at least somewhat corrected for DMC DAC nonlinearity. Feel free to incorporate it.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225701)
tepples wrote:
In a previous topic, I posted a ROM and source for sine sweep that is at least somewhat corrected for DMC DAC nonlinearity. Feel free to incorporate it.

The reason I didn't correct for its nonlinearity is simply that I haven't measured its linearity curve yet (one of many things on my to-do list), and I'm not willing to assume that "blargg's formula" is accurate for this purpose. I could easily have put that formula into my program that generates the sine table, but I feel like that would mostly only accomplish a slightly better SNR in emulators that implement blargg's formula.

For the purposes of the test, as far as I can tell the difference isn't very significant (...but please correct me on that point if you know I'm wrong). Like I mentioned above, the independent measurement of the noise spectrum seems to match fairly well with the sweep analysis, so I feel some justification in making this assumption.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225703)
You're on fire, rainwarrior! I really wish I was in a position to contribute or at least make use of all this awesome data you're posting. :(
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225704)
rainwarrior wrote:
"The Famicom hardware instead ONLY specifies a first-order high-pass filter at 8 Hz"
I put that there, but in retrospect it's pretty misleading. What I meant was that the canonical schematic of the original Famicom – http://nesdev.com/Ntd_8bit.jpg – shows only the presence of a highpass filter with corner frequency at 8Hz. But the RF modulator changes that, and an AV Famicom is probably different too.

.... Also, somehow I did the math wrong. Evaluating 1/(R3//R4//R5 · C2 · 2π) works out to 37Hz, not 8Hz. I don't have any idea what I was thinking at the time.

Quote:
5B sine through the 5B amplifier. I assume this would be unaffected by the Famicom's APU highpass?
As far as I know, the only highpass is the one behind the inverter-as-amplifier, before it goes to the cartridge slot.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225719)
James-F recorded the APU part of the sweep test in both his Famicoms (one is modded, one is AV). Here's a plot of the results, interesting to compare. (Not sure how much is due to different recording devices, unfortunately.)

I can add more if anyone else wants to record it. (sweep_5b_nrom.nes, doesn't require a hotswap, and the first half of the test is APU only, about 90 seconds.)

Attachment:
sweep_famicom_3.png
sweep_famicom_3.png [ 90.12 KiB | Viewed 7759 times ]
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225726)
So I've been pushing around chains of 1-pole highpass filters trying to see if I can model those sweeps:
Attachment:
sweep_models_1.png
sweep_models_1.png [ 143.53 KiB | Viewed 7751 times ]


My NES and Famicom seem to fit pretty well with a single filter (16 and 32 Hz cutoffs respectively). In all of these there is an additional 3 Hz highpass assumed from my recording device (still not sure exactly what it's characteristics are, but this seemed to improve the fit of the NES/Famicom APU curves, and seems to be within a plausible range of the rough measurements I've managed to take so far).

The 5B curves are too sharp a knee to work with just one filter. I decided to model it as the internal 5B and the APU input each having their own filter before entering the amplifier, then finally an additional shared filter on the output of the amplifier. I'm not sure how much sense this makes, but maybe the amplifier in between justifies having two.

5B APU input: 12 Hz
5B internal: 20 Hz
5B output: 12 Hz

The internal curve here only matches until about 10 Hz. This might be the higher frequency noise due to the rough sine wave that's not being attenuated? Maybe I'll get a better idea of this bias once I implement this in NSFPlay and do the same analysis with my synthesized version. I think in all cases the signal should bias high from the model as it weakens but the noise on the APU's sine is a much lower magnitude. (Ignoring most of the lower left part of the graph.)

The APU passing through the 5B has the sharpest falloff of them all. Picking up the 32 Hz from the Famicom first, then a presumed 12 Hz cutoff on its input to the 5B, then the shared 12 Hz on its output... doesn't fit exactly, but I guess it's pretty close. This might be partly due to the amplifier nonlinearity; the 5B internal stuff is kept quiet enough to stay linear but the DMC here is a lot louder, might be causing distortion that's affecting the curve?

I was hoping the APU thru 5B and internal 5B could be modelled with the same filter (and the APU merely getting an additional filter from the Famicom) but I couldn't find a match that worked for both, which is why I've hypothesized the separate input filters... but it seems bizarre to me that they'd put an extra one on the APU like this.


Anyhow, next step is to model these in my emulator, then record and analyze this sweep test from the emulated version... that should give me some better idea of what's still missing.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225737)
rainwarrior wrote:
I was hoping the APU thru 5B and internal 5B could be modelled with the sample filter (and the APU merely getting an additional filter from the Famicom) but I couldn't find a match that worked for both, which is why I've hypothesized the separate input filters... but it seems bizarre to me that they'd put an extra one on the APU like this.
Every inverter-as-amplifier requires a highpass filter, because they need one to remove the DC offset to make sure the inverter's actually somewhere where it amplifies instead of rails.

As I said, there's the highpass filter before the one inside the Famicom (R3//R4//R5 · C5).

There's also an unknown lowpass inside the Famicom (output impedance of U7 · C8)
There's a highpass filter between the circuit that mixes 5B and APU audio on the cart and the amplifier (R1//R2 · C3)
There's a highpass filter after the amplifier (output impedance of amplifier · C4)

After that, it goes straight to the Famicom's RF modulator, but who knows what that does.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225751)
Started a thread for reading the PCB components: thread

rainwarrior wrote:
5B Gimmick! (bootgod)

C1: {R} / 85°C / M4413 / 6.3 v / 47 µF (top left)
C2: 103 (top right)
C3/C4: 85°C / (M) / 228 / 50 v / 1 (top middle, does not say µF after 1)

R1: 10 x 100 5% (right top, brown black orange gold)
R2: 10 x 1k 5% (right bottom, brown black red gold)
R3: 10 x 10k 5% (middle, brown black yellow gold)


...and lidnariq's first response:

lidnariq wrote:
(R1//R2 · C3) = 909Ω·1µF → 175Hz.
That's ... not right. Maybe the 5B has a significant output impedance which moves the corner frequency down.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225763)
Does this look correct to you? I was surprised that pins 2 (amplifier input) and 3 (amplifier output) are directly connected with a resistor like this. Feels like I'm missing a connection to ground somewhere in here... (seems to match this diagram)
Attachment:
5b_audio_diagram.png
5b_audio_diagram.png [ 29.28 KiB | Viewed 7587 times ]


My tracing:
Attachment:
5b_audio_tracing.png
5b_audio_tracing.png [ 2.55 MiB | Viewed 7597 times ]
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225767)
Yeah, that's the same thing I thought I saw when I traced the board six years ago. I mistakenly thought I'd already linked to that: I'm sorry that I didn't.

Inverters-as-amplifier often have a topology like that. The diagram I drew for the MMC5's amplifier is similar.


The external resistor on an inverter-as-amplifier:
Code:
      +---R---+   
      |  \    |
in ---+--|>O--+-- out
         /           
has the same function as with an op-amp:
Code:
 
      +---R---+
      |  \    |
in ---+--|-\  |   
         |  >-+-- out
    ~2V--|+/         
         /   
but is a lot fewer transistors inside.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225768)
Ah, that makes sense. Thanks.

I guess I had been thinking of the amplifier as a self contained thing, but really I shouldn't have. Ha ha.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225791)
Might as well be a simple inverting op-amp.
Pin 27 is the 5B chip output, while pin 45 is you standard famicom signal.
I would guess this cart is loud in comparison to others since the amplification factor is quite high if it is indeed a simple op-amp, but I have no idea.
From lidnariq's post I can see MMC5 mixes two additional channels with the famicom 2A03.

Image
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225803)
James-F wrote:
Might as well be a simple inverting op-amp.
Because you're throwing this into LTSpice, you really ought to actually build a CMOS or NMOS inverter rather than just using an op-amp.

Although I can neither find a depletion nMOSFET in their library nor can I figure out how to get it to accept a model statement declaring one...
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225842)
I tried out LTspice (figured it was a good excuse to learn). Though I probably don't have enough knowledge of circuit design to make very good use of it.

A question about using an inverter as an amplifier: to accomplish this, we need to bias the input to some middle voltage? Right? (2.5v?)

Would a voltage divider inside the 5B before the inverter input account for the highpass strength? For example if I put the input from pin 2 through the middle of a 10k / 10k divider, it seems to lower the cutoff from ~145Hz to ~30Hz. (I seemed to be measuring a 2-pole effect though, not sure how to account for that.)

Was looking at the inverter in the Famicom schematics too, does this achieve a bias by outputting the audio signal from the 2A03 already in an inverted state?
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225845)
rainwarrior wrote:
A question about using an inverter as an amplifier: to accomplish this, we need to bias the input to some middle voltage? Right? (2.5v?)

The magic is that the inverter self-bias. Yep, that's right: the output and the input converges itself to about ½ Vcc; the slight discrepancy is due to unequal gate strength, and makes the output slightly toward 0V (for CMOS, N-channel is "stronger" than a P-channel because the motility of electrons is about 3 times the motility of holes)
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225846)
rainwarrior wrote:
A question about using an inverter as an amplifier: to accomplish this, we need to bias the input to some middle voltage? Right? (2.5v?)
Yup, and that's most of what the external resistor is doing there. It means that if you take the Vin vs Vout curve in the inverter, and plot that on top of a transposed version of the same, it'll self-bias to where the line crosses its transposed version.

The same is true for the Famicom/NES's internal amplifiers, and even the one inside the Famicom's microphone.

Quote:
Would a voltage divider inside the 5B before the inverter input account for the highpass strength? For example if I put the input from pin 2 through the middle of a 10k / 10k divider, it seems to lower the cutoff from ~145Hz to ~30Hz.
I'd be a little surprised if that were the relevant topology.

My hunch, as I tried to say before, is that the functional mixing circuit is something like this:
Code:
  audio from 2A03 ------10k-----+
                                |
          ----------+           +-----1uF----...
         inside 5B  |           |
  ideal source--5k--|----1k-----+
                        |
          ----------+
Now, whether it's 5k? I can't know. But there's definitely something there to make it a less-than-ideal voltage source.

Jarhmander wrote:
Yep, that's right: the output and the input converges itself to about ½ Vcc
Only because of the external resistor to provide external negative feedback! Without that resistor, it'll just rail.

Quote:
N-channel is "stronger" than a P-channel because the motility of electrons is about 3 times the motility of holes [and therefore] makes the output slightly toward 0V
Uhhh.. sort of.

It's straightforward to design an inverter with any choice of properties you want. But that has nothing to do with CMOS vs NMOS, instead only with the properties (dimensions, doping levels, &c) of the transistors inside.

So while it's true that if you used the exact same dimensions of nMOSFET and pMOSFET, the self-bias voltage would be lower. But there's no reason that the IC designers will have chosen to make the two transistors the same size.

Furthermore, I know the MMC5 is NMOS. I suspect the 5B is also, but really don't know. The datasheet for the YM2149F says it's NMOS, but the YMZ284 datasheet says it's CMOS.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225847)
lidnariq wrote:
My hunch, as I tried to say before, is that the functional mixing circuit is something like this...

Ah, yes I can see in LTspice how that affects the cutoff in the same way.

Jahrmander wrote:
The magic is that the inverter self-bias. Yep, that's right: the output and the input converges itself to about ½ Vcc...
lidnariq wrote:
Yup, and that's most of what the external resistor is doing there. It means that if you take the Vin vs Vout curve in the inverter, and plot that on top of a transposed version of the same, it'll self-bias to where the line crosses its transposed version.

Ah, this is interesting. Thank you.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225850)
I'm sure I'm missing something important here, but I figured I might as well try this just to see what it LTspice says. This appears to shift the cutoff way down compared to the op-amp version?
Edit: same as below with the PMOS backwards, and the cutoff was like 1.5Hz but it was horribly broken in this configuration anyway.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225861)
Your pMOS transistor is reversed. Flip it vertically i.e. exchange the drain and the source.
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225876)
Thanks, now it's working better. Now it looks more like what I expected, and I can see the 2.5V bias and proper amplification now in transient mode which I could not before. (Wish I could figure out a way to quickly switch between the transient and ac analysis modes.)

After doing this, the new cutoff appears to be ~14 Hz, so it's lowered, but not quite as drastically as with the transistor backwards. :P (With the op amp version it was more like 175 Hz.) Equivalent to putting more resistance... somewhere...?
Attachment:
5b_sim2c.png
5b_sim2c.png [ 23.86 KiB | Viewed 8022 times ]


(Sorry if these are silly questions. I'm just playing around, seeing if I can learn anything at all here.)
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#225883)
Incidentally the 47µF capacitor (5V-GND) appears to fail a quick ohmmeter test (measures as a steady 500 ohms). Maybe I should consider replacing it.

I do have a crummy digital scope. I might try to measure their response later, just to try and verify that I'm not trying to replicate something that's in a broken state. (I've also asked someone else I know with a Gimmick cart to record my test, for similar verification.)
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#236299)
Looking more closely at my earlier test of LFO reset now that we finally have a proper patch set dump...

Apparently we can reset the tremolo LFO, but not the vibrato LFO. I had mistakenly assumed they would both work the same in that respect, and wasn't too careful about testing both. I've revised the lfo_vrc7 test ROM I made earlier to differentiate this.

Edit: a better method of resetting LFO was found! See this post. The VRC7 has a test register at $0F, and bit 1 of this register holds both LFOs at 0 (resetting and halting them). Toggling this bit does reset them!
Re: VRC7 and 5B amplifier investigation, also VRC7 LFO reset
by on (#236665)
I finally got around to replacing the capacitors on my Gimmick! board. Re-ran the previous tests, including the sweep test from before.

The results have only changed slightly, so that's probably a good sign that previous results were valid (i.e. I didn't need to replace the capacitors):
Attachment:
sweep_5b_recap.png
sweep_5b_recap.png [ 83.11 KiB | Viewed 5843 times ]


Still kinda sad that I broke one of the tabs on the cart shell while opening it. It will never close quite the same. :(