Search in sources :

Example 46 with NoteList

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

the class BlueLiveTopComponent method triggerButtonActionPerformed.

// GEN-LAST:event_noteTemplateTextMousePressed
private void triggerButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if (data == null) {
        return;
    }
    LiveObjectSet liveObjects = data.getLiveData().getLiveObjectBins().getEnabledLiveObjectSet();
    if (liveObjects.size() > 0) {
        System.out.println("LiveObjectsSize: " + liveObjects.size());
        NoteList nl = new NoteList();
        try {
            for (LiveObject liveObj : liveObjects) {
                SoundObject sObj = liveObj.getSoundObject();
                if (sObj.getTimeBehavior() != SoundObject.TIME_BEHAVIOR_NOT_SUPPORTED) {
                    sObj.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
                }
                nl.addAll(sObj.generateForCSD(compileData, 0.0f, -1.0f));
            }
        } catch (Exception e) {
            Exceptions.printStackTrace(e);
        }
        int tempo = (Integer) tempoSpinner.getValue();
        ScoreUtilities.scaleScore(nl, 60.0f / tempo);
        String scoreText = nl.toString();
        if (scoreText != null && scoreText.length() > 0) {
            RealtimeRenderManager.getInstance().passToStdin(scoreText);
        }
    }
}
Also used : NoteList(blue.soundObject.NoteList) SoundObject(blue.soundObject.SoundObject) LiveObjectSet(blue.blueLive.LiveObjectSet) BadLocationException(javax.swing.text.BadLocationException) LiveObject(blue.blueLive.LiveObject)

Example 47 with NoteList

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

the class CSDRender method generateCSDForBlueLiveImpl.

@Override
protected synchronized CsdRenderResult generateCSDForBlueLiveImpl(BlueData data, boolean usingAPI) {
    ProjectPluginManager.getInstance().preRender(data);
    StringChannelNameManager scnm = new StringChannelNameManager();
    ArrayList<StringChannel> stringChannels = getStringChannels(data.getArrangement(), scnm);
    ParameterHelper.clearCompilationVarNames(data);
    double totalDur = 36000f;
    // making copies to use for adding compileTime tables and instruments
    Tables tables = new Tables(data.getTableSet());
    ArrayList<Parameter> originalParameters = null;
    if (usingAPI) {
        originalParameters = ParameterHelper.getAllParameters(data.getArrangement(), data.getMixer());
        assignParameterNames(originalParameters, new ParameterNameManager());
    }
    Arrangement arrangement = new Arrangement(data.getArrangement());
    arrangement.clearUnusedInstrAssignments();
    String[] instrIds = arrangement.getInstrumentIds();
    // PolyObject tempPObj = (PolyObject) data.getPolyObject().clone();
    boolean hasInstruments = arrangement.size() > 0;
    GlobalOrcSco globalOrcSco = new GlobalOrcSco(data.getGlobalOrcSco());
    OpcodeList udos = new OpcodeList(data.getOpcodeList());
    // add all UDO's from instruments and effects
    arrangement.generateUserDefinedOpcodes(udos);
    appendFtgenTableNumbers(globalOrcSco.getGlobalOrc(), tables);
    arrangement.generateFTables(tables);
    CompileData compileData = new CompileData(arrangement, tables);
    // SKIPPING ANYTHING RELATED TO SCORE
    boolean mixerEnabled = data.getMixer().isEnabled();
    Mixer mixer = null;
    if (mixerEnabled) {
        mixer = new Mixer(data.getMixer());
        assignChannelIds(compileData, mixer);
    }
    boolean generateMixer = mixerEnabled && (hasInstruments || mixer.hasSubChannelDependencies());
    int nchnls = getNchnls(data, true);
    ArrayList<Instrument> alwaysOnInstruments = new ArrayList<>();
    arrangement.preGenerateOrchestra(compileData, mixer, nchnls, alwaysOnInstruments);
    String globalSco = globalOrcSco.getGlobalSco() + "\n";
    globalSco += arrangement.generateGlobalSco(compileData) + "\n";
    globalSco = preprocessSco(globalSco, totalDur, 0, 0, null);
    NoteList generatedNotes = null;
    for (Instrument instrument : alwaysOnInstruments) {
        String sourceId = compileData.getInstrSourceId(instrument);
        if (StringUtils.isNumeric(sourceId)) {
            int instrId = arrangement.addInstrumentAtEnd(instrument);
            globalSco += "i" + instrId + " 0 " + totalDur + "\n";
        } else {
            String instrId = sourceId + "_alwaysOn";
            arrangement.addInstrumentWithId(instrument, instrId, false);
            globalSco += "i \"" + instrId + "\" 0 " + totalDur + "\n";
        }
    }
    if (usingAPI) {
        // ArrayList parameters = ParameterHelper.getAllParameters(
        // arrangement, mixer);
        generatedNotes = new NoteList();
        handleParametersForBlueLive(originalParameters, stringChannels, globalOrcSco, generatedNotes, arrangement, usingAPI);
    }
    if (generateMixer) {
        final String mixerId = "BlueMixer";
        clearUnusedMixerChannels(mixer, arrangement);
        globalOrcSco.appendGlobalOrc(mixer.getInitStatements(compileData, nchnls));
        arrangement.addInstrumentWithId(mixer.getMixerInstrument(compileData, udos, nchnls), mixerId, false);
        globalSco += "i \"BlueMixer\" 0 " + totalDur;
    }
    arrangement.addInstrument("blueAllNotesOff", createAllNotesOffInstrument(instrIds));
    String ftables = tables.getTables();
    StrBuilder score = new StrBuilder();
    score.append("<CsoundSynthesizer>\n\n");
    appendCsInstruments(compileData, data, udos, arrangement, globalOrcSco, score, mixer, true);
    appendCsScore(globalSco, ftables, generatedNotes, totalDur, score);
    score.append("</CsoundSynthesizer>");
    // Tempo tempo = data.getScore().getTempo();
    TempoMapper tempoMapper = null;
    // if (tempo.isEnabled()) {
    // tempoMapper = CSDRender.getTempoMapper(tempo);
    // } else {
    // tempoMapper = CSDRender.getTempoMapper(globalSco);
    // }
    CsdRenderResult renderResult = new CsdRenderResult(score.toString(), tempoMapper, originalParameters, stringChannels);
    return renderResult;
}
Also used : GlobalOrcSco(blue.GlobalOrcSco) NoteList(blue.soundObject.NoteList) StringChannel(blue.orchestra.blueSynthBuilder.StringChannel) Mixer(blue.mixer.Mixer) ArrayList(java.util.ArrayList) Arrangement(blue.Arrangement) LinePoint(blue.components.lines.LinePoint) TempoMapper(blue.noteProcessor.TempoMapper) ParameterNameManager(blue.automation.ParameterNameManager) OpcodeList(blue.udo.OpcodeList) StringChannelNameManager(blue.orchestra.blueSynthBuilder.StringChannelNameManager) Instrument(blue.orchestra.Instrument) GenericInstrument(blue.orchestra.GenericInstrument) Tables(blue.Tables) Parameter(blue.automation.Parameter) CompileData(blue.CompileData) StrBuilder(org.apache.commons.lang3.text.StrBuilder) CsdRenderResult(blue.services.render.CsdRenderResult)

