A.D.A. Amiga Demoscene Archive

  Welcome guest! Please register a new account or log in

  

  

  

log in with SceneID

  

Demos Amiga Demoscene Archive Forum / Coding / adpcm
 Page:  ««  1  2  
Author Message
noname
Member
#1 - Posted: 13 May 2007 19:03
Reply Quote
"Play16" used to do the 14 bit trick as well, incl. support for many different output devices, cybersound calibration and adpcm playback.
doom
Member
#2 - Posted: 13 May 2007 23:34
Reply Quote
The DACs are definitely poor, just like the video encoder in the A1200. They chose some really stupid places to save a few pennies. Still, 14-bit audio does sound better than 8-bit ditto, and it's easy and cheap.

I really don't know about audio dithering, especially with lo-fi audio on the Amiga.
rload
Member
#3 - Posted: 14 May 2007 19:30
Reply Quote
we had dithering on lux aeterna, but I must admit it is hard to make up ones mind whether it makes a difference.. I'd say it is reduced quality in a different way rather than good quality. I bet bumping up the Khz does way more for the sound than adding dithering.
doom
Member
#4 - Posted: 14 May 2007 20:45
Reply Quote
You can bump up the kiloherz, but that costs kilobytes. It's a tradeoff thing, but no big surprise really. ;) What really hurts is if the audio itself isn't properly mastered (see: Kilofix).
Blueberry
Member
#5 - Posted: 14 May 2007 22:48
Reply Quote
I guess it will always give best results to use as high sampling frequency as possible, even for the same bitrate. Dithering also becomes much more effective with higher bitrates, as you can use some of the less audible frequencies for dithering the lower ones. Problem is, if your demo is running in PAL mode (which it is) you can only bump up the frequency to 28604Hz, which is just short of satisfactory. But that's what we got.

Anyway, to get any benefit from dithering, you will have to store the exact dithered signal losslessly, or use some compression method which outputs enough quality for a higher-than-9-bit signal. This effectively rules out ADPCM.

On a related note, ADPCM is a very-fixed-rate compression scheme (fixed number of bits for every single sample) which means that it provides inferior quality in difficult parts and wastes bits in easy parts. Does anyone know of a comparatively simple variable-bitrate codec (not necessarily as simple as ADPCM but preferably simpler than full-fledged sub-band coding) that could be used to avoid this drawback?
doom
Member
#6 - Posted: 15 May 2007 15:34
Reply Quote
There's no reason why you couldn't cut the sample up into blocks and selecting a different ADPCM scheme for every block. By some simple mechanism like picking the most compact encoding that produces an error below a fixed threshold. Also, the encoded data can be further packed with various lossless methods.

I've also considered post-processing to improve the result. Haven't actually experimented though.
winden
Member
#7 - Posted: 18 May 2007 15:42
Reply Quote
8bit + dithering doesn't really cost anything compared to plain 8bit since you are going to be waiting for the soundbuffer chipmem longword write. OTOH, 14bit forces to write double the amount of chipmem.
doom
Member
#8 - Posted: 18 May 2007 16:01
Reply Quote
Does it help, though? In the 28 khz, 8-bit context, I mean.
winden
Member
#9 - Posted: 20 May 2007 12:22 - Edited
Reply Quote
For the sound case I've tried with loading a 28khz 16bit wav and outputting to amiga 8bit via realtime floyd-steimber, using this code:

; a0 = 16bit samples
; a1 =  8bit dithered samples
; d0 = chipmem buffer register
; d1 = current sample
; d2 = error from previous sample

m1	macro
	move.w	\1(a0),d1

	add.w	d2,d1		  ; add error from previous sample
	add.w	#$80,d1		; round to nearest 8bit
	move.w	d1,d2		; save
	and.w	#$ff00,d1	; quantize to 8bit
	sub.w	d1,d2		; calc error

	ror.w	#8,d1		; output to lowbyte
	move.b	d1,d0
	endm

.loop
	m1	0
	lsl.l	#8,d0
	m1	2
	lsl.l	#8,d0
	m1	4
	lsl.l	#8,d0
	m1	6
	move.l	d0,(a1)+

	dbra	d7,.loop


I'm not really good at sound, but in images the same routine (in fact the images one was the original) did a very good job for a 8bit --> 4bit greyscale conversion.

