Package jm.music.data

Examples of jm.music.data.Note


                    --pitch;
                }
            }

            // Complete the beat
            returnPhrase.addNote(new Note(pitch,
                                          rhythmValueToCompleteBeat));
        }
        return returnPhrase;
    }       
View Full Code Here


        double[][] tempBeatRVArray =
                new double[(int) phrase.getEndTime() * beatsPerBar][];
        int beatCount = 0;
        int absoluteNotesProcessed = 0;   
        double absoluteCumulativeRV = 0;
        Note note;

        while (absoluteNotesProcessed < phrase.size()) {
            int originalNotesProcessed = absoluteNotesProcessed;
            double originalCumulativeRV = absoluteCumulativeRV;

            int notesProcessed = absoluteNotesProcessed;
            double cumulativeRV = absoluteCumulativeRV;

            double[] tempRVArray = new double[phrase.size()];
            int count = 0;
            note = phrase.getNote(notesProcessed++);
            double rhythmValue = note.getRhythmValue();
            tempRVArray[count++] = rhythmValue;
            if (note.getPitch() == Note.REST) {
                tempRVArray[count - 1] *= -1;
            }


            cumulativeRV += rhythmValue;
            while (cumulativeRV != Math.ceil(cumulativeRV)) {
                note = phrase.getNote(notesProcessed++);
                rhythmValue = note.getRhythmValue();
                tempRVArray[count++] = rhythmValue;
                if (note.getPitch() == Note.REST) {
                    tempRVArray[count - 1] *= -1;
                }

                cumulativeRV += rhythmValue;
            }
            double[] RVArray = new double[count];
            System.arraycopy(tempRVArray, 0, RVArray, 0, count);
            tempBeatRVArray[beatCount++] = RVArray;

            absoluteNotesProcessed = notesProcessed;
            absoluteCumulativeRV = cumulativeRV;

            while (cumulativeRV < originalCumulativeRV + (double) beatsPerBar
                    && notesProcessed < phrase.size()) {
                note = phrase.getNote(notesProcessed++);
                rhythmValue = note.getRhythmValue();
                tempRVArray[count++] = rhythmValue;
                if (note.getPitch() == Note.REST) {
                    tempRVArray[count - 1] *= -1;
                }

                cumulativeRV += rhythmValue;
                while (cumulativeRV != Math.ceil(cumulativeRV)) {
                    note = phrase.getNote(notesProcessed++);
                    rhythmValue = note.getRhythmValue();
                    tempRVArray[count++] = rhythmValue;
                    if (note.getPitch() == Note.REST) {
                        tempRVArray[count - 1] *= -1;
                    }

                    cumulativeRV += rhythmValue;
                }
View Full Code Here

                pitch = currentPitch;
            }
            currentPitch--;
        }

        return new Note(pitch, 1.0);
    }
View Full Code Here

                        previousPitch = nextHarmoniousNote;
                    } else {
                        previousPitch = nextHarmoniousNote;
                    }
                }
                phrase.addNote(new Note(previousPitch, 2.0));
//                for (int i = 0; i < beatsPerBar - 2; i++) {                    
//                    addNote(phrase, target, targetBeat, 1.0, intervalArray, climax,
//                            lowerlimit);
//                }
            } else {
View Full Code Here

//        phrase.addNote(target);

    }

    private void addAppropriateTarget(final Phrase phrase, final Note target) {
        Note targetToAdd = target.copy();
        int lastIndex = phrase.size();
        int lastPitch;
        do {
            lastPitch = phrase.getNote(--lastIndex).getPitch();
        } while (lastPitch == Note.REST);
        int targetPitch = target.getPitch();
        if (lastPitch + 7 < targetPitch) {
            do {
                targetPitch -= 12;
            } while (targetPitch - 12 > lastPitch);
            targetToAdd.setPitch(targetPitch);
        }
        phrase.addNote(targetToAdd);
    }
View Full Code Here

                    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

        int noteCount = 0;
        double endTime = phrase.getEndTime();
        if (endTime == 0.0) {
            return new Possible[0];
        }
        Note downBeat = new Note();
        Note halfBeat = new Note();

        int size = phrase.size();
        final Possible[] chords =
                new Possible[(int) Math.ceil(endTime / beatLength)];
View Full Code Here

        double length=
          curNote[phrIndex].getRhythmValue();
        curNote[phrIndex].setRhythmValue(
            length+newTime);
      }else{
        Note restNote =new Note(REST, newTime, 0);
        restNote.setPan(midiChannel);
        restNote.setDuration(newTime);
        restNote.setOffset(0.0);
        ((Phrase) phrVct.elementAt(phrIndex)).
          addNote(restNote);
      }
      currentLength[phrIndex]+= newTime;
        }
    // get end time
    double time = MidiUtil.getEndEvt(pitch, evtList, i)/
      (double)smf.getPPQN();
    // create the new note
    Note tempNote = new Note(pitch,time, dynamic);
    tempNote.setDuration(time);
    curNote[phrIndex] = tempNote;
    ((Phrase)phrVct.elementAt(phrIndex)).addNote(curNote[phrIndex]);
    currentLength[phrIndex] += curNote[phrIndex].getRhythmValue();
  }
View Full Code Here

        System.out.print(" Phrase " + phraseCounter++ +":");
        // set a silly starting value to force and initial pan cc event
        double pan = -1.0;
        resetTicker(); // zero the ppqn error calculator
        while(phraseEnum.hasMoreElements()){
          Note note = (Note) phraseEnum.nextElement();
          offsetValue = note.getOffset();
          // add a pan control change if required
          if(note.getPan() != pan) {
            pan = note.getPan();
            midiEvents.add(new EventPair(startTime + offsetValue, new CChange((short)10,(short)(pan * 127), (short)inst.getChannel(),0)));
          }
          //check for frequency rather than MIDI notes
          int pitch = 0;
          if (note.getPitchType() == Note.FREQUENCY) {
            System.err.println("jMusic warning: converting note frequency to the closest MIDI pitch for SMF.");
            //System.exit(1);
            pitch = Note.freqToMidiPitch(note.getFrequency());
          } else pitch = note.getPitch();
          if(pitch != REST) {
            midiEvents.add(new EventPair(new Double(startTime + offsetValue),new NoteOn((short)pitch,(short)note.getDynamic(),(short)inst.getChannel(),0)));

            // Add a NoteOn for the END of the note with 0 dynamic, as recommended.
            //create a timing event at the end of the notes duration
            double endTime = startTime + (note.getDuration() * phraseTempoMultiplier);
            // Add the note-off time to the list
            midiEvents.add(new EventPair(new Double(endTime + offsetValue),new NoteOn((short)pitch, (short)0, (short)inst.getChannel(),0)));
          }
          // move the note-on time forward by the rhythmic value
          startTime += tickRounder(note.getRhythmValue() * phraseTempoMultiplier); //time between start times
          System.out.print("."); // completed a note
        }
      }
      /*
      //Sort lists so start times are in the right order
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.