From: Andrew Thompson on
I am having a devil of a time trying to develop a new
sound format. After abandoning my earlier efforts on
the basis that I could not reconstruct the binary
representation to a usable sound, I revisited the
problem today and found my local JREs do not seem
to play the *original* sound that I am converting,
correctly.

Which leaves me to wonder whether it is the sound, the
code or the JRE that is the problem.

The code is ..
<sscce>
import java.net.URL;
import javax.sound.sampled.*;

public class LoopSound {

public static void main(String[] args) throws Exception {
URL url = new URL(
"http://pscode.org/media/leftright.wav");
Clip clip = AudioSystem.getClip();
AudioInputStream ais = AudioSystem.
getAudioInputStream( url );
clip.open(ais);
clip.loop(5);
}
}
</sscce>

The sound is located at the URL shown above. It
was made using Java sound, is 2 seconds in duration,
stereo, and should fade between 441 Hz in one channel,
to 882 Hz in the other, and back again.

When I play it in the system default player, the Totem
Movie Player v. 2.24.3, it sounds as I expect.

Does it play OK for you?

(And as an aside) It should be loopable without any
perceptible 'click' at the loop points. Totem loops it
but has a noticeable click. Does it loop smoothly
for you?

--
Andrew T.
pscode.org
From: Qu0ll on
"Andrew Thompson" <andrewthommo(a)gmail.com> wrote in message
news:ace1b06a-a20c-421a-8b20-68fefa5eed5f(a)i4g2000prm.googlegroups.com...
> I am having a devil of a time trying to develop a new
> sound format. After abandoning my earlier efforts on
> the basis that I could not reconstruct the binary
> representation to a usable sound, I revisited the
> problem today and found my local JREs do not seem
> to play the *original* sound that I am converting,
> correctly.
>
> Which leaves me to wonder whether it is the sound, the
> code or the JRE that is the problem.
>
> The code is ..
> <sscce>
> import java.net.URL;
> import javax.sound.sampled.*;
>
> public class LoopSound {
>
> public static void main(String[] args) throws Exception {
> URL url = new URL(
> "http://pscode.org/media/leftright.wav");
> Clip clip = AudioSystem.getClip();
> AudioInputStream ais = AudioSystem.
> getAudioInputStream( url );
> clip.open(ais);
> clip.loop(5);
> }
> }
> </sscce>
>
> The sound is located at the URL shown above. It
> was made using Java sound, is 2 seconds in duration,
> stereo, and should fade between 441 Hz in one channel,
> to 882 Hz in the other, and back again.
>
> When I play it in the system default player, the Totem
> Movie Player v. 2.24.3, it sounds as I expect.
>
> Does it play OK for you?
>
> (And as an aside) It should be loopable without any
> perceptible 'click' at the loop points. Totem loops it
> but has a noticeable click. Does it loop smoothly
> for you?

I get no sound whatsoever on Vista with Java 6 Update 16. Are you sure the
SSCCE is correct?

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour(a)gmail.com
[Replace the "SixFour" with numbers to email me]

From: Knute Johnson on
Andrew Thompson wrote:
> I am having a devil of a time trying to develop a new
> sound format. After abandoning my earlier efforts on
> the basis that I could not reconstruct the binary
> representation to a usable sound, I revisited the
> problem today and found my local JREs do not seem
> to play the *original* sound that I am converting,
> correctly.
>
> Which leaves me to wonder whether it is the sound, the
> code or the JRE that is the problem.
>
> The code is ..
> <sscce>
> import java.net.URL;
> import javax.sound.sampled.*;
>
> public class LoopSound {
>
> public static void main(String[] args) throws Exception {
> URL url = new URL(
> "http://pscode.org/media/leftright.wav");
> Clip clip = AudioSystem.getClip();
> AudioInputStream ais = AudioSystem.
> getAudioInputStream( url );
> clip.open(ais);
> clip.loop(5);
> }
> }
> </sscce>
>
> The sound is located at the URL shown above. It
> was made using Java sound, is 2 seconds in duration,
> stereo, and should fade between 441 Hz in one channel,
> to 882 Hz in the other, and back again.
>
> When I play it in the system default player, the Totem
> Movie Player v. 2.24.3, it sounds as I expect.
>
> Does it play OK for you?
>
> (And as an aside) It should be loopable without any
> perceptible 'click' at the loop points. Totem loops it
> but has a noticeable click. Does it loop smoothly
> for you?
>
> --
> Andrew T.
> pscode.org

