Page 1 of 1

Play voices on the SNES using frequency modulation.

Posted: Tue Oct 02, 2007 12:56 pm
by Bregalad
I trought of a way to play voices or relatively long steamed samples on the SNES by using the hardware frequency modulation as a way to save space. Instead of playing long steamed samples with horrible quality due to low frequency and interpolling, a simpler wave would just be "steamed" to give information to the next channel, who would be a frequency-moduled sinus (or some other waveform) that would be moduled from the first signal, and trus ouput the actual voice/sound effect, with a loss of quality due to the limits of the modulation instead of the limit of the pitch/memory space.
I did some testing using Goldwave, and I sucessfully found a formula that can take a wave, "frequency differenciate it" (that's how I called this process, which is the opposite of frequency modulation), and then frequency modulate it back to original. If the modulation factor is too low, there is loss of quality (that would be the case on the SNES), as well if the original wave is filtered (that would also be the case on the SNES), but the final result is still largely reconisable.
If the formula to get the wave back from pitch modulation is : sin(2*pi*f*t+y*w) (where f is the modulation frequencey, t time in second, y the modulation factor and w the modulating source), then the formula to get the modulating wave looks like this : w = (arcsin(wave_source)-(2*pi*(f*t)-int(f*t)-0.5)/y
(Same variables as above, exept wave_source is the original wave you want to "frequency derivate" to another one. (Both modulation source and original waves oscillates from -1 to 1). The (f*t)-int(f*t)-0.5 are here to keep the second term always between -pi and pi.

As this works very fine in theory I doubt if the results would be any usefull in the case of the SNES or not.

Posted: Tue Oct 02, 2007 5:12 pm
by blargg
It seems likely that the modulation information would take a similar amount of space as the original sample data. At first I thought you were going to suggest in your post to frequency-modulate a normal sample, effectively resulting in a variable sampling rate. That would be interesting because it could lower the rate for parts of the sample lacking high frequency information.

Posted: Mon Oct 08, 2007 10:10 am
by Bregalad
What you say is interesting, as what I descibe above is definitely not much doable : The less imprecision in frequency parameters will output horribly glitchy sound and that's not what we want.

Posted: Mon Oct 08, 2007 12:59 pm
by tepples
Non-trivial sounds have more than one frequency going at once. If representing each sound as a sequence of instantaneous frequencies over short time windows were such a plausible idea, then might it have replaced MP3 by now?

Posted: Tue Oct 09, 2007 10:03 am
by Bregalad
That's what the fournier transform does, while voice may take only 2 to 3 fundamentals at the same time, this would never do it for actual music (that most people uses MP3 format for). (Btw when I tell people I have over 2k songs on my PC and that they takes about 300MB alltogether they don't trust me because they only use MP3s hehe).
However, in the goal to only approximate voices with terrible quality (but really good storage size) it would be good to use a combination of hardware and software pitch modulation or something. The software would give the main pitch and change between sounds, and the hardware would use one voice to play a silent wave, that would distord the second wave using p.mod and trus sound like voice.

Posted: Tue Oct 09, 2007 12:12 pm
by tepples
If it were so good even for voice, wouldn't digital cell phones use FM over the air? Instead, GSM and UMTS phones use a technique called code-excited linear prediction.

Posted: Thu Oct 11, 2007 9:49 am
by Bregalad
Well... what you say make some sense, but the SNES only decode BRR audio, and any other form of compression would be only possible to decompress in 4-bit resolution (using only filter 0), which somewhat suck, unless of yourse you do a SPC based BRR encoder.

Imagine a programm that would encode samples to be replayed by itself in function of normal (or compressed differently) sound data given by the main CPU...

Posted: Thu Oct 11, 2007 12:56 pm
by tepples
Does Super Game Boy encode audio to BRR?

Posted: Thu Oct 11, 2007 8:17 pm
by ccovell
tepples wrote:Does Super Game Boy encode audio to BRR?
Once again, no, no, no. The SNES' cartridge connector has 2 pins for passing through audio.

Posted: Fri Oct 12, 2007 11:16 am
by tepples
If the Super Famicom and Super NES have Famicom style audio pins, couldn't someone build a Famicom style sound chip like in the Japanese version of Bases Loaded?

Posted: Fri Oct 12, 2007 12:49 pm
by Bregalad
Yes, but you have to come up with something more effective than the SPC700 itself who was very effective for its time. Maybe Star Ocean could have used something for it's voices, but they already used a chip to compress graphics, and they already invented a techique to replay back voices in Tales of Phantasia (by pasting small samples of voice together in real-time).