Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > HowTo: Digi Samples on the SID
2005-10-24 08:20
MRT
Account closed

Registered: Sep 2005
Posts: 149
HowTo: Digi Samples on the SID

Im' thinking of writing a sample-play routine for a demo, but as it seems I'm not sure where to start.

Can somebody explain to me the basics of playing samples on a SID? Things I'm not sure about are:

1. How does one set the volume for one channel? Using the Sustain of the envelope and setting the A, D and R to zero?

2. What kind of wave (Triangle, Block) do I use and why?

3. Do I need a 8x system to play a 400Hz sample? (50 Hz * 8x)

And I prolly have a lot more questions, but I'll ask them when I understand a little more of the basics. :-)
2005-10-24 08:30
tlr

Registered: Sep 2003
Posts: 1790
The Old-School way is just writing samples into the global 4-bit volume of the sid.
This works (only on 6581?) because there is a considerable offset voltage in the sid before the MDAC that sets the volume.
The 4-bit volume is not linearly spaced, so for optimal results you should convert some 8 or 6-bit samples into the correct 4-bit non-linear steps.
If you want Old-school, don't convert, nobody did! ;)
This will ofcourse introduce all sorts of intermodulation, but somehow it seems to sound passable anyway. Check for example the excellent Jinks intro tune by Chris Huelsbeck.
2005-10-24 09:00
Oswald

Registered: Apr 2002
Posts: 5094
for a 400 hz sample you need a replay rate of atleast 800 hz. Imagine a square wave. To represent each high and low state of the wave you need twice the original frequency. This is a rule of thumb in sampling. But for better results you need even more frequency.

And in general, samples are never done using the ADSR registers. You should read one of the article about digis here : http://www.ffd2.com/fridge/chacking/c=hacking20.txt

you might check issue 21 aswell for even more details on square wave samples.

http://www.ffd2.com/fridge/chacking/
2005-10-24 09:11
MRT
Account closed

Registered: Sep 2005
Posts: 149
Quote: The Old-School way is just writing samples into the global 4-bit volume of the sid.
This works (only on 6581?) because there is a considerable offset voltage in the sid before the MDAC that sets the volume.
The 4-bit volume is not linearly spaced, so for optimal results you should convert some 8 or 6-bit samples into the correct 4-bit non-linear steps.
If you want Old-school, don't convert, nobody did! ;)
This will ofcourse introduce all sorts of intermodulation, but somehow it seems to sound passable anyway. Check for example the excellent Jinks intro tune by Chris Huelsbeck.


Hmm, yes, but if I use the global volume I won't be able to use the other channels for playing "normal" SID music.
So, there must be another way to do it too...
2005-10-24 09:20
tlr

Registered: Sep 2003
Posts: 1790
Quote: Hmm, yes, but if I use the global volume I won't be able to use the other channels for playing "normal" SID music.
So, there must be another way to do it too...


Like I said, that's how it's done in old songs even with 3 voices of sid. Check Jinks, or any Rockmonitor song, or even the Galway Arkanoid, Game Over and Combat School songs. They all work this way.
The sample update speed used differs between songs, but one sample every 2 raster lines is quite common. Use NMI timer interrupt (or include it in the timed raster code) for the best quality.
2005-10-24 11:29
Hate Bush

Registered: Jul 2002
Posts: 465
MRT, read the article recommended by Oswald. For starters. Almost every issue concerning sample playback is covered there.

(For playing back samples and SID tune at the same time by using global volume register, you have to drag the volume down (to $5-$8) and add subsequent sample values to it (during the NMI interrupt). AFAIR that's how it's done in most digi+SID combinations.)
2005-10-24 12:11
chatGPZ

Registered: Dec 2001
Posts: 11386
yep, add a DC bias of 8 to the original sample, and compose the regular sid tune with volume=8 .... and as for compensating the non linear behaviour...mmh...i'm not sure if anyone would actually notice, 4bit samples sound crap anyways :=P
2005-10-24 12:40
tlr