Andrew:

Your problem is Java 1.5 or later. There were some changes made in Java
Sound in 1.5 that changed one of the threads to a daemon. So when your
program ends so does the sound. Try putting a sleep after the loop and
it will be obvious.

What you need to do is add a LineListener and wait until you get a STOP
LineEvent before you end your main thread.

--

Knute Johnson
email s/nospam/knute2009/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
From: Qu0ll on
"Qu0ll" <Qu0llSixFour(a)gmail.com> wrote in message
news:i5WdnRCc4cyk6FTXnZ2dnUVZ_q2dnZ2d(a)westnet.com.au...
> "Andrew Thompson" <andrewthommo(a)gmail.com> wrote in message
> news:ace1b06a-a20c-421a-8b20-68fefa5eed5f(a)i4g2000prm.googlegroups.com...
>> I am having a devil of a time trying to develop a new
>> sound format. After abandoning my earlier efforts on
>> the basis that I could not reconstruct the binary
>> representation to a usable sound, I revisited the
>> problem today and found my local JREs do not seem
>> to play the *original* sound that I am converting,
>> correctly.
>>
>> Which leaves me to wonder whether it is the sound, the
>> code or the JRE that is the problem.
>>
>> The code is ..
>> <sscce>
>> import java.net.URL;
>> import javax.sound.sampled.*;
>>
>> public class LoopSound {
>>
>> public static void main(String[] args) throws Exception {
>> URL url = new URL(
>> "http://pscode.org/media/leftright.wav");
>> Clip clip = AudioSystem.getClip();
>> AudioInputStream ais = AudioSystem.
>> getAudioInputStream( url );
>> clip.open(ais);
>> clip.loop(5);
>> }
>> }
>> </sscce>
>>
>> The sound is located at the URL shown above. It
>> was made using Java sound, is 2 seconds in duration,
>> stereo, and should fade between 441 Hz in one channel,
>> to 882 Hz in the other, and back again.
>>
>> When I play it in the system default player, the Totem
>> Movie Player v. 2.24.3, it sounds as I expect.
>>
>> Does it play OK for you?
>>
>> (And as an aside) It should be loopable without any
>> perceptible 'click' at the loop points. Totem loops it
>> but has a noticeable click. Does it loop smoothly
>> for you?
>
> I get no sound whatsoever on Vista with Java 6 Update 16. Are you sure
> the SSCCE is correct?

Following Knute's advice now has it working, it loops without clicking.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour(a)gmail.com
[Replace the "SixFour" with numbers to email me]

From: Andrew Thompson on
On Oct 5, 3:25 pm, Knute Johnson <nos...(a)rabbitbrush.frazmtn.com>
wrote:
....
> Your problem is Java 1.5 or later.  There were some changes made in Java
> Sound in 1.5 that changed one of the threads to a daemon.  

<head-desk>
I forgot that. And that said, even after making
/specific/ comment about it in the source of
BigClip!*
</head-desk>

D'Oh!

*
<http://pscode.org/javadoc/src-html/org/pscode/xui/sound/bigclip/
BigClip.html#line.28>

>...So when your
> program ends so does the sound.  Try putting a sleep after the loop and
> it will be obvious.
>
> What you need to do is add a LineListener and wait until you get a STOP
> LineEvent before you end your main thread.

Good idea. The quick and dirty fix is to pop
a JOptionPane.

And to answer my own (second) question, it seems
to loop without any ugly clicks.

Thanks to you both.

--
Andrew T.
pscode.org