0

对于一些大学工作,我正在制作一个 java VST/Synthesizer。当需要更改音高时,我已经让振荡器产生声音并将频率更改为所需的值,但我希望在屏幕上有一个视觉示波器,所有选项都用于编辑声音。我怎么能这样做?以下是生成和播放 SawTooth 声音的代码,以防万一:

import com.jsyn.JSyn;
import com.jsyn.Synthesizer;
import com.jsyn.unitgen.LineOut;
import com.jsyn.unitgen.SawtoothOscillatorBL;
import com.jsyn.unitgen.UnitOscillator;

public class SawTooth {

    public static Synthesizer synth = JSyn.createSynthesizer();
    public static UnitOscillator osc;
    public static LineOut lineout;

    public static double Frequency = 261.626;
    public static double Amplitude = 0.6;
    public static int Voices = 1;

    public static void Play() {
        synth.start();
        synth.add(osc = new SawtoothOscillatorBL());
        synth.add(lineout = new LineOut());
        osc.output.connect(0, lineout.input, 0);
        osc.output.connect(0, lineout.input, 1);
        osc.frequency.set(Frequency);
        osc.amplitude.set(Amplitude);
        lineout.start();
        System.out.println("Wave Playing");
    }

}

提前致谢

4

1 回答 1

0

GitHub 上有一个示例程序,展示了如何添加范围。它包括一些用于控制声音的推子。

https://github.com/philburk/jsyn/blob/master/tests/com/jsyn/examples/SeeGoogleWave.java

以下是主要步骤:

  AudioScope scope = new AudioScope(synth);

  // Add a scope trace that will be driven by an output port.
  scope.addProbe(oscillator.output);

  // Trigger on a rising edge.
  scope.setTriggerMode(AudioScope.TriggerMode.NORMAL);

   // Turn off scope controls if you want a cleaner UI.
  scope.getView().setShowControls(false);

   // Start a thread that will periodically update the scope.
  scope.start();

  // Add the scope's View to your UI
  add(BorderLayout.CENTER, scope.getView());
于 2018-04-26T03:27:47.790 回答