Search in sources :

Example 6 with Note

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

the class LineAddProcessor method processNotes.

/*
     * (non-Javadoc)
     * 
     * @see blue.noteProcessor.NoteProcessor#processNotes(blue.soundObject.NoteList)
     */
@Override
public void processNotes(NoteList in) throws NoteProcessorException {
    Note temp;
    double addVal = 0f;
    double oldVal = 0f;
    ValueTimeMapper tm = ValueTimeMapper.createValueTimeMapper(this.lineAddString);
    if (tm == null) {
        throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.lineAddStringErr"), pfield);
    }
    for (int i = 0; i < in.size(); i++) {
        temp = in.get(i);
        try {
            oldVal = Double.parseDouble(temp.getPField(this.pfield));
            addVal = tm.getValueForBeat(temp.getStartTime());
        } catch (NumberFormatException ex) {
            throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.pfieldNotDouble"), pfield);
        } catch (Exception ex) {
            throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.missingPfield"), pfield);
        }
        if (Double.isNaN(addVal)) {
            throw new NoteProcessorException(this, BlueSystem.getString("noteProcessorException.noteBeatErr"), pfield);
        }
        temp.setPField(Double.toString(oldVal + addVal), this.pfield);
    }
}
Also used : Note(blue.soundObject.Note) NoteParseException(blue.soundObject.NoteParseException)

Example 7 with Note

use of blue.soundObject.Note 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 8 with Note

use of blue.soundObject.Note 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 9 with Note

use of blue.soundObject.Note 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 10 with Note

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

the class CybilOperator method multiply.

/**
 * @param cybNoteList
 * @param startIndex
 * @param endIndex
 * @param arg
 */
private static void multiply(CybilNoteList cybNoteList, int startIndex, int endIndex, CybilArg arg) {
    int pfield = cybNoteList.pfield;
    cybNoteList.index = startIndex;
    for (int i = startIndex; i < endIndex; i++) {
        Note note = cybNoteList.notes.get(i);
        double val = Double.parseDouble(note.getPField(pfield));
        val = val * arg.getValue(cybNoteList)[0];
        note.setPField(Double.toString(val), pfield);
        cybNoteList.index++;
    }
    cybNoteList.index = endIndex;
}
Also used : 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