Package com.music.model

Examples of com.music.model.ExtendedPhrase


        int nextContinuationChangeMeasurePad1 = 0;
        int nextContinuationChangeMeasurePad2 = 0;

        Part mainPart = ctx.getParts().get(PartType.MAIN);
        for (Phrase phrase : mainPart.getPhraseArray()) {
            ExtendedPhrase ePhrase = (ExtendedPhrase) phrase;
            for (int i = 0; i < ePhrase.getMeasures(); i++) {
                nextContinuationChangeMeasurePad1 = handlePads(ctx, ePhrase.getScale(), pad1Phrase, i, nextContinuationChangeMeasurePad1, pad1Long);
                if (pad2 != null) {
                    nextContinuationChangeMeasurePad2 = handlePads(ctx, ePhrase.getScale(), pad2Phrase, i, nextContinuationChangeMeasurePad2, pad2Long);
                }
            }
        }
    }
View Full Code Here


        for (ExtendedPhrase phrase : lCtx.getPhrases()) {
            if (Chance.test(35)) {
                logger.debug("Repeating phrase");
                int repetitions = 1 + random.nextInt(lCtx.isSimplePhrases() ? 3 : 2);
                for (int i = 0; i < repetitions; i ++) {
                    ExtendedPhrase copy = phrase.copy();
                    if (Chance.test(15)) {
                        copy.setInstrument(InstrumentGroups.MAIN_PART_INSTRUMENTS[random.nextInt(InstrumentGroups.MAIN_PART_INSTRUMENTS.length)]);
                    }
                    phrases.add(random.nextInt(phrases.size()), copy);
                    lCtx.setTotalMeasures(lCtx.getTotalMeasures() + phrase.getMeasures());
                }
            } else {
View Full Code Here

        if (Chance.test(43)) {
            int pitch = Pitches.C4 + lCtx.getScoreContext().getKeyNote();
            // initial note is needed, so that accompaniment can "hook" to it.
            Note note = NoteFactory.createNote(pitch, JMC.QUARTER_NOTE);
            double restLength = lCtx.getScoreContext().getNormalizedMeasureSize() - JMC.QUARTER_NOTE;
            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

        }
        return -1;
    }

    private void createNewPhrase(MainPartContext lCtx, Part part) {
        lCtx.setCurrentPhrase(new ExtendedPhrase());
        lCtx.getCurrentPhrase().setTitle("Phrase " + lCtx.getPhrases().size());
        lCtx.getCurrentPhrase().setScale(lCtx.getCurrentScale());
        lCtx.getCurrentPhrase().setContour(lCtx.getContour());
        lCtx.setCurrentPhraseMotifsCount(2 + random.nextInt(4));
        //currentPhrase.setTempo(score.getTempo() + random.nextInt(20) - 10); TODO synchronize with other parts
View Full Code Here

        lCtx.setCurrentPhrase(null); // end of phrase, start a new one
        lCtx.setCurrentPhraseMeasuresCounter(0);
        lCtx.setPreviousLength(0);

        // one-or-two-measure rest before the next phrase
        ExtendedPhrase pausePhrase = new ExtendedPhrase();
        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[] percussions = getRandomPercussionPattern();

            // TODO allow for -..-..-., and generally allow more strictly accented beats
            boolean useMiddleBeats = Chance.test(5);

            ExtendedPhrase ePhrase = (ExtendedPhrase) phrase;
            double beatNoteLength = ctx.getNormalizedMeasureSize() / 8;
            if (useMiddleBeats) {
                beatNoteLength = ctx.getNormalizedMeasureSize() / 16;
            }
            for (int i = 0; i < ePhrase.getMeasures(); i++) {
                List<Phrase> fullKit = new ArrayList<Phrase>();

                // sometimes alternate the pattern per measure
                if (Chance.test(8)) {
                    percussions = getRandomPercussionPattern();
View Full Code Here

            Phrase dronePhrase = new Phrase();
            if (!(phrase instanceof ExtendedPhrase) || Chance.test(17)) { // skip the drone for some phrases
                continue;
            }

            ExtendedPhrase ePhrase = (ExtendedPhrase) phrase;

            // change the drone type
            if (droneNotes == null || ePhrase.getScale() == ctx.getAlternativeScale() || Chance.test(10)) {
                droneNotes = getDroneNotes(ePhrase.getScale(), ctx.getKeyNote(), ctx.getNormalizedMeasureSize(), ePhrase.getMeasures(), dronePart.getInstrument());
            }

            // if one note is held the entire time;
            if (droneNotes.length == 1) {
                dronePhrase.addNote(droneNotes[0]);
            } else {
                for (int i = 0; i < ePhrase.getMeasures(); i++) {
                    dronePhrase.addNoteList(droneNotes);
                }
            }
            dronePart.add(dronePhrase);
        }
View Full Code Here

        Phrase[] phrases = mainPart.getPhraseArray();

        double durationModifier = Chance.test(30) ? SpecialNoteType.STACCATO.getValue() : 0;

        for (Phrase phrase : phrases) {
            ExtendedPhrase extPhrase = ((ExtendedPhrase) phrase);
            Scale currentScale = extPhrase.getScale();
            if (currentScale.getDefinition().length != 7) { //no bass for irregular scales, for now
                continue;
            }
            Phrase bassPhrase = new Phrase();
            for (int i = 0; i < extPhrase.getMeasures(); i++) {
                for (int k = 0; k < 2; k++) {
                    if (Chance.test(70)) {
                        int degreeIdx = 0;
                        if (dullBass) {
                            degreeIdx = Chance.choose(dullBassPercentages);
View Full Code Here

        ctx.setNoteLengthCoefficient(1);
        double normalizedMeasureSize = 1d * ctx.getMetre()[0] * 4 / ctx.getMetre()[1];
        ctx.setNormalizedMeasureSize(normalizedMeasureSize);
        MainPartContext lCtx = generator.initLocalContext(score, ctx);
        lCtx.setPitches(Arrays.asList(60, 80, 80));
        ExtendedPhrase p = new ExtendedPhrase();
        p.setBaseVelocity(40);
        p.setScale(ctx.getScale());
        mainPart.add(p);
        lCtx.setCurrentPhrase(p);
        for (Note note : melody) {
            p.addNote(note);
        }
        List<Note> modified = new ArrayList<>(Arrays.asList(melody));
        generator.varyBaseStructure(lCtx, modified);
        System.out.println(modified);
        for (Note note : modified) {
            p.addNote(note);
        }

        Play.midi(score);
    }
View Full Code Here

TOP

Related Classes of com.music.model.ExtendedPhrase

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.