|
Copyright 2011-01-06 Werner Randelshofer | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectch.randelshofer.media.eightsvx.EightSVXAudioClip
public class EightSVXAudioClip
Represents an audio sample of type IFF 8SVX.
Supported audio formats:
8 bit linear and fibonacci encoded data samples.
All sample rates
Stereo and Mono
Unsupported features:
Attack and Release information is ignored.
Multi octave samples are not handled.
Known Issues
This class has been implemented with JDK 1.1 in mind. JDK 1.1 does not
have a public API for Sound. This class will thus work only on a small number
of Java VMS.
Poor sound qualitiy: All data is being converted to U-Law 8000 Hertz,
since this is the only kind of audio data that JDK 1.1 supports (As far as I know).
Stereo sound is converted to mono. As far as I know there is now stereo
support built in JDK 1.1.
| Field Summary | |
|---|---|
static int |
LEFT
|
static int |
RIGHT
|
static int |
S_CMP_FIB_DELTA
|
static int |
S_CMP_NONE
|
static int |
STEREO
|
| Fields inherited from interface ch.randelshofer.media.eightsvx.LoopableAudioClip |
|---|
LOOP_CONTINUOUSLY |
| Constructor Summary | |
|---|---|
EightSVXAudioClip()
|
|
| Method Summary | |
|---|---|
static double |
computeStereoVolumeCorrection(byte[] stereo)
This finds the volume correction needed when converting this stereo sample to mono. |
LoopableAudioClip |
createAudioClip()
|
LoopableAudioClip |
createAudioClip(int sampleRate,
int volume,
float pan)
|
LoopableAudioClip |
createJDK10AudioClip(int sampleRate)
|
LoopableAudioClip |
createJDK13AudioClip(int sampleRate,
int volume,
float pan)
|
byte[] |
get8SVXBody()
|
protected java.lang.String |
getAuthor()
|
protected java.lang.String |
getCopyright()
|
int |
getCtOctave()
|
protected java.lang.String |
getName()
|
long |
getOneShotHiSamples()
|
protected java.lang.String |
getRemark()
|
long |
getRepeatHiSamples()
|
int |
getSampleRate()
|
long |
getSamplesPerHiCycle()
|
long |
getSampleType()
|
int |
getSCompression()
|
int |
getVolume()
|
static byte[] |
linear16ToULaw(int[] linear16)
Converts a buffer of signed 8bit samples to uLaw. |
static byte[] |
linear8StereoToMono(byte[] stereo,
double volumeCorrection)
This converts a stereo sample to mono. |
static byte[] |
linear8ToULaw(byte[] linear8)
Halfband lowpass. |
void |
loop()
|
void |
loop(int count)
Starts looping playback from the current position. |
void |
play()
|
void |
prepare()
Make this clip ready for playback. |
static byte[] |
resample(byte[] input,
int inputSampleRate,
int outputSampleRate)
Resamples audio data to match the given sample rate and applies a lowpass filter if necessary. |
void |
set8SVXBody(byte[] value)
|
protected void |
setAuthor(java.lang.String value)
|
protected void |
setCopyright(java.lang.String value)
|
void |
setCtOctave(int value)
|
protected void |
setName(java.lang.String value)
|
void |
setOneShotHiSamples(long value)
|
protected void |
setRemark(java.lang.String value)
|
void |
setRepeatHiSamples(long value)
|
void |
setSampleRate(int value)
|
void |
setSamplesPerHiCycle(long value)
|
void |
setSampleType(int value)
|
void |
setSCompression(int value)
|
void |
setVolume(int value)
|
void |
stop()
|
java.lang.String |
toString()
|
static byte[] |
unpackFibonacciDeltaCompression(byte[] source)
Unpack Fibonacci-delta encoded data from n byte source buffer into 2*(n-2) byte dest buffer. |
static void |
writeSunAudioHeader(java.io.OutputStream outfile,
int dataSize,
int sampleRate,
int sampleType)
Write a "standard" sun header. |
static void |
wrulong(java.io.OutputStream outfile,
int ulong)
Write an unsigned long (Motorola 68000 CPU format). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int S_CMP_NONE
public static final int S_CMP_FIB_DELTA
public static final int RIGHT
public static final int LEFT
public static final int STEREO
| Constructor Detail |
|---|
public EightSVXAudioClip()
| Method Detail |
|---|
protected void setName(java.lang.String value)
protected java.lang.String getName()
protected void setAuthor(java.lang.String value)
protected java.lang.String getAuthor()
protected void setCopyright(java.lang.String value)
protected java.lang.String getCopyright()
protected void setRemark(java.lang.String value)
protected java.lang.String getRemark()
public void set8SVXBody(byte[] value)
public byte[] get8SVXBody()
public void setOneShotHiSamples(long value)
public void setRepeatHiSamples(long value)
public void setSamplesPerHiCycle(long value)
public void setSampleType(int value)
public void setSampleRate(int value)
public void setCtOctave(int value)
public void setSCompression(int value)
public void setVolume(int value)
public long getOneShotHiSamples()
public long getRepeatHiSamples()
public long getSamplesPerHiCycle()
public long getSampleType()
public int getSampleRate()
public int getCtOctave()
public int getVolume()
public int getSCompression()
public java.lang.String toString()
toString in class java.lang.Objectpublic LoopableAudioClip createAudioClip()
public LoopableAudioClip createAudioClip(int sampleRate,
int volume,
float pan)
public LoopableAudioClip createJDK13AudioClip(int sampleRate,
int volume,
float pan)
public LoopableAudioClip createJDK10AudioClip(int sampleRate)
public void play()
play in interface java.applet.AudioClippublic void loop()
loop in interface java.applet.AudioClippublic void stop()
stop in interface java.applet.AudioClippublic void prepare()
public static double computeStereoVolumeCorrection(byte[] stereo)
stereo - Stereo data linear 8. The first half of the
array contains the sound for the left speaker,
the second half the sound for the right speaker.
public static byte[] linear8StereoToMono(byte[] stereo,
double volumeCorrection)
stereo - Stereo data linear 8. The first half of the
array contains the sound for the left speaker,
the second half the sound for the right speaker.volumeCorrection - Combining the two channels into one increases the
sound volume. This can exceed the maximum volume
that can be represented by the linear8 sample model.
To avoid this, the volume must be corrected to fit
into the sample model.
public static byte[] resample(byte[] input,
int inputSampleRate,
int outputSampleRate)
input - Linear8 encoded audio data.inputSampleRate - The sample rate of the input dataoutputSampleRate - The sample rate of the output data.
public static byte[] linear8ToULaw(byte[] linear8)
public static byte[] linear16ToULaw(int[] linear16)
public static byte[] unpackFibonacciDeltaCompression(byte[] source)
public static void writeSunAudioHeader(java.io.OutputStream outfile,
int dataSize,
int sampleRate,
int sampleType)
throws java.io.IOException
sampleType - Specify STEREO, LEFT or RIGHT.
java.io.IOException
public static void wrulong(java.io.OutputStream outfile,
int ulong)
throws java.io.IOException
java.io.IOExceptionpublic void loop(int count)
count times, and finally continue playback to the end of
the clip.
If the current position when this method is invoked is greater than the loop end point, playback simply continues to the end of the clip without looping.
A count value of 0 indicates that any current looping should
cease and playback should continue to the end of the clip. The behavior
is undefined when this method is invoked with any other value during a
loop operation.
If playback is stopped during looping, the current loop status is cleared; the behavior of subsequent loop and start requests is not affected by an interrupted loop operation.
loop in interface LoopableAudioClipcount - the number of times playback should loop back from the
loop's end position to the loop's start position, or
LoopableAudioClip.LOOP_CONTINUOUSLY to indicate that looping should
continue until interrupted
|
Copyright 2011-01-06 Werner Randelshofer | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||