Do you usually smooth Pitch?

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Hi all,

I need to manage the "global" pitch multiplying of my plugin, which it also depends by the "channel pitch" of the DAW/Host where the plugin is loaded (i.e. the usual Mod Wheel param on the generator channel, which send MIDI Pitch Wheel (14)).

My question is: do I really need to "smooth" it? Such as I do with a basic lp filter applied to a Gain knob value?

I tried without smoothing and changing it from DAW, but I don't really get any clicks/glitch applied to a sine generator osc.
Maybe I miss somethings... can I avoid it? Or should I also care about smoothing the pitch?

Thanks

Post

Yes, you definitely want to smooth pitchbend. Treat it as any other (smoothed) parameter, smooth it as a parameter, then add it into your global pitch, together with the current note and any other modulation you might have. I wouldn't smooth the global pitch itself, because then you can't have fast modulation from LFOs or anything and you probably don't want that.

Whether you get glitches (without smoothing) depends on many factors like hardware resolution, ASIO blocksize (how often does it get updated), the sound (does it mask the clicks) and even play style (is the wheel moved fast or slow?), but they are definitely possible and in my experience not particularly hard to produce.

Post

I see! Even with the current buffer I use (<256) I really can get any kind of clicks, also moving Pitch Wheel quite faster. But I trust you, and I'll consider it.
mystran wrote:I wouldn't smooth the global pitch itself, because then you can't have fast modulation from LFOs or anything and you probably don't want that.
Not sure about this point :) Why should you keep global pitch "clicking" with internal (fast) LFO modulation and not "clicking" with singles Host pitch changes? Isn't "bad" or "good" in any case?

Post

Ideally the pitch should be smoothed to sample resolution.
Try higher pitches if you can't hear it stepping at 256 samples.
Also, at the end of the day you don't know what different hosts supply.

Post

I haven't fooled with it lately. Last week was playing with MIDI sequencing first time for awhile, testing how long it would take to make a half-fast fake jazz backing track, in case maybe I'd decide to whip up several sets of solo act music, see how much work it would take.

Anyway was doing MIDI sequencing from Reaper to external hardware MIDI synths. One part of the song had some "data thinned" pitch bends. Its been so long since I messed with it, couldn't remember how thin one can get away with. Test song simple old warhorse standard "comin home baby" 114 BPM. About 526 ms per quarter note.

Pitch bend sensitivity was common +/- 2 semitones, and conventional MIDI Pitch Bend ought to have 14 bit resolution. Though wider PB sensitivity or other musical uses of Pitch Bend might need denser data-- In my simple use in this song (baritone guitar scoops), mouse-drawn pitch gestures at 32nd note spacing did not seem "too coarse to be useful". That would be PB messages at about 66 ms intervals. Or at 44.1 k samplerate, about 2900 samples per pitch bend message.

How much pitch bend smoothing can external hardware MIDI synths afford to do? In this case was a Roland FA-06. No clicks or real obvious pitch-stepping, splitting about a semitone PB over a quarter note with only 8 PB messages, though higher density would probably be generally safer, especially with larger pitch bends.

A well-done hardware synth ought not to click if the sample playback pointer rate is "suddenly" changed at maybe 12.5 cents per step at 66 ms intervals, but maybe a hardware synth does smooth out the step over more than one sample? Dunno. Perceived granularity in a pitch gesture perhaps the greater risk of too-sparse a gesture?

The musician playing or mouse-drawing pitch gestures has the ultimate control over the perceived pitch bend granularity and the synth can't (or maybe shouldn't) second-guess the user? If he wants it pretty smooth maybe he will put in the PB gestures at 128th note granularity or denser. OTOH if the musician just puts in one PB per quarter note then how much second-guessing should the softsynth try to do? Should a synth try to make quarter-note density PB gestures sound just as smooth as 128th note density PB gestures?

That would frustrate the user if the user has inserted quarter-note-density PB gestures "on purpose" knowing full-well how it will sound. Unless the user is a newb, a very-low-density PB gesture is probably intentional and maybe a synth shouldn't try to smooth it out, trying to be smarter than the musician? If the musician wants a smooth gesture then he will probably record a dense gesture?

But a softsynth might have the luxury of being able to make more assumptions, maybe do a "better" job of smoothing than a hardware synth?

Post

JCJR wrote:Should a synth try to make quarter-note density PB gestures sound just as smooth as 128th note density PB gestures?
I actually do my parameter smoothing with linear interpolation with ramp time adjusted depending on the time between successive automation (or MIDI CC, etc) events. This effectively gives low density automation more smoothing and then speeds it up as the density gets higher.

While it's not perfect, it works quite well in practice even with 7-bit MIDI controllers feeling smooth when turned slowly and fairly snappy when turned fast and also helps with the reduced density of synthetic DAW automation with longer process block sizes.

The only thing that doesn't work well with that scheme is when you intentionally try to produce a "steppy" automation that only sends events on the steps, although if you want to get technical you can force faster interpolation by sending some extra events around your step.

I think andy@cytomic suggested somewhere also detecting the "intentional step" case, eg. by looking at the parameter delta and treating it as a step if it's large enough and not close to other events (or something like that), but I haven't personally tried it.. although it sort of would make sense, I guess.

Post

The real issue with pitch bend is for most controllers you're lucky to get the whole 14 bits. It's more often 6 or even 5 bits for cheap controllers. Just try moving the wheel/bender very slowly and with large ranges like 12 semitones you should hear the steps very clearly in increments of 10 cents for example where only 7 bits of resolution + sign (positive/negative) are available.

