Minim Errors - How to detect no playback device (speakers/headphones) and avoid errors?

edited September 2014 in Library Questions

Hi,

I have a Processing2 application that works fine on my PC. When I tried it on a spare machine I got multiple Minim errors. This appears to be because the spare machine (Windows7) has no Speakers or Headphones plugged-in i.e. no playback device. When I plug in headphones all of the errors disappear and the code runs as normal.

Does anyone know of a simple way to detect the lack of playback device from within the code? I could then use this to skip the sound-related commands for any machine that has no sound.

Many thanks,

Batroost

Tagged:

Answers

  • edited September 2014 Answer ✓

    Maybe you should check whether some Minim related variable got null? :-/
    http://processing.org/reference/null.html

  • Yes, that would help. The errors in the console start with:

    ==== JavaSound Minim Error ====
    ==== Unable to return a SourceDataLine: unsupported format - PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian
    

    So, I'm guessing that this is the one I need to trap. Not sure where to go from here?

  • Fixed it - thanks for the hint. Simply used the following before the loading the sounds, and check the flag HasSound before allowing teh code to play any sound:

      minim = new Minim(this);  
      // Check for sound output channel
      AudioOutput out = minim.getLineOut();
      if (out==null) {
        HasSound=false;
        println("No Sound Channel Detected, Sounds Disabled.");
      }
      else { 
      // Sound Output Channel Exists so Initialise Sounds
      HasSound=true;
    

    etc...

Sign In or Register to comment.