Exemple #1
0
  protected void buildGUI() {
    // einmalig PropertyArray initialisieren
    if (static_pr == null) {
      static_pr = new PropertyArray();
      static_pr.text = prText;
      static_pr.textName = prTextName;
      static_pr.intg = prIntg;
      static_pr.intgName = prIntgName;
      static_pr.bool = prBool;
      static_pr.boolName = prBoolName;
      static_pr.para = prPara;
      static_pr.para[PR_WARP] = new Param(-10.0, Param.FACTOR);
      static_pr.para[PR_WARPMODDEPTH] = new Param(20.0, Param.OFFSET_AMP);
      static_pr.para[PR_INFREQ] = new Param(1000.0, Param.ABS_HZ);
      static_pr.para[PR_OUTFREQ] = new Param(1000.0, Param.ABS_HZ);
      static_pr.paraName = prParaName;
      static_pr.envl = prEnvl;
      static_pr.envl[PR_WARPENV] = Envelope.createBasicEnvelope(Envelope.BASIC_TIME);
      static_pr.envlName = prEnvlName;
      //			static_pr.superPr	= DocumentFrame.static_pr;

      fillDefaultAudioDescr(static_pr.intg, PR_OUTPUTTYPE, PR_OUTPUTRES);
      fillDefaultGain(static_pr.para, PR_GAIN);
      static_presets = new Presets(getClass(), static_pr.toProperties(true));
    }
    presets = static_presets;
    pr = (PropertyArray) static_pr.clone();

    // -------- GUI bauen --------

    GridBagConstraints con;

    PathField ggInputFile, ggOutputFile;
    PathField[] ggParent1;
    ParamField ggWarp, ggWarpModDepth, ggInFreq, ggOutFreq;
    JCheckBox ggWarpMod;
    EnvIcon ggWarpEnv;
    Component[] ggGain;
    JComboBox ggFrameSize, ggOverlap;

    gui = new GUISupport();
    con = gui.getGridBagConstraints();
    con.insets = new Insets(1, 2, 1, 2);

    ParamListener paramL =
        new ParamListener() {
          public void paramChanged(ParamEvent e) {
            int ID = gui.getItemID(e);

            switch (ID) {
              case GG_WARP:
              case GG_INFREQ:
                pr.para[ID - GG_OFF_PARAMFIELD] = ((ParamField) e.getSource()).getParam();
                recalcOutFreq();
                break;

              case GG_OUTFREQ:
                pr.para[ID - GG_OFF_PARAMFIELD] = ((ParamField) e.getSource()).getParam();
                recalcWarpAmount();
                break;
            }
          }
        };

    ItemListener il =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            int ID = gui.getItemID(e);

            switch (ID) {
              case GG_WARPMOD:
                pr.bool[ID - GG_OFF_CHECKBOX] = ((JCheckBox) e.getSource()).isSelected();
                reflectPropertyChanges();
                break;
            }
          }
        };

    PathListener pathL =
        new PathListener() {
          public void pathChanged(PathEvent e) {
            int ID = gui.getItemID(e);

            switch (ID) {
              case GG_INPUTFILE:
                setInput(((PathField) e.getSource()).getPath().getPath());
                break;
            }
          }
        };

    // -------- I/O-Gadgets --------
    con.fill = GridBagConstraints.BOTH;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addLabel(
        new GroupLabel("Waveform I/O", GroupLabel.ORIENT_HORIZONTAL, GroupLabel.BRACE_NONE));

    ggInputFile =
        new PathField(PathField.TYPE_INPUTFILE + PathField.TYPE_FORMATFIELD, "Select input file");
    ggInputFile.handleTypes(GenericFile.TYPES_SOUND);
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Input file", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggInputFile, GG_INPUTFILE, pathL);

    ggOutputFile =
        new PathField(
            PathField.TYPE_OUTPUTFILE + PathField.TYPE_FORMATFIELD + PathField.TYPE_RESFIELD,
            "Select output file");
    ggOutputFile.handleTypes(GenericFile.TYPES_SOUND);
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Output file", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggOutputFile, GG_OUTPUTFILE, pathL);
    gui.registerGadget(ggOutputFile.getTypeGadget(), GG_OUTPUTTYPE);
    gui.registerGadget(ggOutputFile.getResGadget(), GG_OUTPUTRES);

    ggParent1 = new PathField[1];
    ggParent1[0] = ggInputFile;
    ggOutputFile.deriveFrom(ggParent1, "$D0$F0Wrp$E");

    ggGain = createGadgets(GGTYPE_GAIN);
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Gain", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addParamField((ParamField) ggGain[0], GG_GAIN, paramL);
    con.weightx = 0.5;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addChoice((JComboBox) ggGain[1], GG_GAINTYPE, il);

    // -------- Settings-Gadgets --------
    gui.addLabel(
        new GroupLabel("Warp settings", GroupLabel.ORIENT_HORIZONTAL, GroupLabel.BRACE_NONE));

    ggWarp = new ParamField(Constants.spaces[Constants.modSpace]); // XXX
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Warp amount", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addParamField(ggWarp, GG_WARP, paramL);

    ggWarpModDepth = new ParamField(Constants.spaces[Constants.offsetAmpSpace]); // XXX
    ggWarpModDepth.setReference(ggWarp);
    ggWarpMod = new JCheckBox();
    con.weightx = 0.1;
    gui.addCheckbox(ggWarpMod, GG_WARPMOD, il);
    con.weightx = 0.4;
    gui.addParamField(ggWarpModDepth, GG_WARPMODDEPTH, paramL);

    ggWarpEnv = new EnvIcon(getComponent());
    con.weightx = 0.1;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addGadget(ggWarpEnv, GG_WARPENV);

    ggInFreq = new ParamField(Constants.spaces[Constants.absHzSpace]);
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Input freq.", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addParamField(ggInFreq, GG_INFREQ, paramL);
    ggOutFreq = new ParamField(Constants.spaces[Constants.absHzSpace]);
    con.weightx = 0.1;
    gui.addLabel(new JLabel("\u2192 Output freq.", SwingConstants.RIGHT));
    con.weightx = 0.4;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addParamField(ggOutFreq, GG_OUTFREQ, paramL);

    ggFrameSize = new JComboBox();
    for (int i = 32; i <= 32768; i <<= 1) {
      ggFrameSize.addItem(String.valueOf(i));
    }
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Frame size [smp]", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addChoice(ggFrameSize, GG_FRAMESIZE, il);

    ggOverlap = new JComboBox();
    for (int i = 1; i <= 16; i++) {
      ggOverlap.addItem(i + "x");
    }
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Overlap", SwingConstants.RIGHT));
    con.weightx = 0.4;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addChoice(ggOverlap, GG_OVERLAP, il);

    initGUI(this, FLAGS_PRESETS | FLAGS_PROGBAR, gui);
  }
