FM synth BRR sample generator

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: FM synth BRR sample generator

Post by Bregalad »

rainwarrior wrote:Unless you can modulate frequency in a perfectly symmetrical way, [...] You'll have a constantly shifting timbre, lots of strange sidebands.
So that's what we get with SPC700's hardware pitch modulation, and Famocom Disk System's adapter's frequency modulation, right?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: FM synth BRR sample generator

Post by lidnariq »

KFF made a demo of using the SPC700's pitch modulation for FM-ish sound...
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: FM synth BRR sample generator

Post by rainwarrior »

Bregalad wrote:
rainwarrior wrote:Unless you can modulate frequency in a perfectly symmetrical way, [...] You'll have a constantly shifting timbre, lots of strange sidebands.
So that's what we get with SPC700's hardware pitch modulation, and Famocom Disk System's adapter's frequency modulation, right?
Yeah, though maybe the resulting sound is acceptable anyway. If your goal is just to make music, maybe you'll find the constantly sliding phase okay.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: FM synth BRR sample generator

Post by Bregalad »

rainwarrior wrote: Yeah, though maybe the resulting sound is acceptable anyway. If your goal is just to make music, maybe you'll find the constantly sliding phase okay.
Well, obviously, the goal is to make music (or sound effects).

I don't even have an idea of what you're refering to by saying "constantly sliding phase".
User avatar
TmEE
Posts: 960
Joined: Wed Feb 13, 2008 9:10 am
Location: Norway (50 and 60Hz compatible :P)
Contact:

Re: FM synth BRR sample generator

Post by TmEE »

Sound will be constantly changing in timbre, which can be really good.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: FM synth BRR sample generator

Post by rainwarrior »

I mean that if you have a steady tone, the modulator and carrier should have exactly the same wavelength, and stay locked together with the same phase. The waveform should be repeating and identical each time.

With frequency modulation, basically there is always going to be some error. It might spend a little more time at a higher frequency and little less time at a lower frequency, and by the end of a waveform it slips a little bit past its starting position. The carrier slowly shifts out of phase with the modulator, giving a slowly changing timbre as the waveform changes. You can't have a repeating identical waveform this way, it is always changing.

The sound is similar to slowly changing the duty on C64, or playing two slightly detuned waves, ZX beeper phaser, that kind of thing.

The main problem is the speed of phasing is going to be different for every note. You can't really control it, it's limited by the accuracy of your hardware. (On FDS it's really bad, but on these SNES examples it seems much slower, less of a consistency problem.)

With a "phase modulation" implementation instead, you never actually change the frequency of the modulator, the carrier's output is just added to its phase when you do the lookup. They'll always stay locked together perfectly.
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: FM synth BRR sample generator

Post by psycopathicteen »

For the pitch modulation, does anyone know what amplitudes correspond with what frequencies?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: FM synth BRR sample generator

Post by lidnariq »

Nocash's fullsnes has the following comment:
FullSNES wrote: The pitch counter is adjusted at 32000Hz rate as follows:
Step = VxPitch ;range 0..3FFFh (0..128 kHz)
IF PMON.Bit(x)=1 AND (x>0) ;pitch modulation enable
 Factor = VxOUTX(x-1) ;range -4000h..+3FFFh (prev voice amplitude)
 Factor = (Factor SAR 4)+400h ;range +000h..+7FFh (factor = 0.00 .. 1.99)
 Step = (Step * Factor) SAR 10 ;range 0..7FEEh (0..256 kHz)
XXX somewhere here, STEP (or the COUNTER-RESULT) is cropped to 128kHz max) XX?
Counter = Counter + Step ;range 0..FFFFh, carry=next BRR block
So the raw signed 15-bit voice magnitude (post BRR decompression and Gain) of the previous channel becomes a linear (not exponential/note name) frequency multiplier from 0x to almost 2x relative to the frequency programmed for the current channel
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: FM synth BRR sample generator

Post by psycopathicteen »

Okay, I guess I found the reason why when I tried pitch modulation before I didn't hear much of a difference. The sample I used for the modulator wasn't loud enough.

That begs the question, if I use a modulator that is always raised, can I bypass the frequency limit?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: FM synth BRR sample generator

Post by lidnariq »

You mean, to produce more aliasing? Certainly fullsnes says you can, to get sample rates up to 256kHz (that are then decimated down to 32kHz as normal)


<pedant>"begs the question" means "assumes the answer", not "requires asking"</pedant>
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: FM synth BRR sample generator

Post by Bregalad »

rainwarrior wrote: With frequency modulation, basically there is always going to be some error.
Excuse me, but I do not see why there would always be going to be some error. I am not saying you're wrong - perhaps you are right, however I do not see why it'd be so obvious.

