Now you're playing with gauss!

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Now you're playing with gauss!
by on (#147158)
I finally got around to adding the 4-point Gaussian filter to my FPGA SPC player. It’s unbelievable what a difference it makes! At the cost of removing quite a bit of treble it really does a great job of dithering/smoothing and removing all the aliasing.

FYI, these are only 1 channel out of 8 (I only have a single channel implemented right now). I have provided links to the “without gauss” and the “with gauss” versions.

Without: https://dl.dropboxusercontent.com/u/362 ... 01_ch6.mp3
With: https://dl.dropboxusercontent.com/u/362 ... 01_ch6.mp3

Without: https://dl.dropboxusercontent.com/u/362 ... 07_ch6.mp3
With: https://dl.dropboxusercontent.com/u/362 ... 07_ch6.mp3

Without: https://dl.dropboxusercontent.com/u/362 ... 16_ch6.mp3
With: https://dl.dropboxusercontent.com/u/362 ... 16_ch6.mp3

Without: https://dl.dropboxusercontent.com/u/362 ... 01_ch6.mp3
With: https://dl.dropboxusercontent.com/u/362 ... 01_ch6.mp3
Re: Now you're playing with gauss!
by on (#147159)
The "yoshi" sound effect is the only one with a big difference.
Re: Now you're playing with gauss!
by on (#147160)
All of them are pretty prominently different.

I wish I had some sort of VST plugin or tracker that could do SNES filtering.
Re: Now you're playing with gauss!
by on (#147256)
That's one of those features I would love to be able to turn off on the real SNES, it hurts the sound so bad in most cases. The SFX is the only one in the examples that I would say got improved, rest sound incredibly muffled with the interpolation added.
Re: Now you're playing with gauss!
by on (#147259)
The official SDK (I think) mentioned that you have to boost the treble of your samples before you encode them, if you were going to use the gaussian filter.
Re: Now you're playing with gauss!
by on (#147266)
To me only the 3rd one without filter sounds more punchy (and better), but only because I like fuzzy bass.

The bass on the SNES was amazing, when I was a kid I had it connected to a Zenith "console television". Playing RPM racing, its sound effects literally rattled the windows. "The fat man" George Sanger was the first game musician I was totally impressed by. (Then later of course Koji Kondo).
Re: Now you're playing with gauss!
by on (#147641)
I now have all 8 channels working! But still no mixing. I also still don't have echo or pitch modulation either. Here are some 1-minute clips of each channel if you're interested.

Donkey Kong Country 2 - Forest Interlude
https://dl.dropboxusercontent.com/u/362 ... 10_ch0.mp3
https://dl.dropboxusercontent.com/u/362 ... 10_ch1.mp3
https://dl.dropboxusercontent.com/u/362 ... 10_ch2.mp3
https://dl.dropboxusercontent.com/u/362 ... 10_ch3.mp3
https://dl.dropboxusercontent.com/u/362 ... 10_ch4.mp3
https://dl.dropboxusercontent.com/u/362 ... 10_ch5.mp3
https://dl.dropboxusercontent.com/u/362 ... 10_ch6.mp3
https://dl.dropboxusercontent.com/u/362 ... 10_ch7.mp3

Mega Man X - Zero
https://dl.dropboxusercontent.com/u/362 ... 07_ch0.mp3
https://dl.dropboxusercontent.com/u/362 ... 07_ch1.mp3
https://dl.dropboxusercontent.com/u/362 ... 07_ch2.mp3
https://dl.dropboxusercontent.com/u/362 ... 07_ch3.mp3
https://dl.dropboxusercontent.com/u/362 ... 07_ch4.mp3
https://dl.dropboxusercontent.com/u/362 ... 07_ch5.mp3
https://dl.dropboxusercontent.com/u/362 ... 07_ch6.mp3
https://dl.dropboxusercontent.com/u/362 ... 07_ch7.mp3
Re: Now you're playing with gauss!
by on (#147644)
Forest Interlude takes up all 8 sound charnels? Do certain sound channels just stop playing the song to allow sound effects? I don't think I've ever realized that. It certainty isn't as obvious as it is on the NES. I would have though that they would have reserved 2 sound channels for sound effects.
Re: Now you're playing with gauss!
by on (#147648)
Espozo wrote:
I would have though that they would have reserved 2 sound channels for sound effects.

That's often how it's done (Vortex and Rock 'n' Roll Racing, for instance, use 6 channels for music, and F-Zero and Kirby's Dream Land 3 seem to use 5), but try actually playing one of the ship hold levels in DKC2 - just about everything you do cuts out a channel from the music. They went all-out for the DKC games; all three of them use all 8 channels...
Re: Now you're playing with gauss!
by on (#147649)
That's correct, one (or more) of the channels will cut out in order to play one (or more) sound effects if the music is using all 8 channels. _But_ you'll notice that in most (all?) songs that use all 8 channels they will have 2-3 channels playing the exact same audio data just at a slightly different pitch and/or just slightly out of phase with each other. That way when the sound affect is played they use one of the "replicant" channels and it's virtually imperceptible to the player - especially when you're focused on other things...like playing the game. :)

In the samples I posted, notice how channels 0 & 1 are nearly identical in the DKC track. Same goes for channels 0 , 1 & 7 in the MMX track. There are more too.

But keep in mind though that having multiple channels playing the same track is not wasted, the music really does sound a lot better with those extra channels playing the same data at a slightly different pitch/phase. Try playing them in an SPC player that allows you to mute individual channels (e.g. audio overload) and you'll see what I mean.
Re: Now you're playing with gauss!
by on (#147653)
One trick you can do on any sampler if you're channel-constrained (as opposed to memory-constrained) is to use polyphonic chord samples. Octave, perfect fifth, and perfect fourth samples will give two for the price of one. You hear this often in Amiga MODs, which were originally limited to four channels (until OctaMED came out with software mixing). This trick even works with FM on the Sega Genesis if you build an instrument out of the dual 2-op algorithm.
Re: Now you're playing with gauss!
by on (#147658)
Very interesting info. Thanks for sharing!
Re: Now you're playing with gauss!
by on (#147750)
Finally got all 8 channels mixing!! Check it out!

https://dl.dropboxusercontent.com/u/362 ... irm-07.mp3
https://dl.dropboxusercontent.com/u/362 ... dkq-10.mp3
https://dl.dropboxusercontent.com/u/362 ... _ki-01.mp3
https://dl.dropboxusercontent.com/u/362 ... mmx-07.mp3
https://dl.dropboxusercontent.com/u/362 ... mmx-16.mp3
Re: Now you're playing with gauss!
by on (#147821)
How do "Chillin' on the Corner" (Zoop #3) and "Friend Like Me (The Genie's Lamp)" (Aladdin #16) sound?

Similar?
Re: Now you're playing with gauss!
by on (#147843)
Sorry about that tepples. I didn't get an email saying that anyone had replied. I've been on this site for many years now and I swear that sometimes I don't get emails when someone replies to a thread that I'm subscribed to. It's very rare, but I'm 99% certain that it does happen. The emails certainly aren't going to my spam folder or anything.

In any case, here are the recordings you requested. And a few more just for fun. :)

https://dl.dropboxusercontent.com/u/362 ... ala-16.mp3
https://dl.dropboxusercontent.com/u/362 ... ct-304.mp3
https://dl.dropboxusercontent.com/u/362 ... ct-317.mp3
https://dl.dropboxusercontent.com/u/362 ... dkc-07.mp3
https://dl.dropboxusercontent.com/u/362 ... ff4-01.mp3
https://dl.dropboxusercontent.com/u/362 ... oop-03.mp3

Still need to add echo, noise, pitch modulation, 8-tap FIR, and probably some other things I'm forgetting right now.
Re: Now you're playing with gauss!
by on (#147844)
Zoop sounds glitched, like the melody is dropping notes. I know the sound engine in Zoop is a really crazy MIDI-style round-robin allocator, so that means the channels are allocated and initialized as notes are needed, meaning each channel is frequently switching samples and envelopes and properties, versus other engines that have channels organized by instrument or sequence.
Re: Now you're playing with gauss!
by on (#147847)
Okay, so I _definitely_ did not get an email notification for Drag's post. Wtf? I unsubscribed and re-subscribed to this thread. Maybe that will help...

Drag wrote:
Zoop sounds glitched
If it actually is then it's most likely due to one of the features I'm missing. Either way, Blargg's SPC emulator output wave file for the same SPC sounds identical to mine (I've modified his emulator to have the same missing features as mine). In either case if it is glitchy it'll all be fixed in the near future.

Drag wrote:
I know the sound engine in Zoop is a really crazy MIDI-style round-robin allocator
This is almost certainly irrelevant as far as the hardware is concerned. The hardware doesn't become more/less complicated just because some developer made the SPC-700 software driver "really crazy". The hardware is always the same regardless of the sound engine driving it. The sound engine could be trying to determine if P=NP for all I care. ;)
Re: Now you're playing with gauss!
by on (#147849)
jwdonal wrote:
Okay, so I _definitely_ did not get an email notification for Drag's post. Wtf? I unsubscribed and re-subscribed to this thread. Maybe that will help...
(off topic) I stopped getting email notifications of PM arrivals about 30 hours ago (last one that arrived was at 19h29 EDT). And I know I'm not running any kind of filtering at all.
Re: Now you're playing with gauss!
by on (#147854)
Try these SPC sets on for size (I consider these a real challenge):
- Clay Fighter 2 - Judgement Clay
- Mickey's Playtown Adventure - A Day of Discovery!
- We're Back! A Dinosaur's Story
- Shin Togenkyo
Re: Now you're playing with gauss!
by on (#147862)
Sure. I'd be happy to make some recordings. But I don't have time to record all the tracks from all of those sets. (At least not until I get some automation set up.) If you want to suggest 1 particular track from each set I can do that.

And I definitely appreciate suggestions for "challenging" SPCs! Any other suggestions are welcome.
Re: Now you're playing with gauss!
by on (#147863)
Here's my selection for each one...

Clay Fighter 2 ~ Main Menu

Mickeys Playtown Adventure ~ Title Screen

Shin Togenkyo ~ Main Menu

We're Back! A Dinosaur's Story ~ Title Screen
Re: Now you're playing with gauss!
by on (#147866)
If Zoop dropping notes is caused by a missing feature, let me know which feature it is since I have no idea what would cause it. Claymates has a similar round-robin allocator for its music engine, so if that's dropping notes too then it's the same glitch.

I only mention it because round-robin allocators are quite different from what most SNES soundtracks use. For instance, if you solo a channel in SMW, you get a single instrument playing a single sequence. If you solo a channel from Zoop or Claymates, you get a bunch of random notes from all instruments.
Re: Now you're playing with gauss!
by on (#147872)
Drag wrote:
Zoop sounds glitched, like the melody is dropping notes. I know the sound engine in Zoop is a really crazy MIDI-style round-robin allocator

Aladdin is glitched as well, but it's always the bass because Aladdin doesn't use round-robin allocation. Your mixer might be missing a channel. Try finding which channel Aladdin plays the bass on, then mute that channel in Zoop and see if it produces the same pattern of missing notes.

The comparison to Claymates is apt because one of the unused samples buried in Zoop sings "Clay Fighter". (This sample isn't even used in the hidden track in Zoop that sounds vaguely like "Blister in the Sun".) This leads me to believe it uses an engine similar to Interplay's ARDI (Advanced Realtime Dynamic Interplay) engine, and a Nintendo Power story heavily implied that ARDI is MIDI-based. (The article might have used the name ARDISS for ARDI Sound System.) So did an article in SNES Force.
Re: Now you're playing with gauss!
by on (#147884)
Welp, attempting to play KungFuFurby's track selections was...umm...far less than what one would call "successful". LOL. Each of the tracks (except for Togenkyo) played for a few seconds each and then died a very horrible death. Togenkyo didn't even play a single note. :) Haha.

Ironically, I am incredibly excited about this! It's fantastic to have these difficult tracks available to test with. I will keep working on my player and adding the rest of the features and squashing more bugs and will keep trying these (and Aladdin and Zoop) until they work flawlessly.

I love this community. Thanks all!
Re: Now you're playing with gauss!
by on (#147894)
You've run into the same killer that SNESAmp ran into. Shin Togenkyo is especially noteworthy for me, because it also failed in some of my more current SPC players (an older version of Audio Overload was successful in playing this song), although it usually fails after a few seconds rather than right off the bat (or after a single note). I didn't expect Shin Togenkyo to fail so horribly, though.

My instincts are as following...

- ENDX may be used for individual samples. Failure to emulate this might be what is causing channel allocation to fail on the Visual Concept games. Plus, these might not even keyed off, meaning allocation is really dependent on those samples stopping.

- For Shin Togenkyo, make sure you're emulating both memory wraparound and register wraparound correctly. Memory should be 16 bits, not 32+ bits (and thus should wrap around to zero rather than overflow), and registers should be 8 bits (and thus should also wrap around). There may also be an opcode that you failed to implement (almost all opcodes don't outright crash the SPC700... unless it's SLEEP or HALT).
Re: Now you're playing with gauss!
by on (#147915)
Ok, so I spent all of 5 seconds looking at the CPU execution debug output of the Togenkyo track (before I had to run to work) and found something very strange... (Again, I haven't delved into this yet, this is just my cursory 5 second assessment of this one track.)

The thing I noticed is that the SPC file's restore state value for the SPC-700's stack pointer register is 0x00. And almost immediately after starting execution the code executes the CALL instruction which pushes the high and low program counters to the stack. So the reason that it didn't play a single note on my emulator was because the program is pushing to a full stack which causes my emulator to report and error message and lock up permanently (by design).

Any thoughts on this?

Also, thank you for your thoughts on what you think the issues were with these tracks I'm sure they will be very helpful in my debugging efforts.
Re: Now you're playing with gauss!
by on (#147916)
SPC700 is largely a 65C02 clone. Does it work if you let the stack pointer wrap around from $00 to $FF, as it does on the 65C02?
Re: Now you're playing with gauss!
by on (#147918)
I will definitely test that out once I get home.

But...am I wrong or isn't the more important question why the program is pushing to a full stack in the first place? That would seem like either a coding error or possibly a dumping error (i.e. incorrect restore state)? I'm just throwing out ideas.
Re: Now you're playing with gauss!
by on (#147921)
The stack on a 6502 processor is empty descending, meaning a push decrements the stack pointer ("descending") and the stack pointer points to the first address past the valid data ("empty"). Apparently the stack pointer on the SPC700 behaves the same way as that of the 6502. If the SPC700 stack were full descending instead of empty descending, $00 would mean an empty stack.

Perhaps it was just sloppy programming by someone who came from a platform with a full descending stack, in which the stack pointer is decremented before the pushed value is written. Both major 8080 descendant families, including Z80 and x86, use a full descending stack. The vaguely x86-like Sony syntax used by "standard" SPC700 assembly language might have helped with this confusion, which I guess is part of why I prefer 65C02 syntax. ARM also uses a full descending stack, where PUSH is a synonym for STMDB (STore Multiple, Decrease Before) or STMFD (STore Multiple to Full Descending stack), and POP is a synonym for LDMIA (LoaD Multiple, Increase After) or LDMFD (LoaD Multiple from Full Descending stack). This is merely by convention in ARM, but Thumb is hardwired to full descending.
Re: Now you're playing with gauss!
by on (#147928)
Native SPC700 syntax is Z80-like to my eyes, actually.

The IPL boot routine by default initializes the stack pointer to $EF. I also think the stack pointer should have wraparound implemented.
Re: Now you're playing with gauss!
by on (#147931)
KungFuFurby wrote:
The IPL boot routine by default initializes the stack pointer to $EF.
That's true, but the IPL is never executed if you're restoring the state from an SPC file. So the stack pointer is just going to start off from whatever value is provided in the SPC file (in this case 0x00). The IPL is only used/needed when running the S-SMP in a full SNES emulator configuration so that the game can upload the audio program and sound data to the APU's memory.

On a related note, I have no idea how this SPC dumping stuff works, but out of curiosity does the person dumping the SPC decide the stack pointer state arbitrarily sometimes? Or is the SP value the actual value that the SP register had when it started playing the actual track in game? Maybe my questions don't even make any sense, like I said, I don't know how the whole dumping process works.
Re: Now you're playing with gauss!
by on (#147943)
Quote:
Or is the SP value the actual value that the SP register had when it started playing the actual track in game?

In an emulator, a save state must capture the state of all CPUs, including their registers and their memory. A .spc file is literally just an SPC700 save state combined with composition metadata. So yes, the .spc file contains the SP value that was in use when the .spc was saved.
Re: Now you're playing with gauss!
by on (#147977)
Well, allowing a push to a full stack without locking up didn't help much. Only a few notes came out just like the others. Looks like I've got some debugging to do. :)
Re: Now you're playing with gauss!
by on (#148323)
tepples wrote:
Aladdin is glitched as well
Does this sound better? https://dl.dropboxusercontent.com/u/362 ... a_test.mp3

Drag wrote:
Zoop sounds glitched
Using the 5 samples below for comparison can you point out to me from these samples exactly what you think sounds "glitched" or incorrect? If you could use timestamps that would be great.
- Audio Overload SPC Player
- Blargg's SPC Emulator
- BSNES (Accuracy Mode)
- My Emulator
- Youtube (Unknown Emulator)
Re: Now you're playing with gauss!
by on (#148327)
Aladdin sounds correct now. (Compare YouTube.)

Zoop: The first thing I can pick out is that "My Emulator" is missing three xylophone notes at 0:02. Audio Overload, Blargg, bsnes, and YouTube play all notes.
Re: Now you're playing with gauss!
by on (#148328)
tepples wrote:
Aladdin sounds correct now. (Compare YouTube.)
Okay, so the problem with Aladdin was that I simply didn't have the echo feature implemented in the previous recording. The only thing changed in this version was that I added the echo feature.

tepples wrote:
Zoop: The first thing I can pick out is that "My Emulator" is missing three xylophone notes at 0:02. Audio Overload, Blargg, bsnes, and YouTube play all notes.
Ah, excellent. Thanks a lot. I never would have picked that out. This is helpful. I'll keep working on it. :)
Re: Now you're playing with gauss!
by on (#148349)
KungFuFurby wrote:
Here's my selection for each one...
Clay Fighter 2 ~ Main Menu
Mickeys Playtown Adventure ~ Title Screen
Shin Togenkyo ~ Main Menu
We're Back! A Dinosaur's Story ~ Title Screen
Progress!! I can now play these tracks for more than a few notes without them barfing. They're probably not perfect yet (and I'm still missing features), but going from not playing at all to continuously playing is a big leap.

https://dl.dropboxusercontent.com/u/362 ... 2jc-01.mp3
https://dl.dropboxusercontent.com/u/362 ... add-02.mp3
https://dl.dropboxusercontent.com/u/362 ... gky-02.mp3
https://dl.dropboxusercontent.com/u/362 ... ads-01.mp3

--
Still missing those 3 dam* xylophone notes at the beginning of the Zoop track though. Grrr...
Re: Now you're playing with gauss!
by on (#148454)
Success!! Finally got the Zoop track working - or at least it's not missing the xylophone notes anymore!

https://dl.dropboxusercontent.com/u/362 ... oop-03.mp3

Do you guys have any more challenging track selections for me? :) I suppose basically all the tracks from all of these midi engine games would be challenging.
Re: Now you're playing with gauss!
by on (#148459)
I listened to the first 24 seconds of the Zoop track, and it sounded correct. What was the bug, if I might ask?
Re: Now you're playing with gauss!
by on (#148460)
Basically, without having to get too needlessly detailed, I was reading the BRR header byte at the wrong time when a certain set of scenarios occurred. A set of scenarios which apparently only happens in a few games (since the bug didn't seem to affect most other games...or maybe it just wasn't noticeable...).
Re: Now you're playing with gauss!
by on (#148461)
Here's something fun...30-second clips from every music track in the Zoop game. There's about 7 seconds of silence in between each track.

https://dl.dropboxusercontent.com/u/362 ... -01-10.mp3

Here are the time indexes:
00:00 - Track 01
00:36 - Track 02
01:12 - Track 03
01:50 - Track 04
02:28 - Track 05
03:06 - Track 06
03:44 - Track 07
04:22 - Track 08
04:59 - Track 09
05:37 - Track 10
Re: Now you're playing with gauss!
by on (#148464)
And here's 30-second clips from every track of Mickey's Playtown Adventure. There's about 7 seconds of silence in between each track.

https://dl.dropboxusercontent.com/u/362 ... -01-09.mp3

Here are the time indexes:
00:01 - Track 01
00:31 - Track 02
01:09 - Track 03
01:45 - Track 04
02:20 - Track 05
02:58 - Track 06
03:36 - Track 07
04:14 - Track 08
04:52 - Track 09
Re: Now you're playing with gauss!
by on (#148467)
And here's 30-second clips from every track of Clay Fighter 2. There's about 7 seconds of silence in between each track.

https://dl.dropboxusercontent.com/u/362 ... -01-14.mp3

Here are the time indexes:
00:00 - Track 01
00:37 - Track 02
01:13 - Track 03
01:24 - Track 04
02:00 - Track 05
02:40 - Track 06
03:19 - Track 07
03:56 - Track 08
04:35 - Track 09
05:12 - Track 10
05:50 - Track 11
06:28 - Track 12
06:59 - Track 13
07:10 - Track 14
Re: Now you're playing with gauss!
by on (#148474)
jwdonal wrote:
Here's something fun...30-second clips from every music track in the Zoop game.

First note of track 01 is missing and part of the first chord of track 8 are missing. Otherwise, all match my recollection.
Re: Now you're playing with gauss!
by on (#148489)
Okay, so the missing note at the beginning of track 01 was definitely just a mistake I made in the recording. But I'm still trying to figure out what you mean with track 08. I don't hear a difference when I compare to other SPC players.

Thanks for your help with these!