Simple SID chip emulator


Today 18:26
Forum: Proton Plus Compiler v3
Starter: glenlivet
Views: 0
Replies: 4
+ Reply to Thread
Results 1 to 6 of 6

Thread: Simple SID chip emulator2608 days old

  1. #1
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,019
    Thumbs Up
    Received: 312
    Given: 120
    Total Downloaded
    1.51 GB

    0 Not allowed!

    Default Simple SID chip emulator

    Collecting 1970's and 1980's computers is one of my hobbies, although, not so much these days as I've run out of places to put them in the house, unless it's a particularly rare or pristine condition one.

    One of the most popular computers of the 1980's was the Commodore64, not only because it had a great graphics chip, but also because it had a great sound chip, namely the "SID chip", or to give its technical name, the MOS6581, later changed to the MOS8580. See http://en.wikipedia.org/wiki/MOS_Technology_SID

    There are several microcontroller emulators for the SID chip knocking around the internet, some are created using 32-bit processors or FPGAs, but some are created using 8-bit microcontrollers, and all based upon the Atmel AVR types for some unknown reason. In fact, for some strange and disturbing reason, most really interesting creations with 8-bit microcontrollers seem to be based upon the AVR, and have been for many years now!

    However, to re-address the balance in some small way, I've produced a simple SID chip sound emulator using Proton BASIC, which I think is the first of its kind for a PICmicro, and certainly for an 8-bit device written in BASIC, which just goes to illustrate the power and flexability of the language

    There are limitations, in that the SID emulator does not support the filters that the original SID chip contained. This is not a hardware issue, or a language issue, but the fact that I don't fully understand the theory and practice of IIR or FIR filters enough to create them with any efficiency. So if anyone with a knowledge of IIR or FIR filters is prepared to pick up the baton and create the filters required within the code, they would be more than welcome to do so.

    However, even without the filters, the sound produced is pretty good. Take a listen to this mp3 file of the sounds created by the simple emulator: Bombjack.mp3

    Or how about these:
    1942.mp3, Ghost and Goblins1.mp3, Ghost and Goblins 2.mp3

    I originally wrote the emulator some time ago for the Amicus18 platform, but never released it. However, as you know, Amicus18 is only the Proton compiler restricted to 2 devices. i.e. the 18F25K20 and the 18F25K22, so adapting it to Proton was simplicity itself.

    Because it is based upon the Amicus18, I've left the code for use with the 18F25K20 device using a 16MHz crystal, internally boosted to 64MHz by the PLL. However, there is no reason that the code could not be adapted for any of the larger 18FxxK devices.

    The code can be downloaded from here: Simple_SID.zip

    The firmware uses the PICmicro's hardware PWM as a DAC, so all that is required is a simple R/C low pass filter connected from PORTC.2 (CCP1) to the input of an amplifier. Headphones will suffice, but the volume will be low.

    Code:
    ' Use the low pass filter circuit below to hear the sounds
    '
    '                          1K             1uF
    '                          ___           +[/
    ' From PORTC.2(RC2) o-----|___|-----o-----[|----o To Amplifier
    '                                   |     [\
    '                                   |
    '                                  ---
    '                                  --- 10nF
    '                                   |
    '                                   |
    '                                  ===
    '                                  GND
    The firmware for the SID emulator looks complex, but in fact it's rather simple. The reason it looks complex is because it has been rolled out in order to increase readability and speed of execution. It consists of a Timer0 overflow interrupt to create and mix the 3 channels of sound, a channel waveform creator, and an ADSR. The player code also looks complicated, and I must admit, it is more complicated than it should be, and could be simplified. However, all it does is read the sequence of SID registers from a very large data table, pass these to the SID emulator, create non-blocking delays, and trigger the ADSR at the appropriate times. The player is not perfect, and could be improved upon significantly, but it served its purpose of testing the main emulator code.

    A SID chip emulator is of limited use if the original SID tunes cannot be played, so I created a very simple Delphi application that converts the output of another, third partly, application into Cdata statements that Proton can understand. The Delphi application, and its source code is included in the zip file. The third party application is named Sid2midiw.exe, however, not only does the application produce midi files based upon actual SID tunes, it also produces a txt file that contains the register changes required for the SID chip for a particular tune. This is what the Delphi application uses for its conversion. This is also included in the zip file along with some txt files produced by it, ready for conversion to Cdata tables.

    To convert a tune ready for the emulator and player:

    1). Download some SID tunes from the internet. There are literally hundreds, if not thousands, of SID tunes out there.
    2). Run Sid2midiw.exe and create a .txt file for the chosen .SID file.
    3). Place the .txt file into the Delphi application's "Raw Tunes" folder.
    4). Run the Delphi app SID_MusicConverter.exe. Press the convert button and point to the file to be converted.
    5). The .inc include file ready to place into proton will be produced in the application's "Converted Tunes" folder.

    That's it!

    Important
    The code is suitable for Proton compiler version 3.5.2.6 onwards, downloadable from the beta section of the forum.

    It's also important to note that because of a combination of the lack of filters within the emulator, and the Sid2midiw.exe application not always producing the exact output, and my player firmware's simplistic nature, not all SID tunes will be re-created as they originally sounded on the Commodore64. This is something that could be cured, but it would take time, time that I don't have at the moment, which is one of the reasons that I've passed the code onto you. Hopefully, you will be able to improve on the code over time, and give it an output that mimics the SID chip in all its, rightly deserved, glory.

    Over to you.....
    Last edited by Les; 9th February 2014 at 16:24.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  2. #2
    Maverick
    Guest Maverick's Avatar

    0 Not allowed!

    Default Re: Simple SID chip emulator

    Bravo Les I am also a fan of C64 chip tunes.

    mucho cudos

  3. #3
    Prolific Poster bill9399's Avatar
    Join Date
    Aug 2004
    Posts
    1,699
    Thumbs Up
    Received: 8
    Given: 0
    Total Downloaded
    972.29 MB

    0 Not allowed!

    Default Re: Simple SID chip emulator

    Quote Originally Posted by Maverick View Post
    Bravo Les I am also a fan of C64 chip tunes.

    mucho cudos
    I concur.

    Maverick,

    Try this web site.

    http://www.hvsc.de/#index

    Mucho SID tunes. (40400)
    Last edited by bill9399; 24th October 2011 at 22:45.
    [B][SIZE=1]A wise man may listen and say nothing. A fool may listen and have nothing to say. Which one are you???[/SIZE][/B]

  4. #4
    Maverick
    Guest Maverick's Avatar

    0 Not allowed!

    Default Re: Simple SID chip emulator

    hehe thanks Bill
    I already have the entire High Voltage Sid Collection I play em on my android when i'm feeling nostalgic.
    I have C64 Emulator on there too, you never fully let go of the 64 ; lol

  5. #5
    Prolific Poster bill9399's Avatar
    Join Date
    Aug 2004
    Posts
    1,699
    Thumbs Up
    Received: 8
    Given: 0
    Total Downloaded
    972.29 MB

    0 Not allowed!

    Default Re: Simple SID chip emulator

    Quote Originally Posted by Maverick View Post
    hehe thanks Bill
    I already have the entire High Voltage Sid Collection I play em on my android when i'm feeling nostalgic.
    I have C64 Emulator on there too, you never fully let go of the 64 ; lol
    Memories, memories. Takes me back also....

    Les,

    Forget my question re voices. I managed to count three in the basic program.
    [B][SIZE=1]A wise man may listen and say nothing. A fool may listen and have nothing to say. Which one are you???[/SIZE][/B]

  6. #6
    Member Frizie's Avatar
    Join Date
    Apr 2003
    Posts
    162
    Thumbs Up
    Received: 12
    Given: 1
    Total Downloaded
    256.57 MB

    1 Not allowed!

    Thumbs up Re: Simple SID chip emulator

  7. Sounds great Les!
    Ohm sweet Ohm: www.picbasic.nl

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. usb serial emulator
    By ayhampic in forum USB Module
    Replies: 14
    Last Post: 15th September 2011, 12:17
  2. PSTN Dial Tone emulator
    By crankshaft in forum The Lounge
    Replies: 22
    Last Post: 6th April 2011, 00:05
  3. USB HID Keyboard emulator
    By Toley in forum Proton Plus Compiler v3
    Replies: 16
    Last Post: 29th June 2010, 18:53
  4. Probably something very simple !
    By moonshadow in forum Proton Plus Compiler v3
    Replies: 10
    Last Post: 13th February 2007, 09:05
  5. Low Cost PIC Emulator....request
    By C H Whitehead in forum The Lounge
    Replies: 0
    Last Post: 9th February 2005, 20:01

Members who have read this thread since 2nd December 2018, 17:07 : 0

Actions :  (Set Date)  (Clear Date)

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts