Home > Archive > Java Help > February 2007 > Opening instruments with appletviewer vs. browser
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Opening instruments with appletviewer vs. browser
|
|
|
| A Java program that I've written that makes sounds works fine when I
test it with appletviewer, but not when I use a browser (Firefox or
Explorer). The difference is that when I call the MidiSystem
synthesizer with getAvailableInstruments, I get a bunch of instruments
(411) when running it with appletviewer, but none when using a browser.
Why the difference? A short program that demonstrates my problem is
below.
Momo
import javax.swing.*;
import javax.sound.midi.*;
public class SimpleSound extends JApplet
{
public void init()
{
try {
Synthesizer synth=MidiSystem.getSynthesizer();
synth.open();
Instrument[] instr=synth.getAvailableInstruments();
JOptionPane.showMessageDialog(null,"instr.length="+instr.length);
}
catch (MidiUnavailableException e) {
}
}
}
| |
| Andrew Thompson 2007-01-26, 10:06 pm |
| On Jan 27, 5:04 am, "Momo" <m...@physics.syr.edu> wrote:
> A Java program that I've written that makes sounds works fine when I
> test it with appletviewer, but not when I use a browser (Firefox or
> Explorer). The difference is that when I call the MidiSystem
> synthesizer with getAvailableInstruments, I get a bunch of instruments
> (411) when running it with appletviewer, but none when using a browser.
> Why the difference?
Quite possibly due to bugs in the sound classes.
There was a long discussion recently* about how
newer versions of Java showed different behaviour
for the same code.
If that is the case, you might try launching your
applet using web-start, to provide more control
over Java versioning.
* Either here or c.l.j.programmer.
Andrew T.
| |
| Andrew Thompson 2007-01-26, 10:06 pm |
| On Jan 27, 5:04 am, "Momo" <m...@physics.syr.edu> wrote:
> A Java ..
Please cross-post rather than multi-post, in future.
(X-post to c.l.j.h./p., w/f-u to c.l.j.h. only)
Andrew T.
| |
| Andrew Thompson 2007-01-26, 10:06 pm |
| On Jan 27, 12:19 pm, "Andrew Thompson" <andrewtho...@gmail.com> wrote:
> On Jan 27, 5:04 am, "Momo" <m...@physics.syr.edu> wrote:
>
>
> (X-post to c.l.j.h./p., w/f-u to c.l.j.h. only)
I may have misunderstood what you did..
So while I am trying to sort out what my own
(damn) web interface to usenet is telling me,
perhaps you might confirm that the original post
was actually x-posted with follow-ups set?
Andrew T.
| |
| Andrew Thompson 2007-01-27, 7:08 pm |
| On Jan 27, 12:27 pm, "Andrew Thompson" <andrewtho...@gmail.com> wrote:[color=darkred]
> On Jan 27, 12:19 pm, "Andrew Thompson" <andrewtho...@gmail.com> wrote:
>
>
Note to OP.
Please do not send me email. FWIW, I
accept you got it wrong this time.
Feel free to continue this thread on the one
technical post that has been made.
Andrew T.
| |
|
| On Jan 26, 8:09 pm, "Andrew Thompson" <andrewtho...@gmail.com> wrote:
> On Jan 27, 5:04 am, "Momo" <m...@physics.syr.edu> wrote:
>
>
> Quite possibly due to bugs in thesoundclasses.
> There was a long discussion recently* about how
> newer versions of Java showed different behaviour
> for the same code.
>
> If that is the case, you might try launching your
> applet using web-start, to provide more control
> over Java versioning.
>
> * Either here or c.l.j.programmer.
>
> Andrew T.
Thank you for the suggestion. It turned out not to work, but I got to
learn how to use WebStart, so that was good.
The solution to my problem turned out to be that I needed to install
the Java soundbank.
(at http://java.sun.com/products/java-m...soundbanks.html )
Apparently even with the soundbank not installed, Java Sound can (on
Windows) make the sound by using a MIDI port for the sound. It will do
this when launched with appletviewer, but (apparently) not when
launched with a web browser or as an application. It seems that the
web browsers had security issues with letting the applet use a MIDI
port. (I'm still not totally sure why running it as an application
didn't work.)
My apologies for setting the follow-ups incorrectly. I believe that I
did in fact cross-post, rather than multi-posting, however?
Momo
| |
| Andrew Thompson 2007-02-11, 7:13 pm |
| On Feb 12, 8:25 am, "Momo" <m...@physics.syr.edu> wrote:
> On Jan 26, 8:09 pm, "Andrew Thompson" <andrewtho...@gmail.com> wrote:
>
>
...[color=darkred]
...[color=darkred]
> Thank you for the suggestion. It turned out not to work, but I got to
> learn how to use WebStart, so that was good.
>
> The solution to my problem turned out to be that I needed to install
> the Java soundbank.
>
> (athttp://java.sun.com/products/java-media/sound/soundbanks.html)
Did you try supplying the soundbank as
a (download='lazy') resource in the JNLP
file? That should result in the soundbank
only being downloaded for the end-users
that do not already have it installed.
Andrew T.
| |
|
| On Feb 11, 4:31 pm, "Andrew Thompson" <andrewtho...@gmail.com> wrote:
> On Feb 12, 8:25 am, "Momo" <m...@physics.syr.edu> wrote:
>
>
>
>
>
> ..
> ..
>
>
>
> Did you try supplying the soundbank as
> a (download='lazy') resource in the JNLP
> file? That should result in the soundbank
> only being downloaded for the end-users
> that do not already have it installed.
>
> Andrew T.
Hi,
No, I did not. But I will give this a try. Thank you for the
suggestion.
Momo
|
|
|
|
|