Exemplo n.º 1
0
 public static void xml(Phrase paramPhrase) {
   Part localPart = new Part();
   localPart.addPhrase(paramPhrase);
   Score localScore = new Score("Score of " + paramPhrase.getTitle());
   localScore.addPart(localPart);
   xml(localScore, paramPhrase.getTitle() + ".xml");
 }
Exemplo n.º 2
0
 public static void au(CPhrase paramCPhrase, Instrument[] paramArrayOfInstrument) {
   Part localPart = new Part();
   localPart.addCPhrase(paramCPhrase);
   Score localScore = new Score("Score of " + paramCPhrase.getTitle());
   localScore.addPart(localPart);
   au(localScore, paramCPhrase.getTitle() + ".au", paramArrayOfInstrument);
 }
Exemplo n.º 3
0
 public static void midi(Phrase paramPhrase, String paramString) {
   Part localPart = new Part();
   localPart.addPhrase(paramPhrase);
   Score localScore = new Score("Score of " + paramPhrase.getTitle());
   localScore.addPart(localPart);
   midi(localScore, paramString);
 }
Exemplo n.º 4
0
 public static void midi(CPhrase paramCPhrase) {
   Part localPart = new Part();
   localPart.addCPhrase(paramCPhrase);
   Score localScore = new Score("Score of " + paramCPhrase.getTitle());
   localScore.addPart(localPart);
   midi(localScore, paramCPhrase.getTitle() + ".mid");
 }
Exemplo n.º 5
0
  public static void main(String[] args) {
    Phrase phr = new Phrase();

    // create a random walk
    int pitch = 60;
    for (int i = 0; i < 12; i++) {
      Note n = new Note(pitch += (int) (Math.random() * 8 - 4), SQ * (int) (Math.random() * 2 + 1));
      phr.addNote(n);
    }

    // repeat the whole thing three times
    Mod.repeat(phr, 3);

    // see the result at this stage
    View.show(phr);

    // repeat beats 2 - 4 three times
    Mod.repeat(phr, 3, 2.0, 4.0);

    // see the result of this change
    View.show(phr, 50, 50);

    // hear the result
    Part p = new Part();
    Score s = new Score();
    p.addPhrase(phr);
    s.addPart(p);
    s.setTempo(140.0);

    Play.midi(s, false);
    // false so that it doesn't close everything, the view.show() window
    // in particular

    Write.midi(s, "Repeat.mid");
  }
Exemplo n.º 6
0
 public static void au(Phrase paramPhrase, String paramString, Instrument paramInstrument) {
   Part localPart = new Part();
   localPart.addPhrase(paramPhrase);
   Score localScore = new Score("Score of " + paramPhrase.getTitle());
   localScore.addPart(localPart);
   Instrument[] arrayOfInstrument = {paramInstrument};
   au(localScore, paramString, arrayOfInstrument);
 }
Exemplo n.º 7
0
 public static void midi(Score paramScore, String paramString) {
   SMF localSMF = new SMF();
   try {
     double d1 = System.currentTimeMillis();
     System.out.println(
         "----------------------------- Writing MIDI File ------------------------------");
     localSMF.clearTracks();
     MidiParser.scoreToSMF(paramScore, localSMF);
     FileOutputStream localFileOutputStream = new FileOutputStream(paramString);
     localSMF.write(localFileOutputStream);
     double d2 = System.currentTimeMillis();
     System.out.println(
         "MIDI file '"
             + paramString
             + "' written from score '"
             + paramScore.getTitle()
             + "' in "
             + (d2 - d1) / 1000.0D
             + " seconds.");
     System.out.println(
         "------------------------------------------------------------------------------");
   } catch (IOException localIOException) {
     System.err.println(localIOException);
   }
 }
Exemplo n.º 8
0
 /** Convert a SMF into the jMusic data type */
 @SuppressWarnings("rawtypes")
 public static void SMFToScore(Score score, SMFTools smf) {
   Enumeration<Track> en = smf.getTrackList().elements();
   // Go through tracks
   while (en.hasMoreElements()) {
     Part part = new Part();
     Track smfTrack = en.nextElement();
     Vector evtList = smfTrack.getEvtList();
     Vector phrVct = new Vector();
     sortEvents(evtList, phrVct, smf, part);
     for (int i = 0; i < phrVct.size(); i++) {
       part.addPhrase((Phrase) phrVct.elementAt(i));
     }
     score.addPart(part);
     score.clean();
   }
 }
