SID Filters


Jack Gassett

Recommended Posts

Hey everyone, great news. Alvaro Lopes has been hard at work implementing filters for the SID chip. He has the first cut implemented along with the tinySID library to play SID tunes. This is a work in progress and we just wanted to release a quick sketch so we can get some feedback. There still needs to be some tweaking, something is still off, and we can use feedback on where you think the issue lies.

 

Attached is a zip file with a bit file to be loaded to the Papilio Pro and a sketch to load a sid file to the board. To change the song replace the music.sid file in the smallfs directory. Not every song seems to work at this point, but most that I tried did work.

 

We would appreciate any feedback, we have a theory about what is wrong but would like other unbiased opinions before talking more about where we think the problem is.

 

Thanks!

Jack.

sidfilters-20130329.zip

Link to comment
Share on other sites

  • Replies 85
  • Created
  • Last Reply

Wow - great news to have this out! I'm up and running with the bit file / sketch. Thanks so much.

 

There is some debugging to be done for sure though. Impressive that the whole 6510 emulation is so tiny in the sketch :-) But the songs do sound a bit strange, the filter parts sound ok, the main problems seem to be around sound balance between the voices, and some occasional odd timing things in songs where notes seem to skip (i've tried about 8 songs so far), and perhaps it's the ADSR piece as voices seem to fade away when they should still be playing? I can hear the filters working though and the overall sound isn't nasty, so hopefully the hardware side is close.

 

Still - great achievement!

Link to comment
Share on other sites

Just tried the Sanxion tune - good workout for the filters! Though some more odd glitches, and the timing of the playback seems a bit iffy - haven't got my head around the sketch yet to see how the timing is controlled, I would have thought with emulating the VBI through the ZPUino interrupt that the timing would be spot on.

 

On another I couldn't get one of my favourite tunes - Ocean Loader by Martin Galway to play at all. Not to worry, I know you're not focusing on a sid player!

 

Any thoughts yet how you plan to expose the filters for live MIDI use? I'm very keen on the thought of a bank store on the retrocade synth to control multiple voices (to thicken up live play), I'm very short on time at the moment though and development seems to be coming on quite fast that I would probably be overtaken!

 

Many thanks

 

Lee

Link to comment
Share on other sites

I'm almost certain it's an ADSR issue. Try Ghostbusters 2 - I can't see how it would happen looking at the code, but it almost sounds like the ADSR is 'rolling over' so that loud sounds are becoming quiet erroneously...

Link to comment
Share on other sites

Jack a bit more info please. Would I be correct to assume this needs a RetroCade megawing?

 

I have to admit, I've never had any need to touch any flavour arduino before so here goes, I downloaded arduino-0100-Z-windows.zip from Alvie's site, run it, opened the sidfilters project file then looked around the menus as a first time user trying to select a Papilio Pro, I can only find an LX4 board, not a LX9. Selected the LX4 and hit Verify, got a "Sketch too big" error message, Binary sketch size: 14684 bytes (of a 12160 byte maximum) but if I select a Papilio 500 the code compiles without complaining about the size so this seems like a board selection issue. At this point I didn't feel like learning how the IDE works under the hood and how to define a whole new board, had a search around Alvie's site under Reference and Tutorial, didn't see anything relating to Papilio Pro LX9 board, searched the forum for "ZPUino Papilio Pro" without anything relevant popping up and this just got put in the "Too Hard" basket.

 

Perhaps someone can throw me a clue otherwise I'll just wait for the HDL source code to come out and not have to deal with the ZPUino IDE.

Link to comment
Share on other sites

Jack a bit more info please. Would I be correct to assume this needs a RetroCade megawing?

Alex, you can comment out the Retrocade definition and use an audio wing or any other MegaWing with audio output.

 

I have to admit, I've never had any need to touch any flavour arduino before so here goes, I downloaded arduino-0100-Z-windows.zip from Alvie's site, run it, opened the sidfilters project file then looked around the menus as a first time user trying to select a Papilio Pro, I can only find an LX4 board, not a LX9. Selected the LX4 and hit Verify, got a "Sketch too big" error message, Binary sketch size: 14684 bytes (of a 12160 byte maximum) but if I select a Papilio 500 the code compiles without complaining about the size so this seems like a board selection issue. At this point I didn't feel like learning how the IDE works under the hood and how to define a whole new board, had a search around Alvie's site under Reference and Tutorial, didn't see anything relating to Papilio Pro LX9 board, searched the forum for "ZPUino Papilio Pro" without anything relevant popping up and this just got put in the "Too Hard" basket.

 

Perhaps someone can throw me a clue otherwise I'll just wait for the HDL source code to come out and not have to deal with the ZPUino IDE.

Your best bet is to download the entire RetroCade package, it has a version of the ZPUino IDE packaged from source code and has the Papilio Pro LX9 defined.

 

Jack.

Link to comment
Share on other sites

Sorry for so many posts, just a bit excited. Are there any details on how the filters have been implemented? Were the DSP slices heavily used, and are they IIR based?

 

Ta!

Alvie worked off the documentation from the Robert Yannes interview and the c source code for ReSID. He basically looked at the algorithms used in ReSID and implemented them as VHDL, he has the filters defined as a lookup table in BRAM so we can eventually plug in different filters like is done with sidplay2. Alvie can provide explain better, I was just a spectator during the process. :)

 

