English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 20 January 2023, 09:44   #1
Steam Ranger
Registered User

Steam Ranger's Avatar
 
Join Date: May 2022
Location: Adelaide
Posts: 111
Best compressed audio?

I'm trying to fit a 3 minute song onto a floppy disk, the best format I've discovered so far is AMR, which has low quality but wonderful amounts of compression. I have several questions:
  1. Does anyone know a better format than AMR for a stock 68000? (More quality with same size)
  2. Where can I obtain Asm/C code to decode the better format on the Amiga? (Real time)
  3. If AMR is the best, can someone provide me with Asm/C decoder (Takes in a memory buffer pointer, outputs a pointer to a new memory buffer with decoded sound)

Thanks in advance.
Steam Ranger is offline  
Old 20 January 2023, 11:06   #2
britelite
Registered User
 
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 802
What quality is your input audio and what's the desired output frequency and bit depth? Mono, stereo?

I assume you've done some benchmarks with AMR, what kind of results did you get regarding size and quality?
britelite is offline  
Old 20 January 2023, 11:28   #3
Steam Ranger
Registered User

Steam Ranger's Avatar
 
Join Date: May 2022
Location: Adelaide
Posts: 111
Quote:
Originally Posted by britelite View Post
What quality is your input audio and what's the desired output frequency and bit depth? Mono, stereo?

I assume you've done some benchmarks with AMR, what kind of results did you get regarding size and quality?
With the highest quality narrowband AMR I can fit the Audio on a DD disk 3 times, I don't know how fast/slow the compression is, but I think it might be a bit slow decompressing? I can't find and way to test it.

AMR narrowband is locked at 8000Hz, and broad band is non-distributable.

I'll settle for 8000Hz minimum, any number of bits I can't hear the difference. It must be able to decode in real time, preferable stream able off of disk.
Steam Ranger is offline  
Old 20 January 2023, 11:30   #4
hooverphonique
ex. demoscener "Bigmama"

 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,479
Ask the guy who did this: https://www.pouet.net/prod.php?which=65736
hooverphonique is offline  
Old 20 January 2023, 11:37   #5
Steam Ranger
Registered User

Steam Ranger's Avatar
 
Join Date: May 2022
Location: Adelaide
Posts: 111
That sounds like tracker music. I'm converting an MP3 song to fit on a floppy disk, and to be usable by a stock A500. It has lyrics, so I can't just convert it to tracker music.
Steam Ranger is offline  
Old 20 January 2023, 11:49   #6
britelite
Registered User
 
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 802
Quote:
Originally Posted by Steam Ranger View Post
That sounds like tracker music. I'm converting an MP3 song to fit on a floppy disk, and to be usable by a stock A500. It has lyrics, so I can't just convert it to tracker music.
It's not tracker music though
britelite is offline  
Old 20 January 2023, 11:52   #7
stevelord
Registered User

stevelord's Avatar
 
Join Date: Apr 2019
Location: UK
Posts: 519
Second half has lyrics.
stevelord is offline  
Old 20 January 2023, 11:57   #8
Steam Ranger
Registered User

Steam Ranger's Avatar
 
Join Date: May 2022
Location: Adelaide
Posts: 111
Oh right, didn't watch that far.
Steam Ranger is offline  
Old 20 January 2023, 12:35   #9
no9
Registered User

no9's Avatar
 
Join Date: Feb 2018
Location: Poland
Posts: 314
There is another one [ Show youtube player ]
no9 is offline  
Old 20 January 2023, 13:05   #10
SoDa7
Registered User

 
Join Date: Jun 2022
Location: Amalfi Coast / Italy
Posts: 35
Quote:
Originally Posted by Steam Ranger View Post
I'm trying to fit a 3 minute song onto a floppy disk, the best format I've discovered so far is AMR, which has low quality but wonderful amounts of compression. I have several questions:
  1. Does anyone know a better format than AMR for a stock 68000? (More quality with same size)
  2. Where can I obtain Asm/C code to decode the better format on the Amiga? (Real time)
  3. If AMR is the best, can someone provide me with Asm/C decoder (Takes in a memory buffer pointer, outputs a pointer to a new memory buffer with decoded sound)

