Digital audio boosting examples

Basic and Machine Language

Moderator: Moderators

User avatar
pixel
Vic 20 Scientist
Posts: 1345
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Digital audio boosting examples

Post by pixel »

Here're the boosters as promised:

HF carriers

The idea behind these is to turn on a sound channel with a frequency so high that it can't possibly make it through your audio equipment but still increases the voltage levels. The highest frequencies are generated by the soprano channel, depending on the TV standard you're nailed to it gives you a little less then a EDIT:????kHz (to tired to figure it out ATM) pulse wave.

But as Viznut discovered 12 years ago you can program the tone–generating 8–bit shift registers down to the bit a bit. That's what these boosters do to get some pulses as short as 4 clock cycles. See also http://www.pelulamu.net/pwp/vic20/waveforms.txt

All HF carrier boosters use this routine to clear the bits in the soprano channel:

Code: Select all

boost0:
    ldx #$7e	; Max. shift rate, channel turned off.
    stx $900b
    stx $900c
    ldy #0
l:  dey
    bne -l
    lda #$fe		; Max. shift rate channel turned on.
    rts
Booster #1 uses a 001101 waveform init:

Code: Select all

boost1:
    jsr boost0
    stx $900c
    stx $900c
    sta $900c
    sta $900c
    stx $900c
    sta $900c
    rts
Booster #2 inits with 001001:

Code: Select all

boost2:
    jsr boost0
    stx $900c
    stx $900c
    sta $900c
    stx $900c
    stx $900c
    sta $900c
    rts
Booster #3 tries 0101, resulting in longer sub–pulses:

Code: Select all

boost3:
    jsr boost0
    stx $900c
    sta $900c
    stx $900c
    sta $900c
    rts
Two channels interleaved

The idea here is to run two channels, soprano and tenor at the same frequency but half a pulse apart from each other, so if one channel is off the other is on. Pretty much like phasing out each other but with the opposite result intended: a steady, strong signal. If things were that simple...

Code: Select all

boost4:
    lda #$fe                                                                                                                                                  
    pha
    lda #$7e	; Clear tenor and soprano channel.
    sta $900b
    sta $900c
    ldy #0
l:  dey
    bne -l
    ldy #5
    lda #$fd		
    sta $900c	; Soprano to half of its maximum frequency.
l:  dey		; Wait 32 cycles (half a pulse).
    bne -l                                                                        
    pla
    sta $900b	; Tenor to highest frequency, same as soprano.
    rts
If this thing could be made to work, that would be the strongest boost possible.

The most simple solution

As beauty lies in simplicty or something like that... I guess this gives a >34kHz tone, doesn't it?

Code: Select all

boost5:
	jsr boost0
	sta $900c
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
Mike
Herr VC
Posts: 4832
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Digital audio boosting examples

Post by Mike »

That's a nice example, where it definitely makes no sense to even try to tell the differences in emulation: those high frequencies of the carrier supposedly lead to bad aliasing with the sample frequency of the PC's audio hardware. On the PC, I can hear the (aliased) carrier in all examples, but #4 is especially bad.
pixel wrote:Two channels interleaved

The idea here is to run two channels, soprano and tenor at the same frequency but half a pulse apart from each other, so if one channel is off the other is on. Pretty much like phasing out each other but with the opposite result intended: a steady, strong signal. If things were that simple...
Yes. Probably the phase between the two voices isn't still quite right, resulting in residual spikes. I can connect the audio output of my VIC-20 to a good scope, and check which phase (in machine cycles between the two STx instructions) is needed to make those spikes disappear. If all goes well I can tell you the results on Friday evening.

Cheers,

Michael

P.S. http://sleepingelephant.com/ipw-web/bul ... 2&start=11 ;)
User avatar
pixel
Vic 20 Scientist
Posts: 1345
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Digital audio boosting examples

Post by pixel »

Mike wrote:That's a nice example, where it definitely makes no sense to even try to tell the differences in emulation: those high frequencies of the carrier supposedly lead to bad aliasing with the sample frequency of the PC's audio hardware. On the PC, I can hear the (aliased) carrier in all examples, but #4 is especially bad.
Yeah, that's why I was asking for real VIC tests in the poll. VICE gave me some ringing in my ears as well. But hey! This is new…
pixel wrote:Two channels interleaved

The idea here is to run two channels, soprano and tenor at the same frequency but half a pulse apart from each other, so if one channel is off the other is on. Pretty much like phasing out each other but with the opposite result intended: a steady, strong signal. If things were that simple...
Yes. Probably the phase between the two voices isn't still quite right, resulting in residual spikes. I can connect the audio output of my VIC-20 to a good scope, and check which phase (in machine cycles between the two STx instructions) is needed to make those spikes disappear. If all goes well I can tell you the results on Friday evening.
I wouldn't be astonished if there'd still be spikes even with cycle counts corrected. Am looking forward to your results! :)
Duh! You let the community live with low–volume digisound all those years!? Shame on you! ;)
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
Mike
Herr VC
Posts: 4832
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Digital audio boosting examples

Post by Mike »

pixel wrote:I wouldn't be astonished if there'd still be spikes even with cycle counts corrected. Am looking forward to your results! :)
If I even get to see those spikes over the noise. They could be as short as 1 µs, so most probably won't come over the low-pass circuit, regardless if it is at its standard 1,6 kHz or modded to 16 kHz by putting in a 10 nF capacitor. However ...

Code: Select all

    sta $900c   ; Soprano to half of its maximum frequency.
l:  dey      ; Wait 32 cycles (half a pulse).
... shouldn't that be 64 cycles? Soprano at full frequency puts out 8 high-bits at 4 µs each, then 8 low-bits at 4 µs each. But you use soprano at half max. frequency, so the period is 128 cycles.

