Skip to content

Instantly share code, notes, and snippets.

@cpq
Created December 16, 2011 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpq/1485914 to your computer and use it in GitHub Desktop.
Save cpq/1485914 to your computer and use it in GitHub Desktop.
Chromatic vs natural scale
#!/usr/bin/env python
# Copyright (c) 2011 by Sergey Lyubka
# All rights reserved
#
# This program calculates note frequencies for chromatic and natural scale.
# Chromatic scale is built by splitting an octave (2x frequency bump) onto
# 12 equal intervals (semitones).
semitones = ['%.5f' % pow(pow(2, x), 1 / 12.0) for x in range(13)]
tones = [0, 2, 4, 5, 7, 9, 11] # Major scale
print 'Frequencies of chromatic notes: (all octaves are the same)'
print 'These are relative frequencies of do, re, mi, fa, sol, la, si'
print [semitones[i] for i in tones]
# The natural (quint) scale is built by the recurring algorithm:
# 1. take the base note
# 2. build a quint interval up, by multiplying the frequency to 3/2. Quint
# interval (3/2) is the most harmonious interval to the human ear after
# the octave (2/1). Harmonius means that frequencies relate as integers:
# 2/1, 3/2, 4/3, 5/4, etc
# 3. if resulting note is > 2 (next octave), divide it by 2 to bring it back
# to our octave.
#
# Note that quints can be built down, as well as up. In this case, frequencies
# will be different. That's why in harmonic scale, C# != Db, these have
# different frequencies! Most musicians cannot explain the difference.
#
# In chromatic scale, these are the same notes, cause the octave is
# split in 12 equal intervals. Almost all modern instruments use the same chromatic
# scale, meaning that modern music is inherently not harmonious! The difference is
# very hard to spot. I am unable to do it by ear, only by playing two notes of
# chromatic and harmonic scale together, the beating is obvious.
def calc_harmonic_quint_up(n):
tone = pow(3, n)
while tone > 2:
tone /= 2.0
return tone
print
print 'Frequencies of natural notes (first 21 octaves):'
for octave in range(21):
notes = [calc_harmonic_quint_up(note + 8 * octave) for note in range(7)]
print ['%.5f' % x for x in sorted(notes)]
print
print 'Note the difference in frequencies!'
print 'Our music is built on chromatic scale, and is dissonant by design.'
@cpq
Copy link
Author

cpq commented Dec 18, 2011

Script output:

Frequencies of chromatic notes: (all octaves are the same)
['1.00000', '1.12246', '1.25992', '1.33484', '1.49831', '1.68179', '1.88775']

Frequencies of natural notes (first 21 octaves):
['1.00000', '1.12500', '1.26562', '1.42383', '1.50000', '1.68750', '1.89844']
['1.01364', '1.14035', '1.20135', '1.35152', '1.52046', '1.60181', '1.80203']
['1.08244', '1.21775', '1.28289', '1.44325', '1.62366', '1.82662', '1.92434']
['1.02747', '1.15591', '1.30040', '1.46294', '1.54121', '1.73386', '1.95059']
['1.04149', '1.17168', '1.23436', '1.38865', '1.56224', '1.64581', '1.85154']
['1.11218', '1.25120', '1.31814', '1.48290', '1.66827', '1.87680', '1.97721']
['1.00209', '1.05570', '1.18766', '1.33612', '1.50314', '1.58355', '1.78149']
['1.07010', '1.20387', '1.26827', '1.42680', '1.60515', '1.69103', '1.90241']
['1.01576', '1.14273', '1.28557', '1.35435', '1.52364', '1.71410', '1.92836']
['1.02962', '1.08470', '1.22029', '1.37283', '1.54443', '1.62705', '1.83044']
['1.09950', '1.23694', '1.30311', '1.46600', '1.64925', '1.73748', '1.95467']
['1.04367', '1.17413', '1.32089', '1.39156', '1.56550', '1.76119', '1.98134']
['1.05791', '1.11450', '1.25382', '1.41054', '1.58686', '1.67175', '1.88072']
['1.00418', '1.12971', '1.27092', '1.33891', '1.50628', '1.69456', '1.78522']
['1.01789', '1.07234', '1.20638', '1.35718', '1.42979', '1.60851', '1.80957']
['1.08697', '1.14512', '1.28826', '1.44929', '1.63046', '1.71768', '1.93239']
['1.03177', '1.16074', '1.30584', '1.37570', '1.54766', '1.74112', '1.83426']
['1.04585', '1.10180', '1.23953', '1.39447', '1.46907', '1.65270', '1.85929']
['1.11683', '1.17658', '1.32365', '1.48911', '1.67525', '1.76487', '1.98548']
['1.06012', '1.19263', '1.34171', '1.41349', '1.59018', '1.78895', '1.88465']
['1.07458', '1.13207', '1.27358', '1.43278', '1.50943', '1.69810', '1.91037']

Note the difference in frequencies!
Our music is built on chromatic scale, and is dissonant by design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment