Package jm.music.data

Examples of jm.music.data.Note


            double nMeasures) {
        double beatCount = nMeasures *
                fromPhrase
                        .getNumerator();
        double beatValue;
        Note theNote;
        while ((beatCount > 0.005) &&
                (fromPhrase.size() > 0)) {
            theNote = fromPhrase.getNote(0);
            beatValue = theNote.getRhythmValue();
            toPhrase.addNote(theNote);
            fromPhrase.removeNote(0);
            beatCount -= beatValue;
        }
    }
View Full Code Here


    // Move all notes from one Phrase to another
    private void moveAll(
            Phrase fromPhrase,
            Phrase toPhrase) {
        Note theNote;
        while ((fromPhrase.size() > 0)) {
            theNote = fromPhrase.getNote(0);
            toPhrase.addNote(theNote);
            fromPhrase.removeNote(0);
        }
View Full Code Here

    public static Phrase pitchAndRhythmStringToPhrase(final String string) {
        StringProcessor processor = new StringProcessor(string);
        Phrase phrase = new Phrase();
        try {
            while (true) {
                phrase.addNote(new Note(
                        (int) processor.getNextRhythm(), processor.getNextRhythm()));
            }
        } catch (EOSException e) {
            /* This is okay.  Continue. */
        }
View Full Code Here

    public static Phrase pitchRhythmAndDynamicStringToPhrase(final String string) {
        StringProcessor processor = new StringProcessor(string);
        Phrase phrase = new Phrase();
        try {
            while (true) {
                phrase.addNote(new Note(
                        (int) processor.getNextRhythm(),
                        processor.getNextRhythm(),
                        (int) processor.getNextRhythm()));
            }
        } catch (EOSException e) {
View Full Code Here

                rectTop = 100000;
                rectRight = oldX;
                rectBot = 0;

                while (enum3.hasMoreElements()) {
                    Note aNote = (Note) enum3.nextElement();
                    int currNote = -1;
                    if (aNote.getPitchType() == Note.MIDI_PITCH) currNote = aNote.getPitch();
                    else currNote = Note.freqToMidiPitch(aNote.getFrequency());
                    if ((currNote <= 127) && (currNote >= 0)) {
                        // 10 - numb of octaves, 12 notes in an octave, 21
                        // (octavePixelheight) is the height of
                        // an octave, 156 is offset to put in position
                        int octavePixelheight = noteHeight * 7;
                        int y = (int) (((10 - currNote / 12) * octavePixelheight +
                                (ePos)) - noteOffset[currNote % 12]);
                        int x = (int) (Math.round(aNote.getDuration() * beatWidth)); //480 ppq note
                        int xRV = (int) (Math.round(aNote.getRhythmValue() * beatWidth)); //480 ppq note
                        // check if the width of the note is less than 1 so
                        // that it will be displayed
                        if (x < 1) x = 1;
                        if (y < rectTop) rectTop = y;
                        if (y > rectBot) rectBot = y;//update values to phrase rectangle
                        //set the colour change brightness for dynamic
                        offScreenGraphics.setColor(Color.getHSBColor(theColours[i % maxColours][0],
                                theColours[i % maxColours][1],
                                (float) (0.7 - (aNote.getDynamic() * 0.004))));
                        // draw note inside
                        if (aNote.getPitchType() == Note.MIDI_PITCH) {
                            offScreenGraphics.fillRect(oldX, y - noteHeight + thinNote, x,
                                    noteHeight * 2 - 2 * thinNote);
                        } else { // draw frequency derrived note
                            int heightOffset = 7;
                            for (int j = oldX; j < oldX + x - 4; j += 4) {
                                offScreenGraphics.drawLine(j, y - noteHeight + heightOffset,
                                        j + 2, y - noteHeight + heightOffset - 3);
                                offScreenGraphics.drawLine(j + 2, y - noteHeight + heightOffset - 3,
                                        j + 4, y - noteHeight + heightOffset);
                            }
                        }

                        // draw note ouside
                        offScreenGraphics.setColor(Color.getHSBColor(theColours[i % maxColours][0],
                                theColours[i % maxColours][1], (float) (0.4)));
                        offScreenGraphics.drawRect(oldX, y - noteHeight + thinNote, xRV,
                                noteHeight * 2 - 2 * thinNote);
                        //add a sharp if required
                        if ((currNote % 12) == 1 || (currNote % 12) == 3 ||
                                (currNote % 12) == 6 || (currNote % 12) == 8 ||
                                (currNote % 12) == 10) {
                            offScreenGraphics.setColor(Color.getHSBColor(
                                    theColours[i % maxColours][0],
                                    theColours[i % maxColours][1], (float) (0.3)));
                            offScreenGraphics.drawString("#", oldX - 7, y + 5);
                        }
                    }
                    oldXBeat += aNote.getRhythmValue();
                    oldX = (int) (Math.round(oldXBeat * beatWidth));
                    rectRight = oldX - rectLeft; //update value for phrase rectangle
                }
                // draw the phrase rectangle
                //offScreenGraphics.setColor(Color.lightGray);
View Full Code Here

    protected Score compose() {
        // Simple example composition
        Phrase phrase = new Phrase();
        Score s = new Score(new Part(phrase));
        //for(int i = 0; i < 8; i++) {
        Note n = new Note(48 + (int) (Math.random() * variableA), 0.5 + variableB * 0.25);
        phrase.addNote(n);
        //}

        //Instrument[] tempInsts = {new SineInst(44100)};
        //insts = tempInsts;
View Full Code Here

        }
    }

    // Add a note to the current phrase
    private void addNote(int pitchValue, char charValue) {
        Note newNote;
        int pv = pitchValue;
        if (currentNote != null) {
            newNote = currentNote.copy();
        } else {
            newNote = new Note();
        }
        if (charValue != 'R') {
            if (pv > currentPitch) {
                while (pitchIsHigh(
                        pv,
                        currentPitch,
                        charValue,
                        currentNoteLetter)) {
                    pv -= 12;
                }
            } else {
                while (pitchIsLow(
                        pv,
                        currentPitch,
                        charValue,
                        currentNoteLetter)) {
                    pv += 12;
                }
            }
        }
        if (noteIsSharp(charValue)) {
            ++pv;
        }
        if (noteIsFlat(charValue)) {
            --pv;
        }
        newNote.setPitch(pv);
        phrase.add(newNote);
        currentNote = newNote;
        currentNoteLetter = charValue;
        if (currentNoteLetter != 'R') {
            currentPitch = pv;
View Full Code Here

    }

    private void tieNotes() {
        if (phrase.size() > 1) {
            phrase.removeLastNote();
            Note lastNote;
            lastNote = phrase.getNote(phrase.size() - 1);
            lastNote.setDuration(
                    lastNote.getDuration()
                            + currentNote.getDuration()
            );
            lastNote.setRhythmValue(
                    lastNote.getRhythmValue()
                            + currentNote.getRhythmValue()
            );
            currentNote = lastNote;
        }
    }
View Full Code Here

            Enumeration enum2 = part.getPhraseList().elements();
            while (enum2.hasMoreElements()) {
                Phrase phrase = (Phrase) enum2.nextElement();
                Enumeration enum3 = phrase.getNoteList().elements();
                while (enum3.hasMoreElements()) {
                    Note note = (Note) enum3.nextElement();
                    // ignore notes with frequency as a pitch
                    if (note.getPitchType() == Note.MIDI_PITCH) {
                        if (note.getPitch() != REST) {
                            // pitch
                            pitchValues[note.getPitch()]++;
                            if (pitchValues[note.getPitch()] > maxPitchValue) maxPitchValue =
                                    pitchValues[note.getPitch()];
                            // rhythm
                            int val = (int) (note.getRhythmValue() / 0.125);
                            if (val >= rhythmValues.length) val = rhythmValues.length - 1;
                            rhythmValues[val]++;
                            if (rhythmValues[val] > maxRhythmValue)
                                maxRhythmValue = rhythmValues[val];
                            // velocities
                            dynamicValues[note.getDynamic()]++;
                            if (dynamicValues[note.getDynamic()] > maxDynamicValue) maxDynamicValue =
                                    dynamicValues[note.getDynamic()];
                            // pan
                            panValues[(int) (note.getPan() * 100)]++;
                            if (panValues[(int) (note.getPan() * 100)] > maxPanValue) maxPanValue =
                                    panValues[(int) (note.getPan() * 100)];
                        }
                    }
                }
            }
        }
View Full Code Here

                if ((longPads && Chance.test(80)) || (!longPads && Chance.test(10))) {
                    holdFor = 2 + random.nextInt(10);
                } else {
                    holdFor = 1;
                }
                Note note = NoteFactory.createNote(getRandomPitch(ctx, scale), holdFor * ctx.getNormalizedMeasureSize());
                note.setDynamic(InstrumentGroups.getInstrumentSpecificDynamics(60, phrase.getInstrument()));
                phrase.addNote(note);
                return nextContinuationChangeMeasure + holdFor;
            } else {
                phrase.addRest(new Rest(ctx.getNormalizedMeasureSize()));
                return nextContinuationChangeMeasure + 1;
View Full Code Here

TOP

Related Classes of jm.music.data.Note

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.