Welcome, Guest. Please login or register.

Author Topic: Amiga sound playback routine/format questions  (Read 3990 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Amiga_NutTopic starter

  • Hero Member
  • *****
  • Join Date: Jan 2007
  • Posts: 926
    • Show only replies by Amiga_Nut
Amiga sound playback routine/format questions
« on: August 09, 2010, 08:39:12 PM »
A couple of questions,

Firstly, is there a routine for Blitz Basic to playback 14bit audio via the channel muxxing hack of Paula? And if so does it strip out the extra data from a 16bit sample or do you have to create bespoke 14bit samples?

Secondly, as far as standard 8bit sample playback goes was there any kind of compression/decompression standard or do you have to read out the data uncompressed from memory due to lack of CPU time on OCS? (not expecting MP3 levels of compression! Just wondering if there is anything apart from depacking it from a compressed files to RAM as raw data before playback)

All questions are centred around a bog standard 7mhz OCS/ECS motherboard.

Cheers.
 

Offline bubblebobble

  • Jr. Member
  • **
  • Join Date: Dec 2003
  • Posts: 66
    • Show only replies by bubblebobble
    • http://www.hd-rec.de
Re: Amiga sound playback routine/format questions
« Reply #1 on: August 09, 2010, 08:50:49 PM »
Not that I know of.

It's all easily possible with the includes (ADPCM4 Codec, AHI Playback), but not with a 7MHz nacked Amiga.

I wrote a 14bit Audio output routine once for BlitzBasic in inline ASM. But I dont know if I have it still somewere. If you know how to deal with the Paula Registers, 14bit playback is not so hard to do. I also think that the ADPCM4 Codec (4bit per sample) I wrote is fast enough for 7MHz (depends on the Samplerate of course), but I think it would be quite busy then.
--
Author of
HD-Rec, Sweeper, Samplemanager, ArTKanoid, Monkeyscript, Toadies, AsteroidsTR, TuiTED, PosTED, TKPlayer, AudioConverter, ScreenCam, PerlinFX, MapEdit, AB3 Includes and many more...
Homepage: http://www.hd-rec.de
 

Offline Amiga_NutTopic starter

  • Hero Member
  • *****
  • Join Date: Jan 2007
  • Posts: 926
    • Show only replies by Amiga_Nut
Re: Amiga sound playback routine/format questions
« Reply #2 on: August 09, 2010, 10:43:30 PM »
Ahh right wasn't sure if Octamed does the 14bit trick on stock machines. And yes I was thinking Blitz calling a 68k ASM routine :)

At most an anim 5/7 may be playing at the same time, possibly just a static ham6 picture slideshow....not really decided as wasn't even sure it was possible.
 

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Amiga sound playback routine/format questions
« Reply #3 on: August 09, 2010, 11:16:06 PM »
14bit audio is quite easy.

Create two 8bit sample buffers the same length, load one with all the highbyte data of the 16bit sample and load the other with the lowbyte data. Set the volume of channel 0 to 1 and the volume of channel 3 to 64 then play both samples back at the same time with the highbyte data in the full volume channel and the lowbyte data in the volume 1 channel. That gives you your left 14bit channel.

Do the same for channels 1 and 2 for your right audio!

Offline amigaksi

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 827
    • Show only replies by amigaksi
    • http://www.krishnasoft.com
Re: Amiga sound playback routine/format questions
« Reply #4 on: August 10, 2010, 04:52:32 AM »
Regarding 8-bit sample decompression, I did that on stock 7.16Mhz Amiga using lossless delta-modulation followed by Huffman encoding.  You can even use Arithmetic encoding to get around 3:1 lossless compression.  Currently, I am just uploading decompressed data from the floppy drive port (from PC) into a queue on Amiga end and I'm easily able to update the queue using 11.025Khz audio and have text/imagery also being uploaded at the same time.
--------
Use PC peripherals with your amiga: http://www.mpdos.com
 

Offline Britelite

  • Full Member
  • ***
  • Join Date: Jul 2003
  • Posts: 187
    • Show only replies by Britelite
    • http://www.dekadence64.org
Re: Amiga sound playback routine/format questions
« Reply #5 on: August 10, 2010, 07:38:39 AM »
My current IMA Adpcm decoder can play 16Khz/mono/16bit@14bit adpcm-files on a standard A500 straight from memory, and could probably play with even better samplerate with some 000-specific optimizations. Haven't tried streaming files from harddrive yet though.
 

Offline bubblebobble

  • Jr. Member
  • **
  • Join Date: Dec 2003
  • Posts: 66
    • Show only replies by bubblebobble
    • http://www.hd-rec.de
Re: Amiga sound playback routine/format questions
« Reply #6 on: August 10, 2010, 10:33:38 AM »
@bloodline

You forgot to mention that the lower byte has to be shifted down 2 bits. This is where the 14bit comes into play. 64 is only 2^6. If they had made the volume control with a granulariy of 256 instead of 64, you could get 16bit playback.

Looseless goes not beyond 1:2 compression. But lossy ADPCM is cheaper to decode and at 8bit sounds pretty good (I cant hear a difference with HQ equipment). It still sounds acceptable at 4bit, but high frequencies get a little rough though.

We had this discussion once already:

PCM 16bit
ADPCM 8bit
ADPCM 4bit
ADPCM 2bit

Those are all plain .wav files, but have been encoded&decoded.
--
Author of
HD-Rec, Sweeper, Samplemanager, ArTKanoid, Monkeyscript, Toadies, AsteroidsTR, TuiTED, PosTED, TKPlayer, AudioConverter, ScreenCam, PerlinFX, MapEdit, AB3 Includes and many more...
Homepage: http://www.hd-rec.de
 

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Amiga sound playback routine/format questions
« Reply #7 on: August 10, 2010, 10:51:12 AM »
Quote from: bubblebobble;574149
@bloodline

You forgot to mention that the lower byte has to be shifted down 2 bits. This is where the 14bit comes into play. 64 is only 2^6. If they had made the volume control with a granulariy of 256 instead of 64, you could get 16bit playback.


Oops, yeah I forgot about that :)

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Amiga sound playback routine/format questions
« Reply #8 on: August 10, 2010, 11:02:57 AM »
Quote from: bubblebobble;574149
@bloodline

