optune
module in Python and you
are set to go!
There are two functions available.
score_to_csound(score, tuning=ET, tempo=80, filename="custom_tuned.csd",
A4=440.0)
The parameter score
is a Music21 Score object.
The parameter tuning
is a list of 12 values in cents for
the tuning of the 12 notes in the octave. Available presets are
Equal Temperament (ET
),
Bach/Lehman (BL
),
Kirnberger 3 (K3
), 1/4 Meantone Comma (QM
),
1/6 Pythagorean Comma (SP
),
Werckmeister III (W3
),
Vallotti (VA
), and Young 2 (Y2
).
The parameter filename
specifies the output file name for the
Csound file.
opt(s, pitchCenter='C', tempo=80, extended=False, A4=440.0)
The parameter s
is a Music21 Score object.
Note that each part must be monophonic or the result will be unpredictable.
The function writes to a Csound file named
optuned.csd
if extended
is False
or
optuned_ext.csd
if extended
is True
.
miserere.xml
in the current directory,
using 1/6 Pythagorean Comma tuning with A4 = 415.0 Hz,
perform the following steps:
from optune import *
s = converter.parse("miserere.xml")
score_to_csound(s, tuning = SP, A4 = 415.0)
custome_tuned.csd
will hold the performance
data for the piece at the default tempo 80 quarter notes per minute
with A4 set to 415Hz.
To optimally tune the piece in the sense described in the paper,
replace step 3 with
opt(s, 'B-', A4 = 415.0)
assuming that
the key signature of the piece is B-flat.
Optune is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses.