Exemplo n.º 1
0
  protected void recalcOutFreq() {
    if (inRate == 0f) return;

    double omegaIn, omegaOut, warp;
    ParamField ggOutFreq;

    omegaIn = pr.para[PR_INFREQ].val / inRate * Constants.PI2;
    warp = Math.max(-0.98, Math.min(0.98, pr.para[PR_WARP].val / 100)); // DAFx2000 'b'
    omegaOut = omegaIn + 2 * Math.atan2(warp * Math.sin(omegaIn), 1.0 - warp * Math.cos(omegaIn));

    ggOutFreq = (ParamField) gui.getItemObj(GG_OUTFREQ);
    if (ggOutFreq != null) {
      ggOutFreq.setParam(new Param(omegaOut / Constants.PI2 * inRate, Param.ABS_HZ));
    }
  }
Exemplo n.º 2
0
  protected void recalcWarpAmount() {
    if (inRate == 0f) return;

    double omegaIn, omegaOut, warp, d1;
    ParamField ggWarp;

    omegaIn = pr.para[PR_INFREQ].val / inRate * Constants.PI2;
    omegaOut = pr.para[PR_OUTFREQ].val / inRate * Constants.PI2;
    d1 = Math.tan((omegaOut - omegaIn) / 2);
    warp =
        Math.max(
            -0.98,
            Math.min(0.98, d1 / (Math.sin(omegaIn) + Math.cos(omegaIn) * d1))); // DAFx2000 'b'

    ggWarp = (ParamField) gui.getItemObj(GG_WARP);
    if (ggWarp != null) {
      ggWarp.setParam(new Param(warp * 100, Param.FACTOR));
    }
  }
Exemplo n.º 3
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);
  }