Amen brother ~ 6 bit audio @ 16.3kHz
Moderator: Moderators
- chysn
- Vic 20 Scientist
- Posts: 1204
- Joined: Tue Oct 22, 2019 12:36 pm
- Website: http://www.beigemaze.com
- Location: Michigan, USA
- Occupation: Software Dev Manager
Re: Amen brother ~ 6 bit audio @ 16.3kHz
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.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5
WIP: MIDIcast BASIC extension
he/him/his
WIP: MIDIcast BASIC extension
he/him/his
Re: Amen brother ~ 6 bit audio @ 16.3kHz
Me too. Well, seems to give the regular sound of speakers wrapped up in packs of toilet paper but with less aliasing sound.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: Amen brother ~ 6 bit audio @ 16.3kHz
Hello Pixel, OK, then it goes public.
Yes you are right. Targeted feedback was still missing. Didn't have time to finish the comment.
- Why PM? It is possible that I am wrong and that there could have been misunderstandings. Topics don't always have to be littered with OT.
- So here are my results, suggestions and questions. My programming environment is always the real thing
The continuous tone for boosting only breaks the sound, it's not worth it.
BTW, please let Tom delete the Youtube video, it sounds really bad and it doesn't show the real quality of the routine.
viewtopic.php?f=1&t=8948#p100144
If I understood correctly, all 4 sections in the code are connected, means four bytes represent a 6 bit sample, right?
I think you can get even more out of the code.
I have created a stripped down version that is not precisely fixed for the cycle, but which averages 25.6 Khz playback frequency. But it still sounds clean. Unfortunately I don't have an adapted sample.
With which wave format did you actually do it?
And how did you convert it? Some script?
Anyway, here a version without boosting and a separate wave file, played by the real machine.
Greetings, Noizer
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
-._/classes instead of masses\_.-
Re: Amen brother ~ 6 bit audio @ 16.3kHz
REAL MACHINE!!!1!1!!! Just let me finish my tenth Sunday beer and zip the original up for you tomorrow morning....
EDIT: Amen, brother
EDIT AGAIN: If I wasn't seeing the DC offset I wouldn't believe crap. Very quiet tho.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: Amen brother ~ 6 bit audio @ 16.3kHz
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.
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.

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.


p.s.: I wouldn't bother Tom. And I don't mind if my BS gets documented. Things just evolve. That's how it is and no delete button will change that. Wish I had at least an high school diploma in math...
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: Amen brother ~ 6 bit audio @ 16.3kHz
Due to lack of time here's what I've got laying around at the moment. Didn't track any changes though. Was mostly counting cycles like a hen counting it's chicks. ("Two, four, seven... no hang on, four, seven, eleven... na... six... etc.)
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
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: Amen brother ~ 6 bit audio @ 16.3kHz
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 

I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
Re: Amen brother ~ 6 bit audio @ 16.3kHz
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![]()
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
-._/classes instead of masses\_.-
Re: Amen brother ~ 6 bit audio @ 16.3kHz
This one: https://sourceforge.net/p/vice-emu/code ... testprogs/ – heard of it the first time either.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: Amen brother ~ 6 bit audio @ 16.3kHz
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?
...
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 AmenBother-spectral view In comparision, no Audio output after Runstop restore - spectral In comparision, POKE 36878,15:POKE36877,253 - spectral
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
-._/classes instead of masses\_.-
Re: Amen brother ~ 6 bit audio @ 16.3kHz
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
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: Amen brother ~ 6 bit audio @ 16.3kHz
OK, it's the VIC. I don't get the meaning of the last two images, though. More sleep required. 

A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: Amen brother ~ 6 bit audio @ 16.3kHz
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?

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.

Now what? Be patient and wait for the first post-pandemic demo party or publish again too early?

A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: Amen brother ~ 6 bit audio @ 16.3kHz
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?![]()
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
-._/classes instead of masses\_.-