Jack.

Link to comment
Share on other sites

Any thoughts yet how you plan to expose the filters for live MIDI use? I'm very keen on the thought of a bank store on the retrocade synth to control multiple voices (to thicken up live play), I'm very short on time at the moment though and development seems to be coming on quite fast that I would probably be overtaken!

 

This should be very easy to do, now that the filters actually exist I will expand the SID library and define CC's that map to the filter registers.

 

Jack.

Link to comment
Share on other sites

Thanks Jack, I got much further with the Retrocade ZPUino IDE, I can for example upload test sketches to my P1-500 as per here to verify the comms and setup is correct, but I can't upload the sidfilter sketch to my PPlus, I get "Cannot get programmer version".

 

I was wondering if the bit file you posted here has anything specific for the PPro, like does it use the external DRAM? Other than that I don't see why it wouldn't work on the PPlus as the rest of the pinouts are the same.

Link to comment
Share on other sites

Alex, that message means that the bit file is not being loaded correctly to the board and the ZPUino IDE cannot communicate with the ZPUino Soft Processor.

 

Here is a quick checklist:

  1. Are you saving the ZPUino bit file to SPI Flash. The ZPUino needs to run from SPI Flash.
  2. In the ZPUino IDE are you selecting the second Papilio Pro Serial Port?

Jack.

 

Oh, I forgot to answer your question. Yes, the ZPUino in the bit file I sent you will not work without the SDRAM of the Papilio Pro. That version of ZPUino runs entirely out of SDRAM.

Link to comment
Share on other sites

Sorry for so many posts, just a bit excited. Are there any details on how the filters have been implemented? Were the DSP slices heavily used, and are they IIR based?

 

Ta!

 

Only one 18x18 multiplier is used for the design. There's a big advantage to have FPGA running way faster than the SID clock (96MHz vs. 1MHz), so I decided to write a sequential (12 clock) filter. The small delay is not relevant.

 

So, the multiplier is shared in order to save DSP (eats up some muxers, but that is OK). The design uses a small ROM for the ressonance coefficients, and a 4096-byte ROM (2048x16) for register to frequency cutoff mappings. The final mappings are (filter only, which includes the mixer):

 

Slices: 119

Flip Flops: 209

LUT: 371

Mult18x18: 1

Block RAM: 2

 

This is how it works (roughly):

 

After each 1MHz cycle, a pulse is generated to load the previous output into the filter input. The inputs are the three voices, and the configuration registers. From this point on, 13 cycles are needed to process filtering. Let me try to summarize what is done at each cycle:

 

0) Address of frequency cutoff is present at the mapping ROM, we reset Vnf (Voice Non Filtered) and Vi (Voice Input) to zero.

