f



Re: Re: Music to Mathematica

At 03:01 AM 3/30/2004, Matthias.Bode@oppenheim.de wrote:
>Hello Steve, hello Marc,
>
>sorry, I wanted to be concise but was imprecise.
>
>1. I have music notes (a song) on paper (classical five line system).
>
>2. I identify (the key) the note(s) and pauses; e.g. "a" (= 440 Hz). (I can
>calculate the frequency for each note.)
>
>3. How to input this information into Mathematica in order to make it *play*
>the music?
>
>4. I do *not* want to write notes in classical notation on paper using
>Mathematica.
>
>5. I used "Scale" and entered frequencies: Unsatisfactory and clumsy because
>a longer note has to be put in several times, speed is a problem as well.


Matthias,

I think the open source Java software called JFugue (www.jfugue.org) will 
do exactly what you want.

Here is a simple example of playing a song using J/Link. Note that you will 
need to change the path below to point to your top JFugue directory (the 
place where jfugue.jar is located). This will play a very convincing piano 
rendition of Frere Jacques:


pathToJFugue = "d:\\javatools\\jfugue";

Needs["JLink`"];
InstallJava[];
AddToClassPath[pathToJFugue];

player = JavaNew["org.jfugue.Player"];
frereJacques =
     JavaNew["org.jfugue.Pattern",
         "C5q D5q E5q C5q C5q D5q E5q C5q E5q F5q G5h E5q F5q G5h G5i A5i 
G5i F5i E5q C5q G5i A5i G5i F5i E5q C5q C5q G4q C5h C5q G4q C5h"];

player@play[frereJacques]


Note that the music is entered in a simple notation giving the note name, 
the octave (C5 is middle C), and the duration (q=quarter-note, 
i=eighth-note, etc.) JFugue is well documented, easy to use, and very 
powerful. It has the ability to do multiple voices, chords, various 
instruments including percussion, etc. (the docs have a nice example of 
Frere Jacques as a round), and of course it is all incredibly simple to 
script from Mathematica using J/Link. Tinkering with a program like this is 
an excellent example of why interactive development with Mathematica and 
J/Link is often a better Java environment than Java itself.


Todd Gayley
Wolfram Research

0
tgayley (64)
4/1/2004 7:23:12 AM
comp.soft-sys.math.mathematica 28821 articles. 0 followers. Follow

1 Replies
436 Views

Similar Articles

[PageSpeed] 8

On
http://sunsite.univie.ac.at/musicfun/tunsound/
you will find a Mathematica notebook which plays scales and chords.
It should be easy to adapt for your purposes.

Erich

0
4/5/2004 10:49:54 AM
Reply: