Search in sources :

Example 16 with NoteList

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

the class AudioLayer method generateForCSD.

NoteList generateForCSD(CompileData compileData, double startTime, double endTime) throws SoundObjectException {
    if (compileData.getCompilationVariable("BLUE_FADE_UDO") == null) {
        StringBuilder str = new StringBuilder();
        try {
            try (BufferedReader br = new BufferedReader(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("blue/score/layers/audio/core/blue_fade.udo")))) {
                String line;
                while ((line = br.readLine()) != null) {
                    str.append(line).append("\n");
                }
            }
            compileData.appendGlobalOrc(str.toString());
        } catch (IOException ioe) {
            throw new RuntimeException("[error] AudioLayer could not load blue_fade.udo");
        }
        compileData.setCompilationVariable("BLUE_FADE_UDO", new Object());
    }
    NoteList notes = new NoteList();
    int instrId = generateInstrumentForAudioLayer(compileData);
    boolean usesEndTime = endTime > startTime;
    double adjustedEndTime = endTime - startTime;
    for (AudioClip clip : this) {
        double clipStart = clip.getStartTime();
        double clipFileStart = clip.getFileStartTime();
        double clipDur = clip.getSubjectiveDuration();
        double clipEnd = clipStart + clipDur;
        if (clipEnd <= startTime || (usesEndTime && clipStart >= endTime)) {
            continue;
        }
        Note n = Note.createNote(11);
        double adjustedStart = clipStart - startTime;
        double adjustedEnd = clipEnd - startTime;
        double startOffset = Math.max(startTime - clipStart, 0.0f);
        double newStart = Math.max(adjustedStart, 0.0f);
        double newEnd = clipEnd - startTime;
        double newDuration = (usesEndTime && newEnd > adjustedEndTime) ? adjustedEndTime - newStart : (newEnd - newStart);
        n.setPField(Integer.toString(instrId), 1);
        n.setStartTime(newStart);
        n.setSubjectiveDuration(newDuration);
        n.setPField("\"" + clip.getAudioFile().getAbsolutePath() + "\"", 4);
        n.setPField(Double.toString(clipFileStart), 5);
        n.setPField(Double.toString(startOffset), 6);
        n.setPField(Double.toString(clipDur), 7);
        int fadeType = clip.getFadeInType().ordinal();
        n.setPField(Integer.toString(fadeType), 8);
        n.setPField(Double.toString(clip.getFadeIn()), 9);
        fadeType = clip.getFadeOutType().ordinal();
        n.setPField(Integer.toString(fadeType), 10);
        n.setPField(Double.toString(clip.getFadeOut()), 11);
        notes.add(n);
    }
    return notes;
}
Also used : InputStreamReader(java.io.InputStreamReader) NoteList(blue.soundObject.NoteList) IOException(java.io.IOException) Note(blue.soundObject.Note) BufferedReader(java.io.BufferedReader) ScoreObject(blue.score.ScoreObject)

Example 17 with NoteList

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

the class CeciliaModuleCompilationUnit method generateNotes.

/**
 * @return
 * @throws NoteParseException
 */
public NoteList generateNotes(CeciliaModule cm) throws NoteParseException {
    parseScore(cm, cm.getModuleDefinition().score.trim());
    NoteList nl = new NoteList();
    if (magicInstrId != Integer.MIN_VALUE) {
        String magicNote = "i" + Integer.toString(magicInstrId) + " 0 " + cm.getSubjectiveDuration();
        nl.add(Note.createNote(magicNote));
    }
    for (Iterator iter = notes.iterator(); iter.hasNext(); ) {
        Note note = (Note) iter.next();
        String id = note.getPField(1).trim();
        String newId = (String) instrIDMap.get(id);
        note.setPField(newId, 1);
        nl.add(note);
    }
    ScoreUtilities.applyTimeBehavior(nl, SoundObject.TIME_BEHAVIOR_SCALE, cm.getSubjectiveDuration(), cm.getRepeatPoint());
    ScoreUtilities.setScoreStart(nl, cm.getStartTime());
    return nl;
}
Also used : NoteList(blue.soundObject.NoteList) Note(blue.soundObject.Note) Iterator(java.util.Iterator)

Example 18 with NoteList

use of blue.soundObject.NoteList 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 19 with NoteList

use of blue.soundObject.NoteList 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 20 with NoteList

use of blue.soundObject.NoteList 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)

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