...
[speexdsp.git] / doc / manual.lyx
1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 221
3 \textclass article
4 \begin_preamble
5 \usepackage{times}
6 \end_preamble
7 \language english
8 \inputencoding auto
9 \fontscheme default
10 \graphics default
11 \paperfontsize default
12 \spacing single 
13 \papersize Default
14 \paperpackage a4
15 \use_geometry 0
16 \use_amsmath 0
17 \use_natbib 0
18 \use_numerical_citations 0
19 \paperorientation portrait
20 \secnumdepth 3
21 \tocdepth 3
22 \paragraph_separation indent
23 \defskip medskip
24 \quotes_language english
25 \quotes_times 2
26 \papercolumns 1
27 \papersides 1
28 \paperpagestyle headings
29
30 \layout Title
31
32 The Speex Codec Manual
33 \newline 
34 (version 1.0)
35 \layout Author
36
37 Jean-Marc Valin
38 \layout Standard
39 \pagebreak_top 
40 Copyright (c) 2002-2003 Jean-Marc Valin.
41 \layout Standard
42
43 Permission is granted to copy, distribute and/or modify this document under
44  the terms of the GNU Free Documentation License, Version 1.1 or any later
45  version published by the Free Software Foundation; with no Invariant Section,
46  with no Front-Cover Texts, and with no Back-Cover.
47  A copy of the license is included in the section entitled "GNU Free Documentati
48 on License".
49  
50 \layout Standard
51 \pagebreak_top \pagebreak_bottom 
52
53 \begin_inset LatexCommand \tableofcontents{}
54
55 \end_inset 
56
57
58 \layout Standard
59 \pagebreak_bottom 
60
61 \begin_inset FloatList table
62
63 \end_inset 
64
65
66 \layout Section
67
68 Introduction to Speex
69 \layout Standard
70
71 The Speex project (
72 \family typewriter 
73 http://www.speex.org/
74 \family default 
75 ) has been started because there was a need for a speech codec that was
76  open-source and free from software patents.
77  These are essential conditions for being used by any open-source software.
78  There is already Vorbis that does general audio, but it is not really suitable
79  for speech.
80  Also, unlike many other speech codecs, Speex is not targeted at cell phones
81  (not many open-source cell phones anyway :-) ) but rather voice over IP
82  (VoIP) and file-based compression.
83  
84 \layout Standard
85
86 As design goals, we wanted to have a codec that would allowed both very
87  good quality speech and low bit-rate (unfortunately not at the same time!),
88  which led us to developing a codec with multiple bit-rates.
89  Of course very good quality also meant we had to do wideband (16 kHz sampling
90  rate) in addition to narrowband (telephone quality, 8 kHz sampling rate).
91 \layout Standard
92
93 Designing for VoIP instead of cell phone use means that Speex must be robust
94  to lost packets, but not to corrupted ones since packets either arrive
95  unaltered or don't arrive at all.
96  Also, the idea was to have a reasonnable complexity and memory requirement
97  without compromising too much on the efficiency of the codec.
98 \layout Standard
99
100 All this led us to the choice of CELP
101 \begin_inset LatexCommand \index{CELP}
102
103 \end_inset 
104
105  as the encoding technique to use for Speex.
106  One of the main reasons is that CELP has long proved that it could do the
107  job and scale well to both low bit-rates (think DoD CELP @ 4.8 kbps) and
108  high bit-rates (think G.728 @ 16 kbps).
109  
110 \layout Standard
111
112 The main characteristics can be summerized as follows:
113 \layout Itemize
114
115 Free software/open-source
116 \begin_inset LatexCommand \index{open-source}
117
118 \end_inset 
119
120 , patent
121 \begin_inset LatexCommand \index{patent}
122
123 \end_inset 
124
125  and royalty-free
126 \layout Itemize
127
128 Integration of narrowband
129 \begin_inset LatexCommand \index{narrowband}
130
131 \end_inset 
132
133  and wideband
134 \begin_inset LatexCommand \index{wideband}
135
136 \end_inset 
137
138  in the same bit-stream
139 \layout Itemize
140
141 Wide range of bit-rates available (from 2 kbps to 44 kbps)
142 \layout Itemize
143
144 Dynamic bit-rate switching and Variable Bit-Rate
145 \begin_inset LatexCommand \index{variable bit-rate}
146
147 \end_inset 
148
149  (VBR)
150 \layout Itemize
151
152 Voice Activity Detection
153 \begin_inset LatexCommand \index{voice activity detection}
154
155 \end_inset 
156
157  (VAD, integrated with VBR)
158 \layout Itemize
159
160 Variable complexity
161 \begin_inset LatexCommand \index{complexity}
162
163 \end_inset 
164
165
166 \layout Itemize
167
168 Ultra-wideband mode at 32 kHz (up to 48 kHz)
169 \layout Itemize
170
171 Intensity stereo encoding option
172 \layout Section
173 \pagebreak_top 
174 Feature description
175 \layout Standard
176
177 This section explains the main Speex features, as well as some concepts
178  in speech coding that help better understand the next sections.
179  
180 \layout Subsection*
181
182 Sampling rate
183 \begin_inset LatexCommand \index{sampling rate}
184
185 \end_inset 
186
187
188 \layout Standard
189
190 Speex is mainly designed for 3 different sampling rates: 8 kHz, 16 kHz,
191  and 32 kHz.
192  These are respectively refered to as narrowband
193 \begin_inset LatexCommand \index{narrowband}
194
195 \end_inset 
196
197 , wideband
198 \begin_inset LatexCommand \index{wideband}
199
200 \end_inset 
201
202  and ultra-wideband
203 \begin_inset LatexCommand \index{ultra-wideband}
204
205 \end_inset 
206
207 .
208  
209 \layout Subsection*
210
211 Quality
212 \begin_inset LatexCommand \index{quality}
213
214 \end_inset 
215
216
217 \layout Standard
218
219 Speex encoding is controlled most of the time by a quality parameter that
220  range from 0 to 10.
221  In constant bit-rate
222 \begin_inset LatexCommand \index{constant bit-rate}
223
224 \end_inset 
225
226  (CBR) operation, the quality parameter is an integer, while for variable
227  bit-rate (VBR), the parameter is a float.
228  
229 \layout Subsection*
230
231 Complexity
232 \begin_inset LatexCommand \index{complexity}
233
234 \end_inset 
235
236  (variable)
237 \layout Standard
238
239 With Speex, it is possible to vary the complexity allowed for the encoder.
240  This is done by controlling how the search is performed with an integer
241  ranging from 1 to 10 in a way that's similar to the -1 to -9 options to
242  
243 \emph on 
244 gzip
245 \emph default 
246  and 
247 \emph on 
248 bzip2
249 \emph default 
250  compression utilities.
251  For normal use, the noise level at complexity 1is between 1 and 2 dB higher
252  than at complexity 10, but the CPU requirements for complexity 10 is about
253  5 time higher than for complexity 1.
254  In practice, the best trade-off is between complexity 2 and 4, though higher
255  settings are often useful when encoding non-speech sounds like DTMF
256 \begin_inset LatexCommand \index{DTMF}
257
258 \end_inset 
259
260  tones.
261 \layout Subsection*
262
263 Variable Bit-Rate
264 \begin_inset LatexCommand \index{variable bit-rate}
265
266 \end_inset 
267
268  (VBR)
269 \layout Standard
270
271 Variable bit-rate (VBR) allows a codec to change its bit-rate dynamically
272  to adapt to the 
273 \begin_inset Quotes eld
274 \end_inset 
275
276 difficulty
277 \begin_inset Quotes erd
278 \end_inset 
279
280  of the audio being encoded.
281  In the example of Speex, sounds like vowels and high-energy transients
282  require a higher bit-rate to achieve good quality, while fricatives (e.g.
283  s,f sounds) can be coded adequately with less bits.
284  For this reason, VBR can achive lower bit-rate for the same quality, or
285  a better quality for a certain bit-rate.
286  Despite its advantages, VBR has two main drawbacks: first, by only specifying
287  quality, there's no guaranty about the final average bit-rate.
288  Second, for some real-time applications like voice over IP (VoIP), what
289  counts is the maximum bit-rate, which must be low enough for the communication
290  channel.
291 \layout Subsection*
292
293 Average Bit-Rate
294 \begin_inset LatexCommand \index{average bit-rate}
295
296 \end_inset 
297
298  (ABR)
299 \layout Standard
300
301 Average bit-rate solves one of the problems of VBR, as it dynamically adjusts
302  VBR quality in order to meet a specific target bit-rate.
303  Because the quality/bit-rate is adjusted in real-time (open-loop), the
304  global quality will be slightly lower than that obtained be encoding in
305  VBR with exactly the right quality setting to meet the target average bit-rate.
306 \layout Subsection*
307
308 Voice Activity Detection
309 \begin_inset LatexCommand \index{voice activity detection}
310
311 \end_inset 
312
313  (VAD)
314 \layout Standard
315
316 When enabled, voice activity detection detects whether the audio being encoded
317  is speech or silence/background noise.
318  VAD is always implicitly activated when encoding in VBR, so the option
319  is only useful in non-VBR operation.
320  In this case, Speex detects non-speech periods and encode them with just
321  enough bits to reproduce the background noise.
322  This is called 
323 \begin_inset Quotes eld
324 \end_inset 
325
326 comfort noise generation
327 \begin_inset Quotes erd
328 \end_inset 
329
330  (CNG).
331 \layout Subsection*
332
333 Discontinuous Transmission
334 \begin_inset LatexCommand \index{discontinuous transmission}
335
336 \end_inset 
337
338  (DTX)
339 \layout Standard
340
341 Discontinuous transmission is an addition to VAD/VBR operation, that allows
342  to stop transmitting completely when the background noise is stationnary.
343  In file-based operation, since we cannot just stop writing to the file,
344  only 5 bits are used for such frames (corresponding to 250 bps).
345 \layout Subsection*
346
347 Perceptual enhancement
348 \begin_inset LatexCommand \index{perceptual enhancement}
349
350 \end_inset 
351
352
353 \layout Standard
354
355 Perceptual enhancement is a part of the decoder which, when turned on, tries
356  to reduce (the perception of) the noise produced by the coding/decoding
357  process.
358  In most cases, perceptual enhancement make the sound further from the original
359  
360 \emph on 
361 objectively
362 \emph default 
363  (if you use SNR), but in the end it still 
364 \emph on 
365 sounds
366 \emph default 
367  better (subjective improvement).
368 \layout Subsection*
369
370 Algorithmic delay
371 \begin_inset LatexCommand \index{algorithmic delay}
372
373 \end_inset 
374
375
376 \layout Standard
377
378 Every speech codec introduces a delay in the transmission.
379  For Speex, this delay is equal to the frame size, plus some amount of 
380 \begin_inset Quotes eld
381 \end_inset 
382
383 look-ahead
384 \begin_inset Quotes erd
385 \end_inset 
386
387  required to process each frame.
388  In narrowband operation (8 kHz), the delay is 30 ms, while for wideband
389  (16 kHz), the delay is 34 ms.
390  These values don't account for the CPU time it takes to encode or decode
391  the frames.
392 \layout Section
393 \pagebreak_top 
394 Command-line encoder/decoder
395 \begin_inset LatexCommand \label{sec:Command-line-encoder/decoder}
396
397 \end_inset 
398
399
400 \layout Standard
401
402 The base Speex distribution includes a command-line encoder (
403 \emph on 
404 speexenc
405 \emph default 
406 ) and decoder (
407 \emph on 
408 speexdec
409 \emph default 
410 ).
411  This section describes how to use these tools.
412 \layout Subsection
413
414
415 \emph on 
416 speexenc
417 \begin_inset LatexCommand \index{speexenc}
418
419 \end_inset 
420
421
422 \layout Standard
423
424 The 
425 \emph on 
426 speexenc
427 \emph default 
428  utility is used to create Speex files from raw PCM or wave files.
429  It can be used by calling: 
430 \layout LyX-Code
431
432 speexenc [options] input_file output_file
433 \layout Standard
434
435 The value '-' for input_file or output_file corresponds respectively to
436  stdin and stdout.
437  The valid options are:
438 \layout Description
439
440 --narrowband\SpecialChar ~
441 (-n) Tell Speex to treat the input as narrowband (8 kHz).
442  This is the default
443 \layout Description
444
445 --wideband\SpecialChar ~
446 (-w) Tell Speex to treat the input as wideband (16 kHz)
447 \layout Description
448
449 --ultra-wideband\SpecialChar ~
450 (-u) Tell Speex to treat the input as 
451 \begin_inset Quotes eld
452 \end_inset 
453
454 ultra-wideband
455 \begin_inset Quotes erd
456 \end_inset 
457
458  (32 kHz)
459 \layout Description
460
461 --quality\SpecialChar ~
462 n Set the encoding quality (0-10), default is 8
463 \layout Description
464
465 --bitrate\SpecialChar ~
466 n Encoding bit-rate (use bit-rate n or lower) 
467 \layout Description
468
469 --vbr Enable VBR (Variable Bit-Rate), disabled by default
470 \layout Description
471
472 --abr\SpecialChar ~
473 n Enable ABR (Average Bit-Rate) at n kbps, disabled by default
474 \layout Description
475
476 --vad Enable VAD (Voice Activity Detection), disabled by default
477 \layout Description
478
479 --dtx Enable DTX (Discontinuous Transmission), disabled by default
480 \layout Description
481
482 --nframes\SpecialChar ~
483 n Pack n frames in each Ogg packet (this saves space at low bit-rates)
484 \layout Description
485
486 --comp\SpecialChar ~
487 n Set encoding speed/quality tradeoff.
488  The higher the value of n, the slower the encoding (default is 3)
489 \layout Description
490
491 -V Verbose operation, print bit-rate currently in use
492 \layout Description
493
494 --help\SpecialChar ~
495 (-h) Print the help
496 \layout Description
497
498 --version\SpecialChar ~
499 (-v) Print version information
500 \layout Subsubsection*
501
502 Speex comments
503 \layout Description
504
505 --comment Add the given string as an extra comment.
506  This may be used multiple times.
507  
508 \layout Description
509
510 --author Author of this track.
511  
512 \layout Description
513
514 --title Title for this track.
515  
516 \layout Subsubsection*
517
518 Raw input options
519 \layout Description
520
521 --rate\SpecialChar ~
522 n Sampling rate for raw input
523 \layout Description
524
525 --stereo Consider raw input as stereo 
526 \layout Description
527
528 --le Raw input is little-endian 
529 \layout Description
530
531 --be Raw input is big-endian 
532 \layout Description
533
534 --8bit Raw input is 8-bit unsigned 
535 \layout Description
536
537 --16bit Raw input is 16-bit signed 
538 \layout Subsection
539
540
541 \emph on 
542 speexdec
543 \begin_inset LatexCommand \index{speexdec}
544
545 \end_inset 
546
547
548 \layout Standard
549
550 The 
551 \emph on 
552 speexdec
553 \emph default 
554  utility is used to decode Speex files and can be used by calling: 
555 \layout LyX-Code
556
557 speexdec [options] speex_file [output_file]
558 \layout Standard
559
560 The value '-' for input_file or output_file corresponds respectively to
561  stdin and stdout.
562  Also, when no output_file is specified, the file is played to the soundcard.
563  The valid options are:
564 \layout Description
565
566 --enh enable post-filter (default)
567 \layout Description
568
569 --no-enh disable post-filter
570 \layout Description
571
572 --force-nb Force decoding in narrowband 
573 \layout Description
574
575 --force-wb Force decoding in wideband 
576 \layout Description
577
578 --force-uwb Force decoding in ultra-wideband 
579 \layout Description
580
581 --mono Force decoding in mono 
582 \layout Description
583
584 --stereo Force decoding in stereo 
585 \layout Description
586
587 --rate\SpecialChar ~
588 n For decoding at n Hz sampling rate
589 \layout Description
590
591 --packet-loss\SpecialChar ~
592 n Simulate n % random packet loss
593 \layout Description
594
595 -V Verbose operation, print bit-rate currently in use
596 \layout Description
597
598 --help\SpecialChar ~
599 (-h) Print the help
600 \layout Description
601
602 --version\SpecialChar ~
603 (-v) Print version information
604 \layout Section
605 \pagebreak_top 
606 Programming with Speex (the libspeex
607 \begin_inset LatexCommand \index{libspeex}
608
609 \end_inset 
610
611  API
612 \begin_inset LatexCommand \index{API}
613
614 \end_inset 
615
616 )
617 \layout Standard
618
619 This section explains how to use the Speex API.
620  Examples of code can also be found in appendix 
621 \begin_inset LatexCommand \ref{sec:Sample-code}
622
623 \end_inset 
624
625 .
626 \layout Subsection
627
628 Encoding
629 \layout Standard
630
631 In order to encode speech using Speex, you first need to:
632 \layout LyX-Code
633
634 #include <speex.h>
635 \layout Standard
636
637 You then need to declare a Speex bit-packing struct
638 \layout LyX-Code
639
640 SpeexBits bits;
641 \layout Standard
642
643 and a Speex encoder state
644 \layout LyX-Code
645
646 void *enc_state;
647 \layout Standard
648
649 The two are initialized by:
650 \layout LyX-Code
651
652 speex_bits_init(&bits);
653 \layout LyX-Code
654
655 enc_state = speex_encoder_init(&speex_nb_mode);
656 \layout Standard
657
658 For wideband coding, 
659 \emph on 
660 speex_nb_mode
661 \emph default 
662  will be replaced by 
663 \emph on 
664 speex_wb_mode
665 \emph default 
666 .
667  In most cases, you will need to know the frame size used by the mode you
668  are using.
669  You can get that value in the 
670 \emph on 
671 frame_size
672 \emph default 
673  variable with:
674 \layout LyX-Code
675
676 speex_encoder_ctl(enc_state,SPEEX_GET_FRAME_SIZE,&frame_size);
677 \layout Standard
678
679 Once the initialization is done, for every input frame:
680 \layout LyX-Code
681
682 speex_bits_reset(&bits);
683 \layout LyX-Code
684
685 speex_encode(enc_state, input_frame, &bits);
686 \layout LyX-Code
687
688 nbBytes = speex_bits_write(&bits, byte_ptr, MAX_NB_BYTES);
689 \layout Standard
690
691 where 
692 \emph on 
693 input_frame
694 \emph default 
695  is a 
696 \emph on 
697 (float *)
698 \emph default 
699  pointing to the beginning of a speech frame, 
700 \emph on 
701 byte_ptr
702 \emph default 
703  is a 
704 \emph on 
705 (char *)
706 \emph default 
707  where the encoded frame will be written, 
708 \emph on 
709 MAX_NB_BYTES
710 \emph default 
711  is the maximum number of bytes that can be written to 
712 \emph on 
713 byte_ptr
714 \emph default 
715  without causing an overflow and 
716 \emph on 
717 nbBytes
718 \emph default 
719  is the number of bytes actually written to 
720 \emph on 
721 byte_ptr
722 \emph default 
723  (the encoded size in bytes).
724  Before calling speex_bits_write, it is possible to find the number of bytes
725  that need to be written by calling 
726 \family typewriter 
727 speex_bits_nbytes(&bits)
728 \family default 
729 , which returns a number of bytes.
730  
731 \layout Standard
732
733 After you're done with the encoding, free all resources with:
734 \layout LyX-Code
735
736 speex_bits_destroy(&bits);
737 \layout LyX-Code
738
739 speex_encoder_destroy(enc_state);
740 \layout Standard
741
742 That's about it for the encoder.
743  
744 \layout Subsection
745
746 Decoding
747 \layout Standard
748
749 In order to encode speech using Speex, you first need to:
750 \layout LyX-Code
751
752 #include <speex.h>
753 \layout Standard
754
755 You also need to declare a Speex bit-packing struct
756 \layout LyX-Code
757
758 SpeexBits bits;
759 \layout Standard
760
761 and a Speex encoder state
762 \layout LyX-Code
763
764 void *dec_state;
765 \layout Standard
766
767 The two are initialized by:
768 \layout LyX-Code
769
770 speex_bits_init(&bits);
771 \layout LyX-Code
772
773 dec_state = speex_decoder_init(&speex_nb_mode);
774 \layout Standard
775
776 For wideband decoding, 
777 \emph on 
778 speex_nb_mode
779 \emph default 
780  will be replaced by 
781 \emph on 
782 speex_wb_mode
783 \emph default 
784 .
785  If you need to obtain the size of the frames that will be used by the decoder,
786  you can get that value in the 
787 \emph on 
788 frame_size
789 \emph default 
790  variable with:
791 \layout LyX-Code
792
793 speex_decoder_ctl(dec_state, SPEEX_GET_FRAME_SIZE, &frame_size); 
794 \layout Standard
795
796 There is also a parameter that can be set for the decoder: whether or not
797  to use a perceptual post-filter.
798  This can be set by: 
799 \layout LyX-Code
800
801 speex_decoder_ctl(dec_state, SPEEX_SET_ENH, &enh); 
802 \layout Standard
803
804 where 
805 \emph on 
806 enh
807 \emph default 
808  is an int that with value 0 to have the post-filter disabled and 1 to have
809  it enabled.
810 \layout Standard
811
812 Again, once the decoder initialization is done, for every input frame:
813 \layout LyX-Code
814
815 speex_bits_read_from(&bits, input_bytes, nbBytes);
816 \layout LyX-Code
817
818 speex_decode(st, &bits, output_frame);
819 \layout Standard
820
821 where input_bytes is a 
822 \emph on 
823 (char *)
824 \emph default 
825  containing the bit-stream data received for a frame, 
826 \emph on 
827 nbBytes
828 \emph default 
829  is the size (in bytes) of that bit-stream, and 
830 \emph on 
831 output_frame
832 \emph default 
833  is a 
834 \emph on 
835 (float *)
836 \emph default 
837  and points to the area where the decoded speech frame will be written.
838  A NULL value as the first argument indicates that we don't have the bits
839  for the current frame.
840  When a frame is lost, the Speex decoder will do its best to "guess" the
841  correct signal.
842 \layout Standard
843
844 After you're done with the decoding, free all resources with:
845 \layout LyX-Code
846
847 speex_bits_destroy(&bits);
848 \layout LyX-Code
849
850 speex_decoder_destroy(dec_state);
851 \layout Subsection
852
853 Codec Options (speex_*_ctl)
854 \layout Standard
855
856 The Speex encoder and decoder support many options and requests that can
857  be accessed through the 
858 \emph on 
859 speex_encoder_ctl
860 \emph default 
861  and 
862 \emph on 
863 speex_decoder_ctl
864 \emph default 
865  functions.
866  These functions are similar to the 
867 \emph on 
868 ioctl
869 \emph default 
870  system call and their prototypes are:
871 \layout LyX-Code
872
873 void speex_encoder_ctl(void *encoder, int request, void *ptr);
874 \layout LyX-Code
875
876 void speex_decoder_ctl(void *encoder, int request, void *ptr);
877 \layout Standard
878
879 The different values of request allowed are (note that some only apply to
880  the encoder or the decoder):
881 \layout Description
882
883 SPEEX_SET_ENH** Set perceptual enhancer
884 \begin_inset LatexCommand \index{perceptual enhancement}
885
886 \end_inset 
887
888  to on (1) or off (0) (integer)
889 \layout Description
890
891 SPEEX_GET_ENH** Get perceptual enhancer status (integer)
892 \layout Description
893
894 SPEEX_GET_FRAME_SIZE Get the frame size used for the current mode (integer)
895 \layout Description
896
897 SPEEX_SET_QUALITY* Set the encoder speech quality (integer 0 to 10)
898 \layout Description
899
900 SPEEX_GET_QUALITY* Get the current encoder speech quality (integer 0 to
901  10)
902 \layout Description
903
904 SPEEX_SET_MODE*
905 \begin_inset Formula $\dagger$
906 \end_inset 
907
908
909 \layout Description
910
911 SPEEX_GET_MODE*
912 \begin_inset Formula $\dagger$
913 \end_inset 
914
915
916 \layout Description
917
918 SPEEX_SET_LOW_MODE*
919 \begin_inset Formula $\dagger$
920 \end_inset 
921
922
923 \layout Description
924
925 SPEEX_GET_LOW_MODE*
926 \begin_inset Formula $\dagger$
927 \end_inset 
928
929
930 \layout Description
931
932 SPEEX_SET_HIGH_MODE*
933 \begin_inset Formula $\dagger$
934 \end_inset 
935
936
937 \layout Description
938
939 SPEEX_GET_HIGH_MODE*
940 \begin_inset Formula $\dagger$
941 \end_inset 
942
943
944 \layout Description
945
946 SPEEX_SET_VBR* Set variable bit-rate (VBR) to on (1) or off (0) (integer)
947 \layout Description
948
949 SPEEX_GET_VBR* Get variable bit-rate
950 \begin_inset LatexCommand \index{variable bit-rate}
951
952 \end_inset 
953
954  (VBR) status (integer)
955 \layout Description
956
957 SPEEX_SET_VBR_QUALITY* Set the encoder VBR speech quality (float 0 to 10)
958 \layout Description
959
960 SPEEX_GET_VBR_QUALITY* Get the current encoder VBR speech quality (float
961  0 to 10)
962 \layout Description
963
964 SPEEX_SET_COMPLEXITY* Set the CPU resources allowed for the encoder (integer
965  1 to 10)
966 \layout Description
967
968 SPEEX_GET_COMPLEXITY* Get the CPU resources allowed for the encoder (integer
969  1 to 10)
970 \layout Description
971
972 SPEEX_SET_BITRATE* Set the bit-rate to use to the closest value not exceeding
973  the parameter (integer in bps)
974 \layout Description
975
976 SPEEX_GET_BITRATE Get the current bit-rate in use (integer in bps)
977 \layout Description
978
979 SPEEX_SET_SAMPLING_RATE Set real sampling rate (integer in Hz)
980 \layout Description
981
982 SPEEX_GET_SAMPLING_RATE Get real sampling rate (integer in Hz)
983 \layout Description
984
985 SPEEX_RESET_STATE Reset the encoder/decoder state to its original state
986  (zeros all memories)
987 \layout Description
988
989 SPEEX_SET_VAD* Set voice activity detection
990 \begin_inset LatexCommand \index{voice activity detection}
991
992 \end_inset 
993
994  (VAD) to on (1) or off (0) (integer)
995 \layout Description
996
997 SPEEX_GET_VAD* Get voice activity detection (VAD) status (integer)
998 \layout Description
999
1000 SPEEX_SET_DTX* Set discontinuous transmission
1001 \begin_inset LatexCommand \index{discontinuous transmission}
1002
1003 \end_inset 
1004
1005  (DTX) to on (1) or off (0) (integer)
1006 \layout Description
1007
1008 SPEEX_GET_DTX* Get discontinuous transmission (DTX) status (integer)
1009 \layout Description
1010
1011 SPEEX_SET_ABR* Set average bit-rate
1012 \begin_inset LatexCommand \index{average bit-rate}
1013
1014 \end_inset 
1015
1016  (ABR) to a value n in bits per second (integer in bps)
1017 \layout Description
1018
1019 SPEEX_GET_ABR* Get average bit-rate (ABR) setting (integer in bps)
1020 \layout Description
1021
1022 * applies only to the encoder
1023 \layout Description
1024
1025 ** applies only to the decoder
1026 \layout Description
1027
1028
1029 \begin_inset Formula $\dagger$
1030 \end_inset 
1031
1032  normally only used internally
1033 \layout Subsection
1034
1035 Mode queries
1036 \layout Standard
1037
1038 Speex modes have a querry system similar to the speex_encoder_ctl and speex_deco
1039 der_ctl calls.
1040  Since modes are read-only, it is only possible to get information about
1041  a particular mode.
1042  The function used to do that is:
1043 \layout LyX-Code
1044
1045 void speex_mode_query(SpeexMode *mode, int request, void *ptr);
1046 \layout Standard
1047
1048 The admissible values for request are (unless otherwise note, the values
1049  are returned through 
1050 \emph on 
1051 ptr
1052 \emph default 
1053 ):
1054 \layout Description
1055
1056 SPEEX_MODE_FRAME_SIZE Get the frame size (in samples) for the mode
1057 \layout Description
1058
1059 SPEEX_SUBMODE_BITRATE Get the bit-rate for a submode number specified throught
1060  
1061 \emph on 
1062 ptr
1063 \emph default 
1064  (integer in bps).
1065  
1066 \layout Subsection
1067
1068 Packing and in-band signalling
1069 \begin_inset LatexCommand \index{in-band signalling}
1070
1071 \end_inset 
1072
1073
1074 \layout Standard
1075
1076 Sometimes it is desirable to pack more than one frame per packet (or other
1077  basic unit of storage).
1078  The proper way to do it is to call speex_encode 
1079 \begin_inset Formula $N$
1080 \end_inset 
1081
1082  times before writing the stream with speex_bits_write.
1083  In cases where the number of frames is not determined by an out-of-band
1084  mechanism, it is possible to include a terminator code.
1085  That terminator consists of the code 15 (decimal) encoded with 5 bits,
1086  as shown in figure 
1087 \begin_inset LatexCommand \ref{cap:quality_vs_bps}
1088
1089 \end_inset 
1090
1091 .
1092  
1093 \layout Standard
1094
1095 It is also possible to send in-band 
1096 \begin_inset Quotes eld
1097 \end_inset 
1098
1099 messages
1100 \begin_inset Quotes erd
1101 \end_inset 
1102
1103  to the other side.
1104  All these messages are encoded as a 
1105 \begin_inset Quotes eld
1106 \end_inset 
1107
1108 pseudo-frame
1109 \begin_inset Quotes erd
1110 \end_inset 
1111
1112  of mode 14 which contain a 4-bit message type code, followed by the message.
1113  Table 
1114 \begin_inset LatexCommand \ref{cap:In-band-signalling-codes}
1115
1116 \end_inset 
1117
1118  lists the available codes, their meaning and the size of the message that
1119  follow.
1120  Most of these messages are requests that are sent to the encoder or decoder
1121  on the other end, which is free to comply or ignore them.
1122  By default, all in-band messages are ignored.
1123 \layout Standard
1124
1125
1126 \begin_inset Float table
1127 placement htbp
1128 wide false
1129 collapsed false
1130
1131 \layout Standard
1132
1133
1134 \begin_inset  Tabular
1135 <lyxtabular version="3" rows="17" columns="3">
1136 <features>
1137 <column alignment="center" valignment="top" leftline="true" width="0pt">
1138 <column alignment="center" valignment="top" leftline="true" width="0pt">
1139 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
1140 <row topline="true" bottomline="true">
1141 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1142 \begin_inset Text
1143
1144 \layout Standard
1145
1146 code
1147 \end_inset 
1148 </cell>
1149 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1150 \begin_inset Text
1151
1152 \layout Standard
1153
1154 Size (bits)
1155 \end_inset 
1156 </cell>
1157 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1158 \begin_inset Text
1159
1160 \layout Standard
1161
1162 Content
1163 \end_inset 
1164 </cell>
1165 </row>
1166 <row topline="true">
1167 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1168 \begin_inset Text
1169
1170 \layout Standard
1171
1172 0
1173 \end_inset 
1174 </cell>
1175 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1176 \begin_inset Text
1177
1178 \layout Standard
1179
1180 1
1181 \end_inset 
1182 </cell>
1183 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1184 \begin_inset Text
1185
1186 \layout Standard
1187
1188 Asks decoder to set perceptual enhancement off (0) or on(1)
1189 \end_inset 
1190 </cell>
1191 </row>
1192 <row topline="true">
1193 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1194 \begin_inset Text
1195
1196 \layout Standard
1197
1198 1
1199 \end_inset 
1200 </cell>
1201 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1202 \begin_inset Text
1203
1204 \layout Standard
1205
1206 1
1207 \end_inset 
1208 </cell>
1209 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1210 \begin_inset Text
1211
1212 \layout Standard
1213
1214 Asks (if 1) the encoder to be less 
1215 \begin_inset Quotes eld
1216 \end_inset 
1217
1218 agressive
1219 \begin_inset Quotes erd
1220 \end_inset 
1221
1222  due to high packet loss
1223 \end_inset 
1224 </cell>
1225 </row>
1226 <row topline="true">
1227 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1228 \begin_inset Text
1229
1230 \layout Standard
1231
1232 2
1233 \end_inset 
1234 </cell>
1235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1236 \begin_inset Text
1237
1238 \layout Standard
1239
1240 4
1241 \end_inset 
1242 </cell>
1243 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1244 \begin_inset Text
1245
1246 \layout Standard
1247
1248 Asks encoder to switch to mode N
1249 \end_inset 
1250 </cell>
1251 </row>
1252 <row topline="true">
1253 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1254 \begin_inset Text
1255
1256 \layout Standard
1257
1258 3
1259 \end_inset 
1260 </cell>
1261 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1262 \begin_inset Text
1263
1264 \layout Standard
1265
1266 4
1267 \end_inset 
1268 </cell>
1269 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1270 \begin_inset Text
1271
1272 \layout Standard
1273
1274 Asks encoder to switch to mode N for low-band
1275 \end_inset 
1276 </cell>
1277 </row>
1278 <row topline="true">
1279 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1280 \begin_inset Text
1281
1282 \layout Standard
1283
1284 4
1285 \end_inset 
1286 </cell>
1287 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1288 \begin_inset Text
1289
1290 \layout Standard
1291
1292 4
1293 \end_inset 
1294 </cell>
1295 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1296 \begin_inset Text
1297
1298 \layout Standard
1299
1300 Asks encoder to switch to mode N for high-band
1301 \end_inset 
1302 </cell>
1303 </row>
1304 <row topline="true">
1305 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1306 \begin_inset Text
1307
1308 \layout Standard
1309
1310 5
1311 \end_inset 
1312 </cell>
1313 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1314 \begin_inset Text
1315
1316 \layout Standard
1317
1318 4
1319 \end_inset 
1320 </cell>
1321 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1322 \begin_inset Text
1323
1324 \layout Standard
1325
1326 Asks encoder to switch to quality N for VBR
1327 \end_inset 
1328 </cell>
1329 </row>
1330 <row topline="true">
1331 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1332 \begin_inset Text
1333
1334 \layout Standard
1335
1336 6
1337 \end_inset 
1338 </cell>
1339 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1340 \begin_inset Text
1341
1342 \layout Standard
1343
1344 4
1345 \end_inset 
1346 </cell>
1347 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1348 \begin_inset Text
1349
1350 \layout Standard
1351
1352 Request acknowloedge (0=no, 1=all, 2=only for in-band data)
1353 \end_inset 
1354 </cell>
1355 </row>
1356 <row topline="true">
1357 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1358 \begin_inset Text
1359
1360 \layout Standard
1361
1362 7
1363 \end_inset 
1364 </cell>
1365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1366 \begin_inset Text
1367
1368 \layout Standard
1369
1370 4
1371 \end_inset 
1372 </cell>
1373 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1374 \begin_inset Text
1375
1376 \layout Standard
1377
1378 Asks encoder to set CBR (0), VAD(1), DTX(3), VBR(5), VBR+DTX(7)
1379 \end_inset 
1380 </cell>
1381 </row>
1382 <row topline="true">
1383 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1384 \begin_inset Text
1385
1386 \layout Standard
1387
1388 8
1389 \end_inset 
1390 </cell>
1391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1392 \begin_inset Text
1393
1394 \layout Standard
1395
1396 8
1397 \end_inset 
1398 </cell>
1399 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1400 \begin_inset Text
1401
1402 \layout Standard
1403
1404 Transmit (8-bit) character to the other end
1405 \end_inset 
1406 </cell>
1407 </row>
1408 <row topline="true">
1409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1410 \begin_inset Text
1411
1412 \layout Standard
1413
1414 9
1415 \end_inset 
1416 </cell>
1417 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1418 \begin_inset Text
1419
1420 \layout Standard
1421
1422 8
1423 \end_inset 
1424 </cell>
1425 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1426 \begin_inset Text
1427
1428 \layout Standard
1429
1430 Intensity stereo information
1431 \end_inset 
1432 </cell>
1433 </row>
1434 <row topline="true">
1435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1436 \begin_inset Text
1437
1438 \layout Standard
1439
1440 10
1441 \end_inset 
1442 </cell>
1443 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1444 \begin_inset Text
1445
1446 \layout Standard
1447
1448 16
1449 \end_inset 
1450 </cell>
1451 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1452 \begin_inset Text
1453
1454 \layout Standard
1455
1456 Announce maximum bit-rate acceptable (N in bytes/second)
1457 \end_inset 
1458 </cell>
1459 </row>
1460 <row topline="true">
1461 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1462 \begin_inset Text
1463
1464 \layout Standard
1465
1466 11
1467 \end_inset 
1468 </cell>
1469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1470 \begin_inset Text
1471
1472 \layout Standard
1473
1474 16
1475 \end_inset 
1476 </cell>
1477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1478 \begin_inset Text
1479
1480 \layout Standard
1481
1482 reserved
1483 \end_inset 
1484 </cell>
1485 </row>
1486 <row topline="true">
1487 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1488 \begin_inset Text
1489
1490 \layout Standard
1491
1492 12
1493 \end_inset 
1494 </cell>
1495 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1496 \begin_inset Text
1497
1498 \layout Standard
1499
1500 32
1501 \end_inset 
1502 </cell>
1503 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1504 \begin_inset Text
1505
1506 \layout Standard
1507
1508 Acknowledge receiving packet N
1509 \end_inset 
1510 </cell>
1511 </row>
1512 <row topline="true">
1513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1514 \begin_inset Text
1515
1516 \layout Standard
1517
1518 13
1519 \end_inset 
1520 </cell>
1521 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1522 \begin_inset Text
1523
1524 \layout Standard
1525
1526 32
1527 \end_inset 
1528 </cell>
1529 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1530 \begin_inset Text
1531
1532 \layout Standard
1533
1534 reserved
1535 \end_inset 
1536 </cell>
1537 </row>
1538 <row topline="true">
1539 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1540 \begin_inset Text
1541
1542 \layout Standard
1543
1544 14
1545 \end_inset 
1546 </cell>
1547 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1548 \begin_inset Text
1549
1550 \layout Standard
1551
1552 64
1553 \end_inset 
1554 </cell>
1555 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1556 \begin_inset Text
1557
1558 \layout Standard
1559
1560 reserved
1561 \end_inset 
1562 </cell>
1563 </row>
1564 <row topline="true" bottomline="true">
1565 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1566 \begin_inset Text
1567
1568 \layout Standard
1569
1570 15
1571 \end_inset 
1572 </cell>
1573 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1574 \begin_inset Text
1575
1576 \layout Standard
1577
1578 64
1579 \end_inset 
1580 </cell>
1581 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1582 \begin_inset Text
1583
1584 \layout Standard
1585
1586 reserved
1587 \end_inset 
1588 </cell>
1589 </row>
1590 </lyxtabular>
1591
1592 \end_inset 
1593
1594
1595 \layout Caption
1596
1597 In-band signalling codes
1598 \begin_inset LatexCommand \label{cap:In-band-signalling-codes}
1599
1600 \end_inset 
1601
1602
1603 \end_inset 
1604
1605
1606 \layout Standard
1607
1608 Finally, applications may define custom in-band messages using mode 13.
1609  The size of the message in bytes is encoded with 5 bits, so that the decoder
1610  can skip it if it doesn't know how to interpret it.
1611 \layout Section
1612 \pagebreak_top 
1613 Formats and standards
1614 \begin_inset LatexCommand \index{standards}
1615
1616 \end_inset 
1617
1618
1619 \layout Standard
1620
1621 Speex can encode speech in both narrowband and wideband and provides different
1622  bit-rates.
1623  However not all features must be supported by a certain implementation
1624  or device.
1625  In order to be said 
1626 \begin_inset Quotes eld
1627 \end_inset 
1628
1629 Speex compatible
1630 \begin_inset Quotes erd
1631 \end_inset 
1632
1633  (whatever that means), an implementation must implement at least a basic
1634  set of features.
1635 \layout Standard
1636
1637 At the minimum, all narrowband modes of operation MUST be supported at the
1638  decoder.
1639  This includes the decoding of a wideband bit-stream by the narrowband decoder
1640 \begin_inset Foot
1641 collapsed true
1642
1643 \layout Standard
1644
1645 The wideband bit-stream contains an embedded narrowband bit-stream which
1646  can be decoded alone
1647 \end_inset 
1648
1649 .
1650  If present, a wideband decoder MUST be able to decode a narrowband stream,
1651  and MAY either be able to decode all wideband modes or be able to decode
1652  the embedded narrowband part of all modes (which includes ignoring the
1653  high-band bits).
1654 \layout Standard
1655
1656 For encoders, at least one narrowband or wideband mode MUST be supported.
1657  The main reason why all encoding modes do not have to be supported is that
1658  some platforms may not be able to handle the complexity of encoding in
1659  some modes.
1660 \layout Subsection
1661
1662 RTP
1663 \begin_inset LatexCommand \index{RTP}
1664
1665 \end_inset 
1666
1667  Payload Format 
1668 \layout Standard
1669
1670 The RTP payload draft is included in appendix 
1671 \begin_inset LatexCommand \ref{sec:IETF-draft}
1672
1673 \end_inset 
1674
1675  and the latest version is available at 
1676 \begin_inset LatexCommand \url{http://www.speex.org/drafts/latest}
1677
1678 \end_inset 
1679
1680 .
1681  This draft has been sent (2003/02/26) to the Internet Engineering Task
1682  Force (IETF) and will be discussed at the March 18th meeting in San Francisco.
1683  
1684 \layout Subsection
1685
1686 MIME Type
1687 \layout Standard
1688
1689 Speex will use the MIME type 
1690 \family typewriter 
1691 audio/speex
1692 \family default 
1693 .
1694  We will apply for that type in the near future.
1695 \layout Subsection
1696
1697 Ogg
1698 \begin_inset LatexCommand \index{Ogg}
1699
1700 \end_inset 
1701
1702  file format
1703 \layout Standard
1704
1705 Speex bit-streams can be stored in Ogg files.
1706  In this case, the first packet of the Ogg file contains the Speex header
1707  described in table 
1708 \begin_inset LatexCommand \ref{cap:ogg_speex_header}
1709
1710 \end_inset 
1711
1712 .
1713  All integer fields in the headers are stored as little-endian.
1714  The 
1715 \family typewriter 
1716 speex_string
1717 \family default 
1718  field must contain the 
1719 \begin_inset Quotes eld
1720 \end_inset 
1721
1722
1723 \family typewriter 
1724 Speex
1725 \family default 
1726 \SpecialChar ~
1727 \SpecialChar ~
1728 \SpecialChar ~
1729
1730 \begin_inset Quotes eld
1731 \end_inset 
1732
1733  (with 3 training spaces), which identifies the bit-stream.
1734  The next field, 
1735 \family typewriter 
1736 speex_version
1737 \family default 
1738  contains the version of Speex that encoded the file.
1739  For now, refer to speex_header.[ch] for more info.
1740  The 
1741 \emph on 
1742 beginning of stream
1743 \emph default 
1744  (
1745 \family typewriter 
1746 b_o_s
1747 \family default 
1748 ) flag is set to 1 for the header.
1749  The header packet has 
1750 \family typewriter 
1751 packetno=0
1752 \family default 
1753  and 
1754 \family typewriter 
1755 granulepos=0
1756 \family default 
1757 .
1758 \layout Standard
1759
1760 The second packet contains the Speex comment header.
1761  The format used is the Vorbis comment format described here: http://www.xiph.org/
1762 ogg/vorbis/doc/v-comment.html .
1763  This packet has 
1764 \family typewriter 
1765 packetno=1
1766 \family default 
1767  and 
1768 \family typewriter 
1769 granulepos=0
1770 \family default 
1771 .
1772 \layout Standard
1773
1774 The third and subsequant packets each contain one or more (number found
1775  in header) Speex frames.
1776  These are identified with 
1777 \family typewriter 
1778 packetno
1779 \family default 
1780  starting from 2 and the 
1781 \family typewriter 
1782 granulepos
1783 \family default 
1784  is the number of the last sample encoded in that packet.
1785  Le last of these packets has the 
1786 \emph on 
1787 end of stream
1788 \emph default 
1789  (
1790 \family typewriter 
1791 e_o_s
1792 \family default 
1793 ) flag is set to 1.
1794 \layout Standard
1795
1796
1797 \begin_inset Float table
1798 placement htbp
1799 wide true
1800 collapsed false
1801
1802 \layout Standard
1803
1804
1805 \begin_inset  Tabular
1806 <lyxtabular version="3" rows="16" columns="3">
1807 <features>
1808 <column alignment="center" valignment="top" leftline="true" width="0pt">
1809 <column alignment="center" valignment="top" leftline="true" width="0pt">
1810 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
1811 <row topline="true" bottomline="true">
1812 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1813 \begin_inset Text
1814
1815 \layout Standard
1816
1817 Field
1818 \end_inset 
1819 </cell>
1820 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1821 \begin_inset Text
1822
1823 \layout Standard
1824
1825 Type
1826 \end_inset 
1827 </cell>
1828 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1829 \begin_inset Text
1830
1831 \layout Standard
1832
1833 Size
1834 \end_inset 
1835 </cell>
1836 </row>
1837 <row topline="true">
1838 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1839 \begin_inset Text
1840
1841 \layout Standard
1842
1843 speex_string
1844 \end_inset 
1845 </cell>
1846 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1847 \begin_inset Text
1848
1849 \layout Standard
1850
1851 char[]
1852 \end_inset 
1853 </cell>
1854 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1855 \begin_inset Text
1856
1857 \layout Standard
1858
1859 8
1860 \end_inset 
1861 </cell>
1862 </row>
1863 <row topline="true">
1864 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1865 \begin_inset Text
1866
1867 \layout Standard
1868
1869 speex_version
1870 \end_inset 
1871 </cell>
1872 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1873 \begin_inset Text
1874
1875 \layout Standard
1876
1877 char[]
1878 \end_inset 
1879 </cell>
1880 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1881 \begin_inset Text
1882
1883 \layout Standard
1884
1885 20
1886 \end_inset 
1887 </cell>
1888 </row>
1889 <row topline="true">
1890 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1891 \begin_inset Text
1892
1893 \layout Standard
1894
1895 speex_version_id
1896 \end_inset 
1897 </cell>
1898 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1899 \begin_inset Text
1900
1901 \layout Standard
1902
1903 int
1904 \end_inset 
1905 </cell>
1906 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1907 \begin_inset Text
1908
1909 \layout Standard
1910
1911 4
1912 \end_inset 
1913 </cell>
1914 </row>
1915 <row topline="true">
1916 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1917 \begin_inset Text
1918
1919 \layout Standard
1920
1921 header_size
1922 \end_inset 
1923 </cell>
1924 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1925 \begin_inset Text
1926
1927 \layout Standard
1928
1929 int
1930 \end_inset 
1931 </cell>
1932 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1933 \begin_inset Text
1934
1935 \layout Standard
1936
1937 4
1938 \end_inset 
1939 </cell>
1940 </row>
1941 <row topline="true">
1942 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1943 \begin_inset Text
1944
1945 \layout Standard
1946
1947 rate
1948 \end_inset 
1949 </cell>
1950 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1951 \begin_inset Text
1952
1953 \layout Standard
1954
1955 int
1956 \end_inset 
1957 </cell>
1958 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1959 \begin_inset Text
1960
1961 \layout Standard
1962
1963 4
1964 \end_inset 
1965 </cell>
1966 </row>
1967 <row topline="true">
1968 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1969 \begin_inset Text
1970
1971 \layout Standard
1972
1973 mode
1974 \end_inset 
1975 </cell>
1976 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1977 \begin_inset Text
1978
1979 \layout Standard
1980
1981 int
1982 \end_inset 
1983 </cell>
1984 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1985 \begin_inset Text
1986
1987 \layout Standard
1988
1989 4
1990 \end_inset 
1991 </cell>
1992 </row>
1993 <row topline="true">
1994 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1995 \begin_inset Text
1996
1997 \layout Standard
1998
1999 mode_bitstream_version
2000 \end_inset 
2001 </cell>
2002 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2003 \begin_inset Text
2004
2005 \layout Standard
2006
2007 int
2008 \end_inset 
2009 </cell>
2010 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2011 \begin_inset Text
2012
2013 \layout Standard
2014
2015 4
2016 \end_inset 
2017 </cell>
2018 </row>
2019 <row topline="true">
2020 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2021 \begin_inset Text
2022
2023 \layout Standard
2024
2025 nb_channels
2026 \end_inset 
2027 </cell>
2028 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2029 \begin_inset Text
2030
2031 \layout Standard
2032
2033 int
2034 \end_inset 
2035 </cell>
2036 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2037 \begin_inset Text
2038
2039 \layout Standard
2040
2041 4
2042 \end_inset 
2043 </cell>
2044 </row>
2045 <row topline="true">
2046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2047 \begin_inset Text
2048
2049 \layout Standard
2050
2051 bitrate
2052 \end_inset 
2053 </cell>
2054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2055 \begin_inset Text
2056
2057 \layout Standard
2058
2059 int
2060 \end_inset 
2061 </cell>
2062 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2063 \begin_inset Text
2064
2065 \layout Standard
2066
2067 4
2068 \end_inset 
2069 </cell>
2070 </row>
2071 <row topline="true">
2072 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2073 \begin_inset Text
2074
2075 \layout Standard
2076
2077 frame_size
2078 \end_inset 
2079 </cell>
2080 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2081 \begin_inset Text
2082
2083 \layout Standard
2084
2085 int
2086 \end_inset 
2087 </cell>
2088 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2089 \begin_inset Text
2090
2091 \layout Standard
2092
2093 4
2094 \end_inset 
2095 </cell>
2096 </row>
2097 <row topline="true">
2098 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2099 \begin_inset Text
2100
2101 \layout Standard
2102
2103 vbr
2104 \end_inset 
2105 </cell>
2106 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2107 \begin_inset Text
2108
2109 \layout Standard
2110
2111 int
2112 \end_inset 
2113 </cell>
2114 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2115 \begin_inset Text
2116
2117 \layout Standard
2118
2119 4
2120 \end_inset 
2121 </cell>
2122 </row>
2123 <row topline="true">
2124 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2125 \begin_inset Text
2126
2127 \layout Standard
2128
2129 frames_per_packet
2130 \end_inset 
2131 </cell>
2132 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2133 \begin_inset Text
2134
2135 \layout Standard
2136
2137 int
2138 \end_inset 
2139 </cell>
2140 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2141 \begin_inset Text
2142
2143 \layout Standard
2144
2145 4
2146 \end_inset 
2147 </cell>
2148 </row>
2149 <row topline="true">
2150 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2151 \begin_inset Text
2152
2153 \layout Standard
2154
2155 extra_headers
2156 \end_inset 
2157 </cell>
2158 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2159 \begin_inset Text
2160
2161 \layout Standard
2162
2163 int
2164 \end_inset 
2165 </cell>
2166 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2167 \begin_inset Text
2168
2169 \layout Standard
2170
2171 4
2172 \end_inset 
2173 </cell>
2174 </row>
2175 <row topline="true">
2176 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2177 \begin_inset Text
2178
2179 \layout Standard
2180
2181 reserved1
2182 \end_inset 
2183 </cell>
2184 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2185 \begin_inset Text
2186
2187 \layout Standard
2188
2189 int
2190 \end_inset 
2191 </cell>
2192 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2193 \begin_inset Text
2194
2195 \layout Standard
2196
2197 4
2198 \end_inset 
2199 </cell>
2200 </row>
2201 <row topline="true" bottomline="true">
2202 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2203 \begin_inset Text
2204
2205 \layout Standard
2206
2207 reserved2
2208 \end_inset 
2209 </cell>
2210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2211 \begin_inset Text
2212
2213 \layout Standard
2214
2215 int
2216 \end_inset 
2217 </cell>
2218 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2219 \begin_inset Text
2220
2221 \layout Standard
2222
2223 4
2224 \end_inset 
2225 </cell>
2226 </row>
2227 </lyxtabular>
2228
2229 \end_inset 
2230
2231
2232 \layout Caption
2233
2234 Ogg/Speex header packet
2235 \begin_inset LatexCommand \label{cap:ogg_speex_header}
2236
2237 \end_inset 
2238
2239
2240 \end_inset 
2241
2242
2243 \layout Section
2244 \pagebreak_top 
2245 Introduction to CELP Coding
2246 \begin_inset LatexCommand \index{CELP}
2247
2248 \end_inset 
2249
2250
2251 \layout Standard
2252
2253 The three following sections describe the internals of the codec and require
2254  some signal processing knowledge.
2255  If you are only interested in using Speex, they are not required.
2256 \layout Standard
2257
2258 Speex is based on CELP, which stands for Code Excited Linear Prediction.
2259  This section attempts to introduce the principles behind CELP, so if you
2260  are already familiar with CELP, you can safely skip to section 
2261 \begin_inset LatexCommand \ref{sec:Speex-narrowband-mode}
2262
2263 \end_inset 
2264
2265 .
2266  The CELP technique is based on three ideas:
2267 \layout Enumerate
2268
2269 The use of a linear prediction (LP) model to model the vocal tract
2270 \layout Enumerate
2271
2272 The use of (adaptive and fixed) codebook entries as input (excitation) of
2273  the LP model
2274 \layout Enumerate
2275
2276 The search performed in closed-loop in a 
2277 \begin_inset Quotes eld
2278 \end_inset 
2279
2280 perceptually weighted domain
2281 \begin_inset Quotes erd
2282 \end_inset 
2283
2284
2285 \layout Standard
2286
2287 This section describes the basic ideas behind CELP.
2288  Note that it's still incomplete.
2289 \layout Subsection
2290
2291 Linear Prediction (LPC)
2292 \begin_inset LatexCommand \index{linear prediction}
2293
2294 \end_inset 
2295
2296
2297 \layout Standard
2298
2299 Linear prediction is at the base of may speech coding techniques, including
2300  CELP.
2301  The idea behind it is to predict the signal 
2302 \begin_inset Formula $x[n]$
2303 \end_inset 
2304
2305  using a linear combination of its past samples:
2306 \layout Standard
2307
2308
2309 \begin_inset Formula \[
2310 y[n]=\sum_{i=1}^{N}a_{i}x[n-i]\]
2311
2312 \end_inset 
2313
2314 where 
2315 \begin_inset Formula $y[n]$
2316 \end_inset 
2317
2318  is the linear prediction of 
2319 \begin_inset Formula $x[n]$
2320 \end_inset 
2321
2322 .
2323  The prediction error is thus given by:
2324 \begin_inset Formula \[
2325 e[n]=x[n]-y[n]=x[n]-\sum_{i=1}^{N}a_{i}x[n-i]\]
2326
2327 \end_inset 
2328
2329
2330 \layout Standard
2331
2332 The goal of the LPC analysis is to find the best prediction coefficients
2333  
2334 \begin_inset Formula $a_{i}$
2335 \end_inset 
2336
2337  which minimize the quadratic error function:
2338 \begin_inset Formula \[
2339 E=\sum_{n=0}^{L-1}\left[e[n]\right]^{2}=\sum_{n=0}^{L-1}\left[x[n]-\sum_{i=1}^{N}a_{i}x[n-i]\right]^{2}\]
2340
2341 \end_inset 
2342
2343 That can be done by making all derivatives 
2344 \begin_inset Formula $\frac{\partial E}{\partial a_{i}}$
2345 \end_inset 
2346
2347  equal to zero:
2348 \begin_inset Formula \[
2349 \frac{\partial E}{\partial a_{i}}=\frac{\partial}{\partial a_{i}}\sum_{n=0}^{L-1}\left[x[n]-\sum_{i=1}^{N}a_{i}x[n-i]\right]^{2}=0\]
2350
2351 \end_inset 
2352
2353
2354 \layout Standard
2355
2356 The 
2357 \begin_inset Formula $a_{i}$
2358 \end_inset 
2359
2360  filter coefficients are computed using the Levinson-Durbin
2361 \begin_inset LatexCommand \index{Levinson-Durbin}
2362
2363 \end_inset 
2364
2365  algorithm, which starts from the auto-correlation
2366 \begin_inset LatexCommand \index{auto-correlation}
2367
2368 \end_inset 
2369
2370  
2371 \begin_inset Formula $R(m)$
2372 \end_inset 
2373
2374  of the signal 
2375 \begin_inset Formula $x[n]$
2376 \end_inset 
2377
2378 .
2379 \layout Standard
2380
2381
2382 \begin_inset Formula \[
2383 R(m)=\sum_{i=0}^{N-1}x[i]x[i-m]\]
2384
2385 \end_inset 
2386
2387
2388 \layout Standard
2389
2390 For an order 
2391 \begin_inset Formula $N$
2392 \end_inset 
2393
2394  filter, we have:
2395 \begin_inset Formula \[
2396 \mathbf{R}=\left[\begin{array}{cccc}
2397 R(0) & R(1) & \cdots & R(N-1)\\
2398 R(1) & R(0) & \cdots & R(N-2)\\
2399 \vdots & \vdots & \ddots & \vdots\\
2400 R(N-1) & R(N-2) & \cdots & R(0)\end{array}\right]\]
2401
2402 \end_inset 
2403
2404
2405 \begin_inset Formula \[
2406 \mathbf{r}=\left[\begin{array}{c}
2407 R(1)\\
2408 R(2)\\
2409 \vdots\\
2410 R(N)\end{array}\right]\]
2411
2412 \end_inset 
2413
2414
2415 \layout Standard
2416
2417 The filter coefficients 
2418 \begin_inset Formula $a_{i}$
2419 \end_inset 
2420
2421  are found by solving the system 
2422 \begin_inset Formula $\mathbf{Ra}=\mathbf{r}$
2423 \end_inset 
2424
2425 .
2426  What the Levinson-Durbin algorithm does here is making the solution to
2427  the problem 
2428 \begin_inset Formula $\mathcal{O}\left(N^{2}\right)$
2429 \end_inset 
2430
2431  instead of 
2432 \begin_inset Formula $\mathcal{O}\left(N^{3}\right)$
2433 \end_inset 
2434
2435  by exploiting the fact that matrix 
2436 \begin_inset Formula $\mathbf{R}$
2437 \end_inset 
2438
2439  is toeplitz hermitian.
2440  Also, it can be proven that all the roots of 
2441 \begin_inset Formula $A(z)$
2442 \end_inset 
2443
2444  are within the unit circle, which means that 
2445 \begin_inset Formula $1/A(z)$
2446 \end_inset 
2447
2448  is always stable.
2449  This is in theory; in practice because of finite precision, there are two
2450  commonly used techniques to make sure we have a stable filter.
2451  First, we multiply 
2452 \begin_inset Formula $R(0)$
2453 \end_inset 
2454
2455  by a number slightly above one (such as 1.0001), which is equivalent to
2456  adding noise to the signal.
2457  Also, we can apply a window to the auto-correlation, which is equivalent
2458  to filtering in the frequency domain, reducing sharp resonances.
2459 \layout Standard
2460
2461 The linear prediction model represents each speech sample as linear combination
2462  of past samples, plus an error signal called the excitation (or residual).
2463 \begin_inset Formula \[
2464 x[n]=\sum_{i=1}^{N}a_{i}x[n-i]+e[n]\]
2465
2466 \end_inset 
2467
2468
2469 \layout Standard
2470
2471 In the 
2472 \emph on 
2473 z
2474 \emph default 
2475 -domain, this can be expressed as
2476 \layout Standard
2477
2478
2479 \begin_inset Formula \[
2480 x(z)=\frac{1}{A(z)}\: e(z)\]
2481
2482 \end_inset 
2483
2484
2485 \layout Standard
2486
2487 where 
2488 \begin_inset Formula $A(z)$
2489 \end_inset 
2490
2491  is defined as
2492 \layout Standard
2493
2494
2495 \begin_inset Formula \[
2496 A(z)=1-\sum_{i=1}^{N}a_{i}z^{-i}\]
2497
2498 \end_inset 
2499
2500
2501 \layout Standard
2502
2503 We usually refer to 
2504 \begin_inset Formula $A(z)$
2505 \end_inset 
2506
2507  as the analysis filter and 
2508 \begin_inset Formula $1/A(z)$
2509 \end_inset 
2510
2511  as the synthesis filter.
2512  The whole process is called short-term prediction as it predicts the signal
2513  
2514 \begin_inset Formula $x[n]$
2515 \end_inset 
2516
2517  using a prediction using only the 
2518 \begin_inset Formula $N$
2519 \end_inset 
2520
2521  past samples, where 
2522 \begin_inset Formula $N$
2523 \end_inset 
2524
2525  is usually around 10.
2526 \layout Standard
2527
2528 Because LPC coefficients have very little robustness to quantization, they
2529  are converted to Line Spectral Pair
2530 \begin_inset LatexCommand \index{line spectral pair}
2531
2532 \end_inset 
2533
2534  (LSP) coefficients which have a much better behaviour with quantization,
2535  one of them being that it's easy to keep the filter stable.
2536  
2537 \layout Comment
2538
2539 Describe LSP's
2540 \layout Subsection
2541
2542 Pitch Prediction
2543 \begin_inset LatexCommand \index{pitch}
2544
2545 \end_inset 
2546
2547
2548 \layout Standard
2549
2550 During voiced segments, the speech signal is periodic, so it is possible
2551  to take advantage of that property by approximating the excitation signal
2552  
2553 \begin_inset Formula $e[n]$
2554 \end_inset 
2555
2556  by a gain times the past of the excitation:
2557 \layout Standard
2558
2559
2560 \begin_inset Formula \[
2561 e[n]\simeq p[n]=\beta e[n-T]\]
2562
2563 \end_inset 
2564
2565
2566 \layout Standard
2567
2568 where 
2569 \begin_inset Formula $T$
2570 \end_inset 
2571
2572  is the pitch period, 
2573 \begin_inset Formula $\beta$
2574 \end_inset 
2575
2576  is the pitch gain.
2577  We call that long-term prediction since the excitation is predicted from
2578  
2579 \begin_inset Formula $e[n-T]$
2580 \end_inset 
2581
2582  with 
2583 \begin_inset Formula $T\gg N$
2584 \end_inset 
2585
2586 .
2587 \layout Subsection
2588
2589 Innovation Codebook
2590 \layout Standard
2591
2592 The final excitation 
2593 \begin_inset Formula $e[n]$
2594 \end_inset 
2595
2596  will be the sum of the pitch prediction and an 
2597 \emph on 
2598 innovation
2599 \emph default 
2600  signal 
2601 \begin_inset Formula $c[n]$
2602 \end_inset 
2603
2604  taken from a fixed codebook, hence the name 
2605 \emph on 
2606 Code
2607 \emph default 
2608  Excited Linear Prediction.
2609  The final excitation is given by:
2610 \layout Standard
2611
2612
2613 \begin_inset Formula \[
2614 e[n]=p[n]+c[n]=\beta e[n-T]+c[n]\]
2615
2616 \end_inset 
2617
2618 The quantization of 
2619 \begin_inset Formula $c[n]$
2620 \end_inset 
2621
2622  is where most of the bits in a CELP codec are allocated.
2623  It represents the information that couldn't be obtained either from linear
2624  prediction or pitch prediction.
2625  In the 
2626 \emph on 
2627 z
2628 \emph default 
2629 -domain we can represent the final signal 
2630 \begin_inset Formula $X(z)$
2631 \end_inset 
2632
2633  as 
2634 \begin_inset Formula \[
2635 X(z)=\frac{C(z)}{A(z)\left(1-\beta z^{-T}\right)}\]
2636
2637 \end_inset 
2638
2639
2640 \layout Subsection
2641
2642 Analysis-by-Synthesis and Error Weighting
2643 \begin_inset LatexCommand \index{error weighting}
2644
2645 \end_inset 
2646
2647
2648 \begin_inset LatexCommand \index{analysis-by-synthesis}
2649
2650 \end_inset 
2651
2652
2653 \layout Standard
2654
2655 Most (if not all) modern audio codecs attempt to 
2656 \begin_inset Quotes eld
2657 \end_inset 
2658
2659 shape
2660 \begin_inset Quotes erd
2661 \end_inset 
2662
2663  the noise so that it appears mostly in the frequency regions where the
2664  ear cannot detect it.
2665  For example, the ear is more tolerant to noise in parts of the spectrum
2666  that are louder and 
2667 \emph on 
2668 vice versa
2669 \emph default 
2670 .
2671  That's why instead of minimizing the simple quadratic error
2672 \begin_inset Formula \[
2673 E=\sum_{n}\left(x[n]-\overline{x}[n]\right)^{2}\]
2674
2675 \end_inset 
2676
2677 where 
2678 \begin_inset Formula $\overline{x}[n]$
2679 \end_inset 
2680
2681  is the encoder signal, we minimize the error for the perceptually weighted
2682  signal
2683 \begin_inset Formula \[
2684 X_{w}(z)=W(z)X(z)\]
2685
2686 \end_inset 
2687
2688 where 
2689 \begin_inset Formula $W(z)$
2690 \end_inset 
2691
2692  is the weighting filter, usually of the form
2693 \layout Standard
2694
2695
2696 \begin_inset Formula \begin{equation}
2697 W(z)=\frac{A\left(\frac{z}{\gamma_{1}}\right)}{A\left(\frac{z}{\gamma_{2}}\right)}\label{eq:weighting_filter}\end{equation}
2698
2699 \end_inset 
2700
2701
2702 \layout Standard
2703
2704 with control parameters 
2705 \begin_inset Formula $\gamma_{1}>\gamma_{2}$
2706 \end_inset 
2707
2708 .
2709  If the noise is white in the perceptually weighted domain, then in the
2710  signal domain its spectral shape will be of the form
2711 \begin_inset Formula \[
2712 A_{noise}(z)=\frac{1}{W(z)}=\frac{A\left(\frac{z}{\gamma_{2}}\right)}{A\left(\frac{z}{\gamma_{1}}\right)}\]
2713
2714 \end_inset 
2715
2716
2717 \layout Standard
2718
2719 If a filter 
2720 \begin_inset Formula $A(z)$
2721 \end_inset 
2722
2723  has (complex) poles at 
2724 \begin_inset Formula $p_{i}$
2725 \end_inset 
2726
2727  in the 
2728 \begin_inset Formula $z$
2729 \end_inset 
2730
2731 -plane, the filter 
2732 \begin_inset Formula $A(z/\gamma)$
2733 \end_inset 
2734
2735  filter will have its poles at 
2736 \begin_inset Formula $p_{i}^{'}=\gamma p_{i}$
2737 \end_inset 
2738
2739 , making it a flatter version of 
2740 \begin_inset Formula $A(z)$
2741 \end_inset 
2742
2743 .
2744 \layout Standard
2745
2746 Analysis-by-synthesis refers to the fact that when trying to find the best
2747  pitch parameters (
2748 \begin_inset Formula $T$
2749 \end_inset 
2750
2751
2752 \begin_inset Formula $\beta$
2753 \end_inset 
2754
2755 ) and innovation signal 
2756 \begin_inset Formula $c[n]$
2757 \end_inset 
2758
2759 , we do not work by making the excitation 
2760 \begin_inset Formula $e[n]$
2761 \end_inset 
2762
2763  as close as the original one (which would be simpler), but apply the synthesis
2764  (and weighting) filter and try making 
2765 \begin_inset Formula $X_{w}(z)$
2766 \end_inset 
2767
2768  as close to the original as possible.
2769 \layout Section
2770 \pagebreak_top 
2771 Speex narrowband mode
2772 \begin_inset LatexCommand \label{sec:Speex-narrowband-mode}
2773
2774 \end_inset 
2775
2776
2777 \begin_inset LatexCommand \index{narrowband}
2778
2779 \end_inset 
2780
2781
2782 \layout Standard
2783
2784 This section looks at how Speex works for narrowband (
2785 \begin_inset Formula $8\:\mathrm{kHz}$
2786 \end_inset 
2787
2788  sampling rate) operation.
2789  The frame size for this mode is 
2790 \begin_inset Formula $20\:\mathrm{ms}$
2791 \end_inset 
2792
2793 , corresponding to 160 samples.
2794  Each frame is also subdivided into 4 sub-frames of 40 samples each.
2795 \layout Standard
2796
2797 Also many design decisions were based on the original goals and assumptions:
2798 \layout Itemize
2799
2800 Minimizing the amount of information extracted from past frames (for robustness
2801  to packet loss)
2802 \layout Itemize
2803
2804 Dynamically-selectable codebooks (LSP, pitch and innovation)
2805 \layout Itemize
2806
2807 sub-vector fixed (innovation) codebooks
2808 \layout Subsection
2809
2810 LPC Analysis
2811 \begin_inset LatexCommand \index{linear prediction}
2812
2813 \end_inset 
2814
2815
2816 \layout Standard
2817
2818 An LPC analysis is first performed on a (asymetric Hamming) window that
2819  spans all the current frame and half a frame in advance.
2820  The LPC coefficients are then converted to Line Spectral Pair
2821 \begin_inset LatexCommand \index{line spectral pair}
2822
2823 \end_inset 
2824
2825  (LSP), a representation that is more robust to quantization.
2826  The LSP's are considered to be associated to the 
2827 \begin_inset Formula $4^{th}$
2828 \end_inset 
2829
2830  sub-frames and the LSP's associated to the first 3 sub-frames are linearly
2831  interpolated using the current and previous LSP's.
2832 \layout Standard
2833
2834 The LSP's are encoded using 30 bits for higher quality modes and 18 bits
2835  for lower quality, through the use of a multi-stage split-vector quantizer.
2836  For the lower quality modes, the 10 coefficients are first quantized with
2837  6 bits and the error is then divided in two 5-coefficient sub-vectors.
2838  Each of them is quantized with 6 bits, for a total of 18 bits.
2839  For the higher quality modes, the remaining error on both sub-vectors is
2840  further quantized with 6 bits each, for a total of 30 bits.
2841 \layout Standard
2842
2843 The perceptual weighting filter 
2844 \begin_inset Formula $W(z)$
2845 \end_inset 
2846
2847  used by Speex is derived from the LPC filter 
2848 \begin_inset Formula $A(z)$
2849 \end_inset 
2850
2851  and corresponds to the one described by eq.
2852  
2853 \begin_inset LatexCommand \ref{eq:weighting_filter}
2854
2855 \end_inset 
2856
2857  with 
2858 \begin_inset Formula $\gamma_{1}=0.9$
2859 \end_inset 
2860
2861  and 
2862 \begin_inset Formula $\gamma_{2}=0.6$
2863 \end_inset 
2864
2865 .
2866  We can use the unquantized 
2867 \begin_inset Formula $A(z)$
2868 \end_inset 
2869
2870  filter since the weighting filter is only used in the encoder.
2871 \layout Subsection
2872
2873 Pitch Prediction (adaptive codebook)
2874 \begin_inset LatexCommand \index{pitch}
2875
2876 \end_inset 
2877
2878
2879 \layout Standard
2880
2881 Speex uses a 3-tap prediction for pitch.
2882  That is, the pitch prediction signal 
2883 \begin_inset Formula $p[n]$
2884 \end_inset 
2885
2886  is obtained by the past of the excitation by:
2887 \begin_inset Formula \[
2888 p[n]=\beta_{0}e[n-T-1]+\beta_{1}e[n-T]+\beta_{2}e[n-T+1]\]
2889
2890 \end_inset 
2891
2892
2893 \layout Standard
2894
2895 where 
2896 \begin_inset Formula $T$
2897 \end_inset 
2898
2899  is the pitch period and the 
2900 \begin_inset Formula $\beta_{i}$
2901 \end_inset 
2902
2903  are the prediction (filter) taps.
2904  It is worth noting that when the pitch is smaller than the sub-frame size,
2905  we repeat the excitation at a period 
2906 \begin_inset Formula $T$
2907 \end_inset 
2908
2909 .
2910  For example, when 
2911 \begin_inset Formula $n-T+1$
2912 \end_inset 
2913
2914 , we use 
2915 \begin_inset Formula $n-2T+1$
2916 \end_inset 
2917
2918  instead.
2919  The period and quantized gains are determined in closed loop (analysis-by-synth
2920 esis).
2921  In most modes, the pitch period is encoded with 7 bits in the 
2922 \begin_inset Formula $\left[17,144\right]$
2923 \end_inset 
2924
2925  range and the 
2926 \begin_inset Formula $\beta_{i}$
2927 \end_inset 
2928
2929  coefficients are vector-quantized using 7 bits (15 kbps narrowband and
2930  above) at higher bit-rates and 5 bits at lower bit-rates (11 kbps narrowband
2931  and below).
2932 \layout Subsection
2933
2934 Innovation Codebook
2935 \layout Standard
2936
2937 In Speex, the innovation signal is quantized using sub-vector shape-only
2938  vector quantization (VQ).
2939  That means that the innovation signal is divided in sub-vectors (of size
2940  5 to 20) and quantized using a codebook that represents both the shape
2941  and the gain at the same time.
2942  This save many bits that would otherwise be allocated for a separate gain
2943  at the price of a slight increase in complexity.
2944  
2945 \layout Subsection
2946
2947 Bit allocation
2948 \layout Standard
2949
2950 There are 7 different narrowband bit-rates defined for Speex, ranging from
2951  250 bps to 24.6 kbps, although the modes below 5.9 kbps should not be used
2952  for speech.
2953  The bit-allocation for each mode is detailed in table 
2954 \begin_inset LatexCommand \ref{cap:bits-narrowband}
2955
2956 \end_inset 
2957
2958 .
2959  Each frame starts with the mode ID encoded with 4 bits which allows a range
2960  from 0 to 15, though only the first 7 values are used (the others are reserved).
2961  The parameters are listed in the table in the order they are packed in
2962  the bit-stream.
2963  All frame-based parameters are packed before sub-frame parameters.
2964  The parameters for a certain sub-frame are all packed before the following
2965  sub-frame is packed.
2966  Note that the 
2967 \begin_inset Quotes eld
2968 \end_inset 
2969
2970 OL
2971 \begin_inset Quotes erd
2972 \end_inset 
2973
2974  in the parameter description means that the parameter is an open loop estimatio
2975 n based on the whole frame.
2976 \layout Standard
2977
2978
2979 \begin_inset Float table
2980 placement h
2981 wide true
2982 collapsed false
2983
2984 \layout Standard
2985
2986
2987 \begin_inset  Tabular
2988 <lyxtabular version="3" rows="12" columns="11">
2989 <features>
2990 <column alignment="center" valignment="top" leftline="true" width="0pt">
2991 <column alignment="center" valignment="top" leftline="true" width="0pt">
2992 <column alignment="center" valignment="top" leftline="true" width="0pt">
2993 <column alignment="center" valignment="top" leftline="true" width="0pt">
2994 <column alignment="center" valignment="top" leftline="true" width="0pt">
2995 <column alignment="center" valignment="top" leftline="true" width="0pt">
2996 <column alignment="center" valignment="top" leftline="true" width="0pt">
2997 <column alignment="center" valignment="top" leftline="true" width="0pt">
2998 <column alignment="center" valignment="top" leftline="true" width="0pt">
2999 <column alignment="center" valignment="top" leftline="true" width="0pt">
3000 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
3001 <row topline="true" bottomline="true">
3002 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3003 \begin_inset Text
3004
3005 \layout Standard
3006
3007 Parameter
3008 \end_inset 
3009 </cell>
3010 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3011 \begin_inset Text
3012
3013 \layout Standard
3014
3015 Update rate
3016 \end_inset 
3017 </cell>
3018 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3019 \begin_inset Text
3020
3021 \layout Standard
3022
3023 0
3024 \end_inset 
3025 </cell>
3026 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3027 \begin_inset Text
3028
3029 \layout Standard
3030
3031 1
3032 \end_inset 
3033 </cell>
3034 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3035 \begin_inset Text
3036
3037 \layout Standard
3038
3039 2
3040 \end_inset 
3041 </cell>
3042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3043 \begin_inset Text
3044
3045 \layout Standard
3046
3047 3
3048 \end_inset 
3049 </cell>
3050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3051 \begin_inset Text
3052
3053 \layout Standard
3054
3055 4
3056 \end_inset 
3057 </cell>
3058 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3059 \begin_inset Text
3060
3061 \layout Standard
3062
3063 5
3064 \end_inset 
3065 </cell>
3066 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3067 \begin_inset Text
3068
3069 \layout Standard
3070
3071 6
3072 \end_inset 
3073 </cell>
3074 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3075 \begin_inset Text
3076
3077 \layout Standard
3078
3079 7
3080 \end_inset 
3081 </cell>
3082 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3083 \begin_inset Text
3084
3085 \layout Standard
3086
3087 8
3088 \end_inset 
3089 </cell>
3090 </row>
3091 <row topline="true">
3092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3093 \begin_inset Text
3094
3095 \layout Standard
3096
3097 Wideband bit
3098 \end_inset 
3099 </cell>
3100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3101 \begin_inset Text
3102
3103 \layout Standard
3104
3105 frame
3106 \end_inset 
3107 </cell>
3108 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3109 \begin_inset Text
3110
3111 \layout Standard
3112
3113 1
3114 \end_inset 
3115 </cell>
3116 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3117 \begin_inset Text
3118
3119 \layout Standard
3120
3121 1
3122 \end_inset 
3123 </cell>
3124 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3125 \begin_inset Text
3126
3127 \layout Standard
3128
3129 1
3130 \end_inset 
3131 </cell>
3132 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3133 \begin_inset Text
3134
3135 \layout Standard
3136
3137 1
3138 \end_inset 
3139 </cell>
3140 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3141 \begin_inset Text
3142
3143 \layout Standard
3144
3145 1
3146 \end_inset 
3147 </cell>
3148 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3149 \begin_inset Text
3150
3151 \layout Standard
3152
3153 1
3154 \end_inset 
3155 </cell>
3156 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3157 \begin_inset Text
3158
3159 \layout Standard
3160
3161 1
3162 \end_inset 
3163 </cell>
3164 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3165 \begin_inset Text
3166
3167 \layout Standard
3168
3169 1
3170 \end_inset 
3171 </cell>
3172 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3173 \begin_inset Text
3174
3175 \layout Standard
3176
3177 1
3178 \end_inset 
3179 </cell>
3180 </row>
3181 <row topline="true">
3182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3183 \begin_inset Text
3184
3185 \layout Standard
3186
3187 Mode ID
3188 \end_inset 
3189 </cell>
3190 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3191 \begin_inset Text
3192
3193 \layout Standard
3194
3195 frame
3196 \end_inset 
3197 </cell>
3198 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3199 \begin_inset Text
3200
3201 \layout Standard
3202
3203 4
3204 \end_inset 
3205 </cell>
3206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3207 \begin_inset Text
3208
3209 \layout Standard
3210
3211 4
3212 \end_inset 
3213 </cell>
3214 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3215 \begin_inset Text
3216
3217 \layout Standard
3218
3219 4
3220 \end_inset 
3221 </cell>
3222 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3223 \begin_inset Text
3224
3225 \layout Standard
3226
3227 4
3228 \end_inset 
3229 </cell>
3230 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3231 \begin_inset Text
3232
3233 \layout Standard
3234
3235 4
3236 \end_inset 
3237 </cell>
3238 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3239 \begin_inset Text
3240
3241 \layout Standard
3242
3243 4
3244 \end_inset 
3245 </cell>
3246 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3247 \begin_inset Text
3248
3249 \layout Standard
3250
3251 4
3252 \end_inset 
3253 </cell>
3254 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3255 \begin_inset Text
3256
3257 \layout Standard
3258
3259 4
3260 \end_inset 
3261 </cell>
3262 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3263 \begin_inset Text
3264
3265 \layout Standard
3266
3267 4
3268 \end_inset 
3269 </cell>
3270 </row>
3271 <row topline="true">
3272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3273 \begin_inset Text
3274
3275 \layout Standard
3276
3277 LSP
3278 \end_inset 
3279 </cell>
3280 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3281 \begin_inset Text
3282
3283 \layout Standard
3284
3285 frame
3286 \end_inset 
3287 </cell>
3288 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3289 \begin_inset Text
3290
3291 \layout Standard
3292
3293 0
3294 \end_inset 
3295 </cell>
3296 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3297 \begin_inset Text
3298
3299 \layout Standard
3300
3301 18
3302 \end_inset 
3303 </cell>
3304 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3305 \begin_inset Text
3306
3307 \layout Standard
3308
3309 18
3310 \end_inset 
3311 </cell>
3312 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3313 \begin_inset Text
3314
3315 \layout Standard
3316
3317 18
3318 \end_inset 
3319 </cell>
3320 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3321 \begin_inset Text
3322
3323 \layout Standard
3324
3325 18
3326 \end_inset 
3327 </cell>
3328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3329 \begin_inset Text
3330
3331 \layout Standard
3332
3333 30
3334 \end_inset 
3335 </cell>
3336 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3337 \begin_inset Text
3338
3339 \layout Standard
3340
3341 30
3342 \end_inset 
3343 </cell>
3344 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3345 \begin_inset Text
3346
3347 \layout Standard
3348
3349 30
3350 \end_inset 
3351 </cell>
3352 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3353 \begin_inset Text
3354
3355 \layout Standard
3356
3357 18
3358 \end_inset 
3359 </cell>
3360 </row>
3361 <row topline="true">
3362 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3363 \begin_inset Text
3364
3365 \layout Standard
3366
3367 OL pitch
3368 \end_inset 
3369 </cell>
3370 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3371 \begin_inset Text
3372
3373 \layout Standard
3374
3375 frame
3376 \end_inset 
3377 </cell>
3378 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3379 \begin_inset Text
3380
3381 \layout Standard
3382
3383 0
3384 \end_inset 
3385 </cell>
3386 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3387 \begin_inset Text
3388
3389 \layout Standard
3390
3391 7
3392 \end_inset 
3393 </cell>
3394 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3395 \begin_inset Text
3396
3397 \layout Standard
3398
3399 7
3400 \end_inset 
3401 </cell>
3402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3403 \begin_inset Text
3404
3405 \layout Standard
3406
3407 0
3408 \end_inset 
3409 </cell>
3410 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3411 \begin_inset Text
3412
3413 \layout Standard
3414
3415 0
3416 \end_inset 
3417 </cell>
3418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3419 \begin_inset Text
3420
3421 \layout Standard
3422
3423 0
3424 \end_inset 
3425 </cell>
3426 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3427 \begin_inset Text
3428
3429 \layout Standard
3430
3431 0
3432 \end_inset 
3433 </cell>
3434 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3435 \begin_inset Text
3436
3437 \layout Standard
3438
3439 0
3440 \end_inset 
3441 </cell>
3442 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3443 \begin_inset Text
3444
3445 \layout Standard
3446
3447 7
3448 \end_inset 
3449 </cell>
3450 </row>
3451 <row topline="true">
3452 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3453 \begin_inset Text
3454
3455 \layout Standard
3456
3457 OL pitch gain
3458 \end_inset 
3459 </cell>
3460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3461 \begin_inset Text
3462
3463 \layout Standard
3464
3465 frame
3466 \end_inset 
3467 </cell>
3468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3469 \begin_inset Text
3470
3471 \layout Standard
3472
3473 0
3474 \end_inset 
3475 </cell>
3476 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3477 \begin_inset Text
3478
3479 \layout Standard
3480
3481 4
3482 \end_inset 
3483 </cell>
3484 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3485 \begin_inset Text
3486
3487 \layout Standard
3488
3489 0
3490 \end_inset 
3491 </cell>
3492 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3493 \begin_inset Text
3494
3495 \layout Standard
3496
3497 0
3498 \end_inset 
3499 </cell>
3500 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3501 \begin_inset Text
3502
3503 \layout Standard
3504
3505 0
3506 \end_inset 
3507 </cell>
3508 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3509 \begin_inset Text
3510
3511 \layout Standard
3512
3513 0
3514 \end_inset 
3515 </cell>
3516 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3517 \begin_inset Text
3518
3519 \layout Standard
3520
3521 0
3522 \end_inset 
3523 </cell>
3524 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3525 \begin_inset Text
3526
3527 \layout Standard
3528
3529 0
3530 \end_inset 
3531 </cell>
3532 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3533 \begin_inset Text
3534
3535 \layout Standard
3536
3537 4
3538 \end_inset 
3539 </cell>
3540 </row>
3541 <row topline="true">
3542 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3543 \begin_inset Text
3544
3545 \layout Standard
3546
3547 OL Exc gain
3548 \end_inset 
3549 </cell>
3550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3551 \begin_inset Text
3552
3553 \layout Standard
3554
3555 frame
3556 \end_inset 
3557 </cell>
3558 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3559 \begin_inset Text
3560
3561 \layout Standard
3562
3563 0
3564 \end_inset 
3565 </cell>
3566 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3567 \begin_inset Text
3568
3569 \layout Standard
3570
3571 5
3572 \end_inset 
3573 </cell>
3574 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3575 \begin_inset Text
3576
3577 \layout Standard
3578
3579 5
3580 \end_inset 
3581 </cell>
3582 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3583 \begin_inset Text
3584
3585 \layout Standard
3586
3587 5
3588 \end_inset 
3589 </cell>
3590 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3591 \begin_inset Text
3592
3593 \layout Standard
3594
3595 5
3596 \end_inset 
3597 </cell>
3598 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3599 \begin_inset Text
3600
3601 \layout Standard
3602
3603 5
3604 \end_inset 
3605 </cell>
3606 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3607 \begin_inset Text
3608
3609 \layout Standard
3610
3611 5
3612 \end_inset 
3613 </cell>
3614 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3615 \begin_inset Text
3616
3617 \layout Standard
3618
3619 5
3620 \end_inset 
3621 </cell>
3622 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3623 \begin_inset Text
3624
3625 \layout Standard
3626
3627 5
3628 \end_inset 
3629 </cell>
3630 </row>
3631 <row topline="true">
3632 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3633 \begin_inset Text
3634
3635 \layout Standard
3636
3637 Fine pitch
3638 \end_inset 
3639 </cell>
3640 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3641 \begin_inset Text
3642
3643 \layout Standard
3644
3645 sub-frame
3646 \end_inset 
3647 </cell>
3648 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3649 \begin_inset Text
3650
3651 \layout Standard
3652
3653 0
3654 \end_inset 
3655 </cell>
3656 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3657 \begin_inset Text
3658
3659 \layout Standard
3660
3661 0
3662 \end_inset 
3663 </cell>
3664 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3665 \begin_inset Text
3666
3667 \layout Standard
3668
3669 0
3670 \end_inset 
3671 </cell>
3672 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3673 \begin_inset Text
3674
3675 \layout Standard
3676
3677 7
3678 \end_inset 
3679 </cell>
3680 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3681 \begin_inset Text
3682
3683 \layout Standard
3684
3685 7
3686 \end_inset 
3687 </cell>
3688 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3689 \begin_inset Text
3690
3691 \layout Standard
3692
3693 7
3694 \end_inset 
3695 </cell>
3696 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3697 \begin_inset Text
3698
3699 \layout Standard
3700
3701 7
3702 \end_inset 
3703 </cell>
3704 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3705 \begin_inset Text
3706
3707 \layout Standard
3708
3709 7
3710 \end_inset 
3711 </cell>
3712 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3713 \begin_inset Text
3714
3715 \layout Standard
3716
3717 0
3718 \end_inset 
3719 </cell>
3720 </row>
3721 <row topline="true">
3722 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3723 \begin_inset Text
3724
3725 \layout Standard
3726
3727 Pitch gain
3728 \end_inset 
3729 </cell>
3730 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3731 \begin_inset Text
3732
3733 \layout Standard
3734
3735 sub-frame
3736 \end_inset 
3737 </cell>
3738 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3739 \begin_inset Text
3740
3741 \layout Standard
3742
3743 0
3744 \end_inset 
3745 </cell>
3746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3747 \begin_inset Text
3748
3749 \layout Standard
3750
3751 0
3752 \end_inset 
3753 </cell>
3754 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3755 \begin_inset Text
3756
3757 \layout Standard
3758
3759 5
3760 \end_inset 
3761 </cell>
3762 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3763 \begin_inset Text
3764
3765 \layout Standard
3766
3767 5
3768 \end_inset 
3769 </cell>
3770 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3771 \begin_inset Text
3772
3773 \layout Standard
3774
3775 5
3776 \end_inset 
3777 </cell>
3778 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3779 \begin_inset Text
3780
3781 \layout Standard
3782
3783 7
3784 \end_inset 
3785 </cell>
3786 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3787 \begin_inset Text
3788
3789 \layout Standard
3790
3791 7
3792 \end_inset 
3793 </cell>
3794 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3795 \begin_inset Text
3796
3797 \layout Standard
3798
3799 7
3800 \end_inset 
3801 </cell>
3802 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3803 \begin_inset Text
3804
3805 \layout Standard
3806
3807 0
3808 \end_inset 
3809 </cell>
3810 </row>
3811 <row topline="true">
3812 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3813 \begin_inset Text
3814
3815 \layout Standard
3816
3817 Innovation gain
3818 \end_inset 
3819 </cell>
3820 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3821 \begin_inset Text
3822
3823 \layout Standard
3824
3825 sub-frame
3826 \end_inset 
3827 </cell>
3828 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3829 \begin_inset Text
3830
3831 \layout Standard
3832
3833 0
3834 \end_inset 
3835 </cell>
3836 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3837 \begin_inset Text
3838
3839 \layout Standard
3840
3841 1
3842 \end_inset 
3843 </cell>
3844 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3845 \begin_inset Text
3846
3847 \layout Standard
3848
3849 0
3850 \end_inset 
3851 </cell>
3852 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3853 \begin_inset Text
3854
3855 \layout Standard
3856
3857 1
3858 \end_inset 
3859 </cell>
3860 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3861 \begin_inset Text
3862
3863 \layout Standard
3864
3865 1
3866 \end_inset 
3867 </cell>
3868 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3869 \begin_inset Text
3870
3871 \layout Standard
3872
3873 3
3874 \end_inset 
3875 </cell>
3876 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3877 \begin_inset Text
3878
3879 \layout Standard
3880
3881 3
3882 \end_inset 
3883 </cell>
3884 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3885 \begin_inset Text
3886
3887 \layout Standard
3888
3889 3
3890 \end_inset 
3891 </cell>
3892 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3893 \begin_inset Text
3894
3895 \layout Standard
3896
3897 0
3898 \end_inset 
3899 </cell>
3900 </row>
3901 <row topline="true" bottomline="true">
3902 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3903 \begin_inset Text
3904
3905 \layout Standard
3906
3907 Innovation VQ
3908 \end_inset 
3909 </cell>
3910 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3911 \begin_inset Text
3912
3913 \layout Standard
3914
3915 sub-frame
3916 \end_inset 
3917 </cell>
3918 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3919 \begin_inset Text
3920
3921 \layout Standard
3922
3923 0
3924 \end_inset 
3925 </cell>
3926 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3927 \begin_inset Text
3928
3929 \layout Standard
3930
3931 0
3932 \end_inset 
3933 </cell>
3934 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3935 \begin_inset Text
3936
3937 \layout Standard
3938
3939 16
3940 \end_inset 
3941 </cell>
3942 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3943 \begin_inset Text
3944
3945 \layout Standard
3946
3947 20
3948 \end_inset 
3949 </cell>
3950 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3951 \begin_inset Text
3952
3953 \layout Standard
3954
3955 35
3956 \end_inset 
3957 </cell>
3958 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3959 \begin_inset Text
3960
3961 \layout Standard
3962
3963 48
3964 \end_inset 
3965 </cell>
3966 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3967 \begin_inset Text
3968
3969 \layout Standard
3970
3971 64
3972 \end_inset 
3973 </cell>
3974 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3975 \begin_inset Text
3976
3977 \layout Standard
3978
3979 96
3980 \end_inset 
3981 </cell>
3982 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3983 \begin_inset Text
3984
3985 \layout Standard
3986
3987 10
3988 \end_inset 
3989 </cell>
3990 </row>
3991 <row topline="true" bottomline="true">
3992 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3993 \begin_inset Text
3994
3995 \layout Standard
3996
3997 Total
3998 \end_inset 
3999 </cell>
4000 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4001 \begin_inset Text
4002
4003 \layout Standard
4004
4005 frame
4006 \end_inset 
4007 </cell>
4008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4009 \begin_inset Text
4010
4011 \layout Standard
4012
4013 5
4014 \end_inset 
4015 </cell>
4016 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4017 \begin_inset Text
4018
4019 \layout Standard
4020
4021 43
4022 \end_inset 
4023 </cell>
4024 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4025 \begin_inset Text
4026
4027 \layout Standard
4028
4029 119
4030 \end_inset 
4031 </cell>
4032 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4033 \begin_inset Text
4034
4035 \layout Standard
4036
4037 160
4038 \end_inset 
4039 </cell>
4040 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4041 \begin_inset Text
4042
4043 \layout Standard
4044
4045 220
4046 \end_inset 
4047 </cell>
4048 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4049 \begin_inset Text
4050
4051 \layout Standard
4052
4053 300
4054 \end_inset 
4055 </cell>
4056 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4057 \begin_inset Text
4058
4059 \layout Standard
4060
4061 364
4062 \end_inset 
4063 </cell>
4064 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4065 \begin_inset Text
4066
4067 \layout Standard
4068
4069 492
4070 \end_inset 
4071 </cell>
4072 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4073 \begin_inset Text
4074
4075 \layout Standard
4076
4077 79
4078 \end_inset 
4079 </cell>
4080 </row>
4081 </lyxtabular>
4082
4083 \end_inset 
4084
4085
4086 \layout Caption
4087
4088 Bit allocation for narrowband modes
4089 \begin_inset LatexCommand \label{cap:bits-narrowband}
4090
4091 \end_inset 
4092
4093
4094 \end_inset 
4095
4096
4097 \layout Standard
4098
4099 So far, no MOS (Mean Opinion Score
4100 \begin_inset LatexCommand \index{mean opinion score}
4101
4102 \end_inset 
4103
4104 ) subjective evaluation has been performed for Speex.
4105  In order to give an idea of the quality achivable with it, table 
4106 \begin_inset LatexCommand \ref{cap:quality_vs_bps}
4107
4108 \end_inset 
4109
4110  presents my own subjective opinion on it.
4111  It sould be noted that different people will perceive the quality differently
4112  and that the person that designed the codec often has a bias (one way or
4113  another) when it comes to subjective evaluation.
4114  Last thing, it should be noted that for most codecs (including Speex) encoding
4115  quality sometimes varies depending on the input.
4116  Note that the complexity is only approximate (within 0.5 mflops and using
4117  the lowers complexity setting).
4118  Decoding requires approximately 0.5 mflops
4119 \begin_inset LatexCommand \index{complexity}
4120
4121 \end_inset 
4122
4123  in most modes (1 mflops with perceptual enhancement).
4124 \layout Standard
4125
4126
4127 \begin_inset Float table
4128 placement h
4129 wide true
4130 collapsed false
4131
4132 \layout Standard
4133
4134
4135 \begin_inset  Tabular
4136 <lyxtabular version="3" rows="17" columns="4">
4137 <features>
4138 <column alignment="center" valignment="top" leftline="true" width="0pt">
4139 <column alignment="center" valignment="top" leftline="true" width="0pt">
4140 <column alignment="center" valignment="top" leftline="true" width="0pt">
4141 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
4142 <row topline="true" bottomline="true">
4143 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4144 \begin_inset Text
4145
4146 \layout Standard
4147
4148 Mode
4149 \end_inset 
4150 </cell>
4151 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4152 \begin_inset Text
4153
4154 \layout Standard
4155
4156 Bit-rate
4157 \begin_inset LatexCommand \index{bit-rate}
4158
4159 \end_inset 
4160
4161  (bps)
4162 \end_inset 
4163 </cell>
4164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4165 \begin_inset Text
4166
4167 \layout Standard
4168
4169 mflops
4170 \begin_inset LatexCommand \index{complexity}
4171
4172 \end_inset 
4173
4174
4175 \end_inset 
4176 </cell>
4177 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4178 \begin_inset Text
4179
4180 \layout Standard
4181
4182 Quality/description
4183 \end_inset 
4184 </cell>
4185 </row>
4186 <row topline="true">
4187 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4188 \begin_inset Text
4189
4190 \layout Standard
4191
4192 0
4193 \end_inset 
4194 </cell>
4195 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4196 \begin_inset Text
4197
4198 \layout Standard
4199
4200 250
4201 \end_inset 
4202 </cell>
4203 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4204 \begin_inset Text
4205
4206 \layout Standard
4207
4208 N/A
4209 \end_inset 
4210 </cell>
4211 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4212 \begin_inset Text
4213
4214 \layout Standard
4215
4216 No transmission (DTX)
4217 \end_inset 
4218 </cell>
4219 </row>
4220 <row topline="true">
4221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4222 \begin_inset Text
4223
4224 \layout Standard
4225
4226 1
4227 \end_inset 
4228 </cell>
4229 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4230 \begin_inset Text
4231
4232 \layout Standard
4233
4234 2,150
4235 \end_inset 
4236 </cell>
4237 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4238 \begin_inset Text
4239
4240 \layout Standard
4241
4242 6
4243 \end_inset 
4244 </cell>
4245 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4246 \begin_inset Text
4247
4248 \layout Standard
4249
4250 Vocoder (mostly for comfort noise)
4251 \end_inset 
4252 </cell>
4253 </row>
4254 <row topline="true">
4255 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4256 \begin_inset Text
4257
4258 \layout Standard
4259
4260 2
4261 \end_inset 
4262 </cell>
4263 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4264 \begin_inset Text
4265
4266 \layout Standard
4267
4268 5,950
4269 \end_inset 
4270 </cell>
4271 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4272 \begin_inset Text
4273
4274 \layout Standard
4275
4276 9
4277 \end_inset 
4278 </cell>
4279 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4280 \begin_inset Text
4281
4282 \layout Standard
4283
4284 Very noticeable artifacts/noise, good intelligibility
4285 \end_inset 
4286 </cell>
4287 </row>
4288 <row topline="true">
4289 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4290 \begin_inset Text
4291
4292 \layout Standard
4293
4294 3
4295 \end_inset 
4296 </cell>
4297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4298 \begin_inset Text
4299
4300 \layout Standard
4301
4302 8,000
4303 \end_inset 
4304 </cell>
4305 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4306 \begin_inset Text
4307
4308 \layout Standard
4309
4310 10
4311 \end_inset 
4312 </cell>
4313 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4314 \begin_inset Text
4315
4316 \layout Standard
4317
4318 Artifacts/noise sometimes noticeable
4319 \end_inset 
4320 </cell>
4321 </row>
4322 <row topline="true">
4323 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4324 \begin_inset Text
4325
4326 \layout Standard
4327
4328 4
4329 \end_inset 
4330 </cell>
4331 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4332 \begin_inset Text
4333
4334 \layout Standard
4335
4336 11,000
4337 \end_inset 
4338 </cell>
4339 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4340 \begin_inset Text
4341
4342 \layout Standard
4343
4344 14
4345 \end_inset 
4346 </cell>
4347 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4348 \begin_inset Text
4349
4350 \layout Standard
4351
4352 Artifacts usually noticeable only with headphones
4353 \end_inset 
4354 </cell>
4355 </row>
4356 <row topline="true">
4357 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4358 \begin_inset Text
4359
4360 \layout Standard
4361
4362 5
4363 \end_inset 
4364 </cell>
4365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4366 \begin_inset Text
4367
4368 \layout Standard
4369
4370 15,000
4371 \end_inset 
4372 </cell>
4373 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4374 \begin_inset Text
4375
4376 \layout Standard
4377
4378 11
4379 \end_inset 
4380 </cell>
4381 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4382 \begin_inset Text
4383
4384 \layout Standard
4385
4386 Need good headphones to tell the difference
4387 \end_inset 
4388 </cell>
4389 </row>
4390 <row topline="true">
4391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4392 \begin_inset Text
4393
4394 \layout Standard
4395
4396 6
4397 \end_inset 
4398 </cell>
4399 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4400 \begin_inset Text
4401
4402 \layout Standard
4403
4404 18,200
4405 \end_inset 
4406 </cell>
4407 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4408 \begin_inset Text
4409
4410 \layout Standard
4411
4412 17.5
4413 \end_inset 
4414 </cell>
4415 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4416 \begin_inset Text
4417
4418 \layout Standard
4419
4420 Hard to tell the difference even with good headphones
4421 \end_inset 
4422 </cell>
4423 </row>
4424 <row topline="true">
4425 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4426 \begin_inset Text
4427
4428 \layout Standard
4429
4430 7
4431 \end_inset 
4432 </cell>
4433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4434 \begin_inset Text
4435
4436 \layout Standard
4437
4438 24,600
4439 \end_inset 
4440 </cell>
4441 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4442 \begin_inset Text
4443
4444 \layout Standard
4445
4446 14.5
4447 \end_inset 
4448 </cell>
4449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4450 \begin_inset Text
4451
4452 \layout Standard
4453
4454 Completely transparent for voice, good quality music
4455 \end_inset 
4456 </cell>
4457 </row>
4458 <row topline="true">
4459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4460 \begin_inset Text
4461
4462 \layout Standard
4463
4464 8
4465 \end_inset 
4466 </cell>
4467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4468 \begin_inset Text
4469
4470 \layout Standard
4471
4472 3,950
4473 \end_inset 
4474 </cell>
4475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4476 \begin_inset Text
4477
4478 \layout Standard
4479
4480 10.5
4481 \end_inset 
4482 </cell>
4483 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4484 \begin_inset Text
4485
4486 \layout Standard
4487
4488 Very noticeable artifacts/noise, good intelligibility
4489 \end_inset 
4490 </cell>
4491 </row>
4492 <row topline="true">
4493 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4494 \begin_inset Text
4495
4496 \layout Standard
4497
4498 9
4499 \end_inset 
4500 </cell>
4501 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4502 \begin_inset Text
4503
4504 \layout Standard
4505
4506 N/A
4507 \end_inset 
4508 </cell>
4509 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4510 \begin_inset Text
4511
4512 \layout Standard
4513
4514 N/A
4515 \end_inset 
4516 </cell>
4517 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4518 \begin_inset Text
4519
4520 \layout Standard
4521
4522 reserved
4523 \end_inset 
4524 </cell>
4525 </row>
4526 <row topline="true">
4527 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4528 \begin_inset Text
4529
4530 \layout Standard
4531
4532 10
4533 \end_inset 
4534 </cell>
4535 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4536 \begin_inset Text
4537
4538 \layout Standard
4539
4540 N/A
4541 \end_inset 
4542 </cell>
4543 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4544 \begin_inset Text
4545
4546 \layout Standard
4547
4548 N/A
4549 \end_inset 
4550 </cell>
4551 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4552 \begin_inset Text
4553
4554 \layout Standard
4555
4556 reserved
4557 \end_inset 
4558 </cell>
4559 </row>
4560 <row topline="true">
4561 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4562 \begin_inset Text
4563
4564 \layout Standard
4565
4566 11
4567 \end_inset 
4568 </cell>
4569 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4570 \begin_inset Text
4571
4572 \layout Standard
4573
4574 N/A
4575 \end_inset 
4576 </cell>
4577 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4578 \begin_inset Text
4579
4580 \layout Standard
4581
4582 N/A
4583 \end_inset 
4584 </cell>
4585 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4586 \begin_inset Text
4587
4588 \layout Standard
4589
4590 reserved
4591 \end_inset 
4592 </cell>
4593 </row>
4594 <row topline="true">
4595 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4596 \begin_inset Text
4597
4598 \layout Standard
4599
4600 12
4601 \end_inset 
4602 </cell>
4603 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4604 \begin_inset Text
4605
4606 \layout Standard
4607
4608 N/A
4609 \end_inset 
4610 </cell>
4611 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4612 \begin_inset Text
4613
4614 \layout Standard
4615
4616 N/A
4617 \end_inset 
4618 </cell>
4619 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4620 \begin_inset Text
4621
4622 \layout Standard
4623
4624 reserved
4625 \end_inset 
4626 </cell>
4627 </row>
4628 <row topline="true">
4629 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4630 \begin_inset Text
4631
4632 \layout Standard
4633
4634 13
4635 \end_inset 
4636 </cell>
4637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4638 \begin_inset Text
4639
4640 \layout Standard
4641
4642 N/A
4643 \end_inset 
4644 </cell>
4645 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4646 \begin_inset Text
4647
4648 \layout Standard
4649
4650 N/A
4651 \end_inset 
4652 </cell>
4653 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4654 \begin_inset Text
4655
4656 \layout Standard
4657
4658 Application-defined, interpreted by callback or skipped
4659 \end_inset 
4660 </cell>
4661 </row>
4662 <row topline="true">
4663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4664 \begin_inset Text
4665
4666 \layout Standard
4667
4668 14
4669 \end_inset 
4670 </cell>
4671 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4672 \begin_inset Text
4673
4674 \layout Standard
4675
4676 N/A
4677 \end_inset 
4678 </cell>
4679 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4680 \begin_inset Text
4681
4682 \layout Standard
4683
4684 N/A
4685 \end_inset 
4686 </cell>
4687 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4688 \begin_inset Text
4689
4690 \layout Standard
4691
4692 Speex in-band signaling
4693 \end_inset 
4694 </cell>
4695 </row>
4696 <row topline="true" bottomline="true">
4697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4698 \begin_inset Text
4699
4700 \layout Standard
4701
4702 15
4703 \end_inset 
4704 </cell>
4705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4706 \begin_inset Text
4707
4708 \layout Standard
4709
4710 N/A
4711 \end_inset 
4712 </cell>
4713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4714 \begin_inset Text
4715
4716 \layout Standard
4717
4718 N/A
4719 \end_inset 
4720 </cell>
4721 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4722 \begin_inset Text
4723
4724 \layout Standard
4725
4726 Terminator code
4727 \end_inset 
4728 </cell>
4729 </row>
4730 </lyxtabular>
4731
4732 \end_inset 
4733
4734
4735 \layout Caption
4736
4737 Quality versus bit-rate
4738 \begin_inset LatexCommand \label{cap:quality_vs_bps}
4739
4740 \end_inset 
4741
4742
4743 \end_inset 
4744
4745
4746 \layout Subsection
4747
4748 Perceptual enhancement
4749 \begin_inset LatexCommand \index{perceptual enhancement}
4750
4751 \end_inset 
4752
4753
4754 \layout Standard
4755
4756 This part of the codec only applies to the decoder and can even be changed
4757  without affecting inter-operability.
4758  For that reason, the implementation provided and described here should
4759  only be considered as a reference implementation.
4760  The enhancement system is devided in two parts.
4761  First, the synthesis filter 
4762 \begin_inset Formula $S(z)=1/A(z)$
4763 \end_inset 
4764
4765  is replaced by an enhanced filter
4766 \begin_inset Formula \[
4767 S'(z)=\frac{A\left(z/a_{2}\right)A\left(z/a_{3}\right)}{A\left(z\right)A\left(z/a_{1}\right)}\]
4768
4769 \end_inset 
4770
4771 where 
4772 \begin_inset Formula $a_{1}$
4773 \end_inset 
4774
4775  and 
4776 \begin_inset Formula $a_{2}$
4777 \end_inset 
4778
4779  depend on the mode in use and 
4780 \begin_inset Formula $a_{3}=\frac{1}{r}\left(1-\frac{1-ra_{1}}{1-ra_{2}}\right)$
4781 \end_inset 
4782
4783  with 
4784 \begin_inset Formula $r=.9$
4785 \end_inset 
4786
4787 .
4788  The second part of the enhancement consists of using a comb filter to enhance
4789  the pitch in the excitation domain.
4790  
4791 \layout Section
4792 \pagebreak_top 
4793 Speex wideband mode (sub-band CELP)
4794 \begin_inset LatexCommand \index{wideband}
4795
4796 \end_inset 
4797
4798
4799 \layout Standard
4800
4801 For wideband, the Speex approach uses a 
4802 \emph on 
4803 q
4804 \emph default 
4805 uadrature 
4806 \emph on 
4807 m
4808 \emph default 
4809 irror 
4810 \emph on 
4811 f
4812 \emph default 
4813 ilter
4814 \begin_inset LatexCommand \index{quadrature mirror filter}
4815
4816 \end_inset 
4817
4818  (QMF) to split the band in two.
4819  The 16 kHz signal is thus divided into two 8 kHz signals, one representing
4820  the low band (0-4 kHz), the other the high band (4-8 kHz).
4821  The low band is encoded with the narrowband mode described in section 
4822 \begin_inset LatexCommand \ref{sec:Speex-narrowband-mode}
4823
4824 \end_inset 
4825
4826  in such a way that the resulting 
4827 \begin_inset Quotes eld
4828 \end_inset 
4829
4830 embedded narrowband bit-stream
4831 \begin_inset Quotes erd
4832 \end_inset 
4833
4834  can also be decoded with the narrowband decoder.
4835  Since the low band encoding has already been described only the high band
4836  encoding is described in this section.
4837 \layout Subsection
4838
4839 Linear Prediction
4840 \layout Standard
4841
4842 The linear prediction part used for the high-band is very similar to what
4843  is done for narrowband.
4844  The only difference is that we use only 12 bits to encode the high-band
4845  LSP's using a multi-stage vector quantizer (MSVQ).
4846  The first level quantizes the 10 coefficients with 6 bits and the error
4847  is then quantized using 6 bits too.
4848 \layout Subsection
4849
4850 Pitch Prediction
4851 \layout Standard
4852
4853 That part is easy: there's no pitch prediction for the high-band.
4854  There are two reasons for that.
4855  First, there is usually little harmonic structure in this band (above 4
4856  kHz).
4857  Second, it would be very hard to implement since the QMF folds the 4-8
4858  kHz band into 4-0 kHz (reversing the frequency axis), which means that
4859  the location of the harmonics are no longer at multiples of the fundamental
4860  (pitch).
4861 \layout Subsection
4862
4863 Excitation Quantization
4864 \layout Standard
4865
4866 The high-band excitation is coded in the same way as for narrowband.
4867  
4868 \layout Subsection
4869
4870 Bit allocation
4871 \layout Standard
4872
4873 For the wideband mode, all the narrowband frame is packed before the high-band
4874  is encoded.
4875  The narrowband part of the bit-stream is as defined in table 
4876 \begin_inset LatexCommand \ref{cap:bits-narrowband}
4877
4878 \end_inset 
4879
4880 .
4881  The high-band follows, as described in table 
4882 \begin_inset LatexCommand \ref{cap:bits-wideband}
4883
4884 \end_inset 
4885
4886 .
4887  This also means that a wideband frame may be correctly decoded by a narrowband
4888  decoder with the only caveat that if more than one frame is packed in the
4889  same packet, the decoder will need to skip the high-band parts in order
4890  to sync with the bit-stream.
4891 \layout Standard
4892
4893
4894 \begin_inset Float table
4895 placement h
4896 wide true
4897 collapsed false
4898
4899 \layout Standard
4900
4901
4902 \begin_inset  Tabular
4903 <lyxtabular version="3" rows="7" columns="7">
4904 <features>
4905 <column alignment="center" valignment="top" leftline="true" width="0pt">
4906 <column alignment="center" valignment="top" leftline="true" width="0pt">
4907 <column alignment="center" valignment="top" leftline="true" width="0pt">
4908 <column alignment="center" valignment="top" leftline="true" width="0pt">
4909 <column alignment="center" valignment="top" leftline="true" width="0pt">
4910 <column alignment="center" valignment="top" leftline="true" width="0pt">
4911 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0pt">
4912 <row topline="true" bottomline="true">
4913 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4914 \begin_inset Text
4915
4916 \layout Standard
4917
4918 Parameter
4919 \end_inset 
4920 </cell>
4921 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4922 \begin_inset Text
4923
4924 \layout Standard
4925
4926 Update rate
4927 \end_inset 
4928 </cell>
4929 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4930 \begin_inset Text
4931
4932 \layout Standard
4933
4934 0
4935 \end_inset 
4936 </cell>
4937 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4938 \begin_inset Text
4939
4940 \layout Standard
4941
4942 1
4943 \end_inset 
4944 </cell>
4945 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4946 \begin_inset Text
4947
4948 \layout Standard
4949
4950 2
4951 \end_inset 
4952 </cell>
4953 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4954 \begin_inset Text
4955
4956 \layout Standard
4957
4958 3
4959 \end_inset 
4960 </cell>
4961 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4962 \begin_inset Text
4963
4964 \layout Standard
4965
4966 4
4967 \end_inset 
4968 </cell>
4969 </row>
4970 <row topline="true">
4971 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4972 \begin_inset Text
4973
4974 \layout Standard
4975
4976 Wideband bit
4977 \end_inset 
4978 </cell>
4979 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4980 \begin_inset Text
4981
4982 \layout Standard
4983
4984 frame
4985 \end_inset 
4986 </cell>
4987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4988 \begin_inset Text
4989
4990 \layout Standard
4991
4992 1
4993 \end_inset 
4994 </cell>
4995 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4996 \begin_inset Text
4997
4998 \layout Standard
4999
5000 1
5001 \end_inset 
5002 </cell>
5003 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5004 \begin_inset Text
5005
5006 \layout Standard
5007
5008 1
5009 \end_inset 
5010 </cell>
5011 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5012 \begin_inset Text
5013
5014 \layout Standard
5015
5016 1
5017 \end_inset 
5018 </cell>
5019 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5020 \begin_inset Text
5021
5022 \layout Standard
5023
5024 1
5025 \end_inset 
5026 </cell>
5027 </row>
5028 <row topline="true">
5029 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5030 \begin_inset Text
5031
5032 \layout Standard
5033
5034 Mode ID
5035 \end_inset 
5036 </cell>
5037 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5038 \begin_inset Text
5039
5040 \layout Standard
5041
5042 frame
5043 \end_inset 
5044 </cell>
5045 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5046 \begin_inset Text
5047
5048 \layout Standard
5049
5050 3
5051 \end_inset 
5052 </cell>
5053 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5054 \begin_inset Text
5055
5056 \layout Standard
5057
5058 3
5059 \end_inset 
5060 </cell>
5061 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5062 \begin_inset Text
5063
5064 \layout Standard
5065
5066 3
5067 \end_inset 
5068 </cell>
5069 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5070 \begin_inset Text
5071
5072 \layout Standard
5073
5074 3
5075 \end_inset 
5076 </cell>
5077 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5078 \begin_inset Text
5079
5080 \layout Standard
5081
5082 3
5083 \end_inset 
5084 </cell>
5085 </row>
5086 <row topline="true">
5087 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5088 \begin_inset Text
5089
5090 \layout Standard
5091
5092 LSP
5093 \end_inset 
5094 </cell>
5095 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5096 \begin_inset Text
5097
5098 \layout Standard
5099
5100 frame
5101 \end_inset 
5102 </cell>
5103 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5104 \begin_inset Text
5105
5106 \layout Standard
5107
5108 0
5109 \end_inset 
5110 </cell>
5111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5112 \begin_inset Text
5113
5114 \layout Standard
5115
5116 12
5117 \end_inset 
5118 </cell>
5119 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5120 \begin_inset Text
5121
5122 \layout Standard
5123
5124 12
5125 \end_inset 
5126 </cell>
5127 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5128 \begin_inset Text
5129
5130 \layout Standard
5131
5132 12
5133 \end_inset 
5134 </cell>
5135 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5136 \begin_inset Text
5137
5138 \layout Standard
5139
5140 12
5141 \end_inset 
5142 </cell>
5143 </row>
5144 <row topline="true">
5145 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5146 \begin_inset Text
5147
5148 \layout Standard
5149
5150 Excitation gain
5151 \end_inset 
5152 </cell>
5153 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5154 \begin_inset Text
5155
5156 \layout Standard
5157
5158 sub-frame
5159 \end_inset 
5160 </cell>
5161 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5162 \begin_inset Text
5163
5164 \layout Standard
5165
5166 0
5167 \end_inset 
5168 </cell>
5169 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5170 \begin_inset Text
5171
5172 \layout Standard
5173
5174 5
5175 \end_inset 
5176 </cell>
5177 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5178 \begin_inset Text
5179
5180 \layout Standard
5181
5182 4
5183 \end_inset 
5184 </cell>
5185 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5186 \begin_inset Text
5187
5188 \layout Standard
5189
5190 4
5191 \end_inset 
5192 </cell>
5193 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5194 \begin_inset Text
5195
5196 \layout Standard
5197
5198 4
5199 \end_inset 
5200 </cell>
5201 </row>
5202 <row topline="true" bottomline="true">
5203 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5204 \begin_inset Text
5205
5206 \layout Standard
5207
5208 Excitation VQ
5209 \end_inset 
5210 </cell>
5211 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5212 \begin_inset Text
5213
5214 \layout Standard
5215
5216 sub-frame
5217 \end_inset 
5218 </cell>
5219 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5220 \begin_inset Text
5221
5222 \layout Standard
5223
5224 0
5225 \end_inset 
5226 </cell>
5227 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5228 \begin_inset Text
5229
5230 \layout Standard
5231
5232 0
5233 \end_inset 
5234 </cell>
5235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5236 \begin_inset Text
5237
5238 \layout Standard
5239
5240 20
5241 \end_inset 
5242 </cell>
5243 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5244 \begin_inset Text
5245
5246 \layout Standard
5247
5248 40
5249 \end_inset 
5250 </cell>
5251 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5252 \begin_inset Text
5253
5254 \layout Standard
5255
5256 80
5257 \end_inset 
5258 </cell>
5259 </row>
5260 <row topline="true" bottomline="true">
5261 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5262 \begin_inset Text
5263
5264 \layout Standard
5265
5266 Total
5267 \end_inset 
5268 </cell>
5269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5270 \begin_inset Text
5271
5272 \layout Standard
5273
5274 frame
5275 \end_inset 
5276 </cell>
5277 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5278 \begin_inset Text
5279
5280 \layout Standard
5281
5282 4
5283 \end_inset 
5284 </cell>
5285 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5286 \begin_inset Text
5287
5288 \layout Standard
5289
5290 36
5291 \end_inset 
5292 </cell>
5293 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5294 \begin_inset Text
5295
5296 \layout Standard
5297
5298 112
5299 \end_inset 
5300 </cell>
5301 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5302 \begin_inset Text
5303
5304 \layout Standard
5305
5306 192
5307 \end_inset 
5308 </cell>
5309 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
5310 \begin_inset Text
5311
5312 \layout Standard
5313
5314 352
5315 \end_inset 
5316 </cell>
5317 </row>
5318 </lyxtabular>
5319
5320 \end_inset 
5321
5322
5323 \layout Caption
5324
5325 Bit allocation for high-band in wideband mode
5326 \begin_inset LatexCommand \label{cap:bits-wideband}
5327
5328 \end_inset 
5329
5330
5331 \end_inset 
5332
5333
5334 \layout Standard
5335
5336
5337 \begin_inset ERT
5338 status Open
5339
5340 \layout Standard
5341
5342 \backslash 
5343 clearpage
5344 \end_inset 
5345
5346
5347 \layout Standard
5348
5349
5350 \begin_inset ERT
5351 status Collapsed
5352
5353 \layout Standard
5354
5355 \backslash 
5356 clearpage
5357 \end_inset 
5358
5359
5360 \layout Section
5361 \start_of_appendix 
5362 FAQ
5363 \layout Subsection*
5364
5365 Vorbis is open-source
5366 \begin_inset LatexCommand \index{open-source}
5367
5368 \end_inset 
5369
5370  and patent-free
5371 \begin_inset LatexCommand \index{patent}
5372
5373 \end_inset 
5374
5375 , why do we need Speex?
5376 \layout Standard
5377
5378 Vorbis is a great project but its goals are not the same as Speex.
5379  Vorbis is mostly aimed at compressing music and audio in general, while
5380  Speex targets speech only.
5381  For that reason Speex can achieve much better results than Vorbis on speech,
5382  typically 2-4 times higher compression at equal quality.
5383 \layout Subsection*
5384
5385 Isn't there a GPL implementation of the GSM-FR codec? Why is Speex necessary?
5386 \layout Standard
5387
5388 First of all, it's not clear whether or not GSM-FR is covered by a phillips
5389  patent (see http://kbs.cs.tu-berlin.de/~jutta/toast.html).
5390  Also, GSM-FR offers mediocre quality at a relatively high bit-rate, while
5391  Speex can offer equivalent quality at almost half the bit-rate.
5392  Last but not least, Speex offers a wide range of bit-rates and sampling
5393  rates, while GSM-FR is limited to 8 kHz speech at 13 kbps.
5394 \layout Subsection*
5395
5396 Under what license is Speex released?
5397 \layout Standard
5398
5399 As of version 1.0 beta 1, Speex in released under Xiph's BSD-like license.
5400  This license is the most permissive of the open-source licenses.
5401 \layout Subsection*
5402
5403 Ogg
5404 \begin_inset LatexCommand \index{Ogg}
5405
5406 \end_inset 
5407
5408 , Speex, Vorbis
5409 \begin_inset LatexCommand \index{Vorbis}
5410
5411 \end_inset 
5412
5413 , what's the difference?
5414 \layout Standard
5415
5416 Ogg is a 
5417 \begin_inset Quotes eld
5418 \end_inset 
5419
5420 container format
5421 \begin_inset Quotes erd
5422 \end_inset 
5423
5424  for holding multimedia data.
5425  Vorbis is an audio codec that uses Ogg to store its bit-streams as files,
5426  hence the name Ogg Vorbis.
5427  Speex also uses the Ogg format to store its bit-streams as files, so technicall