Class EightSVXDecoder

java.lang.Object
org.monte.media.eightsvx.EightSVXDecoder
All Implemented Interfaces:
IFFVisitor

public class EightSVXDecoder extends Object implements 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 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
    • 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

      public EightSVXDecoder(InputStream in) throws IOException
      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

      public ArrayList<AudioClip> getSamples()
    • registerChunks

      public void registerChunks(IFFParser iff)
    • enterGroup

      public void enterGroup(IFFChunk group)
      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:
      enterGroup in interface IFFVisitor
      Parameters:
      group - Group Chunk to be visited.
    • leaveGroup

      public void leaveGroup(IFFChunk group)
      Specified by:
      leaveGroup in interface IFFVisitor
    • visitChunk

      public void visitChunk(IFFChunk group, IFFChunk chunk) throws ParseException
      Specified by:
      visitChunk in interface IFFVisitor
      Throws:
      ParseException
    • addAudioClip

      public void addAudioClip(AudioClip clip)
    • decodeVHDR

      protected void decodeVHDR(EightSVXAudioClip sample, IFFChunk chunk) throws ParseException
      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

      protected void decodeCHAN(EightSVXAudioClip sample, IFFChunk chunk) throws ParseException
      Throws:
      ParseException
    • decodeNAME

      protected void decodeNAME(EightSVXAudioClip sample, IFFChunk chunk) throws ParseException
      Throws:
      ParseException
    • decodeCOPYRIGHT

      protected void decodeCOPYRIGHT(EightSVXAudioClip sample, IFFChunk chunk) throws ParseException
      Throws:
      ParseException
    • decodeAUTH

      protected void decodeAUTH(EightSVXAudioClip sample, IFFChunk chunk) throws ParseException
      Throws:
      ParseException
    • decodeANNO

      protected void decodeANNO(EightSVXAudioClip sample, IFFChunk[] chunks) throws ParseException
      Throws:
      ParseException
    • decodeBODY

      protected void decodeBODY(EightSVXAudioClip sample, IFFChunk chunk) throws ParseException
      Throws:
      ParseException