working on java 1.1 audio

This commit is contained in:
benfry
2005-02-05 03:35:59 +00:00
parent dd93cccce0
commit 9c7467d0bd
2 changed files with 208 additions and 11 deletions

View File

@@ -33,7 +33,7 @@ import javax.sound.sampled.*;
// for this class: http://javaalmanac.com/egs/javax.sound.sampled/pkg.html
public class PSound2 extends PSound {
PApplet parent;
//PApplet parent;
Method soundEventMethod;
Clip clip;
@@ -47,12 +47,11 @@ public class PSound2 extends PSound {
AudioInputStream stream =
AudioSystem.getAudioInputStream(input);
// *** this code appears as though it may just be faulty ***
// At present, ALAW and ULAW encodings must be converted
// to PCM_SIGNED before it can be played
AudioFormat format = stream.getFormat();
if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
// *** this code appears as though it may just be faulty ***
format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
format.getSampleRate(),
format.getSampleSizeInBits()*2,
@@ -61,7 +60,7 @@ public class PSound2 extends PSound {
format.getFrameRate(),
true); // big endian
stream = AudioSystem.getAudioInputStream(format, stream);
//} else {
//} else {
//System.out.println("no conversion necessary");
}
@@ -202,6 +201,7 @@ public class PSound2 extends PSound {
gainControl.setValue(dB);
}
/** mute */
/*
public void noVolume() {