Re: Amen brother ~ 6 bit audio @ 16.3kHz
Posted: Fri Sep 04, 2020 7:09 am
At the moment, I've got a (non-VIC) hardware problem preventing me from transferring stuff to my real VIC, but I can't wait to try this.
The Commodore Vic 20 Forum
https://www.sleepingelephant.com/~sleeping/ipw-web/bulletin/bb/
https://www.sleepingelephant.com/~sleeping/ipw-web/bulletin/bb/viewtopic.php?t=8948
Me too. Well, seems to give the regular sound of speakers wrapped up in packs of toilet paper but with less aliasing sound.
Hello Pixel, OK, then it goes public.
REAL MACHINE!!!1!1!!! Just let me finish my tenth Sunday beer and zip the original up for you tomorrow morning....
Had downloaded some Youtube video, extracted the audio as unsigned 8-bit WAV, probably with ffmpeg and them had it go through a lowpass filter with sox to get the frequencies below the Nyquist limit to avoid extra noise. That WAV data then got included as it was, with the 44 byte header cut off and just long enough to form a loop.
Code: Select all
; Play four volumes for each sample value exactly every 17 CPU cycles.
; On PAL the playback rate is 16.3kHz (1108404 / 17 / 4),
; on NTSC it's 15.1kHz (1027270 / 17 / 4).
; The volumes add up from 1 to 60 which makes almost 6-bit quality.
; 0 is used to mark a sample's end.
fill @(- 256 (mod *pc* 256))
play_6bit_audio:
restart:
; Set pointer to start of sample.
lda #<sample
sta @(+ 1 +l)
lda #>sample
sta @(+ 2 +l)
ldx #0 ; Index into sample.
l: ldy sample,x ; 4 Get sample value.
beq -restart ; 2/3 Start over if the sample value is 0.
lda vals0,y ; 4 Get first volume register value for this sample.
sta $900e ; 4 Set HF carrier volume.
inx ; 2 Step to next sample value.
beq +n ; 2/3 Step to next pageβ¦
nop ; 2 (Waste 5 cycles.)
bit $ea ; 3
lda vals1,y ; 4 Set the second volume for this sample.
sta $900e ; 4
bit $ea ; 3 (Waste 9 cycles.)
bit $ea ; 3
bit $ea ; 3
lda vals2,y ; 4 Set the third volume for this sample.
sta $900e ; 4
inc $900f ; 6 Border colour effect.
bit $ea ; 3 (Waste 3 cycles.)
lda vals3,y ; 4 Set the fourth volume for this sample.
sta $900e ; 4
jmp -l ; 3
n: nop ; 2
nop ; 2
lda vals1,y ; 4 Set the second volume for this sample.
sta $900e ; 4
inc @(+ 2 -l) ; 6 Step to next page.
bit $ea ; 3
lda vals2,y ; 4 Set the third volume for this sample.
sta $900e ; 4
inc $900f ; 6 Border colour effect.
bit $ea ; 3 (Waste 3 cycles.)
lda vals3,y ; 4 Set the fourth volume for this sample.
sta $900e ; 4
jmp -l ; 3
; Split up 60 possible sample values into chunks of four 4-bit values
; that'll add up when playing. The chunks are interleaved.
init_6bit_audio:
ldx #0
l: txa
lsr
lsr
tay
jsr mkval
sta vals0,x
jsr mkval
sta vals1,x
jsr mkval
sta vals2,x
jsr mkval
sta vals3,x
inx
bne -l
rts
mkval:
tya
cmp #15
bcs +l
ldy #0
rts
l: sec
sbc #15
tay
lda #15
r: rts
fill @(- 256 (mod *pc* 256))
vals0: fill 256
vals1: fill 256
vals2: fill 256
vals3: fill 256
Which test repo?groepaz wrote: βFri Sep 11, 2020 7:51 am It would be nice to get some recordings from real HW and the programs that were used to produce them (not only for this sample stuff) so i could put them into the test repo. Small dedicated programs that do nothing but play a certain sound that is, games or demos are not very useful as testcases![]()
This one: https://sourceforge.net/p/vice-emu/code ... testprogs/ β heard of it the first time either.
I think we can certainly improve the code as well as the the volume "hack" which allows to set more resolution than the usual 4 Bit for digis. Maybe "even more bits for the great Denial people"?!pixel wrote: βSun Sep 06, 2020 10:22 pm
Am assuming the the playback frequency is just too high because each sample output will take some time to reach it's peak, making the whole thing far too quiet. If there was a regular VIC tone in that piece you recorded, there'd have been blood.Sounds amazing anyhow. How did it come to that fade-out?
We could find out the maximum frequency that makes sense for the loudest output by reading the VICE source code or grabbing an oscilloscope or by asking Mike.Easing up on the sample rate is the only way to mix "new frontiers in VIC graphics" with "new frontiers in VIC audio". Isn't that what we all wanna experience?
...
Yep. And I have quite a couple of ideas already. Unless I don't have the real machine back hacking around further on my end isn't too much of a wise thing.
Is this all VIC or C64?BTW this technique works with my 4 Bit stereo userport DAC and C64 $D418 output too.
Oscilloscope is on the way, until then some pictures showing maybe some approaches for improvement. Enjoy.
AmenBrother-wav
WaveAB.png
Whatβs the problem, dude? Got the Oscilloscope, right here. PM mepixel wrote: βSat Sep 12, 2020 10:48 am I've removed the ear piercing. Would've happened ages ago with a real box but at least VICE got even better.
Also I had a flash of insight (including walls rattling) and came up with a full digi volume blast. Problem again: no real machine. There might be an ear piercer again.Sounds like the missing resampler thing in VICE though. It's really super-******* loud β the music, I mean.
Now what? Be patient and wait for the first post-pandemic demo party or publish again too early?![]()