Example 48 with NoteList

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

the class CommandlineRunner method passToStdin.

@Override
public void passToStdin(String text) {
    NoteList nl = null;
    try {
        nl = ScoreUtilities.getNotes(text);
    } catch (NoteParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        nl = null;
    }
    if (nl == null) {
        return;
    }
    for (Iterator iter = nl.iterator(); iter.hasNext(); ) {
        Note note = (Note) iter.next();
        console.passToStdin(note.toString());
    }
}
Also used : NoteList(blue.soundObject.NoteList) NoteParseException(blue.soundObject.NoteParseException) Note(blue.soundObject.Note) Iterator(java.util.Iterator)

Example 49 with NoteList

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

the class lo 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) {
        } else {
        }
    } else {
        if (isTime) {
        } else {
            for (int i = 0; i < timeValue; i++) {
                double x = i / (timeValue - 1);
                double val = Math.pow(diff, x) * start;
                Note currentNote = notes.get(cybilNoteList.index);
                String strVal = Double.toString(val);
                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 50 with NoteList

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

the class BlueLiveBinding method triggerLiveData.

protected void triggerLiveData() {
    LiveObjectSet liveObjects = data.getLiveObjectBins().getEnabledLiveObjectSet();
    if (liveObjects.size() > 0) {
        NoteList nl = new NoteList();
        try {
            for (LiveObject liveObj : liveObjects) {
                SoundObject sObj = liveObj.getSoundObject();
                if (sObj.getTimeBehavior() != SoundObject.TIME_BEHAVIOR_NOT_SUPPORTED) {
                    sObj.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
                }
                nl.addAll(sObj.generateForCSD(compileData, 0.0f, -1.0f));
            }
        } catch (Exception e) {
            Exceptions.printStackTrace(e);
        }
        ScoreUtilities.scaleScore(nl, 60.0f / data.getTempo());
        String scoreText = nl.toString();
        if (scoreText != null && scoreText.length() > 0) {
            // FIXME - this is certainly not good code but functions for now...
            BlueLiveToolBar.getInstance().sendEvents(scoreText);
        }
    }
}
Also used : NoteList(blue.soundObject.NoteList) SoundObject(blue.soundObject.SoundObject) LiveObjectSet(blue.blueLive.LiveObjectSet) LiveObject(blue.blueLive.LiveObject)

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