The modulation rate isn't usually important (try to see if you can hear a 32nd stepped glissando) and buffer lengths have absolutely zero to do with it because MIDI messages are sent at per-sample resolution, not per-block.

That said, smoothing the control is really a perfectionist step that you should probably only worry about if you actually notice problems with it. While it might seem like a good idea to filter controller input, the result is that you make it impossible to produce instantaneous sharp edges like pulses.

Normally it is possible to use the pitch bend input to create arpeggio or vibrato effects for example as well as pitch envelopes where the device being controlled doesn't provide these features. If the pitch bend control input were filtered, this application would become impossible.

In a design with signal routing available it is possible to make different types of filters available to filter any signal, not just pitch bend. For example it's very common to want a smoothly filtered s&h noise from an LFO, or a pulse with the edges smoothed. Rather than implementing these as additional waveforms or features of your LFO it makes more sense to add a step to the routing to "process" modulation sources.

In such a case anyone who needed smoothing on pitch bend could apply a filter on their own. This would eliminate the issues with attempting to predict when to filter and when not (just enable/disable the filter with a pedal input) and conflicting with applications like arpeggio and pitch envelopes.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

quikquak wrote:Ideally the pitch should be smoothed to sample resolution.
Try higher pitches if you can't hear it stepping at 256 samples.
Also, at the end of the day you don't know what different hosts supply.
I'm using WDL-OL, and FL Studio. The max pitchbend I can reach is -/+12 semitones:

Code: Select all

double IMidiMsg::PitchWheel() const
{
  if (StatusMsg() == kPitchWheel)
  {
    int iVal = (mData2 << 7) + mData1;
    return (double) (iVal - 8192) / 8192.0;
  }
  return 0.0;
}
Testing the wider range I can use (24 semitones), the pitch multiplying brutally swap from *0.50000 to *1.99983.
But I don't hear any click :o

Post

Of course not. You're modulating pitch, which is then integrated. So the biggest click you could hear would be with a pure sine waveform at a low pitch. The click would be like it was filtered with a 6 dB low-pass with a very low cutoff.

Try sending pitch bend to amplitude instead and play a low sine while adjusting it.

I use a low-pass filter with 200 ms to 1/100th (99% of step) on most parameters including amplitude. This includes automation input, MIDI CCs and moving widgets on the GUI because it applies to all parameter inputs but does not affect modulation.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

aciddose wrote:Try sending pitch bend to amplitude instead and play a low sine while adjusting it.
Uhm? "pitch bend to amplitude" will modulate my "amplitude" param within the plugin, which is ALREADY under smoothing.

I'm only talking about modulating Pitch here (as global multiplying set from Host; i.e. Channel Pitch), not others params.

Post

I'm well aware of that. I'm only pointing out the fact that the "click" you are hearing is a first order integral of any impulse you modulate the pitch with.

In other words it is always low-pass filtered. The oscillator's overall pitch is like a filter's cutoff on the signals mixed in to the pitch once they get to the oscillator's output.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

Nowhk wrote:
quikquak wrote:Ideally the pitch should be smoothed to sample resolution.
Try higher pitches if you can't hear it stepping at 256 samples.
Also, at the end of the day you don't know what different hosts supply.
I'm using WDL-OL, and FL Studio. The max pitchbend I can reach is -/+12 semitones:

Code: Select all

double IMidiMsg::PitchWheel() const
{
  if (StatusMsg() == kPitchWheel)
  {
    int iVal = (mData2 << 7) + mData1;
    return (double) (iVal - 8192) / 8192.0;
  }
  return 0.0;
}
Testing the wider range I can use (24 semitones), the pitch multiplying brutally swap from *0.50000 to *1.99983.
But I don't hear any click :o
What I meant was a higher pitched signal to start with. Like a C7 sine wave. It won't click but you should hear the stepping if not smoothed.
FL Studio has quite a fine pitch-bend update, if I remember correctly. Others may not of course, be aware that other hosts exist! :)

Post

aciddose wrote:I'm well aware of that. I'm only pointing out the fact that the "click" you are hearing is a first order integral of any impulse you modulate the pitch with.

In other words it is always low-pass filtered. The oscillator's overall pitch is like a filter's cutoff on the signals mixed in to the pitch once they get to the oscillator's output.
So I'm not sure what you are suggesting to me :D I can avoid smothing pitch?
quikquak wrote:What I meant was a higher pitched signal to start with. Like a C7 sine wave. It won't click but you should hear the stepping if not smoothed.
Tried with a starting C8. Going from C7 to C9 in one sample. I don't hear any click. Of course I got the "step", but hey, that's what I'm doing: a step from C7 to C9. So of course it "steps" :o That's fine.
quikquak wrote: FL Studio has quite a fine pitch-bend update, if I remember correctly. Others may not of course, be aware that other hosts exist! :)
It simply send MIDI Pitch Wheel as MIDI message at the forthcoming buffer.

Post

You're not instantly moving the pitch wheel though, there's always a physical movement and presumably some musicality involved.
FL Studio has a variable buffer size by default, all the way down to 1 sample. Other hosts may use much larger blocks, and not update the pitch-wheel MIDI as fast as you'd expect. That's all I'm suggesting.

Post

Nowhk wrote:So I'm not sure what you are suggesting to me :D I can avoid smothing pitch?
I tend not to make subjective suggestions or project "between the lines" meaning. I'm merely stating facts.

The reason you can't hear a click is because the click is inherently filtered on its own.

That isn't a suggestion. It's a fact.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post Reply

Return to “DSP and Plugin Development”