Package jm.music.data

Examples of jm.music.data.Rest


                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;
            }
        } else {
            return nextContinuationChangeMeasure;
        }
View Full Code Here


                                    restLength = chordLength / 2;
                                }
                                addChord(chordPitches, chordLength - restLength, dynamics,
                                        accompanimentPhrase, specialNoteType, preferChordNotesOffset,
                                        measureOffset);
                                accompanimentPhrase.addRest(new Rest(restLength));
                            }
                        } else {
                            addChord(chordPitches, chordLength / 2, dynamics, accompanimentPhrase,
                                    specialNoteType, preferChordNotesOffset, measureOffset);
                            addChord(chordPitches, chordLength / 2, dynamics, accompanimentPhrase,
                                    specialNoteType, preferChordNotesOffset, measureOffset);
                        }
                    } else {
                        accompanimentPhrase.addRest(new Rest(chordLength));
                    }

                    measureChordLength += chordLength;
                }

                if (currentNote.isRest() && (currentMeasureSize == 0 || (interMeasureChord && isHalfMeasure))) {
                    accompanimentPhrase.addRest(new Rest(chordLength));
                    measureChordLength += chordLength;
                }

                currentMeasureSize += currentNote.getRhythmValue();
                if (currentMeasureSize >= normalizedMeasureSize) {
                    // when there's a long note and so no inter-measure chord is possible, fill the measure with a rest
                    if (measureChordLength != currentMeasureSize) {
                        double fillingSize = normalizedMeasureSize - measureChordLength;
                        accompanimentPhrase.addRest(new Rest(fillingSize));
                    }
                    currentMeasureSize = 0;
                    measureChordLength = 0;
                }
            }
View Full Code Here

                phrase.add(getNote(ctx, ToneType.TONIC));
                phrase.add(getNote(ctx, ToneType.MEDIANT));
                if (Chance.test(20)) {
                    phrase.add(getNote(ctx, ToneType.TONIC));
                } else {
                    phrase.addRest(new Rest(ctx.getNormalizedMeasureSize() / 4));
                }
                phrase.addRest(new Rest(ctx.getNormalizedMeasureSize() / 4));
            } else {
                phrase.addRest(new Rest(ctx.getNormalizedMeasureSize()));
            }
        }
        phrase.setDynamic(100);
        timpaniPart.add(phrase);
    }
View Full Code Here

                                .test(70))
                    || (lCtx.getCurrentPhraseMeasuresCounter() == lCtx.getPhraseMeasures() && Chance
                            .test(75));

            if (usePause) {
                lCtx.getCurrentPhrase().addRest(new Rest(length));
                structureItem.append("-R-");
            } else {
                Note note = createNote(lCtx, downBeat, length);

                if (lCtx.isAllowOrnaments() && Chance.test(6)) {
View Full Code Here

            ExtendedPhrase phrase = new ExtendedPhrase();
            phrase.setScale(lCtx.getScoreContext().getScale());
            phrase.setMeasures(2 + random.nextInt(3));
            phrase.add(note);
            if (restLength > 0) {
                phrase.add(new Rest(restLength));
            }
            for (int i = 0; i < phrase.getMeasures() - 1; i++) {
                phrase.addRest(new Rest(lCtx.getScoreContext().getNormalizedMeasureSize()));
            }
            lCtx.setTotalMeasures(lCtx.getTotalMeasures() + phrase.getMeasures());
            part.add(phrase);
        }
    }
View Full Code Here

        pausePhrase.setTitle("Phrase " + lCtx.getPhrases().size());
        pausePhrase.setScale(lCtx.getCurrentScale());
        int measures = Chance.test(85) || lCtx.getScoreContext().getScore().getTempo() < 90 ? 1 : 2;
        pausePhrase.setMeasures(measures);
        for (int i = 0; i < measures; i ++) {
            pausePhrase.addRest(new Rest(lCtx.getNormalizedMeasureSize())); //TODO upbeat here as well?
        }
        lCtx.getPhrases().add(pausePhrase);
        lCtx.setTotalMeasures(lCtx.getTotalMeasures() + measures);

        lCtx.setUsePreviousMeasureLengths(false);
View Full Code Here

        int erasedNotes = 1 + random.nextInt(3);
        int erasedCounter = 0;
        for (int i = 0; i < repeatedNotes.size(); i ++) {
            if (firstNotes || Chance.test(erasedNotes * 100 / repeatedNotes.size())) {
                Note removed = repeatedNotes.remove(i);
                repeatedNotes.add(i, new Rest(removed.getRhythmValue()));
                erasedCounter++;
            }
            if (erasedCounter >= erasedNotes) {
                break;
            }
View Full Code Here

                    percussions = getRandomPercussionPattern();
                }
                // don't use the drums in some measures
                if (Chance.test(6)) {
                    Phrase phr = new Phrase(0.0);
                    phr.addRest(new Rest(ctx.getNormalizedMeasureSize()));
                    fullKit.add(phr);
                    continue;
                }

                for (int j = 0; j < percussions.length; j++) {
                    Phrase phr = new Phrase(0.0);
                    for (short k = 0; k < 16; k++) {
                        int[] chances = PRIMARY_DRUM_PERCENTAGES;
                        if (j % 2 == 1 || percussions[j] == 46) {
                            chances = SECONDARY_DRUM_PERCENTAGES;
                        }
                        if ((useMiddleBeats && k % 2 == 1 && Chance.test(6)) || Chance.test(chances[k / 2])) {
                            Note note = NoteFactory.createNote(percussions[j], beatNoteLength);
                            if (k % 2 == 1) {
                                note.setDynamic(35 + random.nextInt(8));
                            } else {
                                note.setDynamic(45 + random.nextInt(10));
                            }
                            phr.addNote(note);
                        } else {
                            phr.addRest(new Rest(beatNoteLength));
                        }
                    }
                    fullKit.add(phr);
                }
View Full Code Here

                    if (Chance.test(85) && currentNotes != null) {
                        for (Note note : currentNotes) {
                            arpeggioPhrase.addNote(note);
                        }
                    } else {
                        arpeggioPhrase.addRest(new Rest(normalizedMeasureSize));
                    }
                } else if (currentMeasureSize == 0 && (currentNote.isRest() || lastMeasure)) {
                    arpeggioPhrase.addRest(new Rest(normalizedMeasureSize));
                }

                currentMeasureSize += currentNote.getRhythmValue();
                if (currentMeasureSize >= normalizedMeasureSize) {
                    currentMeasureSize = 0;
View Full Code Here

    }


    private void handleEffects(ScoreContext ctx, Phrase phrase, int restPercentages) {
        if (Chance.test(restPercentages)) {
            phrase.addRest(new Rest(ctx.getNormalizedMeasureSize()));
        } else {
            int pitch = getRandomPitch(ctx);
            double effectLength = random.nextDouble() * ctx.getNormalizedMeasureSize();
            effectLength = Math.min(effectLength, ctx.getNormalizedMeasureSize());
            Note note = NoteFactory.createNote(pitch, effectLength);
            phrase.add(note);
            double lastRest = ctx.getNormalizedMeasureSize() - effectLength;
            if (lastRest > 0) {
                phrase.add(new Rest(lastRest));
            }
        }
    }
View Full Code Here

TOP

Related Classes of jm.music.data.Rest

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.