1) We save the cutoff value (w0) from the ROM,  and add voice1 volume to either Vnf or Vi depending on filter enable for the voice1.

2) We load the multiplier with " w0 * Vhp ", where Vhp is the Voice High Pass (from previous run). We add voice2 volume to either Vnf or Vi depending on filter enable for the voice2.

3) We take the result from multiplication and save it as dVbp. We present multiplier with " w0 * Vbp " where Vbp is Voice High Pass. We add voice3 volume to either Vnf or Vi depending on filter enable for the voice3 and the voice3_off flag.

4) We take the result from multiplication and save it as dVlp. We compute new Vbp as " Vbp = Vbp - dVbp ". We add ext_in voice to either Vnf or Vi depending on filter enable for the ext_in. We will probably remove this entry since few designs use it. We also present the resonance register value to the resonance ROM (maps linearly between 0.707 to 1.7).

5) We take the resonance value (q) and load multiplier with " q *Vbp ". We compute Vlp as "Vlp = Vlp - dVlp". We assign "Vf" (Voice Filtered) to Vbp or to "0" depending if we have BP flag active or not.

6) We compute Vhp as " (q*Vbp)- Vlp " using the multiplication result. We add Vlp to Vf if we have LP flag active.

7) We compute Vhp  as " Vhp - Vi "

8) We add Vhp to Vf if we have HP flag active.

9) We sum " Vf = Vf + Vnf ", adding both filtered and unfiltered parts.

10) We add the mixer DC constant value to Vf. This might not be needed, since we are not planning to play samples....

11) We load the multiplier with " Vf * volume".

12) We assign output with the multiplied final voice, and move to stage 0 and wait for another tick.

 

I'll present a theoretical diagram and explanation later, I need time to draw some diagrams.

Link to comment
Share on other sites

Lee O'D: I've a simple question for you. Does SID sound off even without the filters ?

 

I am too inclined to bug in the NetSID core. What I observe (or hear) is that noise seems to have a very low volume, so indeed there might be some issue with the decay or release timer.

 

I have to compare HDL with sotware implementations to be sure. Will do that as soon as possible.

Link to comment
Share on other sites

Hi Alvie,

 

I've had a little play around - so i'm not sure how to properly disable the filters (in HW), but if I modify the player such that it ignores anything for registers 21..23 and masks out the upper nibble of register 24 then nothing should get written to the filter registers.

 

I did this with modifying the play loop:

 

 

for (i=0;i<25;i++) {
if(i<21) {sid.writeData(i, sidregs); }
if(i==24) {sid.writeData(i, (sidregs & 0x0F)); }
}
 
But I couldn't tell any difference. Also the register dump didn't seem to be trying to write anything to those registers either.
 
I tried to capture some register dump around the weird sound - I'll also attach the sid file here so you can try, it's quite near the start just towards the end of the intro - one of the voices fades out and clicks (almost like a DC offset). As it's near the start it should be fairly easy to compare register dumps.
 
Voices 1 and 2 look fairly plain (just frequency changes). Voice 3 is messing around with the PW and ADSR at the time the problem occurs. The file sounds fine on eg sidplay.
 
What this sounds like on a version of the SID HW without filters I'm not sure?
 

 

R: 176 14 0 0 33 10 192 112 14 0 0 33 10 192 52 6 128 7 65 141 0 0 0 0 15 
R: 176 14 0 0 33 10 192 112 14 0 0 33 10 192 68 6 208 7 65 141 0 0 0 0 15 
R: 176 14 0 0 33 10 192 176 14 0 0 33 10 192 52 6 32 8 65 141 0 0 0 0 15 
R: 176 14 0 0 33 10 192 240 14 0 0 33 10 192 36 6 208 7 65 141 0 0 0 0 15 
R: 176 14 0 0 33 10 192 176 14 0 0 33 10 192 20 6 128 7 65 141 0 0 0 0 15 
R: 136 15 0 0 33 10 192 72 15 0 0 33 10 192 12 5 48 7 65 14 16 0 0 0 15 
R: 136 15 0 0 33 10 192 72 15 0 0 33 10 192 12 5 224 6 65 14 16 0 0 0 15 
R: 136 15 0 0 33 10 192 136 15 0 0 33 10 192 28 5 144 6 65 14 16 0 0 0 15 
 
