VOGONS

Common searches


First post, by Roxor

User metadata
Rank Newbie
Rank
Newbie

This may sound like an odd suggestion, but has anyone thought about making audio versions of the scalers that DOSBox has for video? An audio scaler would boost the bit-depth and samplerate of any game's digital audio up to whatever the output setting have been configured to use. Naturally, this would add to the CPU load of DOSBox, but if you're going to go to the trouble of improving the graphics, why not the sound as well?

Reply 1 of 13, by Harekiet

User metadata
Rank DOSBox Author
Rank
DOSBox Author

most soundoutput is already generated at the same samplerate as the main mixing sample rate and if they're not there's some linear interpolation

Reply 3 of 13, by Roxor

User metadata
Rank Newbie
Rank
Newbie

I'm afraid I don't know if any previous work in the area exists.

I suppose in theory that it would be possible to convert a game's output to an intermediate data type, such a double-precision float, apply a one-dimensional version of the scaler algorithms that are used for graphics to boost the samplerate, then convert from the intermediate data type to the final output type (eg. 24-bit), and send the boosted samplerate data through the output device.

I'm actually trying to write a program that will do something similar to WAV files (a samplerate and bit-depth booster, if you like), although it's still in the early stages of development.

Reply 4 of 13, by HunterZ

User metadata
Rank l33t++
Rank
l33t++

Interpolation is probably what you want to look into. Linear is probably good enough, but I've heard of other things like cubic interpolation as well:

http://www.alpha-ii.com/Info/AudioInt.html

Reply 5 of 13, by Roxor

User metadata
Rank Newbie
Rank
Newbie

I've already got some C functions for linear, cosine, and cubic interpolation. I'm a bit stumped on what to do with cubic interpolation between points 0 and 1 and between (n-2) and (n-1), where n is the number of data points (numbered 0...(n-1)). In the case of interpolating between 0 and 1, I need a way to extrapolate the value at -1, and in the case of (n-2) and (n-1) I need to extraplolate the value at n. Think you can help? I'd be happy to donate my source code to the DOSBox project once I get the program working.

Reply 6 of 13, by Snejs

User metadata
Rank Newbie
Rank
Newbie

Hummm, that was some time ago, cubic and spline interpolation.

The sound still starts at 0 and ends at (n-1). The points -1 and n only set the derivate/slope from point 0/to point (n-1).

I would try to use v(-1) = v(0) and v(n) = v(n-1). That would set the noise to level in at start and out at end.

Out of curiosity. Sound is played directly, you can usually hear even small delays.
How do you intend to do this? Sound has to be intercepted somewhere and interpolated continously I guess to keep the delay low?

Reply 7 of 13, by HunterZ

User metadata
Rank l33t++
Rank
l33t++

Snejs: Actually, DOSBox buffers a small amount of sound. This is necessary for various reasons and is commonly done in emulators. The trick is making the buffer as small as possible (to minimize noticable delay) without it resulting in stuttery sound.

Edit:
Roxor:

That stuff is a little over my head, as I haven't researched it in a while, but I think you need more than two data points to do cubic interpolation:
http://www.dsprelated.com/showmessage/47166/1.php

Edit 2:
I'd recommend doing Google searches on cubic interpolation of audio.

Here's an official GNU library that might be of interest:
http://www.gnu.org/software/gsl/
http://www.gnu.org/software/gsl/manual/gsl-re … _26.html#SEC398

Another article:
http://www.csounds.com/ezine/summer2000/internals/

Reply 8 of 13, by Snejs

User metadata
Rank Newbie
Rank
Newbie

HunterZ:
That actually makes sense, now when I'm thinking first 😀.
I guess it has something to do with emulating a SB and then sending it along to the what-ever-audio-system-you-use?

Funny you should post those links, I've read some of them as well from when this thread started 😀

It takes four points (call them 0,1,2,3) to do cubic interpolation between point 1 and 2.

The Official GNU library is probably good and nice, but I could only see it using double and that would make it a big performance hog. My guess is that it would be better to find integer code instead and make it fit especially for the soundbuffer (in order to keep initation of arrays, allocating/deallocating arrays and so on as low as possible).

Reply 9 of 13, by kekko

User metadata
Rank Oldbie
Rank
Oldbie

Actually sound cards already do that through a DAC circuit, because digitized sound can't be sent in output as is, but it needs to be converted to analog waveform. So all the work is already done by the hardware, either for low or high sample rates.

Reply 10 of 13, by Snejs

User metadata
Rank Newbie
Rank
Newbie

kekko:
The DAC converts from digital to analog, I agree to that. But does it really perform upsampling as well?

First I should probably say that I'm not an expert about soundequipment/soundcard, just a I-want-to-know-more-guy 😀

But do you mean that todays soundcard has some digital circuit (dsp) doing upsampling to something (16bit/44,1khz or 16bit/48khz or ...) before sending of the digital audio to the DAC, which is working in that designated samplerate at all times?

If that's the case, then audio-scaling is unncesseary to implement. But an interesting discussion though 😀

Reply 11 of 13, by robertmo

User metadata
Rank l33t++
Rank
l33t++

I wonder whether there would be this discussion at all if harekiet and moe didn't post at the same time, cause harekiet said that dosbox already does audio "scaling" but because moe posted at the same time he didn't noticed what harekiet said 😉

Reply 12 of 13, by HunterZ

User metadata
Rank l33t++
Rank
l33t++

I'd be surprised if the sound card does any filtering normally, and I really really doubt that most soundcards do any upscaling on the digital side (except for a few that convert everything internally to, say, 48KHz, but that still doesn't mean any complex interpolation is taking place)

If you have the time to invest, you could always take a stab at implementing something in DOSBox and see if you can hear a difference. Would be an interesting experiment I think.

Reply 13 of 13, by swaaye

User metadata
Rank l33t++
Rank
l33t++

X-Fi has the best resampling engine out there bar none. In hardware anyway. Live and the Audigys were all resampling to 48KHz but creating IMD probs (hardly audible, but they're there).

I'm not sure what the ultra cheapo AC97 codecs out there do but I doubt it's anything fancy.