Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 3 1 2 3 LastLast
Results 1 to 25 of 60

Thread: My Teensy 3.1 Commodore SID Emulation / Player

  1. #1
    Junior Member
    Join Date
    Dec 2015
    Posts
    3

    My Teensy 3.1 Commodore SID Emulation / Player

    I had a bit of fun with the Teensy Audio Library and implemented a MOS6581 / SID emulation using the
    Teensy 3.1. It can play SID-Dump Files, which are register dumps of 25 registers updating 50/60 times a
    second and setting the corresponding SID-Registers.

    I am handling the register changes in a simple routine and setting the corresponding oscillator frequencies, filter cutoff frequency,
    filter routing, filter resonance etc. according to it.

    Here is how it sounds (sorry for the shaky video):


    Features supported so far:
    * Write to 25 of the SID registers
    * Set global volume via register
    * Set each oscillators frequency smoothly via registers
    * Change waveform of each voice
    * Noise (Linear Feedback Shift Register) implemented and working
    * Filter controls / routing working
    * Filter masks working
    * Envelope registers working (timing needs to be verified, though)

    There are still a few bugs:
    * The ring modulation doesn't work so well yet - the output gets too silent.
    * Oscillator sync is not implemented yet

    And also a few things I'd like to include one day (possibly one of you could help?):
    * 6502 CPU Emulation, for supporting real SID files (can be ported from libsidplay)
    * Making a library out of it, for easier usage
    * Combined waveforms support

    I will release the source code soon - it's just a big mess of spaghetti-code now, but it works.
    Last edited by syso123; 12-15-2015 at 02:26 PM.

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Awesome :-)

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,553
    Oh my, you're going to be *very* popular with this one!

  4. #4
    Senior Member adrian's Avatar
    Join Date
    Oct 2015
    Location
    Wellington, NZ
    Posts
    504
    Oh my goodness

  5. #5
    Junior Member
    Join Date
    Jan 2014
    Posts
    19
    Awesome!!!!!!!!!!!! :-)

  6. #6
    Junior Member
    Join Date
    Dec 2015
    Posts
    3
    Thanks for the Feedback. I would certainly need help porting the 6502 CPU Emulation in order to support real SID file playback.
    Would be also nice, if somebody could help me track down the ring modulation issues.

    Quick warning: Please be ready to see some spaghetti code, cause right now it's not really a clean implementation (but as I said, it works)

  7. #7
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Quote Originally Posted by syso123 View Post
    Thanks for the Feedback. I would certainly need help porting the 6502 CPU Emulation in order to support real SID file playback.
    Would be also nice, if somebody could help me track down the ring modulation issues.

    Quick warning: Please be ready to see some spaghetti code, cause right now it's not really a clean implementation (but as I said, it works)
    Oh, i 'm interested, esp. in porting the 6502-emulation.
    I've already ported some things to teensy, like flac or mp3 playback.

  8. #8
    Junior Member
    Join Date
    Dec 2015
    Posts
    3
    Quote Originally Posted by Frank B View Post
    Oh, i 'm interested, esp. in porting the 6502-emulation.
    I've already ported some things to teensy, like flac or mp3 playback.
    Cool! Can you send me a PM? I will add you as a user to my git repo!

  9. #9
    Junior Member
    Join Date
    Dec 2015
    Posts
    15
    Quote Originally Posted by nevvkid View Post
    Awesome!!!!!!!!!!!! :-)
    HOLY SH!T !!!!

    I have just bought a teensy 3.2 and audio board after seeing the audio library and thinking i could make a 4 channel sid-like deal with extras like the chorus.

    I am just finishing building my first analogue synth and wanted 4 adjustable sid voices , this looks great.

    All of the registers could be read from pots on the SPI giving complete control in a patchable synth

    Is the filter emulation working ? Will you be releasing the source into the wild ?

    Lee

  10. #10
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    We're working on a port of "reSID", which is a very good emulation of the SID chip. I think it's just a matter of days. It allows to use every register of the virtual chip.

    Edit:
    For a sidplayer, there is an issue - i'm not sure if can solve it with the Teensy. For a real c64-6502 emulation we need 64KB RAM (sids are 6502-machine code)
    Perhaps there is a way to use less, but at the moment, its more likely that we have to wait for the next-gen Teensy with way more RAM (should come 2016)
    Last edited by Frank B; 12-19-2015 at 11:44 AM.

  11. #11
    Junior Member
    Join Date
    Dec 2015
    Posts
    15
    Thats great. For me just the patchable bit would be fine. How much cpu time does the code take ??

    Although not much use to me but the sid player soft 6502 wouldnt neccesarily need to access the whole 64k would it ? Just a bank where the tune code was located ?

    Or maybe code up a relocator routine for the sid to always occupy a certain bank ?my 6502 is far too rusty but im sure someone could do it .

  12. #12
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Quote Originally Posted by braincell View Post
    Thats great. For me just the patchable bit would be fine. How much cpu time does the code take ??

    Although not much use to me but the sid player soft 6502 wouldnt neccesarily need to access the whole 64k would it ? Just a bank where the tune code was located ?

    Or maybe code up a relocator routine for the sid to always occupy a certain bank ?my 6502 is far too rusty but im sure someone could do it .
    CPU-Time: Too early to say :-)
    Relocation: Yeah, maybe that's possible.. my 6502 is very rusty, too... i don't remember much.

  13. #13
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Hi,

    first reSID recorded sound (a DMP File):

    https://drive.google.com/file/d/0Bx2...w?pref=2&pli=1
    (MP3 Download)

    ..still do not know the CPU Usage, but will measure it tomorrow or in the next days.

    I've turned the SID-Emulation to a Audio-Lib object, instead of the play() method, theres a method to set all virtual registers.
    Last edited by Frank B; 12-19-2015 at 07:56 PM.

  14. #14
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679

  15. #15
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Quote Originally Posted by braincell View Post
    Thats great. For me just the patchable bit would be fine. How much cpu time does the code take ??
    Here's a first version:
    https://github.com/FrankBoesing/Teensy-reSID

    An example DMP Player is included.
    CPU-Usage is somewhat 30%..50% at the moment - i hope it can be reduced.
    But, that's not bad for 3 voices including effects & filters.
    The oversampling runs at nearly 1MHz!

    It would be great if you could help developing it further. The reSID is quite old, but was the best one at it's time.
    But there my be issues, introduced by my porting. Nevertheless, most "DMP" Files are playing good.
    Last edited by Frank B; 12-19-2015 at 11:16 PM.

  16. #16
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    Frank, you are amazing. Every once in a while I go back to those soundtracks. Pretty incredible what they were able to tickle out of the hardware.
    Last edited by Constantin; 12-20-2015 at 05:02 PM.

  17. #17
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Quote Originally Posted by Constantin View Post
    Every once in a while I go back to those soundtracks.
    me too..
    Pretty incredible what they were able to tickle out of the hardware.
    Yes, and the hardware was imperfect, had bugs and so on - those bugs made some things possible where commodore did not even think of.
    Esp. the SID had some Hardwarebugs. The "sample" playback for example were only possible because a part of it produced a "klick" under certain circumstances.(I think the reSID emulation above reproduces this bug.)

  18. #18
    Many thanks great work

    how to convert *.sid file to *.dmp ?

  19. #19
    Junior Member
    Join Date
    Dec 2015
    Posts
    15
    Quote Originally Posted by Frank B View Post
    Here's a first version:
    https://github.com/FrankBoesing/Teensy-reSID

    An example DMP Player is included.
    CPU-Usage is somewhat 30%..50% at the moment - i hope it can be reduced.
    But, that's not bad for 3 voices including effects & filters.
    The oversampling runs at nearly 1MHz!

    It would be great if you could help developing it further. The reSID is quite old, but was the best one at it's time.
    But there my be issues, introduced by my porting. Nevertheless, most "DMP" Files are playing good.
    This is fantastic ..... running a dual sid on a teensy with a load of adc inputs dangling off the SPI bus is almost a reality

    Looks like im gonna have to build another synth !!!!!!!

    EDIT - can this be used without an audio board using the built in 12bit DAC output ????
    Last edited by braincell; 12-21-2015 at 12:30 PM.

  20. #20
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    i did'nt try two sids.
    it's independend of the output.
    if you want, you can use SPDIF, DAC, or every other audiolib-output object

  21. #21
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    @jls, if you find a way, let me know.

  22. #22
    Junior Member
    Join Date
    Dec 2015
    Posts
    15
    Quote Originally Posted by Frank B View Post
    i did'nt try two sids.
    it's independend of the output.
    if you want, you can use SPDIF, DAC, or every other audiolib-output object
    Sorry for the noobish question but i just got my teensy 3 days ago and my audio shield today........

    does the audio library require the audio shield, I mean if i use DAC out can i without the shield ??

    How can you use 2 instances of the library??? I tried importing your GUI code into the online designer but the sid part was missing ?

    lee

  23. #23
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    The library does not require the shield.
    There is no need to use two instances of the library. Use the mixer object.
    There can only be one output - but all signals can be combined with a mixer.
    You might want to visit this page: http://www.pjrc.com/teensy/td_libs_Audio.html
    , and the design tool.


    ..and most important: try the examples first, to get used with it.

    Edit: Ah, yes, of course the sid part is missing. The design tool does not know that it exists.

    I don't know wether Paul is interest to include it, or not. It's not easy to use, there isn't a simple "play()" method due to the nature of chip-emulation. The registers want to be set
    But you can use any other input, and rename the input-object in the xported code.
    Last edited by Frank B; 12-21-2015 at 07:59 PM.

  24. #24
    Junior Member
    Join Date
    Dec 2015
    Posts
    15
    Quote Originally Posted by Frank B View Post
    The library does not require the shield.
    There is no need to use two instances of the library. Use the mixer object.
    There can only be one output - but all signals can be combined with a mixer.
    You might want to visit this page: http://www.pjrc.com/teensy/td_libs_Audio.html
    , and the design tool.


    ..and most important: try the examples first, to get used with it.

    Edit: Ah, yes, of course the sid part is missing. The design tool does not know that it exists.

    I don't know wether Paul is interest to include it, or not. It's not easy to use, there isn't a simple "play()" method due to the nature of chip-emulation. The registers want to be set
    But you can use any other input, and rename the input-object in the xported code.
    What i meant was how too invoke two instances of the SID library , I understand there is only the 1 dac output and everything must be mixed down to this.

  25. #25
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Import this into the GUI-Tool:
    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioPlayMemory          playMem1;       //xy=99,89
    AudioPlayMemory          playMem2;       //xy=102,148
    AudioMixer4              mixer1;         //xy=337,97
    AudioOutputAnalog        dac1;           //xy=541,84
    AudioConnection          patchCord1(playMem1, 0, mixer1, 0);
    AudioConnection          patchCord2(playMem2, 0, mixer1, 1);
    AudioConnection          patchCord3(mixer1, dac1);
    // GUItool: end automatically generated code
    and replace "AudioPlayMemory" by "AudioPlaySID" after export.
    But, again, i did not test two SIDs. But i have more time after christmas and am willing to bring it to work (if it does NOT work now)

Posting Permissions

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