What does register 25 do? I noticed the code to toggle it on and off by "e" and "d" - is this controlling the filter by any chance?
 
Very nice description of the filter above, by the way... :-)
 
Cheers
 

music.zip

Link to comment
Share on other sites

Just also had a play with Sanxion which sounds a bit odd, some strange 'bell like sounds'.

 

I decided to mask out the registers so it only played voice 1 (regs 0..6 and volume), and the plinky sound occured at this transition:

 

 

R: 38 52 0 8 21 10 0 
R: 38 52 0 8 20 10 0 
 
Which is where the gate bit is changed... Not sure if this is behaving differently / used in a weird way on this tune? This voice is being used to ring modulate voice 2 by the way, so it could be a ring modulator issue?
Link to comment
Share on other sites

Ok, I've done a little more digging into this problem. I recorded a couple videos that show a SID tune being played side by side on the RetroCade and using sidplay (I should have dusted off the cobwebs from the stereo's! One of the hazards of working in the basement.). The first two songs I played lined up perfectly and sounded identical, after I disable the EQ on one of the stereo's that is. They looped over and over perfectly together and the filters sounded good, there were no weird unbalanced volumes between the voices.

 

http://youtu.be/yHYzvZL07cE

 

http://youtu.be/HYWyzOHomsI

 

I think that this proves that the filters and the SID implementation are working correctly.

 

I kept playing more songs to look for trouble spots and came across the attached sid file. As I was playing on both devices I realized the the RetroCade was not playing voice one correctly. There was a whole lead missing from the voice... My next step was to play the same song using the NetSid project and the ACID64 player. With this alternative method the entire lead was there and it matched up with what I was hearing from sidplay (minus the filters).

 

I think this is pointing us away from the SID implementation and the filters and straight at the tinySID library, I think that is where our problem lies.

 

Jack.

Conquestador.zip

Link to comment
Share on other sites

Oh boy, that's exciting. Can't wait to get my hands on it. 

Jack, hope that you release this analog filters implentation soon. Don't forget about 500k users, though. 

 

Thank you for the encouragement, once we get this bug squashed I will start work on an official release.

 

I think we better talk about upgrading you to a Papilio Pro though... This Analog Filter implementation is using up two Block RAM blocks. The Papilio One 500K only has a total of 20 Block RAM blocks and I had to drastically cut down the program code to make the RetroCade Lite work. There is no way that the Analog Filters and the tinySID library are going to fit on the Papilio One 500K... This is going to have to be a feature that only works on the Papilio Pro.

 

If you want we can work out upgrading you to the Papilio Pro by taking your Papilio One 500K back and just asking that you pay the difference. If you want to do that just shoot us an email at support@gadgetfactory.net and Kalesh will help you get that worked out.

 

Jack.

Link to comment
Share on other sites

Thank you for the encouragement, once we get this bug squashed I will start work on an official release.

 

I think we better talk about upgrading you to a Papilio Pro though... This Analog Filter implementation is using up two Block RAM blocks. The Papilio One 500K only has a total of 20 Block RAM blocks and I had to drastically cut down the program code to make the RetroCade Lite work. There is no way that the Analog Filters and the tinySID library are going to fit on the Papilio One 500K... This is going to have to be a feature that only works on the Papilio Pro.

 

If you want we can work out upgrading you to the Papilio Pro by taking your Papilio One 500K back and just asking that you pay the difference. If you want to do that just shoot us an email at support@gadgetfactory.net and Kalesh will help you get that worked out.

 

Jack.

I've bought from SeeedStudio. No problem with that? If not, maybe we can work this out. I'll give you a heads up when it arrives. It still stucked under a customs office somewhere. 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.