Exemplo n.º 9
0
 private static Score adjustTempo(Score paramScore) {
   Enumeration localEnumeration1 = paramScore.getPartList().elements();
   double d1 = 60.0D / paramScore.getTempo();
   while (localEnumeration1.hasMoreElements()) {
     Part localPart = (Part) localEnumeration1.nextElement();
     double d2 = d1;
     if (localPart.getTempo() != 0.0D) {
       d2 = 60.0D / localPart.getTempo();
     }
     Enumeration localEnumeration2 = localPart.getPhraseList().elements();
     while (localEnumeration2.hasMoreElements()) {
       Phrase localPhrase = (Phrase) localEnumeration2.nextElement();
       Enumeration localEnumeration3 = localPhrase.getNoteList().elements();
       while (localEnumeration3.hasMoreElements()) {
         Note localNote = (Note) localEnumeration3.nextElement();
         localNote.setRhythmValue(localNote.getRhythmValue() * d2);
         localNote.setDuration(localNote.getDuration() * d2);
       }
     }
   }
   return paramScore;
 }
Exemplo n.º 10
0
 public static void xml(Score paramScore, String paramString) {
   try {
     PrintWriter localPrintWriter = new PrintWriter(new FileWriter(paramString));
     System.out.println("--------------------- Writing XML File -----------------------");
     String str = XMLParser.scoreToXMLString(paramScore);
     localPrintWriter.print(str);
     localPrintWriter.close();
     System.out.println(
         "XML file '" + paramString + "' written from score '" + paramScore.getTitle() + "'");
     System.out.println("-------------------------------------------------------------");
   } catch (IOException localIOException) {
     System.err.println(localIOException);
   }
 }
Exemplo n.º 11
0
 public static void jm(Score paramScore, String paramString) {
   try {
     System.out.println("--------------------- Writing JM File -----------------------");
     FileOutputStream localFileOutputStream = new FileOutputStream(paramString);
     ObjectOutputStream localObjectOutputStream = new ObjectOutputStream(localFileOutputStream);
     localObjectOutputStream.writeObject(paramScore);
     localObjectOutputStream.flush();
     localObjectOutputStream.close();
     System.out.println(
         "JM file '" + paramString + "' written from score '" + paramScore.getTitle() + "'");
     System.out.println("-------------------------------------------------------------");
   } catch (IOException localIOException) {
     System.err.println(localIOException);
   }
 }
Exemplo n.º 12
0
 public static void au(Score paramScore, String paramString, Instrument[] paramArrayOfInstrument) {
   double d1 = System.currentTimeMillis();
   System.out.println(
       "------------------------------ Writing AU File --------------------------------");
   String str1 = paramString + ".jpf";
   String str2 = "jmusic.tmp";
   File localFile = new File(str2);
   if (localFile.exists()) {
     localFile.delete();
   }
   Audio.processScore(paramScore, paramArrayOfInstrument, str1);
   Audio.combine(str1, str2, paramString, true, true);
   double d2 = System.currentTimeMillis();
   System.out.println(
       "AU file '"
           + paramString
           + "' written from score '"
           + paramScore.getTitle()
           + "' in "
           + (d2 - d1) / 1000.0D
           + " seconds.");
   System.out.println(
       "-------------------------------------------------------------------------------");
 }
Exemplo n.º 13
0
 public static void xml(Score paramScore) {
   xml(paramScore, paramScore.getTitle() + ".xml");
 }
