Shop OBEX P1 Docs P2 Docs Learn Events
SIDcog - The sound of the Commodore 64 ! — Parallax Forums

SIDcog - The sound of the Commodore 64 !

Ahle2Ahle2 Posts: 1,178
edited 2021-01-29 15:21 in Propeller 1
Okey guys here it is, an emulation of the famous sound chip used in the Commodore 64 !

Download the zip file and run "ExamplePlayroutine.spin" and "ExampleSidDumpPlay.spin".
"ExampleSidDumpPlay.spin" needs a SD card and the file "Russian.dmp" in the root of the card.

There are two different versions of SIDcog:
- If you want a more accurate emulation of the SID use "SIDcog". (playback of C64 SID dump files)
- If you want a small footprint use "SIDcog_Lite". (uses 63% of the space compared to SIDcog)

The only difference between the two versions at the moment are the combined waveform support in "SIDcog".

SIDcog version 0.80 features:
- Runs in one cog - totally self contained.
- 31kHz sample rate.
- >16bit resolution.
- Full filter support - any combination of Lowpass, Bandpass and Highpass filter.
- Full envelope support with a logarithmic release/decay curve. ( uses the same logarithmic approximation as a real SID)
- Supports all 4 waveform types
- Combined waveform support ( Not supported in SIDcog Lite )
- 16 steps main volume.
- Waveform reset bit works. (many Rob Hubbard tunes relies on this exact behaviour)
- Ring modulation.
- Oscillator synchronization.
- Can be "programmed" in the EXACT same way as a real SID. (Have a look at the official SID documentation for a better understanding)

SIDcog lacks:
- Possibillity to smoothly schange the filter resonance amount value (partly implemented thanks to Ariba)

BTW, if you have missed the initial SIDcog demo have a look at http://forums.parallax.com/showthread.php?p=855167
Here is a link to an archive containing the SID dumper tool.
Download SIDcog serial player to play SID-tunes via a serial link to a propeller running SIDcog.

Post Edited (Ahle2) : 6/14/2010 6:35:43 PM GMT
«13456789

