Search in sources :

Example 11 with NoteList

use of blue.soundObject.NoteList in project blue by kunstmusik.

the class LineAddProcessor method main.

public static void main(String[] args) {
    NoteList n = new NoteList();
    for (int i = 0; i < 10; i++) {
        try {
            n.add(Note.createNote("i1 " + i + " 1 3 4"));
        } catch (NoteParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    System.out.println("before: \n\n" + n + "\n\n");
    LineAddProcessor lap = new LineAddProcessor();
    lap.setLineAddString("0 0 3 -3 6 0");
    try {
        lap.processNotes(n);
    } catch (NoteProcessorException ex) {
        System.out.println("Exception: " + ex.getMessage());
    }
    System.out.println("after: \n\n" + n + "\n\n");
}
Also used : NoteList(blue.soundObject.NoteList) NoteParseException(blue.soundObject.NoteParseException)

Example 12 with NoteList

use of blue.soundObject.NoteList in project blue by kunstmusik.

the class MultiplyProcessor method main.

public static void main(String[] args) {
    NoteList n = new NoteList();
    for (int i = 0; i < 10; i++) {
        try {
            n.add(Note.createNote("i1 " + (i * 2) + " 2 3 4"));
        } catch (NoteParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    System.out.println("before: \n\n" + n + "\n\n");
    MultiplyProcessor mp = new MultiplyProcessor();
    mp.setPfield("2");
    mp.setVal("2.2f");
    try {
        mp.processNotes(n);
    } catch (NoteProcessorException ex) {
        System.out.println("Exception: " + ex.getMessage());
    }
    System.out.println("after: \n\n" + n + "\n\n");
}
Also used : NoteList(blue.soundObject.NoteList) NoteParseException(blue.soundObject.NoteParseException)

Example 13 with NoteList

use of blue.soundObject.NoteList in project blue by kunstmusik.

the class Track method generateNotes.

public NoteList generateNotes() throws NoteParseException {
    NoteList retVal = new NoteList();
    String instrId = getInstrumentId();
    try {
        Double.parseDouble(instrId);
    } catch (NumberFormatException nfe) {
        instrId = "\"" + instrId + "\"";
    }
    String noteTemplate = TextUtilities.replaceAll(getNoteTemplate(), "<INSTR_ID>", instrId);
    noteTemplate = TextUtilities.replaceAll(noteTemplate, "<INSTR_NAME>", getInstrumentId());
    for (int i = 0; i < trackerNotes.size(); i++) {
        TrackerNote trNote = trackerNotes.get(i);
        if (trNote.isActive() && !trNote.isOff()) {
            String noteStr = noteTemplate;
            int dur = 1;
            for (int j = i + 1; j < trackerNotes.size(); j++) {
                TrackerNote temp = trackerNotes.get(j);
                if (temp.isActive() || temp.isOff()) {
                    break;
                }
                dur++;
            }
            String durStr = trNote.isTied() ? "-" + dur : Integer.toString(dur);
            noteStr = TextUtilities.replaceAll(noteStr, "<START>", Integer.toString(i));
            noteStr = TextUtilities.replaceAll(noteStr, "<DUR>", durStr);
            Object[] colNameArg = new Object[1];
            for (int j = 1; j < getNumColumns(); j++) {
                Column col = getColumn(j);
                colNameArg[0] = col.getName();
                String colNameStr = COL_NAME.format(colNameArg);
                String newValue = trNote.getValue(j);
                if (col.getType() == Column.TYPE_BLUE_PCH && col.isOutputFrequency()) {
                    String[] parts = newValue.split("\\.");
                    int octave = Integer.parseInt(parts[0]);
                    int scaleDegree = Integer.parseInt(parts[1]);
                    double freq = col.getScale().getFrequency(octave, scaleDegree);
                    newValue = Double.toString(freq);
                }
                noteStr = TextUtilities.replaceAll(noteStr, colNameStr, newValue);
            }
            Note note = Note.createNote(noteStr);
            retVal.add(note);
        }
    }
    return retVal;
}
Also used : NoteList(blue.soundObject.NoteList) Note(blue.soundObject.Note)

Example 14 with NoteList

use of blue.soundObject.NoteList in project blue by kunstmusik.

the class SoundLayer method generateForCSD.

/**
 * Generates notes for the SoundLayer, skipping over soundObjects which do
 * not contribute notes between the startTime and endTime arguments.
 *
 * StartTime and endTime is adjusted by the PolyObject before passing into
 * SoundLayer if possible, if not possible, will adjust to render everything
 * and filter on top layer.
 */
public NoteList generateForCSD(CompileData compileData, double startTime, double endTime) throws SoundLayerException {
    NoteList notes = new NoteList();
    Collections.sort(this, sObjComparator);
    for (SoundObject sObj : this) {
        try {
            double sObjStart = sObj.getStartTime();
            double sObjDur = sObj.getSubjectiveDuration();
            double sObjEnd = sObjStart + sObjDur;
            if (sObjEnd > startTime) {
                if (endTime <= startTime) {
                    double adjustedStart = startTime - sObjStart;
                    if (adjustedStart < 0.0f) {
                        adjustedStart = 0.0f;
                    }
                    notes.merge((sObj).generateForCSD(compileData, adjustedStart, -1.0f));
                } else if (sObjStart < endTime) {
                    double adjustedStart = startTime - sObjStart;
                    double adjustedEnd = endTime - sObjStart;
                    if (adjustedStart < 0.0f) {
                        adjustedStart = 0.0f;
                    }
                    if (adjustedEnd >= sObjDur) {
                        adjustedEnd = -1.0f;
                    }
                    notes.merge((sObj).generateForCSD(compileData, adjustedStart, adjustedEnd));
                }
            }
        } catch (Exception e) {
            throw new SoundLayerException(this, "Error in SoundLayer: " + this.getName(), e);
        }
    }
    try {
        ScoreUtilities.applyNoteProcessorChain(notes, this.npc);
    } catch (NoteProcessorException e) {
        throw new SoundLayerException(this, "Error in SoundLayer: " + this.getName(), e);
    }
    return notes;
}
Also used : NoteProcessorException(blue.noteProcessor.NoteProcessorException) NoteList(blue.soundObject.NoteList) SoundObject(blue.soundObject.SoundObject) NoteProcessorException(blue.noteProcessor.NoteProcessorException)

Example 15 with NoteList

use of blue.soundObject.NoteList in project blue by kunstmusik.

the class ClojureSoundObjectTest method testGenerateForCSD.

/**
 * Test of generateForCSD method, of class ClojureObject.
 */
@Test
public void testGenerateForCSD() throws Exception {
    CompileData compileData = null;
    float startTime = 0.0F;
    float endTime = 2.0F;
    ClojureObject instance = new ClojureObject();
    instance.setClojureCode("(def score \"i1 0 2 3 5\")");
    NoteList result = instance.generateForCSD(compileData, startTime, endTime);
    assertEquals(result.get(0).getPField(5), "5");
}
Also used : NoteList(blue.soundObject.NoteList) CompileData(blue.CompileData) Test(org.junit.Test)

Aggregations

NoteList (blue.soundObject.NoteList)50 NoteParseException (blue.soundObject.NoteParseException)25 Note (blue.soundObject.Note)11 CompileData (blue.CompileData)6 SoundObject (blue.soundObject.SoundObject)6 GenericScore (blue.soundObject.GenericScore)4 Arrangement (blue.Arrangement)3 GlobalOrcSco (blue.GlobalOrcSco)3 Tables (blue.Tables)3 NoteProcessorException (blue.noteProcessor.NoteProcessorException)3 SoundObjectException (blue.soundObject.SoundObjectException)3 OpcodeList (blue.udo.OpcodeList)3 ParameterNameManager (blue.automation.ParameterNameManager)2 LiveObject (blue.blueLive.LiveObject)2 LiveObjectSet (blue.blueLive.LiveObjectSet)2 LinePoint (blue.components.lines.LinePoint)2 Mixer (blue.mixer.Mixer)2 TempoMapper (blue.noteProcessor.TempoMapper)2 GenericInstrument (blue.orchestra.GenericInstrument)2 Instrument (blue.orchestra.Instrument)2