outputDevice in Sound library causing errors when specifying audio channel

Hello,

I’m trying to use the Sound library to select which channel of a soundcard to play audio from, but whenever I call the outputDevice command I get some extensive red text no audio. This is the case even when selecting the default channel (id = 0).

If I leave out the outputDevice command the file plays from the default channel without an issue.

Here is a minimal version of my code. Any suggestions are welcome.

Ad

import processing.sound.*;

SoundFile start_Sound;

void setup() {
  size(400, 400);
  background(100);

  // create a new Sound object
  Sound s = new Sound(this);

  // list available devices
  s.list();
  
  // select an audio output device
  // including this line causes an error that prevents the sound from playing
  // s.outputDevice(0);

  // A short sound file found in C:\Windows\Media
  start_Sound = new SoundFile(this, "Windows_Speech_On.wav");
  
  // play the sound file on startup
  start_Sound.play();
}

void draw() {

}

// click in the window to play the sound
void mouseClicked() {
      start_Sound.play();
}

I am not sure if you are using the latest sound library. My first question would be: Are you using the native sound library that comes with the Processing install package? Also, what Processing version are you using?

It is my understanding that the sound library is going through a revamp. Not sure what is the sate but I believe they are making progress. You can try using that new library or you can also try the minim library as it does a fantastic job.

Kf

1 Like

Your Processing version number will appear in the PDE toolbar title (e.g. 3.4).

Your library version number can be found in:

PDE > Tools > Contribution Manager > Libraries > Sound

…and at present will probably be either 1.4.0 or 2.0.0.

As @kfrajer mentions, for several years the default advice has been to recommend using the minim library if you run into errors using Sound. This may change, but minim is a good option if you don’t need Sound for a specific reason.

1 Like

Thanks for your replies @kfrajer and @jeremydouglass , I’m running Processing 3.4 and Sound 2.0.0 that I installed via the contribution manager.

I’ll take a look at the minim library. I’m not doing anything too intensive so hopefully minim should meet my needs.

@HauntedPliers could you please post the red text that you get when calling s.outputDevice(0)? If you’re happy with the sound coming from the default device there is no need to deal with the Sound object at all, nor do you have to call Sound.list().

@HauntedPliers the new 2.0.1 update of the Sound library with improved device selection handling should become available from the Content Manager at some point during the day. Please let us know if it fixes things for you!

1 Like