Exemple #2
0
  protected void buildGUI() {
    // einmalig PropertyArray initialisieren
    if (static_pr == null) {
      static_pr = new PropertyArray();
      static_pr.text = prText;
      static_pr.textName = prTextName;
      static_pr.intg = prIntg;
      static_pr.intgName = prIntgName;
      static_pr.bool = prBool;
      static_pr.boolName = prBoolName;
      static_pr.para = prPara;
      static_pr.para[PR_MAXCHANGE] = new Param(96.0, Param.DECIBEL_AMP);
      static_pr.para[PR_AVERAGE] = new Param(1000.0, Param.ABS_MS);
      static_pr.paraName = prParaName;
      static_pr.envl = prEnvl;
      static_pr.envl[PR_ENV] = Envelope.createBasicEnvelope(Envelope.BASIC_UNSIGNED_TIME);
      static_pr.envl[PR_RIGHTCHANENV] = Envelope.createBasicEnvelope(Envelope.BASIC_UNSIGNED_TIME);
      static_pr.envlName = prEnvlName;
      //			static_pr.superPr	= DocumentFrame.static_pr;

      fillDefaultAudioDescr(static_pr.intg, PR_OUTPUTTYPE, PR_OUTPUTRES);
      fillDefaultAudioDescr(static_pr.intg, PR_ENVOUTTYPE, PR_ENVOUTRES);
      fillDefaultGain(static_pr.para, PR_GAIN);
      fillDefaultGain(static_pr.para, PR_ENVGAIN);
      static_presets = new Presets(getClass(), static_pr.toProperties(true));
    }
    presets = static_presets;
    pr = (PropertyArray) static_pr.clone();

    // -------- GUI bauen --------

    GridBagConstraints con;
    //		GridBagLayout		lay;

    PathField ggInputFile, ggOutputFile, ggEnvInFile, ggEnvOutFile;
    PathField[] ggInputs;
    JComboBox ggEnvSource, ggMode;
    ParamField ggMaxChange, ggAverage;
    JCheckBox ggEnvOutput, ggInvert, ggRightChan;
    EnvIcon ggEnv, ggRightChanEnv;
    Component[] ggGain, ggEnvGain;
    ParamSpace[] spcAverage;
    ParamSpace spcMaxChange;

    gui = new GUISupport();
    con = gui.getGridBagConstraints();
    //		lay				= gui.getGridBagLayout();
    con.insets = new Insets(1, 2, 1, 2);

    ItemListener il =
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            int ID = gui.getItemID(e);

            switch (ID) {
              case GG_ENVSOURCE:
                pr.intg[ID - GG_OFF_CHOICE] = ((JComboBox) e.getSource()).getSelectedIndex();
                reflectPropertyChanges();
                break;
              case GG_ENVOUTPUT:
              case GG_RIGHTCHAN:
                pr.bool[ID - GG_OFF_CHECKBOX] = ((JCheckBox) e.getSource()).isSelected();
                reflectPropertyChanges();
                break;
            }
          }
        };

    // -------- Input-Gadgets --------
    con.fill = GridBagConstraints.BOTH;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addLabel(
        new GroupLabel("Waveform I/O", GroupLabel.ORIENT_HORIZONTAL, GroupLabel.BRACE_NONE));

    ggInputFile =
        new PathField(PathField.TYPE_INPUTFILE + PathField.TYPE_FORMATFIELD, "Select input file");
    ggInputFile.handleTypes(GenericFile.TYPES_SOUND);
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Input file", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggInputFile, GG_INPUTFILE, null);

    ggEnvInFile =
        new PathField(
            PathField.TYPE_INPUTFILE + PathField.TYPE_FORMATFIELD, "Select input envelope file");
    ggEnvInFile.handleTypes(GenericFile.TYPES_SOUND);
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Env input", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggEnvInFile, GG_ENVINFILE, null);

    ggOutputFile =
        new PathField(
            PathField.TYPE_OUTPUTFILE + PathField.TYPE_FORMATFIELD + PathField.TYPE_RESFIELD,
            "Select output file");
    ggOutputFile.handleTypes(GenericFile.TYPES_SOUND);
    ggInputs = new PathField[1];
    ggInputs[0] = ggInputFile;
    ggOutputFile.deriveFrom(ggInputs, "$D0$F0Amp$E");
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Output file", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggOutputFile, GG_OUTPUTFILE, null);
    gui.registerGadget(ggOutputFile.getTypeGadget(), GG_OUTPUTTYPE);
    gui.registerGadget(ggOutputFile.getResGadget(), GG_OUTPUTRES);

    ggGain = createGadgets(GGTYPE_GAIN);
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Gain", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addParamField((ParamField) ggGain[0], GG_GAIN, null);
    con.weightx = 0.5;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addChoice((JComboBox) ggGain[1], GG_GAINTYPE, il);

    // -------- Env-Output-Gadgets --------
    gui.addLabel(
        new GroupLabel(
            "Separate envelope output", GroupLabel.ORIENT_HORIZONTAL, GroupLabel.BRACE_NONE));

    ggEnvOutFile =
        new PathField(
            PathField.TYPE_OUTPUTFILE + PathField.TYPE_FORMATFIELD + PathField.TYPE_RESFIELD,
            "Select output envelope file");
    ggEnvOutFile.handleTypes(GenericFile.TYPES_SOUND);
    ggEnvOutFile.deriveFrom(ggInputs, "$D0$F0Env$E");
    con.gridwidth = 1;
    con.weightx = 0.1;
    ggEnvOutput = new JCheckBox("Env output");
    gui.addCheckbox(ggEnvOutput, GG_ENVOUTPUT, il);
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.9;
    gui.addPathField(ggEnvOutFile, GG_ENVOUTFILE, null);
    gui.registerGadget(ggEnvOutFile.getTypeGadget(), GG_ENVOUTTYPE);
    gui.registerGadget(ggEnvOutFile.getResGadget(), GG_ENVOUTRES);

    // cannot call createGadgets twice (BUG!) XXX
    ggEnvGain = new Component[2]; // createGadgets( GGTYPE_GAIN );
    ggEnvGain[0] = new ParamField(Constants.spaces[Constants.decibelAmpSpace]);
    JComboBox ch = new JComboBox();
    ch.addItem("normalized");
    ch.addItem("immediate");
    ggEnvGain[1] = ch;

    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addLabel(new JLabel("Gain", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addParamField((ParamField) ggEnvGain[0], GG_ENVGAIN, null);
    con.weightx = 0.5;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addChoice((JComboBox) ggEnvGain[1], GG_ENVGAINTYPE, il);

    // -------- Settings --------
    gui.addLabel(
        new GroupLabel("Shaper Settings", GroupLabel.ORIENT_HORIZONTAL, GroupLabel.BRACE_NONE));

    ggEnvSource = new JComboBox();
    ggEnvSource.addItem("Input file");
    ggEnvSource.addItem("Sound file");
    ggEnvSource.addItem("Envelope file");
    ggEnvSource.addItem("Envelope");
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Source", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addChoice(ggEnvSource, GG_ENVSOURCE, il);

    ggInvert = new JCheckBox();
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Inversion", SwingConstants.RIGHT));
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 0.4;
    gui.addCheckbox(ggInvert, GG_INVERT, il);

    ggMode = new JComboBox();
    ggMode.addItem("Superposition");
    ggMode.addItem("Replacement");
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Apply mode", SwingConstants.RIGHT));
    con.weightx = 0.4;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addChoice(ggMode, GG_MODE, il);

    ggEnv = new EnvIcon(getComponent());
    con.gridwidth = 1;
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Envelope", SwingConstants.RIGHT));
    con.weightx = 0.4;
    gui.addGadget(ggEnv, GG_ENV);

    spcMaxChange = new ParamSpace(Constants.spaces[Constants.decibelAmpSpace]);
    //		spcMaxChange.min= spcMaxChange.inc;
    spcMaxChange =
        new ParamSpace(spcMaxChange.inc, spcMaxChange.max, spcMaxChange.inc, spcMaxChange.unit);
    ggMaxChange = new ParamField(spcMaxChange);
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Max boost", SwingConstants.RIGHT));
    con.weightx = 0.4;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addParamField(ggMaxChange, GG_MAXCHANGE, null);

    ggRightChan = new JCheckBox("Right chan.");
    ggRightChanEnv = new EnvIcon(getComponent());
    con.weightx = 0.1;
    con.gridwidth = 1;
    gui.addCheckbox(ggRightChan, GG_RIGHTCHAN, il);
    con.weightx = 0.4;
    gui.addGadget(ggRightChanEnv, GG_RIGHTCHANENV);

    spcAverage = new ParamSpace[3];
    spcAverage[0] = Constants.spaces[Constants.absMsSpace];
    spcAverage[1] = Constants.spaces[Constants.absBeatsSpace];
    spcAverage[2] = Constants.spaces[Constants.ratioTimeSpace];
    ggAverage = new ParamField(spcAverage);
    con.weightx = 0.1;
    gui.addLabel(new JLabel("Smoothing", SwingConstants.RIGHT));
    con.weightx = 0.4;
    con.gridwidth = GridBagConstraints.REMAINDER;
    gui.addParamField(ggAverage, GG_AVERAGE, null);

    initGUI(this, FLAGS_PRESETS | FLAGS_PROGBAR, gui);
  }