Released At :
SIDs used in this release :
Look for downloads on external sites:
Submitted by Mixer on 13 May 2009
|Many questions out there, I hope this answers a few of them.|
Edited:14.5.2009 to correct few inaccuracies.
There were 3 kinds of developments going on 2007 and 2008 prior the X2008.
THCM(The Human Code Machine) had long been working with various mixing algorithms to mix samples realtime on c-64. He had an advanced mod player. Few years back Aleksi Eeben did Pollytracker. Pollytracker is brilliant programming it plays samples as it mixes them. THCM approach had NMI playroutine which plays one buffer while another is being "mixed" outside the interrupt. THCM developed a very optimized way for doing this. It allowed for software mixing of 6 7 and 8 bit samples into a buffer that would then be played by various SID sampleplay methods. Software mixing is basically adding sample values together and then advancing source and destination buffer counters with different speeds. Different speeds mean different playing note frequencies for each source sample. The problem is how to do this fast enough to mix 4 channel data to new buffer before the buffer that is currently played loops. THCM approach is fastest known but also comes with some limitations. This means that one cannot just code a demo and install a converted mod into it without considering the modplayroutine itself.
Secondly Antti Lankila, Zrx, Enigma, Lord Nightmare,mrsid and others were working to optimize sid emulation. They started with resid and sidplay libs and worked towards a perfect sid filter emulation. In the process they actually decapped many (dead) sids and Enigma imaged the dies with professional microsopes. This gave insight into 6581 and 8580 differences and answers to questions like how the filter works? Why does the adsr bug? How oscillators really work? How do combined waveforms work? What is with the sid distortion? and why do each 6581 sound different from any other 6581. There are now fresh sid-die "blueprints" traced from the chip die images. This work helped the emulation work and the resulted sid-emulation patches are integrated into Vice 2.1. There are new sidplay versions available too. The new lib has a number of modeled sid versions to choose from.
Third, a group of old sid fans have been constantly theorizing and testing sid tricks since the golden days. There are many others involved, but relevant persons in this case are Soundemon and AMJ and myself.
On one day autumn of 2007 Soundemon worked with sid oscillator stuff and realized that it is possible to use oscillator to play samples in a new way. To explain how this works, I have to explain a bit of sid tech:
Sid chip has 4 waveforms per one sid voice - a single phase accumulator per voice that run always and at each moment there are 4 waveforms available for selection. Waveform selection bits in the voice control register choose which waveform is connected to the output stage - which then goes to envelope generator that does adsr. Output stage does digital to analogue conversion converting oscillator level value to voltage. A saw oscillator value starts from 0 and runs up to max and then starts from 0 again. Triangle starts from 0 goes to max and then back to 0. Pulse width determines how large fraction of each cycle the osc level is max or 0. Other sid registers allow for the manipulation of frequency and pulsewidth for these oscillators. Frequency being the speed at which the oscillator runs and pulsewidth applies to pulse. The oscillator can be reset by setting the test bit. All this becomes one voice output voltage level prior to adsr, filter and mixing.
The important realisation here was that the process is two stage. The value in the oscillator goes to output stage and becomes converted to analogue signal voltage. Soundemon learned that by selecting the waveform 0 (no oscillators out) the output stage still held the value and whatever voltage level it had previously. Voltage did not immediately disappear from there. This then quickly became a question: Can we select the output stage level somehow? Can the oscillator be stopped in a way that the level can be freely selected? Well, the saw and triangle start from 0 and go to max, what if we stop the oscillator at right moment? Soundemon also learned that setting waveform to 0 to hold signal level also did not stop the oscillators. This means that while the output stage is holding the previous value, the oscillators still keep running. This allowed for manipulation of sample level.
Sample level manipulation:
The highest possible frequency register value in sid corresponds to around 4khz. 1/4000 seconds is therefore the quickest time that saw oscillator reaches the maximum value from 0. So, if we reset the oscillator and put 65535 to frequency register every 1/4000 second intervals we can reach the max value in 1/4000 seconds and then hold it with waveform 0. On the other hand setting frq to 0 corresponds to no saw osc increase in that 1/4000s time and therefore sample level 0. Other frq values between 0 and 65535 allow for selection of sample level in 16bit accuracy each 1/4000 seconds. This is nice, but there is more. Triangle waveform rises from 0 to max in half of an oscillator cycle. This means that it is twice as fast as saw. It means that we can actually do the manipulation every 1/8000 seconds when using triangle. So, in theory we now can have 8khz samplerate and 16 bit sampledepth! Well, there is more - Since there are 3 voices in sid chip we could possibly do 3*8khz samples with 16bit sampledepth. Even further - each sample would have their own adsr and the sid filter could be employed as with regular sid music! Sounds awesome! but....
- c-64 only has 65535 bytes of memory, of which only about 48KB is available for samples. At 8khz this runs out very fast. About 3 second 16bit sample is possible at that speed. That'll be 6 seconds for 8 bit without further data manipulation, which then eats precious cycles.
- Sid OSC outputstage D/A is only 12 bit. Even if input is 16 bit the output will be max 12bit.
- Each manipulation of sample level requires 3 control register writes and frequency register writes (1 for 8 bit and 2 for 16bit). If routine is irq timed, the irq handling will take many cycles. Also one has to add samplepointer values to proceed in sampledata. For 16 bit it is more than 2x the cycles than with 8 bit.
- If the sampleplay timing is not exact the sound will include annoying high pitch component at the play frequency . This jitter makes it difficult to do a good quality sampleplayroutine with graphics on due to lost cycles for VIC graphics fetching mechanism. Also jumping to IRQ causes jitter due to the instruction being executed when irq occurs.
- 7884 hz is about 125 cycles. This corresponds to time it takes to draw 2 rasterlines. For program code 125 cycles is very little time. Try to add 4 numbers and increase 4 16 bit pointers in that time while playing sample too with irq.
- One can play samples faster than 7884 but loses bitdepth and volume while doing that. On the other hand one can play 3 samples on 3 voices, but the routines become so slow that triangle is no longer a good choice, saw has to be employed and it halves the volume and lowers the samplerate which makes timing harder with graphics on etc. 3x8-12bit samples at some frq 0-8khz with adsr and filters can be done, but it'll be hard to do any "demo" around it.
So, one voice, 8 bit samples, software mixing. This combination allowed for both graphics and actual mod music and traditional sid playroutine on the remaining sid voices.
Compromises were made and every trick in the known timing tricks and optimization book was employed during the making of Vicious Sid. As a result the demo then had 4 channel mod play employing 4 bit and 6/7 bit samples while graphics on. 8 bit sampleplay with filters and 2 voice traditional sid channels with graphics on while loading more stuff from disk using every last byte of c-64 memory and then a VIC sample routine.
VIC samples was an odd one. All c-64 users know how the crt's often give hearable noise which depends on what sort of graphics the system has on. There is a lot of interference in c-64 and that old tv-tech. Soundemon was actually attempting to use ASCII graphics to generate all sort of "musical" sounds in that interference when AMJ suggested playing samples with color values and thats how that part came to be. So, no sid chip on c-64 but some noisy samples out of the screen neverthless.
As a result I believe the distortion emulation guru Antti Lankila is actually working to do better PAL emulation now to fix emulators to support this method too :)
Some of the tested tricks:
- using cia timers as sampleposition counters.
- using sid voice 3 as a sampleposition counter.
- using stack as samplebuffer pla and phaing data.
- playing 8 bit sampleloop at around 30khz.
- playing 3 voices of 8 bit samples with adsr and filter
- playing 2 voices of 8 bit samples with adsr - this is very feasible and can do some nice mix-demo with trackloading, but no graphics on.
- Generating sound by calculating primitive samples - has the same sampleposition adder problem as modplay, otherwise doable.
Considered stuff and ideas:
- Doing this with 3 sid voices at 2mhz on c-128, which would enable also some fun REU/MCU optimizations with stack and zeropage positions
- Using sync modulation in v2 to retrig v1 to save one register write from irq routine.
- cascading sync modulations v1 v2 v3
- using a combination of 2 oscillators to generate 16 bit sampledepth.
- Utilising #c-64 REU memory as sample source
Submitted by The Human Code Machine on 29 October 2008
|This demo was shown at the X-2008 party, but the organizers forgot to put us on the voting disks. Our demo wasn't meant to compete with the 'big' ones and so it's no big deal for us. It's more a proof of what the good old SID is capable of. This version has some bug fixes and I added some nice converted Amiga modules as a bonus onto the two disksides. Please use the real thing, WinVice 2.05 beta or Hoxs to hear the 8 bit waveform digi samples.||
· Hidden Parts