Refining a modulation algorithm

Discussions about anything analog, digital, MIDI, synth technology, techniques, theories and more.
Post Reply
User avatar
joeboy
Junior Member
Junior Member
Posts: 103
Joined: Tue Jul 17, 2012 1:22 am
Gear: ax-80, jx-8p, ms-20, tr-606, volca sample, ПИФ
Location: Australia

Refining a modulation algorithm

Post by joeboy » Mon Dec 18, 2017 10:19 am

Hello comrades, I'm back with another general synthesis question. I'm not asking to be spoonfed, but any knowledge/suggested reading material that will nudge me in the right direction is greatly appreciated.

At the moment I'm using wavetables with linear interpolation to represent oscillators, and everything seems to be in order. If Wc is an array full of amplitude values between -1.0 and 1.0 representing an arbitrary waveform, then I can pitch it as I please by setting the value i, which is the amount the phase accumulator p is incremented each cycle. That is, if i = 1, the wave would play back at its default frequency and p would increment 0, 1, 2 ... , if i = 2, only every other amplitude value of Wc would be read and the frequency would be an octave higher with p incrementing 0, 2, 4... , if i = 0.5, then interpolation would read "between" indices and the frequency would be an octave lower with p's incrementation being 0, 0.5, 1... , and everything else imaginable. The correct amplitude during any given cycle would be found at the wavetable index Wcp after incrementing p with i first. Really basic stuff.

Now I'm thinking about how to modulate the pitch of Wc in terms of another waveform, which we'll call Wm. If this modulator wave has its own increment value of j, and its own phase accumulator q, then I figure the pitch modulated amplitude value for Wc at any cycle would be Wcp + k, where k = (Wmq × j), and Wm's phase q has also already been incremented by j for the current cycle.

So if Wmq referred to a wavetable index of amplitude value 1.0, then Wc's increment value would be boosted by the full modulating frequency of j at that cycle. Likewise, if Wmq were -1.0, then Wc's increment would be retarded by the full extent of frequency j: and everything in-between. I think this results in periodic pitch offset.

Question 1: Does this sound correct?

Assuming everything above is correct, this is how I plan on implementing LFOs. But I'm left wondering about FM. My very basic understanding of the process is that it entails modulating one high frequency wave with another. You can get FM effects on an analog synth by cranking the LFO up into the audible range, but I don't know if digital implementations behave the same way. Is there a clean, general algorithm that describes all modulations at all frequencies, or are LFOs vs FM usually represented in entirely different terms? If the modulating frequency j were much higher than the carrier frequency i, then a negative value at Wmq could make the overall increment negative and actually move backwards in the carrier wavetable Wc. This seems like it'd result in some kind of distortion, but is it expected?

Question 2: Can a single algorithm represent both low-frequency pitch modulation and FM? Is it performant?

Finally, I'm curious about modulating an oscillator by itself. If Wc were also its own modulator, then its amplitude value would maybe be Wcp + k where k = (Wcp × i), where once again, p has already been assigned the value of p + i for the current cycle. But if k were to yield a negative value to deduct from p, then the "actual" increment for that cycle never "actually" made it as far as the original calculated value of Wcp in k, and shouldn't read from that index? I can't think of a better way to describe it, but it's a recursive chicken/egg problem.

Question 3: When modulating an oscillator by itself, when/how does one increment the phase accumulator?

--

This post has run a little long, most likely contains errors (it's evening and I've cracked open some brews), and probably demonstrates a fundamental misunderstanding of some areas of synthesis as well, but any help with any of these questions would go a long way. I'm going to keep experimenting on my own, but I'd like a theoretical understanding as well. Thanks!

User avatar
joeboy
Junior Member
Junior Member
Posts: 103
Joined: Tue Jul 17, 2012 1:22 am
Gear: ax-80, jx-8p, ms-20, tr-606, volca sample, ПИФ
Location: Australia

Re: Refining a modulation algorithm

Post by joeboy » Fri Dec 29, 2017 7:25 am

Sorry for bumping my own thread, but I thought it might be worthwhile to throw in additional observations since people sometimes find this board through search engines.

I've done more experimenting, and the algorithm I've described indeed modulates pitch periodically. There needs to be an additional variable to describe the modulation depth though, or the pitch offset will be often be imperceptible for low-frequency oscillation. So (Wmq × j × m), where m is modulation depth is the updated formula.

If the carrier wave were 440 Hz and I wanted to simulate an LFO by having the modulating wave's frequency be 0.3 Hz, then the modulation depth value would need to be considerable in order for the LFO effect to be audible, since 440 ± 0.3 is nothing in musical terms. The actual value of the depth parameter versus the user-provided input would have to scale along the octaves, since the perceived musical offset would be greater at lower frequencies for a constant value of m.

Without consulting a textbook (which I wouldn't understand anyway) I think this is called phase modulation. It is also linear FM because the offset at both the zenith and nadir of the modulating wave is the same. This differs from exponential FM which is the expected behavior of lots of VCO synths.

So it seems that questions 1 and 2 can be answered with a relatively elegant solution. That only leaves the issue of self-modulation to tackle. If anybody has other thoughts, however pedantic, feel free to chime in. I'm just having fun stumbling through this blindly, learning what I can along the way.

Post Reply