Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing SoundFile into amp.input() gives error #67

Open
aaruel opened this issue Feb 11, 2016 · 7 comments
Open

Passing SoundFile into amp.input() gives error #67

aaruel opened this issue Feb 11, 2016 · 7 comments

Comments

@aaruel
Copy link

aaruel commented Feb 11, 2016

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.

@koincidence
Copy link

@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.

@naloxx
Copy link

naloxx commented Apr 10, 2016

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.

@kyungyunlee
Copy link

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

@jordirosa-p5
Copy link

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.

@anwarhahjjeffersongeorge
Copy link

anwarhahjjeffersongeorge commented Sep 20, 2016

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.

@softpunch
Copy link

Well, this answers a few questions...

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

Hope this gets fixed soon!

@anwarhahjjeffersongeorge

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants