[sdiy] [synth-diy] integer sample period oscillator
cheater00 .
cheater00 at gmail.com
Wed Feb 12 09:53:34 CET 2014
Thank you for the demo. It sounds like the Axis Mutatis album by
Shamen. I really love your sound. There's no aliasing that I can hear.
There are inharmonic sounds, but I don't know if that's intended or if
that's the aliasing you're talking about. I can't discern any
aliasing. Would you mind playing a scale without aliasing, and then
playing the same scale with slide or something like that? Best make
the notes A 0 D 0 S 100% and just a tiny amount of release, and
unfiltered, no effects.
Cheers,
D.
On Wed, Feb 12, 2014 at 2:03 AM, Scott Nordlund <gsn10 at hotmail.com> wrote:
>> On 11 Feb 2014 06:01, "Scott Nordlund"
>> <gsn10 at hotmail.com<mailto:gsn10 at hotmail.com>> wrote:
>> >
>> > I've done this in software, by constraining oscillator frequency to
>> integer divisions of the (fixed) sample rate. It works well. You can
>> synthesize any arbitrary waveform at any frequency and apply any
>> nonlinearity, hard clipping, oscillator sync, etc. The aliases will
>> fall back onto the harmonic series, distorting the waveform and timbre
>> slightly but resulting in no inharmonicity. But there are some
>> complications. Most obviously, frequency resolution is limited, as in
>> divide-by-n variable playback sample rate systems. This is less of an
>> issue than the divide-by-n machines because it's the complete waveform
>> period that's constrained to an integer number of samples, rather than
>> each sample clock pulse itself. Thus you can get reasonable-ish
>> frequency resolution using a fixed sample rate of 96 or 192 kHz or so,
>> rather than a clock frequency of 8 MHz (in the case of many samplers).
>> And I've developed further improvements to make this work a little
>> better. A bigger problem is tha
>> > t any modulation or variation over time isn't necessarily going to
>> be well-behaved. Continuous pitch modulation is problematic because the
>> nature of the spectral distortion depends on pitch. A static waveform
>> is exactly periodic, but a continuous sweep actually resembles ordinary
>> aliasing. Other forms of modulation essentially only happen
>> discontinuously. Consider the case where you're adding a sub-audio
>> phase shift to a sawtooth wave: the phase shift slightly shifts the
>> frequency, the sawtooth's discontinuity only moves one sample at a
>> time, and it produces the exact same result as playing the shifted
>> frequency with no frequency constraint at all. So adding a little bit
>> of phase modulation negates the whole thing, and it's a trivial
>> sawtooth, aliasing and all. Things like FM with detuned operators, PWM,
>> etc. have similar problems. The result isn't always objectionable,
>> particularly if you're going for a "chiptune" sort of sound where
>> modulation is typically discontinuous an
>> > yway, but it's something to be aware of.
>>
>> What if you dithered the period length? Maybe noise-shaping it would
>> make the transitions less niticeable?
>>
>> D.
>
> That's exactly what I did. Think about it this way: for a phase accumulator oscillator making a trivial sawtooth waveform with a period of 2.33... samples, the length of each period in samples will be 3, 2, 2, 3, 2, 2... So aside from the fact that after the accumulator overflows, the remainder adds a different offset to each period (this is the fractional component), you can say that it really only make waveforms that are an integer number of samples. It's just sort of implicitly "dithered" so that the long term average period is 2.33... samples, with the "dithering" taking the form of frequency modulation by some pulse wave at some frequency. The sidebands generated by this frequency modulation and the varying offset from the fractional part are audible as aliasing. Of course there's no explicit frequency modulation or dithering; this is just another way to think about it.
>
> So, given that it needs some amount of frequency modulation to produce the correct long term average frequency, you can explicitly do this in a way that produces less audible sidebands, by either modulating the frequency at a slower rate (pulse wave vibrato rather than audio rate modulation) or randomly (noise modulation). It's also possible to constrain the oscillator frequency so that several consecutive periods play over an integer number of samples. This increases frequency resolution at the expense of introducing subharmonics, but in some cases the tradeoff is worthwhile. And conversely you can ensure that some fraction of the complete phase accumulator period is an integer number of samples, which is useful for playing back longer looped recordings. In an extreme case, you can get exactly the same result as divide-by-n variable rate sample playback, which correspondingly requires an extremely high sample rate (at least 8 MHz or so).
>
> I did a test of these techniques to see how the artifacts would sound, including some deliberately really harsh stuff, low resolution waveforms, high pitches, etc. that would ordinarily alias terribly. The sample rate is 48 kHz, so it's sort of a worst case example. Here it is: http://www.youtube.com/watch?v=hvuYZGl9ZOA
>
> The artifacts are definitely audible (I used both the vibrato and noise modulation on various sounds), more so at high frequencies, but I think they're tolerable to the extent that I can pretend it was done intentionally. Musical content aside, I think it worked out fairly well, and I continue to use these techniques when I want nasty sounding stuff without inharmonic aliasing.
>
> A major issue is that modulation of anything (pulsewidth, phase, frequency, etc.) is necessarily discontinuous, since this throws away all notion of sub-sample resolution. The "zipper noise" introduced by this discontinuous modulation can re-introduce the exact same aliasing artifacts that we're trying to avoid in the first place. So I don't think this is really suitable for everything you could possibly imagine, but it works well enough for cases where you don't mind the limitations and artifacts.
>
> Later I thought of a different technique for non-bandlimited synthesis without objectionable aliasing. Higher-order integrated wavetable synthesis (http://www.acoustics.hut.fi/publications/papers/dafx12-hoiws/) enables more or less arbitrary transposition of waveforms with greatly reduced aliasing. So assuming you want to make some quasi-periodic signal that has some kind of nasty thing happening with relatively slow, sub-audio rate modulation, you can synthesize one period of your arbitrarily mangled waveform, integrate it, write it to a double buffer, then read it out at some arbitrary pitch while synthesizing the next waveform, cross-fading through a succession of waveforms at some relatively slow rate. This double buffer thing is kind of like the way the Kawai K5 and K5000 perform additive synthesis (I think; I haven't read through enough of the relevant patents to really be certain), only the waveforms are synthesized by some totally arbitrary process rather than an inverse FFT. The integrated wavetable part means that you don't have to worry about multisamples or bandlimiting. The waveform that's being synthesized has a fixed length, so you don't have to worry about aliasing happening here either. Given generously oversampled waveforms, good quality interpolation and a reasonable sample rate (96 kHz or so), the quality should be very good. It's not computationally expensive either. But I haven't tried it.
More information about the Synth-diy
mailing list