Results 1 to 6 of 6
  1. #1
    diablo2070 is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Question Play soundclip and generate"wind" like sound

    Hi,

    My knowledge in Java are very limited and I need to do a program for a project. However, I can't find how to do it.

    2 things :

    1)
    I want to play a soundclip. It can be a wav, a mp3, whatever will be the easiest to read I don't care since I will create that file and it will never change it after. This sound will happen when a specific event happen. I download the Demo of the Java Sound API from the official Java website, but it is quite hard for me to understand how to just read a simple file.

    Also, that file will be a Mono file, wich I want to be able to gage the volume in 3D (2 fronts, 2 rears)... I don't know if something like that is possible in Java.. especially with my knowledge. In the worst case, a left/right balance could do it.

    2)
    I need to generate a sound that will give a wind effect that will be more or less loud depending on parameters coming from an external sensor. I have absolutly no idea how to do that, but i though maybe i could use the MIDI sounds using an instrument like "helicopter" or something like that.


    The first part is the most important one, it is essential to the project.

    Any idea :confused: I'm really lost with all that.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default

    Have a look at the static method Applet.newAudioClip( ... ); it loads a clip and you can play, loop and stop it. Personally I still wonder why this is a static method in the Applet class.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    diablo2070 is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Default

    I just tried it, and trying to read a song converted to wav makes a very slow reading, like if a buffer was always full or something like that :P and one of my core is almost at 85% (i have a T9600 wich should be far enough :P). Any idea why it does that?

    Edit : Ok well I just loaded a short clip (about 1 sec.) and it looks fine.
    Last edited by diablo2070; 02-08-2011 at 08:51 PM.

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    WAVs are huge and java doesn't natively decode mp3. You can look at JLayer for mp3 decoding, but thats quite a bit of work/learning curve. For simple games and the like, WAV and AIFF are fine - assuming you don't have any huge audio tracks.

  5. #5
    diablo2070 is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Default

    The method Applet.newAudioClip( ... ) works fine for my needs, but I really can't find a way to control gain. I'm leaving the idea of surround, but i would at least want to be able to control gain. I've searched a lot on the internet but I can't find any way to control gain with that method. Anyone has an idea?

    Thanks

  6. #6
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    There aren't many transformation controls built in that I know of (there could be some, I have not used them before) but there are many third party libraries that might be helpful.

Similar Threads

  1. Replies: 3
    Last Post: 10-12-2010, 04:21 PM
  2. Replies: 0
    Last Post: 06-07-2010, 06:23 PM
  3. Replies: 1
    Last Post: 01-21-2010, 09:20 AM
  4. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 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
  •