New sounds

Basic and Machine Language

Moderator: Moderators

Iltanen
Vic 20 Devotee
Posts: 200
Joined: Tue Jul 17, 2007 6:08 pm

New sounds

Post by Iltanen »

I read a text file some weeks ago, by viznut, in which he said that in 2003 some "new" sounds were discovered but it was not described how to hear them. So does anyone know what this discovery was all about?
User avatar
Mike
Herr VC
Posts: 4987
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

They have been described in the thread 'Music Theory on the VIC'. Take a look at there for a programming example.

Michael
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

I still wonder to what extent it is practically useful, if there are some shortcuts to take somewhere.
Anders Carlsson

Image Image Image Image Image
User avatar
Mike
Herr VC
Posts: 4987
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Like, if it's really necessary to wait ~100 cycles to reset the waveform. For voice 3, something like this should suffice:

Code: Select all

SEI ; don't want an IRQ to mess up
LDA #desired frequency (MSB set)
LDX #$FE
LDY #$7E
STX $900C  ; set a 0 bit to reset waveform (4 cycles)
STY $900C  ; set a 1 bit
STX $900C or STY $900C  ; depending on desired waveform
STX $900C or STY $900C
STX $900C or STY $900C
STX $900C or STY $900C
STX $900C or STY $900C
STX $900C or STY $900C
STX $900C or STY $900C
STA $900C ; establish desired frequency.
CLI
For voice 2, and voice 1, I'd use blocks of 2, or 4 STX/Y's to compensate for the octave shift. Here you'd only need 8 or 16 cycles to reset the waveform.

I'd interested if this routine would reliably reproduce these waveforms. As has been noted elsewhere, the waveform only needs to be resetted, when it should be changed, or there had been silence in between (MSB=0), but not when only the frequency is changed.

Michael
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Yep. But remember that if you want to change the waveform while playing (e.g. PWM or at least change of "instrument"), you need the 100+ cycles of $7E, which in practise equals silence. For use in a tune, one would have to carefully consider how the tune is composed to afford those breaks. For a sound effect or just playing with one type of waveform, I'm sure its doable.
Anders Carlsson

Image Image Image Image Image
User avatar
Mike
Herr VC
Posts: 4987
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

I've spotted an error in the routine, anyway. The highest frequency for voice 3 clocks in at 1 MHz/32, i.e. one needs to wait 32 cycles before applying another MSB. The output of the voices comes from a 8-bit linear shift feedback register. Suppose Bit 0 is shifted out as output this works similar to:

ROR register

and then either:

AND #$7F ; set MSB to 0, if MSB of voice register is 0,

or

EOR #$80 ; toggle MSB, if MSB of voice register is 1.

