Package jm.music.data

Examples of jm.music.data.Score


     * @param file  File to convert to a score
     *
     * @see #processFiles
     */
    private void processFile(final File file) {
        Score score = Read.midiOrJmWithSwingMessaging(file, owner);
        if (score == null) {
            return;
        }
        if (readListenerList != null) {
            score = readListenerList.scoreRead(score);
View Full Code Here


                if (directoryName == null) {
                    return;
                }
                String[] filenames = new File(directoryName).list(filter);
                for (int i = 0; i < filenames.length; i++) {
                    Score score = Read.midiOrJmWithAWTMessaging(directoryName,
                                                                filenames[i],
                                                                owner);
                    if (score != null && readListenerList != null) {
                        readListenerList.scoreRead(score);
                    }
View Full Code Here

    public Score readFile(final String directoryName, final String fileName) {
        if (directoryName == null || fileName == null) {
            return null;
        }

        Score score = null;
        String message = null;

        /** Attempt to read file */
        try {
      SMF smf = new SMF();
            score = new Score (fileName);
      InputStream is = new FileInputStream(directoryName + fileName);
            smf.read(is);       
      jm.midi.MidiParser.SMFToScore(score,smf);
        } catch (IOException e1) {
            message = e1.getMessage ();
View Full Code Here

                phrase,
                new Double(getProperty(OTHER_NOTES_TOTAL_DUR))
                    .doubleValue()
        );

        Score   s = new Score();
        Part    p = new Part();
        s.addPart(p);
        p.addPhrase(phrase);                    
    }               
View Full Code Here

public class InstrumentTester {
    public static void main(String[] args) {

        //BELLS, CRYSTAL, ATMOSPHERE, DROPS, STAR_THEME, SOUNDEFFECTS, BIRD, HELICOPTER, APPLAUSE, GUNSHOT, FRET_NOISE, TOM, SOUNDTRACK

        Score score = new Score();
        score.addPart(new Part(Instruments.CLARINET));
        Phrase phrase = new Phrase();
        score.getPart(0).addPhrase(phrase);

//        addChord(new int[] {60, 63, 65}, 1d, 90, phrase, null, true);
        for (int i = 50; i < 70; i++) {
            Note note = new Note(i, JMC.EIGHTH_NOTE);
            phrase.add(note);
View Full Code Here

import com.google.common.collect.Multiset;

public class MidiAnalyzer {

    public static void main(String[] args) {
        Score score = new Score();
        Read.midi(score, "C:\\workspace\\music\\analysis\\midi\\jarre\\EQUINOX3.MID");
        for (Part part : score.getPartArray()) {
            System.out.println(part.getTitle() + " : " + part.getInstrument());
        }
        Part part = score.getPart(1);

        System.out.println(part.getInstrument());
        part.setTempo(160);
        int previousPitch = 0;
        int prePreviousPitch = 0;
        System.out.println(score.getTimeSignature());
        Multiset<Integer> uniqueIntervals = HashMultiset.create();
        int directionChanges = 0;
        int directionRetentions = 0;

        LinkedList<Double> noteLengths = new LinkedList<>();
        for (Note note : part.getPhrase(0).getNoteArray()) {
            System.out.println(note.getPitch());
            if (!note.isRest()) {
                if (prePreviousPitch != 0) {
                    int previousDiff = previousPitch - prePreviousPitch;
                    int diff = note.getPitch() - previousPitch;
                    if (Math.signum(previousDiff) != Math.signum(diff) && diff != 0 && previousDiff != 0) {
                        directionChanges++;
                        System.out.println(prePreviousPitch + ":" + previousPitch + ":" + note.getPitch());
                    } else if (diff != 0 && previousDiff != 0) {
                        directionRetentions++;
                    }
                }
                if (note.getPitch() - previousPitch != 0) {
                    prePreviousPitch = previousPitch;
                }

                uniqueIntervals.add(previousPitch - note.getPitch());
                previousPitch = note.getPitch();
            }
            noteLengths.add(note.getRhythmValue());
        }

        double normalizedBeatSize = 1d * score.getNumerator() * 4 / score.getDenominator();
        System.out.println("Beat size: " + normalizedBeatSize);
        double currentBeatSize = 0;
        int beats = 0;
        int beatsWithPerfectHalves = 0;
        // reverse, to avoid off-beats
        for (Iterator<Double> it = noteLengths.descendingIterator(); it.hasNext();) {
            currentBeatSize += it.next();;
            if (currentBeatSize >= normalizedBeatSize) {
                currentBeatSize = 0;
                beats++;
            }
            if (currentBeatSize == normalizedBeatSize / 2) {
                beatsWithPerfectHalves++;
            }
        }

        System.out.println("Beats:beats with perfect halves -- " + beats + ":" + beatsWithPerfectHalves);

        Hashtable<String, Object> table = PhraseAnalysis.getAllStatistics(score.getPart(1).getPhrase(0), 1, 0, Scales.MAJOR_SCALE);
        for (Entry<String, Object> entry : table.entrySet()) {
            System.out.println(entry.getKey() + "=" + entry.getValue());
        }
        for (Integer interval : uniqueIntervals.elementSet()) {
            System.out.println(interval + " : " + uniqueIntervals.count(interval));
View Full Code Here

            }
        } catch (IllegalArgumentException | IllegalAccessException e) {
            throw new IllegalStateException(e);
        }

        Score score = new Score();
        Read.midi(score, "C:\\Users\\bozho\\Downloads\\7938.midi");
        for (Part part : score.getPartArray()) {
            System.out.println(part.getChannel() + " : " + part.getInstrument() + ": " + instrumentNames.get(part.getInstrument()));
        }
    }
View Full Code Here

                new Note(JMC.E5, JMC.EIGHTH_NOTE), new Note(JMC.B4, JMC.EIGHTH_NOTE),
                new Note(JMC.D5, JMC.EIGHTH_NOTE), new Note(JMC.C5, JMC.EIGHTH_NOTE),
                new Note(JMC.A4, JMC.EIGHTH_NOTE) };

        MainPartGenerator generator = new MainPartGenerator();
        Score score = new Score();
        Part mainPart = new Part("Main", 1);
        score.addPart(mainPart);
        ScoreContext ctx = new ScoreContext();
        ctx.setMetre(new int[] {3, 8});
        ctx.setScale(Scale.MINOR);
        ctx.setKeyNote(5);
        ctx.setNoteLengthCoefficient(1);
View Full Code Here

TOP

Related Classes of jm.music.data.Score

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.