Thanks in advance.
Honestly, I'm not sure that AMR is the best format for music - as AMR is a format optimized for voice (and so, used for phone calls mostly)

I think that instead, for an unexpanded AMIGA (AMR might be too much for a 68000 afaik), you could try 8SVX at 8000hz mono. it would be something like 64kbps per second of PCM audio (on an AMIGA formatted floppy is approx 1 minute and 40 seconds of audio)
SoDa7 is offline  
Old 20 January 2023, 14:07   #11
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 54
Posts: 1,580
For Amiga sample it can be 50% compression, i dont know if AMR did it better.
Don_Adan is offline  
Old 20 January 2023, 17:49   #12
pandy71
Registered User
 
Join Date: Jun 2010
Location: PL
Posts: 2,304
I would check some open source codecs as Speex and/or Opus (SILK) they should outperform closed and proprietary AMR - but honestly doubt if you can do something useful on plain MC68000 @7MHz with all normal codecs - maybe some heavily stripped and simplified MPEG 1 Layer I. Or perhaps some INT decoders as Tremor for Vorbis or Helix for MP3 but still >>onslaught<< seem to be best in terms quality/compression/CPU utilization.
ADPCM may be sane approach - giving compression 4 or more...



pandy71 is offline  
Old 20 January 2023, 21:57   #13
smack
Registered User
 
Join Date: May 2020
Location: Germany
Posts: 20
If the AMR you mean is this one https://en.wikipedia.org/wiki/Adapti...te_audio_codec
then I think this decoder can't run in realtime on the 7 MHz 68000.
Also, that's a narrow-band speech codec so I expect the music quality to be seriously degraded.

IMO a reasonable approach can be:
- reduce the sample rate as much as possible, while still getting acceptable audio quality (for example 8 kHz or lower)
- use an ADPCM codec to compress the audio data to 4 bits per sample (50% reduction)

You can find a ready-to-use ADPCM codec implementation by Mikael Kalms here:
https://github.com/Kalmalyzer/adpcm-68k

example:
3 minutes, 8 kHz mono, 4-bit ADPCM would fit on a single floppy disk
180s * 8000/s * 4b = 5.760.000b = 703 KiB

Last edited by smack; 20 January 2023 at 22:37.
smack is offline  
Old 21 January 2023, 06:02   #14
Steam Ranger
Registered User

Steam Ranger's Avatar
 
Join Date: May 2022
Location: Adelaide
Posts: 111
Thanks for all the help! I've managed to fit it onto the disk as ADCMP, however I was hoping for more than 8Khz, so I'm thinking I'll devise my own simple compression and build it into my program and it will run while it's streaming from disk.
Steam Ranger is offline  
Old 21 January 2023, 07:42   #15
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 50
Posts: 4,808
Alternatively you may try XPK lib. Its SQSH method is efficient on samples and fast enough for 68000.
meynaf is offline  
Old 21 January 2023, 12:17   #16
Steam Ranger
Registered User

Steam Ranger's Avatar
 