That means, to get the "polarity" right, it is necessary to flush the whole register ... :idea:, i.e. 8 times 32 cycles for voice 3. O.K., these *are* 128 cycles ..., and 256, or 1024 for voice 2, or 1. :( At first I thought it would suffice to stick a single 0-bit into the LSFR, but now I've disproved myself. Sigh.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Probably the most reliable way to get new sounds out of a VIC-20 is to design a SID cartridge that goes into either of the I/O blocks. ;-)
Anders Carlsson

Image Image Image Image Image
User avatar
Mike
Herr VC
Posts: 4987
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Why stop here? We could also exchange the VIC-656x for the VIC-II, replace the 6502 with a 6510, put in 2 CIA's instead of the 2 VIA's, and not forget, spend 64 K RAM, and finally update KERNEL and BASIC. :lol:
User avatar
orion70
VICtalian
Posts: 4272
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Post by orion70 »

Mike wrote:Why stop here? We could also exchange the VIC-656x for the VIC-II, replace the 6502 with a 6510, put in 2 CIA's instead of the 2 VIA's, and not forget, spend 64 K RAM, and finally update KERNEL and BASIC. :lol:
Why don't we call it "VIC-64"? Mmmm... quite unfriendly... maybe simply "C-64".... :wink:
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

In the infamous first page of the 6562/63 datasheet, it says this chip (never produced) should have three waveforms and three amplitude modulators, programmable frequency (thank you) and programmable noise generator.

Dave Seiter seems to be the only person in the world who has a working 6562 chip, and according to the SWoC entry only the graphics capacities were improved?

In any case, I wonder if this pulse width anomaly observed and attempted to be controlled would be the basis for three waveforms? When it comes to amplitude modulators (volume?), I'd expect to see four of them unless the 6562 chip only was going to have three sound channels of which one alternated as noise, similar to how the later TED chip works.
Anders Carlsson

Image Image Image Image Image
PhilRanger
Vic 20 Hobbyist
Posts: 143
Joined: Thu Aug 25, 2011 10:04 am

Post by PhilRanger »

Mike wrote:I've spotted an error in the routine, anyway. The highest frequency for voice 3 clocks in at 1 MHz/32, i.e. one needs to wait 32 cycles before applying another MSB. The output of the voices comes from a 8-bit linear shift feedback register. Suppose Bit 0 is shifted out as output this works similar to:

ROR register

and then either:

AND #$7F ; set MSB to 0, if MSB of voice register is 0,

or

EOR #$80 ; toggle MSB, if MSB of voice register is 1.

That means, to get the "polarity" right, it is necessary to flush the whole register ... :idea:, i.e. 8 times 32 cycles for voice 3. O.K., these *are* 128 cycles ..., and 256, or 1024 for voice 2, or 1. :( At first I thought it would suffice to stick a single 0-bit into the LSFR, but now I've disproved myself. Sigh.
I'm lost in the details... Would it be possible to set the waveform so it always outputs ones, allowing PWM on 36878 to be louder than modulating a small DC offset?
Phil Ranger
-------------
"Don't eat the trees 2" for the VIC 20 : http://www.box.net/shared/u398kj0nr0lkauzm1k67
on line: http://www.mdawson.net/vic20chrome/vic2 ... otrees.prg
User avatar
Mike
Herr VC
Posts: 4987
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

PhilRanger wrote:[...]set the waveform so it always outputs ones[...]
You could use two voices for this, which output the same frequency but are 180° off-phase. But this already works without resorting to the 'new' waveforms: you'd purge the LFSR of both voices first (to ensure a square wave is being output), enable the first voice, do a delay, and then enable the second voice exactly on the negative edge of the first voice.

BTW, using the volume register in 36878 to output (4-bit) samples is PCM. :)

Back OT, the article 'VIC-I.txt' by Marko Mäkelä states, that the highest frequency in 36876 is f=Phi2/64. As the wave form repeats after 16 steps (8-bit LFSR with inverting feedback), this means one bit is output every 4 CPU cycles.

Which means, the first program I gave at the beginning of the thread is essentially correct, only 7 more STX $900C are necessary at the beginning to purge the LFSR. And this one:
Mike wrote:For voice 2, and voice 1, I'd use blocks of 2, or 4 STX/Y's to compensate for the octave shift.
... should also work.
PhilRanger
Vic 20 Hobbyist
Posts: 143
Joined: Thu Aug 25, 2011 10:04 am

Post by PhilRanger »

Mike wrote:
PhilRanger wrote:[...]set the waveform so it always outputs ones[...]
You could use two voices for this, which output the same frequency but are 180° off-phase. But this already works without resorting to the 'new' waveforms: you'd purge the LFSR of both voices first (to ensure a square wave is being output), enable the first voice, do a delay, and then enable the second voice exactly on the negative edge of the first voice.
So I just need delay the launch of the 2nd oscillator just enough or do I need the more complex trick?
BTW, using the volume register in 36878 to output (4-bit) samples is PCM. :)
I'm thinking about trying PCM first (36878 full on then full off, controlling the duty cycle) then both PCM AND PWM to get better resolution than 4 bits...
Phil Ranger
-------------
"Don't eat the trees 2" for the VIC 20 : http://www.box.net/shared/u398kj0nr0lkauzm1k67
on line: http://www.mdawson.net/vic20chrome/vic2 ... otrees.prg
User avatar
Mike
Herr VC
Posts: 4987
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

PhilRanger wrote:So I just need delay the launch of the 2nd oscillator just enough ...
Yep. But first you need to disable both voices long enough to ensure their shift registers are cleared, and square waves are output after (re-)enabling them. If you don't do that, you might output a 'new' waveform by accident.

You'd possibly want to check with a scope, that the delay really puts both voices 180° off-phase.
I'm thinking about trying PCM first (36878 full on then full off, controlling the duty cycle) [...]
Please take a look at Pulse Width Modulation and Pulse Code Modulation in Wikipedia: what you describe in parenthesis actually is PWM - provided you're using a fixed carrier frequency. A low-pass filter with a cut-off frequency well below the carrier frequency can then convert the duty cycle value into an analog level between the low and high level.

PCM however is not constrained to two output levels, also the output level is changed regularly at uniform intervals, there's no variant duty cycle involved.

You can combine both methods, sure - but before that, you should consider techniques like noise shaping. This method can easily add 1-2 bits (apparent) resolution to 4-bit samples, which have been dithered down from, say, 16-bit source samples; using PCM alone.

P.S. A related discussion can be found here in the thread 'Digitized sound + 2 spare channels possible?'.
PhilRanger
Vic 20 Hobbyist
Posts: 143
Joined: Thu Aug 25, 2011 10:04 am

Post by PhilRanger »

Thanks
I'm thinking about trying PCM first (36878 full on then full off, controlling the duty cycle) [...]
You are of course perfectly right, my fingers somehow disconnected from my brain. Should have been trying PWM first (I already did PCM before)
You can combine both methods, sure - but before that, you should consider techniques like noise shaping. This method can easily add 1-2 bits (apparent) resolution to 4-bit samples, which have been dithered down from, say, 16-bit source samples; using PCM alone.
[...]
Already done that on a Journey song, posted the results here before...
PhilRanger wrote:GOT IT!!!

Some new sampling. It could have been anything, but I like Journey and this one is from 1983, so it fits ;-)

Needs 16kB RAM expansion. The main routine is 206 bytes, the rest is the highly compressed data. Keep in mind a standard mp3 file is typically several MB!!!

NTSC version:
http://www.box.net/shared/xt8zdtquo6iquixg5oqc

PAL version:
http://www.box.net/shared/ga3g2a2gfe93libhgzqj
P.S. A related discussion can be found here in the thread 'Digitized sound + 2 spare channels possible?'.
Already read. Thanks again!
Phil Ranger
-------------
"Don't eat the trees 2" for the VIC 20 : http://www.box.net/shared/u398kj0nr0lkauzm1k67
on line: http://www.mdawson.net/vic20chrome/vic2 ... otrees.prg
Post Reply