Package com.music

Examples of com.music.ScoreContext


    private Joiner joiner = Joiner.on(",");

    @Transactional
    public long generatePiece() {
        long start = System.currentTimeMillis();
        ScoreContext ctx = generator.generatePiece();
        logger.info("Piece generation took: " + (System.currentTimeMillis() - start) + " millis");
        byte[] mp3 = null;
        byte[] midi = null;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                start = System.currentTimeMillis();
                MutingPrintStream.ignore.set(true);
                Write.midi(ctx.getScore(), baos);
                logger.info("Writing MIDI in memory took: " + (System.currentTimeMillis() - start) + " millis");
            } finally {
                MutingPrintStream.ignore.set(null);
            }
            midi = baos.toByteArray();
View Full Code Here


        private static void playMelody(SourceDataLine line, Double[] scaleFrequencies) {
            int position;
            MainPartContext lCtx = new MainPartContext();
            lCtx.setDirectionUp(true);
            ScoreContext ctx = new ScoreContext();
            double[] melody = new double[30];
            double[] lengths = new double[30];
            for (int i = 0; i < 30; i++) {
                position = getNextNotePitchIndex(ctx, lCtx, scaleFrequencies);
                double freq = scaleFrequencies[position];
View Full Code Here

        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);
        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);
        }
View Full Code Here

TOP

Related Classes of com.music.ScoreContext

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.