Digitized sound + 2 spare channels possible?

Basic and Machine Language

Moderator: Moderators

Post Reply
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Digitized sound + 2 spare channels possible?

Post by matsondawson »

I was wondering if you set two channels up with the same frequency but 180 degrees out of phase with each other, would changing volume on both channels in tandem produce analogue levels?
Thus leaving 1 noise channel and 1 tone channel free for music?
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Unless you 'program' one of Viznut's new waveforms, the tone generators of the VIC output square waves. Two of them with the same frequency, but 180 degrees out of phase will cancel out each other completely. There's only one volume register which applies to all voices. So it's not quite clear to me how you'd been going to produce analogue levels.

You can de-tune two voices slightly (taking their octave difference into account), which results in a beat. The resulting amplitude envelope might suggest it should be possible to attenuate volume levels continuosly - but it's really only an aural illusion.

My bet's still on PCM over the volume register (as has been done with Sid Vicious, Berzerk MMX+ and Pulse Sounds). ;)
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

Whoops, for some reason I was thinking each channel had its own volume. what operation does the vic use for mixing channels?
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

They are simply added. However, with high values of the volume register and two or more voices activated, clipping might occur.
User avatar
darkatx
Vic 20 Afficionado
Posts: 470
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Post by darkatx »

I remember experimenting with the same voice playback program for the c64 and I played it thru the voice register not the volume to see if it would work and it actually did?! Think Triangle or Square sounded best?
I just pumped the same 4 bit samples and even tried proper 8 bit as well - just experimenting with the program a little y'know?
It was thrilling to hear about 10 seconds of Star Wars 'fanfare' being played back on the Commy. Not too sure how the Vic would hold up but it can't hurt to play around and see.
:)
Learning all the time... :)
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

Mike wrote:They are simply added. However, with high values of the volume register and two or more voices activated, clipping might occur.
I wish I could up-vote that link! It explains why you can play analogue levels by changing the volume register. Namely because "The voltage for the 0 state when stopped is somewhere between the low and high on states, not quite half way but biased slightly towards the low side. "
What a lucky bug to have in the hardware.
I've updated my emulator code to correctly emulate that feature now (before it was hacked in).
Last edited by matsondawson on Fri Mar 23, 2012 7:28 pm, edited 1 time in total.
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

Actually you may be able to get a little more precision doing DAC by...

1/ Assuming the four channels outputs when off sum to a relative value of 1.8 (4*0.45) once they reach the volume section, that would give us 0->27 in steps of 1.8

2/ Setting two channels 180 degrees out of phase then switching between them when they are at their MAXIMUM values to produce a 2.35 (1 + 3 * 0.45) to the volume register producing 0->35.25 in steps of 2.35

3/ Setting two channels 180 degrees out of phase then switching between them when they are at their MINIMUM values to produce a 1.35 (0 + 3 * 0.45) to the volume register producing 0->20.25 in steps of 1.35


The values I've picked are just relative to each other and not real values.
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

I guess this all depends on whether the channels still generate a wave internally when they are off.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Internally, the square wave sound generators are realised as 8-bit LFSR. When they're active, one bit is shifted out, inverted, output and inserted at the other end, at the rate programmed with the low 7 bits of the frequency register (and taking the octaves into account).
matsondawson wrote:I guess this all depends on whether the channels still generate a wave internally when they are off.
When the enable bit is set to 0, only zeroes are output and inserted at the other end. This purges the LFSR within 8 steps. :(

However, Viznut's new waveforms are exactly generated this way, by starting off with a purged LFSR and then quickly switching the voice at the highest frequency on and off for 8 times - and then changing to the desired frequency. So the sound generator doesn't anymore output '1111111100000000' but rather something like '1011110101000010'. Once the waveform is 'programmed', the frequency can be changed without problems, as long as the voice remains enabled.
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

Are you sure it's an 8 bit LSFR? That would have a maximum sequence of 255 values. In the VICE source it has a 1024 x 8 bit lookup (8192 bits), which suggests a 13bit LFSR. Not to say that vice is correct at all.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

matsondawson wrote:In the VICE source it has a 1024 x 8 bit lookup (8192 bits), which suggests a 13bit LFSR.
That's the noise generator.
User avatar
pixel
Vic 20 Scientist
Posts: 1328
Joined: Fri Feb 28, 2014 3:56 am
Website: http://hugbox.org/
Location: Berlin, Germany
Occupation: Pan–galactic shaman

Re:

Post by pixel »

Mike wrote:
matsondawson wrote:In the VICE source it has a 1024 x 8 bit lookup (8192 bits), which suggests a 13bit LFSR.
That's the noise generator.
This is odd. The noise generator doesn't look very different on the die shot at http://visual6502.org/images/pages/MOS_ ... shots.html
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
Post Reply