Join Date: May 2022
Location: Adelaide
Posts: 111
Quote:
Originally Posted by meynaf View Post
Alternatively you may try XPK lib. Its SQSH method is efficient on samples and fast enough for 68000.
Is XPK a generic archive or audio format?
Steam Ranger is offline  
Old 21 January 2023, 12:46   #17
meynaf
son of 68k
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 50
Posts: 4,808
Quote:
Originally Posted by Steam Ranger View Post
Is XPK a generic archive or audio format?
It's a compression library with sub-libraries - some of which being specialized for audio.
http://aminet.net/package/util/pack/xpk_User
meynaf is offline  
Old 21 January 2023, 13:03   #18
Karlos
Registered User

 
Join Date: Aug 2022
Location: UK
Posts: 1,770
If you want low CPU usage and the ability to pretty much play directly without decompressing the whole thing (or large blocks first), basic 4-bit delta encoding is a good trade off. For the same storage requirements of 8kHz you could use 16kHz. There are different ways to encode the 16 values, I've experimented with quite a few, but you have to be able to encode negative and positive deltas. Also you want to use a nonlinear encoding ideally. Delta value distribution favours small values compared to the original signal. I've also experimented with a zeroless scheme for this (where you can't represent an unchanging value). It's not as limiting for real audio signals as it sounds, but it isn't particularly good on more basic waveforms for reasons that are hopefully self-evident.

For maximum simplicity, you might choose deltas 0, 1, 2, 4, 16, 32, 64, 127, -1, -2, -4, -8, -64. The lack of symmetry is why I experimented with zeroless encoding.

Reading a block of delta values and outputting the sample stream is trivial. You just keep track of the current value, get the next 4-bit delta index, look it up in your encoding table above and add it on. That's the next output sample.
Karlos is offline  
Old 21 January 2023, 20:12   #19
paraj
Registered User

 
Join Date: Feb 2017
Location: Denmark
Posts: 570
Quote:
Originally Posted by Karlos View Post
If you want low CPU usage and the ability to pretty much play directly without decompressing the whole thing (or large blocks first), basic 4-bit delta encoding is a good trade off. For the same storage requirements of 8kHz you could use 16kHz. There are different ways to encode the 16 values, I've experimented with quite a few, but you have to be able to encode negative and positive deltas. Also you want to use a nonlinear encoding ideally. Delta value distribution favours small values compared to the original signal. I've also experimented with a zeroless scheme for this (where you can't represent an unchanging value). It's not as limiting for real audio signals as it sounds, but it isn't particularly good on more basic waveforms for reasons that are hopefully self-evident.

For maximum simplicity, you might choose deltas 0, 1, 2, 4, 16, 32, 64, 127, -1, -2, -4, -8, -64. The lack of symmetry is why I experimented with zeroless encoding.

Reading a block of delta values and outputting the sample stream is trivial. You just keep track of the current value, get the next 4-bit delta index, look it up in your encoding table above and add it on. That's the next output sample.
I think this a good approach for getting 50%, but you want to change the "127" to "-128" in that table, haven't checked if other changes are better. Did a super-quick check of what difference that makes (attached: wagner1.wav is your table, wagner2.wav is using same with 127 changed to -128). (You can hear the original at https://www.lemonamiga.com/games/details.php?id=701 by selecting 8svx.wagner)
Attached Files
File Type: 7z wagner.7z (97.1 KB, 31 views)
paraj is offline  
Old 21 January 2023, 22:52   #20
Karlos
Registered User

 
Join Date: Aug 2022
Location: UK
Posts: 1,770
Quote:
Originally Posted by paraj View Post
I think this a good approach for getting 50%, but you want to change the "127" to "-128" in that table, haven't checked if other changes are better. Did a super-quick check of what difference that makes (attached: wagner1.wav is your table, wagner2.wav is using same with 127 changed to -128). (You can hear the original at https://www.lemonamiga.com/games/details.php?id=701 by selecting 8svx.wagner)
The table was to be illustrative rather than a real world example. To be clear, for real audio, the chances of getting a full scale d deflection in a delta signal is diminishingly small. The delta is the differential of the signal. Think about what the real signal must look like to have such a delta.

Last edited by Karlos; 21 January 2023 at 23:16.
Karlos is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compressed filelist.txt jbl007 project.Amiga File Server 1 11 November 2017 22:54
fs-uae and cd32 compressed audio deejay support.FS-UAE 3 24 March 2014 20:17
ADF file compressed with RAR pucci support.WinUAE 5 16 October 2011 12:37
Compressed HDF saving BippyM request.UAE Wishlist 5 17 October 2005 23:12
Multi-Disk Compressed ADF? TheOutrider support.WinUAE 10 02 October 2003 10:44

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:37.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Page generated in 0.09503 seconds with 14 queries