Search in sources :

Example 11 with Note

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

the class CybilNoteList method createDefaultNote.

public Note createDefaultNote() {
    Note retVal = null;
    // Lazy initialization and caching
    if (defaultNote == null) {
        StringBuffer buffer = new StringBuffer();
        buffer.append("i");
        buffer.append(instrumentId);
        for (int i = 0; i < numPfields - 1; i++) {
            buffer.append(" 0");
        }
        try {
            defaultNote = Note.createNote(buffer.toString());
        } catch (NoteParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    // System.err.println("Default Note: " + defaultNote.toString());
    // System.err.println("Num Pfields: " + numPfields);
    }
    retVal = new Note(defaultNote);
    return retVal;
}
Also used : NoteParseException(blue.soundObject.NoteParseException) Note(blue.soundObject.Note)

Example 12 with Note

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

the class li method getValue.

@Override
public double[] getValue(CybilNoteList cybilNoteList) {
    double start = getDoubleValue(args.get(0));
    double end = getDoubleValue(args.get(1));
    double diff = end - start;
    double timeValue = getTimeValue(args.get(2));
    boolean isTime = isTime(args.get(2));
    NoteList notes = cybilNoteList.notes;
    if (cybilNoteList.pfield == 2) {
        if (isTime) {
        // TODO
        } else {
            for (int i = 0; i < timeValue; i++) {
                double x = i / (timeValue - 1);
                double val = (x * diff) + start;
                String strVal = Double.toString(val);
                Note currentNote = cybilNoteList.createDefaultNote();
                notes.add(currentNote);
                currentNote.setPField(strVal, cybilNoteList.pfield);
                cybilNoteList.index++;
                if (cybilNoteList.index >= notes.size()) {
                    break;
                }
            }
        }
    } else {
        if (isTime) {
        } else {
            for (int i = 0; i < timeValue; i++) {
                double x = i / (timeValue - 1);
                double val = (x * diff) + start;
                String strVal = Double.toString(val);
                Note currentNote = notes.get(cybilNoteList.index);
                currentNote.setPField(strVal, cybilNoteList.pfield);
                cybilNoteList.index++;
                if (cybilNoteList.index >= notes.size()) {
                    break;
                }
            }
        }
    }
    return null;
}
Also used : NoteList(blue.soundObject.NoteList) Note(blue.soundObject.Note)

Example 13 with Note

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

the class ma method getValue.

@Override
public double[] getValue(CybilNoteList cybilNoteList) {
    String ranType = (String) args.get(0);
    boolean isInteger = ranType.equals("i");
    double startMin = getDoubleValue(args.get(1));
    double startMax = getDoubleValue(args.get(2));
    double endMin = getDoubleValue(args.get(3));
    double endMax = getDoubleValue(args.get(4));
    double minDiff = endMin - startMin;
    double maxDiff = endMax - startMax;
    double timeValue = getTimeValue(args.get(5));
    boolean isTime = isTime(args.get(5));
    NoteList notes = cybilNoteList.notes;
    if (cybilNoteList.pfield == 2) {
        if (isTime) {
        } else {
        }
    } else {
        if (isTime) {
            Note currentNote = notes.get(cybilNoteList.index);
            double startTime = currentNote.getStartTime();
            double endTime = startTime + timeValue;
            int count = getCount(notes, cybilNoteList.index, endTime);
            for (int i = 0; i < count; i++) {
                double x = (currentNote.getStartTime() - startTime) / timeValue;
                double min = (minDiff * x) + startMin;
                double max = (maxDiff * x) + startMax;
                double diff = max - min;
                double val = (double) (Math.random() * diff) + min;
                String strVal = isInteger ? Integer.toString((int) val) : Double.toString(val);
                currentNote.setPField(strVal, cybilNoteList.pfield);
                cybilNoteList.index++;
                if (cybilNoteList.index >= notes.size()) {
                    break;
                }
                currentNote = notes.get(cybilNoteList.index);
            }
        } else {
            for (int i = 0; i < timeValue; i++) {
                double x = i / timeValue;
                double min = (minDiff * x) + startMin;
                double max = (maxDiff * x) + startMax;
                double diff = max - min;
                double val = (Math.random() * diff) + min;
                String strVal = isInteger ? Integer.toString((int) val) : Double.toString(val);
                Note currentNote = notes.get(cybilNoteList.index);
                currentNote.setPField(strVal, cybilNoteList.pfield);
                cybilNoteList.index++;
                if (cybilNoteList.index >= notes.size()) {
                    break;
                }
            }
        }
    }
    return null;
}
Also used : NoteList(blue.soundObject.NoteList) Note(blue.soundObject.Note)

Example 14 with Note

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

the class sq method getValue.

// TODO - Need to implement
@Override
public double[] getValue(CybilNoteList cybilNoteList) {
    String time = (String) args.get(args.size() - 1);
    double timeValue = getTimeValue(time);
    boolean isTime = isTime(time);
    if (!isTime) {
        timeValue = timeValue * (args.size() - 1);
    }
    NoteList notes = cybilNoteList.notes;
    int index = 0;
    if (cybilNoteList.pfield == 2) {
        if (isTime) {
            if (notes.size() == 0) {
                notes.add(cybilNoteList.createDefaultNote());
            }
            double startTime = cybilNoteList.p2time;
            double timeLimit = startTime + timeValue;
            while (true) {
                Object obj = args.get(index);
                if (obj instanceof CybilAlgorithm) {
                    ((CybilAlgorithm) obj).getValue(cybilNoteList);
                } else {
                    double val = getDoubleValue(obj);
                    if (cybilNoteList.p2time + val > timeLimit) {
                        break;
                    }
                    cybilNoteList.p2time += val;
                    String strVal = Double.toString(cybilNoteList.p2time);
                    Note currentNote = cybilNoteList.createDefaultNote();
                    notes.add(currentNote);
                    currentNote.setPField(strVal, cybilNoteList.pfield);
                    cybilNoteList.index++;
                }
                index++;
                if (index >= args.size() - 1) {
                    index = 0;
                }
            }
            // remove any extra notes that may have been generated
            while (true) {
                if (notes.size() == 0) {
                    break;
                }
                Note note = (Note) notes.get(notes.size() - 1);
                if (note.getStartTime() < timeLimit) {
                    break;
                }
                notes.remove(note);
                cybilNoteList.index--;
            }
        } else {
            if (notes.size() == 0) {
                notes.add(cybilNoteList.createDefaultNote());
            }
            for (int i = 0; i < timeValue; i++) {
                Object obj = args.get(index);
                if (obj instanceof CybilAlgorithm) {
                    ((CybilAlgorithm) obj).getValue(cybilNoteList);
                } else {
                    double val = getDoubleValue(obj);
                    cybilNoteList.p2time += val;
                    String strVal = Double.toString(cybilNoteList.p2time);
                    Note currentNote = cybilNoteList.createDefaultNote();
                    notes.add(currentNote);
                    currentNote.setPField(strVal, cybilNoteList.pfield);
                    cybilNoteList.index++;
                }
                index++;
                if (index >= args.size() - 1) {
                    index = 0;
                }
            }
        }
    } else {
        if (cybilNoteList.index >= notes.size()) {
            return null;
        }
        if (isTime) {
            Note currentNote = notes.get(cybilNoteList.index);
            double startTime = currentNote.getStartTime();
            double endTime = startTime + timeValue;
            int count = getCount(notes, cybilNoteList.index, endTime);
            for (int i = 0; i < count; i++) {
                Object obj = args.get(index);
                if (obj instanceof CybilAlgorithm) {
                    ((CybilAlgorithm) obj).getValue(cybilNoteList);
                } else {
                    double val = getDoubleValue(obj);
                    String strVal = Double.toString(val);
                    currentNote = notes.get(cybilNoteList.index);
                    currentNote.setPField(strVal, cybilNoteList.pfield);
                    cybilNoteList.index++;
                }
                index++;
                if (index >= args.size() - 1) {
                    index = 0;
                }
                if (cybilNoteList.index >= notes.size()) {
                    break;
                }
            }
        } else {
            for (int i = 0; i < timeValue; i++) {
                Object obj = args.get(index);
                if (obj instanceof CybilAlgorithm) {
                    ((CybilAlgorithm) obj).getValue(cybilNoteList);
                } else {
                    double val = getDoubleValue(obj);
                    Note currentNote = notes.get(cybilNoteList.index);
                    String strVal = Double.toString(val);
                    currentNote.setPField(strVal, cybilNoteList.pfield);
                    cybilNoteList.index++;
                }
                index++;
                if (index >= args.size() - 1) {
                    index = 0;
                }
                if (cybilNoteList.index >= notes.size()) {
                    break;
                }
            }
        }
    }
    // TODO Auto-generated method stub
    return null;
}
Also used : NoteList(blue.soundObject.NoteList) Note(blue.soundObject.Note)

Example 15 with Note

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

the class pa method getValue.

@Override
public double[] getValue(CybilNoteList cybilNoteList) {
    NoteList nl = cybilNoteList.notes;
    int index = Integer.parseInt((String) args.get(0));
    double[] val = new double[1];
    int currentNoteIndex = cybilNoteList.index;
    Note note = cybilNoteList.notes.get(currentNoteIndex);
    val[0] = Double.parseDouble(note.getPField(index));
    return val;
}
Also used : NoteList(blue.soundObject.NoteList) Note(blue.soundObject.Note)

Aggregations

Note (blue.soundObject.Note)30 NoteParseException (blue.soundObject.NoteParseException)14 NoteList (blue.soundObject.NoteList)11 Iterator (java.util.Iterator)2 Random (java.util.Random)2 Arrangement (blue.Arrangement)1 CompileData (blue.CompileData)1 GlobalOrcSco (blue.GlobalOrcSco)1 Tables (blue.Tables)1 ParameterNameManager (blue.automation.ParameterNameManager)1 LinePoint (blue.components.lines.LinePoint)1 Mixer (blue.mixer.Mixer)1 TempoMapper (blue.noteProcessor.TempoMapper)1 GenericInstrument (blue.orchestra.GenericInstrument)1 Instrument (blue.orchestra.Instrument)1 StringChannel (blue.orchestra.blueSynthBuilder.StringChannel)1 StringChannelNameManager (blue.orchestra.blueSynthBuilder.StringChannelNameManager)1 ScoreGenerationException (blue.score.ScoreGenerationException)1 ScoreObject (blue.score.ScoreObject)1 Tempo (blue.score.tempo.Tempo)1