No wonders the current version is so loud. It actually produces a 3-step-'triangle'-curve, like this: "_--¯--_--¯--". And this is clearly audible at ~8 kHz.
Duh! You let the community live with low–volume digisound all those years!? Shame on you! ;)
Heh! I'm not the maid-of-all-work. :mrgreen:
User avatar
pixel
Vic 20 Scientist
Posts: 1345
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Digital audio boosting examples

Post by pixel »

Mike wrote:
pixel wrote:I wouldn't be astonished if there'd still be spikes even with cycle counts corrected. Am looking forward to your results! :)
If I even get to see those spikes over the noise. They could be as short as 1 µs, so most probably won't come over the low-pass circuit, regardless if it is at its standard 1,6 kHz or modded to 16 kHz by putting in a 10 nF capacitor. However ...
Can provide you with a version with silence. No problem.

Code: Select all

    sta $900c   ; Soprano to half of its maximum frequency.
l:  dey      ; Wait 32 cycles (half a pulse).
... shouldn't that be 64 cycles? Soprano at full frequency puts out 8 high-bits at 4 µs each, then 8 low-bits at 4 µs each. But you use soprano at half max. frequency, so the period is 128 cycles.
Yeah, right. Complete turnover. Am daft as toast with no sleep. :( Uploaded one with 64 cycles.

Code: Select all

boost4:
    pha
    lda #$7e
    sta $900b
    sta $900c
    ldy #0
l:  dey
    bne -l
    ldy #12
    lda #$fd
    sta $900c
l:  dey
    bne -l
    pla
    sta $900b
    rts
Mike wrote:No wonders the current version is so loud. It actually produces a 3-step-'triangle'-curve, like this: "_--¯--_--¯--". And this is clearly audible at ~8 kHz.
The notion "ear piercing" came to mind… More luck with the new version?
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
Mike
Herr VC
Posts: 4832
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Digital audio boosting examples

Post by Mike »

pixel wrote:Can provide you with a version with silence. No problem.
:lol: I really didn't refer to the nice Saxophone Jam sample you put in.

Actually I meant the residual noise that would be present even when a silent sample was output, due to bus activity, etc.

Unfortunately, at least in VICE the carrier is still audible even with your updated version. ...?
User avatar
pixel
Vic 20 Scientist
Posts: 1345
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Digital audio boosting examples

Post by pixel »

Didn't subtract three cycles in the new snippet. Just a minute...
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
pixel
Vic 20 Scientist
Posts: 1345
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Digital audio boosting examples

Post by pixel »

Hold it! More to the left! No, more to the right! Y…Y… Phoaarrh! Yesss! Right there:

Code: Select all

boost4:
    lda #$7e
    sta $900b
    sta $900c
    ldy #0
l:  dey
    bne -l
    ldy #11
    lda #$fd
    sta $900c
l:  dey
    bne -l
    nop
    nop
    nop                                                                                                                                                       
    lda #$fe
    sta $900b
    rts
That should do! :mrgreen:

VICE squeaks but that really sounds like aliasing. :D
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
pixel
Vic 20 Scientist
Posts: 1345
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Digital audio boosting examples

Post by pixel »

Forgot to mention: the test program has been updated, of course, just in case somebody wants to confirm the dawn of new frontiers in VIC audio. ;)
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
Mike
Herr VC
Posts: 4832
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Digital audio boosting examples

Post by Mike »

I also was taking a look into this in the meantime. For the "main"-part:

Code: Select all

 LDA #$FD
 STA $900C
 LDX #11
.loop
 DEX
 BNE loop
 NOP
 LDA #$FE
 STA $900B
... here, the fourth cycle of the second STA (where the write access happens) is scheduled to commence exactly 64 cycles later than that of the first STA.

Could you also try out this and compare?
User avatar
pixel
Vic 20 Scientist
Posts: 1345
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Digital audio boosting examples

Post by pixel »

Mike wrote:

Code: Select all

 LDA #$FD
 STA $900C
 LDX #11
.loop
 DEX
 BNE loop
 NOP
 LDA #$FE
 STA $900B
... here, the fourth cycle of the second STA (where the write access happens) is scheduled to commence exactly 64 cycles later than that of the first STA.

Could you also try out this and compare?
It's basically what I just did. Just more terse. :p Same effect. Congrats! :mrgreen: And uploaded.

You just have to love this community…
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
pixel
Vic 20 Scientist
Posts: 1345
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Digital audio boosting examples

Post by pixel »

Somebody please solder a capacitor into VICE. :lol:
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
pixel
Vic 20 Scientist
Posts: 1345
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Digital audio boosting examples

Post by pixel »

pixel wrote:Somebody please solder a capacitor into VICE. :lol:
EDIT: As always: thanks a million, Mike! I think I'll just unmount my head with a gallon of quality beer to celebrate. :mrgreen:
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
User avatar
pixel
Vic 20 Scientist
Posts: 1345
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re: Digital audio boosting examples

Post by pixel »

pixel wrote:
pixel wrote:Somebody please solder a capacitor into VICE. :lol:
EDIT: As always: thanks a million, Mike! I think I'll just unmount my head with a gallon of quality beer to celebrate. :mrgreen:
EDIT: Oh, I see, I missed the 1-off because of the last branch not taken. Great! I call computer time off for today. It's gonna be a 28h journey tomorrow (if I calculated it right ;) )
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: Digital audio boosting examples

Post by Boray »

Does this sound as good as only using the volume register, but just louder? Have you tried sampling the output and looked at the waveform?
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Post Reply