Exemplo n.º 14
0
  public ParseMidiSmart() {
    FileDialog fd;
    Frame f = new Frame();

    // open a MIDI file
    fd = new FileDialog(f, "Open MIDI file or choose cancel to" + " finish.", FileDialog.LOAD);
    fd.show();

    // break out when user presses cancel
    if (fd.getFile() == null) return;
    //        SMF smf = new SMF();
    //        try {
    //            smf.read(new FileInputStream(new File(fd.getDirectory()+fd.getFile())));
    //        } catch (IOException e) {
    //            e.printStackTrace();
    //        }
    //        Vector vector = smf.getTrackList();
    //        for (int i = 0; i < vector.size(); i++) {
    //            Score score = new Score();
    //            MidiParser.SMFToScore(score, smf);
    //            System.out.println();
    //        }
    Read.midi(s, fd.getDirectory() + fd.getFile());
    s.setTitle(fd.getFile());
    //        try {
    //            System.out.println(MidiSystem.getMidiFileFormat(fd.getFiles()[0]));
    //        } catch (InvalidMidiDataException e) {
    //            e.printStackTrace();
    //        } catch (IOException e) {
    //            e.printStackTrace();
    //        }

    Score scoreToWrite = null;
    for (int i = 0; i < s.getSize(); i++) {
      scoreToWrite = new Score();
      scoreToWrite.add(s.getPart(i));
      scoreToWrite.setTempo(200);
      Write.midi(scoreToWrite, String.format(fd.getFile() + "%d.mid", i));

      Part part = s.getPart(i);
      for (int j = 0; j < part.getSize(); j++) {
        Phrase phrase = part.getPhrase(j);
        for (int ii = 0; ii < phrase.getSize(); ii++) {
          System.out.println(phrase.getNote(ii).getNote());
        }
      }
    }

    //            //keep track of the number of scores analysed
    //            scoreCount++;
    //            //reset melody length
    //            int tempLength = 0;
    //            // iterate through each note
    //            //find the highest and lowest notes
    //            Enumeration enum1 = s.getPartList().elements();
    //            while(enum1.hasMoreElements()){
    //                Part nextPt = (Part)enum1.nextElement();
    //                Enumeration enum2 =
    //                        nextPt.getPhraseList().elements();
    //                while(enum2.hasMoreElements()){
    //                    Phrase nextPhr =
    //                            (Phrase)enum2.nextElement();
    //                    Enumeration enum3 =
    //                            nextPhr.getNoteList().elements();
    //                    while(enum3.hasMoreElements()){
    //                        Note nextNote =
    //                                (Note)enum3.nextElement();
    //                        int pitch = nextNote.getPitch();
    //                        //check range
    //                        pitchRange(pitch);
    //                        double rv =
    //                                nextNote.getRhythmValue();
    //                        //check rhythmic values
    //                        rhythmRange(rv);
    //                        //check meldoy length
    //                        tempLength++;
    //                        //check direction
    //                        upOrDown(pitch);
    //                    }
    //                }
    //            }
    // update length extremes
    // musicLength(tempLength);

    //            //output the current stats
    //            System.out.print(PRE_TEXT);
    //            System.out.println("STATS after "+scoreCount+
    //                    " files. Last score called "+
    //                    s.getTitle());
    //            System.out.print(PRE_TEXT);
    //            System.out.println("Lowest note is "+lowNote);
    //            System.out.println("Highest note is "+highNote);
    //            System.out.println("---------------------------------");
    //            System.out.println("Shortest note is "+shortestRhythm);
    //            System.out.println("Longest note is "+longestRhythm);
    //            System.out.println("---------------------------------");
    //            System.out.println("Smallest score contains "+
    //                    shortLength+" notes");
    //            System.out.println("Largest score contains "+longLength+
    //                    " notes");
    //            System.out.println("---------------------------------");
    //            System.out.println("Upward movements were "+ascending);
    //            System.out.println("Downward movements were "+
    //                    descending);
    //            System.out.println("---------------------------------");
  }
Exemplo n.º 15
0
 public static void jm(Score paramScore) {
   jm(paramScore, paramScore.getTitle() + ".jm");
 }
Exemplo n.º 16
0
 public static void midi(Part paramPart, String paramString) {
   Score localScore = new Score("Score of " + paramPart.getTitle());
   localScore.addPart(paramPart);
   midi(localScore, paramString);
 }
Exemplo n.º 17
0
 public static void jm(Part paramPart) {
   Score localScore = new Score("Score of " + paramPart.getTitle());
   localScore.addPart(paramPart);
   jm(localScore, paramPart.getTitle() + ".jm");
 }
Exemplo n.º 18
0
 public static void au(Score paramScore, Instrument paramInstrument) {
   Instrument[] arrayOfInstrument = {paramInstrument};
   au(paramScore, paramScore.getTitle() + ".au", arrayOfInstrument);
 }
Exemplo n.º 19
0
 public static void xml(Part paramPart) {
   Score localScore = new Score("Score of " + paramPart.getTitle());
   localScore.addPart(paramPart);
   xml(localScore, paramPart.getTitle() + ".xml");
 }
Exemplo n.º 20
0
 public static void midi(Note paramNote, String paramString) {
   Score localScore = new Score("Score of a single note");
   Part localPart = new Part(new Phrase(paramNote));
   localScore.addPart(localPart);
   midi(localScore, paramString);
 }
Exemplo n.º 21
0
 public static void au(Score paramScore, Instrument[] paramArrayOfInstrument) {
   au(paramScore, paramScore.getTitle() + ".au", paramArrayOfInstrument);
 }
Exemplo n.º 22
0
 public static void au(Part paramPart, String paramString, Instrument[] paramArrayOfInstrument) {
   Score localScore = new Score("Score of " + paramPart.getTitle());
   localScore.addPart(paramPart);
   au(localScore, paramString, paramArrayOfInstrument);
 }