BTW, anyone remembers how many cycles was chipmem copyspeed on a1200/060?
Kalms
Member
#10 - Posted: 20 May 2007 14:59
Reply Quote
winden: 26-28 cycles.

(Original a500 core clock period: 140ns. bus runs at half that: 280ns. CPU gets every other cycle: 560ns. 060/50 clock period: 20ns. 560/20 = 28.)
rload
Member
#11 - Posted: 28 May 2007 11:37
Reply Quote
I think Blueberry made an interesting point on dithering. We have a 4 bit signal which is extrapolated to 16-bit and then we optionally dither it down to 8-bit or 14-bit.

How much resolution does the signal really have left after it is expanded to 16-bit? Is the output made 16-bit mostly for the convenience or does it actually use the full resolution in a sensible way?
doom
Member
#12 - Posted: 28 May 2007 13:45
Reply Quote
ADPCM isn't just 4-bit quantization. The amplitude of the error (on average) is proportional to the change in amplitude for the last (couple of) samples. To reduce resolution on top of that would only make it worse. It might not matter much because there's a great deal of noise anyway, but I can hear the difference between 8-bit and 14-bit playback, at least, with my IMA ADPCM replayer.

Also, consider that ADPCM will pack a simple triangle wave very nicely with very little noise, and in some cases zero noise.

I'd love to see some discussion of the nature of ADPCM noise though. There might be a decent way to filter some of it out with stopband filters etc., and lots of free time for it while waiting for chipmem.
noname
Member
#13 - Posted: 26 Feb 2010 00:57
Reply Quote
Three years old thread revival!

I would be interested in testing some ADPCM routines on my Amiga for a change. Seeing that so many people seem to have their ADPCM routine ready-at-hand, is anyone willing to share theirs with me?

If desirable, I could also add it to WickedOS and make a new release so that others could enjoy ADPCM playback as well.
rload
Member
#14 - Posted: 27 Feb 2010 22:18
Reply Quote
I have something in C. It is Microsoft ADPCM and the routine is just written to the point where it works, but maybe we can upload it to some google code repository and start tweaking on it. I think a common optimized asm adpcm routine could do wonders for the 060 scene.
noname
Member
#15 - Posted: 28 Feb 2010 20:02
Reply Quote
Hi Loaderror, I think that is a very good idea. So many playroutines out there, but none for ADPCM on Amiga.
Btw. I wrote you an email at yourhandle@amigascne.org.
Kalms
Member
#16 - Posted: 2 Mar 2010 23:03
Reply Quote
I've got a version that is optimized for plain 68000 lying around. If someone sets up an online repo then I'll upload it there.
rload
Member
#17 - Posted: 5 Mar 2010 18:25
Reply Quote
@kalms : I've made a repository now on google code: http://code.google.com/p/unitedstatesofamiga/

I'm happy to add you as admin if you give me your email so you can upload stuff. (I think that is the only thing required to grant access).
Kalms
Member
#18 - Posted: 7 Mar 2010 03:01
Reply Quote
Thanks Loady!

ADPCM decoder is in the repository now :)
Blueberry
Member
#19 - Posted: 25 Feb 2012 22:47
Reply Quote
Such nice things you can find on ADA if you dig a little. ;)

I integrated your code into my demosystem (and extended it to support stereo replay) and it works great. Thanks! :)
britelite
Member
#20 - Posted: 26 Feb 2012 01:14
Reply Quote
If anyone is interested I can provide you with two different adpcm-routines, one for 020+ and one for 68000 that is able to decode 28khz/mono at 14bits on an A500 with some cpu-time to spare :)
Reloaded
Member
#21 - Posted: 4 Mar 2012 10:22
Reply Quote
What software can I use to convert wav (or mp3) files to ADPCM?.
bstrr
Member
#22 - Posted: 4 Mar 2012 11:22 - Edited
Reply Quote
I think there's an encoder (Windows exe + source) included here:

http://code.google.com/p/unitedstatesofamiga/downl oads/detail?name=ADPCM-Kalms-2.1.zip&can=2&q=
Reloaded
Member
#23 - Posted: 4 Mar 2012 13:35
Reply Quote
Thanks bstrr, I was blind. It works perfectly :)
 Page:  ««  1  2  

  Please register a new account or log in to comment

  

  

  

 

A.D.A. Amiga Demoscene Archive, Version 3.0