You forgot to mention that the lower byte has to be shifted down 2 bits.

As Britelite pointed out at boozembly, plain shifting is slightly wrong though. If you want "perfect" scaling typically you'll use a lookup table.
 

Offline bubblebobble

  • Jr. Member
  • **
  • Join Date: Dec 2003
  • Posts: 66
    • Show only replies by bubblebobble
    • http://www.hd-rec.de
Re: Amiga sound playback routine/format questions
« Reply #9 on: August 10, 2010, 12:43:26 PM »
Quote from: Piru;574151
As Britelite pointed out at boozembly, plain shifting is slightly wrong though. If you want "perfect" scaling typically you'll use a lookup table.

Sure, and if you want to do it really perfect, you do dithering.
But we are talking about a hack that adds two audio signals to resemble 14bit. Because the playback is far from beeing perfect/linear etc., the result is not perfect 14bit. I would say the noise from artefacts is somehow comparable with something like 12bit. So you do not really gain a lot from trying to be better than a simple shift, which is the fastest way to do it.
--
Author of
HD-Rec, Sweeper, Samplemanager, ArTKanoid, Monkeyscript, Toadies, AsteroidsTR, TuiTED, PosTED, TKPlayer, AudioConverter, ScreenCam, PerlinFX, MapEdit, AB3 Includes and many more...
Homepage: http://www.hd-rec.de
 

Offline amigaksi

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 827
    • Show only replies by amigaksi
    • http://www.krishnasoft.com
Re: Amiga sound playback routine/format questions
« Reply #10 on: August 10, 2010, 04:24:12 PM »
Quote from: bubblebobble;574149
@bloodline

You forgot to mention that the lower byte has to be shifted down 2 bits. This is where the 14bit comes into play. 64 is only 2^6. If they had made the volume control with a granulariy of 256 instead of 64, you could get 16bit playback.

Looseless goes not beyond 1:2 compression. But lossy ADPCM is cheaper to decode and at 8bit sounds pretty good (I cant hear a difference with HQ equipment). It still sounds acceptable at 4bit, but high frequencies get a little rough though.

We had this discussion once already:

PCM 16bit
ADPCM 8bit
ADPCM 4bit
ADPCM 2bit

Those are all plain .wav files, but have been encoded&decoded.


