Polyphonic Wavetable Synth - Mozzi

839 views
Skip to first unread message

Liam Power

unread,
Aug 4, 2017, 10:55:44 PM8/4/17
to Mozzi-users
Hi, I am using Mozzi with a NS1 Nanosynth, which has pre-filtered outputs on pins 9 and 10 for mozzi output.
This synth has an arduino leonardo built in, which supports native USB Midi using the Arcore Library found here. I have successfully modified the polyphonic mozzi synth sketch (found on this group) to output 6 note polyphony with 8 bits resolution. 
Unfortunately I have hit a couple of snags and need some help.

1. How would I go about adding a control voltage in for frequency modulation/vibrato? I know how to use mozzi analogread and store a variable, but I don't know where or what to call in my sketch to frequency modulate the 6 oscillators? I have a feeling the phMod parameter might be useful for what I'm looking at, but I can't seem to get it to respond in real time to an integer.

2. I have successfully ported some of the Ensoniq SQ8l Waves to the sketch using char2mozzi.py but while some of them work perfectly with polyphony, some are only playing moniphonically.
Please see attached sketch below, as well as the wavetables which you need to put in you /tables folder to use this sketch.

Thanks in advance for your help.
Liam


mozzi wavetables.zip
WavetablePoly_NS1_v1.0.zip

Tim Barrass

unread,
Aug 5, 2017, 9:03:23 AM8/5/17
to 'Ian C.' via Mozzi-users
Hi Liam,

>control voltage in for frequency modulation/vibrato
>to frequency modulate the 6 oscillators
>respond in real time to an integer
Do you mean the control voltage input would offset the read point in the wavetable from wherever it is in the cycle of the oscillator?

I'll try to find time to look at the sketch in the next few days.

Tim


--
You received this message because you are subscribed to the Google Groups "Mozzi-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mozzi-users...@googlegroups.com.
To post to this group, send email to mozzi...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/mozzi-users/79e6fc6c-52d9-4a45-b10b-648b2d55500e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<mozzi wavetables.zip><WavetablePoly_NS1_v1.0.zip>

Liam Power

unread,
Aug 5, 2017, 7:56:06 PM8/5/17
to Mozzi-users
Hi Tim, thanks for quick reply!

Basically I want to control the pitch of the oscillators with USB-midi AND a control voltage at the same time. or an internal mozzi LFO with rate and depth controlled by potentiometers on A1 and A2. At the moment as I am only changing the pitch of the oscillators when a noteOn is recieved (for efficiency), I can't frequency modulate the oscillators at all. So I want MIDI to set the centre frequency and then use either a control voltage from the ADC or a Mozzi LFO to modulate that frequency.
Hope that makes sense.
Thanks
Liam

PS The newest version of my code can be found here (sans wavetables for easy compatibility

Glen van Alkemade

unread,
Aug 10, 2017, 9:29:01 AM8/10/17
to Mozzi-users
Liam, that is tricky. We couldn't quite figure it out. We make the Macchiato Mini Synth with Mozzi, and it features LFO modulation and two-note polyphony. (Search for it on this forum.) Our sketch implements both MIDI note-on functionality and frequency-lookup-table functionality. The synth has a built-in keyboard that looks up the frequency from a table, or you can plug a MIDI controller into the MIDI IN to trigger a note that way. When you setFrequency from a table, it's easy enough to modulate that frequency with a LFO, but not so easy (to me) to monkey with the MIDI-set frequency. The Macchiato sketch illustrates how we set up the LFO to modulate the LPF cutoff frequency. Perhaps this will give you an inspiration of how to adapt the principle to modulate the MIDI note frequency.

Tim Barrass

unread,
Aug 10, 2017, 11:20:15 PM8/10/17
to mozzi...@googlegroups.com
Hi,
without setting up the hardware, I haven't tested this, but it is the approach I would start with.

It adds an offset to the frequency of each oscillator that's playing.  Keep track of the base frequency of the note set when the note-on is triggered for each oscillator.  The offset is set by your moduation oscil or analog input, and added every time updateControl() runs.

I hope this gives you some clues....

  // do once at noteon
  Q16n16_freq1_base = Q16n16_mtof(Q8n0_to_Q16n16(note1));


// every time updateControl() runs, for each playing oscillator....

  // freq offset/modulation cv on FREQ_OFFSET_PIN, centred at VCC/2
  // this would go up or down by roughly 5 semitones (512 cents)
  int freq1_offset_cents = mozziAnalogRead(FREQ_OFFSET_PIN)-512;

// the following would be ideal, but div is too slow
// float freq_offset_midi_notes = (float)freq1_offset_cents/100.f

// this is faster, and gives a range of +-4 semitones
Q16n16 Q16n16_freq_offset = Q16n16_mtof((signed)freq1_offset_cents<<9);
Q16n16_freq1 = Q16n16_freq1_base+Q16n16_freq_offset;

// set the freqency for each playing oscillator, every time update(control runs, eg.
oscil1.setFreq_Q16n16(Q16n16_freq1);


-- 
You received this message because you are subscribed to the Google Groups "Mozzi-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mozzi-users...@googlegroups.com.
To post to this group, send email to mozzi...@googlegroups.com.

Tim Barrass

unread,
Aug 11, 2017, 8:21:26 PM8/11/17
to 'Ian C.' via Mozzi-users
Woops,
the lookup table used by Q16n16_mtof() can't go negative, so this has a better chance of working...
sorry about the fixed point math, it really makes everything obscure, but it does make it possible on the limited processors

  // do once at noteon
  Q16n16_freq1_base = Q16n16_mtof(Q8n0_to_Q16n16(note1));


// every time updateControl() runs, for each playing oscillator....

  // freq offset/modulation cv on FREQ_OFFSET_PIN, centred at VCC/2
  // this would go up  roughly 10 semitones (512 cents)
  int freq1_offset_cents = mozziAnalogRead(FREQ_OFFSET_PIN);

// this is faster, and gives a range of +8 semitones

Q16n16 Q16n16_freq_offset = Q16n16_mtof((signed)freq1_offset_cents<<9);
// centre the offset (subtract half the shifted-up input range)... painful and probably needs checking/debugging
Q16n16_freq1 = Q16n16_freq1_base+Q16n16_freq_offset - (BINARY)111111111111111111;

// set the freqency for each playing oscillator, every time update(control runs, eg.
oscil1.setFreq_Q16n16(Q16n16_freq1);

good luck
tim

Liam Power

unread,
Aug 17, 2017, 4:54:46 AM8/17/17
to Mozzi-users
Hi Glen, Macchiato MIDI synth looks great! While researching this program I actually already came upon your project and was checking out how you real time changed parameter values. Cool coincidence that you are on here!

Liam Power

unread,
Aug 17, 2017, 5:00:33 AM8/17/17
to Mozzi-users
Hi Tim, definitely going to pull out the Nanosynth tonight and try this out. I almost got to this the other day but I think I was using the wrong fixed point conversions and the modulation was... unstable. Will post results when they happen. Thanks so much for your help, I reckon Mozzi is an absolutely amazing tool!

Tim Barrass

unread,
Aug 17, 2017, 6:39:29 AM8/17/17
to 'Ian C.' via Mozzi-users
Hi Liam,
I was thinking today that it is much simpler for prototyping to avoid the Q16n16 stuff and just use mtof(int) for midi to frequency.  The frequencies returned will be integer values, so not totally in tune, but might help get the sketch up and going, then tweak for accuracy later.

Tim

Reply all
Reply to author
Forward
0 new messages