Exemplo n.º 1
0
  public static void main(String[] args) {
    AudioContext context = new AudioContext(1024);
    Gain gain = new Gain(context, 2);

    CrazySoundReactor csr = new CrazySoundReactor(context);
    gain.addInput(csr);
    gain.start();
    context.setRoot(gain);
    csr.start();
    context.start();
  }
Exemplo n.º 2
0
    public void message(Bead message) {
      // muck around with the clock
      clock.setIntervalEnvelope(new Envelope(context, Math.random() < 0.5 ? 500.0f : 1000.0f));

      BeadArray stopTrigger = new BeadArray();
      WavePlayer sinePlayer =
          WavePlayer.newSinePlayer(context, (float) Math.random() * scale + 100.0f);
      sinePlayer.start();
      Gain gain = new Gain(context, 1);

      stopTrigger.add(sinePlayer);
      ((Envelope) gain.getGainEnvelope()).addSegment(0.1f, 200, 1, null);
      ((Envelope) gain.getGainEnvelope()).addSegment(0.01f, 500, 1, null);
      ((Envelope) gain.getGainEnvelope()).addSegment(0.1f, 500, 1, null);
      ((Envelope) gain.getGainEnvelope()).addSegment(0, 3000, 1, stopTrigger);
      gain.addInput(sinePlayer);
      gain.start();
      stopTrigger.add(gain);
      addInput(gain);
    }