Playing (MIDI) sounds from Java applet (Shepard's Tones)  
Author Message
SOB-like MIDIs





PostPosted: 2003-10-17 8:36:00 Top

java-programmer, Playing (MIDI) sounds from Java applet (Shepard's Tones)

The applet for endlessly rising/falling scale
(auditory illusion)
on this page is fantastic!

http://www.cs.ubc.ca/nest/imager/contributions/flinn/Illusions/ST/st.html


How is this done?
(I'm assuming it uses MIDI.)

Is this sound applet playable from any
java-enabled browser on any Windows system?

How about on Mac or Unix?


I'm asking because I want to write
Java programs that plays simple
2-part inventions by Bach.

Thanks.

http://geocities.com/SOBlikeMIDIs/




__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
 
snamaur





PostPosted: 2003-10-17 18:23:00 Top

java-programmer >> Playing (MIDI) sounds from Java applet (Shepard's Tones) > The applet for endlessly rising/falling scale
> (auditory illusion)
> on this page is fantastic!
>
> http://www.cs.ubc.ca/nest/imager/contributions/flinn/Illusions/ST/st.html
>
>
> How is this done?
> (I'm assuming it uses MIDI.)
>

Sorry, but it uses .AU files ( download and use Jode, then you got:

...
public void init(AppletStarter appletstarter) {
applet = appletstarter;
URL url = appletstarter.getCodeBase();
int i = 1;
STone2 = new AudioClip[12];
for (int i_0_ = 0; i_0_ < 12; i_0_++) {
appletstarter.setLabel("Loading audio clip " + i + " of 36 ...");
i++;
String string = "st-c2/st" + (i_0_ + 1) + ".au";
STone2[i_0_] = appletstarter.getAudioClip(url, string);
if (STone2[i_0_] == null)
System.out.println("Couldn't load audio clip " + url + string);
}
STone3 = new AudioClip[12];
for (int i_1_ = 0; i_1_ < 12; i_1_++) {
appletstarter.setLabel("Loading audio clip " + i + " of 36 ...");
i++;
String string = "st-c3/st" + (i_1_ + 1) + ".au";
STone3[i_1_] = appletstarter.getAudioClip(url, string);
if (STone3[i_1_] == null)
System.out
.println("Couldn't create audio clip " + url + string);
}
STone6 = new AudioClip[12];
for (int i_2_ = 0; i_2_ < 12; i_2_++) {
appletstarter.setLabel("Loading audio clip " + i + " of 36 ...");
i++;
String string = "st-c6/st" + (i_2_ + 1) + ".au";
STone6[i_2_] = appletstarter.getAudioClip(url, string);
if (STone6[i_2_] == null)
System.out
.println("Couldn't create audio clip " + url + string);
}
appletstarter.appletLoaded();
}
...
)

Scooby-Ced
 
nathanz





PostPosted: 2003-10-17 23:52:00 Top

java-programmer >> Playing (MIDI) sounds from Java applet (Shepard's Tones) A link to the source code is provided:

http://www.cs.ubc.ca/nest/imager/contributions/flinn/Illusions/Applets/source.html

-Nathan

email***@***.com (Cedric) wrote in message news:<email***@***.com>...
> > The applet for endlessly rising/falling scale
> > (auditory illusion)
> > on this page is fantastic!
> >
> > http://www.cs.ubc.ca/nest/imager/contributions/flinn/Illusions/ST/st.html
> >
> >
> > How is this done?
> > (I'm assuming it uses MIDI.)
> >
>
> Sorry, but it uses .AU files ( download and use Jode, then you got:
>
> ...
> public void init(AppletStarter appletstarter) {
> applet = appletstarter;
> URL url = appletstarter.getCodeBase();
> int i = 1;
> STone2 = new AudioClip[12];
> for (int i_0_ = 0; i_0_ < 12; i_0_++) {
> appletstarter.setLabel("Loading audio clip " + i + " of 36 ...");
> i++;
> String string = "st-c2/st" + (i_0_ + 1) + ".au";
> STone2[i_0_] = appletstarter.getAudioClip(url, string);
> if (STone2[i_0_] == null)
> System.out.println("Couldn't load audio clip " + url + string);
> }
> STone3 = new AudioClip[12];
> for (int i_1_ = 0; i_1_ < 12; i_1_++) {
> appletstarter.setLabel("Loading audio clip " + i + " of 36 ...");
> i++;
> String string = "st-c3/st" + (i_1_ + 1) + ".au";
> STone3[i_1_] = appletstarter.getAudioClip(url, string);
> if (STone3[i_1_] == null)
> System.out
> .println("Couldn't create audio clip " + url + string);
> }
> STone6 = new AudioClip[12];
> for (int i_2_ = 0; i_2_ < 12; i_2_++) {
> appletstarter.setLabel("Loading audio clip " + i + " of 36 ...");
> i++;
> String string = "st-c6/st" + (i_2_ + 1) + ".au";
> STone6[i_2_] = appletstarter.getAudioClip(url, string);
> if (STone6[i_2_] == null)
> System.out
> .println("Couldn't create audio clip " + url + string);
> }
> appletstarter.appletLoaded();
> }
> ...
> )
>
> Scooby-Ced
 
 
Ben





PostPosted: 2003-10-23 4:36:00 Top

java-programmer >> Playing (MIDI) sounds from Java applet (Shepard's Tones) "SOB-like MIDIs" wrote :

> How is this done?
> (I'm assuming it uses MIDI.)

No. Java only supports MIDI in its 1.4 version (javax.sound.midi).
This applet runs regular short au clips. Another method to do
audio with earlier versions of java is to use the sun.audio classes.
They're not standard java, but (before 1.4) it was the only way to
perform low-level sound synthesis in java.

An example with source code :
http://www.neuralsemantics.com/applets/jazz.html
(also take a look at the online e-guitar !)

> Is this sound applet playable from any
> java-enabled browser on any Windows system?

supposed to be, yes (provided there is a sound card !)

> How about on Mac or Unix?

same

Ben