3 // Contains interface definition of VoiCTech (Voice Communications Technology)
4 // voice encoder/decoder.
6 // Written by Matthew F. Storch, Ph.D., copyright (c) 1998 Volition Inc.
9 //////////////////////////////////////////////////////////////////////////////
11 // Introduction to the VoiCTech encoder
12 // ------------------------------------
13 // The VoiCTech (short for Voice Communication Technology, pronounced
14 // "voice-tech") audio codec uses two separate algorithm suites: Codec1
15 // and LPC-10. Codec1 does compression without using traditional signal
16 // processing algorithms (expcept for a simple FIR low-pass filter). As
17 // a result, it is extremely fast, and yields moderate-quality voice at a
18 // compression ratio of between 3-to-1 and 10-to-1, assuming 11KHz sampled
19 // data. LPC-10 does significantly more analysis and is therefore slower
20 // (approximately 3 times slower than Codec1), but achieves substantially
21 // better compression (25-1) at a comparable quality. (However, the
22 // *character* of the loss in quality is quite different.)
24 // The externally-callable interface for both algorithm suites is through
25 // a simple, generic front-end that is prototyped in this file.
27 // codec1.cpp contains the implementions of both the generic interface and
28 // Codec1. LPC-10 is implemented in a set of files in the LPC10 subdirectory.
30 //////////////////////////////////////////////////////////////////////////////
33 // VoiCTech is only intended to work with 8-bit samples recorded at 11KHz.
34 // 8KHz should also work.
35 typedef unsigned char t_Sample;
38 enum t_Code { e_cCodec1, e_cLPC10 };
40 // One of these is passed with every buffer that is transmitted; it contains
41 // data on how to decode the buffer.
42 struct t_CodeInfo { t_Code Code; double Gain; };
45 // WARNING ***** DANGER ***** WARNING ***** DANGER ***** WARNING ***** DANGER
46 // If LPC-10 is used, all buffers must be a multiple of LFRAME (Frame length
47 // for LPC-10 codec) in length
49 // WARNING ***** DANGER ***** WARNING ***** DANGER ***** WARNING ***** DANGER
52 //////////////////////////////////////////////////////////////////////////////
53 // InitDecoder must be called once to initialize the decoder.
55 // QoS - Quality of Service: 1..10, 1 = highest compression/lowest
56 // quality, 10 = worst compression/best quality (currently
57 // *not* used by decoder)
58 // tempBuf - Temporary buffer that must be available until Encode() will
59 // no longer be called. Must be at least as large as the
60 // largest sizeIn that will be passed to Encode().
62 // initializes global variables
64 void InitDecoder(int QoS, t_Sample* tempBuf);
66 //////////////////////////////////////////////////////////////////////////////
69 //////////////////////////////////////////////////////////////////////////////
70 // Decode is the main decoder entry point.
72 // codeInfo - Information about how the buffer was encoded
73 // bufIn - Encoded data to decode
74 // bufOut - Empty buffer in which to place decoded data (should be
75 // at least decodeSize in length)
76 // encodeSize - Size in bytes of encoded data in bufIn
77 // decodeSize - Size data should be after decoding
79 // bufOut - Decoded data written here
82 void Decode(t_CodeInfo* codeInfo, t_Sample* bufIn, t_Sample* bufOut,
83 int encodeSize, int decodeSize);
85 //////////////////////////////////////////////////////////////////////////////
88 //////////////////////////////////////////////////////////////////////////////
89 // InitEncoder must be called once to initialize the encoder. May safely be
90 // called again to change tuning parameters.
92 // code - The algorithm that will be used to encode the data in
93 // subsequent calls to Encode()
94 // QoS - Quality of Service: 1..10, 1 = highest compression/lowest
95 // quality, 10 = worst compression/best quality
96 // tempBuf1 - Temporary buffer that must be available until Encode() will
97 // no longer be called. Must be at least as large as the
98 // largest sizeIn that will be passed to Encode().
99 // tempBuf2 - Another temporary buffer (cannot be the same buffer as
100 // tempBuf1) with same lifetime and size as tempBuf1.
102 // initializes global variables
104 void InitEncoder(t_Code code, int QoS, t_Sample* tempBuf1, t_Sample* tempBuf2);
106 //////////////////////////////////////////////////////////////////////////////
109 //////////////////////////////////////////////////////////////////////////////
110 // Encode is the main Encoder entry point.
112 // bufIn - encoded data to decode
113 // bufOut - empty buffer in which to place decoded data
114 // sizeIn - size of bufIn in bytes
115 // sizeOut - size of bufOut in bytes
117 // bufOut - encoded data written here
118 // returns - number of bytes written to bufOut
120 #if defined(CODEC_DEMO)
121 // Test program version
122 int Encode(t_Sample* bufIn, t_Sample* bufOut, int sizeIn, int sizeOut,
123 t_CodeInfo* codeInfo,
124 t_Sample* levels, int* modes, int samples[9], int storage[9]);
127 int Encode(t_Sample* bufIn, t_Sample* bufOut, int sizeIn, int sizeOut,
128 t_CodeInfo* codeInfo);
131 //////////////////////////////////////////////////////////////////////////////