I understand the phase of the modulator can be random relative to the phase of the modulatee (is that how we say it ?), because of random things happening after a "key on" event on both channels. Even that might not happen if the "key on" event is simultaneous, but let's happen the phases align randomly.

Once the note is sustained I see no reason there should be a phase shift or anything. If the frequency of a channel is a direct multiple of the frequency of the other (no matter which is which), then I see no reason the synchronization wouldn't last forever. If you just use the same note one octave down for instance, there might be a problem due to the low frequency bit being lost. On the countrary, if you use the lowest value and discard the unnecessary bits for the highest value, the sync should be perfect.
It might spend a little more time at a higher frequency and little less time at a lower frequency, and by the end of a waveform it slips a little bit past its starting position. The carrier slowly shifts out of phase with the modulator, giving a slowly changing timbre as the waveform changes. You can't have a repeating identical waveform this way, it is always changing.
Again, I do not understand your logic. You just claim "you can't", as if this was absolutely obvious, but to me it's not.
(On FDS it's really bad, but on these SNES examples it seems much slower, less of a consistency problem.)
On what basis do you make this claim ? Please show demos attempting to do that and explain what the problem is. The previously mentioned demo by KungFuKirby is actually very impressive and generate sounds close to what the Genesis can do on the SNES.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: FM synth BRR sample generator

Post by rainwarrior »

Okay, since you do seem interested, I will try to explain with more detail:


When the frequency of an oscillator stays constant, its wavelength stays constant.

With phase modulation synthesis, both carrier and modulator stay at the same frequency always. Their wavelengths always match, they always stay synchronized.

With frequency modulation, the frequency of the modulator is constant, but the frequency of the carrier is always changing. The wavelength of the carrier is much more complicated in this case, it is an integral related to the changing frequency over time.

So, with a perfect sine wave modulator, the "ideal" mathematical version, the wavelength of the carrier adds back up to where it started; there's equal time spent in lower frequency and higher frequency and it balances out.

With an integer approximation of a sine wave modulator, they only approximately balance. It's similar to how Euler integration step by step of a physical trajectory will have an error compared to the ideal continuous integral.

What happens when the wavelength of the modulator does not match the wavelength of the carrier? Its phase shifts a little bit each wavelength. How much it shifts depends on how much error. The amount of error is a bit chaotic with these kinds of systems, which is what I mean when I say every different note is going to have a different speed of phase shifting.

Anyhow, if the phase shifts, the timbre of the sound changes. If the phase is shifting slowly, you get a slowly changing sound. If it shifts quickly, you get a quickly changing sound.

There do exist ways to make integer approximations where the errors will balance (and even systems that don't tend to have a few "lucky" notes that are stable), but it requires careful design with this in mind. You're not likely going to get something that does that in the SNES or FDS.

Does this explain what the problem is and how it occurs?

Bregalad wrote:
rainwarrior wrote:(On FDS it's really bad, but on these SNES examples it seems much slower, less of a consistency problem.)
On what basis do you make this claim ? Please show demos attempting to do that and explain what the problem is. The previously mentioned demo by KungFuKirby is actually very impressive and generate sounds close to what the Genesis can do on the SNES.
It was quite a long time ago that I did test of this with the FDS and I did not document them. Sorry. You can easily operate the FDS modulator with Famitracker, but you'd need to use a real FDS to get an accurate test.

RushJet1 tried making music this way. His goal wasn't to make perfect FM synthesis, it was just to use high frequency modulators to make interesting sounds, and he did make some music with it. He was dissatisfied with how different it sounded on FDS and Famitracker though, so I think he kind of gave up.

In the demo by KungFuFurby you can hear the phasing problem constantly. You can also here it in psycopathicteen's demos in this thread. I alerady commented on this (i.e. the phasing is slower, i think cause SNES has a lot more precision for the modulator).

Whether the phasing is objectionable, musically, is a matter of taste. I was just trying to point out that it's an inherent an uncontrollable part of the sound when you do this on such a system.
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

Re: FM synth BRR sample generator

Post by psycopathicteen »

You can also here it in psycopathicteen's demos in this thread.
I didn't use the hardware pitch modulation. The timbre changing was done intentionally to show off it can change timbres while playing a sound, even though it doesn't exactly fit with the beat of the song.
User avatar
TOUKO
Posts: 306
Joined: Mon Mar 30, 2015 10:14 am
Location: FRANCE

Re: FM synth BRR sample generator

Post by TOUKO »

lidnariq wrote:KFF made a demo of using the SPC700's pitch modulation for FM-ish sound...
Wahoo, terrific sound,but does it run on a real snes, or needs an hacked emulator ??
Post Reply