processing-sound-archive
processing-sound-archive copied to clipboard
Passing SoundFile into amp.input() gives error
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 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.
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.
same problem here...aiff files work but mp3 files don't work! did anyone solve the problem???
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.
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:
- Route your soundcard output to its input (like with JACK, Soundflower, etc.)
- 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 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