[sdiy] Interesting article on top octave generators.
Chris McDowell
declareupdate at gmail.com
Sun Jan 5 23:12:37 CET 2025
Tom, can you describe this in a touch more detail? or just from another angle? I'm not quite following how this works but it sounds neat. You have a free running NCO, and from that you get the current sample of many harmonics of the fundamental by incrementing the phase by itself (some temporary copied version, not the NCO's working phase), between a series of lookups?
I think my description was much worse haha!
Chris McDowell
> On Jan 5, 2025, at 8:45 AM, Tom Wiltshire <tom at electricdruid.net> wrote:
>
> I've generated a whole series of harmonically-related sinewaves on a dsPIC by taking the NCO's phase value and sticking it in a register. Use the register to do a Sine table lookup, you've got the fundamental. Add the phase value to the register. Do another lookup. Now you have the second harmonic. Add the phase value to the register. Do another lookup. Now you have the third harmonic. Repeat those last two steps until you have all the sinewaves you need.
>
> While the waveshaping approach is interesting, I can see lots of simpler ways. Having another lookup table with 2f, another with 3f, etc would be very fast if you have lots of memory. The advantage of the multiplying-phase-by-incrementing-a-register technique described above is that you don't lose any resolution in your table look-up. You only need one sinewave table, so you can afford to have it nice and big. And there's an elegant purity about the only waveform stored in a synth being a sine!!
>
>
>> On 4 Jan 2025, at 21:19, rburnett at richieburnett.co.uk wrote:
>>
>> They convert a sinewave at one frequency into a sinewave at an integer multiple of that frequency. This can be faster than running a whole other NCO and interpolated table lookup. This is particularly so if table lookups incur wait-states and the playback index into the LUT doesn't increment in steps of a whole sample.
>>
>> You can speed up the calculations on a DSP slightly by rearranging the Chebyshev polynomials into Horner form. There are also some optimisations that can be done if you want to calculate multiple harmonics like 2f, 3f, 4f, etc at the same time.
>>
>> -Richie.
>>
>>
>>
>> On 2025-01-04 20:23, brianw wrote:
>>> I don't understand how these Chebyshev polynomials would work, or how they would help.
>>> If you have a sine wave at f, presumably as a table of samples in DSP memory like many of them have, and you want another sine wave at 3f, then you can simply skip 2 samples and use every 3rd sample. What would the T3(x) function even do? It requires four multiply operations and subtraction. A DSP would be able to read every third address in a table without even requiring an extra opcode.
>>> A quick look at NCO operation shows a Phase Accumulator and a Phase-to-Amplitude Converter, which usually contains a Look-Up Table. It seems like it would be easier to just have a second NCO borrow most of the PA of the first NCO, but triple the rate of the phase accumulation.
>>> I suppose there could be a savings if the PAC uses complicated interpolation that's more expensive than the four multiply-accumulate operations that the T3(x) function has.
>>> Brian
>>> On Dec 28, 2024, at 3:50 AM, Richie Burnett wrote:
>>>> In "DSP land" you can use Chebyshev polynomials of the first kind to multiply the frequency of a sine-wave by an integer...
>>>> https://en.wikipedia.org/wiki/Chebyshev_polynomials#First_kind
>>>> So, if you have a sine-wave at f and want another sine-wave at 3f you can "wave-shape" it using the T3(x) function in that table. This can be quicker than running another NCO at 3f and another (interpolated) LUT to convert it's phase-angle to a sine-wave, provided your processor is quick at maths. The f and 3f waveforms are guaranteed to be "phase locked", if that is what you're after. If you don't want them phase locked then running a bunch of "Magic circle" algorithms is probably the quickest way to get a load of sine-waves at arbitrary frequencies.
>>>> Real tone-wheels don't generate pure sine-waves though (>.<)
>>>> -Richie,
>>>> -----Original Message----- From: Tom Wiltshire
>>>> Sent: Friday, December 27, 2024 11:48 PM
>>>> To: Roman
>>>> Cc: synth-diy at synth-diy org
>>>> Subject: Re: [sdiy] Interesting article on top octave generators.
>>>> I think the tonewheel "n/m" thing is actually quite a bit harder to do. The obvious way would be an NCO, since that gives you the fractional divider structure, the n/m, but then you have a problem with jitter, which is not something the gearwheels in the original generator have to deal with. With rotating gears, you can multiply a frequency *up* or *down* by whatever tooth-ratio you like, within reason. Since in that situation you might be after sinewaves instead of squares, perhaps some kind of pulse-density-modulated sine output would be ok. Yes, there'd be some small amount of jitter, but after the PDM is filtered, it might well be inaudible.
>>>> It's actually a situation where DSP with a fairly low sample rate is more than acceptable, since we're only producing sinewaves and the highest sine frequency in the Hammond organ isn't that high - just under 6KHz. Hence a fairly modest DSP running at even a 20KHz sample rate could generate the sines with no aliasing.
>>>> The classic divide-down TOG can be done without jitter since it's always a whole number of master clock pulses. With the original chips running at about 2MHz, there's enough time to calculate the outputs on a basic processor going somewhat faster (20MHz, 32MHz, whatever).
>>>> I completely agree that RPi2040 is massive overkill even for a 12-note TOG, let alone six. It's been done on an AVR, so there's really no need for such heavy firepower!
>>>> On 27 Dec 2024, at 14:06, Roman via Synth-diy <synth-diy at synth-diy.org> wrote:
>>>>> Following that route - why not make TOG replacement which produses exact frequencies of tonewheels, or better yet, switchable frequencies of every historical or another weird scales?
>>>>> Frankly, using RP2040 for 6 tone TOG is not so impressive to make video about it. Microcontroller based TOG replacements are available for decades now.
>>>>> Roman
>>>>> ---- Użytkownik Tom Wiltshire napisał ----
>>>>> .
>>>>>> I agree that it does seem a bit crazy to replace some basic logic with a whole uP, but the arguments for doing it are pretty convincing. Doing twelve 9-bit dividers in hardware is going to be a lot of chips, whereas the uP is only one. That makes it much easier to fit inside whatever it is you're fixing. And it's cheaper - a boardful of simple logic costs *more* than a processor these days because of the economies of scale. It *is* crazy to use a million transistors when 10,000 would do, but when they all come on one chip and costs pennies, it starts to make a lot of sense.
>>>>>> It terms of the technological limitations, all of the uP-based divider solutions I've seen are pretty much exact clones and just as limited as the original chips! They certainly keep the original division ratios and consequent frequency error.
>>>>>> There are a few original divider chips out there, but the people that have them want $30 a chip or worse for them. $1 processor wins over that every time.
>>> ________________________________________________________
>>> This is the Synth-diy mailing list
>>> Submit email to: Synth-diy at synth-diy.org
>>> View archive at: https://synth-diy.org/pipermail/synth-diy/
>>> Check your settings at: https://synth-diy.org/mailman/listinfo/synth-diy
>>> Selling or trading? Use marketplace at synth-diy.org
>> ________________________________________________________
>> This is the Synth-diy mailing list
>> Submit email to: Synth-diy at synth-diy.org
>> View archive at: https://synth-diy.org/pipermail/synth-diy/
>> Check your settings at: https://synth-diy.org/mailman/listinfo/synth-diy
>> Selling or trading? Use marketplace at synth-diy.org
>
>
> ________________________________________________________
> This is the Synth-diy mailing list
> Submit email to: Synth-diy at synth-diy.org
> View archive at: https://synth-diy.org/pipermail/synth-diy/
> Check your settings at: https://synth-diy.org/mailman/listinfo/synth-diy
> Selling or trading? Use marketplace at synth-diy.org
More information about the Synth-diy
mailing list