Results 1 to 6 of 6
  1. #1
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default [SOLVED] Resource limit in jars? Sound problems.

    Hi, I'm currently writing applets using digital filtering techniques. The problem I have is that the sound files I'm using are truncated when viewing the applet online. When viewed using appletviewer they are the correct length. I'm using getResourceAsStream() to load the sound data. Is there a size limit on resources you load from jars or is something else going on?
    Thanks.

    I can't post links as my post count is too low, so rather than spam with pointless posts i'll do this: Examples are at the following address
    www dot srcf dot ucam dot org slash ~jmh205 slash partIIproj

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Arrow elsewhere,....

    I think it is somewhere else:

    Spellex SDK for Java(TM) support

    I saw something recently which gives me cause for pause whenever data transmission block goes over 4k minus control header space,... rioutine traffic on any given minute of internet activity streams copiously in excess of what I would think your DSP project would likely use. Third Light has "Online Galleries Of Your Pictures" so it would not be them. At SCRF it's no news is good news, so ( I guess ) let's see some code.

    dot jar files and ....

    we see things like this all the time:
    Java Code:
    	/* Workaround for bug 4155072.  The shared double buffer image
    	 * may hang on to a reference to this applet; unfortunately 
    	 * Image.getGraphics() will continue to call JApplet.getForeground()
    	 * and getBackground() even after this applet has been destroyed.
    	 * So we ensure that these properties are non-null here.
    	 */
    So I would start by going back to scratch zero and placing File.write( various data values in your program at random points around the trouble area ) which is what all the experiences coders do in this situation..
    Attached Thumbnails Attached Thumbnails [SOLVED] Resource limit in jars? Sound problems.-srcf.jpg  
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  3. #3
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Here's the relevant code in Prototype2:

    Loading:
    Java Code:
    public void run() {
        try {
            InputStream is = Applet.class.getResourceAsStream("test.wav");
            AudioInputStream in = AudioSystem.getAudioInputStream(is);
            if (!in.getFormat().matches(format)) {
                throw new IOException("Audio data is not in the correct format.");
            }
            if (in.getFrameLength() > Integer.MAX_VALUE) {
                throw new IOException("Audio data is too long.");
            }
            soundClip = new byte[(int)in.getFrameLength() * format.getFrameSize()];
            in.read(soundClip, 0, soundClip.length);
            in.close();
            playButton.setEnabled(true);
        }
        catch (IOException e) {
            System.err.println("I/O error: " + e.getMessage());
        }
        catch (UnsupportedAudioFileException e) {
            System.err.println("I/O error: " + e.getMessage());
        }
    }
    Playing:
    Java Code:
    public void run() {
        line.start();
        for (int i=0; i<soundClip.length; i+=bufsize) {
            line.write(soundClip, i, bufsize);
        }
        line.close();
    }
    Last edited by OrangeDog; 05-14-2009 at 12:52 AM.

  4. #4
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Is there a workaround/fix or do I just have to use smaller input files?

  5. #5
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    8

    Default

    Wait for Hardwired or Fubarable ...
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  6. #6
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Fixed it. Seems that the AudioInputStream.read() was unable to tell how long the stream was.

Similar Threads

  1. Replies: 0
    Last Post: 08-19-2008, 04:44 PM
  2. [SOLVED] what is text limit line?
    By Nicholas Jordan in forum NetBeans
    Replies: 12
    Last Post: 07-16-2008, 05:05 AM
  3. Replies: 0
    Last Post: 07-11-2008, 04:43 PM
  4. PM Inbox Limit Increased
    By JavaBean in forum Suggestions & Feedback
    Replies: 7
    Last Post: 01-17-2008, 08:48 PM
  5. Limit of String
    By javaplus in forum New To Java
    Replies: 5
    Last Post: 11-19-2007, 04:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •