Sounds stop loading in Minim - 'Couldn't open the line', 'Unable to return a SourceDataLine'

edited November 2014 in Library Questions

I have a program I'm working on which needs to play lots of different sounds. I've figured out that it's a mistake to try loading them all into memory at once, so instead I have an array of ten sounds, and it loads a new one (in advance) every time it needs to, ready to be triggered (only two of the sounds play more than once - there are two pops, and a sample for every element in the Periodic Table).

After it's loaded a certain number of samples (31, I think), even though it's never storing any more than 12 in memory altogether, it fails to load any more - I get these errors:

==== JavaSound Minim Error ====
==== Couldn't open the line: line with format PCM_SIGNED 11025.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported.

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

Incidentally, it keeps playing sounds that it had previously loaded.

This is in Ubuntu 14.04, Processing 2.1.1 but I had the same error in 3.0a4. I initially thought it must be a problem with some of my sound files, but I now realise it happens whichever ones it loads.

I had a stab at following the suggestions in this thread - https://processing.org/discourse/beta/num_1274221471.html - but they didn't seem to make any difference. Any more ideas?

Answers

  • edited November 2014

    Have you called close() over unneeded 1s? 8-X
    They're registered in a Minim instance. So they can't be garbage-collected until un-registered outta there! :-&

  • ...nope, I had no idea that was a thing! Thank you!

    Um, is there documentation for it somewhere? Not here: http://code.compartmental.net/minim/javadoc/ddf/minim/Minim.html#dispose()

  • edited November 2014 Answer ✓

    Sorry. I got it mixed up w/ Movie. It's close() instead! :-\"

    From AudioSource:

    /**
     * Closes this source, making it unavailable.
     * 
     * @invisible
     */
    public void close()
    {
        Minim.debug( "Closing " + this.toString() );
    
        stream.close();
    
        // if we have a parent, tell them to stop tracking us
        // so that we can get garbage collected
        if ( parent != null )
        {
            parent.removeSource( this );
        }
    }
    

    P.S.: Of course, don't use close() if you intend to re-play() it later! A pause() is enough! :P

  • Thank you! I'm still occasionally running into the same error when the program's been running for a while, but this seems to do the trick 90% of the time, at least!

Sign In or Register to comment.