Tuning samples to harmonics

Hello fellow renoisers!

Some time ago, I’ve derived a funky little formula. I want to share it with you now, as I found it immensely useful for doing sound design in renoise (or maybe even other synths as the principle is rather general).

17.31234049066756091*math.log(x)

“x” is the number of a harmonic, the multiplier to the base frequency of any note. The output will be the note offset in semitones from any base note, that defines a tuning to that harmonic. It will often result in fractional numbers - so it is targetting a “note” that lies between the usual tunings applied to keys in the equal temperament scale. You can also input fractional numbers for “x”, so “0.5” will be the first subharmonic (down one octave) or “1.5” a perfect natural fifth which will be different (no beating…) from a fifth reached by transposing up 7 semitones…

So it will often result in a fractional number, so a tuning between the standard scale keys. In renoise you can take account to those fractions by using fine tunings, like the cent tunings, or better: the pitch modulation in the modulation sets.

let’s do it for harmonic 3 and 5 which are especially useful for making a deep bass frequency sound more hollow. Let’s assume the pitch modulation is set to a range of 96 semitones

>>> print (17.31234049066756091*math.log(3))
19.019550008654
>>> print (17.31234049066756091*math.log(5))
27.863137138648
>>> print (17.31234049066756091*math.log(3)/96)
0.19812031259014
>>> print (17.31234049066756091*math.log(5)/96)
0.29024101186092

As you see, you will need to add “0.19812031259014” to tune to the 3rd harmonic, and “0.29024101186092” for the 5th harmonic. Try it with three sine waves tuned to the same frequency, one unchanged and the other two with these offsets - and watch the mix of all three becoming similar to a squarewave in a scope…

For tuning using semitones/cents, you would tune for the 3rd harmonic 19 semitones up, and “0.019550008654*128” = 2.502401108 cents. Renoise will only allow you to tune up 2 or 3 cents, both not perfectly aligning the harmonic. Be aware that the factor 128 is only for renoise, most other programs will use the factor 100, for 100 cents per semitone.

Here be some epic table for the offsets of the first 64 natural harmonics:

harmonic imperfect renoise tuning
    "perfect" offset

2 - 12.0000000000000 - tune: 12 + 0 Rc
3 - 19.0195500086539 - tune: 19 + 3 Rc
4 - 24.0000000000000 - tune: 24 + 0 Rc
5 - 27.8631371386483 - tune: 28 -18 Rc
6 - 31.0195500086539 - tune: 31 + 3 Rc
7 - 33.6882590646913 - tune: 34 -40 Rc
8 - 36.0000000000000 - tune: 36 + 0 Rc
9 - 38.0391000173078 - tune: 38 + 5 Rc
10 - 39.8631371386484 - tune: 40 -18 Rc
11 - 41.5131794236476 - tune: 42 -62 Rc
12 - 43.0195500086539 - tune: 43 + 3 Rc
13 - 44.4052766176931 - tune: 44 +52 Rc
14 - 45.6882590646913 - tune: 46 -40 Rc
15 - 46.8826871473022 - tune: 47 -15 Rc
16 - 48.0000000000000 - tune: 48 + 0 Rc
17 - 49.0495540950041 - tune: 49 + 6 Rc
18 - 50.0391000173078 - tune: 50 + 5 Rc
19 - 50.9751301613230 - tune: 51 - 3 Rc
20 - 51.8631371386483 - tune: 52 -18 Rc
21 - 52.7078090733451 - tune: 53 -37 Rc
22 - 53.5131794236476 - tune: 54 -62 Rc
23 - 54.2827434726842 - tune: 54 +36 Rc
24 - 55.0195500086539 - tune: 55 + 3 Rc
25 - 55.7262742772967 - tune: 56 -35 Rc
26 - 56.4052766176931 - tune: 56 +52 Rc
27 - 57.0586500259616 - tune: 57 + 8 Rc
28 - 57.6882590646913 - tune: 58 -40 Rc
29 - 58.2957719415309 - tune: 58 +38 Rc
30 - 58.8826871473022 - tune: 59 -15 Rc
31 - 59.4503557246425 - tune: 59 +58 Rc
32 - 60.0000000000000 - tune: 60 + 0 Rc
33 - 60.5327294323014 - tune: 61 -60 Rc
34 - 61.0495540950041 - tune: 61 + 6 Rc
35 - 61.5513962033396 - tune: 62 -57 Rc
36 - 62.0391000173078 - tune: 62 + 5 Rc
37 - 62.5134403875474 - tune: 63 -62 Rc
38 - 62.9751301613230 - tune: 63 - 3 Rc
39 - 63.4248266263470 - tune: 63 +54 Rc
40 - 63.8631371386484 - tune: 64 -18 Rc
41 - 64.2906240554170 - tune: 64 +37 Rc
42 - 64.7078090733451 - tune: 65 -37 Rc
43 - 65.1151770564252 - tune: 65 +15 Rc
44 - 65.5131794236476 - tune: 66 -62 Rc
45 - 65.9022371559561 - tune: 66 -13 Rc
46 - 66.2827434726842 - tune: 66 +36 Rc
47 - 66.6550662201317 - tune: 67 -44 Rc
48 - 67.0195500086539 - tune: 67 + 3 Rc
49 - 67.3765181293825 - tune: 67 +48 Rc
50 - 67.7262742772967 - tune: 68 -35 Rc
51 - 68.0691041036579 - tune: 68 + 9 Rc
52 - 68.4052766176931 - tune: 68 +52 Rc
53 - 68.7350454547584 - tune: 69 -34 Rc
54 - 69.0586500259616 - tune: 69 + 8 Rc
55 - 69.3763165622959 - tune: 69 +48 Rc
56 - 69.6882590646913 - tune: 70 -40 Rc
57 - 69.9946801699769 - tune: 70 - 1 Rc
58 - 70.2957719415309 - tune: 70 +38 Rc
59 - 70.5917165923421 - tune: 71 -52 Rc
60 - 70.8826871473022 - tune: 71 -15 Rc
61 - 71.1688480507546 - tune: 71 +22 Rc
62 - 71.4503557246425 - tune: 71 +58 Rc
63 - 71.7273590819990 - tune: 72 -35 Rc
64 - 72.0000000000000 - tune: 72 + 0 Rc