Registered: Sep 2003
Posts: 1790
Quote: yep, add a DC bias of 8 to the original sample, and compose the regular sid tune with volume=8 .... and as for compensating the non linear behaviour...mmh...i'm not sure if anyone would actually notice, 4bit samples sound crap anyways :=P


Maybe that's why it sounds crap. ;)
Seriously though, it's fairly simple to correct for the non-linearity for samples only, i.e no sid-voices. Most samplers are 8-bit anyway, so the original resolution is there.
It is probably pointless to do this when samples are combined with sid-voices because the intermodulation will take over anyway.
I'm also not sure if the non-linearities are equal on different revisions of the chip. Maybe it's time to read the C=Hacking article. :)
2005-10-24 13:50
chatGPZ

Registered: Dec 2001
Posts: 11386
the non linearity is (among other things) related to the external capacitors, thus +/-10% difference on different c64s. not quite worth the effort to compensate this imho :=P oh and playing stuff on the sid voices at the same time wont make it exactly better either :=)
2005-10-24 14:04
MRT
Account closed

Registered: Sep 2005
Posts: 149
:-D

Thanx guys...

Still, I've seen some demos which use fairly good samples combined with normal SID music while playing a rotating starfield (Or was it a rotating dot-scroller? I'll have to look that up when I'm at home again).
So, it must be possible do all those things at the same time.

Ah well... For the thing I'm thingking of programming, the overall volume (SID master volume) would prolly work just fine.
2005-10-24 15:02
tlr

Registered: Sep 2003
Posts: 1790
Quote: the non linearity is (among other things) related to the external capacitors, thus +/-10% difference on different c64s. not quite worth the effort to compensate this imho :=P oh and playing stuff on the sid voices at the same time wont make it exactly better either :=)

Huh? I'm not talking about the frequency response here. I'm talking about the steps of the output volume MDAC. These steps are not linear, they are logarithmic. Their absolute size is probably dependant on the silicon batch, but I'm guessing that their relative size is not.
Differences of the relative size may ofcourse exist between different revisions of the chip though.
2005-10-24 16:46
chatGPZ

Registered: Dec 2001
Posts: 11386
ah ok yes :) what i'm referring to is that if you play a square wave using volume register, the higher the frequency is, the less the actual output will actually be square :) there will be lots of distortion introduced due to the capacitors charging and discharging....effectivly defeating most techniques of removing distortion :=P (and ofcourse, anything else played on the normal sid voices will have its influence here aswell, and finally ruin every effort of compensating the effect by preprocessing)
2005-10-24 17:19
tlr

Registered: Sep 2003
Posts: 1790
Quote: ah ok yes :) what i'm referring to is that if you play a square wave using volume register, the higher the frequency is, the less the actual output will actually be square :) there will be lots of distortion introduced due to the capacitors charging and discharging....effectivly defeating most techniques of removing distortion :=P (and ofcourse, anything else played on the normal sid voices will have its influence here aswell, and finally ruin every effort of compensating the effect by preprocessing)

Do you mean like a regular filter with differing cutoff frequency due to capacitor tolerances, or do you mean an asymmetrical effect due to a different output impedance when driving or sinking the output?
2005-10-25 02:46
chatGPZ

Registered: Dec 2001
Posts: 11386
the latter... its somewhat as if a lowpass filter would be applied to the final output...just more complex than with normal filters :=P you get a quite funny signal depending on whats played on the sid voices at the same time.
2005-10-25 07:37
tlr

Registered: Sep 2003
Posts: 1790
Quote: the latter... its somewhat as if a lowpass filter would be applied to the final output...just more complex than with normal filters :=P you get a quite funny signal depending on whats played on the sid voices at the same time.

Ok, check! :)
Harder to compensate for that. Maybe for samples only, but the assymetrical filtering effect could well introduce so much distortion that it masks the other effects.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
DeMOSic/MS^LSD^ONS
Dr.Science/Atlantis
MCM/ONSLAUGHT
Jammer
Guests online: 118
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.6)
5 Facet  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.064 sec.