I am not a fan of lossy algorithms including MPEG, JPEG, MP3, etc.  I rather know exactly what I'm losing every sample rather than some sort of probability distribution where some samples may lose a lot more bits than others.  It doesn't matter how it sounds to some particular person since that's subjective.  Yeah, I do get 3.3:1 compression in my Gita multimedia CD (available on my website).  I compressed 2GB of 11Khz 8-bit samples losslessly to 600MB so they fit on one CD along with images.  It depends on the algorithm and audio data and rate.  I can probably get higher compression at higher sampling rates since redundancies increase.  Some people think MP3 sounds just like uncompressed digital audio CDs, but objectively speaking, the uncompressed is higher quality.
--------
Use PC peripherals with your amiga: http://www.mpdos.com
 

Offline bubblebobble

  • Jr. Member
  • **
  • Join Date: Dec 2003
  • Posts: 66
    • Show only replies by bubblebobble
    • http://www.hd-rec.de
Re: Amiga sound playback routine/format questions
« Reply #11 on: August 10, 2010, 05:07:38 PM »
> Yeah, I do get 3.3:1 compression in my Gita multimedia CD
This is probably due so relatively silent parts in the samples and/or the 8bit quantisation.
Try the same on some randrom music in 16bit. In average, you wont get better than 1:2 when you go loosless.
http://wiki.hydrogenaudio.org/index.php?title=Lossless_comparison

And Amiga_Nut needs something fast enough for a nacked A500 that should do some GFX in the meanwhile.
--
Author of
HD-Rec, Sweeper, Samplemanager, ArTKanoid, Monkeyscript, Toadies, AsteroidsTR, TuiTED, PosTED, TKPlayer, AudioConverter, ScreenCam, PerlinFX, MapEdit, AB3 Includes and many more...
Homepage: http://www.hd-rec.de
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: Amiga sound playback routine/format questions
« Reply #12 on: August 10, 2010, 05:38:46 PM »
Quote from: bubblebobble;574163
But we are talking about a hack that adds two audio signals to resemble 14bit. Because the playback is far from beeing perfect/linear etc., the result is not perfect 14bit. I would say the noise from artefacts is somehow comparable with something like 12bit.
Paula 14 bit sound becomes quite a lot better when you use a proper calibration table and properly down sampled audio files. No calibration: lowered quality. No proper down sampling: lowered quality. Add these two together, and it won't sound very good.

Furthermore, it's not really a hack, because Paula is a 14 bit D/A converter ;)
 

Offline bubblebobble

  • Jr. Member
  • **
  • Join Date: Dec 2003
  • Posts: 66
    • Show only replies by bubblebobble
    • http://www.hd-rec.de
Re: Amiga sound playback routine/format questions
« Reply #13 on: August 10, 2010, 05:48:24 PM »
If Paula is a 14bit DA Converter, what is the "calibration" for then?

As for th downsampling, this is another story, but can be done "offline". I used to do 44.1kHz with interrupt, but on a 68060.
With dithering I mean to reduce (or better mask, it is some kind of noise shaping) the audible quantisation noise. Just like dithering in images with low bit depth.
--
Author of
HD-Rec, Sweeper, Samplemanager, ArTKanoid, Monkeyscript, Toadies, AsteroidsTR, TuiTED, PosTED, TKPlayer, AudioConverter, ScreenCam, PerlinFX, MapEdit, AB3 Includes and many more...
Homepage: http://www.hd-rec.de
 

Offline amigaksi

  • Hero Member
  • *****
  • Join Date: Dec 2006
  • Posts: 827
    • Show only replies by amigaksi
    • http://www.krishnasoft.com
Re: Amiga sound playback routine/format questions
« Reply #14 on: August 11, 2010, 02:56:10 AM »
Quote from: bubblebobble;574202
> Yeah, I do get 3.3:1 compression in my Gita multimedia CD
This is probably due so relatively silent parts in the samples and/or the 8bit quantisation.
Try the same on some randrom music in 16bit. In average, you wont get better than 1:2 when you go loosless.
http://wiki.hydrogenaudio.org/index.php?title=Lossless_comparison

And Amiga_Nut needs something fast enough for a nacked A500 that should do some GFX in the meanwhile.


Thanks for that link-- I didn't realize my link was also in that article: http://www.krishnasoft.com/sps.htm.  I never promoted my audio software but I guess someone did it for me.  I did say 8-bit in my post #5 and it does work on stock Amiga at 7.16Mhz as the decompressor is very fast (faster than playback rate).  All speech and even some music have silent parts; it's part of natural sentence structure.  But even the silence is noisy in my audio as it was digitized from cassettes and there's that "hiss" type of noise when someone pauses between words.
--------
Use PC peripherals with your amiga: http://www.mpdos.com