Ejemplo n.º 1
0
  public void start() {
    try {
      audioSystem.start();
    } catch (Exception ex) {
      Logger.getLogger(ADC2Panel.class.getName()).log(Level.SEVERE, null, ex);
    }

    Timer timer =
        new Timer(
            50,
            new ActionListener() {

              public void actionPerformed(ActionEvent ae) {
                updateMeters();
              }
            });
    timer.start();

    // setPreferredSize(new Dimension(500,80));
  }
Ejemplo n.º 2
0
  public ADC2Panel() throws Exception {

    setLayout(new BorderLayout());

    audioSystem = AudioSystem.instance();

    peakIn = new AudioPeakMonitor();

    //        if (url) {
    URL u = ((new File("/home/pjl/audiodump.wav")).toURI()).toURL();
    //  audioReader = new URLWavReader(u);
    //   URL u = ((new File("/home/pjl/dangermouse.mp3")).toURI()).toURL();
    audioReader = new MP3AudioReader("file:/home/pjl/MissionImpossible.mp3", 2.0f);

    quantizer = new QuantizerProcess();

    float Fs = 11000;

    final float preCutoff = Fs / 2;

    AudioServer server = audioSystem.getServer();

    final AudioProcess output = audioSystem.getOut();

    server.setClient(
        new AudioClient() {
          int frameSize = 0;

          public void work(int size) {

            if (chunk == null || size != frameSize) {
              frameSize = size;
              chunk = new AudioBuffer(null, 2, size, 44100.0f);
              chunk2 = new AudioBuffer(null, 2, size, 44100.0f);
              chunk.setRealTime(true);
            }

            chunk.makeSilence();

            if (audioReader != null) {
              if ((audioReader instanceof AudioReader) && ((AudioReader) audioReader).eof()) {
              } else {
                audioReader.processAudio(chunk);
              }
            }

            if (cancel) {
              int n = chunk.getSampleCount();
              for (int c = 0; c < chunk.getChannelCount(); c++) {
                System.arraycopy(chunk.getChannel(c), 0, chunk2.getChannel(c), 0, n);
              }
            }

            if (preFilterOn) {
              preFilter.processAudio(chunk);
            }

            if (quantizeOn) {
              quantizer.processAudio(chunk);
            }

            peakIn.processAudio(chunk);

            if (cancel) {
              int n = chunk.getSampleCount();
              for (int c = 0; c < chunk.getChannelCount(); c++) {
                float a[] = chunk.getChannel(c);
                float b[] = chunk2.getChannel(c);
                for (int i = 0; i < n; i++) {
                  a[i] = a[i] - b[i];
                }
              }
            }

            output.processAudio(chunk);
          }

          public void setEnabled(boolean arg0) {
            //  throw new UnsupportedOperationException("Not supported yet.");
          }
        });
    configure();
  }
Ejemplo n.º 3
0
 void dispose() {
   audioSystem.stop();
 }