Class EightSVXDecoder
java.lang.Object
org.monte.media.eightsvx.EightSVXDecoder
- All Implemented Interfaces:
IFFVisitor
Creates a collection of EightSVXAudioClip objects by
reading an IFF 8SVX file.
8SVX Type Definitions
#define ID_8SVX MakeID('8', 'S', 'V', 'X')
#define ID_VHDR MakeID('V', 'H', 'D', 'R')
typedef LONG Fixed; // A Fixed-point value, 16 bits to the left of
// the point and 16 to the right. A Fixed is a number
// of 2^16ths, i.e., 65536ths.
#define Unity 0x10000L // Unity = Fixed 1.0 = maximum volume
// sCompression: Choice of compression algorithm applied to the samples.
#define sCmpNone 0 // not compressed
#define sCmpFibDelta 1 // Fibonacci-delta encoding.
// Can be more kinds in the future.
typedef struct {
ULONG oneShotHiSamples, // # samples in the high octave 1-shot part
repeatHiSamples, // # samples in the high octave repeat part
samplesPerHiCycle; // # samples/cycle in high octave, else 0
UWORD samplesPerSec; // data sampling rate
UBYTE ctOctave, // # octaves of waveform
sCompression; // data compression technique used
Fixed volume; // playback volume form 0 to Unity (full
// volume). Map this value into the output
// hardware's dynamic range.
} Voice8Header;
#define ID_NAME MakeID('N', 'A', 'M', 'E')
// NAME chunk contains a CHAR[], the voice's name.
#define ID_Copyright MakeID('(', 'c', ')', ' ')
// "(c) " chunk contains a CHAR[], the FORM's copyright notice.
#define ID_AUTH MakeID('A', 'U', 'T', 'H')
// AUTH chunk contains a CHAR[], the author's name.
#define ID_ANNO MakeID('A', 'N', 'N', 'O')
// ANNO chunk contains a CHAR[], author's text annotations.
#define ID_ATAK MakeID('A', 'T', 'A', 'K')
#define ID_RLSE MakeID('R', 'L', 'S', 'E')
typedef struct {
UWORD duration; // segment duration in milliseconds, > 0
Fixed dest; // destination volume factor
} EGPoint;
// ATAK and RLSE chunks contain an EGPoint[], piecewise-linear envelope.
// The envelope defines a function of time returning Fixed values. It's
// used to scale the nominal volume specified in the Voice8Header.
#define RIGHT 4L
#define LEFT 2L
#define STEREO 6L
#define ID_CHAN MakeID('C', 'H', 'A', 'N')
typedef sampletype LONG;
#define ID_PAN MakeID('P', 'A', 'N', ' ')
typedef sposition Fixed; // 0 <= sposition <= Unity
// Unity refers to the maximum possible volume.
#define ID_BODY MakeID('B', 'O', 'D', 'Y')
typedef character BYTE; // 8 bit signed number, -128 thru 127.
// BODY chunk contains a BYTE[], array of audio data samples
8SVX Regular Expression
8SVX ::= "FORM" #{ "8SVX" VHDR [NAME] [Copyright] [AUTH] ANNO* [ATAK] [RLSE] [CHAN] [PAN] BODY }
VHDR ::= "VHDR" #{ Voice8Header }
NAME ::= "NAME" #{ CHAR* } [0]
Copyright ::= "(c) " #{ CHAR* } [0]
AUTH ::= "AUTH" #{ CHAR* } [0]
ANNO ::= "ANNO" #{ CHAR* } [0]
ATAK ::= "ATAK" #{ EGPoint* }
RLSE ::= "RLSE" #{ EGPoint* }
CHAN ::= "CHAN" #{ sampletype }
PAN ::= "PAN " #{ sposition }
BODY ::= "BODY" #{ BYTE* } [0]
The token "#" represents a ckSize LONG count of the following {braced} data bytes.
E.g., a VHDR's "#" should equal sizeof(Voice8Header). Literal items are shown in
"quotes", [square bracket items] are optional, and "*" means 0 ore more replications.
A sometimes-needed pad byte is shown as "[0]".- Author:
- Werner Randelshofer, Hausmatt 10, CH-6405 Goldau, Switzerland
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Audio Source from the specified InputStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAudioClip(AudioClip clip) protected voiddecodeANNO(EightSVXAudioClip sample, IFFChunk[] chunks) protected voiddecodeAUTH(EightSVXAudioClip sample, IFFChunk chunk) protected voiddecodeBODY(EightSVXAudioClip sample, IFFChunk chunk) protected voiddecodeCHAN(EightSVXAudioClip sample, IFFChunk chunk) protected voiddecodeCOPYRIGHT(EightSVXAudioClip sample, IFFChunk chunk) protected voiddecodeNAME(EightSVXAudioClip sample, IFFChunk chunk) protected voiddecodeVHDR(EightSVXAudioClip sample, IFFChunk chunk) The Voice 8 Header (VHDR) property chunk holds the playback parameters for the sampled waveform.voidenterGroup(IFFChunk group) Visits the start of an IFF GroupChunkExpression.voidleaveGroup(IFFChunk group) voidregisterChunks(IFFParser iff) voidvisitChunk(IFFChunk group, IFFChunk chunk)
-
Field Details
-
EIGHT_SVX_ID
public static final int EIGHT_SVX_ID -
VHDR_ID
public static final int VHDR_ID -
NAME_ID
public static final int NAME_ID -
COPYRIGHT_ID
public static final int COPYRIGHT_ID -
ANNO_ID
public static final int ANNO_ID -
AUTH_ID
public static final int AUTH_ID -
CHAN_ID
public static final int CHAN_ID -
BODY_ID
public static final int BODY_ID
-
-
Constructor Details
-
EightSVXDecoder
Creates a new Audio Source from the specified InputStream.Pre condition InputStream must contain IFF 8SVX data. Post condition - Obligation -
- Parameters:
in- The input stream.- Throws:
IOException
-
EightSVXDecoder
public EightSVXDecoder()
-
-
Method Details
-
getSamples
-
registerChunks
-
enterGroup
Visits the start of an IFF GroupChunkExpression.Although this method is declared as public it may only be called from an IFFParser that has been invoked by this class.
Pre condition Vector "clips" must not be null. This method expects only FORM groups of type 8SVX. Post condition - Obligation -
- Specified by:
enterGroupin interfaceIFFVisitor- Parameters:
group- Group Chunk to be visited.
-
leaveGroup
- Specified by:
leaveGroupin interfaceIFFVisitor
-
visitChunk
- Specified by:
visitChunkin interfaceIFFVisitor- Throws:
ParseException
-
addAudioClip
-
decodeVHDR
The Voice 8 Header (VHDR) property chunk holds the playback parameters for the sampled waveform.typedef LONG Fixed; // A Fixed-point value, 16 bits to the left of // the point and 16 to the right. A Fixed is a number // of 2^16ths, i.e., 65536ths. #define Unity 0x10000L // Unity = Fixed 1.0 = maximum volume // sCompression: Choice of compression algorithm applied to the samples. #define sCmpNone 0 // not compressed #define sCmpFibDelta 1 // Fibonacci-delta encoding. // Can be more kinds in the future. typedef struct { ULONG oneShotHiSamples, // # samples in the high octave 1-shot part repeatHiSamples, // # samples in the high octave repeat part samplesPerHiCycle; // # samples/cycle in high octave, else 0 UWORD samplesPerSec; // data sampling rate UBYTE ctOctave, // # octaves of waveform sCompression; // data compression technique used Fixed volume; // playback volume form 0 to Unity (full // volume). Map this value into the output // hardware's dynamic range. } Voice8Header;- Throws:
ParseException
-
decodeCHAN
- Throws:
ParseException
-
decodeNAME
- Throws:
ParseException
-
decodeCOPYRIGHT
- Throws:
ParseException
-
decodeAUTH
- Throws:
ParseException
-
decodeANNO
- Throws:
ParseException
-
decodeBODY
- Throws:
ParseException
-