Search in sources :

Example 1 with GenericInstrument

use of blue.orchestra.GenericInstrument in project blue by kunstmusik.

the class Mixer method getMixerInstrument.

public GenericInstrument getMixerInstrument(CompileData data, OpcodeList udos, int nchnls) {
    GenericInstrument instr = new GenericInstrument();
    instr.setName("Blue Mixer Instrument");
    StrBuilder buffer = new StrBuilder();
    MixerNode node = MixerNode.getMixerGraph(this);
    EffectManager manager = new EffectManager();
    buffer.append(MixerNode.getMixerCode(data, this, udos, manager, node, nchnls));
    buffer.append("outc ");
    for (int i = 0; i < nchnls; i++) {
        if (i > 0) {
            buffer.append(", ");
        }
        buffer.append(getVar(data, master, i));
    }
    buffer.append("\n").append(getClearStatements(data, nchnls));
    instr.setText(buffer.toString());
    return instr;
}
Also used : GenericInstrument(blue.orchestra.GenericInstrument) StrBuilder(org.apache.commons.lang3.text.StrBuilder)

Example 2 with GenericInstrument

use of blue.orchestra.GenericInstrument in project blue by kunstmusik.

the class OrchestraUtilities method parseInstruments.

public static ArrayList parseInstruments(File csoundTextFile) {
    ArrayList foundInstruments = null;
    BufferedReader in = null;
    try {
        in = new BufferedReader(new FileReader(csoundTextFile));
        String line = "";
        String iName = "";
        StringBuffer iBody = new StringBuffer();
        foundInstruments = new ArrayList();
        int state = 1;
        while ((line = in.readLine()) != null) {
            switch(state) {
                case 1:
                    if (line.trim().startsWith("instr")) {
                        int index = line.indexOf(';');
                        if (index != -1) {
                            iName = line.substring(index + 1);
                        }
                        state = 2;
                    }
                    break;
                case 2:
                    if (line.trim().startsWith("endin")) {
                        GenericInstrument temp = new GenericInstrument();
                        temp.setName(iName);
                        temp.setText(iBody.toString());
                        foundInstruments.add(temp);
                        iName = "";
                        iBody = new StringBuffer();
                        state = 1;
                    } else {
                        iBody.append(line).append("\n");
                    }
                    break;
            }
        }
    } catch (Exception e) {
        System.out.println(blue.BlueSystem.getString("orchestraGUI.error.instrumentParse"));
        System.out.println(e);
        foundInstruments = null;
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
                System.err.println("Could not close file");
                e.printStackTrace();
            }
        }
    }
    return foundInstruments;
}
Also used : ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) GenericInstrument(blue.orchestra.GenericInstrument) FileReader(java.io.FileReader) IOException(java.io.IOException) IOException(java.io.IOException)

Example 3 with GenericInstrument

use of blue.orchestra.GenericInstrument in project blue by kunstmusik.

the class FrozenSoundObject method generateInstruments.

public void generateInstruments(CompileData compileData) {
    Object obj = compileData.getCompilationVariable(FSO_HAS_BEEN_COMPILED);
    if (obj == null || obj != Boolean.TRUE) {
        compileData.setCompilationVariable(FSO_HAS_BEEN_COMPILED, Boolean.TRUE);
        String instrumentText = generateInstrumentText();
        if (instrumentText == null) {
            throw new RuntimeException(new SoundObjectException(this, BlueSystem.getString("audioFile.couldNotGenerate") + " " + getName()));
        }
        GenericInstrument temp = new GenericInstrument();
        temp.setName(FSO_INSTR_NAME);
        temp.setText(instrumentText);
        int iNum = compileData.addInstrument(temp);
        instrumentNumber = iNum;
    }
}
Also used : GenericInstrument(blue.orchestra.GenericInstrument)

Example 4 with GenericInstrument

use of blue.orchestra.GenericInstrument in project blue by kunstmusik.

the class AudioFile method generateInstrument.

public Instrument generateInstrument() {
    String instrumentText = generateInstrumentText();
    if (instrumentText == null) {
        return null;
    }
    GenericInstrument temp = new GenericInstrument();
    temp.setName(this.name);
    temp.setText(instrumentText);
    return temp;
}
Also used : GenericInstrument(blue.orchestra.GenericInstrument)

Example 5 with GenericInstrument

use of blue.orchestra.GenericInstrument in project blue by kunstmusik.

the class Arrangement method createAlwaysOnInstrument.

private Instrument createAlwaysOnInstrument(CompileData data, InstrumentAssignment ia, Mixer mixer, int nchnls) {
    Instrument instr = ia.instr;
    String alwaysOnInstrCode = instr.generateAlwaysOnInstrument();
    if (alwaysOnInstrCode == null || alwaysOnInstrCode.trim().isEmpty()) {
        return null;
    }
    String transformed = convertBlueMixerOut(data, mixer, ia.arrangementId, alwaysOnInstrCode, nchnls);
    GenericInstrument retVal = new GenericInstrument();
    retVal.setText(transformed);
    return retVal;
}
Also used : GenericInstrument(blue.orchestra.GenericInstrument) Instrument(blue.orchestra.Instrument) GenericInstrument(blue.orchestra.GenericInstrument)

Aggregations

GenericInstrument (blue.orchestra.GenericInstrument)17 LinePoint (blue.components.lines.LinePoint)4 StrBuilder (org.apache.commons.lang3.text.StrBuilder)4 Instrument (blue.orchestra.Instrument)3 Iterator (java.util.Iterator)3 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 Arrangement (blue.Arrangement)1 TransferableInstrument (blue.TransferableInstrument)1 Parameter (blue.automation.Parameter)1 Line (blue.components.lines.Line)1 Channel (blue.mixer.Channel)1 BlueSynthBuilder (blue.orchestra.BlueSynthBuilder)1 StringChannel (blue.orchestra.blueSynthBuilder.StringChannel)1 NoteParseException (blue.soundObject.NoteParseException)1 OpcodeList (blue.udo.OpcodeList)1 UserDefinedOpcode (blue.udo.UserDefinedOpcode)1 Point (java.awt.Point)1 FileReader (java.io.FileReader)1 InputStreamReader (java.io.InputStreamReader)1