Comments

  • ColeyColey Posts: 1,108
    edited 2009-12-11 16:44
    Thank you so much for this excellent piece of work.

    This will be used many many times over wink.gif

    Coley

    PS Do you have an app to dump the SID registers?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PropGFX - The home of the Hybrid Development System and PropGFX Lite

    Post Edited (Coley) : 12/11/2009 10:59:11 PM GMT
  • BaggersBaggers Posts: 3,019
    edited 2009-12-11 16:52
    Excellent Ahle2 [noparse]:D[/noparse] thanks, and like Coley says, this will be used many many times over!

    Baggers.

    PS, I think we should really think about making a ModTracker. in Spin.
    Paul (Paulie) Hughes, who wrote the Ocean Loader, and driver for most of the early OCEAN SID tunes has 6502 source on his website, for the driver.
    We just need to convert it to spin/pasm, then make a tracker [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-11 17:22
    Coley said...
    Thank you so much for this excellent piece of work.

    This will be used many many times over wink.gif

    Coley

    PS Do you have an app to dum the SID registers?

    Yes, I do.... But it's buggy at the moment blush.gif
    I will make a bug free platform independant QT version as soon as I have got any time.
  • BaggersBaggers Posts: 3,019
    edited 2009-12-11 20:01
    Ahle2, I just noticed the example play routine [noparse]:)[/noparse] EXCELLENT.
    Looks like I'm definitely going to have to make an on prop tracker now!

    Cheers,
    Jim.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-11 21:02
    Baggers said...
    Ahle2, I just noticed the example play routine [noparse]:)[/noparse] EXCELLENT.
    Looks like I'm definitely going to have to make an on prop tracker now!

    Cheers,
    Jim.

    Yes.... You just have to do that jumpin.gif

    I have been a tracker musician for 15 years and would LOVE to have a real tracker for the prop.
    It will be soooo much easier than typing in all the music data as numbers in a dat block.
    It took me forever just to type in all those numbers and the end result wasn't as good as I would have wanted it to be. (Its EXTREMELY hard to make anything decent by typing numbers in dat block)

    In the early 90s I used Protracker on my Amiga 500 and was limited to just 4 channels.
    In the mid 90s I used to do my music in Digibooster Professional on my Ultra Expanded Amiga 1200 and could have up to 128 channels.
    Today i'm using Psycle with 100s of VST synths and unlimted amount of channels.
    Tomorrow I will use SIDcog tracker on a Parallax Propeller with just 3 channels. wink.gif

    The circle is finally closed....
  • AribaAriba Posts: 2,682
    edited 2009-12-13 22:16
    Ahle2

    Thank you so much for releasing the source.
    Nice and well commented code !

    I have played a bit with the SID object, mainly to test the filter.
    Why have you made the resonance parameter a constant, and do not use the according SID register to change it?
    The resonance seems to work well.

    Can you convert the attached .SID file, I would like to compare it with the MP3s of this site: sid.kubarth.com/

    Thanks again
    Andy
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-14 01:09
    The reason for it being a constant is... it simply isn't enough cycles left for the additional multiplication that is needed for calculating the resonance level.
    I could make it work by change the sample frequency to 15khz instead of 30Khz.... but is it worth it?

    I will try to make a proper version of my SID dumping tool and release it here.

    I have attached a RAR-file containing 141 dumps. Just rename the file to .rar

    Post Edited (Ahle2) : 12/14/2009 1:20:09 AM GMT
  • BaggersBaggers Posts: 3,019
    edited 2009-12-14 09:23
    Nice to see you have the waveform reset bit working [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • LeonLeon Posts: 7,620
    edited 2009-12-14 13:56
    Coincidentally, there is something similar for the XMOS chip:

    www.xcore.com/projects/xc-1-sid-emulator-demo

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • ColeyColey Posts: 1,108
    edited 2009-12-14 14:29
    Leon,

    You just can't help yourself can you?
    I just knew you'd mention XMOS.......

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PropGFX - The home of the Hybrid Development System and PropGFX Lite
  • LeonLeon Posts: 7,620
    edited 2009-12-14 14:43
    I thought that comparing the two techniques might be of interest.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-14 17:29
    As far as I understand, he just took an already available SID emulator and compiled it for the XMOS.
    That's cheating nono.gif
  • LeonLeon Posts: 7,620
    edited 2009-12-14 18:11
    Yes. He used the SID Codec for Rockbox based on the TinySID engine.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-14 19:22
    Leon said...
    Yes. He used the SID Codec for Rockbox based on the TinySID engine.

    Leon

    TinySID is quite inaccurate actually. I did a lot of research for this project and I had a little look at the TinySID source code.
    The envelope part is totally wrong.
    And the combined waveforms is just a logical anding of the waveforms wich is incorrect.
  • LeonLeon Posts: 7,620
    edited 2009-12-14 20:01
    I might try them both and see if if they sound different.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-16 15:15
    Here is a little cool demonstration of psuedo stereo sid playing using two SIDcogs at once.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-12-16 15:51
    I've lost track of the fsrw thread (it's been moving forward fast!) but can it now support
    the opening of two different files? If so, you could open both the right and left sides of
    stereo sid files and play them in six voices.

    Here's a bunch of data from another Commodore die hard (Glenn wouldn't mind that title.) on stereo SIDs.
    www.lyonlabs.org/commodore/stereo-sid/index.html

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Visit the: The Propeller Pages @ Warranty Void.
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-16 22:52
    Very interesting OBC.

    I will have a look to see if there is an easy way of getting dumps of music made in Stereo sidplay.
    They can't be dumped in my tool at the moment. [noparse]:([/noparse]
  • lonesocklonesock Posts: 917
    edited 2009-12-16 23:19
    Oldbitcollector said...
    I've lost track of the fsrw thread (it's been moving forward fast!) but can it now support
    the opening of two different files?...
    Yep. Just declare an array of FSRW objects, and make sure to mount one of them.

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lonesock
    Piranha are people too.
  • AribaAriba Posts: 2,682
    edited 2009-12-16 23:21
    Hello Ahle2

    Here are some results of my experimenting.

    1) A midi file player with the SID as target. Not very useful for GeneralMidi files, but theoretically one can compose SID music in a sequencer on the first 3 MIDI channels, save it as midi file, and ply it with this code from SD card.

    2) A SID variation with resonance, that goes near to self oscillating. Has perhaps not much tot do with the real SID, but who cares [noparse];)[/noparse]

    Andy
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-17 00:43
    Very interesting Ariba!
    Thanks!
    Ariba said...

    1) A midi file player with the SID as target. Not very useful for GeneralMidi files, but theoretically one can compose SID music in a sequencer on the first 3 MIDI channels, save it as midi file, and ply it with this code from SD card.
    Theoretically we can have 6 SIDcogs running at once (1 cog for control and 1 for fswr), that's 6*3 = 18 channels and that's enough for good midi playback.
    Now we just need to make presets for all the 128 GM sounds wink.gif

    Ariba said...

    2) A SID variation with resonance, that goes near to self oscillating. Has perhaps not much tot do with the real SID, but who cares [noparse];)[/noparse]
    Well, SIDcog already had resonance but I understand what you mean.
    "A SID variation with the abilility to adjust the resonance amount" would be more accurate to say smilewinkgrin.gif

    Anyway, it's a very fast and good solution using a table until I have optimized the code enough to be able to do it more accurately with linear multiplication as I initially intended.
    I will keep that in my code for now, but I will calibrate it with a real SID as reference because the resonance is way to much at higher values shocked.gif
  • JonnyMacJonnyMac Posts: 8,910
    edited 2009-12-28 03:27
    Is there a way to detect when one of the channels is quiet, i.e., it has completed the release portion of the ADSR envelope?
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-28 13:25
    JonnyMac said...
    Is there a way to detect when one of the channels is quiet, i.e., it has completed the release portion of the ADSR envelope?
    No... that whould require some extra hubops and in the end I would have to half the sample rate to 15Khz to make it work (SIDcog already uses >96% of the COGtime at 31khz).

    It's quite easy to "calculate" it through a lookup table.


    attackTable         word 2,8,16,24,38,56,68,80,100,250,500,800,1000,3000,5000,8000
    decayReleaseTable   word 6,24,48,72,114,168,204,240,300,750,1500,2400,3000,9000,15000,24000
    
    



    If you want to know how many milliseconds it is from noteOff until complete silence.
    Example:
      releaseValue := 15
      timeToSilence := decayReleaseTable[noparse][[/noparse]releaseValue]
    

    Post Edited (Ahle2) : 12/28/2009 1:46:28 PM GMT
  • mikedivmikediv Posts: 825
    edited 2009-12-28 17:09
    Ahle2, very nice, Thank you for sharing your work with us I will use it a lot
  • JonnyMacJonnyMac Posts: 8,910
    edited 2009-12-28 23:28
    @Ahle2: That was the path I started down. Thanks for the confirmation.
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-29 09:29
    @JonnyMac
    It isn't an exact science though, because theoretically it never gets completely silenced thanks to the logarithmic decay/release curve.

    SIDcog has got a 16bit envelope resolution instead of an 8bit as on the real C64.
    This will cause the tone to stay audible longer when the envelope are "beyond the 8bit resolution".

    The constant DTCF (Decay Table Correction Factor) can be adjusted to perfectly match the decay/release times of the SID.
    I have calibrated this factor by ear while comparing dumped SID tunes to my real C64.
    I'll do it more scientifically with the help of a clock when I've got the time.

    Attack times doesn't need any correction thanks to the linear behavior.

    @Everybody
    I'll need your oppinion:
    - What methods to add/change/delete/rename?
    - Add support for an external voice input? (Like a real SID)
    - Implement combined waveforms with the help of lookup tables on behalf of cog memory space? (It would require at least 4kb for decent quality)

    And please share any experience, bug, thought or project that involves SIDcog cool.gif

    / Johannes Ahlebrand.
  • Nick McClickNick McClick Posts: 1,003
    edited 2009-12-29 10:09
    What are some songs that use combined waveforms?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Forums RSS Feed!

    Gadget Gangster - Share your Electronic Projects
  • Ahle2Ahle2 Posts: 1,178
    edited 2009-12-29 11:24
    @Nick McClick
    Luckily combined waveforms are seldom used, therefore it havn't been a priority to implement support for it.
    Maybe 3% of all available C64 "material" makes use of it.
    The reason is that the older version of the sid chip(6581), produced between 1982-1986, couldn't handle combined waveforms very well..
    Even the later version(8580), produced between 1986-1993, made "unpredictable" sounds whith combined waveforms.
    All SID emulators on the PC, except for TinySID, relies on lookup tables, because combined waveforms are almost impossible to emulate properly with known algorithms.
    TinySID does combined waveforms by bitwise anding of the waveforms (exactly as the patent says) but in reality the result isn't even close to the real deal.
    Combined waveforms tends to have an "analog" feature about them and can vary over time and between different SID chips.

    SIDcog "converts" all combined waveforms to saw waves for now.

    Here is a very good example of a "proper" usage of combined waveforms www.youtube.com/watch?v=-htbkZ72FgI&feature=related
    Listen to the guitar/harp like sound at the beginning of the tune.
  • Nick McClickNick McClick Posts: 1,003
    edited 2009-12-30 04:07
    It might be interesting - not so much to play other tunes, but maybe as a synth. Sidcog could be the core of an awesome synth.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Forums RSS Feed!

    Gadget Gangster - Share your Electronic Projects
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-12-30 04:17
    Any chance that steel drums could be done with SIDcog?

    Drum sounds weren't exactly the real SID's strong point,
    but I have a midi project in the works that could use drum sounds.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Visit the: The Propeller Pages @ Warranty Void.
Sign In or Register to comment.