Search in sources :

Example 11 with Pattern

use of blue.soundObject.pattern.Pattern in project blue by kunstmusik.

the class PatternObject method generateNotes.

/* COMPILATION METHODS */
public NoteList generateNotes(double renderStart, double renderEnd) throws SoundObjectException {
    NoteList tempNoteList = new NoteList();
    // check if solo is selected, if so, return only that layer's notes if
    // not muted
    boolean soloFound = false;
    double timeIncrement = 1.0f / this.subDivisions;
    for (int i = 0; i < this.size(); i++) {
        Pattern p = this.getPattern(i);
        if (p.isSolo() && !p.isMuted()) {
            soloFound = true;
            boolean[] tempPatternArray = p.values;
            for (int j = 0; j < tempPatternArray.length; j++) {
                if (tempPatternArray[j]) {
                    NoteList tempPattern;
                    try {
                        tempPattern = ScoreUtilities.getNotes(p.getPatternScore());
                    } catch (NoteParseException e) {
                        throw new SoundObjectException(this, e);
                    }
                    double start = (j * timeIncrement);
                    ScoreUtilities.setScoreStart(tempPattern, start);
                    tempNoteList.merge(tempPattern);
                }
            }
        }
    }
    if (!soloFound) {
        for (int i = 0; i < this.size(); i++) {
            Pattern p = this.getPattern(i);
            if (!p.isMuted()) {
                boolean[] tempPatternArray = p.values;
                for (int j = 0; j < tempPatternArray.length; j++) {
                    if (tempPatternArray[j]) {
                        NoteList tempPattern;
                        try {
                            tempPattern = ScoreUtilities.getNotes(p.getPatternScore());
                        } catch (NoteParseException e) {
                            throw new SoundObjectException(this, e);
                        }
                        double start = (j * timeIncrement);
                        ScoreUtilities.setScoreStart(tempPattern, start);
                        tempNoteList.merge(tempPattern);
                    }
                }
            }
        }
    }
    try {
        ScoreUtilities.applyNoteProcessorChain(tempNoteList, this.npc);
    } catch (NoteProcessorException e) {
        throw new SoundObjectException(this, e);
    }
    ScoreUtilities.applyTimeBehavior(tempNoteList, this.getTimeBehavior(), this.getSubjectiveDuration(), this.getRepeatPoint(), beats);
    ScoreUtilities.setScoreStart(tempNoteList, startTime);
    return tempNoteList;
}
Also used : Pattern(blue.soundObject.pattern.Pattern) NoteProcessorException(blue.noteProcessor.NoteProcessorException)

Aggregations

Pattern (blue.soundObject.pattern.Pattern)11 Element (electric.xml.Element)2 Iterator (java.util.Iterator)2 NoteProcessorException (blue.noteProcessor.NoteProcessorException)1 Elements (electric.xml.Elements)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 ToStringBuilder (org.apache.commons.lang3.builder.ToStringBuilder)1