project: tempering in MIDI-Perl?

[email protected] ("Sean M. Burke") Sun, 24 Dec 2000 13:56:22 -0700
Newsgroups perl.midi
Message-ID <[email protected]>
I was sent the message below, suggesting that making tempering
utilities in MIDI-Perl would be a good idea.  I replied by saying
that I didn't know anything about the theory or practice of
microtuning, so I couldn't be the one to do it, but that
I'd pass it on to the list here, in the hopes someone might find
it an interesting project.

While I have little idea how this all works, I'm under the impression
that it's all just a matter of inserting a pitch-wheel event immediately
after each non-percussive non-0-volume note-start event.
One could run test MIDI files thru the programs mentioned below
(http://www.netidea.com/~fredn/midiutil.htm) and then dump the resulting
MIDI file to see how those programs do what they do.

(Hint prod hint: you could implement a general retuning utility, or just
something to tune to 12-tone, and then give a little talk about it at
the Yet Another Perl Conference this June -- which will probably be in
Montréal.  You could explain the concept of temperment, play some sample
files to make it all apparent, and then explain the implemention.  My
experience with past YAPC audiences is that they'd be very receptive
to such a talk.)

Date: Wed, 13 Dec 2000 01:41:26 +0000
From: Charles Lucy <[email protected]>
Reply-To: [email protected]
Organization: LucyScaleDevelopments
To: "Sean M. Burke" <[email protected]>
Subject: [Fwd: Midi Tempering Utilities -  Improve interface and Convert to 
 perl????]

> Charles Lucy wrote:
> 
> I have found windoze programs (at url below) to convert 12tET midi
> files
> to any selected microtuning very useful.
> Yet I have now converted all my ex-ms hardware to linux, and wine
> always
> seems to fail for me.
> 
> Since you seem to have an interest in midi and possess perl skills
> beyond mine; would you be interested in making a perl version of this
> type of useful program?
> 
> NB This is NOT an offer of employment, merely a request which might
> interest you.
> 
> The original programs can be found at:
> 
> http://www.netidea.com/~fredn/midiutil.htm
> --
> ~====================================================~
> Charles Lucy - [email protected] (LucyScaleDevelopments)
> ------------  Promoting global harmony through LucyTuning  -------
> for information on LucyTuning go to http://www.ilhawaii.net/~lucy  or
> http://www.harmonics.com/lucy/
> for Lucytuned Lullabies go to http://www.lucytune.com or
> http://www.lucytune.co.uk
> --------------------------------------------------------
> 
>     ---------------------------------------------------------------
> 
>   Harmonic     Midi     Piano   Terms                                Other
>   Analyser    Temper    Tuner    of     Downloads  Demos   Links   Software
>                                  Use
> 
>                       Midi Tempering Utilities
>       [Midi-Temper]                                [Piano-Tuner]
>                            by Fred Nachbaur
> 
>                                "The Harmonic Analyser" started out as
>                                a project to investigate the
> relationship between the way notes are tuned in scales, and the
> natural harmonic series. You specify how many harmonics to take into
> account, and the program calculates the nearest harmonic to each tone
> in the scale. Deviation in percent and cents is given, and any tone
> can be edited to bring it closer (or further) from the nearest
> harmonic value.
> 
> The project has evolved from these humble beginnings into a versatile
> tempering tool, whose main uses are to improve the authenticity of
> pre-existing midi files, and to give an infinite number of
> possibilities for refinements in new work. The program includes a
> number of pre-defined temperaments, and gives the midi pitch-bend
> equivalent for each tone. The tonic note can be changed, so you can
> (for instance) do a Werckmeister temperament based on a key other than
> C.
> 
> As of Version 2.2, The Harmonic Analyser has been extensively
> upgraded, sporting many new options to make it even more useful as a
> midi tool. Read What's New for a summary of improvements over V2.1.
> The tempering data created by The Harmonic Analyser can be exported
> for use of Midi-Temper or Piano-Tuner. Program runs on any DOS system
> (including MS Windows 3.1 and 9x), icons and PIF files included for
> easy use with Windows.
> 
> The single most significant improvement is the ability to directly
> import any of over 2000 different scale temperaments from an archive
> collected and compiled by Manuel Op de Coul. Download the SCALES.ZIP
> archive file from his Scala Downloads page, then put it into the same
> directory as harmonic.exe. (Do not unzip the file!)
> 
> History:
> 21/09/99 V2.11: added info screen at end to summarize tempering
> options.
> 12/10/99 V2.2 : many new features added
> 14/10/99 V2.2a : removed a compilation error causing a stop when
> importing SCALES.ZIP
> 26/06/00 V2.2b : minor cosmetic touchup
> 
> "BASEFIX.EXE" is a small program used to calculate the required
> correction to the inputted "base frequency" (e.g. A=440) in order to
> make the final result absolute to A, rather than relative to your
> chosen tonic note. For instance, if you wanted A to be at 440 Hz. in a
> given temperament, with a chosen tonic of C, you will need this little
> program to reverse-calculate the required base frequency. Instructions
> for use provided when you run the program, or have a look at
> basefix.txt.
> 
> "Midi-Temper" (V1.2) takes the tempering data exported by Harmonic
> Analyzer and uses it to temper a pre-existing midi file. The midi may
> be Type 0 or Type 1, and may contain any number of different
> instrument patches on any number of channels. The only restriction is
> that no more than one note may sound at any given time on any channel.
> Tempering is accomplish by inserting a pitch-bend before every note-on
> event in the midi file. Various reset options are provided.
> 
> History:
> 18/09/99 V1.0: Release version.
> 21/09/99 V1.1: Minor cosmetic touchups.
> 12/10/99 V1.2: Modified for new .dat file format, arbitrary .dat
> filenames.
> 
> 
> "Piano-Tuner" (V1.1) overcomes Midi-Temper's chord or overlapping note
> limitation. However, it only allows a single instrument patch. It is
> thus ideally suited for tempering piano or harpsichord sequences
> (hence the name). If you've ever wondered what a harpsichord sounds
> like, tempered according to one of the systems in use in Bach's time,
> here's your chance!
> 
> History:
> 09/27/99 V1.0: Release version, including automatic call to
> midi1to0.exe for Type 1 midi files, courtesy Günter Nagler
> 12/10/99 V1.1: Modified for new .dat file format, arbitrary .dat
> filenames, more debugging.
> ----------------------------------------------------------------------
> 
>                              Terms of Use
> 
> The distribution packages are offered for free use and circulation.
> See License for further information. Midi-Temp and Piano-Tuner use
> Piet van Oostrom's freeware "mf2t" midi-to-text converters for
> intermediate processing. Piano-Tuner includes Günter Nagler's
> "midi1to0.exe" as a courtesy feature, with his permission. Visit his
> website for terms of use, and lots of other excellent programs and
> original music. Harmonic Analyser uses pkunzip.exe for extracting
> archives data.
> 
> ----------------------------------------------------------------------
>           Download Fred Nachbaur's Midi Tempering Utilities
> 
> Preferred method:
> Download the entire kit-and-kaboodle at once by clicking HERE. Save it
> to a temporary or archive directory on your hard drive. Unzip
> kitnkbdl.zip (285k) using the unzipper of your choice, all into the
> same working directory. If you have older versions of the software, be
> sure you select "overwrite = yes"
> 
> Alternate method:
> If you prefer to download in smaller chunks or if you're just
> downloading an upgrade, download the programs from the table below.
> Unzip the contents of all of them into the same directory (I suggest
> making a folder called "harmonic"). Files with the same filename are
> indeed the same, so it's safe to choose the "overwrite = yes"
> unzipping mode. The table also includes the documentation text files,
> for on-line reading, in case you wish to learn more about these
> programs before downloading.
> 
>                Harmonic
>               Analyser        BaseFix      Midi-Temper    Piano-Tuner
> 
>    Program   Harmonic.zip   Basefix.zip    Miditemp.zip   Pianotun.zip
>     Files       (87k)          (26k)          (100k)         (134k)
> 
>     Info     Harmonic.txt   Basefix.txt    Miditemp.txt   Pianotun.txt
>     Files       (17k)           (2k)          (8.5k)         (9.7k)
> 
>                  Copyright 1999, 2000 by Fred Nachbaur
> 
>   If you wish to experiment with the SCALES.ZIP archive, download it
>                      from the following ftp site:
> 
>       ftp://ella.mills.edu/ccm/tuning/software/scales/scales.zip
> 
>                    Last known update: Oct. 20, 2000
> 
>      Download it into your working directory, but don't unzip it.
>  Harmonic.exe will automagically extract files from it as required. If
>   you're downloading an updated version, delete the file "scales.ndx"
> from your working directory before launching harmonic.exe; the program
>      will re-create the new index based on the contents of the new
>                            scales.zip file.
> 
> ----------------------------------------------------------------------
> ----------------------------------------------------------------------
> 
>                             Demonstrations
> 
> Does tempering midi files make them more realistic or
> authentic-sounding? You be the judge. Click on the "HA" icon on the
> left for un-tempered midi, or on the "MT" icon on the right for the
> tempered (using Midi-Temp) but otherwise identical midi.
>                      [Un-Tempered]     [Tempered]
> 
>                        Original          Tempered
> 
> This is my "Divertimento No. 1 on a Study by Sor." In the tempered
> version, the two flutes use the "Natural" temperament, the 'cello and
> bass use the "Pythagorean" temperament, and the guitar (being a
> fretted instrument) remains Equal-tempered. Do you hear how the notes
> on certain chords "rub" against each other?
> ----------------------------------------------------------------------
> 
> This next one (tempered by Piano Tuner) is a bit more subtle. You've
> undoubtedly heard of J.S. Bach's"The Well-Tempered Klavier." There
> were several "Well" temperaments in use at his time, and while we
> don't know exactly which one he had in mind, it could well have been
> the "Werckmeister" temperament. This is the temperament used in the
> following short medley of two simple J.S. Bach pieces; "Minuet in G"
> (sequenced by Damien Hall) and "Bouree for Lute" (arranged for
> keyboard and sequenced by Zachary Audler.) Again, the icon on the left
> is the unchanged Equal-tempered file, and the icon on the right is the
> Werckmeister-tempered file.
>                      [Un-Tempered]     [Tempered]
> 
>                        Original          Tempered
> 
> You might have to listen to each file several times to appreciate the
> difference. One feature of the "well" temperaments is that each key
> has its own unique sound. Note how the Bouree (in A minor) has a
> distinctly different tonality than the Minuet in G in the tempered
> version.
> 
> For another example, download my Werckmeister-tempered version of
> Schubert's Arpeggione Sonata.
> ----------------------------------------------------------------------
> 
> ----------------------------------------------------------------------
> 
>                       More about temperaments...
> 
> Andrew Purdam has a well-presented page on the hows and whys of
> tempering at his website. Most of the tables used in Harmonic.exe were
> snagged from data he in turn gleaned from study of other, more arcane
> sources linked to in his page. Well worth a visit, the information is
> presented in an easy-to-handle format.
> 
> For more information on the rather tricky "5-limit, 19-tone Just
> Intonation" system, visit Brian M. Ames' page on the topic. He even
> has a nifty little demo where you can hear chords shift from ordinary
> old equal-temperament to the 5/19 Just temperament.
> 
> Another neat demonstration (this one involving Java applets) is of
> meantone scales, available at Graham Breed's Meantone Temperament Home
> Page. He has also written a pair of excellent tempering programs (see
> the "Other Free Software" section below).
> 
> An excellent introductory treatment of the topics of harmonics and
> temperaments is the section on Tuning, Scales and Temperament at the
> Physics and Psychophysics of Music site.
> 
> A more in-depth treatment from a musical and historical perspective by
> Pierre Lewis is Understanding Temperaments, he also has a recently
> (April 2000) updated JavaTuner page which lets you experiment with the
> sound of different temperaments online. Recommended!
> 
> For a truly scholarly work on the subject of Pythagorean tuning (and
> other topics), check out Margo Schulter's Pythagorean Tuning and
> Medieval Polyphony site.
> 
> Most tempering schemes involve either the relationship of notes to the
> harmonic series (as does harmonic.exe), or else explore various
> integer ratios (not necessarily harmonically related). Charles Lucy
> has spent many years working up a temperament based on an irrational
> number (Pi), and has an absolutely fascinating webpage on the topic at
> his Lucy-Tuning site.
> ----------------------------------------------------------------------
> 
> ----------------------------------------------------------------------
> 
>                         Other Free Software...
> 
> Manuel Op de Coul, the person who compiled the SCALES.ZIP archive,
> also has an extraordinary program called Scala. The DOS version is
> strictly command-line, with some 330 possible command-line options for
> truly in-depth study of temperaments. Versions for Windows 95 and
> Linux are also available. Included is the facility to micro-tune any
> of a large number of synthesizers, so the program is not limited to
> General Midi - compatible devices. Get Scala at The Scala Home Page.
> 
> Graham Breed has written two tempering programs and is offering them
> for free download from his Graham Breed's Software site. Midi-Relay
> essentially does in real-time what Miditemp/Pianotuner do to existing
> midi files. You play your external keyboard, and Midi-Relay tempers
> the output via your computer's sound card. Midi-Convert converts
> existing midi files, using either of the two approaches paralleled by
> Midi-Temper and Piano-Tuner.
> 
> [new] Robert Walker has written an impressive fractal music generator,
> The Fractal Tune Smithy which features very comprehensive tempering
> options in addition to a many other features that allow you a great
> degree of flexibility in generating fractal-based music sequences.
> Well worth checking out, the package has two modes: freeware (with
> minor restrictions) and reasonably-priced shareware (no restrictions).
> 
>  (If all this synchronicity is any indication, the time is really ripe
>                  for "The Well-Tempered Midi-File"!)
> 
> Not exactly tempering utilities, but a couple other small programs
> I've found useful or interesting: Drake Donahue and Barry Graham have
> both written programs to manipulate midi files in various ways.
> Drake's Midi Splitter can be used to split chorded midis into multiple
> channels, and might be useful as an adjunct to other programs. Barry's
> Midi-Exp expands or inverts note intervals to give new and often
> startling counterpoints. Get these progs at NWC Scriptorium Helpful
> Files
> 
> A great adjunct to your toolkit is a compact program by Marcel Sluiter
> called "Tempo.exe". Tap the ENTER key along with a recording of a
> rubato piece of music, or with the way you hear it in your head, and
> the program generates a text file compatible with Piet van Oostrom's
> "mf2t.exe" midi-to-text converter. Great for improving the realism of
> your classical midis. Get it at Marcel's Music Site
> ----------------------------------------------------------------------
> 
>         To get in touch with me, please e-mail Dogstar Music at
>                           [email protected]
>                    Go to my "About This Site" Page
>                    Go to Dogstar Music's Main Page
> ----------------------------------------------------------------------
>               ---This page last updated Oct. 8, 2000.---
> 
>                           [Valid HTML 4.0!]
> 
> 

-- 
~====================================================~
Charles Lucy - [email protected] (LucyScaleDevelopments)
------------  Promoting global harmony through LucyTuning  -------
for information on LucyTuning go to http://www.ilhawaii.net/~lucy  or
http://www.harmonics.com/lucy/
for Lucytuned Lullabies go to http://www.lucytune.com or
http://www.lucytune.co.uk     
--------------------------------------------------------

--
Sean M. Burke  [email protected]  http://www.spinn.net/~sburke/