VRC7/YM2413/OPLL Custom Patches

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

Moderator: Moderators

User avatar
Ben Boldt
Posts: 1148
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: VRC7/YM2413/OPLL Custom Patches

Post by Ben Boldt »

This PDM stuff is pretty interesting but it is hard to wrap my head around the concept. From what I understand, when you put out 1-bit DAC pulses, if the DAC is high, it increases the resulting analog voltage, low it decreases, both at a defined rate, which differs from poor man's DAC because in that case you're charging/discharging a cap which does not have constant rates. Is this a correct statement or have I completely missed it?

So you can sit there at 50% duty cycle on your 1-bit DAC to hold a constant arbitrary position of the resulting analog signal, similar to the NES's DMC channel? Then the feedback comes back in to help maintain the DC offset of the signal? And now your effective bit depth of the resulting signal is a factor of how precisely you can time/dither the 1-bit DAC pulses?
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: VRC7/YM2413/OPLL Custom Patches

Post by tepples »

Correct. It's a lot like converting an image from 256 grays to 1-bit: you have to add some sort of noise so that the eye's low-pass filter can reconstruct some semblance of the original gray tones.
1. Original image
1. Original image
rockhill_bandw.png (65.47 KiB) Viewed 6984 times
2. Threshold: bitcrush to 1 bit
2. Threshold: bitcrush to 1 bit
rockhill_threshold.png (5.9 KiB) Viewed 6984 times
3. Bayer dithering: Adding a constant 2x2 pattern before conversion. Analogous to PWM.
3. Bayer dithering: Adding a constant 2x2 pattern before conversion. Analogous to PWM.
rockhill_bayer.png (4.42 KiB) Viewed 6984 times
4. Floyd-Steinberg dithering: mixing the "error" (difference between input and quantized levels) from neighboring pixels into the current pixel. Analogous to PDM or delta sigma.
4. Floyd-Steinberg dithering: mixing the "error" (difference between input and quantized levels) from neighboring pixels into the current pixel. Analogous to PDM or delta sigma.
rockhill_floyd.png (10.03 KiB) Viewed 6984 times
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: VRC7/YM2413/OPLL Custom Patches

Post by lidnariq »

Ben Boldt wrote: Sun Sep 20, 2020 11:41 am This PDM stuff is pretty interesting but it is hard to wrap my head around the concept. From what I understand, when you put out 1-bit DAC pulses, if the DAC is high, it increases the resulting analog voltage, low it decreases, both at a defined rate, which differs from poor man's DAC because in that case you're charging/discharging a cap which does not have constant rates. Is this a correct statement or have I completely missed it?
I think you're overthinking it? These are all fundamentally the same hardware, but with varying levels of cleverness about what digital signal you feed that hardware.

* The simplest to understand is conventional PWM, where you divide the time slot into X equal bits, and the first N slots of each time slot are high and the rest are low, and you can represent any digital value from 0 to X within each time slot. (e.g. high high low low = 50%)
* Only slightly more complicated is Bit Angle Modulation, where you divide the time slot into Y unequal bits, each one twice as long as the previous. (They don't have to be in order, either.) This saves on interrupt service time if you're doing your PWM in an interrupt.
* "conventional" PDM, you divide each time slot into X equal bits, but those N slots are uniformly distributed across the time slot. This means that instead of always having harmonics that are exactly multiples of the PWM period, different DAC values will have more higher-frequency components. (e.g. high low high low = also 50%)
* 1st-order delta sigma, where there's no longer a concept of "time slot": instead you have smooth filtered (ideally) audio at the output rate, and the output dithering continuously responds to the current sample.
So you can sit there at 50% duty cycle on your 1-bit DAC to hold a constant arbitrary position of the resulting analog signal, similar to the NES's DMC channel?
Yes. In fact, the NES's DMC channel is basically equivalent to a very low sample rate delta-sigma or PDM output stage, plus a digital lowpass filter.
Then the feedback comes back in to help maintain the DC offset of the signal?
Approximately? Have you read wikipedia's article? https://en.wikipedia.org/wiki/Pulse-density_modulation
And now your effective bit depth of the resulting signal is a factor of how precisely you can time/dither the 1-bit DAC pulses?
Yes.
User avatar
Ben Boldt
Posts: 1148
Joined: Tue Mar 22, 2016 8:27 pm
Location: Minnesota, USA

Re: VRC7/YM2413/OPLL Custom Patches

Post by Ben Boldt »

Thanks for your help explaining lidnariq. I was looking at the wikipedia article actually. As soon as I see a control loop diagram I know from experience not to trust that I have clue what I am looking at. (Or that the person who drew it did either in most cases, lol). The way you explain it makes a lot of sense to me.
naku
Posts: 3
Joined: Mon Nov 23, 2020 5:12 pm

Re: VRC7/YM2413/OPLL Custom Patches

Post by naku »

I'm making music in FamiStudio with the VRC7 audio expansion and would love to be able to edit my music in cartridge format. Is there a known way to create this type of cartridge without gutting old copies?
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: VRC7/YM2413/OPLL Custom Patches

Post by lidnariq »

VRC7 itself is unique to the cart. You can get YM2413s used and inexpensively, however, and they're kinda close. (2op FM sound is very itself)
naku
Posts: 3
Joined: Mon Nov 23, 2020 5:12 pm

Re: VRC7/YM2413/OPLL Custom Patches

Post by naku »

Yes! I know that YM2413 is an option but i read about VRC7 have a memory mapping circuit included in the same chip. Does you know how can i adap an YM2413 to the cartridge circuitry?
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: VRC7/YM2413/OPLL Custom Patches

Post by lidnariq »

What else is on the PCB that you're adding the YM2413 to?
User avatar
Quietust
Posts: 1918
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: VRC7/YM2413/OPLL Custom Patches

Post by Quietust »

naku wrote: Mon Nov 23, 2020 5:27 pm I'm making music in FamiStudio with the VRC7 audio expansion and would love to be able to edit my music in cartridge format. Is there a known way to create this type of cartridge without gutting old copies?
naku wrote: Tue Nov 24, 2020 7:07 am Yes! I know that YM2413 is an option but i read about VRC7 have a memory mapping circuit included in the same chip. Does you know how can i adap an YM2413 to the cartridge circuitry?
Implementing the rest of the VRC7's functionality could probably be done with an FPGA or CPLD, or maybe even a bunch of individual chips if the cartridge is big enough. Exactly how you implement it is up to you - the mapper documentation on the wiki should contain enough details to get it working.

However, if you want to play VRC7 music, then how are you going to deal with all of the builtin instruments being different (unless you're going to use the "custom" instrument for everything)?
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
naku
Posts: 3
Joined: Mon Nov 23, 2020 5:12 pm

Re: VRC7/YM2413/OPLL Custom Patches

Post by naku »

Yes! I was wondering if someone have the implementation in FPGA or CPLD of a VRC7 working because I know that here I have all the technical data but I'm a musician that knows very little about electronics and I would love to have my work on a real cartridge. I can release it on a rom file but a real cart would be great.
Post Reply