PIC32 polyphonic digital/analog synth

Show off your projects to others!
Post Reply
madias
Posts: 53
Joined: Fri Nov 28, 2014 11:30 pm
Location: Vienna/Austria

PIC32 polyphonic digital/analog synth

Post by madias » Wed Jan 14, 2015 9:44 pm

Hello,
I currently doing a conversation of my 4-voice dual DCO synth with 4 analog filters.
In my first project I used 4 Amega328 minis with 8-bit parallel DAC's as voice engines, one Atmega 328 for inputs and potis and a TM4C123G LaunchPad for controlling everything (voice engines via I2C, ADSR's, LFO's, control voltage outputs for filters and VCA, displays (one 4 line LCD and one 320*240 TFT).
I wanna share with you my first basic voice engine adapted to a pic32mx250 using a mcp4922 as dual output.

This is a very rough conversation (because of the 8-bit of the 328er) with following limits:
[*]using 16bit values for phase accumulator (maybe switching to floating or 32bit?) = less accurate
[*]wavetables limited to 256steps (more steps need reorganize the phase accumulator)
[*]only two DCO and one LFO
[*]wavetables are limited to 8 bit (just adjust the "DAC_val1=sig[0]<<4; " in the waveengine code

Features:
[*]Wavetables: sine,tri,saw-up,saw-down,sqr,PWM
[*]midi notes conversation: use note[] for midi notes
[*]frequency modulation between DCO0+DCO1
[*]LFO modulation for pitch and PWM

In this version there is no I2C or MIDI protocol implimented.
I've analyzed the main IRQ (calculating DCO's and SPI output), there is much space left on the pic32 for much more things to to :) Maybe one PIC32 is enough for a complete polyphonic synth (but I need for one physical output 3 additional DAC's for the analog section: cutoff,resonance,VCA, I've ordered a cheap octal 8bit spi DAC for the control things already)
My sample code should run fine on UECIDE with no additional libraries and a PIC32MX250. For other MCU's the SPI pins have to be changed (I use mapPps)

The code plays midi-notes 0-80 in the main loop.
regards

ps: a note to myself:
never use "int" anymore: use uint16_t (int on avr=16bit, int on PIC32=32bit, I spend 2 hours for finding the error)
Attachments
dac-synth-working2.zip
(4.57 KiB) Downloaded 112 times

madias
Posts: 53
Joined: Fri Nov 28, 2014 11:30 pm
Location: Vienna/Austria

Re: PIC32 polyphonic digital/analog synth

Post by madias » Thu Jan 15, 2015 12:13 am

ok, I've done some further testings:

floatings are a noway within the IRQ loop: about 66% utilization caused by the IRQ only with 2 voices! (at this point I miss my tiva tm123 with HW floating points...)
so I stay with 16bit variables, so i get about 50% MCU utilization with virtual 16 voices (on 2 outputs) running - not bad!
explanation for picture:
I'm toggling two pins: first one is in the main loop, without nothing further. second one is in the IRQ: at the beginning HIGH, at the end LOW
saleae-irq-test.png
saleae-irq-test.png (59.22 KiB) Viewed 1317 times

madias
Posts: 53
Joined: Fri Nov 28, 2014 11:30 pm
Location: Vienna/Austria

Re: PIC32 polyphonic digital/analog synth

Post by madias » Sun Mar 15, 2015 1:16 pm

Ok. Further success.
Got my PIC32MX250 to play 4 voices simultaneously via 2 I2s-DAC's (both on independent SPI channels). Overclocked to about 60 MHZ for further headroom.
I'll try to get the whole voice engine into this PIC: ADSR's, LFO's, octal-DAC for voltage controlling the filters.
All other stuff (patch editing, display(s), rotary encoders, knobs, MIDI, storage) is outsourced to a STM32F103 (maple mini clone for 3 bucks).
I also got my first PCB (the quad multimode filter board) into production.
Notes to myself: Never use Fritzing anymore, use KiCAD.
I am curious if my board wlll working, have to wait 2-4 weeks for delivery.
File on dirt cheap dirty boards:
http://dirtypcbs.com/view.php?share=5397&accesskey=

Post Reply