Introduction

Optune is a tool written in Python that automates the process of finding an optimal tuning of a piece of music from the Renaissance period based on just intonation. It is a realization of an approach described by Ross W. Duffin. Technical background for Optune is described in the paper.

Installation

Optune is compatible with Python 2.6 and 2.7. You will need to have Music21 and PyMathProg installed. Once you have downloaded the package, simply unpack it in a desired directory. You can then import the optune module in Python and you are set to go!

Usage

There are two functions available.

  1. 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.

  2. 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.

For example, to tune a piece of music in a MusicXML file named miserere.xml in the current directory, using 1/6 Pythagorean Comma tuning with A4 = 415.0 Hz, perform the following steps:
  1. from optune import *
  2. s = converter.parse("miserere.xml")
  3. score_to_csound(s, tuning = SP, A4 = 415.0)
The Csound file 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.

License

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.