processing-sound-archive icon indicating copy to clipboard operation
processing-sound-archive copied to clipboard

Passing SoundFile into amp.input() gives error

Open aaruel opened this issue 9 years ago • 7 comments

For example, given this code

import processing.sound.*;
Amplitude amp;
SoundFile file;

void setup() {
  amp = new Amplitude(this);
  file = new SoundFile(this, "sample.mp3");
  file.play();
  amp.input(file);
} ... 

the following error displays in the console

ERROR: /synth/map/input: Audio input index 0 out of range for synth 2

and the audio only plays through the right channel.

If I do it through AudioIn the output is fine, but this is giving me problems.

aaruel avatar Feb 11 '16 06:02 aaruel

@aaruel I noticed the same issue with FFT.input, but for both amp and FFT, the error and the right channel audio playback occur only with stereo sound files.

koincidence avatar Apr 05 '16 17:04 koincidence

I am experiencing the same error. I tried running the example code for sound visualization from the tutorials website. Running the Processing3 standalone app on OSX.

naloxx avatar Apr 10 '16 23:04 naloxx

same problem here...aiff files work but mp3 files don't work! did anyone solve the problem???

kyungyunlee avatar Jul 07 '16 13:07 kyungyunlee

The same here, using the FFTSpectrum example sketch (Sound library) and any .mp3, .aiff and .wav file generated in my computer (from Adobe Audition or Ableton live).

It works perfectly using the sample audio file beat.aiff, though.

jordirosa-p5 avatar Aug 29 '16 13:08 jordirosa-p5

Each FFT object seems to be prepared to accept only a mono audio input stream. If you open the sample audio file beat.aiff in Audacity, you will see it's a single track.

To do a temporary work around until more stereo support is added, you can do:

import processing.sound.*;

int bands = 512;
int numChannels = 2;
SoundFile sample;
FFT[] fft = new FFT[numChannels];
AudioIn [] channels = new AudioIn[numChannels];

void setup(){
  for(int ch=0; ch<numChannels;ch++){
    channels[ch] = new AudioIn(this, ch);
    channels[ch].start();
    fft[ch] = new FFT(this, bands);
    fft[ch].input(channels[ch]);
  }
  sample.play();
}

For this to work, you will have to:

  1. Route your soundcard output to its input (like with JACK, Soundflower, etc.)
  2. Realize that the AudioIn data received by Processing will now receive all sounds in addition to what you're playing in Processing (i.e., system noises, etc.). So maybe disable these.

Well, this answers a few questions...

Too bad JACK doesn't work on El Capitan. (Soundflower does, thankfully.)

Hope this gets fixed soon!

softpunch avatar Oct 12 '16 21:10 softpunch

@softpunch Yes, I used Soundflower to do this successfully. I only mentioned JACK because some people have apparently reported getting beta versions to work on El Capitan