Instead of separating the APU channels, how's possible to produce a stereo sound effect much like a few emulators do?
I guess an emulator could watch the memory of a particular game's sound engine and figure out where an action happened that caused the game to play a particular sound effect.
Try playing your mono output through one channel (L/R) and a slightly delayed copy through the other.
Which emulator are you referring to? There's a number of techniques to turn mono sound into stereo.
One way to do it is to implement a comb filter to put half the sound in each channel, separated by regularly-spaced frequency. Or you could build a more complicated filter with a fast fourier transform and tweak the separation frequencies to your liking.
Other techniques might involve delay or reverb.
I'd recommend that whatever you do, make it an option for the user. Personally, I would usually rather the authentic sound, but even when I want stereo, I much prefer simple panning on the sound channels than the "fake stereo" techniques I've seen.
Well, puNES is one of them.
Another thing you can do is run two noise generators in parallel starting from a different seed. This would let you have stereo noise, at least. You could also introduce panning based on the frequency setting.
puNES uses the delay technique. The length of the delay is even configurable.
rainwarrior's first proposal of applying different filters to the two channels is interesting. That's what was done to the original official soundtrack CD for Final Fantasy I and II. The downside is it can be jarring and feel rather uncomfortable to have all the bass on one side and all the treble on the other. I think it would be kinda cool to have in an emulator if you could customize the filtering even if I don't think I'd use it much. Other people might like it.
Another thing you could do, although this might be violating the terms of your question, is to invert the phase of an APU channel. This is done in the NotSoFatso NSF player plugin for Winamp. You can set a frequency at which point any tone generated at or above it gets inverted in one channel which creates an extreme stereo effect when listening with speakers. However, if, for some reason, anybody had mono playback where both channels are mixed together that sound would get canceled out and be inaudible to them. I like to use it on the noise channel to make it stereo while I pan square 1 mostly to the right and square 2 mostly to the left and keep the triangle centered. I find that gives the ideal stereo NES sound to me and would love to see that capability in an emulator.
Try a reverb, with the dry part in phase and the wet part 180 degrees out of phase. This way, mono listeners still hear the dry part, stereo listeners hear the music with stereo reverb, and surround listeners hear the dry part in front and the wet part in surround.
I don't know how to do it. My emu generates +samples or -samples, then I update left/right sound stream channels.
Reverb is echo with a comparatively short echo time, comparable to the human lower threshold of hearing (i.e. ≈ 50ms, or some less) (
wikpedia:Reverberation)
To do an echo in a computer, keep a log of past samples calculated or emitted, and mix them back in.
There are two ways: FIR (mix a fixed number of previous calculated samples in). Usually sounds a little wrong, because most things don't just echo once or twice, but rather there's some feedback as the signal echoes back and forth. But is bounded and guaranteed to not be unstable (i.e. ring or clip forever). The other is IIR, where you instead mix in a previously
emitted sample. This is more authentic, but can potentially produce feedback squeals.
An echo effect that uses the formula for a digital IIR allpass filter won't produce squeals. Cascade three allpass delay lines with periods that are pairwise relatively prime, and this should give you a reasonable facsimile of reverb.
(And if the above was Hellenic to you, ask a DSP geek.)
tepples wrote:
Try a reverb, with the dry part in phase and the wet part 180 degrees out of phase. This way, mono listeners still hear the dry part, stereo listeners hear the music with stereo reverb, and surround listeners hear the dry part in front and the wet part in surround.
That's a really cool idea. I think stereo panning is the best way to achieve stereo but I'd appreciate being able to add some subtle reverb too, even on top of that. I'm someone who has my computer hooked up to a home theater system using Dolby Pro Logic II. I've become very accustomed to having some sound in my rear speakers and find myself enjoying mono music much less because nothing comes out of the back when playing a mono source. It just seems distant. A little bit of reverb can make the music feel more full and enjoyable to me just by making a little bit of ambiance play in my back speakers. I also think NES and other largely mono game music, going as far as Sega Genesis or even some Game Boy Advance music, benefits in particular.
It seems to me the biggest issue is making a reverb algorithm that actually sounds good though. In my experience, if I try to add reverb to NES music very few presets/room simulations in plugins sound good. I find a fairly tough lowpass filter to be a necessity too, filtering from the reverb everything higher than several kHz or else it "sizzles" too much.
Adding reverb in an emulator might be getting a good ways removed from an authentic NES experience, but I generally believe in making things as good as they can be so I'd be happy to use it if it sounds better.
As a first approximation of what this sort of surround effect might sound like, try
neoMAX (Surround Mix).
DM Ashura made "neoMAX", a tribute to the "Max" songs in Dance Dance Revolution, with a JRPG-ish sound font for a contest on a DDR forum. Later he remade it with a more Bemani-typical sound font. I put both of them in an audio editor and panned one of them out of phase so that it's sent back to surround.
Since nobody came with code, I had an idea... but it doesn't work as expected. Take the volume level of square#1 >> 1 AND 7 (same for #2) - this is the shifter. Take the current sample (example, Left) and apply the shifter. This is the gain. Add the gain level to the other channel. Here, if subtracting (or adding the negative), the effect is different.
Why it doesn't work well? Because most games use the same volume level for squares #1 and #2.
Any other idea? Comments?
I spent some time digging through Nestopia's source to try to figure out how it did stereo ... but mostly just found in an exercise in frustration because the C++ goo got all over everything and made it impossible to follow data flow.
In any case, the least wrong choice is probably a static pan effect, panning each of the 5 (or 6, 8, 11, or 13) channels by using a slightly different volume for left and right.