Jump to content
IGNORED

Sound Sampling Question


Guest

Recommended Posts

Back in the 80s I used to use a cart/software combo:-

Replay Sound Sampling System (2-bit systems) (i still have one of these today)

 

from what i recall, the default "save as" file format was in ".spl"

 

my question:

does anyone know how to convert modern mp3/wav files into atari "spl" format?

is there an app/piece of software that'll do this?

 

thanks

 

 

 

Link to comment
Share on other sites

I also have the device but not the software at the moment.

 

From (my poor) memory, weren't they 4-bit raw samples (although the company name implies 2-bit)?

 

Is that just the case of getting a .wav file and stripping the header off? I'm not sure of the bit-rate.

 

I used it in a game once, but I think that there are better ways now. The playback routine used to use shed loads of CPU and would switch the screen off. You can get some better playback routines that leave the screen on with a better quality but lower rate sample now (think of 'Space Harrier').

Link to comment
Share on other sites

It'd be fairly trivial to convert - chances are that practically all modern-day tools would ignore packed 2 and 4 bit formats so you'd need to roll your own.

 

Easist option is to get your MP3 or WAV stuff and just export it as unsigned mono 8-bit data, then run it through your own converter.

What I usually do is just write an Atari Basic program and run in turbo in an emulator.

Link to comment
Share on other sites

There is one serious problem with converting 8-bit samples to 4-bit. Simple cutting off 4 least significant bits introduce a lot of unwanted quantisation noise. There are some clever algorithms that basically simulate going through an analog line (had a plug-in in SoundForge doing that, like 10+ years ago), but so far the best results I got were from sampling directly into 4 bits.

 

If you know of a modern day solution to this pesky issue, I am all ears.

Link to comment
Share on other sites

It's a similar step going from 16 down to 8 bits, ie like CD vs barely adequately tuned AM radio.

 

I've tried an oversampling technique where you take the current/previous sample and generate a 5 bit result that gets output for a barely worth it slight improvement.

The problem is that it increases the processing time significantly.

 

The advantage of modern day method using Pokey Timers as witnessed in Space Harrier - it gives reasonable playback quality and still allows game action to take place.

Link to comment
Share on other sites

Yes, you are 100% right, but there is an additional effect that makes these 4 bits sound worse than it should. I found a nice description with a proposed solution here: http://stackoverflow.com/questions/5717447/convert-16-bit-pcm-to-8-bit

 

 

In C, this could be expressed as output = (unsigned char)((unsigned short)(input + 32768) >> 8 ). This is a good start, and might be good enough for your needs, but it won't sound very nice. It sounds rough because of "quantization noise".

 

Quantization noise is the difference between the original input and your algorithm's output. No matter what you do, you're going to have noise, and the noise will be "half a bit" on average. There's nothing you can do about that, but there are ways to make the noise less noticeable.

The main problem with the quantization noise is that it tends to form patterns. If the difference between input and output were completely random, things would actually sound fine, but instead the output will repeatedly be too high for a certain part of the waveform and too low for the next part. Your ear picks up on this pattern.

To have a result that sounds good, you need to add dithering. Dithering is a technique that tries to smooth-out the quantization noise. The simplest dithering just removes the patterns from the noise so that the noise patterns don't distract from the actual signal patterns. Better dithering can go a step further and take steps to reduce the noise by adding together the error values from multiple samples and then adding in a correction when the total error gets large enough to be worth correcting.

You can find explanations and code samples for various dithering algorithms online. One good area to investigate might be the SoX tool, http://en.wikipedia.org/wiki/SoX. Check the source for its dithering effect, and experiment with converting various sounds from 16-bit to 8-bit with and without dithering enabled. You will be surprised by the difference in quality that dithering can make when converting to 8-bit sound.

When going from 8-bit to 4-bit the quantisation noise is even worse a problem and samples on our 8-bitter could sound much better if converted to 4 bits with some fancy dithering.

Best,

pirx

Edited by pirx
Link to comment
Share on other sites

Yes, you are 100% right, but there is an additional effect that makes these 4 bits sound worse than it should. I found a nice description with a proposed solution here: http://stackoverflow.com/questions/5717447/convert-16-bit-pcm-to-8-bit

 

 

When going from 8-bit to 4-bit the quantisation noise is even worse a problem and samples on our 8-bitter could sound much better if converted to 4 bits with some fancy dithering.

 

Best,

 

pirx

Audacity automatically dithers when converting audio to a form with fewer bits, but 8-bit is as low as it goes. To do four bits, you'd need to roll your own code, but that's really easy. Dithering is easy, too. Say you have 8-bit audio samples for the input. Dither needs to be +/- 0.5, plus or minus half a bit. Apply that before you convert, so half a bit for 4-bit samples is +/- 8 for 8-bit samples.

 

If RANDOM is a random number between 0 and 1, you want DITHER_NOISE = 8 * (RANDOM - 0.5). For a rectangular power distribution function, the sample you use is merely (sample - DITHER_NOISE) >> 4. If you want the better triangular power distribution function, the sample is (sample + DITHER_NOISE - PREVIOUS_DITHER) >> 4, then set PREVIOUS_DITHER = DITHER_NOISE.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...