As a demonstration I will add a renoise 3.1 instrument, that uses the principle to tune 12 sine waves in additive synthesis (renoise instruments have a limit of 12 voices per note, sad…), one as the fundamental and 11 of them as its harmonics. If you move the first macro, it scans though the harmonics, always mixing ~ 3 of them - it will sound like an impossible bandpass filter, although no filtering is involved in shaping the sound this way - only the gain of each harmonic is modulated to create the sweeps.

Play with the math in action - look at the macros to have some fun…

Oh and I almost forgot…

You can also tune the modulation comb filter and ring mod to harmonics using these numbers/this formula.

Just divide the calculated offset by 119, and add via operator after the key tracker. Just like 12/119 would be an octave offset…

Awesome. Can’t wait to play with this info.

It sounds really beautiful, like throat singing or overtone flute, using the scan macro.

I had no idea that cents in renoise are 128 per semitone.

What does the waver macro do?

The “waver” will apply a saw lfo on top of the movement of the “scan” macro. 0.5 is neutral position, above/below will be positive/negative saw action blending in. You will see all the action in the instrument FX, The LFO should be the first in the first FX track, after the key tracker, in case you want to adjust the speed to something different than 4 lpc. The other LFOs are used for crossfading of the harmonics and should not be tweaked.

Thats some excellent work. Its very complex for me to understand fully ( especially as I have no clue about lua ). The harmonic series is very interesting. I’ll have to spend some time to try and break it down to understand piece by piece. Definitely produces a sound which I would like to use.

well yes - the instrument itself was thought just as a demo of the tunings. I wanted to show something that uses the technique for something that is unique within its possibilities. I admit the crossfading stuff is not straightforward to learn, also with the lua coding involved.

maybe I can help a little to understand the instrument. basically it is a bunch of sine waves, each gets its own tuning in the mod sets. look for the pitch operands in the mod sets, there the tuning forumula is applied, I calculated the offset and copy/paste the long digits number to the operands to tune the samples. Each is then a natural harmonic of the base note being played. these harmonics are then fed into an instrument fx chain each. in the first chain, there is a setup that realises a multipoint blending/crossfading of the harmonics by controlling the gainer in each harmonics’ fx lane, so you can “scan” through through the harmonics like you would sweep a filter. If there was no scanning, you would only hear a static wave composed of the harmonics, that would behave like a single cycle waveform. also each sample has a certain gain that I think I have calculated with another formula to build the instrument, so the higher the harmonic gets the quieter it will be and the sweep will sound more natural - harmonics of sounds tend to have less power than the fundamental.

the harmonic series used for this instrument is just straight natural harmonics 1-12. and yes harmonics are overtones, or rather the base frequencies of overtones. if you manage to use the formula/data above, you can tune the mod sets to other harmonics, try for some fun just the odd harmonics to make it sound like a tube, or only the even to let it sound very sharp and nasty, or composing a “melody” of harmonics by omitting some that seem misfit to you. you can also use fractional numbers for harmonics with the formula in the first post, use base 3, 5 or whatever to get into interesting chordlike realms. The joys of additive synthesis! also tuning the ring mod or comb filter to harmonics/overtones is another interesting realm with much power.

renoise can only layer 12 samples per note though, this limits the technique.

Thanks again for the in depth explanation.

I’m copying your last post into a text file to keep in a folder with the example so I can pick apart every piece of whats going on in there later.