![]() |
![]() |
#381 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,356
|
No, it's just a minor shortcoming.
Yeah. Actually, Atari monitor ![]() Quote:
![]() Mine is close to fitting. A few words less and we're ok. But i couldn't get them ![]() Anyway, 5:3 does fit. Quote:
Yeah, the only method is to actually do it. |
||
![]() |
![]() |
#382 | ||
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,854
|
Do you hear it when you turn the volume up?
A piece of music from CD. Quite clean. Doesn't sound noisy at all. Sox down samples great, as usual. Extremely little quantization noise, but averaging produces quite a lot. How audible it is will vary based on the kind of music, and the passage, of course. Quote:
Quote:
Code:
.loop ; 00000111 movem.w (a0)+,a3-a6 ; samples 0, 1, 2 and 3 move.l a3,d0 add.l d0,d0 add.l a4,d0 add.l d0,d0 add.l a3,d0 add.l a4,d0 asr.l #3,d0 ; write move.l d6,a3 add.l d0,a3 add.l d0,a3 move.b (a3)+,(a1)+ ; high move.b (a3)+,(a2)+ ; low ; 11222223 move.l a5,d0 add.l d0,d0 add.l a4,d0 add.l d0,d0 add.l a5,d0 add.l a6,d0 asr.l #3,d0 ; write move.l d6,a3 add.l d0,a3 add.l d0,a3 move.b (a3)+,(a1)+ ; high move.b (a3)+,(a2)+ ; low ; 33334444 move.l a6,d0 movem.w (a0)+,a3-a6 ; samples 4, 5, 6 and 7 add.l a3,d0 asr.l #1,d0 move.l a3,d1 ; write move.l d6,a3 add.l d0,a3 add.l d0,a3 move.b (a3)+,(a1)+ ; high move.b (a3)+,(a2)+ ; low ; 45555566 move.l a4,d0 add.l d0,d0 add.l a5,d0 add.l d0,d0 add.l a4,d0 add.l d1,d0 asr.l #3,d0 ; write move.l d6,a3 add.l d0,a3 add.l d0,a3 move.b (a3)+,(a1)+ ; high move.b (a3)+,(a2)+ ; low ; 66677777 move.l a6,d0 add.l d0,d0 add.l d5,d0 add.l d0,d0 add.l a5,d0 add.l a6,d0 asr.l #3,d0 ; write move.l d6,a3 add.l d0,a3 add.l d0,a3 move.b (a3)+,(a1)+ ; high move.b (a3)+,(a2)+ ; low ; next subq.l #1,d7 bne .loop |
||
![]() |
![]() |
#383 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,356
|
I don't turn the volume up too much. If you tested monitors sound this way, not surprising you got bad results - they're simply not meant for this use.
Only thing i can say is that i don't hear it for normal volume levels - by the way, do you hear it when you don't turn the volume up ? Quote:
![]() Do you still have the code or some (badly) downsampled piece of music, so that i can hear the damage too ? Quote:
Just put as many instructions not accessing memory after every write. |
||
![]() |
![]() |
#384 | ||||
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,854
|
Quote:
Quote:
It causes quantization noise. When you just calculate the average, there's nothing you can do about it. Quote:
![]() It wants 16 bit signed little endian interleaved raw data, and outputs 16 bit big endian interleaved raw data at half the frequency. Play16 pars: signed paula14c freq=22050 tracks=2 bits=16. Code:
incdir "680x0:" a lea wav,a0 lea b,a1 move.l #2^20>>2,d7 clr.l d0 clr.l d1 clr.l d2 clr.l d3 .loop ; read samples movem.w (a0)+,d0-d3 rol.w #8,d0 rol.w #8,d1 rol.w #8,d2 rol.w #8,d3 ext.l d0 ext.l d1 ext.l d2 ext.l d3 add.l d2,d0 add.l d3,d1 asr.l #1,d0 asr.l #1,d1 move.w d0,(a1)+ move.w d1,(a1)+ subq.l #1,d7 bne .loop rts section data,data_f wav incbin "test.raw" section data2,bss_f b ds.b 512*1024 Quote:
Wouldn't it be better to try and spread them as evenly as possible? |
||||
![]() |
![]() |
#385 | |||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,356
|
Quote:
Quote:
Quote:
There are a number of clocks to fulfill after each write. As long as it's not full, where the instructions are doesn't matter. The trick is to have as few register-only instructions as possible out of these areas. |
|||
![]() |
![]() |
#386 | ||
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,854
|
Quote:
Averaging is a cheap method that gives mediocre results. It works much better for image down sampling, where the only real problem is that you can get Moire effects, and you often don't get those. Quote:
You probably can, yes, but it still won't be optimal. This thing sure is a pain ![]() Okay, that's pretty clear. |
||
![]() |
![]() |
#387 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,356
|
Quote:
The lower it is, the better the job you have to do to get a decent result. So 22.05 is too low. I don't think you're gonna get much noise in down sampling 88khz to 44... Quote:
Code:
.loop movem.w (a0)+,d0-d1/d3/d6 ; l0, r0, l1, r1 move.l d0,d4 add.l d0,d4 add.l d0,d4 add.l d3,d4 add.l d3,d4 divs #5,d4 move.w (a3,d4.w*2),d4 ; 00011 move.b d4,(a2)+ lsr.w #8,d4 move.l d1,d7 add.l d1,d7 add.l d1,d7 move.b d4,(a1)+ add.l d6,d7 add.l d6,d7 movem.w (a0)+,d0-d1/d4-d5 ; l2, r2, l3, r3 divs #5,d7 move.w (a3,d7.w*2),d7 move.b d7,(a6)+ add.l d4,d3 add.l d0,d3 add.l d0,d3 add.l d0,d3 lsr.w #8,d7 divs #5,d3 move.b d7,(a4)+ add.l d5,d6 add.l d1,d6 add.l d1,d6 add.l d1,d6 divs #5,d6 move.w (a3,d3.w*2),d3 ; 12223 move.w (a3,d6.w*2),d6 movem.w (a0)+,d0-d1 move.b d3,(a2)+ lsr.w #8,d3 add.l d4,d4 add.l d0,d4 add.l d0,d4 add.l d0,d4 divs #5,d4 move.b d3,(a1)+ add.l d5,d5 add.l d1,d5 add.l d1,d5 add.l d1,d5 divs #5,d5 move.w (a3,d4.w*2),d4 ; 33444 move.w (a3,d5.w*2),d5 move.b d6,(a6)+ lsr.w #8,d6 move.b d6,(a4)+ move.b d4,(a2)+ lsr.w #8,d4 move.b d4,(a1)+ move.b d5,(a6)+ lsr.w #8,d5 move.b d5,(a4)+ subq.l #1,d2 bgt.s .loop |
||
![]() |
![]() |
#388 | |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
Quote:
What they could do instead is do A/D to a higher bit width, say 12 bit, and then use error diffusion when dropping down to their 8 bit output. I have been pondering writing a sample converter myself, using this sort of technique. When averaging to do 2:1 downsampling, the result is really 9 bit, so you have 1 bit of error you need to diffuse, which shouldn't be too difficult. Just keep the bit shifted out and add it onto the next 9-bit total. |
|
![]() |
![]() |
#389 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,356
|
Quote:
|
|
![]() |
![]() |
#390 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
i would have thought you would need very good speakers to hear that kind of noise, but you know audiophiles... professional software does to this sort of thing, often working from a 32 bit master, so presumably someone can hear the difference (even floating point is used, for some reason, well we can ponder the wisdom of that...)
|
![]() |
![]() |
#391 | |||
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,854
|
Quote:
![]() Quote:
Quote:
You can hear quantization noise with 45 euro headphones from a good brand, and 150 euro stereo amp. |
|||
![]() |
![]() |
#392 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,356
|
|
![]() |
![]() |
#393 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,854
|
Yeah, I figured something like that
![]() Probably can't be done without refactoring, then. You can either write the data non-interleaved, or sign extend to 32bit and write that to the intermediate buffers. Last one is probably the easiest, but I don't know how much of a difference it will make. Either way, it won't happen without some changes, as much of a pain it might be. |
![]() |
![]() |
#394 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,356
|
Quote:
The best way is probably giving the user the option to change the buffer size, but then any size must be supported. Quote:
Sign extend to 32 bit probably wouldn't help much. I read data with movem.w, which does that sign extend on the fly. |
||
![]() |
![]() |
#395 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,854
|
Quote:
![]() ![]() ![]() Code:
.loop ;00000111 d0/d1 = 0 d2/d3 = 1 movem.w (a0)+,d0-d3 move.l d0,d6 lsl.l #2,d0 add.l d0,d6 add.l d2,d6 add.l d2,d2 add.l d2,d6 asr.l #3,d6 lea (a5,d6.w*2),a6 move.b (a6)+,(a1)+ move.b (a6)+,(a2)+ move.l d1,d6 lsl.l #2,d1 add.l d1,d6 add.l d3,d6 add.l d3,d3 add.l d3,d6 asr.l #3,d6 lea (a5,d6.w*2),a6 move.b (a6)+,(a3)+ move.b (a6)+,(a4)+ ;11222223 d2/d3 = 2 * 1 d0/d1 = 2 d4/d5 = 3 movem.w (a0)+,d0-d1/d4-d5 add.l d0,d2 lsl.l #2,d0 add.l d0,d2 add.l d4,d2 asr.l #3,d2 lea (a5,d2.w*2),a6 move.b (a6)+,(a1)+ move.b (a6)+,(a2)+ add.l d1,d3 lsl.l #2,d1 add.l d1,d3 add.l d5,d3 asr.l #3,d3 lea (a5,d3.w*2),a6 move.b (a6)+,(a3)+ move.b (a6)+,(a4)+ ;33334444 d4/d5 = 3 d0/d1 = 4 d2/d3 = 5 movem.w (a0)+,d0-d3 add.l d0,d4 asr.l #1,d4 lea (a5,d4.w*2),a6 move.b (a6)+,(a1)+ move.b (a6)+,(a2)+ add.l d1,d5 asr.l #1,d5 lea (a5,d5.w*2),a6 move.b (a6)+,(a3)+ move.b (a6)+,(a4)+ ;45555566 d0/d1 = 4 d2/d3 = 5 add.l d2,d0 lsl.l #2,d0 add.l d2,d0 add.l d3,d1 lsl.l #2,d1 add.l d3,d1 movem.w (a0)+,d2-d5 ; d2/d3 = 6 d4/d5 = 7 add.l d2,d0 add.l d2,d0 asr.l #3,d0 lea (a5,d0.w*2),a6 move.b (a6)+,(a1)+ move.b (a6)+,(a2)+ add.l d3,d1 add.l d3,d1 asr.l #3,d1 lea (a5,d1.w*2),a6 move.b (a6)+,(a3)+ move.b (a6)+,(a4)+ ;66677777 d2/d3 = 6 d4/d5 = 7 move.l d4,d0 add.l d0,d0 add.l d2,d0 add.l d0,d0 add.l d2,d0 add.l d4,d0 asr.l #3,d0 lea (a5,d0.w*2),a6 move.b (a6)+,(a1)+ move.b (a6)+,(a2)+ move.l d5,d1 add.l d1,d1 add.l d3,d1 add.l d1,d1 add.l d3,d1 add.l d5,d1 asr.l #3,d1 lea (a5,d1.w*2),a6 move.b (a6)+,(a3)+ move.b (a6)+,(a4)+ subq.l #1,d7 bne .loop |
|
![]() |
![]() |
#396 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,356
|
Quote:
![]() |
|
![]() |
![]() |
#397 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,356
|
I did the "move some code around" and made the code a little shorter as well.
Normally it should work ![]() Code:
.loop movem.w (a0)+,d0-d1/d3-d6 ; d0=0l, d1=0r, d3=1l, d4=1r, d5=2l, d6=2r move.l d3,d7 ; d0=0, d7=1 add.l d0,d7 ; d7=01 add.l d7,d0 ; d0=001 add.l d0,d0 ; d0=000011 add.l d7,d0 ; d0=00000111 lsr.l #3,d0 lea (a3,d0.w*2),a5 move.b (a5)+,(a1)+ ; l hi move.b (a5)+,(a2)+ ; l lo move.l d4,d7 add.l d1,d7 add.l d7,d1 add.l d1,d1 add.l d7,d1 lsr.l #3,d1 lea (a3,d1.w*2),a5 move.b (a5)+,(a4)+ ; r hi add.l d3,d3 ; d3=11 add.l d5,d3 ; d3=112 lsl.l #2,d5 ; d5=2222 add.l d5,d3 ; d3=1122222 add.l d4,d4 add.l d6,d4 lsl.l #2,d6 add.l d6,d4 movem.w (a0)+,d0-d1/d5-d7 ; d0=3l, d1=3r, d5=4l, d6=4r, d7=5l move.b (a5)+,(a6)+ ; r lo add.l d0,d3 ; d3=11222223 add.l d1,d4 lsr.l #3,d3 lsr.l #3,d4 lea (a3,d3.w*2),a5 move.b (a5)+,(a1)+ move.b (a5)+,(a2)+ lea (a3,d4.w*2),a5 move.b (a5)+,(a4)+ move.b (a5)+,(a6)+ add.l d5,d0 ; d0=34 lsr.l #1,d0 ; d0=33334444 (34 <<2 >>3) lea (a3,d0.w*2),a5 move.b (a5)+,(a1)+ move.b (a5)+,(a2)+ add.l d6,d1 lsr.l #1,d1 lea (a3,d1.w*2),a5 move.b (a5)+,(a4)+ add.l d7,d5 ; d5=45 lsl.l #2,d7 ; d7=5555 add.l d7,d5 ; d5=455555 (l) movem.w (a0)+,d0-d1/d3-d4/d7 ; d0=5r, d1=6l, d3=6r, d4=7l, d7=7r move.b (a5)+,(a6)+ add.l d1,d5 ; 4555556 add.l d1,d5 ; 45555566 lsr.l #3,d5 lea (a3,d5.w*2),a5 move.b (a5)+,(a1)+ move.b (a5)+,(a2)+ add.l d0,d6 ; d6=45 add.l d0,d0 ; d0=55 add.l d3,d0 ; d0=556 add.l d0,d0 ; d0=555566 add.l d6,d0 ; d0=45555566 lsr.l #3,d0 lea (a3,d0.w*2),a5 move.b (a5)+,(a4)+ move.b (a5)+,(a6)+ add.l d4,d1 ; d1=67, d4=7 add.l d1,d4 ; d1=67, d4=677 add.l d4,d4 ; d1=67, d4=667777 add.l d4,d1 ; d1=66677777 lsr.l #3,d1 lea (a3,d1.w*2),a5 move.b (a5)+,(a1)+ move.b (a5)+,(a2)+ add.l d7,d3 add.l d3,d7 add.l d7,d7 add.l d7,d3 lsr.l #3,d3 lea (a3,d3.w*2),a5 move.b (a5)+,(a4)+ move.b (a5)+,(a6)+ subq.l #1,d2 bgt .loop |
![]() |
![]() |
#398 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,854
|
|
![]() |
![]() |
#399 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,356
|
Good enough, apparently. How it compares to other methods is another thing and for this, i've zoned something for you. You will find several versions of my (command-line only) sound player in the archive. Feed them with some 44100 16bit stereo wave or aiff and enjoy the result (or not
![]() These versions differ by something. I'm not telling who's who for not introducing psychologic bias in the test ![]() |
![]() |
![]() |
#400 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,854
|
Quote:
I'm willing to bet that: spl-a = 8:5 spl-b = not down sampled spl-c = 5:3 spl-d = 2:1 Note: Your player doesn't handle the WAV I tried and had to convert it to AIFF. The WAV plays fine in HippoPlayer. |
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Starting ASM coding on A1200. Which Assembler? | Nosferax | Coders. Asm / Hardware | 68 | 27 November 2015 16:14 |
4th tutorial on ASM- and HW-coding | Vikke | Coders. Asm / Hardware | 11 | 10 April 2013 20:32 |
3rd tutorial on ASM- and HW-coding | Vikke | Coders. Asm / Hardware | 6 | 26 March 2013 15:57 |
First tutorial on ASM- and HW-coding | Vikke | Coders. Asm / Hardware | 46 | 18 March 2013 12:33 |
2nd tutorial on ASM- and HW-coding | Vikke | Coders. Asm / Hardware | 10 | 17 March 2013 11:49 |
|
|