Results 1 to 3 of 3
  1. #1
    lor
    lor is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Need to instantiate an AudioClip with sound code generated within applet (not a file)

    Have searched and searched, but all examples assume the sound code (.wav, etc.) resource is located as a file on the server. However I need to be able to dynamically create the sound code string (which I know how to do) within the applet and instantiate the AudioClip therefrom. Anybody done this? Any hints, perhaps, as to how to configure a URL to refer to a string variable within the applet, so that newAudioClip can use it? Whatever else would work?

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Need to instantiate an AudioClip with sound code generated within applet (not a f

    What's a "sound code string"?

    I've never done this, but this example looks fairly general.

    The author only considers allocating a AudioInputStream piped from a file or URL which is precisely what you don't want to do ;) But AudioSystem has a more general getAudioInputStream(InputStream) method which will give you an AudioInputStream based on any input stream you sprecify. Note that this method imposes some requirements on the input stream that you pass it (so that it can determine the type of data that is contained.)

    That page also considers handling of midi data (if that's what your strings are).

  3. #3
    lor
    lor is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Re: Need to instantiate an AudioClip with sound code generated within applet (not a f

    A "sound code string" is a string of bytes that convey some sound, in the form that would be the contents of a .wav file, or .au, or .mp3, or .midi, etc.), with the proper header info and sound samples or instructions as bytes or words or whatever is appropriate to the type of file. If you dump a .wav file, for example, you would see the sound code string.

    Your getAudioInputStream link looks promising, if the 'stream' comprises a 'sound code string'.

Similar Threads

  1. help instantiate a java class that extend applet
    By geosa in forum Java Applets
    Replies: 0
    Last Post: 12-04-2010, 09:14 AM
  2. AudioClip: Sound file format?
    By CoderMan in forum Java Applets
    Replies: 3
    Last Post: 07-04-2010, 12:29 AM
  3. Replies: 1
    Last Post: 03-31-2009, 05:04 PM
  4. Applet-Image,audioclip problem-pls help
    By samares in forum Java Applets
    Replies: 1
    Last Post: 02-21-2009, 03:23 AM
  5. How to delete pre-generated code?
    By Terentius in forum NetBeans
    Replies: 0
    Last Post: 08-19-2008, 04:02 PM

Tags for this Thread

Posting Permissions

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