Volume channel noise?

Basic and Machine Language

Moderator: Moderators

User avatar
R'zo
Vic 20 Afficionado
Posts: 354
Joined: Fri Jan 16, 2015 11:48 pm

Volume channel noise?

Postby R'zo » Sat Jun 24, 2017 6:45 pm

Is there anyway to prevent the noise that is created when you poke the volume chanel.
R'zo
I do not believe in obsolete...

User avatar
Boray
Musical Smurf
Posts: 4024
Joined: Mon May 03, 2004 10:47 am

Re: Volume channel noise?

Postby Boray » Sun Jun 25, 2017 3:18 am

Yes, the pop is bigger the bigger the difference in volume change. So you can do it gradually.

Compare this:

10 FORT=0TO15:POKE36878,T:NEXT
20 FORT=15TO0STEP-1:POKE36878,T:NEXT
30 GOTO10

to this:

10 POKE36878,15:POKE36878,0:GOTO10
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)

User avatar
R'zo
Vic 20 Afficionado
Posts: 354
Joined: Fri Jan 16, 2015 11:48 pm

Re: Volume channel noise?

Postby R'zo » Sun Jun 25, 2017 6:38 am

Boray wrote:Yes, the pop is bigger the bigger the difference in volume change. So you can do it gradually.

Compare this:

10 FORT=0TO15:POKE36878,T:NEXT
20 FORT=15TO0STEP-1:POKE36878,T:NEXT
30 GOTO10

to this:

10 POKE36878,15:POKE36878,0:GOTO10


Is there anyway te prevent it when modulating it dramatically?
Even when modulating byou a value of 1 there's a light buzz.
R'zo
I do not believe in obsolete...

User avatar
Boray
Musical Smurf
Posts: 4024
Joined: Mon May 03, 2004 10:47 am

Re: Volume channel noise?

Postby Boray » Sun Jun 25, 2017 11:54 am

Well, you could always turn the volume down on your monitor... :wink:
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)

User avatar
R'zo
Vic 20 Afficionado
Posts: 354
Joined: Fri Jan 16, 2015 11:48 pm

Re: Volume channel noise?

Postby R'zo » Sun Jun 25, 2017 3:45 pm

Boray wrote:Well, you could always turn the volume down on your monitor... :wink:


I want to write a synth program. I would like to use mudulation on the volume channel for attack, delay and effects. I would also like to use it for recording and maybe live performance. I thought I saw a post on how to avoid the volume channel noise a while back but I can't seem to find it now.
R'zo
I do not believe in obsolete...

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

Re: Volume channel noise?

Postby pixel » Mon Jun 26, 2017 12:31 am

R'zo wrote:I want to write a synth program. I would like to use mudulation on the volume channel for attack, delay and effects. I would also like to use it for recording and maybe live performance. I thought I saw a post on how to avoid the volume channel noise a while back but I can't seem to find it now.

One could write a real-time mixer to play rectangular waveforms via the volume register, perhaps running as a self–modifying NMI routine on the zero page to push up the maximum sample rate. Had something like that but it got lost somewhere on Github. The bass was epic. Make the waveforms fill a 256-byte page each and you should get the algorithm rocking, soon.
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 Nerd
Posts: 868
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/pixel/
Location: various
Occupation: Pan–galactic shaman

Re: Volume channel noise?

Postby pixel » Tue Jun 27, 2017 7:03 am

Here's a little inspiration. :)

Code: Select all

; !!!! QUICK OFFICE BREAK SKETCH !!!! of a 4 channel 4-bit audio sample player.
;
; No special zero page hacks.

sample_rate = 8000
cpu_cycles_pal = 1108404
timer = cpu_cycles_pal / sample_rate   ; PAL

    .data

; Positions in waveform is 16bit but only the high byte is used as a pointer into a 256 byte wave forms.
; That way one gets a 16bit resolution for the frequency!
waveform_position_a:    .word 0
waveform_position_b:    .word 0
waveform_position_c:    .word 0
waveform_position_d:    .word 0

waveform_freq_a:        .word 0
waveform_freq_b:        .word 0
waveform_freq_c:        .word 0
waveform_freq_d:        .word 0

    .code

main:
    jsr disable_nmi_and_other_interrupts
    jsr boost_digital_audio
    jsr start_player
    jmp to_the_application

start_player:
    jsr enable_nmi

    ; Set NMI frequency and start timer.
    lda #<timer
    sta $9114
    lda #>timer
    sta $9115

    ; Set NMI vector.
    lda #<play_audio_sample
    sta $318
    lda #>play_audio_sample
    sta $319

    cli         ; Tell CPU to take interrupts.
    rts

play_audio_sample:
    pha
    txa
    pha

    ; Restart the NMI timer (only setting high byte required).
    lda #>timer
    sta $9115

    ; Add all current 4-bit(!) samples together.
    clc
    ldx waveform_position_a+1
    lda waveform_a,x
    ldx waveform_position_b+1
    adc waveform_b,x
    ldx waveform_position_c+1
    adc waveform_c,x
    ldx waveform_position_d+1
    adc waveform_d,x
   
    ; Divide by 4.
    lsr
    lsr
    lsr
    lsr

    ; Play sample via volume register.                                                                                                                                                                                                                                                     
    sta $900e

    ; Step to next sample of channel A.
    lda waveform_position_a
    clc
    adc waveform_freq_a
    sta waveform_position_a
    lda waveform_position_a+1
    adc waveform_freq_a+1
    sta waveform_position_a+1

    ; Step to next sample of channel B.
    lda waveform_position_b
    clc
    adc waveform_freq_b
    sta waveform_position_b
    lda waveform_position_b+1
    adc waveform_freq_b+1
    sta waveform_position_b+1

    ; Step to next sample of channel C.
    lda waveform_position_c
    clc
    adc waveform_freq_c
    sta waveform_position_c
    lda waveform_position_c+1
    adc waveform_freq_c+1
    sta waveform_position_c+1

    ; Step to next sample of channel D.
    lda waveform_position_d
    clc
    adc waveform_freq_d
    sta waveform_position_d
    lda waveform_position_d+1
    adc waveform_freq_d+1
    sta waveform_position_d+1

    ; Return from NMI.
    pla
    tax
    pla
    rti

boost_digital_audio:
    lda #$fe    ; (Highest frequency on soprano channel.)
    ldx #$7e    ; (Channel off.)

    stx $900c   ; Stop soprano channel.

    ldy #0      ; Wait a couple of cycles.
l:  dey
    bne l

    ; Give soprano a beating.
    stx $900c   ; off
    stx $900c   ; off
    sta $900c   ; on
    sta $900c   ; on
    stx $900c   ; off
    sta $900c   ; on
    rts

enable_nmi:
    lda #$40
    sta $911b
    lda #$c0
    sta $911e
    rts

disable_nmi_and_other_interrupts:
    sei
    lda #$7f
    sta $911e
    sta $912e   ; Perhaps these two could be left out.
    sta $912d
    rts
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose

User avatar
R'zo
Vic 20 Afficionado
Posts: 354
Joined: Fri Jan 16, 2015 11:48 pm

Re: Volume channel noise?

Postby R'zo » Tue Jun 27, 2017 10:34 am

pixel wrote:Here's a little inspiration. :)

[code]; !!!! QUICK OFFICE BREAK SKETCH !!!! of a 4 channel 4-bit audio sample player.


Thank you pixel. It will take me some time to look this over.
I usually have a hard time understanding code written by others but most of this actually makes sense to me :)
R'zo
I do not believe in obsolete...


Return to “Programming”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest