SynthMaker

Detune?

Archive · 2005 11 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

fdner ·

Well, let me start off by saying that I'm a novice at both Synthmaker and DSP so this may sound like a rather stupid question. Nevertheless, I am eager to learn so any help would be appreciated.

My current problem is that I want to detune the oscilators on a synth to a maximum of +/- 100 cents but I haven't got a clue on how to achieve this. I know that I have to change the input frequency of the oscillators, but how do I calculate the frequency change?

platinumears ·

The easiest way is to use the pitch outputs of the MIDI to Poly instead of the frequency outs, and run them through a pitch to freq module.

The pitch signal uses a semitone scale, so detuning an osc by +100 cents just means adding 1 to the pitch before it is converted to a frequency value.

try this example

Dan 🙂

platinumears ·

Another way would be to calculate the frequency factor for the desired detune (ie: what value to multiply the frequency with to achieve the desired detune in cents)

like this

This method might be more efficient than the first, as it uses float data rather than poly for the calculations. but is only good for static offsets (for the same reason)

Dan 🙂

fdner ·

Thanks for the suggestions.

The first solution was exactly what I was looking for. 🙂

grease ·

Here's the basics (some of which you probably know already):

Moving from one note to another is accomplished by multiplication. In particular, if a note has frequency f, then the note one octave above it has frequency 2f.

To split up the octave into twelve equal tones, you want to find the right factor to move by one semitone. That is, you want to find the right value of x so that multiplying a frequency f by x twelve times will produce the frequency 2f. This number x is therefore the twelfth root of 2, or 2^(1/12), which is approximately 1.059463.

You can have an even smaller division of tones with cents. By definition, 100 cents is one semitone, or said otherwise, 1200 cents makes an octave. So the factor to multiply f by in order to move up by one cent is the number 2^(1/1200). In general, the note with frequency

(2^(c/1200))*f

is c cents above the note with frequency f. Similarly, the note with frequency

(2^(-c/1200))*f

is c cents below the note with frequency f.

You'll find this math implemented inside the "detune" module in my simple example synth called stupid_synth, available here.

Hope that helps!

Shifrin ·

Good post grease 🙂

Shif.

Nu Audio Science ·

No way i needed just this info cheers Grease 😀 😀 😀 😀

grease ·

Cool - glad I could be of help! (And thanks Shif!)

Tom7777 ·

Thanks all, often i know how to do stuff like detune but when it comes to using exact values i can get confused, thanks grease that info is very helpfull 🙂

grease ·

Well, as long as some people found that interesting, maybe I'll add a bit more...and again, I'm sure most of you know this stuff, but maybe one or two of you would find it interesting...

Perhaps you may have wondered why we break up the octave into twelve tones instead of some other number. This is a rather long story and I won't try to explain, but to be sure, other cultures have used different divisions of the octave. And even given our choice of using twelve tones, there are many ways to choose the frequencies of the notes in between a note and the note an octave above - it does not have to be done in equal amounts, and in fact "equal temperament" as it is called is considered a rather poor choice by those who are familiar with the much more consonant choices like "just intonation." (I'm not one of those people!)

Basically the idea is that two notes sound nice together if their frequency ratio is a nice ratio like 3/2 or 4/3 or some nice fraction like that with small integer numbers (that is, a frequency ratio of 1.087432 or a ratio of 27/11 won't sound as nice as something like 4/3). The reason for this has to do with the harmonics of the two notes matching up. Notes played on strings, woodwinds, etc., or synthetic notes with a square, sawtooth, or triangle waveform don't just play a root tone (that alone would be a simple sine wave). Instead, if you play a note with frequency 100Hz, you will hear the following integer multiple frequencies in the accompanying harmonics:

100, 200, 300, 400, 500, 600, 700, 800, 900,...

and if you play a note at a frequency 150Hz (this would be at a nice ratio of 3/2 with respect to the 100Hz tone), then you will hear the following frequencies:

150, 300, 450, 600, 750, 900, ...

Notice how the two notes share a lot of harmonics - 300, 600, 900, etc. So the two notes go well together in that sense.

So the idea in creating a scale, then, is to break up the octave by choosing notes that will create nice ratios with each other when played together. But some of the other things you want your notes to do will be at odds with this (using a small number of notes, including octaves of all notes, other things). So different temperaments have their strengths and weaknesses according to which conditions they attempt to satisfy, and which had to be compromised.

Observe the twelve semitone frequency ratios in an equal temperament scale, and compare them to the "pure" frequencies that they attempt to approximate:

(0) 1.000000 (Root note) (1) 1.059463 (2) 1.122462 (3) 1.189207 (Minor third, approximately 1.2 = 6/5) (4) 1.259921 (Major third, approximately 1.25 = 5/4) (5) 1.334840 (Fourth, approximately 4/3 = 1.33333...) (6) 1.414214 (7) 1.498307 (Fifth, approximately 3/2 = 1.5) (8) 1.587401 (9) 1.681793 (10) 1.781797 (11) 1.887749 (12) 2.000000 (one octave)

Note that the major and minor thirds are off from their "pure" counterparts by much greater amounts than the fifth (3/2) and fourth (4/3) are. The major third is considered a quite dissonant tone by those who know better (and again, I'm not one of those people!).

platinumears ·

Best way to hear how out an equal tempered major third is, is to try my Microtunal Tuner schematic: it opens with a 'just' tuning example, so hold a C major triad and toggle the On / Off switch. I personally think the difference is rather dramatic, especially when auditioned with pure unfiltered sawtooth waves... but if you stack up a bunch of detuned waves through a filter it gets less obvious! 😉

Dan 🙂

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.