Next Generation Emulation banner
1 - 2 of 2 Posts

20 Posts
Discussion Starter · #1 ·
Yeah, I'm making a thread about this again.

I've written a new program that sets the GBC Square Wave channels' frequency and volume independently, without using volume envelopes. Normally, you need to reset the waveform in order to change the volume for the square channels.
I've written a test program that calculates the exact time it's okay to reset the phase of the wave with no artifacts, and it resets the wave to change the volume at that time.

The program itself isn't anything special, it just plays a chord of two square waves repeatedly, but it sounds great on hardware, and fails miserably on VBA. I'm about to revise PocketNES to use this method for sound.

The basic algorithm:
You have the Sound Period for the GB channel
Multiply it by 16
That's your timer frequency (Negate it before you use it as a timer reload value obviously)
Add some "fudge" factor to set the initial value of the timer. I'm using 192.
Set the timer's initial value and restart the sound channel at the same time.
When you want to change the sound, enable IRQs for that timer.
The interrupt handler for the timer will wait until the exact instant it should rewrite the sound register. If the timer interrupt triggered too late, wait one more waveform before trying again.

35,081 Posts
Haven't heard from Blaarg in a while, he did mention not wanting to do it, but will end up having to rewrite the audio core for better timing, write/reads and accuracy..... whether this makes it into vba-m is unknown,... might end up going into VBA2
1 - 2 of 2 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.