Shop OBEX P1 Docs P2 Docs Learn Events
Polyphonic SIDcog synth - WIP — Parallax Forums

Polyphonic SIDcog synth - WIP

AntoineDoinelAntoineDoinel Posts: 312
edited 2015-03-17 18:05 in Propeller 1
I'm working on a SIDcog based polyphonic synth, based on Ahle2's SIDcog and StereoSpatializer by Chip Gracey.

It will use one SID emulation per voice: two VCOs, one LFO, three envelopes and one filter per voice, a canonical structure for a subtractive synth.

COGs are used this way:
0 - Main and MIDI decoding
1 - Debug serial driver (later to be recycled for modulation)
2..5 - 4x SIDcog objects (tone generators)
6 - StereoSpatializer (mixing, FX and output)
7 - MIDI serial driver


Well, today I fixed some things and broke some others, so I thought it's time for a preview:

Working:
- polyphonic voice allocation (two possible algorithms: round robin or one which I dubbed "panpot affinity").
- some realtime controls (ADSR, CC# 25,26,27,28)
- 4 fake patches (program change 1..4 to select, there's no patch management yet)
- pitch bender

Problems:
- it's very noisy, it seems to change with stereo spatializer knobs (i.e. always noisy or more noise when not playing), but still there's too much hiss with any setting
- cutoff and resonance (CC# 91,93) make an effect, but produce a scratchy sound
- ADSR has common values for all three envelopes at the moment

TODO:
- patch management
- modulation, at least for pitch and VCF cutoff frequency (at the moment I'm unable to read back modulation values from SIDs)
- separate set of values for the three envelopes
- key tracking for cutoff and ADR time
- more realtime controls, based on E-MU Xboard 61 but configurable

Attached you'll find one archive with four binaries:
m00_d30_31250 - MIDI on P0,P1, debug on P30,P31, standard MIDI speed
m00_d30_38400 - MIDI on P0,P1, debug on P30,P31, for use with roland serial driver
m30_d00_31250 - MIDI on P30,P31, debug on P0,P1, standard MIDI speed
m30_d00_38400 - MIDI on P30,P31, debug on P0,P1, for use with roland serial driver

Debug speed is 115200, mixed audio output on P10, P11.

Be aware, whathever you might have connected to P16..P23, that the four SIDs have separate outputs on P20..P23, and P16..P19 are used for LEDs (showing gate for the voices).

A sample mp3 of the output in the 2nd archive.

I hope to be able to write a little longer about it, and post the source (which is really too messed up at the moment :innocent:).

Regards
Alessandro
«13

Comments

  • Ahle2Ahle2 Posts: 1,178
    edited 2011-07-18 01:47
    Sweet!
    The sound sample sounded good but was very noisy. What's the cause for the noise?
    It's important to keep the "audio output cog number" as low as possible...preferably cog 0.
    This will minimize interference from other cogs.

    /Johannes
  • John A. ZoidbergJohn A. Zoidberg Posts: 514
    edited 2011-07-18 04:37
    The sound is nice and sweet. How many oscillators you cram them inside the Prop? :)
  • Ahle2Ahle2 Posts: 1,178
    edited 2011-07-18 05:14
    He uses 4 SIDcog objects, so the answer is 3 x 4 = 12 oscillators.However, he uses one SIDcog object per voice so it is a 4 voice polofony synthesizer.
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2011-07-18 11:07
    Ahle2 wrote: »
    Sweet!
    The sound sample sounded good but was very noisy. What's the cause for the noise?
    It's important to keep the "audio output cog number" as low as possible...preferably cog 0.
    This will minimize interference from other cogs.

    /Johannes

    I'll try with cog 1 and see if that makes a difference, cog 0 it's a little more difficult I guess, need to migrate all spin first.

    Maybe my troubles reading OSC3 and ENV3 might be (DOH!) a VAR-vs-DAT thing??

    @John
    Thanks... they say "standing on the shoulder of giants... you need lower delta-v to reach orbit!" :lol:
    Maybe when all the rest works more thinner/fatter modes can be implemented.
  • Ahle2Ahle2 Posts: 1,178
    edited 2011-07-18 11:17
    "Maybe my troubles reading OSC3 and ENV3 might be (DOH!) a VAR-vs-DAT thing??"
    Or it "may" be because SIDcog doesn't write them to hub ram. (I'm sorry but there isn't enough cycles left for that)

    Why do you want to read these values anyway?

    /Johannes
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2011-07-18 13:29
    Ahle2 wrote: »
    "Maybe my troubles reading OSC3 and ENV3 might be (DOH!) a VAR-vs-DAT thing??"
    Or it "may" be because SIDcog doesn't write them to hub ram. (I'm sorry but there isn't enough cycles left for that)

    Why do you want to read these values anyway?
    /Johannes

    Oh... thanks. At this point the "DOH!" should be big and carved in the stone :blush:

    I wanted to use the third oscillator as LFO, and third envelope as dedicated EG for VCF (setting bit #7 in volume register to shut off voice 3 from mix).
    I used this configuration (but monophonic) long time ago with a real C64, using a self made keyboard (more or less equivalent to SIEL CMK-49) and I liked the result.

    Gonna try disabling the osc3*env3 multiply part, but leave them running. Should free enough time for HUB writes, without lowering the samplerate.

    Alessandro
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2011-07-19 12:49
    An update:

    - upgraded to SIDcog 1.0 (modified to disable oscillator3 output, and write modulators to HUB)
    - moved StereoSpatializer to COG 1, the noise seems a little lower now
    - cutoff and resonance RT controls now working
    - modulation LFO->pitch and EG3->cutoff working, but still in the main loop (the update rate is too low)
    - EnvAmt (EG3 to cutoff) and LFOrate MIDI CC mapped to CC# 82 and 71
    - 1:1 key tracking to cutoff frequency implemented
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2011-07-23 14:26
    New binary, now getting usable enough.

    - Replaced serial driver with "Multiple serial port driver" by Tim Moore to free one cog.
    - Moved modulation to a separate cog, now modulation it's very smooth.
    - Separate SID outputs moved to P4..P7, P16..P23 reserved for debug LEDs.
    - Started to build a VSTi GUI (with SynthMaker).

    Refer to the picture in the archive for MIDI CC already implemented.

    Next planned is cleanup for source release.
  • LeoDLeoD Posts: 4
    edited 2011-08-16 04:42
    Alessandro,

    Nice job on this... Did you have a chance to play with it some more ? I'd love to have a source for your latest version, so I could adopt it to my own home-grown prop board.

    Thanks,

    Leo
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2011-08-16 14:08
    Hi Leo

    as usual... 5% of the time to do 95% of the job, and 95% for the remaining 5% :lol:

    As for the source, it's not finished. But here it is anyway.
    Not even "alpha quality". I'll blame the greeks for putting the "alpha" as the first in the alphabet. :innocent:

    Unfortunately I had the very bad idea of changing normal SPIN arrays to C-like structures, mostly because I wanted to copy a patch with a single bytemove instruction. This resulted in hard to find bugs and multiplication of the entropy.

    Added since previous release:
    - True MIDI input (optoisolator) will most likely require inverted serial levels, added option.
    - Preset patches (only 8, and no saving back of changes possible currently)
    - Velocity scaling for EG attack time
    - Key scaling for EG decay and release time
    - Delayed LFO with ramp
    - Free running and sync-to-key modes for LFO
    - Synthmaker GUI rebuilt again from scratch (accidentally lost the red one shown in previous post)
    - Too many other small changes to count...

    Regards
    Alessandro
  • Ahle2Ahle2 Posts: 1,178
    edited 2011-08-17 11:10
    @AntoineDoinel
    You have done an excellent job on this. :)
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2011-08-17 17:13
    @Ahle2
    Many thanks, it's worth double said from the AudioMaster! :smile:

    Just tried with better headphones, and the sound it's much different (more bass range).
    Still only DemoBoard, haven't heard it with the unmuffled filter on other boards.
    Maybe that will compensate a bit, but some patches will need retouching anyway.

    Also made a binary with stripped debug output, to better evaluate key to note latency.
    It should be much more agile with chords and fast sequences.

    No LEDs this time: just MIDI TX/RX at P0,P1, audio at P10,P11, and debug serial at P30,P31.
    MIDI serial is 31250bps with inverted levels.

    Alessandro
  • Clock LoopClock Loop Posts: 2,069
    edited 2011-08-30 04:57
    Could the noise problems people have with generating audio on the prop be eliminated by using dual cogs and or dual output pins tied to eachother also?

    There has got to be a hardware way to eliminate this noise using multiple cogs and multiple output pins putting out the same signals?
  • average joeaverage joe Posts: 795
    edited 2012-04-05 22:54
    Alessandro, I was wondering if you've made any progress on this project. It seems as if you've done quite a bit and I would like to try the binary you posted, but my hardware has different pinouts. I grabbed the previous post and I'm trying to understand the modifications I must make. I need to disable 2 audio outputs, change the midi and audio pins as well as disable debug. Any help would be greatly appreciated!
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2012-04-06 18:22
    Alessandro, I was wondering if you've made any progress on this project. It seems as if you've done quite a bit and I would like to try the binary you posted, but my hardware has different pinouts. I grabbed the previous post and I'm trying to understand the modifications I must make. I need to disable 2 audio outputs, change the midi and audio pins as well as disable debug. Any help would be greatly appreciated!

    Hi average joe

    despite using BST conditional compilation at first for debug, at some point I needed so many of them that I didn't care anymore to make them conditional. I remember producing the "nodebug" version by manually removing debug statements on a copy of the source... sorry for this, didn't have time to work some more on it.

    Anyway, no big worries in adapting to different configuration, I did it already for this dedicated board that I've built:
    26122011327_small.jpg


    Would you mind describing your hardware configuration more in detail? (i.e. MIDI and audio pins)
    I think I still have the stripped source somewhere, so pins could be changed in that one.
    1024 x 768 - 291K
  • average joeaverage joe Posts: 795
    edited 2012-04-06 19:56
    Well I'm currently in-between hardware right now. I'm working on the new hardware on this thread
    http://forums.parallax.com/showthread.php?137999-LCD-touchscreen-A-development-thread
    The most recent post has the next hardware candidate attached as a pdf. I'm just waiting for parts to arrive so I can test this out and revise as necessary. I am attaching a pdf of the current hardware.
    I was hoping to get basic touch functions to control parameters, but I doubt I will be able to get this done in time for the expo. I have "SIDsynth_05_110816" source, but I have not had much of a chance to dig around in it. SO, "Midi In - 26" "Audio 24,27"
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2012-04-07 01:55
    Hi Joe

    changing pins on the beginning of the main source should be all there is to it.

    I've attached the main source with removed debug printouts (I've noticed there are still some, but they are out of the processing loop: at initialization, and then only for events recurring not very often, like program changes, etc.).

    Anyway, should you recompile the source, do play with inverted serial levels, that always gets me! :lol:
    (whenever I change the optoisolator, used a 4N27 but also H11L1, or from opto to direct TTL.
    Check the two binaries, one with true ("nrm") and one with inverted levels. I hope one of those will work straight away, let me know.

    Using 24,27 for audio, I'm afraid you're going to get more noise: because of the way the propeller is internally wired, it's best to use the lowest possible numbered pins with the lowest numbered COG. I'm using P0, P2 in my board, and StereoSpatializer, which does the output, runs in COG #1.

    Alternatives would be:
    - mixing the four SIDs externally with a passive mixer (eventually giving up stereo), that should lower the noise by some 2 bits, I guess (~12dBs)
    - using a modified StereoDuty object for output in place of StereoSpatializer (I've had an unsuccessful attempt at this, I might try it again if I have the chance). StereoDuty should be modified to mix 4 sources to 2 outputs, like StereoSpatializer does, but without the fancy doppler and echo effects.

    Alessandro
  • average joeaverage joe Posts: 795
    edited 2012-04-07 02:03
    Thank you SO MUCH! I'm exhausted but I will work on this first thing in the AM. I've read about this noise problem and wondered if outputting sample data from StereoSpatializer through a 16-bit parallel dac such as the PCM54 would help. I have a few of these laying around and they were quite popular for CD-quality audio. I was reading somewhere about the connections between cogs and pins. I wish I could find that thread again. I don't have pins for option 1 right now so I will continue thinking about using more than 1 prop.
    Thanks again!
    Joe
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2012-04-07 08:43
    Thank you SO MUCH! I'm exhausted but I will work on this first thing in the AM. I've read about this noise problem and wondered if outputting sample data from StereoSpatializer through a 16-bit parallel dac such as the PCM54 would help. I have a few of these laying around and they were quite popular for CD-quality audio. I was reading somewhere about the connections between cogs and pins. I wish I could find that thread again. I don't have pins for option 1 right now so I will continue thinking about using more than 1 prop.
    Thanks again!
    Joe

    You're welcome, however 90%+ of the credits goes to Ahle2 for his wonderful SIDcog object! :smile:

    StereoSpatializer does a lot of processing between sample output updates, so probably serial I2S or SPDIF in the same COG is out of question. But a parallel DAC seems feasible, requiring at most one shift to align data, and latching it. The only drawback is that, according to the datasheet, it requires additional circuitry for stereo operation... and a lot of pins!
    In the end I think the best option for high quality is an I2S or SPDIF object *replacing* StereoSpatializer. Less pins for I2S, or even down to a single LED patched to one end of the optical cable in the latter case.

    Since we already have a driver in the OBEX for SPDIF, I was planning to do the experiment sooner or later, not only for this synth but also for the wonderful PropB3 (http://forums.parallax.com/showthread.php?136674-Tonewheel-Organ-with-Propeller-Chip-Hammond-B3).
    I don't have an SPDIF to analog DAC, but they are available for cheap on ebay, and I should be able to test it with a SoundBlaster Audigy 2 (which has both optical and coax inputs).
  • average joeaverage joe Posts: 795
    edited 2012-04-07 16:57
    I have some SPIDIF optical connectors, I will look into building a down and dirty DAC and interface for the prop. I agree that the PCM54 requires a bit of extra circuitry for stereo operation, but I do have 2 of these chips *actually quite a few more than 2* I think it would be easier to use 2 PCM54's and 2 lines to latch them. The new hardware was designed with 19 pin data bus, and 12 pin address bus so expansion should not be an issue. Thanks again for your input and don't sell your work on this short. I've played with sidcog a bit but it would take me FOREVER to get anywhere close to what you have done!
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2012-04-11 14:18
    I have some SPIDIF optical connectors, I will look into building a down and dirty DAC and interface for the prop. I agree that the PCM54 requires a bit of extra circuitry for stereo operation, but I do have 2 of these chips *actually quite a few more than 2* I think it would be easier to use 2 PCM54's and 2 lines to latch them. The new hardware was designed with 19 pin data bus, and 12 pin address bus so expansion should not be an issue. Thanks again for your input and don't sell your work on this short. I've played with sidcog a bit but it would take me FOREVER to get anywhere close to what you have done!

    Joe, I've been playing with SPDIF, and found that coax (or TTL) SPDIF works equally well... don't know why I ruled it out in the first place! :innocent:

    Coax SPDIF works well on Demo Board using the TV output, and resistors can be used to adjust the level.
    But even with a bare pin, AFAIK all Creative sound cards since the first LIVE model, have at least one SPDIF TTL input that can be used, the digital CD input.

    Yesterday I've been pulling my hair out to try to get the synth working with it, without much success (the demos were running ok, so the digital link was up). Then, today I've had the idea to do time multiplexing to avoid mixing, and it seems to work reasonably well.

    The only downside is that SIDCOGs are running at 24KHz (half the SPDIF rate), and any real stereo capability is lost, all you get is 2 channels left and 2 right, Amiga style. Talking about Amiga, this trick is probably similar to the one used in "Oktalyzer" tracker to double the channels, I guess. :smile:

    I will upload something soon... do you have a Demo Board?
  • average joeaverage joe Posts: 795
    edited 2012-04-11 19:06
    Very nice work! I have been pondering SPIDIF but not had time to do any exploring. I don't have a demo board, I'm using a HEAVILY modified propRPM at this time. The video DAC has been removed for access to the pins. This will all be changing next week. I have several Creative cards so I will play around with this after the expo.
    I still have yet to get control changes mapped. I tried fitting my LCD GUI over the project but do not have enough memory. New hardware should fix all the issues I'm currently facing. Last question, SPIDIF should work equally well on all pins correct?
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2012-04-12 02:00
    Very nice work! I have been pondering SPIDIF but not had time to do any exploring. I don't have a demo board, I'm using a HEAVILY modified propRPM at this time. The video DAC has been removed for access to the pins. This will all be changing next week. I have several Creative cards so I will play around with this after the expo.
    I still have yet to get control changes mapped. I tried fitting my LCD GUI over the project but do not have enough memory. New hardware should fix all the issues I'm currently facing. Last question, SPIDIF should work equally well on all pins correct?


    yes, if you're going into CD input (a 2pin connector on the card), any pin and just the wires should do.

    For coax, I've been referring to this:
    http://www.epanorama.net/documents/audio/spdif.html

    if you scroll down, you see the simplest circuit is done with a capacitor and a voltage divider of 330 vs 100 ohms. So approx less than 1/4 of 5V TTL. That values probably match cable impedance better, but since the TV circuit is already there, we can try at least to match the attenuation (considering we start with 3.3V). We got no decoupling capacitor, but most probably there is one in the input of the receiver anyway.

    P.S.: about the GUI, using another output method, like SPDIF or the parallel DAC, approx ~8K of StereoSpatializer buffers can be released.
  • average joeaverage joe Posts: 795
    edited 2012-04-12 02:26
    Thanks again for all the info. I will try again after I get back from the expo. I am rushing to finish everything else right now. I will also check on the input cap for the sound-cards I have. These are all good things to think about for my hardware revision. 8k would be enough memory if I wasn't wasting a cog on reading character info off of propROM. Current drivers for my screen use 3 cogs. It would be fairly simple to get down to 2 cogs. 1 would take a bit more work. I keep talking about the "Next -Gen" hardware because it will solve all these problems and more.
    I can't thank you enough for all your help!
    Joe
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2012-04-12 09:47
    Ok, here are some test binaries. Tried the same TDM trick with StereoDuty driver, and it works with just a little modification to it!

    I'm trying to put all debug output under conditional compilation, probably did something stupid in the process which messed the oscillator release (but only when using StereoSpatializer output, it seems). :innocent:

    The 1st archive is for DemoBoard, StereoDuty (on audio jack) or SPDIF (on TV connector) output, MIDI TX/RX at P0,P1 (normal or inverted), and MIDI thru ICSP serial at 38400. Separate SID outputs are available at P4..P7, debug serial 115200bps at P30,P31.

    The 2nd archive contains similar options, for AverageJoe board (without separate SID outputs, and LEDs at P16..P23 not driven).

    The 38400bps serial can be used with Roland MIDI serial driver, or even better with this one:
    http://projectgus.github.com/hairless-midiserial/
    It might be useful if anyone wants to try the synth with a virtual (on screen) MIDI keyboard (if you don't have a real one), or to test the SynthMaker interface included. In this case MIDI and debug pin sets are swapped.
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2012-04-13 02:41
    Looks like the bug in StereoSpatializer configuration only happens with debug enabled.
    Too busy (lazy?) to look for it now... so I'm posting the updated sources. :innocent:

    Changes from v0.5:
    - added: compile time options for StereoSpatializer, StereoDuty, or SPDIF audio output
    - added: slightly modified StereoDuty and SPDIF drivers included
    - changed: most of debug printouts now use BST conditionals, added various options for verbosity
    - changed: separate MIDI RX and TX pins in configuration (for boards where RX is not TX+1)
    - changed: debug is disabled by default, only initialization and critical errors will be shown

    NOTE: I've removed the SynthMaker GUI to make the archive smaller, but that's unchanged from v0.5. Also download that if you're interested.
  • average joeaverage joe Posts: 795
    edited 2012-04-13 03:35
    Thank you SO much. I still have a TON of playing around to do. I was able to get a GUI overlay working, but the hardware is STILL way too slow right now. See http://forums.parallax.com/showthread.php?137266-Propeller-GUI-touchscreen-and-full-color-display&p=1089158&viewfull=1#post1089158
    I will post you new HW when it comes. I should have something nailed down in the next month. I like that serial midi driver. I am using this one http://www.spikenzielabs.com/SpikenzieLabs/Serial_MIDI.html They should be equivalent though. I am still looking through various free music production software for testing and controlling "display-less" hardware. I am also working on a modification of Cluso's triblade. I still have not tried synthMaker. I will do that tonight. I will also keep my eye out for the bug although I'm not sure how much time I will have "under the hood" in the next week.
    Keep up the great work as always and thanks again!
    Joe
  • Ahle2Ahle2 Posts: 1,178
    edited 2012-05-21 13:41
    @AntoineDoinel
    I haven't looked at the source code until just now, and wow....
    that's an awful lot of work you have put into this.
    Could you do some kind of demo and upload to YouTube or SoundCloud??

    Btw, how do you solve the issue with SIDcogs native sample rate on spdif?

    /Johannes
  • AntoineDoinelAntoineDoinel Posts: 312
    edited 2012-05-22 15:25
    Ahle2 wrote: »
    @AntoineDoinel
    I haven't looked at the source code until just now, and wow....
    that's an awful lot of work you have put into this.
    Could you do some kind of demo and upload to YouTube or SoundCloud??

    Btw, how do you solve the issue with SIDcogs native sample rate on spdif?

    /Johannes

    Hi Johannes, thanks for your kind words, and sorry for being late.

    You're right, it's a long time that I think about making a video. I had some demos tunes recorded as MIDI data on a QY20 sequencer, just waiting to be replayed. But then never managed to get any video editing software installed... now that even my trusty E72 cell phone lies in the seabed of tuscany, and only got a crappy 320x240 capable replacement it's going to be more difficult :frown:

    Do you have any suggestion on which software to use to sync video with a separate audio track?

    About the sample rate, I did wonder at first if that was going to generate some beating noise equal to the difference of rates, but in the end I just used it as a sort of dumb (i.e. non-buffered) DAC, even knowing that it would run at a different frequency. I guess this gives not optimal result (similar to nearest-neighbor thing on graphic rescaling), but it's not much noticeable to me. Same thing applies to modded StereoDuty.
    Still, being the DemoBoard my platform of choice for quick tests, its very dark filters could be masking it, maybe?

    The funny thing is that with SPDIF, and using the TDM technique to fake 4 channels, if you later import the recording in a editor you'll clearly see the single samples alternating up and down!
    It still sounds ok (and it's ok with StereoDuty, since filter will smooth that out), but I wonder if, once we got the benefit of transferring the signal digitally, some filtering could be applied in postprocessing...

    Also, the way this technique generates two hard-left and two hard-right panned channels could be interesting in that other thread about amiga audio emulation, maybe? Obviously the thing missing is implementing the four pseudo DMAs from HUB.

    Alessandro
  • average joeaverage joe Posts: 795
    edited 2012-05-22 15:54
    Alessandro, I would like to do a video eventually. I will be moving in the next few weeks so it will be after I move. I have not had a chance to look at the wav files, so I will have to pay attention when recording.
    I've run through several different filters and it sounds good on all! My main board used 1k metal film resistors and .1uf metal film caps. 1k carbon and .1uf ceramic are OKAY but sound a bit harsh IMO. I have some teflon caps on the way from my supplier so it will be interesting to hear the difference in those. SPDIF will be interesting to check out and when I get a chance I'll advise on post-processing.
    As far as software, I am using Windows Live video editor for the most part. I have access to After Effects, but this is a bit too complex for most video editing. There are some good Linux editors available, but I'm not familiar enough to recommend one.
    Cheers!
Sign In or Register to comment.