1#LyX 1.6.1 created this file. For more info see http://www.lyx.org/ 2\lyxformat 345 3\begin_document 4\begin_header 5\textclass scrbook 6\use_default_options true 7\language english 8\inputencoding auto 9\font_roman default 10\font_sans default 11\font_typewriter default 12\font_default_family default 13\font_sc false 14\font_osf false 15\font_sf_scale 100 16\font_tt_scale 100 17 18\graphics default 19\paperfontsize 10 20\spacing single 21\use_hyperref false 22\papersize letterpaper 23\use_geometry true 24\use_amsmath 2 25\use_esint 2 26\cite_engine basic 27\use_bibtopic false 28\paperorientation portrait 29\leftmargin 2cm 30\topmargin 2cm 31\rightmargin 2cm 32\bottommargin 2cm 33\secnumdepth 3 34\tocdepth 3 35\paragraph_separation indent 36\defskip medskip 37\quotes_language english 38\papercolumns 1 39\papersides 1 40\paperpagestyle headings 41\tracking_changes false 42\output_changes false 43\author "" 44\author "" 45\end_header 46 47\begin_body 48 49\begin_layout Title 50The Speex Manual 51\begin_inset Newline newline 52\end_inset 53 54Version 1.2 55\end_layout 56 57\begin_layout Author 58Jean-Marc Valin 59\end_layout 60 61\begin_layout Standard 62\begin_inset Newpage newpage 63\end_inset 64 65 66\end_layout 67 68\begin_layout Standard 69Copyright 70\begin_inset ERT 71status collapsed 72 73\begin_layout Plain Layout 74 75 76\backslash 77copyright 78\end_layout 79 80\end_inset 81 82 2002-2008 Jean-Marc Valin/Xiph.org Foundation 83\end_layout 84 85\begin_layout Standard 86Permission is granted to copy, distribute and/or modify this document under 87 the terms of the GNU Free Documentation License, Version 1.1 or any later 88 version published by the Free Software Foundation; with no Invariant Section, 89 with no Front-Cover Texts, and with no Back-Cover. 90 A copy of the license is included in the section entitled "GNU Free Documentati 91on License". 92 93\end_layout 94 95\begin_layout Standard 96\begin_inset Newpage newpage 97\end_inset 98 99 100\begin_inset CommandInset toc 101LatexCommand tableofcontents 102 103\end_inset 104 105 106\begin_inset Newpage newpage 107\end_inset 108 109 110\end_layout 111 112\begin_layout Standard 113\begin_inset FloatList table 114 115\end_inset 116 117 118\begin_inset Newpage newpage 119\end_inset 120 121 122\end_layout 123 124\begin_layout Chapter 125Introduction to Speex 126\end_layout 127 128\begin_layout Standard 129The Speex codec ( 130\family typewriter 131http://www.speex.org/ 132\family default 133) exists because there is a need for a speech codec that is open-source 134 and free from software patent royalties. 135 These are essential conditions for being usable in any open-source software. 136 In essence, Speex is to speech what Vorbis is to audio/music. 137 Unlike many other speech codecs, Speex is not designed for mobile phones 138 but rather for packet networks and voice over IP (VoIP) applications. 139 File-based compression is of course also supported. 140 141\end_layout 142 143\begin_layout Standard 144The Speex codec is designed to be very flexible and support a wide range 145 of speech quality and bit-rate. 146 Support for very good quality speech also means that Speex can encode wideband 147 speech (16 kHz sampling rate) in addition to narrowband speech (telephone 148 quality, 8 kHz sampling rate). 149\end_layout 150 151\begin_layout Standard 152Designing for VoIP instead of mobile phones means that Speex is robust to 153 lost packets, but not to corrupted ones. 154 This is based on the assumption that in VoIP, packets either arrive unaltered 155 or don't arrive at all. 156 Because Speex is targeted at a wide range of devices, it has modest (adjustable 157) complexity and a small memory footprint. 158\end_layout 159 160\begin_layout Standard 161All the design goals led to the choice of CELP 162\begin_inset Index 163status collapsed 164 165\begin_layout Plain Layout 166CELP 167\end_layout 168 169\end_inset 170 171 as the encoding technique. 172 One of the main reasons is that CELP has long proved that it could work 173 reliably and scale well to both low bit-rates (e.g. 174 DoD CELP @ 4.8 kbps) and high bit-rates (e.g. 175 G.728 @ 16 kbps). 176 177\end_layout 178 179\begin_layout Section 180Getting help 181\begin_inset CommandInset label 182LatexCommand label 183name "sec:Getting-help" 184 185\end_inset 186 187 188\end_layout 189 190\begin_layout Standard 191As for many open source projects, there are many ways to get help with Speex. 192 These include: 193\end_layout 194 195\begin_layout Itemize 196This manual 197\end_layout 198 199\begin_layout Itemize 200Other documentation on the Speex website (http://www.speex.org/) 201\end_layout 202 203\begin_layout Itemize 204Mailing list: Discuss any Speex-related topic on speex-dev@xiph.org (not 205 just for developers) 206\end_layout 207 208\begin_layout Itemize 209IRC: The main channel is #speex on irc.freenode.net. 210 Note that due to time differences, it may take a while to get someone, 211 so please be patient. 212\end_layout 213 214\begin_layout Itemize 215Email the author privately at jean-marc.valin@usherbrooke.ca 216\series bold 217only 218\series default 219 for private/delicate topics you do not wish to discuss publicly. 220\end_layout 221 222\begin_layout Standard 223Before asking for help (mailing list or IRC), 224\series bold 225it is important to first read this manual 226\series default 227 (OK, so if you made it here it's already a good sign). 228 It is generally considered rude to ask on a mailing list about topics that 229 are clearly detailed in the documentation. 230 On the other hand, it's perfectly OK (and encouraged) to ask for clarifications 231 about something covered in the manual. 232 This manual does not (yet) cover everything about Speex, so everyone is 233 encouraged to ask questions, send comments, feature requests, or just let 234 us know how Speex is being used. 235 236\end_layout 237 238\begin_layout Standard 239Here are some additional guidelines related to the mailing list. 240 Before reporting bugs in Speex to the list, it is strongly recommended 241 (if possible) to first test whether these bugs can be reproduced using 242 the speexenc and speexdec (see Section 243\begin_inset CommandInset ref 244LatexCommand ref 245reference "sec:Command-line-encoder/decoder" 246 247\end_inset 248 249) command-line utilities. 250 Bugs reported based on 3rd party code are both harder to find and far too 251 often caused by errors that have nothing to do with Speex. 252 253\end_layout 254 255\begin_layout Section 256About this document 257\end_layout 258 259\begin_layout Standard 260This document is divided in the following way. 261 Section 262\begin_inset CommandInset ref 263LatexCommand ref 264reference "sec:Feature-description" 265 266\end_inset 267 268 describes the different Speex features and defines many basic terms that 269 are used throughout this manual. 270 Section 271\begin_inset CommandInset ref 272LatexCommand ref 273reference "sec:Command-line-encoder/decoder" 274 275\end_inset 276 277 documents the standard command-line tools provided in the Speex distribution. 278 Section 279\begin_inset CommandInset ref 280LatexCommand ref 281reference "sec:Programming-with-Speex" 282 283\end_inset 284 285 includes detailed instructions about programming using the libspeex 286\begin_inset Index 287status collapsed 288 289\begin_layout Plain Layout 290libspeex 291\end_layout 292 293\end_inset 294 295 API. 296 Section 297\begin_inset CommandInset ref 298LatexCommand ref 299reference "sec:Formats-and-standards" 300 301\end_inset 302 303 has some information related to Speex and standards. 304 305\end_layout 306 307\begin_layout Standard 308The three last sections describe the algorithms used in Speex. 309 These sections require signal processing knowledge, but are not required 310 for merely using Speex. 311 They are intended for people who want to understand how Speex really works 312 and/or want to do research based on Speex. 313 Section 314\begin_inset CommandInset ref 315LatexCommand ref 316reference "sec:Introduction-to-CELP" 317 318\end_inset 319 320 explains the general idea behind CELP, while sections 321\begin_inset CommandInset ref 322LatexCommand ref 323reference "sec:Speex-narrowband-mode" 324 325\end_inset 326 327 and 328\begin_inset CommandInset ref 329LatexCommand ref 330reference "sec:Speex-wideband-mode" 331 332\end_inset 333 334 are specific to Speex. 335\end_layout 336 337\begin_layout Standard 338\begin_inset Newpage newpage 339\end_inset 340 341 342\end_layout 343 344\begin_layout Chapter 345Codec description 346\begin_inset CommandInset label 347LatexCommand label 348name "sec:Feature-description" 349 350\end_inset 351 352 353\end_layout 354 355\begin_layout Standard 356This section describes Speex and its features into more details. 357\end_layout 358 359\begin_layout Section 360Concepts 361\end_layout 362 363\begin_layout Standard 364Before introducing all the Speex features, here are some concepts in speech 365 coding that help better understand the rest of the manual. 366 Although some are general concepts in speech/audio processing, others are 367 specific to Speex. 368\end_layout 369 370\begin_layout Subsection* 371Sampling rate 372\begin_inset Index 373status collapsed 374 375\begin_layout Plain Layout 376sampling rate 377\end_layout 378 379\end_inset 380 381 382\end_layout 383 384\begin_layout Standard 385The sampling rate expressed in Hertz (Hz) is the number of samples taken 386 from a signal per second. 387 For a sampling rate of 388\begin_inset Formula $F_{s}$ 389\end_inset 390 391 kHz, the highest frequency that can be represented is equal to 392\begin_inset Formula $F_{s}/2$ 393\end_inset 394 395 kHz ( 396\begin_inset Formula $F_{s}/2$ 397\end_inset 398 399 is known as the Nyquist frequency). 400 This is a fundamental property in signal processing and is described by 401 the sampling theorem. 402 Speex is mainly designed for three different sampling rates: 8 kHz, 16 403 kHz, and 32 kHz. 404 These are respectively referred to as narrowband 405\begin_inset Index 406status collapsed 407 408\begin_layout Plain Layout 409narrowband 410\end_layout 411 412\end_inset 413 414, wideband 415\begin_inset Index 416status collapsed 417 418\begin_layout Plain Layout 419wideband 420\end_layout 421 422\end_inset 423 424 and ultra-wideband 425\begin_inset Index 426status collapsed 427 428\begin_layout Plain Layout 429ultra-wideband 430\end_layout 431 432\end_inset 433 434. 435 436\end_layout 437 438\begin_layout Subsection* 439Bit-rate 440\end_layout 441 442\begin_layout Standard 443When encoding a speech signal, the bit-rate is defined as the number of 444 bits per unit of time required to encode the speech. 445 It is measured in 446\emph on 447bits per second 448\emph default 449 (bps), or generally 450\emph on 451kilobits per second 452\emph default 453. 454 It is important to make the distinction between 455\emph on 456kilo 457\series bold 458bits 459\series default 460\emph default 461 462\emph on 463per second 464\emph default 465 (k 466\series bold 467b 468\series default 469ps) and 470\emph on 471kilo 472\series bold 473bytes 474\series default 475\emph default 476 477\emph on 478per second 479\emph default 480 (k 481\series bold 482B 483\series default 484ps). 485\end_layout 486 487\begin_layout Subsection* 488Quality 489\begin_inset Index 490status collapsed 491 492\begin_layout Plain Layout 493quality 494\end_layout 495 496\end_inset 497 498 (variable) 499\end_layout 500 501\begin_layout Standard 502Speex is a lossy codec, which means that it achieves compression at the 503 expense of fidelity of the input speech signal. 504 Unlike some other speech codecs, it is possible to control the trade-off 505 made between quality and bit-rate. 506 The Speex encoding process is controlled most of the time by a quality 507 parameter that ranges from 0 to 10. 508 In constant bit-rate 509\begin_inset Index 510status collapsed 511 512\begin_layout Plain Layout 513constant bit-rate 514\end_layout 515 516\end_inset 517 518 (CBR) operation, the quality parameter is an integer, while for variable 519 bit-rate (VBR), the parameter is a float. 520 521\end_layout 522 523\begin_layout Subsection* 524Complexity 525\begin_inset Index 526status collapsed 527 528\begin_layout Plain Layout 529complexity 530\end_layout 531 532\end_inset 533 534 (variable) 535\end_layout 536 537\begin_layout Standard 538With Speex, it is possible to vary the complexity allowed for the encoder. 539 This is done by controlling how the search is performed with an integer 540 ranging from 1 to 10 in a way that's similar to the -1 to -9 options to 541 542\emph on 543gzip 544\emph default 545 and 546\emph on 547bzip2 548\emph default 549 compression utilities. 550 For normal use, the noise level at complexity 1 is between 1 and 2 dB higher 551 than at complexity 10, but the CPU requirements for complexity 10 is about 552 5 times higher than for complexity 1. 553 In practice, the best trade-off is between complexity 2 and 4, though higher 554 settings are often useful when encoding non-speech sounds like DTMF 555\begin_inset Index 556status collapsed 557 558\begin_layout Plain Layout 559DTMF 560\end_layout 561 562\end_inset 563 564 tones. 565\end_layout 566 567\begin_layout Subsection* 568Variable Bit-Rate 569\begin_inset Index 570status collapsed 571 572\begin_layout Plain Layout 573variable bit-rate 574\end_layout 575 576\end_inset 577 578 (VBR) 579\end_layout 580 581\begin_layout Standard 582Variable bit-rate (VBR) allows a codec to change its bit-rate dynamically 583 to adapt to the 584\begin_inset Quotes eld 585\end_inset 586 587difficulty 588\begin_inset Quotes erd 589\end_inset 590 591 of the audio being encoded. 592 In the example of Speex, sounds like vowels and high-energy transients 593 require a higher bit-rate to achieve good quality, while fricatives (e.g. 594 s,f sounds) can be coded adequately with less bits. 595 For this reason, VBR can achieve lower bit-rate for the same quality, or 596 a better quality for a certain bit-rate. 597 Despite its advantages, VBR has two main drawbacks: first, by only specifying 598 quality, there's no guaranty about the final average bit-rate. 599 Second, for some real-time applications like voice over IP (VoIP), what 600 counts is the maximum bit-rate, which must be low enough for the communication 601 channel. 602\end_layout 603 604\begin_layout Subsection* 605Average Bit-Rate 606\begin_inset Index 607status collapsed 608 609\begin_layout Plain Layout 610average bit-rate 611\end_layout 612 613\end_inset 614 615 (ABR) 616\end_layout 617 618\begin_layout Standard 619Average bit-rate solves one of the problems of VBR, as it dynamically adjusts 620 VBR quality in order to meet a specific target bit-rate. 621 Because the quality/bit-rate is adjusted in real-time (open-loop), the 622 global quality will be slightly lower than that obtained by encoding in 623 VBR with exactly the right quality setting to meet the target average bit-rate. 624\end_layout 625 626\begin_layout Subsection* 627Voice Activity Detection 628\begin_inset Index 629status collapsed 630 631\begin_layout Plain Layout 632voice activity detection 633\end_layout 634 635\end_inset 636 637 (VAD) 638\end_layout 639 640\begin_layout Standard 641When enabled, voice activity detection detects whether the audio being encoded 642 is speech or silence/background noise. 643 VAD is always implicitly activated when encoding in VBR, so the option 644 is only useful in non-VBR operation. 645 In this case, Speex detects non-speech periods and encode them with just 646 enough bits to reproduce the background noise. 647 This is called 648\begin_inset Quotes eld 649\end_inset 650 651comfort noise generation 652\begin_inset Quotes erd 653\end_inset 654 655 (CNG). 656\end_layout 657 658\begin_layout Subsection* 659Discontinuous Transmission 660\begin_inset Index 661status collapsed 662 663\begin_layout Plain Layout 664discontinuous transmission 665\end_layout 666 667\end_inset 668 669 (DTX) 670\end_layout 671 672\begin_layout Standard 673Discontinuous transmission is an addition to VAD/VBR operation, that allows 674 to stop transmitting completely when the background noise is stationary. 675 In file-based operation, since we cannot just stop writing to the file, 676 only 5 bits are used for such frames (corresponding to 250 bps). 677\end_layout 678 679\begin_layout Subsection* 680Perceptual enhancement 681\begin_inset Index 682status collapsed 683 684\begin_layout Plain Layout 685perceptual enhancement 686\end_layout 687 688\end_inset 689 690 691\end_layout 692 693\begin_layout Standard 694Perceptual enhancement is a part of the decoder which, when turned on, attempts 695 to reduce the perception of the noise/distortion produced by the encoding/decod 696ing process. 697 In most cases, perceptual enhancement brings the sound further from the 698 original 699\emph on 700objectively 701\emph default 702 (e.g. 703 considering only SNR), but in the end it still 704\emph on 705sounds 706\emph default 707 better (subjective improvement). 708\end_layout 709 710\begin_layout Subsection* 711Latency and algorithmic delay 712\begin_inset Index 713status collapsed 714 715\begin_layout Plain Layout 716algorithmic delay 717\end_layout 718 719\end_inset 720 721 722\end_layout 723 724\begin_layout Standard 725Every speech codec introduces a delay in the transmission. 726 For Speex, this delay is equal to the frame size, plus some amount of 727\begin_inset Quotes eld 728\end_inset 729 730look-ahead 731\begin_inset Quotes erd 732\end_inset 733 734 required to process each frame. 735 In narrowband operation (8 kHz), the look-ahead is 10 ms, in wideband operation 736 (16 kHz), the look-ahead is 13.9 ms and in ultra-wideband operation (32 737 kHz) look-ahead is 15.9 ms, resulting in the algorithic delays of 30 ms, 738 33.9 ms and 35.9 ms accordingly. 739 These values don't account for the CPU time it takes to encode or decode 740 the frames. 741\end_layout 742 743\begin_layout Section 744Codec 745\end_layout 746 747\begin_layout Standard 748The main characteristics of Speex can be summarized as follows: 749\end_layout 750 751\begin_layout Itemize 752Free software/open-source 753\begin_inset Index 754status collapsed 755 756\begin_layout Plain Layout 757open-source 758\end_layout 759 760\end_inset 761 762, patent 763\begin_inset Index 764status collapsed 765 766\begin_layout Plain Layout 767patent 768\end_layout 769 770\end_inset 771 772 and royalty-free 773\end_layout 774 775\begin_layout Itemize 776Integration of narrowband 777\begin_inset Index 778status collapsed 779 780\begin_layout Plain Layout 781narrowband 782\end_layout 783 784\end_inset 785 786 and wideband 787\begin_inset Index 788status collapsed 789 790\begin_layout Plain Layout 791wideband 792\end_layout 793 794\end_inset 795 796 using an embedded bit-stream 797\end_layout 798 799\begin_layout Itemize 800Wide range of bit-rates available (from 2.15 kbps to 44 kbps) 801\end_layout 802 803\begin_layout Itemize 804Dynamic bit-rate switching (AMR) and Variable Bit-Rate 805\begin_inset Index 806status collapsed 807 808\begin_layout Plain Layout 809variable bit-rate 810\end_layout 811 812\end_inset 813 814 (VBR) operation 815\end_layout 816 817\begin_layout Itemize 818Voice Activity Detection 819\begin_inset Index 820status collapsed 821 822\begin_layout Plain Layout 823voice activity detection 824\end_layout 825 826\end_inset 827 828 (VAD, integrated with VBR) and discontinuous transmission (DTX) 829\end_layout 830 831\begin_layout Itemize 832Variable complexity 833\begin_inset Index 834status collapsed 835 836\begin_layout Plain Layout 837complexity 838\end_layout 839 840\end_inset 841 842 843\end_layout 844 845\begin_layout Itemize 846Embedded wideband structure (scalable sampling rate) 847\end_layout 848 849\begin_layout Itemize 850Ultra-wideband sampling rate at 32 kHz 851\end_layout 852 853\begin_layout Itemize 854Intensity stereo encoding option 855\end_layout 856 857\begin_layout Itemize 858Fixed-point implementation 859\end_layout 860 861\begin_layout Section 862Preprocessor 863\end_layout 864 865\begin_layout Standard 866This part refers to the preprocessor module introduced in the 1.1.x branch. 867 The preprocessor is designed to be used on the audio 868\emph on 869before 870\emph default 871 running the encoder. 872 The preprocessor provides three main functionalities: 873\end_layout 874 875\begin_layout Itemize 876noise suppression 877\end_layout 878 879\begin_layout Itemize 880automatic gain control (AGC) 881\end_layout 882 883\begin_layout Itemize 884voice activity detection (VAD) 885\end_layout 886 887\begin_layout Standard 888The denoiser can be used to reduce the amount of background noise present 889 in the input signal. 890 This provides higher quality speech whether or not the denoised signal 891 is encoded with Speex (or at all). 892 However, when using the denoised signal with the codec, there is an additional 893 benefit. 894 Speech codecs in general (Speex included) tend to perform poorly on noisy 895 input, which tends to amplify the noise. 896 The denoiser greatly reduces this effect. 897\end_layout 898 899\begin_layout Standard 900Automatic gain control (AGC) is a feature that deals with the fact that 901 the recording volume may vary by a large amount between different setups. 902 The AGC provides a way to adjust a signal to a reference volume. 903 This is useful for voice over IP because it removes the need for manual 904 adjustment of the microphone gain. 905 A secondary advantage is that by setting the microphone gain to a conservative 906 (low) level, it is easier to avoid clipping. 907\end_layout 908 909\begin_layout Standard 910The voice activity detector (VAD) provided by the preprocessor is more advanced 911 than the one directly provided in the codec. 912 913\end_layout 914 915\begin_layout Section 916Adaptive Jitter Buffer 917\end_layout 918 919\begin_layout Standard 920When transmitting voice (or any content for that matter) over UDP or RTP, 921 packet may be lost, arrive with different delay, or even out of order. 922 The purpose of a jitter buffer is to reorder packets and buffer them long 923 enough (but no longer than necessary) so they can be sent to be decoded. 924 925\end_layout 926 927\begin_layout Section 928Acoustic Echo Canceller 929\end_layout 930 931\begin_layout Standard 932In any hands-free communication system (Fig. 933 934\begin_inset CommandInset ref 935LatexCommand ref 936reference "fig:Acoustic-echo-model" 937 938\end_inset 939 940), speech from the remote end is played in the local loudspeaker, propagates 941 in the room and is captured by the microphone. 942 If the audio captured from the microphone is sent directly to the remote 943 end, then the remote user hears an echo of his voice. 944 An acoustic echo canceller is designed to remove the acoustic echo before 945 it is sent to the remote end. 946 It is important to understand that the echo canceller is meant to improve 947 the quality on the 948\series bold 949remote 950\series default 951 end. 952 For those who care a lot about mouth-to-ear delays it should be noted that 953 unlike Speex codec, resampler and preprocessor, this Acoustic Echo Canceller 954 does not introduce any latency. 955\end_layout 956 957\begin_layout Standard 958\begin_inset Float figure 959wide false 960sideways false 961status open 962 963\begin_layout Plain Layout 964\begin_inset ERT 965status collapsed 966 967\begin_layout Plain Layout 968 969 970\backslash 971begin{center} 972\end_layout 973 974\end_inset 975 976 977\begin_inset Graphics 978 filename echo_path.eps 979 width 10cm 980 981\end_inset 982 983 984\begin_inset ERT 985status collapsed 986 987\begin_layout Plain Layout 988 989 990\backslash 991end{center} 992\end_layout 993 994\end_inset 995 996 997\end_layout 998 999\begin_layout Plain Layout 1000\begin_inset Caption 1001 1002\begin_layout Plain Layout 1003Acoustic echo model 1004\begin_inset CommandInset label 1005LatexCommand label 1006name "fig:Acoustic-echo-model" 1007 1008\end_inset 1009 1010 1011\end_layout 1012 1013\end_inset 1014 1015 1016\end_layout 1017 1018\end_inset 1019 1020 1021\end_layout 1022 1023\begin_layout Section 1024Resampler 1025\end_layout 1026 1027\begin_layout Standard 1028In some cases, it may be useful to convert audio from one sampling rate 1029 to another. 1030 There are many reasons for that. 1031 It can be for mixing streams that have different sampling rates, for supporting 1032 sampling rates that the soundcard doesn't support, for transcoding, etc. 1033 That's why there is now a resampler that is part of the Speex project. 1034 This resampler can be used to convert between any two arbitrary rates (the 1035 ratio must only be a rational number) and there is control over the quality/com 1036plexity tradeoff. 1037 Keep in mind, that resampler introduce some delay in audio stream, which 1038 size depends on resampler quality setting. 1039 Refer to resampler API documentation to know how to get exact delay values. 1040\end_layout 1041 1042\begin_layout Section 1043Integration 1044\end_layout 1045 1046\begin_layout Standard 1047Knowing 1048\emph on 1049how 1050\emph default 1051 to use each of the components is not that useful unless we know 1052\emph on 1053where 1054\emph default 1055 to use them. 1056 Figure 1057\begin_inset CommandInset ref 1058LatexCommand ref 1059reference "fig:Integration-VoIP" 1060 1061\end_inset 1062 1063 shows where each of the components would be used in a typical VoIP client. 1064 Components in dotted lines are optional, though they may be very useful 1065 in some circumstances. 1066 There are several important things to note from there. 1067 The AEC must be placed as close as possible to the playback and capture. 1068 Only the resampling may be closer. 1069 Also, it is very important to use the same clock for both mic capture and 1070 speaker/headphones playback. 1071\end_layout 1072 1073\begin_layout Standard 1074\begin_inset Float figure 1075wide false 1076sideways false 1077status open 1078 1079\begin_layout Plain Layout 1080\begin_inset ERT 1081status collapsed 1082 1083\begin_layout Plain Layout 1084 1085 1086\backslash 1087begin{center} 1088\end_layout 1089 1090\end_inset 1091 1092 1093\begin_inset Graphics 1094 filename components.eps 1095 width 80text% 1096 1097\end_inset 1098 1099 1100\begin_inset ERT 1101status collapsed 1102 1103\begin_layout Plain Layout 1104 1105 1106\backslash 1107end{center} 1108\end_layout 1109 1110\end_inset 1111 1112 1113\end_layout 1114 1115\begin_layout Plain Layout 1116\begin_inset Caption 1117 1118\begin_layout Plain Layout 1119Integration of all the components in a VoIP client. 1120\begin_inset CommandInset label 1121LatexCommand label 1122name "fig:Integration-VoIP" 1123 1124\end_inset 1125 1126 1127\end_layout 1128 1129\end_inset 1130 1131 1132\end_layout 1133 1134\end_inset 1135 1136 1137\end_layout 1138 1139\begin_layout Standard 1140\begin_inset Newpage newpage 1141\end_inset 1142 1143 1144\end_layout 1145 1146\begin_layout Chapter 1147Compiling and Porting 1148\end_layout 1149 1150\begin_layout Standard 1151Compiling Speex under UNIX/Linux or any other platform supported by autoconf 1152 (e.g. 1153 Win32/cygwin) is as easy as typing: 1154\end_layout 1155 1156\begin_layout LyX-Code 1157% ./configure [options] 1158\end_layout 1159 1160\begin_layout LyX-Code 1161% make 1162\end_layout 1163 1164\begin_layout LyX-Code 1165% make install 1166\end_layout 1167 1168\begin_layout Standard 1169The options supported by the Speex configure script are: 1170\end_layout 1171 1172\begin_layout Description 1173--prefix=<path> Specifies the base path for installing Speex (e.g. 1174 /usr) 1175\end_layout 1176 1177\begin_layout Description 1178--enable-shared/--disable-shared Whether to compile shared libraries 1179\end_layout 1180 1181\begin_layout Description 1182--enable-static/--disable-static Whether to compile static libraries 1183\end_layout 1184 1185\begin_layout Description 1186--disable-wideband Disable the wideband part of Speex (typically to save 1187 space) 1188\end_layout 1189 1190\begin_layout Description 1191--enable-valgrind Enable extra hits for valgrind for debugging purposes 1192 (do not use by default) 1193\end_layout 1194 1195\begin_layout Description 1196--enable-sse Enable use of SSE instructions (x86/float only) 1197\end_layout 1198 1199\begin_layout Description 1200--enable-fixed-point 1201\begin_inset Index 1202status collapsed 1203 1204\begin_layout Plain Layout 1205fixed-point 1206\end_layout 1207 1208\end_inset 1209 1210 Compile Speex for a processor that does not have a floating point unit 1211 (FPU) 1212\end_layout 1213 1214\begin_layout Description 1215--enable-arm4-asm Enable assembly specific to the ARMv4 architecture (gcc 1216 only) 1217\end_layout 1218 1219\begin_layout Description 1220--enable-arm5e-asm Enable assembly specific to the ARMv5E architecture (gcc 1221 only) 1222\end_layout 1223 1224\begin_layout Description 1225--enable-fixed-point-debug Use only for debugging the fixed-point 1226\begin_inset Index 1227status collapsed 1228 1229\begin_layout Plain Layout 1230fixed-point 1231\end_layout 1232 1233\end_inset 1234 1235 code (very slow) 1236\end_layout 1237 1238\begin_layout Description 1239--enable-ti-c55x Enable support for the TI C5x family 1240\end_layout 1241 1242\begin_layout Description 1243--enable-blackfin-asm Enable assembly specific to the Blackfin DSP architecture 1244 (gcc only) 1245\end_layout 1246 1247\begin_layout Section 1248Platforms 1249\end_layout 1250 1251\begin_layout Standard 1252Speex is known to compile and work on a large number of architectures, both 1253 floating-point and fixed-point. 1254 In general, any architecture that can natively compute the multiplication 1255 of two signed 16-bit numbers (32-bit result) and runs at a sufficient clock 1256 rate (architecture-dependent) is capable of running Speex. 1257 Architectures on which Speex is 1258\series bold 1259known 1260\series default 1261 to work (it probably works on many others) are: 1262\end_layout 1263 1264\begin_layout Itemize 1265x86 & x86-64 1266\end_layout 1267 1268\begin_layout Itemize 1269Power 1270\end_layout 1271 1272\begin_layout Itemize 1273SPARC 1274\end_layout 1275 1276\begin_layout Itemize 1277ARM 1278\end_layout 1279 1280\begin_layout Itemize 1281Blackfin 1282\end_layout 1283 1284\begin_layout Itemize 1285Coldfire (68k family) 1286\end_layout 1287 1288\begin_layout Itemize 1289TI C54xx & C55xx 1290\end_layout 1291 1292\begin_layout Itemize 1293TI C6xxx 1294\end_layout 1295 1296\begin_layout Itemize 1297TriMedia (experimental) 1298\end_layout 1299 1300\begin_layout Standard 1301Operating systems on top of which Speex is known to work include (it probably 1302 works on many others): 1303\end_layout 1304 1305\begin_layout Itemize 1306Linux 1307\end_layout 1308 1309\begin_layout Itemize 1310\begin_inset Formula $\mu$ 1311\end_inset 1312 1313Clinux 1314\end_layout 1315 1316\begin_layout Itemize 1317MacOS X 1318\end_layout 1319 1320\begin_layout Itemize 1321BSD 1322\end_layout 1323 1324\begin_layout Itemize 1325Other UNIX/POSIX variants 1326\end_layout 1327 1328\begin_layout Itemize 1329Symbian 1330\end_layout 1331 1332\begin_layout Standard 1333The source code directory include additional information for compiling on 1334 certain architectures or operating systems in README.xxx files. 1335\end_layout 1336 1337\begin_layout Section 1338Porting and Optimising 1339\end_layout 1340 1341\begin_layout Standard 1342Here are a few things to consider when porting or optimising Speex for a 1343 new platform or an existing one. 1344\end_layout 1345 1346\begin_layout Subsection 1347CPU optimisation 1348\end_layout 1349 1350\begin_layout Standard 1351The single factor that will affect the CPU usage of Speex the most is whether 1352 it is compiled for floating point or fixed-point. 1353 If your CPU/DSP does not have a floating-point unit FPU, then compiling 1354 as fixed-point will be orders of magnitudes faster. 1355 If there is an FPU present, then it is important to test which version 1356 is faster. 1357 On the x86 architecture, floating-point is 1358\series bold 1359generally 1360\series default 1361 faster, but not always. 1362 To compile Speex as fixed-point, you need to pass --fixed-point to the 1363 configure script or define the FIXED_POINT macro for the compiler. 1364 As of 1.2beta3, it is now possible to disable the floating-point compatibility 1365 API, which means that your code can link without a float emulation library. 1366 To do that configure with --disable-float-api or define the DISABLE_FLOAT_API 1367 macro. 1368 Until the VBR feature is ported to fixed-point, you will also need to configure 1369 with --disable-vbr or define DISABLE_VBR. 1370\end_layout 1371 1372\begin_layout Standard 1373Other important things to check on some DSP architectures are: 1374\end_layout 1375 1376\begin_layout Itemize 1377Make sure the cache is set to write-back mode 1378\end_layout 1379 1380\begin_layout Itemize 1381If the chip has SRAM instead of cache, make sure as much code and data are 1382 in SRAM, rather than in RAM 1383\end_layout 1384 1385\begin_layout Standard 1386If you are going to be writing assembly, then the following functions are 1387 1388\series bold 1389usually 1390\series default 1391 the first ones you should consider optimising: 1392\end_layout 1393 1394\begin_layout Itemize 1395\begin_inset listings 1396inline true 1397status collapsed 1398 1399\begin_layout Plain Layout 1400 1401filter_mem16() 1402\end_layout 1403 1404\end_inset 1405 1406 1407\end_layout 1408 1409\begin_layout Itemize 1410\begin_inset listings 1411inline true 1412status collapsed 1413 1414\begin_layout Plain Layout 1415 1416iir_mem16() 1417\end_layout 1418 1419\end_inset 1420 1421 1422\end_layout 1423 1424\begin_layout Itemize 1425\begin_inset listings 1426inline true 1427status collapsed 1428 1429\begin_layout Plain Layout 1430 1431vq_nbest() 1432\end_layout 1433 1434\end_inset 1435 1436 1437\end_layout 1438 1439\begin_layout Itemize 1440\begin_inset listings 1441inline true 1442status collapsed 1443 1444\begin_layout Plain Layout 1445 1446pitch_xcorr() 1447\end_layout 1448 1449\end_inset 1450 1451 1452\end_layout 1453 1454\begin_layout Itemize 1455\begin_inset listings 1456inline true 1457status collapsed 1458 1459\begin_layout Plain Layout 1460 1461interp_pitch() 1462\end_layout 1463 1464\end_inset 1465 1466 1467\end_layout 1468 1469\begin_layout Standard 1470The filtering functions 1471\begin_inset listings 1472inline true 1473status collapsed 1474 1475\begin_layout Plain Layout 1476 1477filter_mem16() 1478\end_layout 1479 1480\end_inset 1481 1482 and 1483\begin_inset listings 1484inline true 1485status collapsed 1486 1487\begin_layout Plain Layout 1488 1489iir_mem16() 1490\end_layout 1491 1492\end_inset 1493 1494 are implemented in the direct form II transposed (DF2T). 1495 However, for architectures based on multiply-accumulate (MAC), DF2T requires 1496 frequent reload of the accumulator, which can make the code very slow. 1497 For these architectures (e.g. 1498 Blackfin and Coldfire), a better approach is to implement those functions 1499 as direct form I (DF1), which is easier to express in terms of MAC. 1500 When doing that however, 1501\series bold 1502it is important to make sure that the DF1 implementation still behaves like 1503 the original DF2T behaviour when it comes to memory values 1504\series default 1505. 1506 This is necessary because the filter is time-varying and must compute exactly 1507 the same value (not counting machine rounding) on any encoder or decoder. 1508\end_layout 1509 1510\begin_layout Subsection 1511Memory optimisation 1512\end_layout 1513 1514\begin_layout Standard 1515Memory optimisation is mainly something that should be considered for small 1516 embedded platforms. 1517 For PCs, Speex is already so tiny that it's just not worth doing any of 1518 the things suggested here. 1519 There are several ways to reduce the memory usage of Speex, both in terms 1520 of code size and data size. 1521 For optimising code size, the trick is to first remove features you do 1522 not need. 1523 Some examples of things that can easily be disabled 1524\series bold 1525if you don't need them 1526\series default 1527 are: 1528\end_layout 1529 1530\begin_layout Itemize 1531Wideband support (--disable-wideband) 1532\end_layout 1533 1534\begin_layout Itemize 1535Support for stereo (removing stereo.c) 1536\end_layout 1537 1538\begin_layout Itemize 1539VBR support (--disable-vbr or DISABLE_VBR) 1540\end_layout 1541 1542\begin_layout Itemize 1543Static codebooks that are not needed for the bit-rates you are using (*_table.c 1544 files) 1545\end_layout 1546 1547\begin_layout Standard 1548Speex also has several methods for allocating temporary arrays. 1549 When using a compiler that supports C99 properly (as of 2007, Microsoft 1550 compilers don't, but gcc does), it is best to define VAR_ARRAYS. 1551 That makes use of the variable-size array feature of C99. 1552 The next best is to define USE_ALLOCA so that Speex can use alloca() to 1553 allocate the temporary arrays. 1554 Note that on many systems, alloca() is buggy so it may not work. 1555 If none of VAR_ARRAYS and USE_ALLOCA are defined, then Speex falls back 1556 to allocating a large 1557\begin_inset Quotes eld 1558\end_inset 1559 1560scratch space 1561\begin_inset Quotes erd 1562\end_inset 1563 1564 and doing its own internal allocation. 1565 The main disadvantage of this solution is that it is wasteful. 1566 It needs to allocate enough stack for the worst case scenario (worst bit-rate, 1567 highest complexity setting, ...) and by default, the memory isn't shared between 1568 multiple encoder/decoder states. 1569 Still, if the 1570\begin_inset Quotes eld 1571\end_inset 1572 1573manual 1574\begin_inset Quotes erd 1575\end_inset 1576 1577 allocation is the only option left, there are a few things that can be 1578 improved. 1579 By overriding the speex_alloc_scratch() call in os_support.h, it is possible 1580 to always return the same memory area for all states 1581\begin_inset Foot 1582status collapsed 1583 1584\begin_layout Plain Layout 1585In this case, one must be careful with threads 1586\end_layout 1587 1588\end_inset 1589 1590. 1591 In addition to that, by redefining the NB_ENC_STACK and NB_DEC_STACK (or 1592 similar for wideband), it is possible to only allocate memory for a scenario 1593 that is known in advance. 1594 In this case, it is important to measure the amount of memory required 1595 for the specific sampling rate, bit-rate and complexity level being used. 1596\end_layout 1597 1598\begin_layout Standard 1599\begin_inset Newpage newpage 1600\end_inset 1601 1602 1603\end_layout 1604 1605\begin_layout Chapter 1606Command-line encoder/decoder 1607\begin_inset CommandInset label 1608LatexCommand label 1609name "sec:Command-line-encoder/decoder" 1610 1611\end_inset 1612 1613 1614\end_layout 1615 1616\begin_layout Standard 1617The base Speex distribution includes a command-line encoder ( 1618\emph on 1619speexenc 1620\emph default 1621) and decoder ( 1622\emph on 1623speexdec 1624\emph default 1625). 1626 Those tools produce and read Speex files encapsulated in the Ogg container. 1627 Although it is possible to encapsulate Speex in any container, Ogg is the 1628 recommended container for files. 1629 This section describes how to use the command line tools for Speex files 1630 in Ogg. 1631\end_layout 1632 1633\begin_layout Section 1634 1635\emph on 1636speexenc 1637\begin_inset Index 1638status collapsed 1639 1640\begin_layout Plain Layout 1641speexenc 1642\end_layout 1643 1644\end_inset 1645 1646 1647\end_layout 1648 1649\begin_layout Standard 1650The 1651\emph on 1652speexenc 1653\emph default 1654 utility is used to create Speex files from raw PCM or wave files. 1655 It can be used by calling: 1656\end_layout 1657 1658\begin_layout LyX-Code 1659speexenc [options] input_file output_file 1660\end_layout 1661 1662\begin_layout Standard 1663The value '-' for input_file or output_file corresponds respectively to 1664 stdin and stdout. 1665 The valid options are: 1666\end_layout 1667 1668\begin_layout Description 1669--narrowband 1670\begin_inset space ~ 1671\end_inset 1672 1673(-n) Tell Speex to treat the input as narrowband (8 kHz). 1674 This is the default 1675\end_layout 1676 1677\begin_layout Description 1678--wideband 1679\begin_inset space ~ 1680\end_inset 1681 1682(-w) Tell Speex to treat the input as wideband (16 kHz) 1683\end_layout 1684 1685\begin_layout Description 1686--ultra-wideband 1687\begin_inset space ~ 1688\end_inset 1689 1690(-u) Tell Speex to treat the input as 1691\begin_inset Quotes eld 1692\end_inset 1693 1694ultra-wideband 1695\begin_inset Quotes erd 1696\end_inset 1697 1698 (32 kHz) 1699\end_layout 1700 1701\begin_layout Description 1702--quality 1703\begin_inset space ~ 1704\end_inset 1705 1706n Set the encoding quality (0-10), default is 8 1707\end_layout 1708 1709\begin_layout Description 1710--bitrate 1711\begin_inset space ~ 1712\end_inset 1713 1714n Encoding bit-rate (use bit-rate n or lower) 1715\end_layout 1716 1717\begin_layout Description 1718--vbr Enable VBR (Variable Bit-Rate), disabled by default 1719\end_layout 1720 1721\begin_layout Description 1722--abr 1723\begin_inset space ~ 1724\end_inset 1725 1726n Enable ABR (Average Bit-Rate) at n kbps, disabled by default 1727\end_layout 1728 1729\begin_layout Description 1730--vad Enable VAD (Voice Activity Detection), disabled by default 1731\end_layout 1732 1733\begin_layout Description 1734--dtx Enable DTX (Discontinuous Transmission), disabled by default 1735\end_layout 1736 1737\begin_layout Description 1738--nframes 1739\begin_inset space ~ 1740\end_inset 1741 1742n Pack n frames in each Ogg packet (this saves space at low bit-rates) 1743\end_layout 1744 1745\begin_layout Description 1746--comp 1747\begin_inset space ~ 1748\end_inset 1749 1750n Set encoding speed/quality tradeoff. 1751 The higher the value of n, the slower the encoding (default is 3) 1752\end_layout 1753 1754\begin_layout Description 1755-V Verbose operation, print bit-rate currently in use 1756\end_layout 1757 1758\begin_layout Description 1759--help 1760\begin_inset space ~ 1761\end_inset 1762 1763(-h) Print the help 1764\end_layout 1765 1766\begin_layout Description 1767--version 1768\begin_inset space ~ 1769\end_inset 1770 1771(-v) Print version information 1772\end_layout 1773 1774\begin_layout Subsection* 1775Speex comments 1776\end_layout 1777 1778\begin_layout Description 1779--comment Add the given string as an extra comment. 1780 This may be used multiple times. 1781 1782\end_layout 1783 1784\begin_layout Description 1785--author Author of this track. 1786 1787\end_layout 1788 1789\begin_layout Description 1790--title Title for this track. 1791 1792\end_layout 1793 1794\begin_layout Subsection* 1795Raw input options 1796\end_layout 1797 1798\begin_layout Description 1799--rate 1800\begin_inset space ~ 1801\end_inset 1802 1803n Sampling rate for raw input 1804\end_layout 1805 1806\begin_layout Description 1807--stereo Consider raw input as stereo 1808\end_layout 1809 1810\begin_layout Description 1811--le Raw input is little-endian 1812\end_layout 1813 1814\begin_layout Description 1815--be Raw input is big-endian 1816\end_layout 1817 1818\begin_layout Description 1819--8bit Raw input is 8-bit unsigned 1820\end_layout 1821 1822\begin_layout Description 1823--16bit Raw input is 16-bit signed 1824\end_layout 1825 1826\begin_layout Section 1827 1828\emph on 1829speexdec 1830\begin_inset Index 1831status collapsed 1832 1833\begin_layout Plain Layout 1834speexdec 1835\end_layout 1836 1837\end_inset 1838 1839 1840\end_layout 1841 1842\begin_layout Standard 1843The 1844\emph on 1845speexdec 1846\emph default 1847 utility is used to decode Speex files and can be used by calling: 1848\end_layout 1849 1850\begin_layout LyX-Code 1851speexdec [options] speex_file [output_file] 1852\end_layout 1853 1854\begin_layout Standard 1855The value '-' for input_file or output_file corresponds respectively to 1856 stdin and stdout. 1857 Also, when no output_file is specified, the file is played to the soundcard. 1858 The valid options are: 1859\end_layout 1860 1861\begin_layout Description 1862--enh enable post-filter (default) 1863\end_layout 1864 1865\begin_layout Description 1866--no-enh disable post-filter 1867\end_layout 1868 1869\begin_layout Description 1870--force-nb Force decoding in narrowband 1871\end_layout 1872 1873\begin_layout Description 1874--force-wb Force decoding in wideband 1875\end_layout 1876 1877\begin_layout Description 1878--force-uwb Force decoding in ultra-wideband 1879\end_layout 1880 1881\begin_layout Description 1882--mono Force decoding in mono 1883\end_layout 1884 1885\begin_layout Description 1886--stereo Force decoding in stereo 1887\end_layout 1888 1889\begin_layout Description 1890--rate 1891\begin_inset space ~ 1892\end_inset 1893 1894n Force decoding at n Hz sampling rate 1895\end_layout 1896 1897\begin_layout Description 1898--packet-loss 1899\begin_inset space ~ 1900\end_inset 1901 1902n Simulate n % random packet loss 1903\end_layout 1904 1905\begin_layout Description 1906-V Verbose operation, print bit-rate currently in use 1907\end_layout 1908 1909\begin_layout Description 1910--help 1911\begin_inset space ~ 1912\end_inset 1913 1914(-h) Print the help 1915\end_layout 1916 1917\begin_layout Description 1918--version 1919\begin_inset space ~ 1920\end_inset 1921 1922(-v) Print version information 1923\end_layout 1924 1925\begin_layout Standard 1926\begin_inset Newpage newpage 1927\end_inset 1928 1929 1930\end_layout 1931 1932\begin_layout Chapter 1933Using the Speex Codec API ( 1934\emph on 1935libspeex 1936\emph default 1937 1938\begin_inset Index 1939status collapsed 1940 1941\begin_layout Plain Layout 1942libspeex 1943\end_layout 1944 1945\end_inset 1946 1947) 1948\begin_inset CommandInset label 1949LatexCommand label 1950name "sec:Programming-with-Speex" 1951 1952\end_inset 1953 1954 1955\end_layout 1956 1957\begin_layout Standard 1958The 1959\emph on 1960libspeex 1961\emph default 1962 library contains all the functions for encoding and decoding speech with 1963 the Speex codec. 1964 When linking on a UNIX system, one must add 1965\emph on 1966-lspeex -lm 1967\emph default 1968 to the compiler command line. 1969 One important thing to know is that 1970\series bold 1971libspeex calls are reentrant, but not thread-safe 1972\series default 1973. 1974 That means that it is fine to use calls from many threads, but 1975\series bold 1976calls using the same state from multiple threads must be protected by mutexes 1977\series default 1978. 1979 Examples of code can also be found in Appendix 1980\begin_inset CommandInset ref 1981LatexCommand ref 1982reference "sec:Sample-code" 1983 1984\end_inset 1985 1986 and the complete API documentation is included in the Documentation section 1987 of the Speex website (http://www.speex.org/). 1988\end_layout 1989 1990\begin_layout Section 1991Encoding 1992\begin_inset CommandInset label 1993LatexCommand label 1994name "sub:Encoding" 1995 1996\end_inset 1997 1998 1999\end_layout 2000 2001\begin_layout Standard 2002In order to encode speech using Speex, one first needs to: 2003\end_layout 2004 2005\begin_layout Standard 2006\begin_inset listings 2007inline false 2008status open 2009 2010\begin_layout Plain Layout 2011 2012#include <speex/speex.h> 2013\end_layout 2014 2015\end_inset 2016 2017Then in the code, a Speex bit-packing struct must be declared, along with 2018 a Speex encoder state: 2019\begin_inset listings 2020inline false 2021status open 2022 2023\begin_layout Plain Layout 2024 2025SpeexBits bits; 2026\end_layout 2027 2028\begin_layout Plain Layout 2029 2030void *enc_state; 2031\end_layout 2032 2033\end_inset 2034 2035The two are initialized by: 2036\begin_inset listings 2037inline false 2038status open 2039 2040\begin_layout Plain Layout 2041 2042speex_bits_init(&bits); 2043\end_layout 2044 2045\begin_layout Plain Layout 2046 2047enc_state = speex_encoder_init(&speex_nb_mode); 2048\end_layout 2049 2050\end_inset 2051 2052 2053\end_layout 2054 2055\begin_layout Standard 2056For wideband coding, 2057\emph on 2058speex_nb_mode 2059\emph default 2060 will be replaced by 2061\emph on 2062speex_wb_mode 2063\emph default 2064. 2065 In most cases, you will need to know the frame size used at the sampling 2066 rate you are using. 2067 You can get that value in the 2068\emph on 2069frame_size 2070\emph default 2071 variable (expressed in 2072\series bold 2073samples 2074\series default 2075, not bytes) with: 2076\end_layout 2077 2078\begin_layout Standard 2079\begin_inset listings 2080inline false 2081status open 2082 2083\begin_layout Plain Layout 2084 2085speex_encoder_ctl(enc_state,SPEEX_GET_FRAME_SIZE,&frame_size); 2086\end_layout 2087 2088\end_inset 2089 2090 2091\end_layout 2092 2093\begin_layout Standard 2094In practice, 2095\emph on 2096frame_size 2097\emph default 2098 will correspond to 20 ms when using 8, 16, or 32 kHz sampling rate. 2099 There are many parameters that can be set for the Speex encoder, but the 2100 most useful one is the quality parameter that controls the quality vs bit-rate 2101 tradeoff. 2102 This is set by: 2103\end_layout 2104 2105\begin_layout Standard 2106\begin_inset listings 2107inline false 2108status open 2109 2110\begin_layout Plain Layout 2111 2112speex_encoder_ctl(enc_state,SPEEX_SET_QUALITY,&quality); 2113\end_layout 2114 2115\end_inset 2116 2117where 2118\emph on 2119quality 2120\emph default 2121 is an integer value ranging from 0 to 10 (inclusively). 2122 The mapping between quality and bit-rate is described in Fig. 2123 2124\begin_inset CommandInset ref 2125LatexCommand ref 2126reference "cap:quality_vs_bps" 2127 2128\end_inset 2129 2130 for narrowband. 2131\end_layout 2132 2133\begin_layout Standard 2134Once the initialization is done, for every input frame: 2135\end_layout 2136 2137\begin_layout Standard 2138\begin_inset listings 2139inline false 2140status open 2141 2142\begin_layout Plain Layout 2143 2144speex_bits_reset(&bits); 2145\end_layout 2146 2147\begin_layout Plain Layout 2148 2149speex_encode_int(enc_state, input_frame, &bits); 2150\end_layout 2151 2152\begin_layout Plain Layout 2153 2154nbBytes = speex_bits_write(&bits, byte_ptr, MAX_NB_BYTES); 2155\end_layout 2156 2157\end_inset 2158 2159 2160\end_layout 2161 2162\begin_layout Standard 2163where 2164\emph on 2165input_frame 2166\emph default 2167 is a 2168\emph on 2169( 2170\emph default 2171short 2172\emph on 2173*) 2174\emph default 2175 pointing to the beginning of a speech frame, 2176\emph on 2177byte_ptr 2178\emph default 2179 is a 2180\emph on 2181(char *) 2182\emph default 2183 where the encoded frame will be written, 2184\emph on 2185MAX_NB_BYTES 2186\emph default 2187 is the maximum number of bytes that can be written to 2188\emph on 2189byte_ptr 2190\emph default 2191 without causing an overflow and 2192\emph on 2193nbBytes 2194\emph default 2195 is the number of bytes actually written to 2196\emph on 2197byte_ptr 2198\emph default 2199 (the encoded size in bytes). 2200 Before calling speex_bits_write, it is possible to find the number of bytes 2201 that need to be written by calling 2202\family typewriter 2203speex_bits_nbytes(&bits) 2204\family default 2205, which returns a number of bytes. 2206\end_layout 2207 2208\begin_layout Standard 2209It is still possible to use the 2210\emph on 2211speex_encode() 2212\emph default 2213 function, which takes a 2214\emph on 2215(float *) 2216\emph default 2217 for the audio. 2218 However, this would make an eventual port to an FPU-less platform (like 2219 ARM) more complicated. 2220 Internally, 2221\emph on 2222speex_encode() 2223\emph default 2224 and 2225\emph on 2226speex_encode_int() 2227\emph default 2228 are processed in the same way. 2229 Whether the encoder uses the fixed-point version is only decided by the 2230 compile-time flags, not at the API level. 2231\end_layout 2232 2233\begin_layout Standard 2234After you're done with the encoding, free all resources with: 2235\end_layout 2236 2237\begin_layout Standard 2238\begin_inset listings 2239inline false 2240status open 2241 2242\begin_layout Plain Layout 2243 2244speex_bits_destroy(&bits); 2245\end_layout 2246 2247\begin_layout Plain Layout 2248 2249speex_encoder_destroy(enc_state); 2250\end_layout 2251 2252\end_inset 2253 2254 2255\end_layout 2256 2257\begin_layout Standard 2258That's about it for the encoder. 2259 2260\end_layout 2261 2262\begin_layout Section 2263Decoding 2264\begin_inset CommandInset label 2265LatexCommand label 2266name "sub:Decoding" 2267 2268\end_inset 2269 2270 2271\end_layout 2272 2273\begin_layout Standard 2274In order to decode speech using Speex, you first need to: 2275\begin_inset listings 2276inline false 2277status open 2278 2279\begin_layout Plain Layout 2280 2281#include <speex/speex.h> 2282\end_layout 2283 2284\end_inset 2285 2286You also need to declare a Speex bit-packing struct 2287\begin_inset listings 2288inline false 2289status open 2290 2291\begin_layout Plain Layout 2292 2293SpeexBits bits; 2294\end_layout 2295 2296\end_inset 2297 2298and a Speex decoder state 2299\begin_inset listings 2300inline false 2301status open 2302 2303\begin_layout Plain Layout 2304 2305void *dec_state; 2306\end_layout 2307 2308\end_inset 2309 2310The two are initialized by: 2311\begin_inset listings 2312inline false 2313status open 2314 2315\begin_layout Plain Layout 2316 2317speex_bits_init(&bits); 2318\end_layout 2319 2320\begin_layout Plain Layout 2321 2322dec_state = speex_decoder_init(&speex_nb_mode); 2323\end_layout 2324 2325\end_inset 2326 2327 2328\end_layout 2329 2330\begin_layout Standard 2331For wideband decoding, 2332\emph on 2333speex_nb_mode 2334\emph default 2335 will be replaced by 2336\emph on 2337speex_wb_mode 2338\emph default 2339. 2340 If you need to obtain the size of the frames that will be used by the decoder, 2341 you can get that value in the 2342\emph on 2343frame_size 2344\emph default 2345 variable (expressed in 2346\series bold 2347samples 2348\series default 2349, not bytes) with: 2350\end_layout 2351 2352\begin_layout Standard 2353\begin_inset listings 2354inline false 2355status open 2356 2357\begin_layout Plain Layout 2358 2359speex_decoder_ctl(dec_state, SPEEX_GET_FRAME_SIZE, &frame_size); 2360\end_layout 2361 2362\end_inset 2363 2364 2365\end_layout 2366 2367\begin_layout Standard 2368There is also a parameter that can be set for the decoder: whether or not 2369 to use a perceptual enhancer. 2370 This can be set by: 2371\end_layout 2372 2373\begin_layout Standard 2374\begin_inset listings 2375inline false 2376status open 2377 2378\begin_layout Plain Layout 2379 2380speex_decoder_ctl(dec_state, SPEEX_SET_ENH, &enh); 2381\end_layout 2382 2383\end_inset 2384 2385 2386\end_layout 2387 2388\begin_layout Standard 2389where 2390\emph on 2391enh 2392\emph default 2393 is an int with value 0 to have the enhancer disabled and 1 to have it enabled. 2394 As of 1.2-beta1, the default is now to enable the enhancer. 2395\end_layout 2396 2397\begin_layout Standard 2398Again, once the decoder initialization is done, for every input frame: 2399\end_layout 2400 2401\begin_layout Standard 2402\begin_inset listings 2403inline false 2404status open 2405 2406\begin_layout Plain Layout 2407 2408speex_bits_read_from(&bits, input_bytes, nbBytes); 2409\end_layout 2410 2411\begin_layout Plain Layout 2412 2413speex_decode_int(dec_state, &bits, output_frame); 2414\end_layout 2415 2416\end_inset 2417 2418where input_bytes is a 2419\emph on 2420(char *) 2421\emph default 2422 containing the bit-stream data received for a frame, 2423\emph on 2424nbBytes 2425\emph default 2426 is the size (in bytes) of that bit-stream, and 2427\emph on 2428output_frame 2429\emph default 2430 is a 2431\emph on 2432(short *) 2433\emph default 2434 and points to the area where the decoded speech frame will be written. 2435 A NULL value as the second argument indicates that we don't have the bits 2436 for the current frame. 2437 When a frame is lost, the Speex decoder will do its best to "guess" the 2438 correct signal. 2439\end_layout 2440 2441\begin_layout Standard 2442As for the encoder, the 2443\emph on 2444speex_decode() 2445\emph default 2446 function can still be used, with a 2447\emph on 2448(float *) 2449\emph default 2450 as the output for the audio. 2451 After you're done with the decoding, free all resources with: 2452\end_layout 2453 2454\begin_layout Standard 2455\begin_inset listings 2456inline false 2457status open 2458 2459\begin_layout Plain Layout 2460 2461speex_bits_destroy(&bits); 2462\end_layout 2463 2464\begin_layout Plain Layout 2465 2466speex_decoder_destroy(dec_state); 2467\end_layout 2468 2469\end_inset 2470 2471 2472\end_layout 2473 2474\begin_layout Section 2475Codec Options (speex_*_ctl) 2476\begin_inset CommandInset label 2477LatexCommand label 2478name "sub:Codec-Options" 2479 2480\end_inset 2481 2482 2483\end_layout 2484 2485\begin_layout Quote 2486\align center 2487 2488\emph on 2489Entities should not be multiplied beyond necessity -- William of Ockham. 2490\end_layout 2491 2492\begin_layout Quote 2493\align center 2494 2495\emph on 2496Just because there's an option for it doesn't mean you have to turn it on 2497 -- me. 2498\end_layout 2499 2500\begin_layout Standard 2501The Speex encoder and decoder support many options and requests that can 2502 be accessed through the 2503\emph on 2504speex_encoder_ctl 2505\emph default 2506 and 2507\emph on 2508speex_decoder_ctl 2509\emph default 2510 functions. 2511 These functions are similar to the 2512\emph on 2513ioctl 2514\emph default 2515 system call and their prototypes are: 2516\end_layout 2517 2518\begin_layout Standard 2519\begin_inset listings 2520inline false 2521status open 2522 2523\begin_layout Plain Layout 2524 2525void speex_encoder_ctl(void *encoder, int request, void *ptr); 2526\end_layout 2527 2528\begin_layout Plain Layout 2529 2530void speex_decoder_ctl(void *encoder, int request, void *ptr); 2531\end_layout 2532 2533\end_inset 2534 2535 2536\end_layout 2537 2538\begin_layout Standard 2539Despite those functions, the defaults are usually good for many applications 2540 and 2541\series bold 2542optional settings should only be used when one understands them and knows 2543 that they are needed 2544\series default 2545. 2546 A common error is to attempt to set many unnecessary settings. 2547 2548\end_layout 2549 2550\begin_layout Standard 2551Here is a list of the values allowed for the requests. 2552 Some only apply to the encoder or the decoder. 2553 Because the last argument is of type 2554\begin_inset listings 2555inline true 2556status collapsed 2557 2558\begin_layout Plain Layout 2559 2560void * 2561\end_layout 2562 2563\end_inset 2564 2565, the 2566\begin_inset listings 2567inline true 2568status collapsed 2569 2570\begin_layout Plain Layout 2571 2572_ctl() 2573\end_layout 2574 2575\end_inset 2576 2577 functions are 2578\series bold 2579not type safe 2580\series default 2581, and should thus be used with care. 2582 The type 2583\begin_inset listings 2584inline true 2585status collapsed 2586 2587\begin_layout Plain Layout 2588 2589spx_int32_t 2590\end_layout 2591 2592\end_inset 2593 2594 is the same as the C99 2595\begin_inset listings 2596inline true 2597status collapsed 2598 2599\begin_layout Plain Layout 2600 2601int32_t 2602\end_layout 2603 2604\end_inset 2605 2606 type. 2607\end_layout 2608 2609\begin_layout Description 2610SPEEX_SET_ENH 2611\begin_inset Formula $\ddagger$ 2612\end_inset 2613 2614 Set perceptual enhancer 2615\begin_inset Index 2616status collapsed 2617 2618\begin_layout Plain Layout 2619perceptual enhancement 2620\end_layout 2621 2622\end_inset 2623 2624 to on (1) or off (0) ( 2625\begin_inset listings 2626inline true 2627status collapsed 2628 2629\begin_layout Plain Layout 2630 2631spx_int32_t 2632\end_layout 2633 2634\end_inset 2635 2636, default is on) 2637\end_layout 2638 2639\begin_layout Description 2640SPEEX_GET_ENH 2641\begin_inset Formula $\ddagger$ 2642\end_inset 2643 2644 Get perceptual enhancer status ( 2645\begin_inset listings 2646inline true 2647status collapsed 2648 2649\begin_layout Plain Layout 2650 2651spx_int32_t 2652\end_layout 2653 2654\end_inset 2655 2656) 2657\end_layout 2658 2659\begin_layout Description 2660SPEEX_GET_FRAME_SIZE Get the number of samples per frame for the current 2661 mode ( 2662\begin_inset listings 2663inline true 2664status collapsed 2665 2666\begin_layout Plain Layout 2667 2668spx_int32_t 2669\end_layout 2670 2671\end_inset 2672 2673) 2674\end_layout 2675 2676\begin_layout Description 2677SPEEX_SET_QUALITY 2678\begin_inset Formula $\dagger$ 2679\end_inset 2680 2681 Set the encoder speech quality ( 2682\begin_inset listings 2683inline true 2684status collapsed 2685 2686\begin_layout Plain Layout 2687 2688spx_int32_t 2689\end_layout 2690 2691\end_inset 2692 2693 from 0 to 10, default is 8) 2694\end_layout 2695 2696\begin_layout Description 2697SPEEX_GET_QUALITY 2698\begin_inset Formula $\dagger$ 2699\end_inset 2700 2701 Get the current encoder speech quality ( 2702\begin_inset listings 2703inline true 2704status collapsed 2705 2706\begin_layout Plain Layout 2707 2708spx_int32_t 2709\end_layout 2710 2711\end_inset 2712 2713 from 0 to 10) 2714\end_layout 2715 2716\begin_layout Description 2717SPEEX_SET_MODE 2718\begin_inset Formula $\dagger$ 2719\end_inset 2720 2721 Set the mode number, as specified in the RTP spec ( 2722\begin_inset listings 2723inline true 2724status collapsed 2725 2726\begin_layout Plain Layout 2727 2728spx_int32_t 2729\end_layout 2730 2731\end_inset 2732 2733) 2734\end_layout 2735 2736\begin_layout Description 2737SPEEX_GET_MODE 2738\begin_inset Formula $\dagger$ 2739\end_inset 2740 2741 Get the current mode number, as specified in the RTP spec ( 2742\begin_inset listings 2743inline true 2744status collapsed 2745 2746\begin_layout Plain Layout 2747 2748spx_int32_t 2749\end_layout 2750 2751\end_inset 2752 2753) 2754\end_layout 2755 2756\begin_layout Description 2757SPEEX_SET_VBR 2758\begin_inset Formula $\dagger$ 2759\end_inset 2760 2761 Set variable bit-rate (VBR) to on (1) or off (0) ( 2762\begin_inset listings 2763inline true 2764status collapsed 2765 2766\begin_layout Plain Layout 2767 2768spx_int32_t 2769\end_layout 2770 2771\end_inset 2772 2773, default is off) 2774\end_layout 2775 2776\begin_layout Description 2777SPEEX_GET_VBR 2778\begin_inset Formula $\dagger$ 2779\end_inset 2780 2781 Get variable bit-rate 2782\begin_inset Index 2783status collapsed 2784 2785\begin_layout Plain Layout 2786variable bit-rate 2787\end_layout 2788 2789\end_inset 2790 2791 (VBR) status ( 2792\begin_inset listings 2793inline true 2794status collapsed 2795 2796\begin_layout Plain Layout 2797 2798spx_int32_t 2799\end_layout 2800 2801\end_inset 2802 2803) 2804\end_layout 2805 2806\begin_layout Description 2807SPEEX_SET_VBR_QUALITY 2808\begin_inset Formula $\dagger$ 2809\end_inset 2810 2811 Set the encoder VBR speech quality (float 0.0 to 10.0, default is 8.0) 2812\end_layout 2813 2814\begin_layout Description 2815SPEEX_GET_VBR_QUALITY 2816\begin_inset Formula $\dagger$ 2817\end_inset 2818 2819 Get the current encoder VBR speech quality (float 0 to 10) 2820\end_layout 2821 2822\begin_layout Description 2823SPEEX_SET_COMPLEXITY 2824\begin_inset Formula $\dagger$ 2825\end_inset 2826 2827 Set the CPU resources allowed for the encoder ( 2828\begin_inset listings 2829inline true 2830status collapsed 2831 2832\begin_layout Plain Layout 2833 2834spx_int32_t 2835\end_layout 2836 2837\end_inset 2838 2839 from 1 to 10, default is 2) 2840\end_layout 2841 2842\begin_layout Description 2843SPEEX_GET_COMPLEXITY 2844\begin_inset Formula $\dagger$ 2845\end_inset 2846 2847 Get the CPU resources allowed for the encoder ( 2848\begin_inset listings 2849inline true 2850status collapsed 2851 2852\begin_layout Plain Layout 2853 2854spx_int32_t 2855\end_layout 2856 2857\end_inset 2858 2859 from 1 to 10, default is 2) 2860\end_layout 2861 2862\begin_layout Description 2863SPEEX_SET_BITRATE 2864\begin_inset Formula $\dagger$ 2865\end_inset 2866 2867 Set the bit-rate to use the closest value not exceeding the parameter ( 2868\begin_inset listings 2869inline true 2870status collapsed 2871 2872\begin_layout Plain Layout 2873 2874spx_int32_t 2875\end_layout 2876 2877\end_inset 2878 2879 in bits per second) 2880\end_layout 2881 2882\begin_layout Description 2883SPEEX_GET_BITRATE Get the current bit-rate in use ( 2884\begin_inset listings 2885inline true 2886status collapsed 2887 2888\begin_layout Plain Layout 2889 2890spx_int32_t 2891\end_layout 2892 2893\end_inset 2894 2895 in bits per second) 2896\end_layout 2897 2898\begin_layout Description 2899SPEEX_SET_SAMPLING_RATE Set real sampling rate ( 2900\begin_inset listings 2901inline true 2902status collapsed 2903 2904\begin_layout Plain Layout 2905 2906spx_int32_t 2907\end_layout 2908 2909\end_inset 2910 2911 in Hz) 2912\end_layout 2913 2914\begin_layout Description 2915SPEEX_GET_SAMPLING_RATE Get real sampling rate ( 2916\begin_inset listings 2917inline true 2918status collapsed 2919 2920\begin_layout Plain Layout 2921 2922spx_int32_t 2923\end_layout 2924 2925\end_inset 2926 2927 in Hz) 2928\end_layout 2929 2930\begin_layout Description 2931SPEEX_RESET_STATE Reset the encoder/decoder state to its original state, 2932 clearing all memories (no argument) 2933\end_layout 2934 2935\begin_layout Description 2936SPEEX_SET_VAD 2937\begin_inset Formula $\dagger$ 2938\end_inset 2939 2940 Set voice activity detection 2941\begin_inset Index 2942status collapsed 2943 2944\begin_layout Plain Layout 2945voice activity detection 2946\end_layout 2947 2948\end_inset 2949 2950 (VAD) to on (1) or off (0) ( 2951\begin_inset listings 2952inline true 2953status collapsed 2954 2955\begin_layout Plain Layout 2956 2957spx_int32_t 2958\end_layout 2959 2960\end_inset 2961 2962, default is off) 2963\end_layout 2964 2965\begin_layout Description 2966SPEEX_GET_VAD 2967\begin_inset Formula $\dagger$ 2968\end_inset 2969 2970 Get voice activity detection (VAD) status ( 2971\begin_inset listings 2972inline true 2973status collapsed 2974 2975\begin_layout Plain Layout 2976 2977spx_int32_t 2978\end_layout 2979 2980\end_inset 2981 2982) 2983\end_layout 2984 2985\begin_layout Description 2986SPEEX_SET_DTX 2987\begin_inset Formula $\dagger$ 2988\end_inset 2989 2990 Set discontinuous transmission 2991\begin_inset Index 2992status collapsed 2993 2994\begin_layout Plain Layout 2995discontinuous transmission 2996\end_layout 2997 2998\end_inset 2999 3000 (DTX) to on (1) or off (0) ( 3001\begin_inset listings 3002inline true 3003status collapsed 3004 3005\begin_layout Plain Layout 3006 3007spx_int32_t 3008\end_layout 3009 3010\end_inset 3011 3012, default is off) 3013\end_layout 3014 3015\begin_layout Description 3016SPEEX_GET_DTX 3017\begin_inset Formula $\dagger$ 3018\end_inset 3019 3020 Get discontinuous transmission (DTX) status ( 3021\begin_inset listings 3022inline true 3023status collapsed 3024 3025\begin_layout Plain Layout 3026 3027spx_int32_t 3028\end_layout 3029 3030\end_inset 3031 3032) 3033\end_layout 3034 3035\begin_layout Description 3036SPEEX_SET_ABR 3037\begin_inset Formula $\dagger$ 3038\end_inset 3039 3040 Set average bit-rate 3041\begin_inset Index 3042status collapsed 3043 3044\begin_layout Plain Layout 3045average bit-rate 3046\end_layout 3047 3048\end_inset 3049 3050 (ABR) to a value n in bits per second ( 3051\begin_inset listings 3052inline true 3053status collapsed 3054 3055\begin_layout Plain Layout 3056 3057spx_int32_t 3058\end_layout 3059 3060\end_inset 3061 3062 in bits per second) 3063\end_layout 3064 3065\begin_layout Description 3066SPEEX_GET_ABR 3067\begin_inset Formula $\dagger$ 3068\end_inset 3069 3070 Get average bit-rate (ABR) setting ( 3071\begin_inset listings 3072inline true 3073status collapsed 3074 3075\begin_layout Plain Layout 3076 3077spx_int32_t 3078\end_layout 3079 3080\end_inset 3081 3082 in bits per second) 3083\end_layout 3084 3085\begin_layout Description 3086SPEEX_SET_PLC_TUNING 3087\begin_inset Formula $\dagger$ 3088\end_inset 3089 3090 Tell the encoder to optimize encoding for a certain percentage of packet 3091 loss ( 3092\begin_inset listings 3093inline true 3094status collapsed 3095 3096\begin_layout Plain Layout 3097 3098spx_int32_t 3099\end_layout 3100 3101\end_inset 3102 3103 in percent) 3104\end_layout 3105 3106\begin_layout Description 3107SPEEX_GET_PLC_TUNING 3108\begin_inset Formula $\dagger$ 3109\end_inset 3110 3111 Get the current tuning of the encoder for PLC ( 3112\begin_inset listings 3113inline true 3114status collapsed 3115 3116\begin_layout Plain Layout 3117 3118spx_int32_t 3119\end_layout 3120 3121\end_inset 3122 3123 in percent) 3124\end_layout 3125 3126\begin_layout Description 3127SPEEX_GET_LOOKAHEAD Returns the lookahead used by Speex separately for an 3128 encoder and a decoder. 3129 Sum encoder and decoder lookahead values to get the total codec lookahead. 3130\end_layout 3131 3132\begin_layout Description 3133SPEEX_SET_VBR_MAX_BITRATE 3134\begin_inset Formula $\dagger$ 3135\end_inset 3136 3137 Set the maximum bit-rate allowed in VBR operation ( 3138\begin_inset listings 3139inline true 3140status collapsed 3141 3142\begin_layout Plain Layout 3143 3144spx_int32_t 3145\end_layout 3146 3147\end_inset 3148 3149 in bits per second) 3150\end_layout 3151 3152\begin_layout Description 3153SPEEX_GET_VBR_MAX_BITRATE 3154\begin_inset Formula $\dagger$ 3155\end_inset 3156 3157 Get the current maximum bit-rate allowed in VBR operation ( 3158\begin_inset listings 3159inline true 3160status collapsed 3161 3162\begin_layout Plain Layout 3163 3164spx_int32_t 3165\end_layout 3166 3167\end_inset 3168 3169 in bits per second) 3170\end_layout 3171 3172\begin_layout Description 3173SPEEX_SET_HIGHPASS Set the high-pass filter on (1) or off (0) ( 3174\begin_inset listings 3175inline true 3176status collapsed 3177 3178\begin_layout Plain Layout 3179 3180spx_int32_t 3181\end_layout 3182 3183\end_inset 3184 3185, default is on) 3186\end_layout 3187 3188\begin_layout Description 3189SPEEX_GET_HIGHPASS Get the current high-pass filter status ( 3190\begin_inset listings 3191inline true 3192status collapsed 3193 3194\begin_layout Plain Layout 3195 3196spx_int32_t 3197\end_layout 3198 3199\end_inset 3200 3201) 3202\end_layout 3203 3204\begin_layout Description 3205\begin_inset Formula $\dagger$ 3206\end_inset 3207 3208 applies only to the encoder 3209\end_layout 3210 3211\begin_layout Description 3212\begin_inset Formula $\ddagger$ 3213\end_inset 3214 3215 applies only to the decoder 3216\end_layout 3217 3218\begin_layout Section 3219Mode queries 3220\begin_inset CommandInset label 3221LatexCommand label 3222name "sub:Mode-queries" 3223 3224\end_inset 3225 3226 3227\end_layout 3228 3229\begin_layout Standard 3230Speex modes have a query system similar to the speex_encoder_ctl and speex_decod 3231er_ctl calls. 3232 Since modes are read-only, it is only possible to get information about 3233 a particular mode. 3234 The function used to do that is: 3235\begin_inset listings 3236inline false 3237status open 3238 3239\begin_layout Plain Layout 3240 3241void speex_mode_query(SpeexMode *mode, int request, void *ptr); 3242\end_layout 3243 3244\end_inset 3245 3246The admissible values for request are (unless otherwise note, the values 3247 are returned through 3248\emph on 3249ptr 3250\emph default 3251): 3252\end_layout 3253 3254\begin_layout Description 3255SPEEX_MODE_FRAME_SIZE Get the frame size (in samples) for the mode 3256\end_layout 3257 3258\begin_layout Description 3259SPEEX_SUBMODE_BITRATE Get the bit-rate for a submode number specified through 3260 3261\emph on 3262ptr 3263\emph default 3264 (integer in bps). 3265 3266\end_layout 3267 3268\begin_layout Section 3269Packing and in-band signalling 3270\begin_inset Index 3271status collapsed 3272 3273\begin_layout Plain Layout 3274in-band signalling 3275\end_layout 3276 3277\end_inset 3278 3279 3280\end_layout 3281 3282\begin_layout Standard 3283Sometimes it is desirable to pack more than one frame per packet (or other 3284 basic unit of storage). 3285 The proper way to do it is to call speex_encode 3286\begin_inset Formula $N$ 3287\end_inset 3288 3289 times before writing the stream with speex_bits_write. 3290 In cases where the number of frames is not determined by an out-of-band 3291 mechanism, it is possible to include a terminator code. 3292 That terminator consists of the code 15 (decimal) encoded with 5 bits, 3293 as shown in Table 3294\begin_inset CommandInset ref 3295LatexCommand ref 3296reference "cap:quality_vs_bps" 3297 3298\end_inset 3299 3300. 3301 Note that as of version 1.0.2, calling speex_bits_write automatically inserts 3302 the terminator so as to fill the last byte. 3303 This doesn't involves any overhead and makes sure Speex can always detect 3304 when there is no more frame in a packet. 3305\end_layout 3306 3307\begin_layout Standard 3308It is also possible to send in-band 3309\begin_inset Quotes eld 3310\end_inset 3311 3312messages 3313\begin_inset Quotes erd 3314\end_inset 3315 3316 to the other side. 3317 All these messages are encoded as 3318\begin_inset Quotes eld 3319\end_inset 3320 3321pseudo-frames 3322\begin_inset Quotes erd 3323\end_inset 3324 3325 of mode 14 which contain a 4-bit message type code, followed by the message. 3326 Table 3327\begin_inset CommandInset ref 3328LatexCommand ref 3329reference "cap:In-band-signalling-codes" 3330 3331\end_inset 3332 3333 lists the available codes, their meaning and the size of the message that 3334 follows. 3335 Most of these messages are requests that are sent to the encoder or decoder 3336 on the other end, which is free to comply or ignore them. 3337 By default, all in-band messages are ignored. 3338\end_layout 3339 3340\begin_layout Standard 3341\begin_inset Float table 3342placement htbp 3343wide false 3344sideways false 3345status open 3346 3347\begin_layout Plain Layout 3348\begin_inset ERT 3349status collapsed 3350 3351\begin_layout Plain Layout 3352 3353 3354\backslash 3355begin{center} 3356\end_layout 3357 3358\end_inset 3359 3360 3361\begin_inset Tabular 3362<lyxtabular version="3" rows="17" columns="3"> 3363<features> 3364<column alignment="center" valignment="top" width="0pt"> 3365<column alignment="center" valignment="top" width="0pt"> 3366<column alignment="center" valignment="top" width="0pt"> 3367<row> 3368<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 3369\begin_inset Text 3370 3371\begin_layout Plain Layout 3372Code 3373\end_layout 3374 3375\end_inset 3376</cell> 3377<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 3378\begin_inset Text 3379 3380\begin_layout Plain Layout 3381Size (bits) 3382\end_layout 3383 3384\end_inset 3385</cell> 3386<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 3387\begin_inset Text 3388 3389\begin_layout Plain Layout 3390Content 3391\end_layout 3392 3393\end_inset 3394</cell> 3395</row> 3396<row> 3397<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3398\begin_inset Text 3399 3400\begin_layout Plain Layout 34010 3402\end_layout 3403 3404\end_inset 3405</cell> 3406<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3407\begin_inset Text 3408 3409\begin_layout Plain Layout 34101 3411\end_layout 3412 3413\end_inset 3414</cell> 3415<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3416\begin_inset Text 3417 3418\begin_layout Plain Layout 3419Asks decoder to set perceptual enhancement off (0) or on(1) 3420\end_layout 3421 3422\end_inset 3423</cell> 3424</row> 3425<row> 3426<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3427\begin_inset Text 3428 3429\begin_layout Plain Layout 34301 3431\end_layout 3432 3433\end_inset 3434</cell> 3435<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3436\begin_inset Text 3437 3438\begin_layout Plain Layout 34391 3440\end_layout 3441 3442\end_inset 3443</cell> 3444<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3445\begin_inset Text 3446 3447\begin_layout Plain Layout 3448Asks (if 1) the encoder to be less 3449\begin_inset Quotes eld 3450\end_inset 3451 3452aggressive 3453\begin_inset Quotes erd 3454\end_inset 3455 3456 due to high packet loss 3457\end_layout 3458 3459\end_inset 3460</cell> 3461</row> 3462<row> 3463<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3464\begin_inset Text 3465 3466\begin_layout Plain Layout 34672 3468\end_layout 3469 3470\end_inset 3471</cell> 3472<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3473\begin_inset Text 3474 3475\begin_layout Plain Layout 34764 3477\end_layout 3478 3479\end_inset 3480</cell> 3481<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3482\begin_inset Text 3483 3484\begin_layout Plain Layout 3485Asks encoder to switch to mode N 3486\end_layout 3487 3488\end_inset 3489</cell> 3490</row> 3491<row> 3492<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3493\begin_inset Text 3494 3495\begin_layout Plain Layout 34963 3497\end_layout 3498 3499\end_inset 3500</cell> 3501<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3502\begin_inset Text 3503 3504\begin_layout Plain Layout 35054 3506\end_layout 3507 3508\end_inset 3509</cell> 3510<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3511\begin_inset Text 3512 3513\begin_layout Plain Layout 3514Asks encoder to switch to mode N for low-band 3515\end_layout 3516 3517\end_inset 3518</cell> 3519</row> 3520<row> 3521<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3522\begin_inset Text 3523 3524\begin_layout Plain Layout 35254 3526\end_layout 3527 3528\end_inset 3529</cell> 3530<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3531\begin_inset Text 3532 3533\begin_layout Plain Layout 35344 3535\end_layout 3536 3537\end_inset 3538</cell> 3539<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3540\begin_inset Text 3541 3542\begin_layout Plain Layout 3543Asks encoder to switch to mode N for high-band 3544\end_layout 3545 3546\end_inset 3547</cell> 3548</row> 3549<row> 3550<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3551\begin_inset Text 3552 3553\begin_layout Plain Layout 35545 3555\end_layout 3556 3557\end_inset 3558</cell> 3559<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3560\begin_inset Text 3561 3562\begin_layout Plain Layout 35634 3564\end_layout 3565 3566\end_inset 3567</cell> 3568<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3569\begin_inset Text 3570 3571\begin_layout Plain Layout 3572Asks encoder to switch to quality N for VBR 3573\end_layout 3574 3575\end_inset 3576</cell> 3577</row> 3578<row> 3579<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3580\begin_inset Text 3581 3582\begin_layout Plain Layout 35836 3584\end_layout 3585 3586\end_inset 3587</cell> 3588<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3589\begin_inset Text 3590 3591\begin_layout Plain Layout 35924 3593\end_layout 3594 3595\end_inset 3596</cell> 3597<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3598\begin_inset Text 3599 3600\begin_layout Plain Layout 3601Request acknowledge (0=no, 1=all, 2=only for in-band data) 3602\end_layout 3603 3604\end_inset 3605</cell> 3606</row> 3607<row> 3608<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3609\begin_inset Text 3610 3611\begin_layout Plain Layout 36127 3613\end_layout 3614 3615\end_inset 3616</cell> 3617<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3618\begin_inset Text 3619 3620\begin_layout Plain Layout 36214 3622\end_layout 3623 3624\end_inset 3625</cell> 3626<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3627\begin_inset Text 3628 3629\begin_layout Plain Layout 3630Asks encoder to set CBR (0), VAD(1), DTX(3), VBR(5), VBR+DTX(7) 3631\end_layout 3632 3633\end_inset 3634</cell> 3635</row> 3636<row> 3637<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3638\begin_inset Text 3639 3640\begin_layout Plain Layout 36418 3642\end_layout 3643 3644\end_inset 3645</cell> 3646<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3647\begin_inset Text 3648 3649\begin_layout Plain Layout 36508 3651\end_layout 3652 3653\end_inset 3654</cell> 3655<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3656\begin_inset Text 3657 3658\begin_layout Plain Layout 3659Transmit (8-bit) character to the other end 3660\end_layout 3661 3662\end_inset 3663</cell> 3664</row> 3665<row> 3666<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3667\begin_inset Text 3668 3669\begin_layout Plain Layout 36709 3671\end_layout 3672 3673\end_inset 3674</cell> 3675<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3676\begin_inset Text 3677 3678\begin_layout Plain Layout 36798 3680\end_layout 3681 3682\end_inset 3683</cell> 3684<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3685\begin_inset Text 3686 3687\begin_layout Plain Layout 3688Intensity stereo information 3689\end_layout 3690 3691\end_inset 3692</cell> 3693</row> 3694<row> 3695<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3696\begin_inset Text 3697 3698\begin_layout Plain Layout 369910 3700\end_layout 3701 3702\end_inset 3703</cell> 3704<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3705\begin_inset Text 3706 3707\begin_layout Plain Layout 370816 3709\end_layout 3710 3711\end_inset 3712</cell> 3713<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3714\begin_inset Text 3715 3716\begin_layout Plain Layout 3717Announce maximum bit-rate acceptable (N in bytes/second) 3718\end_layout 3719 3720\end_inset 3721</cell> 3722</row> 3723<row> 3724<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3725\begin_inset Text 3726 3727\begin_layout Plain Layout 372811 3729\end_layout 3730 3731\end_inset 3732</cell> 3733<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3734\begin_inset Text 3735 3736\begin_layout Plain Layout 373716 3738\end_layout 3739 3740\end_inset 3741</cell> 3742<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3743\begin_inset Text 3744 3745\begin_layout Plain Layout 3746reserved 3747\end_layout 3748 3749\end_inset 3750</cell> 3751</row> 3752<row> 3753<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3754\begin_inset Text 3755 3756\begin_layout Plain Layout 375712 3758\end_layout 3759 3760\end_inset 3761</cell> 3762<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3763\begin_inset Text 3764 3765\begin_layout Plain Layout 376632 3767\end_layout 3768 3769\end_inset 3770</cell> 3771<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3772\begin_inset Text 3773 3774\begin_layout Plain Layout 3775Acknowledge receiving packet N 3776\end_layout 3777 3778\end_inset 3779</cell> 3780</row> 3781<row> 3782<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3783\begin_inset Text 3784 3785\begin_layout Plain Layout 378613 3787\end_layout 3788 3789\end_inset 3790</cell> 3791<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3792\begin_inset Text 3793 3794\begin_layout Plain Layout 379532 3796\end_layout 3797 3798\end_inset 3799</cell> 3800<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3801\begin_inset Text 3802 3803\begin_layout Plain Layout 3804reserved 3805\end_layout 3806 3807\end_inset 3808</cell> 3809</row> 3810<row> 3811<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3812\begin_inset Text 3813 3814\begin_layout Plain Layout 381514 3816\end_layout 3817 3818\end_inset 3819</cell> 3820<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 3821\begin_inset Text 3822 3823\begin_layout Plain Layout 382464 3825\end_layout 3826 3827\end_inset 3828</cell> 3829<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 3830\begin_inset Text 3831 3832\begin_layout Plain Layout 3833reserved 3834\end_layout 3835 3836\end_inset 3837</cell> 3838</row> 3839<row> 3840<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 3841\begin_inset Text 3842 3843\begin_layout Plain Layout 384415 3845\end_layout 3846 3847\end_inset 3848</cell> 3849<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 3850\begin_inset Text 3851 3852\begin_layout Plain Layout 385364 3854\end_layout 3855 3856\end_inset 3857</cell> 3858<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 3859\begin_inset Text 3860 3861\begin_layout Plain Layout 3862reserved 3863\end_layout 3864 3865\end_inset 3866</cell> 3867</row> 3868</lyxtabular> 3869 3870\end_inset 3871 3872 3873\begin_inset ERT 3874status collapsed 3875 3876\begin_layout Plain Layout 3877 3878 3879\backslash 3880end{center} 3881\end_layout 3882 3883\end_inset 3884 3885 3886\end_layout 3887 3888\begin_layout Plain Layout 3889\begin_inset Caption 3890 3891\begin_layout Plain Layout 3892In-band signalling codes 3893\begin_inset CommandInset label 3894LatexCommand label 3895name "cap:In-band-signalling-codes" 3896 3897\end_inset 3898 3899 3900\end_layout 3901 3902\end_inset 3903 3904 3905\end_layout 3906 3907\end_inset 3908 3909 3910\end_layout 3911 3912\begin_layout Standard 3913Finally, applications may define custom in-band messages using mode 13. 3914 The size of the message in bytes is encoded with 5 bits, so that the decoder 3915 can skip it if it doesn't know how to interpret it. 3916\begin_inset Newpage newpage 3917\end_inset 3918 3919 3920\end_layout 3921 3922\begin_layout Chapter 3923Speech Processing API ( 3924\emph on 3925libspeexdsp 3926\emph default 3927) 3928\end_layout 3929 3930\begin_layout Standard 3931As of version 1.2beta3, the non-codec parts of the Speex package are now 3932 in a separate library called 3933\emph on 3934libspeexdsp 3935\emph default 3936. 3937 This library includes the preprocessor, the acoustic echo canceller, the 3938 jitter buffer, and the resampler. 3939 In a UNIX environment, it can be linked into a program by adding 3940\emph on 3941-lspeexdsp -lm 3942\emph default 3943 to the compiler command line. 3944 Just like for libspeex, 3945\series bold 3946libspeexdsp calls are reentrant, but not thread-safe 3947\series default 3948. 3949 That means that it is fine to use calls from many threads, but 3950\series bold 3951calls using the same state from multiple threads must be protected by mutexes 3952\series default 3953. 3954\end_layout 3955 3956\begin_layout Section 3957Preprocessor 3958\begin_inset CommandInset label 3959LatexCommand label 3960name "sub:Preprocessor" 3961 3962\end_inset 3963 3964 3965\end_layout 3966 3967\begin_layout Standard 3968\noindent 3969In order to use the Speex preprocessor 3970\begin_inset Index 3971status collapsed 3972 3973\begin_layout Plain Layout 3974preprocessor 3975\end_layout 3976 3977\end_inset 3978 3979, you first need to: 3980\begin_inset listings 3981inline false 3982status open 3983 3984\begin_layout Plain Layout 3985 3986#include <speex/speex_preprocess.h> 3987\end_layout 3988 3989\end_inset 3990 3991 3992\end_layout 3993 3994\begin_layout Standard 3995\noindent 3996Then, a preprocessor state can be created as: 3997\begin_inset listings 3998inline false 3999status open 4000 4001\begin_layout Plain Layout 4002 4003SpeexPreprocessState *preprocess_state = speex_preprocess_state_init(frame_size, 4004 sampling_rate); 4005\end_layout 4006 4007\end_inset 4008 4009 4010\end_layout 4011 4012\begin_layout Standard 4013\noindent 4014and it is recommended to use the same value for 4015\family typewriter 4016frame_size 4017\family default 4018 as is used by the encoder (20 4019\emph on 4020ms 4021\emph default 4022). 4023\end_layout 4024 4025\begin_layout Standard 4026For each input frame, you need to call: 4027\end_layout 4028 4029\begin_layout Standard 4030\begin_inset listings 4031inline false 4032status open 4033 4034\begin_layout Plain Layout 4035 4036speex_preprocess_run(preprocess_state, audio_frame); 4037\end_layout 4038 4039\end_inset 4040 4041 4042\end_layout 4043 4044\begin_layout Standard 4045\noindent 4046where 4047\family typewriter 4048audio_frame 4049\family default 4050 is used both as input and output. 4051 In cases where the output audio is not useful for a certain frame, it is 4052 possible to use instead: 4053\end_layout 4054 4055\begin_layout Standard 4056\begin_inset listings 4057inline false 4058status open 4059 4060\begin_layout Plain Layout 4061 4062speex_preprocess_estimate_update(preprocess_state, audio_frame); 4063\end_layout 4064 4065\end_inset 4066 4067 4068\end_layout 4069 4070\begin_layout Standard 4071\noindent 4072This call will update all the preprocessor internal state variables without 4073 computing the output audio, thus saving some CPU cycles. 4074\end_layout 4075 4076\begin_layout Standard 4077The behaviour of the preprocessor can be changed using: 4078\end_layout 4079 4080\begin_layout Standard 4081\begin_inset listings 4082inline false 4083status open 4084 4085\begin_layout Plain Layout 4086 4087speex_preprocess_ctl(preprocess_state, request, ptr); 4088\end_layout 4089 4090\end_inset 4091 4092 4093\end_layout 4094 4095\begin_layout Standard 4096\noindent 4097which is used in the same way as the encoder and decoder equivalent. 4098 Options are listed in Section 4099\begin_inset CommandInset ref 4100LatexCommand ref 4101reference "sub:Preprocessor-options" 4102 4103\end_inset 4104 4105. 4106\end_layout 4107 4108\begin_layout Standard 4109The preprocessor state can be destroyed using: 4110\end_layout 4111 4112\begin_layout Standard 4113\begin_inset listings 4114inline false 4115status open 4116 4117\begin_layout Plain Layout 4118 4119speex_preprocess_state_destroy(preprocess_state); 4120\end_layout 4121 4122\end_inset 4123 4124 4125\end_layout 4126 4127\begin_layout Subsection 4128Preprocessor options 4129\begin_inset CommandInset label 4130LatexCommand label 4131name "sub:Preprocessor-options" 4132 4133\end_inset 4134 4135 4136\end_layout 4137 4138\begin_layout Standard 4139As with the codec, the preprocessor also has options that can be controlled 4140 using an ioctl()-like call. 4141 The available options are: 4142\end_layout 4143 4144\begin_layout Description 4145SPEEX_PREPROCESS_SET_DENOISE Turns denoising on(1) or off(0) ( 4146\begin_inset listings 4147inline true 4148status collapsed 4149 4150\begin_layout Plain Layout 4151 4152spx_int32_t 4153\end_layout 4154 4155\end_inset 4156 4157) 4158\end_layout 4159 4160\begin_layout Description 4161SPEEX_PREPROCESS_GET_DENOISE Get denoising status ( 4162\begin_inset listings 4163inline true 4164status collapsed 4165 4166\begin_layout Plain Layout 4167 4168spx_int32_t 4169\end_layout 4170 4171\end_inset 4172 4173) 4174\end_layout 4175 4176\begin_layout Description 4177SPEEX_PREPROCESS_SET_AGC Turns automatic gain control (AGC) on(1) or off(0) 4178 ( 4179\begin_inset listings 4180inline true 4181status collapsed 4182 4183\begin_layout Plain Layout 4184 4185spx_int32_t 4186\end_layout 4187 4188\end_inset 4189 4190) 4191\end_layout 4192 4193\begin_layout Description 4194SPEEX_PREPROCESS_GET_AGC Get AGC status ( 4195\begin_inset listings 4196inline true 4197status collapsed 4198 4199\begin_layout Plain Layout 4200 4201spx_int32_t 4202\end_layout 4203 4204\end_inset 4205 4206) 4207\end_layout 4208 4209\begin_layout Description 4210SPEEX_PREPROCESS_SET_VAD Turns voice activity detector (VAD) on(1) or off(0) 4211 ( 4212\begin_inset listings 4213inline true 4214status collapsed 4215 4216\begin_layout Plain Layout 4217 4218spx_int32_t 4219\end_layout 4220 4221\end_inset 4222 4223) 4224\end_layout 4225 4226\begin_layout Description 4227SPEEX_PREPROCESS_GET_VAD Get VAD status ( 4228\begin_inset listings 4229inline true 4230status collapsed 4231 4232\begin_layout Plain Layout 4233 4234spx_int32_t 4235\end_layout 4236 4237\end_inset 4238 4239) 4240\end_layout 4241 4242\begin_layout Description 4243SPEEX_PREPROCESS_SET_AGC_LEVEL 4244\end_layout 4245 4246\begin_layout Description 4247SPEEX_PREPROCESS_GET_AGC_LEVEL 4248\end_layout 4249 4250\begin_layout Description 4251SPEEX_PREPROCESS_SET_DEREVERB Turns reverberation removal on(1) or off(0) 4252 ( 4253\begin_inset listings 4254inline true 4255status collapsed 4256 4257\begin_layout Plain Layout 4258 4259spx_int32_t 4260\end_layout 4261 4262\end_inset 4263 4264) 4265\end_layout 4266 4267\begin_layout Description 4268SPEEX_PREPROCESS_GET_DEREVERB Get reverberation removal status ( 4269\begin_inset listings 4270inline true 4271status collapsed 4272 4273\begin_layout Plain Layout 4274 4275spx_int32_t 4276\end_layout 4277 4278\end_inset 4279 4280) 4281\end_layout 4282 4283\begin_layout Description 4284SPEEX_PREPROCESS_SET_DEREVERB_LEVEL Not working yet, do not use 4285\end_layout 4286 4287\begin_layout Description 4288SPEEX_PREPROCESS_GET_DEREVERB_LEVEL Not working yet, do not use 4289\end_layout 4290 4291\begin_layout Description 4292SPEEX_PREPROCESS_SET_DEREVERB_DECAY Not working yet, do not use 4293\end_layout 4294 4295\begin_layout Description 4296SPEEX_PREPROCESS_GET_DEREVERB_DECAY Not working yet, do not use 4297\end_layout 4298 4299\begin_layout Description 4300SPEEX_PREPROCESS_SET_PROB_START 4301\end_layout 4302 4303\begin_layout Description 4304SPEEX_PREPROCESS_GET_PROB_START 4305\end_layout 4306 4307\begin_layout Description 4308SPEEX_PREPROCESS_SET_PROB_CONTINUE 4309\end_layout 4310 4311\begin_layout Description 4312SPEEX_PREPROCESS_GET_PROB_CONTINUE 4313\end_layout 4314 4315\begin_layout Description 4316SPEEX_PREPROCESS_SET_NOISE_SUPPRESS Set maximum attenuation of the noise 4317 in dB (negative 4318\begin_inset listings 4319inline true 4320status collapsed 4321 4322\begin_layout Plain Layout 4323 4324spx_int32_t 4325\end_layout 4326 4327\end_inset 4328 4329) 4330\end_layout 4331 4332\begin_layout Description 4333SPEEX_PREPROCESS_GET_NOISE_SUPPRESS Get maximum attenuation of the noise 4334 in dB (negative 4335\begin_inset listings 4336inline true 4337status collapsed 4338 4339\begin_layout Plain Layout 4340 4341spx_int32_t 4342\end_layout 4343 4344\end_inset 4345 4346) 4347\end_layout 4348 4349\begin_layout Description 4350SPEEX_PREPROCESS_SET_ECHO_SUPPRESS Set maximum attenuation of the residual 4351 echo in dB (negative 4352\begin_inset listings 4353inline true 4354status collapsed 4355 4356\begin_layout Plain Layout 4357 4358spx_int32_t 4359\end_layout 4360 4361\end_inset 4362 4363) 4364\end_layout 4365 4366\begin_layout Description 4367SPEEX_PREPROCESS_GET_ECHO_SUPPRESS Get maximum attenuation of the residual 4368 echo in dB (negative 4369\begin_inset listings 4370inline true 4371status collapsed 4372 4373\begin_layout Plain Layout 4374 4375spx_int32_t 4376\end_layout 4377 4378\end_inset 4379 4380) 4381\end_layout 4382 4383\begin_layout Description 4384SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE Set maximum attenuation of the 4385 echo in dB when near end is active (negative 4386\begin_inset listings 4387inline true 4388status collapsed 4389 4390\begin_layout Plain Layout 4391 4392spx_int32_t 4393\end_layout 4394 4395\end_inset 4396 4397) 4398\end_layout 4399 4400\begin_layout Description 4401SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE Get maximum attenuation of the 4402 echo in dB when near end is active (negative 4403\begin_inset listings 4404inline true 4405status collapsed 4406 4407\begin_layout Plain Layout 4408 4409spx_int32_t 4410\end_layout 4411 4412\end_inset 4413 4414) 4415\end_layout 4416 4417\begin_layout Description 4418SPEEX_PREPROCESS_SET_ECHO_STATE Set the associated echo canceller for residual 4419 echo suppression (pointer or NULL for no residual echo suppression) 4420\end_layout 4421 4422\begin_layout Description 4423SPEEX_PREPROCESS_GET_ECHO_STATE Get the associated echo canceller (pointer) 4424\end_layout 4425 4426\begin_layout Section 4427Echo Cancellation 4428\begin_inset CommandInset label 4429LatexCommand label 4430name "sub:Echo-Cancellation" 4431 4432\end_inset 4433 4434 4435\end_layout 4436 4437\begin_layout Standard 4438The Speex library now includes an echo cancellation 4439\begin_inset Index 4440status collapsed 4441 4442\begin_layout Plain Layout 4443echo cancellation 4444\end_layout 4445 4446\end_inset 4447 4448 algorithm suitable for Acoustic Echo Cancellation 4449\begin_inset Index 4450status collapsed 4451 4452\begin_layout Plain Layout 4453acoustic echo cancellation 4454\end_layout 4455 4456\end_inset 4457 4458 (AEC). 4459 In order to use the echo canceller, you first need to 4460\end_layout 4461 4462\begin_layout Standard 4463\begin_inset listings 4464inline false 4465status open 4466 4467\begin_layout Plain Layout 4468 4469#include <speex/speex_echo.h> 4470\end_layout 4471 4472\end_inset 4473 4474 4475\end_layout 4476 4477\begin_layout Standard 4478Then, an echo canceller state can be created by: 4479\end_layout 4480 4481\begin_layout Standard 4482\begin_inset listings 4483inline false 4484status open 4485 4486\begin_layout Plain Layout 4487 4488SpeexEchoState *echo_state = speex_echo_state_init(frame_size, filter_length); 4489\end_layout 4490 4491\end_inset 4492 4493 4494\end_layout 4495 4496\begin_layout Standard 4497where 4498\family typewriter 4499frame_size 4500\family default 4501 is the amount of data (in samples) you want to process at once and 4502\family typewriter 4503filter_length 4504\family default 4505 is the length (in samples) of the echo cancelling filter you want to use 4506 (also known as 4507\shape italic 4508tail length 4509\shape default 4510 4511\begin_inset Index 4512status collapsed 4513 4514\begin_layout Plain Layout 4515tail length 4516\end_layout 4517 4518\end_inset 4519 4520). 4521 It is recommended to use a frame size in the order of 20 ms (or equal to 4522 the codec frame size) and make sure it is easy to perform an FFT of that 4523 size (powers of two are better than prime sizes). 4524 The recommended tail length is approximately the third of the room reverberatio 4525n time. 4526 For example, in a small room, reverberation time is in the order of 300 4527 ms, so a tail length of 100 ms is a good choice (800 samples at 8000 Hz 4528 sampling rate). 4529\end_layout 4530 4531\begin_layout Standard 4532Once the echo canceller state is created, audio can be processed by: 4533\end_layout 4534 4535\begin_layout Standard 4536\begin_inset listings 4537inline false 4538status open 4539 4540\begin_layout Plain Layout 4541 4542speex_echo_cancellation(echo_state, input_frame, echo_frame, output_frame); 4543\end_layout 4544 4545\end_inset 4546 4547 4548\end_layout 4549 4550\begin_layout Standard 4551where 4552\family typewriter 4553input_frame 4554\family default 4555 is the audio as captured by the microphone, 4556\family typewriter 4557echo_frame 4558\family default 4559 is the signal that was played in the speaker (and needs to be removed) 4560 and 4561\family typewriter 4562output_frame 4563\family default 4564 is the signal with echo removed. 4565 4566\end_layout 4567 4568\begin_layout Standard 4569One important thing to keep in mind is the relationship between 4570\family typewriter 4571input_frame 4572\family default 4573 and 4574\family typewriter 4575echo_frame 4576\family default 4577. 4578 It is important that, at any time, any echo that is present in the input 4579 has already been sent to the echo canceller as 4580\family typewriter 4581echo_frame 4582\family default 4583. 4584 In other words, the echo canceller cannot remove a signal that it hasn't 4585 yet received. 4586 On the other hand, the delay between the input signal and the echo signal 4587 must be small enough because otherwise part of the echo cancellation filter 4588 is inefficient. 4589 In the ideal case, you code would look like: 4590\begin_inset listings 4591lstparams "breaklines=true" 4592inline false 4593status open 4594 4595\begin_layout Plain Layout 4596 4597write_to_soundcard(echo_frame, frame_size); 4598\end_layout 4599 4600\begin_layout Plain Layout 4601 4602read_from_soundcard(input_frame, frame_size); 4603\end_layout 4604 4605\begin_layout Plain Layout 4606 4607speex_echo_cancellation(echo_state, input_frame, echo_frame, output_frame); 4608\end_layout 4609 4610\end_inset 4611 4612 4613\end_layout 4614 4615\begin_layout Standard 4616If you wish to further reduce the echo present in the signal, you can do 4617 so by associating the echo canceller to the preprocessor (see Section 4618\begin_inset CommandInset ref 4619LatexCommand ref 4620reference "sub:Preprocessor" 4621 4622\end_inset 4623 4624). 4625 This is done by calling: 4626\begin_inset listings 4627lstparams "breaklines=true" 4628inline false 4629status open 4630 4631\begin_layout Plain Layout 4632 4633speex_preprocess_ctl(preprocess_state, SPEEX_PREPROCESS_SET_ECHO_STATE,echo_stat 4634e); 4635\end_layout 4636 4637\end_inset 4638 4639in the initialisation. 4640\end_layout 4641 4642\begin_layout Standard 4643As of version 1.2-beta2, there is an alternative, simpler API that can be 4644 used instead of 4645\emph on 4646speex_echo_cancellation() 4647\emph default 4648. 4649 When audio capture and playback are handled asynchronously (e.g. 4650 in different threads or using the 4651\emph on 4652poll() 4653\emph default 4654 or 4655\emph on 4656select() 4657\emph default 4658 system call), it can be difficult to keep track of what input_frame comes 4659 with what echo_frame. 4660 Instead, the playback context/thread can simply call: 4661\end_layout 4662 4663\begin_layout Standard 4664\begin_inset listings 4665inline false 4666status open 4667 4668\begin_layout Plain Layout 4669 4670speex_echo_playback(echo_state, echo_frame); 4671\end_layout 4672 4673\end_inset 4674 4675 4676\end_layout 4677 4678\begin_layout Standard 4679every time an audio frame is played. 4680 Then, the capture context/thread calls: 4681\end_layout 4682 4683\begin_layout Standard 4684\begin_inset listings 4685inline false 4686status open 4687 4688\begin_layout Plain Layout 4689 4690speex_echo_capture(echo_state, input_frame, output_frame); 4691\end_layout 4692 4693\end_inset 4694 4695 4696\end_layout 4697 4698\begin_layout Standard 4699for every frame captured. 4700 Internally, 4701\emph on 4702speex_echo_playback() 4703\emph default 4704 simply buffers the playback frame so it can be used by 4705\emph on 4706speex_echo_capture() 4707\emph default 4708 to call 4709\emph on 4710speex_echo_cancel() 4711\emph default 4712. 4713 A side effect of using this alternate API is that the playback audio is 4714 delayed by two frames, which is the normal delay caused by the soundcard. 4715 When capture and playback are already synchronised, 4716\emph on 4717speex_echo_cancellation() 4718\emph default 4719 is preferable since it gives better control on the exact input/echo timing. 4720\end_layout 4721 4722\begin_layout Standard 4723The echo cancellation state can be destroyed with: 4724\end_layout 4725 4726\begin_layout Standard 4727\begin_inset listings 4728inline false 4729status open 4730 4731\begin_layout Plain Layout 4732 4733speex_echo_state_destroy(echo_state); 4734\end_layout 4735 4736\end_inset 4737 4738 4739\end_layout 4740 4741\begin_layout Standard 4742It is also possible to reset the state of the echo canceller so it can be 4743 reused without the need to create another state with: 4744\end_layout 4745 4746\begin_layout Standard 4747\begin_inset listings 4748inline false 4749status open 4750 4751\begin_layout Plain Layout 4752 4753speex_echo_state_reset(echo_state); 4754\end_layout 4755 4756\end_inset 4757 4758 4759\end_layout 4760 4761\begin_layout Subsection 4762Troubleshooting 4763\end_layout 4764 4765\begin_layout Standard 4766There are several things that may prevent the echo canceller from working 4767 properly. 4768 One of them is a bug (or something suboptimal) in the code, but there are 4769 many others you should consider first 4770\end_layout 4771 4772\begin_layout Itemize 4773Using a different soundcard to do the capture and plaback will 4774\series bold 4775not 4776\series default 4777 work, regardless of what you may think. 4778 The only exception to that is if the two cards can be made to have their 4779 sampling clock 4780\begin_inset Quotes eld 4781\end_inset 4782 4783locked 4784\begin_inset Quotes erd 4785\end_inset 4786 4787 on the same clock source. 4788 If not, the clocks will always have a small amount of drift, which will 4789 prevent the echo canceller from adapting. 4790\end_layout 4791 4792\begin_layout Itemize 4793The delay between the record and playback signals must be minimal. 4794 Any signal played has to 4795\begin_inset Quotes eld 4796\end_inset 4797 4798appear 4799\begin_inset Quotes erd 4800\end_inset 4801 4802 on the playback (far end) signal slightly before the echo canceller 4803\begin_inset Quotes eld 4804\end_inset 4805 4806sees 4807\begin_inset Quotes erd 4808\end_inset 4809 4810 it in the near end signal, but excessive delay means that part of the filter 4811 length is wasted. 4812 In the worst situations, the delay is such that it is longer than the filter 4813 length, in which case, no echo can be cancelled. 4814\end_layout 4815 4816\begin_layout Itemize 4817When it comes to echo tail length (filter length), longer is 4818\series bold 4819not 4820\series default 4821 better. 4822 Actually, the longer the tail length, the longer it takes for the filter 4823 to adapt. 4824 Of course, a tail length that is too short will not cancel enough echo, 4825 but the most common problem seen is that people set a very long tail length 4826 and then wonder why no echo is being cancelled. 4827\end_layout 4828 4829\begin_layout Itemize 4830Non-linear distortion cannot (by definition) be modeled by the linear adaptive 4831 filter used in the echo canceller and thus cannot be cancelled. 4832 Use good audio gear and avoid saturation/clipping. 4833\end_layout 4834 4835\begin_layout Standard 4836Also useful is reading 4837\emph on 4838Echo Cancellation Demystified 4839\emph default 4840 by Alexey Frunze 4841\begin_inset Foot 4842status collapsed 4843 4844\begin_layout Plain Layout 4845http://www.embeddedstar.com/articles/2003/7/article20030720-1.html 4846\end_layout 4847 4848\end_inset 4849 4850, which explains the fundamental principles of echo cancellation. 4851 The details of the algorithm described in the article are different, but 4852 the general ideas of echo cancellation through adaptive filters are the 4853 same. 4854\end_layout 4855 4856\begin_layout Standard 4857As of version 1.2beta2, a new 4858\family typewriter 4859echo_diagnostic.m 4860\family default 4861 tool is included in the source distribution. 4862 The first step is to define DUMP_ECHO_CANCEL_DATA during the build. 4863 This causes the echo canceller to automatically save the near-end, far-end 4864 and output signals to files (aec_rec.sw aec_play.sw and aec_out.sw). 4865 These are exactly what the AEC receives and outputs. 4866 From there, it is necessary to start Octave and type: 4867\end_layout 4868 4869\begin_layout Standard 4870\begin_inset listings 4871lstparams "language=Matlab" 4872inline false 4873status open 4874 4875\begin_layout Plain Layout 4876 4877echo_diagnostic('aec_rec.sw', 'aec_play.sw', 'aec_diagnostic.sw', 1024); 4878\end_layout 4879 4880\end_inset 4881 4882 4883\end_layout 4884 4885\begin_layout Standard 4886The value of 1024 is the filter length and can be changed. 4887 There will be some (hopefully) useful messages printed and echo cancelled 4888 audio will be saved to aec_diagnostic.sw . 4889 If even that output is bad (almost no cancellation) then there is probably 4890 problem with the playback or recording process. 4891\end_layout 4892 4893\begin_layout Section 4894Jitter Buffer 4895\end_layout 4896 4897\begin_layout Standard 4898The jitter buffer can be enabled by including: 4899\begin_inset listings 4900lstparams "breaklines=true" 4901inline false 4902status open 4903 4904\begin_layout Plain Layout 4905 4906#include <speex/speex_jitter.h> 4907\end_layout 4908 4909\end_inset 4910 4911 and a new jitter buffer state can be initialised by: 4912\end_layout 4913 4914\begin_layout Standard 4915\begin_inset listings 4916lstparams "breaklines=true" 4917inline false 4918status open 4919 4920\begin_layout Plain Layout 4921 4922JitterBuffer *state = jitter_buffer_init(step); 4923\end_layout 4924 4925\end_inset 4926 4927 4928\end_layout 4929 4930\begin_layout Standard 4931where the 4932\begin_inset listings 4933inline true 4934status collapsed 4935 4936\begin_layout Plain Layout 4937 4938step 4939\end_layout 4940 4941\end_inset 4942 4943 argument is the default time step (in timestamp units) used for adjusting 4944 the delay and doing concealment. 4945 A value of 1 is always correct, but higher values may be more convenient 4946 sometimes. 4947 For example, if you are only able to do concealment on 20ms frames, there 4948 is no point in the jitter buffer asking you to do it on one sample. 4949 Another example is that for video, it makes no sense to adjust the delay 4950 by less than a full frame. 4951 The value provided can always be changed at a later time. 4952\end_layout 4953 4954\begin_layout Standard 4955The jitter buffer API is based on the 4956\begin_inset listings 4957inline true 4958status open 4959 4960\begin_layout Plain Layout 4961 4962JitterBufferPacket 4963\end_layout 4964 4965\end_inset 4966 4967 type, which is defined as: 4968\begin_inset listings 4969inline false 4970status open 4971 4972\begin_layout Plain Layout 4973 4974typedef struct { 4975\end_layout 4976 4977\begin_layout Plain Layout 4978 4979 char *data; /* Data bytes contained in the packet */ 4980\end_layout 4981 4982\begin_layout Plain Layout 4983 4984 spx_uint32_t len; /* Length of the packet in bytes */ 4985\end_layout 4986 4987\begin_layout Plain Layout 4988 4989 spx_uint32_t timestamp; /* Timestamp for the packet */ 4990\end_layout 4991 4992\begin_layout Plain Layout 4993 4994 spx_uint32_t span; /* Time covered by the packet (timestamp units) 4995 */ 4996\end_layout 4997 4998\begin_layout Plain Layout 4999 5000} JitterBufferPacket; 5001\end_layout 5002 5003\end_inset 5004 5005 5006\end_layout 5007 5008\begin_layout Standard 5009As an example, for audio the timestamp field would be what is obtained from 5010 the RTP timestamp field and the span would be the number of samples that 5011 are encoded in the packet. 5012 For Speex narrowband, span would be 160 if only one frame is included in 5013 the packet. 5014 5015\end_layout 5016 5017\begin_layout Standard 5018When a packet arrives, it need to be inserter into the jitter buffer by: 5019\begin_inset listings 5020inline false 5021status open 5022 5023\begin_layout Plain Layout 5024 5025JitterBufferPacket packet; 5026\end_layout 5027 5028\begin_layout Plain Layout 5029 5030/* Fill in each field in the packet struct */ 5031\end_layout 5032 5033\begin_layout Plain Layout 5034 5035jitter_buffer_put(state, &packet); 5036\end_layout 5037 5038\end_inset 5039 5040 5041\end_layout 5042 5043\begin_layout Standard 5044When the decoder is ready to decode a packet the packet to be decoded can 5045 be obtained by: 5046\begin_inset listings 5047inline false 5048status open 5049 5050\begin_layout Plain Layout 5051 5052int start_offset; 5053\end_layout 5054 5055\begin_layout Plain Layout 5056 5057err = jitter_buffer_get(state, &packet, desired_span, &start_offset); 5058\end_layout 5059 5060\end_inset 5061 5062 5063\end_layout 5064 5065\begin_layout Standard 5066If 5067\begin_inset listings 5068inline true 5069status open 5070 5071\begin_layout Plain Layout 5072 5073jitter_buffer_put() 5074\end_layout 5075 5076\end_inset 5077 5078 and 5079\begin_inset listings 5080inline true 5081status collapsed 5082 5083\begin_layout Plain Layout 5084 5085jitter_buffer_get() 5086\end_layout 5087 5088\end_inset 5089 5090 are called from different threads, then 5091\series bold 5092you need to protect the jitter buffer state with a mutex 5093\series default 5094. 5095 5096\end_layout 5097 5098\begin_layout Standard 5099Because the jitter buffer is designed not to use an explicit timer, it needs 5100 to be told about the time explicitly. 5101 This is done by calling: 5102\begin_inset listings 5103inline false 5104status open 5105 5106\begin_layout Plain Layout 5107 5108jitter_buffer_tick(state); 5109\end_layout 5110 5111\end_inset 5112 5113 5114\end_layout 5115 5116\begin_layout Standard 5117This needs to be done periodically in the playing thread. 5118 This will be the last jitter buffer call before going to sleep (until more 5119 data is played back). 5120 In some cases, it may be preferable to use 5121\begin_inset listings 5122inline false 5123status open 5124 5125\begin_layout Plain Layout 5126 5127jitter_buffer_remaining_span(state, remaining); 5128\end_layout 5129 5130\end_inset 5131 5132 5133\end_layout 5134 5135\begin_layout Standard 5136The second argument is used to specify that we are still holding data that 5137 has not been written to the playback device. 5138 For instance, if 256 samples were needed by the soundcard (specified by 5139 5140\begin_inset listings 5141inline true 5142status collapsed 5143 5144\begin_layout Plain Layout 5145 5146desired_span 5147\end_layout 5148 5149\end_inset 5150 5151), but 5152\begin_inset listings 5153inline true 5154status collapsed 5155 5156\begin_layout Plain Layout 5157 5158jitter_buffer_get() 5159\end_layout 5160 5161\end_inset 5162 5163 returned 320 samples, we would have 5164\begin_inset listings 5165inline true 5166status open 5167 5168\begin_layout Plain Layout 5169 5170remaining=64 5171\end_layout 5172 5173\end_inset 5174 5175. 5176\end_layout 5177 5178\begin_layout Section 5179Resampler 5180\end_layout 5181 5182\begin_layout Standard 5183Speex includes a resampling modules. 5184 To make use of the resampler, it is necessary to include its header file: 5185\end_layout 5186 5187\begin_layout Standard 5188\begin_inset listings 5189inline false 5190status open 5191 5192\begin_layout Plain Layout 5193 5194#include <speex/speex_resampler.h> 5195\end_layout 5196 5197\end_inset 5198 5199 5200\end_layout 5201 5202\begin_layout Standard 5203For each stream that is to be resampled, it is necessary to create a resampler 5204 state with: 5205\end_layout 5206 5207\begin_layout Standard 5208\begin_inset listings 5209inline false 5210status open 5211 5212\begin_layout Plain Layout 5213 5214SpeexResamplerState *resampler; 5215\end_layout 5216 5217\begin_layout Plain Layout 5218 5219resampler = speex_resampler_init(nb_channels, input_rate, output_rate, quality, 5220 &err); 5221\end_layout 5222 5223\end_inset 5224 5225 5226\end_layout 5227 5228\begin_layout Standard 5229where 5230\begin_inset listings 5231inline true 5232status collapsed 5233 5234\begin_layout Plain Layout 5235 5236nb_channels 5237\end_layout 5238 5239\end_inset 5240 5241 is the number of channels that will be used (either interleaved or non-interlea 5242ved), 5243\begin_inset listings 5244inline true 5245status collapsed 5246 5247\begin_layout Plain Layout 5248 5249input_rate 5250\end_layout 5251 5252\end_inset 5253 5254 is the sampling rate of the input stream, 5255\begin_inset listings 5256inline true 5257status collapsed 5258 5259\begin_layout Plain Layout 5260 5261output_rate 5262\end_layout 5263 5264\end_inset 5265 5266 is the sampling rate of the output stream and 5267\begin_inset listings 5268inline true 5269status collapsed 5270 5271\begin_layout Plain Layout 5272 5273quality 5274\end_layout 5275 5276\end_inset 5277 5278 is the requested quality setting (0 to 10). 5279 The quality parameter is useful for controlling the quality/complexity/latency 5280 tradeoff. 5281 Using a higher quality setting means less noise/aliasing, a higher complexity 5282 and a higher latency. 5283 Usually, a quality of 3 is acceptable for most desktop uses and quality 5284 10 is mostly recommended for pro audio work. 5285 Quality 0 usually has a decent sound (certainly better than using linear 5286 interpolation resampling), but artifacts may be heard. 5287\end_layout 5288 5289\begin_layout Standard 5290The actual resampling is performed using 5291\end_layout 5292 5293\begin_layout Standard 5294\begin_inset listings 5295inline false 5296status open 5297 5298\begin_layout Plain Layout 5299 5300err = speex_resampler_process_int(resampler, channelID, in, &in_length, 5301 out, &out_length); 5302\end_layout 5303 5304\end_inset 5305 5306where 5307\begin_inset listings 5308inline true 5309status collapsed 5310 5311\begin_layout Plain Layout 5312 5313channelID 5314\end_layout 5315 5316\end_inset 5317 5318 is the ID of the channel to be processed. 5319 For a mono stream, use 0. 5320 The 5321\emph on 5322in 5323\emph default 5324 pointer points to the first sample of the input buffer for the selected 5325 channel and 5326\begin_inset listings 5327inline true 5328status collapsed 5329 5330\begin_layout Plain Layout 5331 5332out 5333\end_layout 5334 5335\end_inset 5336 5337 points to the first sample of the output. 5338 The size of the input and output buffers are specified by 5339\begin_inset listings 5340inline true 5341status collapsed 5342 5343\begin_layout Plain Layout 5344 5345in_length 5346\end_layout 5347 5348\end_inset 5349 5350 and 5351\begin_inset listings 5352inline true 5353status collapsed 5354 5355\begin_layout Plain Layout 5356 5357out_length 5358\end_layout 5359 5360\end_inset 5361 5362 respectively. 5363 Upon completion, these values are replaced by the number of samples read 5364 and written by the resampler. 5365 Unless an error occurs, either all input samples will be read or all output 5366 samples will be written to (or both). 5367 For floating-point samples, the function 5368\begin_inset listings 5369inline true 5370status open 5371 5372\begin_layout Plain Layout 5373 5374speex_resampler_process_float() 5375\end_layout 5376 5377\end_inset 5378 5379 behaves similarly. 5380\end_layout 5381 5382\begin_layout Standard 5383It is also possible to process multiple channels at once. 5384 To do that, you can use speex_resampler_process_interleaved_int() or 5385\begin_inset listings 5386inline true 5387status open 5388 5389\begin_layout Plain Layout 5390 5391speex_resampler_process_interleaved_float() 5392\end_layout 5393 5394\end_inset 5395 5396. 5397 The arguments are the same except that there is no 5398\begin_inset listings 5399inline true 5400status collapsed 5401 5402\begin_layout Plain Layout 5403 5404channelID 5405\end_layout 5406 5407\end_inset 5408 5409 argument. 5410 Note that the 5411\series bold 5412length parameters are per-channel 5413\series default 5414. 5415 So if you have 1024 samples for each of 4 channels, you pass 1024 and not 5416 4096. 5417\end_layout 5418 5419\begin_layout Standard 5420The resampler allows changing the quality and input/output sampling frequencies 5421 on the fly without glitches. 5422 This can be done with calls such as 5423\begin_inset listings 5424inline true 5425status open 5426 5427\begin_layout Plain Layout 5428 5429speex_resampler_set_quality() 5430\end_layout 5431 5432\end_inset 5433 5434 and 5435\begin_inset listings 5436inline true 5437status open 5438 5439\begin_layout Plain Layout 5440 5441speex_resampler_set_rate() 5442\end_layout 5443 5444\end_inset 5445 5446. 5447 The only side effect is that a new filter will have to be recomputed, consuming 5448 many CPU cycles. 5449 5450\end_layout 5451 5452\begin_layout Standard 5453When resampling a file, it is often desirable to have the output file perfectly 5454 synchronised with the input. 5455 To do that, you need to call 5456\begin_inset listings 5457inline true 5458status open 5459 5460\begin_layout Plain Layout 5461 5462speex_resampler_skip_zeros() 5463\end_layout 5464 5465\end_inset 5466 5467 5468\series bold 5469before 5470\series default 5471 you start processing any samples. 5472 For real-time applications (e.g. 5473 VoIP), it is not recommended to do that as the first process frame will 5474 be shorter to compensate for the delay (the skipped zeros). 5475 Instead, in real-time applications you may want to know how many delay 5476 is introduced by the resampler. 5477 This can be done at run-time with 5478\begin_inset listings 5479inline true 5480status open 5481 5482\begin_layout Plain Layout 5483 5484speex_resampler_get_input_latency() 5485\end_layout 5486 5487\end_inset 5488 5489 and 5490\begin_inset listings 5491inline true 5492status open 5493 5494\begin_layout Plain Layout 5495 5496speex_resampler_get_output_latency() 5497\end_layout 5498 5499\end_inset 5500 5501 functions. 5502 First function returns delay measured in samples at input samplerate, while 5503 second returns delay measured in samples at output samplerate. 5504\end_layout 5505 5506\begin_layout Standard 5507To destroy a resampler state, just call 5508\begin_inset listings 5509inline true 5510status open 5511 5512\begin_layout Plain Layout 5513 5514speex_resampler_destroy() 5515\end_layout 5516 5517\end_inset 5518 5519. 5520\end_layout 5521 5522\begin_layout Section 5523Ring Buffer 5524\end_layout 5525 5526\begin_layout Standard 5527In some cases, it is necessary to interface components that use different 5528 block sizes. 5529 For example, it is possible that the soundcard does not support reading/writing 5530 in blocks of 20 5531\begin_inset space ~ 5532\end_inset 5533 5534ms or sometimes, complicated resampling ratios mean that the blocks don't 5535 always have the same time. 5536 In thoses cases, it is often necessary to buffer a bit of audio using a 5537 ring buffer. 5538\end_layout 5539 5540\begin_layout Standard 5541\begin_inset Newpage newpage 5542\end_inset 5543 5544 5545\end_layout 5546 5547\begin_layout Chapter 5548Formats and standards 5549\begin_inset Index 5550status collapsed 5551 5552\begin_layout Plain Layout 5553standards 5554\end_layout 5555 5556\end_inset 5557 5558 5559\begin_inset CommandInset label 5560LatexCommand label 5561name "sec:Formats-and-standards" 5562 5563\end_inset 5564 5565 5566\end_layout 5567 5568\begin_layout Standard 5569Speex can encode speech in both narrowband and wideband and provides different 5570 bit-rates. 5571 However, not all features need to be supported by a certain implementation 5572 or device. 5573 In order to be called 5574\begin_inset Quotes eld 5575\end_inset 5576 5577Speex compatible 5578\begin_inset Quotes erd 5579\end_inset 5580 5581 (whatever that means), an implementation must implement at least a basic 5582 set of features. 5583\end_layout 5584 5585\begin_layout Standard 5586At the minimum, all narrowband modes of operation MUST be supported at the 5587 decoder. 5588 This includes the decoding of a wideband bit-stream by the narrowband decoder 5589\begin_inset Foot 5590status collapsed 5591 5592\begin_layout Plain Layout 5593The wideband bit-stream contains an embedded narrowband bit-stream which 5594 can be decoded alone 5595\end_layout 5596 5597\end_inset 5598 5599. 5600 If present, a wideband decoder MUST be able to decode a narrowband stream, 5601 and MAY either be able to decode all wideband modes or be able to decode 5602 the embedded narrowband part of all modes (which includes ignoring the 5603 high-band bits). 5604\end_layout 5605 5606\begin_layout Standard 5607For encoders, at least one narrowband or wideband mode MUST be supported. 5608 The main reason why all encoding modes do not have to be supported is that 5609 some platforms may not be able to handle the complexity of encoding in 5610 some modes. 5611\end_layout 5612 5613\begin_layout Section 5614RTP 5615\begin_inset Index 5616status collapsed 5617 5618\begin_layout Plain Layout 5619RTP 5620\end_layout 5621 5622\end_inset 5623 5624 Payload Format 5625\end_layout 5626 5627\begin_layout Standard 5628The RTP payload draft is included in appendix 5629\begin_inset CommandInset ref 5630LatexCommand ref 5631reference "sec:IETF-draft" 5632 5633\end_inset 5634 5635 and the latest version is available at 5636\begin_inset Flex URL 5637status collapsed 5638 5639\begin_layout Plain Layout 5640 5641http://www.speex.org/drafts/latest 5642\end_layout 5643 5644\end_inset 5645 5646. 5647 This draft has been sent (2003/02/26) to the Internet Engineering Task 5648 Force (IETF) and will be discussed at the March 18th meeting in San Francisco. 5649 5650\end_layout 5651 5652\begin_layout Section 5653MIME Type 5654\end_layout 5655 5656\begin_layout Standard 5657For now, you should use the MIME type audio/x-speex for Speex-in-Ogg. 5658 We will apply for type 5659\family typewriter 5660audio/speex 5661\family default 5662 in the near future. 5663\end_layout 5664 5665\begin_layout Section 5666Ogg 5667\begin_inset Index 5668status collapsed 5669 5670\begin_layout Plain Layout 5671Ogg 5672\end_layout 5673 5674\end_inset 5675 5676 file format 5677\end_layout 5678 5679\begin_layout Standard 5680Speex bit-streams can be stored in Ogg files. 5681 In this case, the first packet of the Ogg file contains the Speex header 5682 described in table 5683\begin_inset CommandInset ref 5684LatexCommand ref 5685reference "cap:ogg_speex_header" 5686 5687\end_inset 5688 5689. 5690 All integer fields in the headers are stored as little-endian. 5691 The 5692\family typewriter 5693speex_string 5694\family default 5695 field must contain the 5696\begin_inset Quotes eld 5697\end_inset 5698 5699 5700\family typewriter 5701Speex 5702\family default 5703 5704\begin_inset space ~ 5705\end_inset 5706 5707 5708\begin_inset space ~ 5709\end_inset 5710 5711 5712\begin_inset space ~ 5713\end_inset 5714 5715 5716\begin_inset Quotes erd 5717\end_inset 5718 5719 (with 3 trailing spaces), which identifies the bit-stream. 5720 The next field, 5721\family typewriter 5722speex_version 5723\family default 5724 contains the version of Speex that encoded the file. 5725 For now, refer to speex_header.[ch] for more info. 5726 The 5727\emph on 5728beginning of stream 5729\emph default 5730 ( 5731\family typewriter 5732b_o_s 5733\family default 5734) flag is set to 1 for the header. 5735 The header packet has 5736\family typewriter 5737packetno=0 5738\family default 5739 and 5740\family typewriter 5741granulepos=0 5742\family default 5743. 5744\end_layout 5745 5746\begin_layout Standard 5747The second packet contains the Speex comment header. 5748 The format used is the Vorbis comment format described here: http://www.xiph.org/ 5749ogg/vorbis/doc/v-comment.html . 5750 This packet has 5751\family typewriter 5752packetno=1 5753\family default 5754 and 5755\family typewriter 5756granulepos=0 5757\family default 5758. 5759\end_layout 5760 5761\begin_layout Standard 5762The third and subsequent packets each contain one or more (number found 5763 in header) Speex frames. 5764 These are identified with 5765\family typewriter 5766packetno 5767\family default 5768 starting from 2 and the 5769\family typewriter 5770granulepos 5771\family default 5772 is the number of the last sample encoded in that packet. 5773 The last of these packets has the 5774\emph on 5775end of stream 5776\emph default 5777 ( 5778\family typewriter 5779e_o_s 5780\family default 5781) flag is set to 1. 5782\end_layout 5783 5784\begin_layout Standard 5785\begin_inset Float table 5786placement htbp 5787wide true 5788sideways false 5789status open 5790 5791\begin_layout Plain Layout 5792\begin_inset ERT 5793status collapsed 5794 5795\begin_layout Plain Layout 5796 5797 5798\backslash 5799begin{center} 5800\end_layout 5801 5802\end_inset 5803 5804 5805\begin_inset Tabular 5806<lyxtabular version="3" rows="16" columns="3"> 5807<features> 5808<column alignment="center" valignment="top" width="0pt"> 5809<column alignment="center" valignment="top" width="0pt"> 5810<column alignment="center" valignment="top" width="0pt"> 5811<row> 5812<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 5813\begin_inset Text 5814 5815\begin_layout Plain Layout 5816Field 5817\end_layout 5818 5819\end_inset 5820</cell> 5821<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 5822\begin_inset Text 5823 5824\begin_layout Plain Layout 5825Type 5826\end_layout 5827 5828\end_inset 5829</cell> 5830<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 5831\begin_inset Text 5832 5833\begin_layout Plain Layout 5834Size 5835\end_layout 5836 5837\end_inset 5838</cell> 5839</row> 5840<row> 5841<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5842\begin_inset Text 5843 5844\begin_layout Plain Layout 5845speex_string 5846\end_layout 5847 5848\end_inset 5849</cell> 5850<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5851\begin_inset Text 5852 5853\begin_layout Plain Layout 5854char[] 5855\end_layout 5856 5857\end_inset 5858</cell> 5859<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 5860\begin_inset Text 5861 5862\begin_layout Plain Layout 58638 5864\end_layout 5865 5866\end_inset 5867</cell> 5868</row> 5869<row> 5870<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5871\begin_inset Text 5872 5873\begin_layout Plain Layout 5874speex_version 5875\end_layout 5876 5877\end_inset 5878</cell> 5879<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5880\begin_inset Text 5881 5882\begin_layout Plain Layout 5883char[] 5884\end_layout 5885 5886\end_inset 5887</cell> 5888<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 5889\begin_inset Text 5890 5891\begin_layout Plain Layout 589220 5893\end_layout 5894 5895\end_inset 5896</cell> 5897</row> 5898<row> 5899<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5900\begin_inset Text 5901 5902\begin_layout Plain Layout 5903speex_version_id 5904\end_layout 5905 5906\end_inset 5907</cell> 5908<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5909\begin_inset Text 5910 5911\begin_layout Plain Layout 5912int 5913\end_layout 5914 5915\end_inset 5916</cell> 5917<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 5918\begin_inset Text 5919 5920\begin_layout Plain Layout 59214 5922\end_layout 5923 5924\end_inset 5925</cell> 5926</row> 5927<row> 5928<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5929\begin_inset Text 5930 5931\begin_layout Plain Layout 5932header_size 5933\end_layout 5934 5935\end_inset 5936</cell> 5937<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5938\begin_inset Text 5939 5940\begin_layout Plain Layout 5941int 5942\end_layout 5943 5944\end_inset 5945</cell> 5946<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 5947\begin_inset Text 5948 5949\begin_layout Plain Layout 59504 5951\end_layout 5952 5953\end_inset 5954</cell> 5955</row> 5956<row> 5957<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5958\begin_inset Text 5959 5960\begin_layout Plain Layout 5961rate 5962\end_layout 5963 5964\end_inset 5965</cell> 5966<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5967\begin_inset Text 5968 5969\begin_layout Plain Layout 5970int 5971\end_layout 5972 5973\end_inset 5974</cell> 5975<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 5976\begin_inset Text 5977 5978\begin_layout Plain Layout 59794 5980\end_layout 5981 5982\end_inset 5983</cell> 5984</row> 5985<row> 5986<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5987\begin_inset Text 5988 5989\begin_layout Plain Layout 5990mode 5991\end_layout 5992 5993\end_inset 5994</cell> 5995<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 5996\begin_inset Text 5997 5998\begin_layout Plain Layout 5999int 6000\end_layout 6001 6002\end_inset 6003</cell> 6004<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 6005\begin_inset Text 6006 6007\begin_layout Plain Layout 60084 6009\end_layout 6010 6011\end_inset 6012</cell> 6013</row> 6014<row> 6015<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6016\begin_inset Text 6017 6018\begin_layout Plain Layout 6019mode_bitstream_version 6020\end_layout 6021 6022\end_inset 6023</cell> 6024<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6025\begin_inset Text 6026 6027\begin_layout Plain Layout 6028int 6029\end_layout 6030 6031\end_inset 6032</cell> 6033<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 6034\begin_inset Text 6035 6036\begin_layout Plain Layout 60374 6038\end_layout 6039 6040\end_inset 6041</cell> 6042</row> 6043<row> 6044<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6045\begin_inset Text 6046 6047\begin_layout Plain Layout 6048nb_channels 6049\end_layout 6050 6051\end_inset 6052</cell> 6053<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6054\begin_inset Text 6055 6056\begin_layout Plain Layout 6057int 6058\end_layout 6059 6060\end_inset 6061</cell> 6062<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 6063\begin_inset Text 6064 6065\begin_layout Plain Layout 60664 6067\end_layout 6068 6069\end_inset 6070</cell> 6071</row> 6072<row> 6073<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6074\begin_inset Text 6075 6076\begin_layout Plain Layout 6077bitrate 6078\end_layout 6079 6080\end_inset 6081</cell> 6082<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6083\begin_inset Text 6084 6085\begin_layout Plain Layout 6086int 6087\end_layout 6088 6089\end_inset 6090</cell> 6091<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 6092\begin_inset Text 6093 6094\begin_layout Plain Layout 60954 6096\end_layout 6097 6098\end_inset 6099</cell> 6100</row> 6101<row> 6102<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6103\begin_inset Text 6104 6105\begin_layout Plain Layout 6106frame_size 6107\end_layout 6108 6109\end_inset 6110</cell> 6111<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6112\begin_inset Text 6113 6114\begin_layout Plain Layout 6115int 6116\end_layout 6117 6118\end_inset 6119</cell> 6120<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 6121\begin_inset Text 6122 6123\begin_layout Plain Layout 61244 6125\end_layout 6126 6127\end_inset 6128</cell> 6129</row> 6130<row> 6131<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6132\begin_inset Text 6133 6134\begin_layout Plain Layout 6135vbr 6136\end_layout 6137 6138\end_inset 6139</cell> 6140<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6141\begin_inset Text 6142 6143\begin_layout Plain Layout 6144int 6145\end_layout 6146 6147\end_inset 6148</cell> 6149<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 6150\begin_inset Text 6151 6152\begin_layout Plain Layout 61534 6154\end_layout 6155 6156\end_inset 6157</cell> 6158</row> 6159<row> 6160<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6161\begin_inset Text 6162 6163\begin_layout Plain Layout 6164frames_per_packet 6165\end_layout 6166 6167\end_inset 6168</cell> 6169<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6170\begin_inset Text 6171 6172\begin_layout Plain Layout 6173int 6174\end_layout 6175 6176\end_inset 6177</cell> 6178<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 6179\begin_inset Text 6180 6181\begin_layout Plain Layout 61824 6183\end_layout 6184 6185\end_inset 6186</cell> 6187</row> 6188<row> 6189<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6190\begin_inset Text 6191 6192\begin_layout Plain Layout 6193extra_headers 6194\end_layout 6195 6196\end_inset 6197</cell> 6198<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6199\begin_inset Text 6200 6201\begin_layout Plain Layout 6202int 6203\end_layout 6204 6205\end_inset 6206</cell> 6207<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 6208\begin_inset Text 6209 6210\begin_layout Plain Layout 62114 6212\end_layout 6213 6214\end_inset 6215</cell> 6216</row> 6217<row> 6218<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6219\begin_inset Text 6220 6221\begin_layout Plain Layout 6222reserved1 6223\end_layout 6224 6225\end_inset 6226</cell> 6227<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 6228\begin_inset Text 6229 6230\begin_layout Plain Layout 6231int 6232\end_layout 6233 6234\end_inset 6235</cell> 6236<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 6237\begin_inset Text 6238 6239\begin_layout Plain Layout 62404 6241\end_layout 6242 6243\end_inset 6244</cell> 6245</row> 6246<row> 6247<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 6248\begin_inset Text 6249 6250\begin_layout Plain Layout 6251reserved2 6252\end_layout 6253 6254\end_inset 6255</cell> 6256<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 6257\begin_inset Text 6258 6259\begin_layout Plain Layout 6260int 6261\end_layout 6262 6263\end_inset 6264</cell> 6265<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 6266\begin_inset Text 6267 6268\begin_layout Plain Layout 62694 6270\end_layout 6271 6272\end_inset 6273</cell> 6274</row> 6275</lyxtabular> 6276 6277\end_inset 6278 6279 6280\begin_inset ERT 6281status collapsed 6282 6283\begin_layout Plain Layout 6284 6285 6286\backslash 6287end{center} 6288\end_layout 6289 6290\end_inset 6291 6292 6293\end_layout 6294 6295\begin_layout Plain Layout 6296\begin_inset Caption 6297 6298\begin_layout Plain Layout 6299Ogg/Speex header packet 6300\begin_inset CommandInset label 6301LatexCommand label 6302name "cap:ogg_speex_header" 6303 6304\end_inset 6305 6306 6307\end_layout 6308 6309\end_inset 6310 6311 6312\end_layout 6313 6314\end_inset 6315 6316 6317\end_layout 6318 6319\begin_layout Standard 6320\begin_inset ERT 6321status collapsed 6322 6323\begin_layout Plain Layout 6324 6325 6326\backslash 6327clearpage 6328\end_layout 6329 6330\end_inset 6331 6332 6333\end_layout 6334 6335\begin_layout Chapter 6336Introduction to CELP Coding 6337\begin_inset Index 6338status collapsed 6339 6340\begin_layout Plain Layout 6341CELP 6342\end_layout 6343 6344\end_inset 6345 6346 6347\begin_inset CommandInset label 6348LatexCommand label 6349name "sec:Introduction-to-CELP" 6350 6351\end_inset 6352 6353 6354\end_layout 6355 6356\begin_layout Quote 6357\align center 6358 6359\emph on 6360Do not meddle in the affairs of poles, for they are subtle and quick to 6361 leave the unit circle. 6362\end_layout 6363 6364\begin_layout Standard 6365Speex is based on CELP, which stands for Code Excited Linear Prediction. 6366 This section attempts to introduce the principles behind CELP, so if you 6367 are already familiar with CELP, you can safely skip to section 6368\begin_inset CommandInset ref 6369LatexCommand ref 6370reference "sec:Speex-narrowband-mode" 6371 6372\end_inset 6373 6374. 6375 The CELP technique is based on three ideas: 6376\end_layout 6377 6378\begin_layout Enumerate 6379The use of a linear prediction (LP) model to model the vocal tract 6380\end_layout 6381 6382\begin_layout Enumerate 6383The use of (adaptive and fixed) codebook entries as input (excitation) of 6384 the LP model 6385\end_layout 6386 6387\begin_layout Enumerate 6388The search performed in closed-loop in a 6389\begin_inset Quotes eld 6390\end_inset 6391 6392perceptually weighted domain 6393\begin_inset Quotes erd 6394\end_inset 6395 6396 6397\end_layout 6398 6399\begin_layout Standard 6400This section describes the basic ideas behind CELP. 6401 This is still a work in progress. 6402\end_layout 6403 6404\begin_layout Section 6405Source-Filter Model of Speech Prediction 6406\end_layout 6407 6408\begin_layout Standard 6409The source-filter model of speech production assumes that the vocal cords 6410 are the source of spectrally flat sound (the excitation signal), and that 6411 the vocal tract acts as a filter to spectrally shape the various sounds 6412 of speech. 6413 While still an approximation, the model is widely used in speech coding 6414 because of its simplicity.Its use is also the reason why most speech codecs 6415 (Speex included) perform badly on music signals. 6416 The different phonemes can be distinguished by their excitation (source) 6417 and spectral shape (filter). 6418 Voiced sounds (e.g. 6419 vowels) have an excitation signal that is periodic and that can be approximated 6420 by an impulse train in the time domain or by regularly-spaced harmonics 6421 in the frequency domain. 6422 On the other hand, fricatives (such as the "s", "sh" and "f" sounds) have 6423 an excitation signal that is similar to white Gaussian noise. 6424 So called voice fricatives (such as "z" and "v") have excitation signal 6425 composed of an harmonic part and a noisy part. 6426\end_layout 6427 6428\begin_layout Standard 6429The source-filter model is usually tied with the use of Linear prediction. 6430 The CELP model is based on source-filter model, as can be seen from the 6431 CELP decoder illustrated in Figure 6432\begin_inset CommandInset ref 6433LatexCommand ref 6434reference "fig:The-CELP-model" 6435 6436\end_inset 6437 6438. 6439 6440\end_layout 6441 6442\begin_layout Standard 6443\begin_inset Float figure 6444wide false 6445sideways false 6446status open 6447 6448\begin_layout Plain Layout 6449\begin_inset ERT 6450status collapsed 6451 6452\begin_layout Plain Layout 6453 6454 6455\backslash 6456begin{center} 6457\end_layout 6458 6459\end_inset 6460 6461 6462\begin_inset Graphics 6463 filename celp_decoder.eps 6464 width 45page% 6465 keepAspectRatio 6466 6467\end_inset 6468 6469 6470\begin_inset ERT 6471status collapsed 6472 6473\begin_layout Plain Layout 6474 6475 6476\backslash 6477end{center} 6478\end_layout 6479 6480\end_inset 6481 6482 6483\end_layout 6484 6485\begin_layout Plain Layout 6486\begin_inset Caption 6487 6488\begin_layout Plain Layout 6489The CELP model of speech synthesis (decoder) 6490\begin_inset CommandInset label 6491LatexCommand label 6492name "fig:The-CELP-model" 6493 6494\end_inset 6495 6496 6497\end_layout 6498 6499\end_inset 6500 6501 6502\end_layout 6503 6504\end_inset 6505 6506 6507\end_layout 6508 6509\begin_layout Section 6510Linear Prediction Coefficients (LPC) 6511\begin_inset Index 6512status collapsed 6513 6514\begin_layout Plain Layout 6515linear prediction 6516\end_layout 6517 6518\end_inset 6519 6520 6521\end_layout 6522 6523\begin_layout Standard 6524Linear prediction is at the base of many speech coding techniques, including 6525 CELP. 6526 The idea behind it is to predict the signal 6527\begin_inset Formula $x[n]$ 6528\end_inset 6529 6530 using a linear combination of its past samples: 6531\end_layout 6532 6533\begin_layout Standard 6534\begin_inset Formula \[ 6535y[n]=\sum_{i=1}^{N}a_{i}x[n-i]\] 6536 6537\end_inset 6538 6539where 6540\begin_inset Formula $y[n]$ 6541\end_inset 6542 6543 is the linear prediction of 6544\begin_inset Formula $x[n]$ 6545\end_inset 6546 6547. 6548 The prediction error is thus given by: 6549\begin_inset Formula \[ 6550e[n]=x[n]-y[n]=x[n]-\sum_{i=1}^{N}a_{i}x[n-i]\] 6551 6552\end_inset 6553 6554 6555\end_layout 6556 6557\begin_layout Standard 6558The goal of the LPC analysis is to find the best prediction coefficients 6559 6560\begin_inset Formula $a_{i}$ 6561\end_inset 6562 6563 which minimize the quadratic error function: 6564\begin_inset Formula \[ 6565E=\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}\] 6566 6567\end_inset 6568 6569That can be done by making all derivatives 6570\begin_inset Formula $\frac{\partial E}{\partial a_{i}}$ 6571\end_inset 6572 6573 equal to zero: 6574\begin_inset Formula \[ 6575\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\] 6576 6577\end_inset 6578 6579 6580\end_layout 6581 6582\begin_layout Standard 6583For an order 6584\begin_inset Formula $N$ 6585\end_inset 6586 6587 filter, the filter coefficients 6588\begin_inset Formula $a_{i}$ 6589\end_inset 6590 6591 are found by solving the system 6592\begin_inset Formula $N\times N$ 6593\end_inset 6594 6595 linear system 6596\begin_inset Formula $\mathbf{Ra}=\mathbf{r}$ 6597\end_inset 6598 6599, where 6600\begin_inset Formula \[ 6601\mathbf{R}=\left[\begin{array}{cccc} 6602R(0) & R(1) & \cdots & R(N-1)\\ 6603R(1) & R(0) & \cdots & R(N-2)\\ 6604\vdots & \vdots & \ddots & \vdots\\ 6605R(N-1) & R(N-2) & \cdots & R(0)\end{array}\right]\] 6606 6607\end_inset 6608 6609 6610\begin_inset Formula \[ 6611\mathbf{r}=\left[\begin{array}{c} 6612R(1)\\ 6613R(2)\\ 6614\vdots\\ 6615R(N)\end{array}\right]\] 6616 6617\end_inset 6618 6619with 6620\begin_inset Formula $R(m)$ 6621\end_inset 6622 6623, the auto-correlation 6624\begin_inset Index 6625status collapsed 6626 6627\begin_layout Plain Layout 6628auto-correlation 6629\end_layout 6630 6631\end_inset 6632 6633 of the signal 6634\begin_inset Formula $x[n]$ 6635\end_inset 6636 6637, computed as: 6638\end_layout 6639 6640\begin_layout Standard 6641\begin_inset Formula \[ 6642R(m)=\sum_{i=0}^{N-1}x[i]x[i-m]\] 6643 6644\end_inset 6645 6646 6647\end_layout 6648 6649\begin_layout Standard 6650Because 6651\begin_inset Formula $\mathbf{R}$ 6652\end_inset 6653 6654 is Hermitian Toeplitz, the Levinson-Durbin 6655\begin_inset Index 6656status collapsed 6657 6658\begin_layout Plain Layout 6659Levinson-Durbin 6660\end_layout 6661 6662\end_inset 6663 6664 algorithm can be used, making the solution to the problem 6665\begin_inset Formula $\mathcal{O}\left(N^{2}\right)$ 6666\end_inset 6667 6668 instead of 6669\begin_inset Formula $\mathcal{O}\left(N^{3}\right)$ 6670\end_inset 6671 6672. 6673 Also, it can be proven that all the roots of 6674\begin_inset Formula $A(z)$ 6675\end_inset 6676 6677 are within the unit circle, which means that 6678\begin_inset Formula $1/A(z)$ 6679\end_inset 6680 6681 is always stable. 6682 This is in theory; in practice because of finite precision, there are two 6683 commonly used techniques to make sure we have a stable filter. 6684 First, we multiply 6685\begin_inset Formula $R(0)$ 6686\end_inset 6687 6688 by a number slightly above one (such as 1.0001), which is equivalent to 6689 adding noise to the signal. 6690 Also, we can apply a window to the auto-correlation, which is equivalent 6691 to filtering in the frequency domain, reducing sharp resonances. 6692\end_layout 6693 6694\begin_layout Section 6695Pitch Prediction 6696\begin_inset Index 6697status collapsed 6698 6699\begin_layout Plain Layout 6700pitch 6701\end_layout 6702 6703\end_inset 6704 6705 6706\end_layout 6707 6708\begin_layout Standard 6709During voiced segments, the speech signal is periodic, so it is possible 6710 to take advantage of that property by approximating the excitation signal 6711 6712\begin_inset Formula $e[n]$ 6713\end_inset 6714 6715 by a gain times the past of the excitation: 6716\end_layout 6717 6718\begin_layout Standard 6719\begin_inset Formula \[ 6720e[n]\simeq p[n]=\beta e[n-T]\ ,\] 6721 6722\end_inset 6723 6724where 6725\begin_inset Formula $T$ 6726\end_inset 6727 6728 is the pitch period, 6729\begin_inset Formula $\beta$ 6730\end_inset 6731 6732 is the pitch gain. 6733 We call that long-term prediction since the excitation is predicted from 6734 6735\begin_inset Formula $e[n-T]$ 6736\end_inset 6737 6738 with 6739\begin_inset Formula $T\gg N$ 6740\end_inset 6741 6742. 6743\end_layout 6744 6745\begin_layout Section 6746Innovation Codebook 6747\end_layout 6748 6749\begin_layout Standard 6750The final excitation 6751\begin_inset Formula $e[n]$ 6752\end_inset 6753 6754 will be the sum of the pitch prediction and an 6755\emph on 6756innovation 6757\emph default 6758 signal 6759\begin_inset Formula $c[n]$ 6760\end_inset 6761 6762 taken from a fixed codebook, hence the name 6763\emph on 6764Code 6765\emph default 6766 Excited Linear Prediction. 6767 The final excitation is given by 6768\end_layout 6769 6770\begin_layout Standard 6771\begin_inset Formula \[ 6772e[n]=p[n]+c[n]=\beta e[n-T]+c[n]\ .\] 6773 6774\end_inset 6775 6776The quantization of 6777\begin_inset Formula $c[n]$ 6778\end_inset 6779 6780 is where most of the bits in a CELP codec are allocated. 6781 It represents the information that couldn't be obtained either from linear 6782 prediction or pitch prediction. 6783 In the 6784\emph on 6785z 6786\emph default 6787-domain we can represent the final signal 6788\begin_inset Formula $X(z)$ 6789\end_inset 6790 6791 as 6792\begin_inset Formula \[ 6793X(z)=\frac{C(z)}{A(z)\left(1-\beta z^{-T}\right)}\] 6794 6795\end_inset 6796 6797 6798\end_layout 6799 6800\begin_layout Section 6801Noise Weighting 6802\begin_inset Index 6803status collapsed 6804 6805\begin_layout Plain Layout 6806error weighting 6807\end_layout 6808 6809\end_inset 6810 6811 6812\begin_inset Index 6813status collapsed 6814 6815\begin_layout Plain Layout 6816analysis-by-synthesis 6817\end_layout 6818 6819\end_inset 6820 6821 6822\end_layout 6823 6824\begin_layout Standard 6825Most (if not all) modern audio codecs attempt to 6826\begin_inset Quotes eld 6827\end_inset 6828 6829shape 6830\begin_inset Quotes erd 6831\end_inset 6832 6833 the noise so that it appears mostly in the frequency regions where the 6834 ear cannot detect it. 6835 For example, the ear is more tolerant to noise in parts of the spectrum 6836 that are louder and 6837\emph on 6838vice versa 6839\emph default 6840. 6841 In order to maximize speech quality, CELP codecs minimize the mean square 6842 of the error (noise) in the perceptually weighted domain. 6843 This means that a perceptual noise weighting filter 6844\begin_inset Formula $W(z)$ 6845\end_inset 6846 6847 is applied to the error signal in the encoder. 6848 In most CELP codecs, 6849\begin_inset Formula $W(z)$ 6850\end_inset 6851 6852 is a pole-zero weighting filter derived from the linear prediction coefficients 6853 (LPC), generally using bandwidth expansion. 6854 Let the spectral envelope be represented by the synthesis filter 6855\begin_inset Formula $1/A(z)$ 6856\end_inset 6857 6858, CELP codecs typically derive the noise weighting filter as 6859\begin_inset Formula \begin{equation} 6860W(z)=\frac{A(z/\gamma_{1})}{A(z/\gamma_{2})}\ ,\label{eq:gamma-weighting}\end{equation} 6861 6862\end_inset 6863 6864where 6865\begin_inset Formula $\gamma_{1}=0.9$ 6866\end_inset 6867 6868 and 6869\begin_inset Formula $\gamma_{2}=0.6$ 6870\end_inset 6871 6872 in the Speex reference implementation. 6873 If a filter 6874\begin_inset Formula $A(z)$ 6875\end_inset 6876 6877 has (complex) poles at 6878\begin_inset Formula $p_{i}$ 6879\end_inset 6880 6881 in the 6882\begin_inset Formula $z$ 6883\end_inset 6884 6885-plane, the filter 6886\begin_inset Formula $A(z/\gamma)$ 6887\end_inset 6888 6889 will have its poles at 6890\begin_inset Formula $p'_{i}=\gamma p_{i}$ 6891\end_inset 6892 6893, making it a flatter version of 6894\begin_inset Formula $A(z)$ 6895\end_inset 6896 6897. 6898\end_layout 6899 6900\begin_layout Standard 6901The weighting filter is applied to the error signal used to optimize the 6902 codebook search through analysis-by-synthesis (AbS). 6903 This results in a spectral shape of the noise that tends towards 6904\begin_inset Formula $1/W(z)$ 6905\end_inset 6906 6907. 6908 While the simplicity of the model has been an important reason for the 6909 success of CELP, it remains that 6910\begin_inset Formula $W(z)$ 6911\end_inset 6912 6913 is a very rough approximation for the perceptually optimal noise weighting 6914 function. 6915 Fig. 6916 6917\begin_inset CommandInset ref 6918LatexCommand ref 6919reference "cap:Standard-noise-shaping" 6920 6921\end_inset 6922 6923 illustrates the noise shaping that results from Eq. 6924 6925\begin_inset CommandInset ref 6926LatexCommand ref 6927reference "eq:gamma-weighting" 6928 6929\end_inset 6930 6931. 6932 Throughout this paper, we refer to 6933\begin_inset Formula $W(z)$ 6934\end_inset 6935 6936 as the noise weighting filter and to 6937\begin_inset Formula $1/W(z)$ 6938\end_inset 6939 6940 as the noise shaping filter (or curve). 6941\end_layout 6942 6943\begin_layout Standard 6944\begin_inset Float figure 6945wide false 6946sideways false 6947status open 6948 6949\begin_layout Plain Layout 6950\begin_inset ERT 6951status collapsed 6952 6953\begin_layout Plain Layout 6954 6955 6956\backslash 6957begin{center} 6958\end_layout 6959 6960\end_inset 6961 6962 6963\begin_inset Graphics 6964 filename ref_shaping.eps 6965 width 45page% 6966 keepAspectRatio 6967 6968\end_inset 6969 6970 6971\begin_inset ERT 6972status collapsed 6973 6974\begin_layout Plain Layout 6975 6976 6977\backslash 6978end{center} 6979\end_layout 6980 6981\end_inset 6982 6983 6984\end_layout 6985 6986\begin_layout Plain Layout 6987\begin_inset Caption 6988 6989\begin_layout Plain Layout 6990Standard noise shaping in CELP. 6991 Arbitrary y-axis offset. 6992\begin_inset CommandInset label 6993LatexCommand label 6994name "cap:Standard-noise-shaping" 6995 6996\end_inset 6997 6998 6999\end_layout 7000 7001\end_inset 7002 7003 7004\end_layout 7005 7006\end_inset 7007 7008 7009\end_layout 7010 7011\begin_layout Section 7012Analysis-by-Synthesis 7013\end_layout 7014 7015\begin_layout Standard 7016One of the main principles behind CELP is called Analysis-by-Synthesis (AbS), 7017 meaning that the encoding (analysis) is performed by perceptually optimising 7018 the decoded (synthesis) signal in a closed loop. 7019 In theory, the best CELP stream would be produced by trying all possible 7020 bit combinations and selecting the one that produces the best-sounding 7021 decoded signal. 7022 This is obviously not possible in practice for two reasons: the required 7023 complexity is beyond any currently available hardware and the 7024\begin_inset Quotes eld 7025\end_inset 7026 7027best sounding 7028\begin_inset Quotes erd 7029\end_inset 7030 7031 selection criterion implies a human listener. 7032 7033\end_layout 7034 7035\begin_layout Standard 7036In order to achieve real-time encoding using limited computing resources, 7037 the CELP optimisation is broken down into smaller, more manageable, sequential 7038 searches using the perceptual weighting function described earlier. 7039\end_layout 7040 7041\begin_layout Standard 7042\begin_inset Newpage newpage 7043\end_inset 7044 7045 7046\end_layout 7047 7048\begin_layout Chapter 7049The Speex Decoder Specification 7050\end_layout 7051 7052\begin_layout Section 7053Narrowband decoder 7054\end_layout 7055 7056\begin_layout Standard 7057<Insert decoder figure here> 7058\end_layout 7059 7060\begin_layout Subsection 7061Narrowband modes 7062\end_layout 7063 7064\begin_layout Standard 7065There are 7 different narrowband bit-rates defined for Speex, ranging from 7066 250 bps to 24.6 kbps, although the modes below 5.9 kbps should not be used 7067 for speech. 7068 The bit-allocation for each mode is detailed in table 7069\begin_inset CommandInset ref 7070LatexCommand ref 7071reference "cap:bits-narrowband" 7072 7073\end_inset 7074 7075. 7076 Each frame starts with the mode ID encoded with 4 bits which allows a range 7077 from 0 to 15, though only the first 7 values are used (the others are reserved). 7078 The parameters are listed in the table in the order they are packed in 7079 the bit-stream. 7080 All frame-based parameters are packed before sub-frame parameters. 7081 The parameters for a certain sub-frame are all packed before the following 7082 sub-frame is packed. 7083 The 7084\begin_inset Quotes eld 7085\end_inset 7086 7087OL 7088\begin_inset Quotes erd 7089\end_inset 7090 7091 in the parameter description means that the parameter is an open loop estimatio 7092n based on the whole frame. 7093\end_layout 7094 7095\begin_layout Standard 7096\begin_inset Float table 7097placement h 7098wide true 7099sideways false 7100status open 7101 7102\begin_layout Plain Layout 7103\begin_inset ERT 7104status collapsed 7105 7106\begin_layout Plain Layout 7107 7108 7109\backslash 7110begin{center} 7111\end_layout 7112 7113\end_inset 7114 7115 7116\begin_inset Tabular 7117<lyxtabular version="3" rows="12" columns="11"> 7118<features> 7119<column alignment="center" valignment="top" width="0pt"> 7120<column alignment="center" valignment="top" width="0pt"> 7121<column alignment="center" valignment="top" width="0pt"> 7122<column alignment="center" valignment="top" width="0pt"> 7123<column alignment="center" valignment="top" width="0pt"> 7124<column alignment="center" valignment="top" width="0pt"> 7125<column alignment="center" valignment="top" width="0pt"> 7126<column alignment="center" valignment="top" width="0pt"> 7127<column alignment="center" valignment="top" width="0pt"> 7128<column alignment="center" valignment="top" width="0pt"> 7129<column alignment="center" valignment="top" width="0pt"> 7130<row> 7131<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 7132\begin_inset Text 7133 7134\begin_layout Plain Layout 7135Parameter 7136\end_layout 7137 7138\end_inset 7139</cell> 7140<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 7141\begin_inset Text 7142 7143\begin_layout Plain Layout 7144Update rate 7145\end_layout 7146 7147\end_inset 7148</cell> 7149<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 7150\begin_inset Text 7151 7152\begin_layout Plain Layout 71530 7154\end_layout 7155 7156\end_inset 7157</cell> 7158<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 7159\begin_inset Text 7160 7161\begin_layout Plain Layout 71621 7163\end_layout 7164 7165\end_inset 7166</cell> 7167<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 7168\begin_inset Text 7169 7170\begin_layout Plain Layout 71712 7172\end_layout 7173 7174\end_inset 7175</cell> 7176<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 7177\begin_inset Text 7178 7179\begin_layout Plain Layout 71803 7181\end_layout 7182 7183\end_inset 7184</cell> 7185<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 7186\begin_inset Text 7187 7188\begin_layout Plain Layout 71894 7190\end_layout 7191 7192\end_inset 7193</cell> 7194<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 7195\begin_inset Text 7196 7197\begin_layout Plain Layout 71985 7199\end_layout 7200 7201\end_inset 7202</cell> 7203<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 7204\begin_inset Text 7205 7206\begin_layout Plain Layout 72076 7208\end_layout 7209 7210\end_inset 7211</cell> 7212<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 7213\begin_inset Text 7214 7215\begin_layout Plain Layout 72167 7217\end_layout 7218 7219\end_inset 7220</cell> 7221<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 7222\begin_inset Text 7223 7224\begin_layout Plain Layout 72258 7226\end_layout 7227 7228\end_inset 7229</cell> 7230</row> 7231<row> 7232<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7233\begin_inset Text 7234 7235\begin_layout Plain Layout 7236Wideband bit 7237\end_layout 7238 7239\end_inset 7240</cell> 7241<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7242\begin_inset Text 7243 7244\begin_layout Plain Layout 7245frame 7246\end_layout 7247 7248\end_inset 7249</cell> 7250<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7251\begin_inset Text 7252 7253\begin_layout Plain Layout 72541 7255\end_layout 7256 7257\end_inset 7258</cell> 7259<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7260\begin_inset Text 7261 7262\begin_layout Plain Layout 72631 7264\end_layout 7265 7266\end_inset 7267</cell> 7268<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7269\begin_inset Text 7270 7271\begin_layout Plain Layout 72721 7273\end_layout 7274 7275\end_inset 7276</cell> 7277<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7278\begin_inset Text 7279 7280\begin_layout Plain Layout 72811 7282\end_layout 7283 7284\end_inset 7285</cell> 7286<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7287\begin_inset Text 7288 7289\begin_layout Plain Layout 72901 7291\end_layout 7292 7293\end_inset 7294</cell> 7295<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7296\begin_inset Text 7297 7298\begin_layout Plain Layout 72991 7300\end_layout 7301 7302\end_inset 7303</cell> 7304<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7305\begin_inset Text 7306 7307\begin_layout Plain Layout 73081 7309\end_layout 7310 7311\end_inset 7312</cell> 7313<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7314\begin_inset Text 7315 7316\begin_layout Plain Layout 73171 7318\end_layout 7319 7320\end_inset 7321</cell> 7322<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 7323\begin_inset Text 7324 7325\begin_layout Plain Layout 73261 7327\end_layout 7328 7329\end_inset 7330</cell> 7331</row> 7332<row> 7333<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7334\begin_inset Text 7335 7336\begin_layout Plain Layout 7337Mode ID 7338\end_layout 7339 7340\end_inset 7341</cell> 7342<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7343\begin_inset Text 7344 7345\begin_layout Plain Layout 7346frame 7347\end_layout 7348 7349\end_inset 7350</cell> 7351<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7352\begin_inset Text 7353 7354\begin_layout Plain Layout 73554 7356\end_layout 7357 7358\end_inset 7359</cell> 7360<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7361\begin_inset Text 7362 7363\begin_layout Plain Layout 73644 7365\end_layout 7366 7367\end_inset 7368</cell> 7369<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7370\begin_inset Text 7371 7372\begin_layout Plain Layout 73734 7374\end_layout 7375 7376\end_inset 7377</cell> 7378<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7379\begin_inset Text 7380 7381\begin_layout Plain Layout 73824 7383\end_layout 7384 7385\end_inset 7386</cell> 7387<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7388\begin_inset Text 7389 7390\begin_layout Plain Layout 73914 7392\end_layout 7393 7394\end_inset 7395</cell> 7396<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7397\begin_inset Text 7398 7399\begin_layout Plain Layout 74004 7401\end_layout 7402 7403\end_inset 7404</cell> 7405<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7406\begin_inset Text 7407 7408\begin_layout Plain Layout 74094 7410\end_layout 7411 7412\end_inset 7413</cell> 7414<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7415\begin_inset Text 7416 7417\begin_layout Plain Layout 74184 7419\end_layout 7420 7421\end_inset 7422</cell> 7423<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 7424\begin_inset Text 7425 7426\begin_layout Plain Layout 74274 7428\end_layout 7429 7430\end_inset 7431</cell> 7432</row> 7433<row> 7434<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7435\begin_inset Text 7436 7437\begin_layout Plain Layout 7438LSP 7439\end_layout 7440 7441\end_inset 7442</cell> 7443<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7444\begin_inset Text 7445 7446\begin_layout Plain Layout 7447frame 7448\end_layout 7449 7450\end_inset 7451</cell> 7452<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7453\begin_inset Text 7454 7455\begin_layout Plain Layout 74560 7457\end_layout 7458 7459\end_inset 7460</cell> 7461<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7462\begin_inset Text 7463 7464\begin_layout Plain Layout 746518 7466\end_layout 7467 7468\end_inset 7469</cell> 7470<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7471\begin_inset Text 7472 7473\begin_layout Plain Layout 747418 7475\end_layout 7476 7477\end_inset 7478</cell> 7479<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7480\begin_inset Text 7481 7482\begin_layout Plain Layout 748318 7484\end_layout 7485 7486\end_inset 7487</cell> 7488<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7489\begin_inset Text 7490 7491\begin_layout Plain Layout 749218 7493\end_layout 7494 7495\end_inset 7496</cell> 7497<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7498\begin_inset Text 7499 7500\begin_layout Plain Layout 750130 7502\end_layout 7503 7504\end_inset 7505</cell> 7506<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7507\begin_inset Text 7508 7509\begin_layout Plain Layout 751030 7511\end_layout 7512 7513\end_inset 7514</cell> 7515<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7516\begin_inset Text 7517 7518\begin_layout Plain Layout 751930 7520\end_layout 7521 7522\end_inset 7523</cell> 7524<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 7525\begin_inset Text 7526 7527\begin_layout Plain Layout 752818 7529\end_layout 7530 7531\end_inset 7532</cell> 7533</row> 7534<row> 7535<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7536\begin_inset Text 7537 7538\begin_layout Plain Layout 7539OL pitch 7540\end_layout 7541 7542\end_inset 7543</cell> 7544<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7545\begin_inset Text 7546 7547\begin_layout Plain Layout 7548frame 7549\end_layout 7550 7551\end_inset 7552</cell> 7553<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7554\begin_inset Text 7555 7556\begin_layout Plain Layout 75570 7558\end_layout 7559 7560\end_inset 7561</cell> 7562<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7563\begin_inset Text 7564 7565\begin_layout Plain Layout 75667 7567\end_layout 7568 7569\end_inset 7570</cell> 7571<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7572\begin_inset Text 7573 7574\begin_layout Plain Layout 75757 7576\end_layout 7577 7578\end_inset 7579</cell> 7580<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7581\begin_inset Text 7582 7583\begin_layout Plain Layout 75840 7585\end_layout 7586 7587\end_inset 7588</cell> 7589<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7590\begin_inset Text 7591 7592\begin_layout Plain Layout 75930 7594\end_layout 7595 7596\end_inset 7597</cell> 7598<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7599\begin_inset Text 7600 7601\begin_layout Plain Layout 76020 7603\end_layout 7604 7605\end_inset 7606</cell> 7607<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7608\begin_inset Text 7609 7610\begin_layout Plain Layout 76110 7612\end_layout 7613 7614\end_inset 7615</cell> 7616<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7617\begin_inset Text 7618 7619\begin_layout Plain Layout 76200 7621\end_layout 7622 7623\end_inset 7624</cell> 7625<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 7626\begin_inset Text 7627 7628\begin_layout Plain Layout 76297 7630\end_layout 7631 7632\end_inset 7633</cell> 7634</row> 7635<row> 7636<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7637\begin_inset Text 7638 7639\begin_layout Plain Layout 7640OL pitch gain 7641\end_layout 7642 7643\end_inset 7644</cell> 7645<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7646\begin_inset Text 7647 7648\begin_layout Plain Layout 7649frame 7650\end_layout 7651 7652\end_inset 7653</cell> 7654<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7655\begin_inset Text 7656 7657\begin_layout Plain Layout 76580 7659\end_layout 7660 7661\end_inset 7662</cell> 7663<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7664\begin_inset Text 7665 7666\begin_layout Plain Layout 76674 7668\end_layout 7669 7670\end_inset 7671</cell> 7672<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7673\begin_inset Text 7674 7675\begin_layout Plain Layout 76760 7677\end_layout 7678 7679\end_inset 7680</cell> 7681<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7682\begin_inset Text 7683 7684\begin_layout Plain Layout 76850 7686\end_layout 7687 7688\end_inset 7689</cell> 7690<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7691\begin_inset Text 7692 7693\begin_layout Plain Layout 76940 7695\end_layout 7696 7697\end_inset 7698</cell> 7699<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7700\begin_inset Text 7701 7702\begin_layout Plain Layout 77030 7704\end_layout 7705 7706\end_inset 7707</cell> 7708<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7709\begin_inset Text 7710 7711\begin_layout Plain Layout 77120 7713\end_layout 7714 7715\end_inset 7716</cell> 7717<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7718\begin_inset Text 7719 7720\begin_layout Plain Layout 77210 7722\end_layout 7723 7724\end_inset 7725</cell> 7726<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 7727\begin_inset Text 7728 7729\begin_layout Plain Layout 77304 7731\end_layout 7732 7733\end_inset 7734</cell> 7735</row> 7736<row> 7737<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7738\begin_inset Text 7739 7740\begin_layout Plain Layout 7741OL Exc gain 7742\end_layout 7743 7744\end_inset 7745</cell> 7746<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7747\begin_inset Text 7748 7749\begin_layout Plain Layout 7750frame 7751\end_layout 7752 7753\end_inset 7754</cell> 7755<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7756\begin_inset Text 7757 7758\begin_layout Plain Layout 77590 7760\end_layout 7761 7762\end_inset 7763</cell> 7764<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7765\begin_inset Text 7766 7767\begin_layout Plain Layout 77685 7769\end_layout 7770 7771\end_inset 7772</cell> 7773<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7774\begin_inset Text 7775 7776\begin_layout Plain Layout 77775 7778\end_layout 7779 7780\end_inset 7781</cell> 7782<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7783\begin_inset Text 7784 7785\begin_layout Plain Layout 77865 7787\end_layout 7788 7789\end_inset 7790</cell> 7791<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7792\begin_inset Text 7793 7794\begin_layout Plain Layout 77955 7796\end_layout 7797 7798\end_inset 7799</cell> 7800<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7801\begin_inset Text 7802 7803\begin_layout Plain Layout 78045 7805\end_layout 7806 7807\end_inset 7808</cell> 7809<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7810\begin_inset Text 7811 7812\begin_layout Plain Layout 78135 7814\end_layout 7815 7816\end_inset 7817</cell> 7818<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7819\begin_inset Text 7820 7821\begin_layout Plain Layout 78225 7823\end_layout 7824 7825\end_inset 7826</cell> 7827<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 7828\begin_inset Text 7829 7830\begin_layout Plain Layout 78315 7832\end_layout 7833 7834\end_inset 7835</cell> 7836</row> 7837<row> 7838<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7839\begin_inset Text 7840 7841\begin_layout Plain Layout 7842Fine pitch 7843\end_layout 7844 7845\end_inset 7846</cell> 7847<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7848\begin_inset Text 7849 7850\begin_layout Plain Layout 7851sub-frame 7852\end_layout 7853 7854\end_inset 7855</cell> 7856<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7857\begin_inset Text 7858 7859\begin_layout Plain Layout 78600 7861\end_layout 7862 7863\end_inset 7864</cell> 7865<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7866\begin_inset Text 7867 7868\begin_layout Plain Layout 78690 7870\end_layout 7871 7872\end_inset 7873</cell> 7874<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7875\begin_inset Text 7876 7877\begin_layout Plain Layout 78780 7879\end_layout 7880 7881\end_inset 7882</cell> 7883<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7884\begin_inset Text 7885 7886\begin_layout Plain Layout 78877 7888\end_layout 7889 7890\end_inset 7891</cell> 7892<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7893\begin_inset Text 7894 7895\begin_layout Plain Layout 78967 7897\end_layout 7898 7899\end_inset 7900</cell> 7901<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7902\begin_inset Text 7903 7904\begin_layout Plain Layout 79057 7906\end_layout 7907 7908\end_inset 7909</cell> 7910<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7911\begin_inset Text 7912 7913\begin_layout Plain Layout 79147 7915\end_layout 7916 7917\end_inset 7918</cell> 7919<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7920\begin_inset Text 7921 7922\begin_layout Plain Layout 79237 7924\end_layout 7925 7926\end_inset 7927</cell> 7928<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 7929\begin_inset Text 7930 7931\begin_layout Plain Layout 79320 7933\end_layout 7934 7935\end_inset 7936</cell> 7937</row> 7938<row> 7939<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7940\begin_inset Text 7941 7942\begin_layout Plain Layout 7943Pitch gain 7944\end_layout 7945 7946\end_inset 7947</cell> 7948<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7949\begin_inset Text 7950 7951\begin_layout Plain Layout 7952sub-frame 7953\end_layout 7954 7955\end_inset 7956</cell> 7957<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7958\begin_inset Text 7959 7960\begin_layout Plain Layout 79610 7962\end_layout 7963 7964\end_inset 7965</cell> 7966<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7967\begin_inset Text 7968 7969\begin_layout Plain Layout 79700 7971\end_layout 7972 7973\end_inset 7974</cell> 7975<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7976\begin_inset Text 7977 7978\begin_layout Plain Layout 79795 7980\end_layout 7981 7982\end_inset 7983</cell> 7984<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7985\begin_inset Text 7986 7987\begin_layout Plain Layout 79885 7989\end_layout 7990 7991\end_inset 7992</cell> 7993<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 7994\begin_inset Text 7995 7996\begin_layout Plain Layout 79975 7998\end_layout 7999 8000\end_inset 8001</cell> 8002<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8003\begin_inset Text 8004 8005\begin_layout Plain Layout 80067 8007\end_layout 8008 8009\end_inset 8010</cell> 8011<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8012\begin_inset Text 8013 8014\begin_layout Plain Layout 80157 8016\end_layout 8017 8018\end_inset 8019</cell> 8020<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8021\begin_inset Text 8022 8023\begin_layout Plain Layout 80247 8025\end_layout 8026 8027\end_inset 8028</cell> 8029<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 8030\begin_inset Text 8031 8032\begin_layout Plain Layout 80330 8034\end_layout 8035 8036\end_inset 8037</cell> 8038</row> 8039<row> 8040<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8041\begin_inset Text 8042 8043\begin_layout Plain Layout 8044Innovation gain 8045\end_layout 8046 8047\end_inset 8048</cell> 8049<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8050\begin_inset Text 8051 8052\begin_layout Plain Layout 8053sub-frame 8054\end_layout 8055 8056\end_inset 8057</cell> 8058<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8059\begin_inset Text 8060 8061\begin_layout Plain Layout 80620 8063\end_layout 8064 8065\end_inset 8066</cell> 8067<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8068\begin_inset Text 8069 8070\begin_layout Plain Layout 80711 8072\end_layout 8073 8074\end_inset 8075</cell> 8076<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8077\begin_inset Text 8078 8079\begin_layout Plain Layout 80800 8081\end_layout 8082 8083\end_inset 8084</cell> 8085<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8086\begin_inset Text 8087 8088\begin_layout Plain Layout 80891 8090\end_layout 8091 8092\end_inset 8093</cell> 8094<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8095\begin_inset Text 8096 8097\begin_layout Plain Layout 80981 8099\end_layout 8100 8101\end_inset 8102</cell> 8103<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8104\begin_inset Text 8105 8106\begin_layout Plain Layout 81073 8108\end_layout 8109 8110\end_inset 8111</cell> 8112<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8113\begin_inset Text 8114 8115\begin_layout Plain Layout 81163 8117\end_layout 8118 8119\end_inset 8120</cell> 8121<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 8122\begin_inset Text 8123 8124\begin_layout Plain Layout 81253 8126\end_layout 8127 8128\end_inset 8129</cell> 8130<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 8131\begin_inset Text 8132 8133\begin_layout Plain Layout 81340 8135\end_layout 8136 8137\end_inset 8138</cell> 8139</row> 8140<row> 8141<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8142\begin_inset Text 8143 8144\begin_layout Plain Layout 8145Innovation VQ 8146\end_layout 8147 8148\end_inset 8149</cell> 8150<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8151\begin_inset Text 8152 8153\begin_layout Plain Layout 8154sub-frame 8155\end_layout 8156 8157\end_inset 8158</cell> 8159<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8160\begin_inset Text 8161 8162\begin_layout Plain Layout 81630 8164\end_layout 8165 8166\end_inset 8167</cell> 8168<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8169\begin_inset Text 8170 8171\begin_layout Plain Layout 81720 8173\end_layout 8174 8175\end_inset 8176</cell> 8177<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8178\begin_inset Text 8179 8180\begin_layout Plain Layout 818116 8182\end_layout 8183 8184\end_inset 8185</cell> 8186<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8187\begin_inset Text 8188 8189\begin_layout Plain Layout 819020 8191\end_layout 8192 8193\end_inset 8194</cell> 8195<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8196\begin_inset Text 8197 8198\begin_layout Plain Layout 819935 8200\end_layout 8201 8202\end_inset 8203</cell> 8204<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8205\begin_inset Text 8206 8207\begin_layout Plain Layout 820848 8209\end_layout 8210 8211\end_inset 8212</cell> 8213<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8214\begin_inset Text 8215 8216\begin_layout Plain Layout 821764 8218\end_layout 8219 8220\end_inset 8221</cell> 8222<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8223\begin_inset Text 8224 8225\begin_layout Plain Layout 822696 8227\end_layout 8228 8229\end_inset 8230</cell> 8231<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 8232\begin_inset Text 8233 8234\begin_layout Plain Layout 823510 8236\end_layout 8237 8238\end_inset 8239</cell> 8240</row> 8241<row> 8242<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8243\begin_inset Text 8244 8245\begin_layout Plain Layout 8246Total 8247\end_layout 8248 8249\end_inset 8250</cell> 8251<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8252\begin_inset Text 8253 8254\begin_layout Plain Layout 8255frame 8256\end_layout 8257 8258\end_inset 8259</cell> 8260<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8261\begin_inset Text 8262 8263\begin_layout Plain Layout 82645 8265\end_layout 8266 8267\end_inset 8268</cell> 8269<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8270\begin_inset Text 8271 8272\begin_layout Plain Layout 827343 8274\end_layout 8275 8276\end_inset 8277</cell> 8278<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8279\begin_inset Text 8280 8281\begin_layout Plain Layout 8282119 8283\end_layout 8284 8285\end_inset 8286</cell> 8287<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8288\begin_inset Text 8289 8290\begin_layout Plain Layout 8291160 8292\end_layout 8293 8294\end_inset 8295</cell> 8296<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8297\begin_inset Text 8298 8299\begin_layout Plain Layout 8300220 8301\end_layout 8302 8303\end_inset 8304</cell> 8305<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8306\begin_inset Text 8307 8308\begin_layout Plain Layout 8309300 8310\end_layout 8311 8312\end_inset 8313</cell> 8314<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8315\begin_inset Text 8316 8317\begin_layout Plain Layout 8318364 8319\end_layout 8320 8321\end_inset 8322</cell> 8323<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8324\begin_inset Text 8325 8326\begin_layout Plain Layout 8327492 8328\end_layout 8329 8330\end_inset 8331</cell> 8332<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 8333\begin_inset Text 8334 8335\begin_layout Plain Layout 833679 8337\end_layout 8338 8339\end_inset 8340</cell> 8341</row> 8342</lyxtabular> 8343 8344\end_inset 8345 8346 8347\begin_inset ERT 8348status collapsed 8349 8350\begin_layout Plain Layout 8351 8352 8353\backslash 8354end{center} 8355\end_layout 8356 8357\end_inset 8358 8359 8360\end_layout 8361 8362\begin_layout Plain Layout 8363\begin_inset Caption 8364 8365\begin_layout Plain Layout 8366Bit allocation for narrowband modes 8367\begin_inset CommandInset label 8368LatexCommand label 8369name "cap:bits-narrowband" 8370 8371\end_inset 8372 8373 8374\end_layout 8375 8376\end_inset 8377 8378 8379\end_layout 8380 8381\end_inset 8382 8383 8384\end_layout 8385 8386\begin_layout Subsection 8387LSP decoding 8388\end_layout 8389 8390\begin_layout Standard 8391Depending on the mode, LSP parameters are encoded using either 18 bits or 8392 30 bits. 8393\end_layout 8394 8395\begin_layout Standard 8396Interpolation 8397\end_layout 8398 8399\begin_layout Standard 8400Safe margin 8401\end_layout 8402 8403\begin_layout Subsection 8404Adaptive codebook 8405\end_layout 8406 8407\begin_layout Standard 8408For rates of 8 kbit/s and above, the pitch period is encoded for each subframe. 8409 The real period is 8410\begin_inset Formula $T=p_{i}+17$ 8411\end_inset 8412 8413 where 8414\begin_inset Formula $p_{i}$ 8415\end_inset 8416 8417 is a value encoded with 7 bits and 17 corresponds to the minimum pitch. 8418 The maximum period is 144. 8419 At 5.95 kbit/s (mode 2), the pitch period is similarly encoded, but only 8420 once for the frame. 8421 Each sub-frame then has a 2-bit offset that is added to the pitch value 8422 of the frame. 8423 In that case, the pitch for each sub-frame is equal to 8424\begin_inset Formula $T-1+offset$ 8425\end_inset 8426 8427. 8428 For rates below 5.95 kbit/s, only the per-frame pitch is used and the pitch 8429 is constant for all sub-frames. 8430\end_layout 8431 8432\begin_layout Standard 8433Speex uses a 3-tap predictor for rates of 5.95 kbit/s and above. 8434 The three gain values are obtained from a 5-bit or a 7-bit codebook, depending 8435 on the mode. 8436 8437\end_layout 8438 8439\begin_layout Subsection 8440Innovation codebook 8441\end_layout 8442 8443\begin_layout Standard 8444Split codebook, size and entries depend on bit-rate 8445\end_layout 8446 8447\begin_layout Standard 8448a 5-bit gain is encoder on a per-frame basis 8449\end_layout 8450 8451\begin_layout Standard 8452Depending on the mode, higher resolution per sub-frame 8453\end_layout 8454 8455\begin_layout Standard 8456innovation sub-vectors concatenated, gain applied 8457\end_layout 8458 8459\begin_layout Subsection 8460Perceptual enhancement 8461\end_layout 8462 8463\begin_layout Standard 8464Optional, implementation-defined. 8465 8466\end_layout 8467 8468\begin_layout Subsection 8469Bit-stream definition 8470\end_layout 8471 8472\begin_layout Standard 8473This section defines the bit-stream that is transmitted on the wire. 8474 One speex packet consist of 1 frame header and 4 sub-frames: 8475\end_layout 8476 8477\begin_layout Standard 8478\begin_inset Tabular 8479<lyxtabular version="3" rows="1" columns="5"> 8480<features> 8481<column alignment="center" valignment="top" width="0"> 8482<column alignment="center" valignment="top" width="0"> 8483<column alignment="center" valignment="top" width="0"> 8484<column alignment="center" valignment="top" width="0"> 8485<column alignment="center" valignment="top" width="0"> 8486<row> 8487<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8488\begin_inset Text 8489 8490\begin_layout Plain Layout 8491Frame Header 8492\end_layout 8493 8494\end_inset 8495</cell> 8496<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8497\begin_inset Text 8498 8499\begin_layout Plain Layout 8500Subframe 1 8501\end_layout 8502 8503\end_inset 8504</cell> 8505<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8506\begin_inset Text 8507 8508\begin_layout Plain Layout 8509Subframe2 8510\end_layout 8511 8512\end_inset 8513</cell> 8514<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8515\begin_inset Text 8516 8517\begin_layout Plain Layout 8518Subframe 3 8519\end_layout 8520 8521\end_inset 8522</cell> 8523<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 8524\begin_inset Text 8525 8526\begin_layout Plain Layout 8527Subframe 4 8528\end_layout 8529 8530\end_inset 8531</cell> 8532</row> 8533</lyxtabular> 8534 8535\end_inset 8536 8537 8538\end_layout 8539 8540\begin_layout Standard 8541The frame header is variable length, depending on decoding mode and submode. 8542 The narrowband frame header is defined as follows: 8543\end_layout 8544 8545\begin_layout Standard 8546\begin_inset Tabular 8547<lyxtabular version="3" rows="1" columns="6"> 8548<features> 8549<column alignment="center" valignment="top" width="0"> 8550<column alignment="center" valignment="top" width="0"> 8551<column alignment="center" valignment="top" width="0"> 8552<column alignment="center" valignment="top" width="0"> 8553<column alignment="center" valignment="top" width="0"> 8554<column alignment="center" valignment="top" width="0"> 8555<row> 8556<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8557\begin_inset Text 8558 8559\begin_layout Plain Layout 8560wb bit 8561\end_layout 8562 8563\end_inset 8564</cell> 8565<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8566\begin_inset Text 8567 8568\begin_layout Plain Layout 8569modeid 8570\end_layout 8571 8572\end_inset 8573</cell> 8574<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8575\begin_inset Text 8576 8577\begin_layout Plain Layout 8578LSP 8579\end_layout 8580 8581\end_inset 8582</cell> 8583<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8584\begin_inset Text 8585 8586\begin_layout Plain Layout 8587OL-pitch 8588\end_layout 8589 8590\end_inset 8591</cell> 8592<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8593\begin_inset Text 8594 8595\begin_layout Plain Layout 8596OL-pitchgain 8597\end_layout 8598 8599\end_inset 8600</cell> 8601<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 8602\begin_inset Text 8603 8604\begin_layout Plain Layout 8605OL ExcGain 8606\end_layout 8607 8608\end_inset 8609</cell> 8610</row> 8611</lyxtabular> 8612 8613\end_inset 8614 8615 8616\end_layout 8617 8618\begin_layout Standard 8619wb-bit: Wideband bit (1 bit) 0=narrowband, 1=wideband 8620\end_layout 8621 8622\begin_layout Standard 8623modeid: Mode identifier (4 bits) 8624\end_layout 8625 8626\begin_layout Standard 8627LSP: Line Spectral Pairs (0, 18 or 30 bits) 8628\end_layout 8629 8630\begin_layout Standard 8631OL-pitch: Open Loop Pitch (0 or 7 bits) 8632\end_layout 8633 8634\begin_layout Standard 8635OL-pitchgain: Open Loop Pitch Gain (0 or 4 bits) 8636\end_layout 8637 8638\begin_layout Standard 8639OL-ExcGain: Open Loop Excitation Gain (0 or 5 bits) 8640\end_layout 8641 8642\begin_layout Standard 8643... 8644\end_layout 8645 8646\begin_layout Standard 8647Each subframe is defined as follows: 8648\end_layout 8649 8650\begin_layout Standard 8651\begin_inset Tabular 8652<lyxtabular version="3" rows="1" columns="4"> 8653<features> 8654<column alignment="center" valignment="top" width="0"> 8655<column alignment="center" valignment="top" width="0"> 8656<column alignment="center" valignment="top" width="0"> 8657<column alignment="center" valignment="top" width="0"> 8658<row> 8659<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8660\begin_inset Text 8661 8662\begin_layout Plain Layout 8663FinePitch 8664\end_layout 8665 8666\end_inset 8667</cell> 8668<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8669\begin_inset Text 8670 8671\begin_layout Plain Layout 8672PitchGain 8673\end_layout 8674 8675\end_inset 8676</cell> 8677<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 8678\begin_inset Text 8679 8680\begin_layout Plain Layout 8681InnovationGain 8682\end_layout 8683 8684\end_inset 8685</cell> 8686<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 8687\begin_inset Text 8688 8689\begin_layout Plain Layout 8690Innovation VQ 8691\end_layout 8692 8693\end_inset 8694</cell> 8695</row> 8696</lyxtabular> 8697 8698\end_inset 8699 8700 8701\end_layout 8702 8703\begin_layout Standard 8704FinePitch: (0 or 7 bits) 8705\end_layout 8706 8707\begin_layout Standard 8708PitchGain: (0, 5, or 7 bits) 8709\end_layout 8710 8711\begin_layout Standard 8712Innovation Gain: (0, 1, 3 bits) 8713\end_layout 8714 8715\begin_layout Standard 8716Innovation VQ: (0-96 bits) 8717\end_layout 8718 8719\begin_layout Standard 8720... 8721\end_layout 8722 8723\begin_layout Subsection 8724Sample decoder 8725\end_layout 8726 8727\begin_layout Standard 8728This section contains some sample source code, showing how a basic Speex 8729 decoder can be implemented. 8730 The sample decoder is narrowband submode 3 only, and with no advanced features 8731 like enhancement, vbr etc. 8732\end_layout 8733 8734\begin_layout Standard 8735... 8736\end_layout 8737 8738\begin_layout Subsection 8739Lookup tables 8740\end_layout 8741 8742\begin_layout Standard 8743The Speex decoder includes a set of lookup tables and codebooks, which are 8744 used to convert between values of different domains. 8745 This includes: 8746\end_layout 8747 8748\begin_layout Standard 8749- Excitation 10x16 (3200 bps) 8750\end_layout 8751 8752\begin_layout Standard 8753- Excitation 10x32 (4000 bps) 8754\end_layout 8755 8756\begin_layout Standard 8757- Excitation 20x32 (2000 bps) 8758\end_layout 8759 8760\begin_layout Standard 8761- Excitation 5x256 (12800 bps) 8762\end_layout 8763 8764\begin_layout Standard 8765- Excitation 5x64 (9600 bps) 8766\end_layout 8767 8768\begin_layout Standard 8769- Excitation 8x128 (7000 bps) 8770\end_layout 8771 8772\begin_layout Standard 8773- Codebook for 3-tap pitch prediction gain (Normal and Low Bitrate) 8774\end_layout 8775 8776\begin_layout Standard 8777- Codebook for LSPs in narrowband CELP mode 8778\end_layout 8779 8780\begin_layout Standard 8781... 8782\end_layout 8783 8784\begin_layout Standard 8785The exact lookup tables are included here for reference. 8786\end_layout 8787 8788\begin_layout Section 8789Wideband embedded decoder 8790\end_layout 8791 8792\begin_layout Standard 8793QMF filter. 8794 Narrowband signal decoded using narrowband decoder 8795\end_layout 8796 8797\begin_layout Standard 8798For the high band, the decoder is similar to the narrowband decoder, with 8799 the main difference being that there is no adaptive codebook. 8800\end_layout 8801 8802\begin_layout Standard 8803Gain is per-subframe 8804\end_layout 8805 8806\begin_layout Chapter 8807Speex narrowband mode 8808\begin_inset CommandInset label 8809LatexCommand label 8810name "sec:Speex-narrowband-mode" 8811 8812\end_inset 8813 8814 8815\begin_inset Index 8816status collapsed 8817 8818\begin_layout Plain Layout 8819narrowband 8820\end_layout 8821 8822\end_inset 8823 8824 8825\end_layout 8826 8827\begin_layout Standard 8828This section looks at how Speex works for narrowband ( 8829\begin_inset Formula $8\:\mathrm{kHz}$ 8830\end_inset 8831 8832 sampling rate) operation. 8833 The frame size for this mode is 8834\begin_inset Formula $20\:\mathrm{ms}$ 8835\end_inset 8836 8837, corresponding to 160 samples. 8838 Each frame is also subdivided into 4 sub-frames of 40 samples each. 8839\end_layout 8840 8841\begin_layout Standard 8842Also many design decisions were based on the original goals and assumptions: 8843\end_layout 8844 8845\begin_layout Itemize 8846Minimizing the amount of information extracted from past frames (for robustness 8847 to packet loss) 8848\end_layout 8849 8850\begin_layout Itemize 8851Dynamically-selectable codebooks (LSP, pitch and innovation) 8852\end_layout 8853 8854\begin_layout Itemize 8855sub-vector fixed (innovation) codebooks 8856\end_layout 8857 8858\begin_layout Section 8859Whole-Frame Analysis 8860\begin_inset Index 8861status collapsed 8862 8863\begin_layout Plain Layout 8864linear prediction 8865\end_layout 8866 8867\end_inset 8868 8869 8870\end_layout 8871 8872\begin_layout Standard 8873In narrowband, Speex frames are 20 ms long (160 samples) and are subdivided 8874 in 4 sub-frames of 5 ms each (40 samples). 8875 For most narrowband bit-rates (8 kbps and above), the only parameters encoded 8876 at the frame level are the Line Spectral Pairs (LSP) and a global excitation 8877 gain 8878\begin_inset Formula $g_{frame}$ 8879\end_inset 8880 8881, as shown in Fig. 8882 8883\begin_inset CommandInset ref 8884LatexCommand ref 8885reference "cap:Frame-open-loop-analysis" 8886 8887\end_inset 8888 8889. 8890 All other parameters are encoded at the sub-frame level. 8891\end_layout 8892 8893\begin_layout Standard 8894Linear prediction analysis is performed once per frame using an asymmetric 8895 Hamming window centered on the fourth sub-frame. 8896 Because linear prediction coefficients (LPC) are not robust to quantization, 8897 they are first converted to line spectral pairs (LSP) 8898\begin_inset Index 8899status collapsed 8900 8901\begin_layout Plain Layout 8902line spectral pair 8903\end_layout 8904 8905\end_inset 8906 8907. 8908 The LSP's are considered to be associated to the 8909\begin_inset Formula $4^{th}$ 8910\end_inset 8911 8912 sub-frames and the LSP's associated to the first 3 sub-frames are linearly 8913 interpolated using the current and previous LSP coefficients. 8914 The LSP coefficients and converted back to the LPC filter 8915\begin_inset Formula $\hat{A}(z)$ 8916\end_inset 8917 8918. 8919 The non-quantized interpolated filter is denoted 8920\begin_inset Formula $A(z)$ 8921\end_inset 8922 8923 and can be used for the weighting filter 8924\begin_inset Formula $W(z)$ 8925\end_inset 8926 8927 because it does not need to be available to the decoder. 8928 8929\end_layout 8930 8931\begin_layout Standard 8932To make Speex more robust to packet loss, no prediction is applied on the 8933 LSP coefficients prior to quantization. 8934 The LSPs are encoded using vector quantization (VQ) with 30 bits for higher 8935 quality modes and 18 bits for lower quality. 8936\end_layout 8937 8938\begin_layout Standard 8939\begin_inset Float figure 8940wide false 8941sideways false 8942status open 8943 8944\begin_layout Plain Layout 8945\begin_inset ERT 8946status collapsed 8947 8948\begin_layout Plain Layout 8949 8950 8951\backslash 8952begin{center} 8953\end_layout 8954 8955\end_inset 8956 8957 8958\begin_inset Graphics 8959 filename speex_analysis.eps 8960 width 35page% 8961 8962\end_inset 8963 8964 8965\begin_inset ERT 8966status collapsed 8967 8968\begin_layout Plain Layout 8969 8970 8971\backslash 8972end{center} 8973\end_layout 8974 8975\end_inset 8976 8977 8978\end_layout 8979 8980\begin_layout Plain Layout 8981\begin_inset Caption 8982 8983\begin_layout Plain Layout 8984Frame open-loop analysis 8985\begin_inset CommandInset label 8986LatexCommand label 8987name "cap:Frame-open-loop-analysis" 8988 8989\end_inset 8990 8991 8992\end_layout 8993 8994\end_inset 8995 8996 8997\end_layout 8998 8999\end_inset 9000 9001 9002\end_layout 9003 9004\begin_layout Section 9005Sub-Frame Analysis-by-Synthesis 9006\end_layout 9007 9008\begin_layout Standard 9009\begin_inset Float figure 9010wide false 9011sideways false 9012status open 9013 9014\begin_layout Plain Layout 9015\begin_inset ERT 9016status collapsed 9017 9018\begin_layout Plain Layout 9019 9020 9021\backslash 9022begin{center} 9023\end_layout 9024 9025\end_inset 9026 9027 9028\begin_inset Graphics 9029 filename speex_abs.eps 9030 lyxscale 75 9031 width 40page% 9032 9033\end_inset 9034 9035 9036\begin_inset ERT 9037status collapsed 9038 9039\begin_layout Plain Layout 9040 9041 9042\backslash 9043end{center} 9044\end_layout 9045 9046\end_inset 9047 9048 9049\end_layout 9050 9051\begin_layout Plain Layout 9052\begin_inset Caption 9053 9054\begin_layout Plain Layout 9055Analysis-by-synthesis closed-loop optimization on a sub-frame. 9056\begin_inset CommandInset label 9057LatexCommand label 9058name "cap:Sub-frame-AbS" 9059 9060\end_inset 9061 9062 9063\end_layout 9064 9065\end_inset 9066 9067 9068\end_layout 9069 9070\end_inset 9071 9072 9073\end_layout 9074 9075\begin_layout Standard 9076The analysis-by-synthesis (AbS) encoder loop is described in Fig. 9077 9078\begin_inset CommandInset ref 9079LatexCommand ref 9080reference "cap:Sub-frame-AbS" 9081 9082\end_inset 9083 9084. 9085 There are three main aspects where Speex significantly differs from most 9086 other CELP codecs. 9087 First, while most recent CELP codecs make use of fractional pitch estimation 9088 with a single gain, Speex uses an integer to encode the pitch period, but 9089 uses a 3-tap predictor (3 gains). 9090 The adaptive codebook contribution 9091\begin_inset Formula $e_{a}[n]$ 9092\end_inset 9093 9094 can thus be expressed as: 9095\begin_inset Formula \begin{equation} 9096e_{a}[n]=g_{0}e[n-T-1]+g_{1}e[n-T]+g_{2}e[n-T+1]\label{eq:adaptive-3tap}\end{equation} 9097 9098\end_inset 9099 9100where 9101\begin_inset Formula $g_{0}$ 9102\end_inset 9103 9104, 9105\begin_inset Formula $g_{1}$ 9106\end_inset 9107 9108 and 9109\begin_inset Formula $g_{2}$ 9110\end_inset 9111 9112 are the jointly quantized pitch gains and 9113\begin_inset Formula $e[n]$ 9114\end_inset 9115 9116 is the codec excitation memory. 9117 It is worth noting that when the pitch is smaller than the sub-frame size, 9118 we repeat the excitation at a period 9119\begin_inset Formula $T$ 9120\end_inset 9121 9122. 9123 For example, when 9124\begin_inset Formula $n-T+1\geq0$ 9125\end_inset 9126 9127, we use 9128\begin_inset Formula $n-2T+1$ 9129\end_inset 9130 9131 instead. 9132 In most modes, the pitch period is encoded with 7 bits in the 9133\begin_inset Formula $\left[17,144\right]$ 9134\end_inset 9135 9136 range and the 9137\begin_inset Formula $\beta_{i}$ 9138\end_inset 9139 9140 coefficients are vector-quantized using 7 bits at higher bit-rates (15 9141 kbps narrowband and above) and 5 bits at lower bit-rates (11 kbps narrowband 9142 and below). 9143\end_layout 9144 9145\begin_layout Standard 9146Many current CELP codecs use moving average (MA) prediction to encode the 9147 fixed codebook gain. 9148 This provides slightly better coding at the expense of introducing a dependency 9149 on previously encoded frames. 9150 A second difference is that Speex encodes the fixed codebook gain as the 9151 product of the global excitation gain 9152\begin_inset Formula $g_{frame}$ 9153\end_inset 9154 9155 with a sub-frame gain corrections 9156\begin_inset Formula $g_{subf}$ 9157\end_inset 9158 9159. 9160 This increases robustness to packet loss by eliminating the inter-frame 9161 dependency. 9162 The sub-frame gain correction is encoded before the fixed codebook is searched 9163 (not closed-loop optimized) and uses between 0 and 3 bits per sub-frame, 9164 depending on the bit-rate. 9165\end_layout 9166 9167\begin_layout Standard 9168The third difference is that Speex uses sub-vector quantization of the innovatio 9169n (fixed codebook) signal instead of an algebraic codebook. 9170 Each sub-frame is divided into sub-vectors of lengths ranging between 5 9171 and 20 samples. 9172 Each sub-vector is chosen from a bitrate-dependent codebook and all sub-vectors 9173 are concatenated to form a sub-frame. 9174 As an example, the 3.95 kbps mode uses a sub-vector size of 20 samples with 9175 32 entries in the codebook (5 bits). 9176 This means that the innovation is encoded with 10 bits per sub-frame, or 9177 2000 bps. 9178 On the other hand, the 18.2 kbps mode uses a sub-vector size of 5 samples 9179 with 256 entries in the codebook (8 bits), so the innovation uses 64 bits 9180 per sub-frame, or 12800 bps. 9181 9182\end_layout 9183 9184\begin_layout Section 9185Bit-rates 9186\end_layout 9187 9188\begin_layout Standard 9189So far, no MOS (Mean Opinion Score 9190\begin_inset Index 9191status collapsed 9192 9193\begin_layout Plain Layout 9194mean opinion score 9195\end_layout 9196 9197\end_inset 9198 9199) subjective evaluation has been performed for Speex. 9200 In order to give an idea of the quality achievable with it, table 9201\begin_inset CommandInset ref 9202LatexCommand ref 9203reference "cap:quality_vs_bps" 9204 9205\end_inset 9206 9207 presents my own subjective opinion on it. 9208 It should be noted that different people will perceive the quality differently 9209 and that the person that designed the codec often has a bias (one way or 9210 another) when it comes to subjective evaluation. 9211 Last thing, it should be noted that for most codecs (including Speex) encoding 9212 quality sometimes varies depending on the input. 9213 Note that the complexity is only approximate (within 0.5 mflops and using 9214 the lowest complexity setting). 9215 Decoding requires approximately 0.5 mflops 9216\begin_inset Index 9217status collapsed 9218 9219\begin_layout Plain Layout 9220complexity 9221\end_layout 9222 9223\end_inset 9224 9225 in most modes (1 mflops with perceptual enhancement). 9226\end_layout 9227 9228\begin_layout Standard 9229\begin_inset Float table 9230placement h 9231wide true 9232sideways false 9233status open 9234 9235\begin_layout Plain Layout 9236\begin_inset ERT 9237status collapsed 9238 9239\begin_layout Plain Layout 9240 9241 9242\backslash 9243begin{center} 9244\end_layout 9245 9246\end_inset 9247 9248 9249\begin_inset Tabular 9250<lyxtabular version="3" rows="17" columns="5"> 9251<features> 9252<column alignment="center" valignment="top" width="0pt"> 9253<column alignment="center" valignment="top" width="0pt"> 9254<column alignment="center" valignment="top" width="0pt"> 9255<column alignment="center" valignment="top" width="0pt"> 9256<column alignment="center" valignment="top" width="0pt"> 9257<row> 9258<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 9259\begin_inset Text 9260 9261\begin_layout Plain Layout 9262Mode 9263\end_layout 9264 9265\end_inset 9266</cell> 9267<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 9268\begin_inset Text 9269 9270\begin_layout Plain Layout 9271Quality 9272\end_layout 9273 9274\end_inset 9275</cell> 9276<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 9277\begin_inset Text 9278 9279\begin_layout Plain Layout 9280Bit-rate 9281\begin_inset Index 9282status collapsed 9283 9284\begin_layout Plain Layout 9285bit-rate 9286\end_layout 9287 9288\end_inset 9289 9290 (bps) 9291\end_layout 9292 9293\end_inset 9294</cell> 9295<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 9296\begin_inset Text 9297 9298\begin_layout Plain Layout 9299mflops 9300\begin_inset Index 9301status collapsed 9302 9303\begin_layout Plain Layout 9304complexity 9305\end_layout 9306 9307\end_inset 9308 9309 9310\end_layout 9311 9312\end_inset 9313</cell> 9314<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 9315\begin_inset Text 9316 9317\begin_layout Plain Layout 9318Quality/description 9319\end_layout 9320 9321\end_inset 9322</cell> 9323</row> 9324<row> 9325<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9326\begin_inset Text 9327 9328\begin_layout Plain Layout 93290 9330\end_layout 9331 9332\end_inset 9333</cell> 9334<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9335\begin_inset Text 9336 9337\begin_layout Plain Layout 9338- 9339\end_layout 9340 9341\end_inset 9342</cell> 9343<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9344\begin_inset Text 9345 9346\begin_layout Plain Layout 9347250 9348\end_layout 9349 9350\end_inset 9351</cell> 9352<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9353\begin_inset Text 9354 9355\begin_layout Plain Layout 93560 9357\end_layout 9358 9359\end_inset 9360</cell> 9361<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9362\begin_inset Text 9363 9364\begin_layout Plain Layout 9365No transmission (DTX) 9366\end_layout 9367 9368\end_inset 9369</cell> 9370</row> 9371<row> 9372<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9373\begin_inset Text 9374 9375\begin_layout Plain Layout 93761 9377\end_layout 9378 9379\end_inset 9380</cell> 9381<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9382\begin_inset Text 9383 9384\begin_layout Plain Layout 93850 9386\end_layout 9387 9388\end_inset 9389</cell> 9390<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9391\begin_inset Text 9392 9393\begin_layout Plain Layout 93942,150 9395\end_layout 9396 9397\end_inset 9398</cell> 9399<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9400\begin_inset Text 9401 9402\begin_layout Plain Layout 94036 9404\end_layout 9405 9406\end_inset 9407</cell> 9408<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9409\begin_inset Text 9410 9411\begin_layout Plain Layout 9412Vocoder (mostly for comfort noise) 9413\end_layout 9414 9415\end_inset 9416</cell> 9417</row> 9418<row> 9419<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9420\begin_inset Text 9421 9422\begin_layout Plain Layout 94232 9424\end_layout 9425 9426\end_inset 9427</cell> 9428<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9429\begin_inset Text 9430 9431\begin_layout Plain Layout 94322 9433\end_layout 9434 9435\end_inset 9436</cell> 9437<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9438\begin_inset Text 9439 9440\begin_layout Plain Layout 94415,950 9442\end_layout 9443 9444\end_inset 9445</cell> 9446<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9447\begin_inset Text 9448 9449\begin_layout Plain Layout 94509 9451\end_layout 9452 9453\end_inset 9454</cell> 9455<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9456\begin_inset Text 9457 9458\begin_layout Plain Layout 9459Very noticeable artifacts/noise, good intelligibility 9460\end_layout 9461 9462\end_inset 9463</cell> 9464</row> 9465<row> 9466<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9467\begin_inset Text 9468 9469\begin_layout Plain Layout 94703 9471\end_layout 9472 9473\end_inset 9474</cell> 9475<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9476\begin_inset Text 9477 9478\begin_layout Plain Layout 94793-4 9480\end_layout 9481 9482\end_inset 9483</cell> 9484<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9485\begin_inset Text 9486 9487\begin_layout Plain Layout 94888,000 9489\end_layout 9490 9491\end_inset 9492</cell> 9493<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9494\begin_inset Text 9495 9496\begin_layout Plain Layout 949710 9498\end_layout 9499 9500\end_inset 9501</cell> 9502<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9503\begin_inset Text 9504 9505\begin_layout Plain Layout 9506Artifacts/noise sometimes noticeable 9507\end_layout 9508 9509\end_inset 9510</cell> 9511</row> 9512<row> 9513<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9514\begin_inset Text 9515 9516\begin_layout Plain Layout 95174 9518\end_layout 9519 9520\end_inset 9521</cell> 9522<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9523\begin_inset Text 9524 9525\begin_layout Plain Layout 95265-6 9527\end_layout 9528 9529\end_inset 9530</cell> 9531<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9532\begin_inset Text 9533 9534\begin_layout Plain Layout 953511,000 9536\end_layout 9537 9538\end_inset 9539</cell> 9540<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9541\begin_inset Text 9542 9543\begin_layout Plain Layout 954414 9545\end_layout 9546 9547\end_inset 9548</cell> 9549<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9550\begin_inset Text 9551 9552\begin_layout Plain Layout 9553Artifacts usually noticeable only with headphones 9554\end_layout 9555 9556\end_inset 9557</cell> 9558</row> 9559<row> 9560<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9561\begin_inset Text 9562 9563\begin_layout Plain Layout 95645 9565\end_layout 9566 9567\end_inset 9568</cell> 9569<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9570\begin_inset Text 9571 9572\begin_layout Plain Layout 95737-8 9574\end_layout 9575 9576\end_inset 9577</cell> 9578<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9579\begin_inset Text 9580 9581\begin_layout Plain Layout 958215,000 9583\end_layout 9584 9585\end_inset 9586</cell> 9587<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9588\begin_inset Text 9589 9590\begin_layout Plain Layout 959111 9592\end_layout 9593 9594\end_inset 9595</cell> 9596<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9597\begin_inset Text 9598 9599\begin_layout Plain Layout 9600Need good headphones to tell the difference 9601\end_layout 9602 9603\end_inset 9604</cell> 9605</row> 9606<row> 9607<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9608\begin_inset Text 9609 9610\begin_layout Plain Layout 96116 9612\end_layout 9613 9614\end_inset 9615</cell> 9616<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9617\begin_inset Text 9618 9619\begin_layout Plain Layout 96209 9621\end_layout 9622 9623\end_inset 9624</cell> 9625<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9626\begin_inset Text 9627 9628\begin_layout Plain Layout 962918,200 9630\end_layout 9631 9632\end_inset 9633</cell> 9634<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9635\begin_inset Text 9636 9637\begin_layout Plain Layout 963817.5 9639\end_layout 9640 9641\end_inset 9642</cell> 9643<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9644\begin_inset Text 9645 9646\begin_layout Plain Layout 9647Hard to tell the difference even with good headphones 9648\end_layout 9649 9650\end_inset 9651</cell> 9652</row> 9653<row> 9654<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9655\begin_inset Text 9656 9657\begin_layout Plain Layout 96587 9659\end_layout 9660 9661\end_inset 9662</cell> 9663<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9664\begin_inset Text 9665 9666\begin_layout Plain Layout 966710 9668\end_layout 9669 9670\end_inset 9671</cell> 9672<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9673\begin_inset Text 9674 9675\begin_layout Plain Layout 967624,600 9677\end_layout 9678 9679\end_inset 9680</cell> 9681<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9682\begin_inset Text 9683 9684\begin_layout Plain Layout 968514.5 9686\end_layout 9687 9688\end_inset 9689</cell> 9690<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9691\begin_inset Text 9692 9693\begin_layout Plain Layout 9694Completely transparent for voice, good quality music 9695\end_layout 9696 9697\end_inset 9698</cell> 9699</row> 9700<row> 9701<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9702\begin_inset Text 9703 9704\begin_layout Plain Layout 97058 9706\end_layout 9707 9708\end_inset 9709</cell> 9710<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9711\begin_inset Text 9712 9713\begin_layout Plain Layout 97141 9715\end_layout 9716 9717\end_inset 9718</cell> 9719<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9720\begin_inset Text 9721 9722\begin_layout Plain Layout 97233,950 9724\end_layout 9725 9726\end_inset 9727</cell> 9728<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9729\begin_inset Text 9730 9731\begin_layout Plain Layout 973210.5 9733\end_layout 9734 9735\end_inset 9736</cell> 9737<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9738\begin_inset Text 9739 9740\begin_layout Plain Layout 9741Very noticeable artifacts/noise, good intelligibility 9742\end_layout 9743 9744\end_inset 9745</cell> 9746</row> 9747<row> 9748<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9749\begin_inset Text 9750 9751\begin_layout Plain Layout 97529 9753\end_layout 9754 9755\end_inset 9756</cell> 9757<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9758\begin_inset Text 9759 9760\begin_layout Plain Layout 9761- 9762\end_layout 9763 9764\end_inset 9765</cell> 9766<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9767\begin_inset Text 9768 9769\begin_layout Plain Layout 9770- 9771\end_layout 9772 9773\end_inset 9774</cell> 9775<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9776\begin_inset Text 9777 9778\begin_layout Plain Layout 9779- 9780\end_layout 9781 9782\end_inset 9783</cell> 9784<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9785\begin_inset Text 9786 9787\begin_layout Plain Layout 9788reserved 9789\end_layout 9790 9791\end_inset 9792</cell> 9793</row> 9794<row> 9795<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9796\begin_inset Text 9797 9798\begin_layout Plain Layout 979910 9800\end_layout 9801 9802\end_inset 9803</cell> 9804<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9805\begin_inset Text 9806 9807\begin_layout Plain Layout 9808- 9809\end_layout 9810 9811\end_inset 9812</cell> 9813<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9814\begin_inset Text 9815 9816\begin_layout Plain Layout 9817- 9818\end_layout 9819 9820\end_inset 9821</cell> 9822<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9823\begin_inset Text 9824 9825\begin_layout Plain Layout 9826- 9827\end_layout 9828 9829\end_inset 9830</cell> 9831<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9832\begin_inset Text 9833 9834\begin_layout Plain Layout 9835reserved 9836\end_layout 9837 9838\end_inset 9839</cell> 9840</row> 9841<row> 9842<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9843\begin_inset Text 9844 9845\begin_layout Plain Layout 984611 9847\end_layout 9848 9849\end_inset 9850</cell> 9851<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9852\begin_inset Text 9853 9854\begin_layout Plain Layout 9855- 9856\end_layout 9857 9858\end_inset 9859</cell> 9860<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9861\begin_inset Text 9862 9863\begin_layout Plain Layout 9864- 9865\end_layout 9866 9867\end_inset 9868</cell> 9869<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9870\begin_inset Text 9871 9872\begin_layout Plain Layout 9873- 9874\end_layout 9875 9876\end_inset 9877</cell> 9878<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9879\begin_inset Text 9880 9881\begin_layout Plain Layout 9882reserved 9883\end_layout 9884 9885\end_inset 9886</cell> 9887</row> 9888<row> 9889<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9890\begin_inset Text 9891 9892\begin_layout Plain Layout 989312 9894\end_layout 9895 9896\end_inset 9897</cell> 9898<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9899\begin_inset Text 9900 9901\begin_layout Plain Layout 9902- 9903\end_layout 9904 9905\end_inset 9906</cell> 9907<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9908\begin_inset Text 9909 9910\begin_layout Plain Layout 9911- 9912\end_layout 9913 9914\end_inset 9915</cell> 9916<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9917\begin_inset Text 9918 9919\begin_layout Plain Layout 9920- 9921\end_layout 9922 9923\end_inset 9924</cell> 9925<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9926\begin_inset Text 9927 9928\begin_layout Plain Layout 9929reserved 9930\end_layout 9931 9932\end_inset 9933</cell> 9934</row> 9935<row> 9936<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9937\begin_inset Text 9938 9939\begin_layout Plain Layout 994013 9941\end_layout 9942 9943\end_inset 9944</cell> 9945<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9946\begin_inset Text 9947 9948\begin_layout Plain Layout 9949- 9950\end_layout 9951 9952\end_inset 9953</cell> 9954<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9955\begin_inset Text 9956 9957\begin_layout Plain Layout 9958- 9959\end_layout 9960 9961\end_inset 9962</cell> 9963<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9964\begin_inset Text 9965 9966\begin_layout Plain Layout 9967- 9968\end_layout 9969 9970\end_inset 9971</cell> 9972<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 9973\begin_inset Text 9974 9975\begin_layout Plain Layout 9976Application-defined, interpreted by callback or skipped 9977\end_layout 9978 9979\end_inset 9980</cell> 9981</row> 9982<row> 9983<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9984\begin_inset Text 9985 9986\begin_layout Plain Layout 998714 9988\end_layout 9989 9990\end_inset 9991</cell> 9992<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 9993\begin_inset Text 9994 9995\begin_layout Plain Layout 9996- 9997\end_layout 9998 9999\end_inset 10000</cell> 10001<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10002\begin_inset Text 10003 10004\begin_layout Plain Layout 10005- 10006\end_layout 10007 10008\end_inset 10009</cell> 10010<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10011\begin_inset Text 10012 10013\begin_layout Plain Layout 10014- 10015\end_layout 10016 10017\end_inset 10018</cell> 10019<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 10020\begin_inset Text 10021 10022\begin_layout Plain Layout 10023Speex in-band signaling 10024\end_layout 10025 10026\end_inset 10027</cell> 10028</row> 10029<row> 10030<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10031\begin_inset Text 10032 10033\begin_layout Plain Layout 1003415 10035\end_layout 10036 10037\end_inset 10038</cell> 10039<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10040\begin_inset Text 10041 10042\begin_layout Plain Layout 10043- 10044\end_layout 10045 10046\end_inset 10047</cell> 10048<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10049\begin_inset Text 10050 10051\begin_layout Plain Layout 10052- 10053\end_layout 10054 10055\end_inset 10056</cell> 10057<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10058\begin_inset Text 10059 10060\begin_layout Plain Layout 10061- 10062\end_layout 10063 10064\end_inset 10065</cell> 10066<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 10067\begin_inset Text 10068 10069\begin_layout Plain Layout 10070Terminator code 10071\end_layout 10072 10073\end_inset 10074</cell> 10075</row> 10076</lyxtabular> 10077 10078\end_inset 10079 10080 10081\begin_inset ERT 10082status collapsed 10083 10084\begin_layout Plain Layout 10085 10086 10087\backslash 10088end{center} 10089\end_layout 10090 10091\end_inset 10092 10093 10094\end_layout 10095 10096\begin_layout Plain Layout 10097\begin_inset Caption 10098 10099\begin_layout Plain Layout 10100Quality versus bit-rate 10101\begin_inset CommandInset label 10102LatexCommand label 10103name "cap:quality_vs_bps" 10104 10105\end_inset 10106 10107 10108\end_layout 10109 10110\end_inset 10111 10112 10113\end_layout 10114 10115\end_inset 10116 10117 10118\end_layout 10119 10120\begin_layout Section 10121Perceptual enhancement 10122\begin_inset Index 10123status collapsed 10124 10125\begin_layout Plain Layout 10126perceptual enhancement 10127\end_layout 10128 10129\end_inset 10130 10131 10132\end_layout 10133 10134\begin_layout Standard 10135 10136\series bold 10137This section was only valid for version 1.1.12 and earlier. 10138 It does not apply to version 1.2-beta1 (and later), for which the new perceptual 10139 enhancement is not yet documented. 10140\end_layout 10141 10142\begin_layout Standard 10143This part of the codec only applies to the decoder and can even be changed 10144 without affecting inter-operability. 10145 For that reason, the implementation provided and described here should 10146 only be considered as a reference implementation. 10147 The enhancement system is divided into two parts. 10148 First, the synthesis filter 10149\begin_inset Formula $S(z)=1/A(z)$ 10150\end_inset 10151 10152 is replaced by an enhanced filter: 10153\begin_inset Formula \[ 10154S'(z)=\frac{A\left(z/a_{2}\right)A\left(z/a_{3}\right)}{A\left(z\right)A\left(z/a_{1}\right)}\] 10155 10156\end_inset 10157 10158where 10159\begin_inset Formula $a_{1}$ 10160\end_inset 10161 10162 and 10163\begin_inset Formula $a_{2}$ 10164\end_inset 10165 10166 depend on the mode in use and 10167\begin_inset Formula $a_{3}=\frac{1}{r}\left(1-\frac{1-ra_{1}}{1-ra_{2}}\right)$ 10168\end_inset 10169 10170 with 10171\begin_inset Formula $r=.9$ 10172\end_inset 10173 10174. 10175 The second part of the enhancement consists of using a comb filter to enhance 10176 the pitch in the excitation domain. 10177 10178\end_layout 10179 10180\begin_layout Standard 10181\begin_inset Newpage newpage 10182\end_inset 10183 10184 10185\end_layout 10186 10187\begin_layout Chapter 10188Speex wideband mode (sub-band CELP) 10189\begin_inset Index 10190status collapsed 10191 10192\begin_layout Plain Layout 10193wideband 10194\end_layout 10195 10196\end_inset 10197 10198 10199\begin_inset CommandInset label 10200LatexCommand label 10201name "sec:Speex-wideband-mode" 10202 10203\end_inset 10204 10205 10206\end_layout 10207 10208\begin_layout Standard 10209For wideband, the Speex approach uses a 10210\emph on 10211q 10212\emph default 10213uadrature 10214\emph on 10215m 10216\emph default 10217irror 10218\emph on 10219f 10220\emph default 10221ilter 10222\begin_inset Index 10223status collapsed 10224 10225\begin_layout Plain Layout 10226quadrature mirror filter 10227\end_layout 10228 10229\end_inset 10230 10231 (QMF) to split the band in two. 10232 The 16 kHz signal is thus divided into two 8 kHz signals, one representing 10233 the low band (0-4 kHz), the other the high band (4-8 kHz). 10234 The low band is encoded with the narrowband mode described in section 10235\begin_inset CommandInset ref 10236LatexCommand ref 10237reference "sec:Speex-narrowband-mode" 10238 10239\end_inset 10240 10241 in such a way that the resulting 10242\begin_inset Quotes eld 10243\end_inset 10244 10245embedded narrowband bit-stream 10246\begin_inset Quotes erd 10247\end_inset 10248 10249 can also be decoded with the narrowband decoder. 10250 Since the low band encoding has already been described, only the high band 10251 encoding is described in this section. 10252\end_layout 10253 10254\begin_layout Section 10255Linear Prediction 10256\end_layout 10257 10258\begin_layout Standard 10259The linear prediction part used for the high-band is very similar to what 10260 is done for narrowband. 10261 The only difference is that we use only 12 bits to encode the high-band 10262 LSP's using a multi-stage vector quantizer (MSVQ). 10263 The first level quantizes the 10 coefficients with 6 bits and the error 10264 is then quantized using 6 bits, too. 10265\end_layout 10266 10267\begin_layout Section 10268Pitch Prediction 10269\end_layout 10270 10271\begin_layout Standard 10272That part is easy: there's no pitch prediction for the high-band. 10273 There are two reasons for that. 10274 First, there is usually little harmonic structure in this band (above 4 10275 kHz). 10276 Second, it would be very hard to implement since the QMF folds the 4-8 10277 kHz band into 4-0 kHz (reversing the frequency axis), which means that 10278 the location of the harmonics is no longer at multiples of the fundamental 10279 (pitch). 10280\end_layout 10281 10282\begin_layout Section 10283Excitation Quantization 10284\end_layout 10285 10286\begin_layout Standard 10287The high-band excitation is coded in the same way as for narrowband. 10288 10289\end_layout 10290 10291\begin_layout Section 10292Bit allocation 10293\end_layout 10294 10295\begin_layout Standard 10296For the wideband mode, the entire narrowband frame is packed before the 10297 high-band is encoded. 10298 The narrowband part of the bit-stream is as defined in table 10299\begin_inset CommandInset ref 10300LatexCommand ref 10301reference "cap:bits-narrowband" 10302 10303\end_inset 10304 10305. 10306 The high-band follows, as described in table 10307\begin_inset CommandInset ref 10308LatexCommand ref 10309reference "cap:bits-wideband" 10310 10311\end_inset 10312 10313. 10314 For wideband, the mode ID is the same as the Speex quality setting and 10315 is defined in table 10316\begin_inset CommandInset ref 10317LatexCommand ref 10318reference "tab:wideband-quality" 10319 10320\end_inset 10321 10322. 10323 This also means that a wideband frame may be correctly decoded by a narrowband 10324 decoder with the only caveat that if more than one frame is packed in the 10325 same packet, the decoder will need to skip the high-band parts in order 10326 to sync with the bit-stream. 10327\end_layout 10328 10329\begin_layout Standard 10330\begin_inset Float table 10331placement h 10332wide true 10333sideways false 10334status open 10335 10336\begin_layout Plain Layout 10337\begin_inset ERT 10338status collapsed 10339 10340\begin_layout Plain Layout 10341 10342 10343\backslash 10344begin{center} 10345\end_layout 10346 10347\end_inset 10348 10349 10350\begin_inset Tabular 10351<lyxtabular version="3" rows="7" columns="7"> 10352<features> 10353<column alignment="center" valignment="top" width="0pt"> 10354<column alignment="center" valignment="top" width="0pt"> 10355<column alignment="center" valignment="top" width="0pt"> 10356<column alignment="center" valignment="top" width="0pt"> 10357<column alignment="center" valignment="top" width="0pt"> 10358<column alignment="center" valignment="top" width="0pt"> 10359<column alignment="center" valignment="top" width="0pt"> 10360<row> 10361<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10362\begin_inset Text 10363 10364\begin_layout Plain Layout 10365Parameter 10366\end_layout 10367 10368\end_inset 10369</cell> 10370<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10371\begin_inset Text 10372 10373\begin_layout Plain Layout 10374Update rate 10375\end_layout 10376 10377\end_inset 10378</cell> 10379<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10380\begin_inset Text 10381 10382\begin_layout Plain Layout 103830 10384\end_layout 10385 10386\end_inset 10387</cell> 10388<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10389\begin_inset Text 10390 10391\begin_layout Plain Layout 103921 10393\end_layout 10394 10395\end_inset 10396</cell> 10397<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10398\begin_inset Text 10399 10400\begin_layout Plain Layout 104012 10402\end_layout 10403 10404\end_inset 10405</cell> 10406<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10407\begin_inset Text 10408 10409\begin_layout Plain Layout 104103 10411\end_layout 10412 10413\end_inset 10414</cell> 10415<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 10416\begin_inset Text 10417 10418\begin_layout Plain Layout 104194 10420\end_layout 10421 10422\end_inset 10423</cell> 10424</row> 10425<row> 10426<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10427\begin_inset Text 10428 10429\begin_layout Plain Layout 10430Wideband bit 10431\end_layout 10432 10433\end_inset 10434</cell> 10435<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10436\begin_inset Text 10437 10438\begin_layout Plain Layout 10439frame 10440\end_layout 10441 10442\end_inset 10443</cell> 10444<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10445\begin_inset Text 10446 10447\begin_layout Plain Layout 104481 10449\end_layout 10450 10451\end_inset 10452</cell> 10453<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10454\begin_inset Text 10455 10456\begin_layout Plain Layout 104571 10458\end_layout 10459 10460\end_inset 10461</cell> 10462<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10463\begin_inset Text 10464 10465\begin_layout Plain Layout 104661 10467\end_layout 10468 10469\end_inset 10470</cell> 10471<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10472\begin_inset Text 10473 10474\begin_layout Plain Layout 104751 10476\end_layout 10477 10478\end_inset 10479</cell> 10480<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 10481\begin_inset Text 10482 10483\begin_layout Plain Layout 104841 10485\end_layout 10486 10487\end_inset 10488</cell> 10489</row> 10490<row> 10491<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10492\begin_inset Text 10493 10494\begin_layout Plain Layout 10495Mode ID 10496\end_layout 10497 10498\end_inset 10499</cell> 10500<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10501\begin_inset Text 10502 10503\begin_layout Plain Layout 10504frame 10505\end_layout 10506 10507\end_inset 10508</cell> 10509<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10510\begin_inset Text 10511 10512\begin_layout Plain Layout 105133 10514\end_layout 10515 10516\end_inset 10517</cell> 10518<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10519\begin_inset Text 10520 10521\begin_layout Plain Layout 105223 10523\end_layout 10524 10525\end_inset 10526</cell> 10527<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10528\begin_inset Text 10529 10530\begin_layout Plain Layout 105313 10532\end_layout 10533 10534\end_inset 10535</cell> 10536<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10537\begin_inset Text 10538 10539\begin_layout Plain Layout 105403 10541\end_layout 10542 10543\end_inset 10544</cell> 10545<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 10546\begin_inset Text 10547 10548\begin_layout Plain Layout 105493 10550\end_layout 10551 10552\end_inset 10553</cell> 10554</row> 10555<row> 10556<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10557\begin_inset Text 10558 10559\begin_layout Plain Layout 10560LSP 10561\end_layout 10562 10563\end_inset 10564</cell> 10565<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10566\begin_inset Text 10567 10568\begin_layout Plain Layout 10569frame 10570\end_layout 10571 10572\end_inset 10573</cell> 10574<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10575\begin_inset Text 10576 10577\begin_layout Plain Layout 105780 10579\end_layout 10580 10581\end_inset 10582</cell> 10583<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10584\begin_inset Text 10585 10586\begin_layout Plain Layout 1058712 10588\end_layout 10589 10590\end_inset 10591</cell> 10592<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10593\begin_inset Text 10594 10595\begin_layout Plain Layout 1059612 10597\end_layout 10598 10599\end_inset 10600</cell> 10601<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10602\begin_inset Text 10603 10604\begin_layout Plain Layout 1060512 10606\end_layout 10607 10608\end_inset 10609</cell> 10610<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 10611\begin_inset Text 10612 10613\begin_layout Plain Layout 1061412 10615\end_layout 10616 10617\end_inset 10618</cell> 10619</row> 10620<row> 10621<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10622\begin_inset Text 10623 10624\begin_layout Plain Layout 10625Excitation gain 10626\end_layout 10627 10628\end_inset 10629</cell> 10630<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10631\begin_inset Text 10632 10633\begin_layout Plain Layout 10634sub-frame 10635\end_layout 10636 10637\end_inset 10638</cell> 10639<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10640\begin_inset Text 10641 10642\begin_layout Plain Layout 106430 10644\end_layout 10645 10646\end_inset 10647</cell> 10648<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10649\begin_inset Text 10650 10651\begin_layout Plain Layout 106525 10653\end_layout 10654 10655\end_inset 10656</cell> 10657<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10658\begin_inset Text 10659 10660\begin_layout Plain Layout 106614 10662\end_layout 10663 10664\end_inset 10665</cell> 10666<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10667\begin_inset Text 10668 10669\begin_layout Plain Layout 106704 10671\end_layout 10672 10673\end_inset 10674</cell> 10675<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 10676\begin_inset Text 10677 10678\begin_layout Plain Layout 106794 10680\end_layout 10681 10682\end_inset 10683</cell> 10684</row> 10685<row> 10686<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10687\begin_inset Text 10688 10689\begin_layout Plain Layout 10690Excitation VQ 10691\end_layout 10692 10693\end_inset 10694</cell> 10695<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10696\begin_inset Text 10697 10698\begin_layout Plain Layout 10699sub-frame 10700\end_layout 10701 10702\end_inset 10703</cell> 10704<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10705\begin_inset Text 10706 10707\begin_layout Plain Layout 107080 10709\end_layout 10710 10711\end_inset 10712</cell> 10713<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10714\begin_inset Text 10715 10716\begin_layout Plain Layout 107170 10718\end_layout 10719 10720\end_inset 10721</cell> 10722<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10723\begin_inset Text 10724 10725\begin_layout Plain Layout 1072620 10727\end_layout 10728 10729\end_inset 10730</cell> 10731<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10732\begin_inset Text 10733 10734\begin_layout Plain Layout 1073540 10736\end_layout 10737 10738\end_inset 10739</cell> 10740<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 10741\begin_inset Text 10742 10743\begin_layout Plain Layout 1074480 10745\end_layout 10746 10747\end_inset 10748</cell> 10749</row> 10750<row> 10751<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10752\begin_inset Text 10753 10754\begin_layout Plain Layout 10755Total 10756\end_layout 10757 10758\end_inset 10759</cell> 10760<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10761\begin_inset Text 10762 10763\begin_layout Plain Layout 10764frame 10765\end_layout 10766 10767\end_inset 10768</cell> 10769<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10770\begin_inset Text 10771 10772\begin_layout Plain Layout 107734 10774\end_layout 10775 10776\end_inset 10777</cell> 10778<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10779\begin_inset Text 10780 10781\begin_layout Plain Layout 1078236 10783\end_layout 10784 10785\end_inset 10786</cell> 10787<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10788\begin_inset Text 10789 10790\begin_layout Plain Layout 10791112 10792\end_layout 10793 10794\end_inset 10795</cell> 10796<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10797\begin_inset Text 10798 10799\begin_layout Plain Layout 10800192 10801\end_layout 10802 10803\end_inset 10804</cell> 10805<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 10806\begin_inset Text 10807 10808\begin_layout Plain Layout 10809352 10810\end_layout 10811 10812\end_inset 10813</cell> 10814</row> 10815</lyxtabular> 10816 10817\end_inset 10818 10819 10820\begin_inset ERT 10821status collapsed 10822 10823\begin_layout Plain Layout 10824 10825 10826\backslash 10827end{center} 10828\end_layout 10829 10830\end_inset 10831 10832 10833\end_layout 10834 10835\begin_layout Plain Layout 10836\begin_inset Caption 10837 10838\begin_layout Plain Layout 10839Bit allocation for high-band in wideband mode 10840\begin_inset CommandInset label 10841LatexCommand label 10842name "cap:bits-wideband" 10843 10844\end_inset 10845 10846 10847\end_layout 10848 10849\end_inset 10850 10851 10852\end_layout 10853 10854\end_inset 10855 10856 10857\end_layout 10858 10859\begin_layout Standard 10860\begin_inset Float table 10861placement h 10862wide true 10863sideways false 10864status open 10865 10866\begin_layout Plain Layout 10867\begin_inset ERT 10868status collapsed 10869 10870\begin_layout Plain Layout 10871 10872 10873\backslash 10874begin{center} 10875\end_layout 10876 10877\end_inset 10878 10879 10880\begin_inset Tabular 10881<lyxtabular version="3" rows="12" columns="3"> 10882<features> 10883<column alignment="center" valignment="top" width="0pt"> 10884<column alignment="center" valignment="top" width="0pt"> 10885<column alignment="center" valignment="top" width="0pt"> 10886<row> 10887<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10888\begin_inset Text 10889 10890\begin_layout Plain Layout 10891Mode/Quality 10892\end_layout 10893 10894\end_inset 10895</cell> 10896<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 10897\begin_inset Text 10898 10899\begin_layout Plain Layout 10900Bit-rate 10901\begin_inset Index 10902status collapsed 10903 10904\begin_layout Plain Layout 10905bit-rate 10906\end_layout 10907 10908\end_inset 10909 10910 (bps) 10911\end_layout 10912 10913\end_inset 10914</cell> 10915<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 10916\begin_inset Text 10917 10918\begin_layout Plain Layout 10919Quality/description 10920\end_layout 10921 10922\end_inset 10923</cell> 10924</row> 10925<row> 10926<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10927\begin_inset Text 10928 10929\begin_layout Plain Layout 109300 10931\end_layout 10932 10933\end_inset 10934</cell> 10935<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10936\begin_inset Text 10937 10938\begin_layout Plain Layout 109393,950 10940\end_layout 10941 10942\end_inset 10943</cell> 10944<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 10945\begin_inset Text 10946 10947\begin_layout Plain Layout 10948Barely intelligible (mostly for comfort noise) 10949\end_layout 10950 10951\end_inset 10952</cell> 10953</row> 10954<row> 10955<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10956\begin_inset Text 10957 10958\begin_layout Plain Layout 109591 10960\end_layout 10961 10962\end_inset 10963</cell> 10964<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10965\begin_inset Text 10966 10967\begin_layout Plain Layout 109685,750 10969\end_layout 10970 10971\end_inset 10972</cell> 10973<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 10974\begin_inset Text 10975 10976\begin_layout Plain Layout 10977Very noticeable artifacts/noise, poor intelligibility 10978\end_layout 10979 10980\end_inset 10981</cell> 10982</row> 10983<row> 10984<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10985\begin_inset Text 10986 10987\begin_layout Plain Layout 109882 10989\end_layout 10990 10991\end_inset 10992</cell> 10993<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 10994\begin_inset Text 10995 10996\begin_layout Plain Layout 109977,750 10998\end_layout 10999 11000\end_inset 11001</cell> 11002<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 11003\begin_inset Text 11004 11005\begin_layout Plain Layout 11006Very noticeable artifacts/noise, good intelligibility 11007\end_layout 11008 11009\end_inset 11010</cell> 11011</row> 11012<row> 11013<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11014\begin_inset Text 11015 11016\begin_layout Plain Layout 110173 11018\end_layout 11019 11020\end_inset 11021</cell> 11022<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11023\begin_inset Text 11024 11025\begin_layout Plain Layout 110269,800 11027\end_layout 11028 11029\end_inset 11030</cell> 11031<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 11032\begin_inset Text 11033 11034\begin_layout Plain Layout 11035Artifacts/noise sometimes annoying 11036\end_layout 11037 11038\end_inset 11039</cell> 11040</row> 11041<row> 11042<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11043\begin_inset Text 11044 11045\begin_layout Plain Layout 110464 11047\end_layout 11048 11049\end_inset 11050</cell> 11051<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11052\begin_inset Text 11053 11054\begin_layout Plain Layout 1105512,800 11056\end_layout 11057 11058\end_inset 11059</cell> 11060<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 11061\begin_inset Text 11062 11063\begin_layout Plain Layout 11064Artifacts/noise usually noticeable 11065\end_layout 11066 11067\end_inset 11068</cell> 11069</row> 11070<row> 11071<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11072\begin_inset Text 11073 11074\begin_layout Plain Layout 110755 11076\end_layout 11077 11078\end_inset 11079</cell> 11080<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11081\begin_inset Text 11082 11083\begin_layout Plain Layout 1108416,800 11085\end_layout 11086 11087\end_inset 11088</cell> 11089<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 11090\begin_inset Text 11091 11092\begin_layout Plain Layout 11093Artifacts/noise sometimes noticeable 11094\end_layout 11095 11096\end_inset 11097</cell> 11098</row> 11099<row> 11100<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11101\begin_inset Text 11102 11103\begin_layout Plain Layout 111046 11105\end_layout 11106 11107\end_inset 11108</cell> 11109<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11110\begin_inset Text 11111 11112\begin_layout Plain Layout 1111320,600 11114\end_layout 11115 11116\end_inset 11117</cell> 11118<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 11119\begin_inset Text 11120 11121\begin_layout Plain Layout 11122Need good headphones to tell the difference 11123\end_layout 11124 11125\end_inset 11126</cell> 11127</row> 11128<row> 11129<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11130\begin_inset Text 11131 11132\begin_layout Plain Layout 111337 11134\end_layout 11135 11136\end_inset 11137</cell> 11138<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11139\begin_inset Text 11140 11141\begin_layout Plain Layout 1114223,800 11143\end_layout 11144 11145\end_inset 11146</cell> 11147<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 11148\begin_inset Text 11149 11150\begin_layout Plain Layout 11151Need good headphones to tell the difference 11152\end_layout 11153 11154\end_inset 11155</cell> 11156</row> 11157<row> 11158<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11159\begin_inset Text 11160 11161\begin_layout Plain Layout 111628 11163\end_layout 11164 11165\end_inset 11166</cell> 11167<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11168\begin_inset Text 11169 11170\begin_layout Plain Layout 1117127,800 11172\end_layout 11173 11174\end_inset 11175</cell> 11176<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 11177\begin_inset Text 11178 11179\begin_layout Plain Layout 11180Hard to tell the difference even with good headphones 11181\end_layout 11182 11183\end_inset 11184</cell> 11185</row> 11186<row> 11187<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11188\begin_inset Text 11189 11190\begin_layout Plain Layout 111919 11192\end_layout 11193 11194\end_inset 11195</cell> 11196<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> 11197\begin_inset Text 11198 11199\begin_layout Plain Layout 1120034,200 11201\end_layout 11202 11203\end_inset 11204</cell> 11205<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> 11206\begin_inset Text 11207 11208\begin_layout Plain Layout 11209Hard to tell the difference even with good headphones 11210\end_layout 11211 11212\end_inset 11213</cell> 11214</row> 11215<row> 11216<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 11217\begin_inset Text 11218 11219\begin_layout Plain Layout 1122010 11221\end_layout 11222 11223\end_inset 11224</cell> 11225<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> 11226\begin_inset Text 11227 11228\begin_layout Plain Layout 1122942,200 11230\end_layout 11231 11232\end_inset 11233</cell> 11234<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> 11235\begin_inset Text 11236 11237\begin_layout Plain Layout 11238Completely transparent for voice, good quality music 11239\end_layout 11240 11241\end_inset 11242</cell> 11243</row> 11244</lyxtabular> 11245 11246\end_inset 11247 11248 11249\begin_inset ERT 11250status collapsed 11251 11252\begin_layout Plain Layout 11253 11254 11255\backslash 11256end{center} 11257\end_layout 11258 11259\end_inset 11260 11261 11262\end_layout 11263 11264\begin_layout Plain Layout 11265\begin_inset Caption 11266 11267\begin_layout Plain Layout 11268Quality versus bit-rate for the wideband encoder 11269\begin_inset CommandInset label 11270LatexCommand label 11271name "tab:wideband-quality" 11272 11273\end_inset 11274 11275 11276\end_layout 11277 11278\end_inset 11279 11280 11281\end_layout 11282 11283\end_inset 11284 11285 11286\end_layout 11287 11288\begin_layout Standard 11289\begin_inset ERT 11290status open 11291 11292\begin_layout Plain Layout 11293 11294 11295\backslash 11296clearpage 11297\end_layout 11298 11299\end_inset 11300 11301 11302\end_layout 11303 11304\begin_layout Standard 11305\begin_inset ERT 11306status collapsed 11307 11308\begin_layout Plain Layout 11309 11310 11311\backslash 11312clearpage 11313\end_layout 11314 11315\end_inset 11316 11317 11318\end_layout 11319 11320\begin_layout Chapter 11321\start_of_appendix 11322Sample code 11323\begin_inset CommandInset label 11324LatexCommand label 11325name "sec:Sample-code" 11326 11327\end_inset 11328 11329 11330\end_layout 11331 11332\begin_layout Standard 11333This section shows sample code for encoding and decoding speech using the 11334 Speex API. 11335 The commands can be used to encode and decode a file by calling: 11336\family typewriter 11337 11338\begin_inset Newline newline 11339\end_inset 11340 11341% sampleenc in_file.sw | sampledec out_file.sw 11342\family default 11343 11344\begin_inset Newline newline 11345\end_inset 11346 11347where both files are raw (no header) files encoded at 16 bits per sample 11348 (in the machine natural endianness). 11349\end_layout 11350 11351\begin_layout Section 11352sampleenc.c 11353\end_layout 11354 11355\begin_layout Standard 11356sampleenc takes a raw 16 bits/sample file, encodes it and outputs a Speex 11357 stream to stdout. 11358 Note that the packing used is 11359\series bold 11360not 11361\series default 11362 compatible with that of speexenc/speexdec. 11363\end_layout 11364 11365\begin_layout Standard 11366\begin_inset CommandInset include 11367LatexCommand lstinputlisting 11368filename "sampleenc.c" 11369lstparams "caption={Source code for sampleenc},label={sampleenc-source-code},numbers=left,numberstyle={\\footnotesize}" 11370 11371\end_inset 11372 11373 11374\end_layout 11375 11376\begin_layout Section 11377sampledec.c 11378\end_layout 11379 11380\begin_layout Standard 11381sampledec reads a Speex stream from stdin, decodes it and outputs it to 11382 a raw 16 bits/sample file. 11383 Note that the packing used is 11384\series bold 11385not 11386\series default 11387 compatible with that of speexenc/speexdec. 11388\end_layout 11389 11390\begin_layout Standard 11391\begin_inset CommandInset include 11392LatexCommand lstinputlisting 11393filename "sampledec.c" 11394lstparams "caption={Source code for sampledec},label={sampledec-source-code},numbers=left,numberstyle={\\footnotesize}" 11395 11396\end_inset 11397 11398 11399\end_layout 11400 11401\begin_layout Standard 11402\begin_inset Newpage newpage 11403\end_inset 11404 11405 11406\end_layout 11407 11408\begin_layout Chapter 11409Jitter Buffer for Speex 11410\end_layout 11411 11412\begin_layout Standard 11413\begin_inset CommandInset include 11414LatexCommand lstinputlisting 11415filename "../speexclient/speex_jitter_buffer.c" 11416lstparams "caption={Example of using the jitter buffer for Speex packets},label={example-speex-jitter},numbers=left,numberstyle={\\footnotesize}" 11417 11418\end_inset 11419 11420 11421\end_layout 11422 11423\begin_layout Standard 11424\begin_inset Newpage newpage 11425\end_inset 11426 11427 11428\end_layout 11429 11430\begin_layout Chapter 11431IETF RTP Profile 11432\begin_inset CommandInset label 11433LatexCommand label 11434name "sec:IETF-draft" 11435 11436\end_inset 11437 11438 11439\end_layout 11440 11441\begin_layout Standard 11442\begin_inset CommandInset include 11443LatexCommand verbatiminput 11444filename "draft-ietf-avt-rtp-speex-05-tmp.txt" 11445 11446\end_inset 11447 11448 11449\end_layout 11450 11451\begin_layout Standard 11452\begin_inset Newpage newpage 11453\end_inset 11454 11455 11456\end_layout 11457 11458\begin_layout Chapter 11459Speex License 11460\begin_inset CommandInset label 11461LatexCommand label 11462name "sec:Speex-License" 11463 11464\end_inset 11465 11466 11467\end_layout 11468 11469\begin_layout Standard 11470\begin_inset CommandInset include 11471LatexCommand verbatiminput 11472filename "../COPYING" 11473 11474\end_inset 11475 11476 11477\end_layout 11478 11479\begin_layout Standard 11480\begin_inset Newpage newpage 11481\end_inset 11482 11483 11484\end_layout 11485 11486\begin_layout Chapter 11487GNU Free Documentation License 11488\end_layout 11489 11490\begin_layout Standard 11491Version 1.1, March 2000 11492\end_layout 11493 11494\begin_layout Standard 11495Copyright (C) 2000 Free Software Foundation, Inc. 11496 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted 11497 to copy and distribute verbatim copies of this license document, but changing 11498 it is not allowed. 11499 11500\end_layout 11501 11502\begin_layout Section* 115030. 11504 PREAMBLE 11505\end_layout 11506 11507\begin_layout Standard 11508The purpose of this License is to make a manual, textbook, or other written 11509 document "free" in the sense of freedom: to assure everyone the effective 11510 freedom to copy and redistribute it, with or without modifying it, either 11511 commercially or noncommercially. 11512 Secondarily, this License preserves for the author and publisher a way 11513 to get credit for their work, while not being considered responsible for 11514 modifications made by others. 11515\end_layout 11516 11517\begin_layout Standard 11518This License is a kind of "copyleft", which means that derivative works 11519 of the document must themselves be free in the same sense. 11520 It complements the GNU General Public License, which is a copyleft license 11521 designed for free software. 11522\end_layout 11523 11524\begin_layout Standard 11525We have designed this License in order to use it for manuals for free software, 11526 because free software needs free documentation: a free program should come 11527 with manuals providing the same freedoms that the software does. 11528 But this License is not limited to software manuals; it can be used for 11529 any textual work, regardless of subject matter or whether it is published 11530 as a printed book. 11531 We recommend this License principally for works whose purpose is instruction 11532 or reference. 11533 11534\end_layout 11535 11536\begin_layout Section* 115371. 11538 APPLICABILITY AND DEFINITIONS 11539\end_layout 11540 11541\begin_layout Standard 11542This License applies to any manual or other work that contains a notice 11543 placed by the copyright holder saying it can be distributed under the terms 11544 of this License. 11545 The "Document", below, refers to any such manual or work. 11546 Any member of the public is a licensee, and is addressed as "you". 11547\end_layout 11548 11549\begin_layout Standard 11550A "Modified Version" of the Document means any work containing the Document 11551 or a portion of it, either copied verbatim, or with modifications and/or 11552 translated into another language. 11553\end_layout 11554 11555\begin_layout Standard 11556A "Secondary Section" is a named appendix or a front-matter section of the 11557 Document that deals exclusively with the relationship of the publishers 11558 or authors of the Document to the Document's overall subject (or to related 11559 matters) and contains nothing that could fall directly within that overall 11560 subject. 11561 (For example, if the Document is in part a textbook of mathematics, a Secondary 11562 Section may not explain any mathematics.) The relationship could be a matter 11563 of historical connection with the subject or with related matters, or of 11564 legal, commercial, philosophical, ethical or political position regarding 11565 them. 11566\end_layout 11567 11568\begin_layout Standard 11569The "Invariant Sections" are certain Secondary Sections whose titles are 11570 designated, as being those of Invariant Sections, in the notice that says 11571 that the Document is released under this License. 11572\end_layout 11573 11574\begin_layout Standard 11575The "Cover Texts" are certain short passages of text that are listed, as 11576 Front-Cover Texts or Back-Cover Texts, in the notice that says that the 11577 Document is released under this License. 11578\end_layout 11579 11580\begin_layout Standard 11581A "Transparent" copy of the Document means a machine-readable copy, represented 11582 in a format whose specification is available to the general public, whose 11583 contents can be viewed and edited directly and straightforwardly with generic 11584 text editors or (for images composed of pixels) generic paint programs 11585 or (for drawings) some widely available drawing editor, and that is suitable 11586 for input to text formatters or for automatic translation to a variety 11587 of formats suitable for input to text formatters. 11588 A copy made in an otherwise Transparent file format whose markup has been 11589 designed to thwart or discourage subsequent modification by readers is 11590 not Transparent. 11591 A copy that is not "Transparent" is called "Opaque". 11592\end_layout 11593 11594\begin_layout Standard 11595Examples of suitable formats for Transparent copies include plain ASCII 11596 without markup, Texinfo input format, LaTeX input format, SGML or XML using 11597 a publicly available DTD, and standard-conforming simple HTML designed 11598 for human modification. 11599 Opaque formats include PostScript, PDF, proprietary formats that can be 11600 read and edited only by proprietary word processors, SGML or XML for which 11601 the DTD and/or processing tools are not generally available, and the machine-ge 11602nerated HTML produced by some word processors for output purposes only. 11603\end_layout 11604 11605\begin_layout Standard 11606The "Title Page" means, for a printed book, the title page itself, plus 11607 such following pages as are needed to hold, legibly, the material this 11608 License requires to appear in the title page. 11609 For works in formats which do not have any title page as such, "Title Page" 11610 means the text near the most prominent appearance of the work's title, 11611 preceding the beginning of the body of the text. 11612\end_layout 11613 11614\begin_layout Section* 116152. 11616 VERBATIM COPYING 11617\end_layout 11618 11619\begin_layout Standard 11620You may copy and distribute the Document in any medium, either commercially 11621 or noncommercially, provided that this License, the copyright notices, 11622 and the license notice saying this License applies to the Document are 11623 reproduced in all copies, and that you add no other conditions whatsoever 11624 to those of this License. 11625 You may not use technical measures to obstruct or control the reading or 11626 further copying of the copies you make or distribute. 11627 However, you may accept compensation in exchange for copies. 11628 If you distribute a large enough number of copies you must also follow 11629 the conditions in section 3. 11630\end_layout 11631 11632\begin_layout Standard 11633You may also lend copies, under the same conditions stated above, and you 11634 may publicly display copies. 11635\end_layout 11636 11637\begin_layout Section* 116383. 11639 COPYING IN QUANTITY 11640\end_layout 11641 11642\begin_layout Standard 11643If you publish printed copies of the Document numbering more than 100, and 11644 the Document's license notice requires Cover Texts, you must enclose the 11645 copies in covers that carry, clearly and legibly, all these Cover Texts: 11646 Front-Cover Texts on the front cover, and Back-Cover Texts on the back 11647 cover. 11648 Both covers must also clearly and legibly identify you as the publisher 11649 of these copies. 11650 The front cover must present the full title with all words of the title 11651 equally prominent and visible. 11652 You may add other material on the covers in addition. 11653 Copying with changes limited to the covers, as long as they preserve the 11654 title of the Document and satisfy these conditions, can be treated as verbatim 11655 copying in other respects. 11656\end_layout 11657 11658\begin_layout Standard 11659If the required texts for either cover are too voluminous to fit legibly, 11660 you should put the first ones listed (as many as fit reasonably) on the 11661 actual cover, and continue the rest onto adjacent pages. 11662\end_layout 11663 11664\begin_layout Standard 11665If you publish or distribute Opaque copies of the Document numbering more 11666 than 100, you must either include a machine-readable Transparent copy along 11667 with each Opaque copy, or state in or with each Opaque copy a publicly-accessib 11668le computer-network location containing a complete Transparent copy of the 11669 Document, free of added material, which the general network-using public 11670 has access to download anonymously at no charge using public-standard network 11671 protocols. 11672 If you use the latter option, you must take reasonably prudent steps, when 11673 you begin distribution of Opaque copies in quantity, to ensure that this 11674 Transparent copy will remain thus accessible at the stated location until 11675 at least one year after the last time you distribute an Opaque copy (directly 11676 or through your agents or retailers) of that edition to the public. 11677\end_layout 11678 11679\begin_layout Standard 11680It is requested, but not required, that you contact the authors of the Document 11681 well before redistributing any large number of copies, to give them a chance 11682 to provide you with an updated version of the Document. 11683 11684\end_layout 11685 11686\begin_layout Section* 116874. 11688 MODIFICATIONS 11689\end_layout 11690 11691\begin_layout Standard 11692You may copy and distribute a Modified Version of the Document under the 11693 conditions of sections 2 and 3 above, provided that you release the Modified 11694 Version under precisely this License, with the Modified Version filling 11695 the role of the Document, thus licensing distribution and modification 11696 of the Modified Version to whoever possesses a copy of it. 11697 In addition, you must do these things in the Modified Version: 11698\end_layout 11699 11700\begin_layout Itemize 11701A. 11702 Use in the Title Page (and on the covers, if any) a title distinct from 11703 that of the Document, and from those of previous versions (which should, 11704 if there were any, be listed in the History section of the Document). 11705 You may use the same title as a previous version if the original publisher 11706 of that version gives permission. 11707\end_layout 11708 11709\begin_layout Itemize 11710B. 11711 List on the Title Page, as authors, one or more persons or entities responsible 11712 for authorship of the modifications in the Modified Version, together with 11713 at least five of the principal authors of the Document (all of its principal 11714 authors, if it has less than five). 11715\end_layout 11716 11717\begin_layout Itemize 11718C. 11719 State on the Title page the name of the publisher of the Modified Version, 11720 as the publisher. 11721\end_layout 11722 11723\begin_layout Itemize 11724D. 11725 Preserve all the copyright notices of the Document. 11726\end_layout 11727 11728\begin_layout Itemize 11729E. 11730 Add an appropriate copyright notice for your modifications adjacent to 11731 the other copyright notices. 11732\end_layout 11733 11734\begin_layout Itemize 11735F. 11736 Include, immediately after the copyright notices, a license notice giving 11737 the public permission to use the Modified Version under the terms of this 11738 License, in the form shown in the Addendum below. 11739\end_layout 11740 11741\begin_layout Itemize 11742G. 11743 Preserve in that license notice the full lists of Invariant Sections and 11744 required Cover Texts given in the Document's license notice. 11745\end_layout 11746 11747\begin_layout Itemize 11748H. 11749 Include an unaltered copy of this License. 11750\end_layout 11751 11752\begin_layout Itemize 11753I. 11754 Preserve the section entitled "History", and its title, and add to it an 11755 item stating at least the title, year, new authors, and publisher of the 11756 Modified Version as given on the Title Page. 11757 If there is no section entitled "History" in the Document, create one stating 11758 the title, year, authors, and publisher of the Document as given on its 11759 Title Page, then add an item describing the Modified Version as stated 11760 in the previous sentence. 11761\end_layout 11762 11763\begin_layout Itemize 11764J. 11765 Preserve the network location, if any, given in the Document for public 11766 access to a Transparent copy of the Document, and likewise the network 11767 locations given in the Document for previous versions it was based on. 11768 These may be placed in the "History" section. 11769 You may omit a network location for a work that was published at least 11770 four years before the Document itself, or if the original publisher of 11771 the version it refers to gives permission. 11772\end_layout 11773 11774\begin_layout Itemize 11775K. 11776 In any section entitled "Acknowledgements" or "Dedications", preserve the 11777 section's title, and preserve in the section all the substance and tone 11778 of each of the contributor acknowledgements and/or dedications given therein. 11779\end_layout 11780 11781\begin_layout Itemize 11782L. 11783 Preserve all the Invariant Sections of the Document, unaltered in their 11784 text and in their titles. 11785 Section numbers or the equivalent are not considered part of the section 11786 titles. 11787\end_layout 11788 11789\begin_layout Itemize 11790M. 11791 Delete any section entitled "Endorsements". 11792 Such a section may not be included in the Modified Version. 11793\end_layout 11794 11795\begin_layout Itemize 11796N. 11797 Do not retitle any existing section as "Endorsements" or to conflict in 11798 title with any Invariant Section. 11799 11800\end_layout 11801 11802\begin_layout Standard 11803If the Modified Version includes new front-matter sections or appendices 11804 that qualify as Secondary Sections and contain no material copied from 11805 the Document, you may at your option designate some or all of these sections 11806 as invariant. 11807 To do this, add their titles to the list of Invariant Sections in the Modified 11808 Version's license notice. 11809 These titles must be distinct from any other section titles. 11810\end_layout 11811 11812\begin_layout Standard 11813You may add a section entitled "Endorsements", provided it contains nothing 11814 but endorsements of your Modified Version by various parties--for example, 11815 statements of peer review or that the text has been approved by an organization 11816 as the authoritative definition of a standard. 11817\end_layout 11818 11819\begin_layout Standard 11820You may add a passage of up to five words as a Front-Cover Text, and a passage 11821 of up to 25 words as a Back-Cover Text, to the end of the list of Cover 11822 Texts in the Modified Version. 11823 Only one passage of Front-Cover Text and one of Back-Cover Text may be 11824 added by (or through arrangements made by) any one entity. 11825 If the Document already includes a cover text for the same cover, previously 11826 added by you or by arrangement made by the same entity you are acting on 11827 behalf of, you may not add another; but you may replace the old one, on 11828 explicit permission from the previous publisher that added the old one. 11829\end_layout 11830 11831\begin_layout Standard 11832The author(s) and publisher(s) of the Document do not by this License give 11833 permission to use their names for publicity for or to assert or imply endorseme 11834nt of any Modified Version. 11835 11836\end_layout 11837 11838\begin_layout Section* 118395. 11840 COMBINING DOCUMENTS 11841\end_layout 11842 11843\begin_layout Standard 11844You may combine the Document with other documents released under this License, 11845 under the terms defined in section 4 above for modified versions, provided 11846 that you include in the combination all of the Invariant Sections of all 11847 of the original documents, unmodified, and list them all as Invariant Sections 11848 of your combined work in its license notice. 11849\end_layout 11850 11851\begin_layout Standard 11852The combined work need only contain one copy of this License, and multiple 11853 identical Invariant Sections may be replaced with a single copy. 11854 If there are multiple Invariant Sections with the same name but different 11855 contents, make the title of each such section unique by adding at the end 11856 of it, in parentheses, the name of the original author or publisher of 11857 that section if known, or else a unique number. 11858 Make the same adjustment to the section titles in the list of Invariant 11859 Sections in the license notice of the combined work. 11860\end_layout 11861 11862\begin_layout Standard 11863In the combination, you must combine any sections entitled "History" in 11864 the various original documents, forming one section entitled "History"; 11865 likewise combine any sections entitled "Acknowledgements", and any sections 11866 entitled "Dedications". 11867 You must delete all sections entitled "Endorsements." 11868\end_layout 11869 11870\begin_layout Section* 118716. 11872 COLLECTIONS OF DOCUMENTS 11873\end_layout 11874 11875\begin_layout Standard 11876You may make a collection consisting of the Document and other documents 11877 released under this License, and replace the individual copies of this 11878 License in the various documents with a single copy that is included in 11879 the collection, provided that you follow the rules of this License for 11880 verbatim copying of each of the documents in all other respects. 11881\end_layout 11882 11883\begin_layout Standard 11884You may extract a single document from such a collection, and distribute 11885 it individually under this License, provided you insert a copy of this 11886 License into the extracted document, and follow this License in all other 11887 respects regarding verbatim copying of that document. 11888 11889\end_layout 11890 11891\begin_layout Section* 118927. 11893 AGGREGATION WITH INDEPENDENT WORKS 11894\end_layout 11895 11896\begin_layout Standard 11897A compilation of the Document or its derivatives with other separate and 11898 independent documents or works, in or on a volume of a storage or distribution 11899 medium, does not as a whole count as a Modified Version of the Document, 11900 provided no compilation copyright is claimed for the compilation. 11901 Such a compilation is called an "aggregate", and this License does not 11902 apply to the other self-contained works thus compiled with the Document, 11903 on account of their being thus compiled, if they are not themselves derivative 11904 works of the Document. 11905\end_layout 11906 11907\begin_layout Standard 11908If the Cover Text requirement of section 3 is applicable to these copies 11909 of the Document, then if the Document is less than one quarter of the entire 11910 aggregate, the Document's Cover Texts may be placed on covers that surround 11911 only the Document within the aggregate. 11912 Otherwise they must appear on covers around the whole aggregate. 11913\end_layout 11914 11915\begin_layout Section* 119168. 11917 TRANSLATION 11918\end_layout 11919 11920\begin_layout Standard 11921Translation is considered a kind of modification, so you may distribute 11922 translations of the Document under the terms of section 4. 11923 Replacing Invariant Sections with translations requires special permission 11924 from their copyright holders, but you may include translations of some 11925 or all Invariant Sections in addition to the original versions of these 11926 Invariant Sections. 11927 You may include a translation of this License provided that you also include 11928 the original English version of this License. 11929 In case of a disagreement between the translation and the original English 11930 version of this License, the original English version will prevail. 11931\end_layout 11932 11933\begin_layout Section* 119349. 11935 TERMINATION 11936\end_layout 11937 11938\begin_layout Standard 11939You may not copy, modify, sublicense, or distribute the Document except 11940 as expressly provided for under this License. 11941 Any other attempt to copy, modify, sublicense or distribute the Document 11942 is void, and will automatically terminate your rights under this License. 11943 However, parties who have received copies, or rights, from you under this 11944 License will not have their licenses terminated so long as such parties 11945 remain in full compliance. 11946 11947\end_layout 11948 11949\begin_layout Section* 1195010. 11951 FUTURE REVISIONS OF THIS LICENSE 11952\end_layout 11953 11954\begin_layout Standard 11955The Free Software Foundation may publish new, revised versions of the GNU 11956 Free Documentation License from time to time. 11957 Such new versions will be similar in spirit to the present version, but 11958 may differ in detail to address new problems or concerns. 11959 See http://www.gnu.org/copyleft/. 11960\end_layout 11961 11962\begin_layout Standard 11963Each version of the License is given a distinguishing version number. 11964 If the Document specifies that a particular numbered version of this License 11965 "or any later version" applies to it, you have the option of following 11966 the terms and conditions either of that specified version or of any later 11967 version that has been published (not as a draft) by the Free Software Foundatio 11968n. 11969 If the Document does not specify a version number of this License, you 11970 may choose any version ever published (not as a draft) by the Free Software 11971 Foundation. 11972\end_layout 11973 11974\begin_layout Standard 11975\begin_inset CommandInset index_print 11976LatexCommand printindex 11977 11978\end_inset 11979 11980 11981\end_layout 11982 11983\end_body 11984\end_document 11985