This discussion is archived
3 Replies Latest reply: May 31, 2011 8:11 AM by captfoss RSS

How to edit and save the Clip object

848735 Newbie
Currently Being Moderated
Hi. I need to open an audio file, then select part which will be looped. I did it with Clip, but I don't know how to save this looped part into new file. I also don't know how to edit frames - I want to add fade-in and fade-out effect at begining and end of the clip. May you explain me how to do that?
  • 1. Re: How to edit and save the Clip object
    captfoss Pro
    Currently Being Moderated
    845732 wrote:
    Hi. I need to open an audio file, then select part which will be looped. I did it with Clip, but I don't know how to save this looped part into new file. I also don't know how to edit frames - I want to add fade-in and fade-out effect at begining and end of the clip. May you explain me how to do that?
    Clips are exclusively for playing audio files. There is no way to use them to record a new file.

    http://download.oracle.com/javase/1.5.0/docs/guide/sound/programmer_guide/contents.html

    You need to read the manual and find out about DataLines and how they work.

    http://www.jsresources.org/examples/audio_playing_recording.html

    Read through some example code to see the concepts in action...

    Ultimately, you should know that JavaSound isn't going to give you very much to work with... you'll have to implement the fade effects on your own. There's nothing built-in to do it for you. I'm guessing by the briefness of your question, you're probably going to want to find a 3rd party library on Google to handle most of the work for you.
  • 2. Re: How to edit and save the Clip object
    848735 Newbie
    Currently Being Moderated
    It's quite old, but still actual:). So... now I'm loading file into AudioInputStream. I have a panel drawing its waveform, now and I'm going to write a selection. But still, I can't find any example showing how to create a clip from part of an AudioInputStream (byte array?).
  • 3. Re: How to edit and save the Clip object
    captfoss Pro
    Currently Being Moderated
    845732 wrote:
    But still, I can't find any example showing how to create a clip from part of an AudioInputStream (byte array?).
    There's no reason to create a clip of it... you can play an AudioInputStream by writing its contents to a SourceDataLine...
    http://www.jsresources.org/examples/SimpleAudioPlayer.html

    And you can record its contents using the AudioSystem.write function (which will record the entire contents of the AudioInputStream, so make sure you discard the data out of it you don't want recorded...)
    http://www.jsresources.org/examples/SimpleAudioRecorder.html

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points