18 March 2021, 21:18 | #1 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
Question about the 14-bit Paula trick
I don't fully understand how I convert a signed 16-bit PCM sample into an 8-bit pair for 14-bit Paula output...
I have played around with it a bit, and the only way I can make it sound good is by doing this: Code:
move.w d0,d1 ; d1 = -32768..32767 lsr.b #2,d1 ; hi byte = normal sample, lo byte = low-vol (vol 1) sample Can anyone explain why this is? And maybe I'm doing it all wrong? |
18 March 2021, 21:34 | #2 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
The sign bit is only on bit 15, on bit 7 there some lower significance part of the 16 bit signed integer.
So it is sure better a logical than an arithmetic shift for the lower byte. |
18 March 2021, 21:36 | #3 | |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
Quote:
So ideally I should insert the sign bit in bit 6 and 7 after the lsr? EDIT: How about just subtracting 32 from d1.b? Is that correct? Last edited by 8bitbubsy; 18 March 2021 at 21:57. |
|
18 March 2021, 21:48 | #4 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
I don't think it makes a difference, just a little bias in the signal.
Test by ear if it's different for you |
18 March 2021, 22:07 | #5 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
Seems like the 0..63 range is correct, or at least anything else I try makes it sound (and look) wrong. So maybe the "lower 6 bits" part just shouldn't be signed (-32..31).
This is a bit confusing to me, though! |
18 March 2021, 22:19 | #6 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
Well it actually makes sense, you are always adding-up at the most significant part of the sample, you surely generate all the valid 2^14 theoretical combinations, in a linear way.
For simplicity try to think how it work around the zero point and you will see that make sense. |
19 March 2021, 08:45 | #7 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Following code converts 16-bit sample to the 8-bit pair :
Code:
; d3=16-bit sample -> d4=high byte, d5=low byte move.w d3,d4 eori.w #$8000,d4 bpl.s .pos1 neg.w d4 .pos1 move.b d4,d5 lsr.w #8,d4 lsr.b #2,d5 tst.w d3 bpl.s .pos2 neg.b d4 neg.b d5 .pos2 Also note that the 14-bit trick works best if calibrated (in that case, the code becomes a lot more complicated). In any case, better use a table. |
19 March 2021, 09:03 | #8 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
I'll try it and see how it works out.
Regarding calibration, that requires unique calibration per Amiga machine, right? If not, then no problem, the stuff I'm doing is already for generating a LUT. The reason I want it to be fast is because I am calculating a lot of LUT entries, but precision is more important. |
19 March 2021, 09:12 | #9 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Yes it needs unique calibration per Amiga machine.
|
19 March 2021, 09:13 | #10 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
Alright, I'm not going to bother with the calibration then.
|
19 March 2021, 09:22 | #11 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
|
19 March 2021, 09:56 | #12 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
But I thought you weren't supposed to store the lower 6 bits as signed -32..31?
|
19 March 2021, 10:03 | #13 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
Quote:
Why did the coder do such a thing? Maybe it sounded better in his equipment And has been proven there are many ways to generate a '14-bit' signal on the Amiga and none of them bring perfect results yet. So the method used in the first message is no more wrong than the others |
|
19 March 2021, 10:09 | #14 |
Registered User
Join Date: Sep 2009
Location: Norway
Posts: 1,711
|
Ah, so maybe it's stored as -63..0?
|
19 March 2021, 10:21 | #15 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,474
|
In this case, yes.
But, it seems better to me, for a 16-bit signed sample, to use values from 0 to 63 in the lowest byte. In a perspective of pure additive mixing it seems fair that the low byte 'fills' the gap between the magnitude higher bytes, that have 64x_volume than the low. But it is absolutely not certain that I'm right, indeed I would like to have the opinion of others. |
19 March 2021, 11:17 | #16 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
Code:
move.w (a0)+,d0 ; our sample move.w (a3,d0.w*2),d0 move.b d0,(a2)+ ; low lsr.w #8,d0 move.b d0,(a1)+ ; high |
|
19 March 2021, 13:05 | #17 |
Registered User
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,153
|
Just in case you're not already aware of this document, it might be useful:
http://bax.comlab.uni-rostock.de/dl/...mTheoretic.pdf |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
double Copper trick question.. | mateusz_s | Coders. Blitz Basic | 14 | 21 October 2021 13:33 |
24-bit + Picasso96 (stupid question) | studiox | support.WinUAE | 10 | 22 July 2011 14:58 |
Question about 32-bit ram | sink | support.WinUAE | 7 | 12 January 2011 12:02 |
Simple 14 bit audio question... | Thorham | Coders. General | 7 | 06 June 2010 10:55 |
32 and 64 bit sprite control words question | FrenchShark | Coders. General | 8 | 10 January 2008 02:32 |
|
|