├── doc ├── .cvsignore ├── Makefile.am ├── manual.pdf ├── echo_path.odg ├── speex_abs.odg ├── celp_decoder.odg ├── components.odg ├── speex_analysis.odg ├── sampleenc.c ├── sampledec.c └── programming.html ├── include ├── Makefile.am └── speex │ ├── speexdsp_config_types.h.in │ ├── Makefile.am │ ├── speex_buffer.h │ ├── speexdsp_types.h │ └── speex_echo.h ├── NEWS ├── html ├── speex.png ├── speex.xcf └── speex.webprj ├── macosx ├── English.lproj │ └── InfoPlist.strings ├── Speex_Prefix.pch └── Info.plist ├── README ├── libspeexdsp ├── .cvsignore ├── bfin.h ├── testdenoise.c ├── kiss_fftr.h ├── testecho.c ├── smallft.h ├── Makefile.am ├── testjitter.c ├── echo_diagnostic.m ├── misc_bfin.h ├── fftwrap.h ├── filterbank.h ├── testresample.c ├── testresample2.c ├── kiss_fft.h ├── vorbis_psy.h ├── stack_alloc.h ├── fixed_bfin.h ├── fixed_arm4.h ├── resample_sse.h ├── fixed_generic.h ├── fixed_arm5e.h ├── buffer.c ├── os_support.h └── _kiss_fft_guts.h ├── INSTALL ├── symbian ├── Makefile.am ├── speex.mmp ├── bld.inf └── config.h ├── .cvsignore ├── autogen.sh ├── regressions ├── ti ├── speex_C55_test │ ├── Makefile.am │ ├── speex_C55_test.pjt │ └── speex_C55_test.cmd ├── speex_C64_test │ ├── Makefile.am │ ├── speex_C64_test.pjt │ └── speex_C64_test.cmd ├── speex_C54_test │ ├── Makefile.am │ ├── speex_C54_test.pjt │ └── speex_C54_test.cmd ├── Makefile.am ├── config.h └── os_support_custom.h ├── win32 ├── VS2003 │ ├── libspeexdsp │ │ └── Makefile.am │ ├── Makefile.am │ └── tests │ │ ├── Makefile.am │ │ ├── testecho.vcproj │ │ ├── testdenoise.vcproj │ │ └── testresample.vcproj ├── VS2005 │ ├── libspeexdsp │ │ └── Makefile.am │ ├── Makefile.am │ └── tests │ │ └── Makefile.am ├── VS2008 │ ├── libspeexdsp │ │ └── Makefile.am │ ├── Makefile.am │ └── tests │ │ └── Makefile.am ├── libspeexdsp │ ├── Makefile.am │ ├── libspeexdsp.dsw │ └── libspeexdsp.dsp ├── Makefile.am ├── config.h ├── libspeexdsp.def └── speex.iss ├── .travis.yml ├── speexdsp.pc.in ├── .gitignore ├── AUTHORS ├── README.win32 ├── Makefile.am ├── tmv ├── speex_config_types.h ├── misc_tm.h ├── fixed_tm.h ├── config.h ├── fftwrap_tm.h └── _kiss_fft_guts_tm.h ├── README.blackfin ├── regression-fixes └── 1-resampler_unsigned_fix.patch ├── .gitlab-ci.yml ├── ChangeLog ├── TODO ├── COPYING ├── SpeexDSP.spec.in ├── acinclude.m4 └── README.Trimedia /doc/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | SUBDIRS = speex 3 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 2002/02/13: Creation of the "Speex" project 2 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | doc_DATA = manual.pdf 2 | 3 | EXTRA_DIST = $(doc_DATA) 4 | -------------------------------------------------------------------------------- /doc/manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speexdsp/master/doc/manual.pdf -------------------------------------------------------------------------------- /html/speex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speexdsp/master/html/speex.png -------------------------------------------------------------------------------- /html/speex.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speexdsp/master/html/speex.xcf -------------------------------------------------------------------------------- /doc/echo_path.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speexdsp/master/doc/echo_path.odg -------------------------------------------------------------------------------- /doc/speex_abs.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speexdsp/master/doc/speex_abs.odg -------------------------------------------------------------------------------- /doc/celp_decoder.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speexdsp/master/doc/celp_decoder.odg -------------------------------------------------------------------------------- /doc/components.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speexdsp/master/doc/components.odg -------------------------------------------------------------------------------- /doc/speex_analysis.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speexdsp/master/doc/speex_analysis.odg -------------------------------------------------------------------------------- /macosx/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mumble-voip/speexdsp/master/macosx/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | See INSTALL file for instructions on how to install SpeexDSP. 2 | 3 | SpeexDSP is a patent-free, Open Source/Free Software DSP library. 4 | -------------------------------------------------------------------------------- /macosx/Speex_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Speex' target in the 'Speex' project. 3 | // 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /libspeexdsp/.cvsignore: -------------------------------------------------------------------------------- 1 | .deps 2 | .libs 3 | *.la 4 | *.lo 5 | *.o 6 | Makefile 7 | Makefile.in 8 | testdenoise 9 | testenc 10 | testenc_uwb 11 | testenc_wb 12 | -------------------------------------------------------------------------------- /html/speex.webprj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installing SpeexDSP is as easy as: 2 | 3 | % ./configure [--prefix=] 4 | % make 5 | % make install 6 | 7 | Note that if you are using the code from git you will need to run "autogen.sh" 8 | and then "configure". 9 | -------------------------------------------------------------------------------- /symbian/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = bld.inf config.h speex.mmp 7 | -------------------------------------------------------------------------------- /.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | Speex.spec 4 | aclocal.m4 5 | autom4te.cache 6 | config.guess 7 | config.log 8 | config.status 9 | config.sub 10 | configure 11 | depcomp 12 | install-sh 13 | libtool 14 | ltconfig 15 | ltmain.sh 16 | missing 17 | mkinstalldirs 18 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run this to set up the build system: configure, makefiles, etc. 3 | set -e 4 | 5 | srcdir=`dirname $0` 6 | test -n "$srcdir" && cd "$srcdir" 7 | 8 | echo "Updating build configuration files, please wait...." 9 | 10 | mkdir -p m4 11 | autoreconf -if 12 | 13 | -------------------------------------------------------------------------------- /regressions: -------------------------------------------------------------------------------- 1 | 1: 723f644e09333a0230383eae4af1f3aa3e46e1c3 (r12736): broke resampler badly 2 | Changed the sign of a bunch of parameters in the API. Tons of signed/unsigned changes in the code as a consequence of that. Hopefully this will be the last change to the API. 3 | Fixed: 2007-08-11 4 | 5 | -------------------------------------------------------------------------------- /ti/speex_C55_test/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speex_C55_test.cmd speex_C55_test.pjt 7 | -------------------------------------------------------------------------------- /ti/speex_C64_test/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speex_C64_test.cmd speex_C64_test.pjt 7 | -------------------------------------------------------------------------------- /win32/VS2003/libspeexdsp/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = libspeexdsp.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2005/libspeexdsp/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = libspeexdsp.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2008/libspeexdsp/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = libspeexdsp.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /include/speex/speexdsp_config_types.h.in: -------------------------------------------------------------------------------- 1 | #ifndef __SPEEX_TYPES_H__ 2 | #define __SPEEX_TYPES_H__ 3 | 4 | @INCLUDE_STDINT@ 5 | 6 | typedef @SIZE16@ spx_int16_t; 7 | typedef @USIZE16@ spx_uint16_t; 8 | typedef @SIZE32@ spx_int32_t; 9 | typedef @USIZE32@ spx_uint32_t; 10 | 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /ti/speex_C54_test/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = speex_C54_test.cmd speex_C54_test.pjt 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2003/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | SUBDIRS = libspeexdsp tests 7 | 8 | EXTRA_DIST = libspeexdsp.sln 9 | -------------------------------------------------------------------------------- /win32/VS2005/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | SUBDIRS = libspeexdsp tests 7 | 8 | EXTRA_DIST = libspeexdsp.sln 9 | -------------------------------------------------------------------------------- /win32/VS2008/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | SUBDIRS = libspeexdsp tests 7 | 8 | EXTRA_DIST = libspeexdsp.sln 9 | -------------------------------------------------------------------------------- /win32/libspeexdsp/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = libspeexdsp.dsw libspeexdsp.dsp libspeexdsp_dynamic.dsp 7 | -------------------------------------------------------------------------------- /win32/VS2003/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = testdenoise.vcproj testecho.vcproj testresample.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2005/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = testdenoise.vcproj testecho.vcproj testresample.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/VS2008/tests/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | EXTRA_DIST = testdenoise.vcproj testecho.vcproj testresample.vcproj 7 | 8 | 9 | -------------------------------------------------------------------------------- /win32/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | SUBDIRS = libspeexdsp VS2003 VS2005 VS2008 7 | 8 | EXTRA_DIST = speex.iss config.h libspeexdsp.def 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | env: 4 | - CONFIG="" 5 | - CONFIG="--enable-fixed-point" 6 | - CONFIG="--enable-fixed-point --disable-float-api" 7 | 8 | os: 9 | - linux 10 | - osx 11 | 12 | compiler: 13 | - gcc 14 | - clang 15 | 16 | script: 17 | - ./autogen.sh 18 | - ./configure $CONFIG 19 | - make distcheck 20 | -------------------------------------------------------------------------------- /ti/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # Disable automatic dependency tracking if using other tools than gcc and gmake 4 | #AUTOMAKE_OPTIONS = no-dependencies 5 | 6 | SUBDIRS = speex_C54_test speex_C55_test speex_C64_test 7 | 8 | EXTRA_DIST = config.h os_support_custom.h 9 | 10 | -------------------------------------------------------------------------------- /speexdsp.pc.in: -------------------------------------------------------------------------------- 1 | # libspeexdsp pkg-config source file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: speexdsp 9 | Description: Speexdsp is a speech processing library that goes along with the Speex codec 10 | Version: @PACKAGE_VERSION@ 11 | Requires: @FFT_PKGCONFIG@ 12 | Conflicts: 13 | Libs: -L${libdir} -lspeexdsp 14 | Libs.private: @LIBM@ 15 | Cflags: -I${includedir} 16 | -------------------------------------------------------------------------------- /libspeexdsp/bfin.h: -------------------------------------------------------------------------------- 1 | /* Common Blackfin assembly defines 2 | * 3 | * Copyright (C) 2005-2009 Analog Devices 4 | */ 5 | 6 | #if __GNUC__ <= 3 7 | /* GCC-3.4 and older did not use hardware loops and thus did not have 8 | * register constraints for declaring clobbers. 9 | */ 10 | # define BFIN_HWLOOP0_REGS 11 | # define BFIN_HWLOOP1_REGS 12 | #else 13 | # define BFIN_HWLOOP0_REGS , "LB0", "LT0", "LC0" 14 | # define BFIN_HWLOOP1_REGS , "LB1", "LT1", "LC1" 15 | #endif 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.lo 3 | Makefile.in 4 | *~ 5 | *.orig 6 | fixed 7 | float 8 | aclocal.m4 9 | autom4te.cache 10 | compile 11 | config.guess 12 | config.h.in 13 | config.sub 14 | configure 15 | depcomp 16 | install-sh 17 | ltmain.sh 18 | missing 19 | Makefile 20 | .deps 21 | .libs 22 | *.la 23 | work 24 | SpeexDSP.spec 25 | config.h 26 | config.log 27 | config.status 28 | include/speex/speexdsp_config_types.h 29 | *.sw[lmnop] 30 | testdenoise 31 | testecho 32 | testjitter 33 | libtool 34 | speexdsp.pc 35 | stamp-* 36 | patches 37 | /m4 38 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Jean-Marc Valin 2 | All the code except the following 3 | 4 | David Rowe 5 | lsp.c lsp.h 6 | Also ideas and feedback 7 | 8 | John Francis Edwards 9 | wave_out.[ch], some #ifdefs for windows port and MSVC project files 10 | 11 | Segher Boessenkool 12 | Misc. optimizations (for QMF in particular) 13 | 14 | Atsuhiko Yamanaka : 15 | Patch to speexenc.c to add Vorbis comment format 16 | 17 | Radim Kolar : 18 | Patch to speexenc.c for supporting more input formats 19 | -------------------------------------------------------------------------------- /README.win32: -------------------------------------------------------------------------------- 1 | Win32 Specific options 2 | 3 | In order to enable the following options within SpeexDSP, you will need to manually edit the project options for the appropriate VC configuration. These macros can be specified by adding them as "Preprocessor Definitions" under the appropriate Configuration's project options. If you don't know how to do this, please check your Visual C documentation. 4 | 5 | Feature: 6 | 7 | Intel Streaming SIMD Extensions - SSE - macro: USE_SSE 8 | Fixed point - macro: FIXED_POINT 9 | Epic 48 - macro: EPIC_48K 10 | 11 | Note: USE_SSE and FIXED_POINT are mutually exclusive. 12 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in. -*-Makefile-*- 2 | 3 | # To disable automatic dependency tracking if using other tools than 4 | # gcc and gmake, add the option 'no-dependencies' 5 | AUTOMAKE_OPTIONS = 1.8 6 | ACLOCAL_AMFLAGS = -I m4 7 | 8 | pkgconfigdir = $(libdir)/pkgconfig 9 | pkgconfig_DATA = speexdsp.pc 10 | 11 | EXTRA_DIST = SpeexDSP.spec SpeexDSP.spec.in SpeexDSP.kdevelop speexdsp.pc.in README.blackfin 12 | 13 | #Fools KDevelop into including all files 14 | SUBDIRS = libspeexdsp include doc win32 symbian ti 15 | 16 | DIST_SUBDIRS = libspeexdsp include doc win32 symbian ti 17 | 18 | rpm: dist 19 | rpmbuild -ta ${PACKAGE}-${VERSION}.tar.gz 20 | -------------------------------------------------------------------------------- /tmv/speex_config_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __SPEEX_TYPES_H__ 2 | #define __SPEEX_TYPES_H__ 3 | 4 | #ifdef __TCS__ 5 | 6 | #include 7 | 8 | 9 | 10 | typedef Int16 spx_int16_t; 11 | typedef UInt16 spx_uint16_t; 12 | typedef Int32 spx_int32_t; 13 | typedef UInt32 spx_uint32_t; 14 | 15 | #ifdef FIXED_POINT 16 | #define VMUX(a,b,c) mux((a),(b),(c)) 17 | #define VABS(a) iabs((a)) 18 | #define VMAX(a,b) imax((a),(b)) 19 | #define VMIN(a,b) imin((a),(b)) 20 | #else 21 | #define VMUX(a,b,c) fmux((a),(b),(c)) 22 | #define VABS(a) fabs((a)) 23 | #define VMAX(a,b) fmax((a),(b)) 24 | #define VMIN(a,b) fmin((a),(b)) 25 | #endif 26 | 27 | #endif 28 | 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /include/speex/Makefile.am: -------------------------------------------------------------------------------- 1 | # Disable automatic dependency tracking if using other tools than gcc and gmake 2 | #AUTOMAKE_OPTIONS = no-dependencies 3 | 4 | # Historically, these headers were part of the speex package, so in order to 5 | # keep compatibility with existing software we need to keep installing them 6 | # in the same place as they were found then. If new functionality, with new 7 | # headers, are added later, some thought should be given as to whether they 8 | # should instead go somewhere other than $prefix/include/speex. 9 | 10 | speexincludedir = $(includedir)/speex 11 | 12 | nodist_speexinclude_HEADERS = speexdsp_config_types.h 13 | 14 | speexinclude_HEADERS = speex_echo.h speex_jitter.h speex_preprocess.h speex_resampler.h \ 15 | speexdsp_types.h 16 | 17 | noinst_HEADERS=speex_buffer.h 18 | 19 | -------------------------------------------------------------------------------- /README.blackfin: -------------------------------------------------------------------------------- 1 | SpeexDSP has been ported to the Blackfin DSP, for the STAMP development board. 2 | 3 | This port has been tested on the STAMP development board and requires the 4 | toolchain available at http://blackfin.uclinux.org/ 5 | 6 | 1/ In order to cross-compile for uClinux from the SpeexDSP tarball: 7 | 8 | ./configure --enable-blackfin-asm --enable-fixed-point --host=bfin-uclinux 9 | cd libspeexdsp 10 | make 11 | 12 | The --enable-blackfin-asm option is not required, but it speeds up Speex by 13 | approximately a factor of two. 14 | 15 | 2/ In order to cross-compile for uClinux from the SpeexDSP git: 16 | 17 | git clone git://git.xiph.org/speexdsp.git 18 | cd speexdsp 19 | ./autogen.sh 20 | ./configure --enable-blackfin-asm --enable-fixed-point --host=bfin-uclinux 21 | cd libspeexdsp 22 | make 23 | -------------------------------------------------------------------------------- /regression-fixes/1-resampler_unsigned_fix.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libspeex/resample.c b/libspeex/resample.c 2 | index 4403f78..48ffcef 100644 3 | --- a/libspeex/resample.c 4 | +++ b/libspeex/resample.c 5 | @@ -561,10 +561,10 @@ static void update_filter(SpeexResamplerState *st) 6 | } 7 | for (i=0;iden_rate;i++) 8 | { 9 | - spx_uint32_t j; 10 | + spx_int32_t j; 11 | for (j=0;jfilt_len;j++) 12 | { 13 | - st->sinc_table[i*st->filt_len+j] = sinc(st->cutoff,((j-st->filt_len/2+1)-((float)i)/st->den_rate), st->filt_len, quality_map[st->quality].window_func); 14 | + st->sinc_table[i*st->filt_len+j] = sinc(st->cutoff,((j-(spx_int32_t)st->filt_len/2+1)-((float)i)/st->den_rate), st->filt_len, quality_map[st->quality].window_func); 15 | } 16 | } 17 | #ifdef FIXED_POINT 18 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | default: 2 | tags: 3 | - docker 4 | # Image from https://hub.docker.com/_/gcc/ based on Debian 5 | image: gcc:9 6 | 7 | .autoconf: 8 | stage: build 9 | before_script: 10 | - apt-get update && 11 | apt-get install -y libfftw3-dev 12 | script: 13 | - ./autogen.sh 14 | - ./configure ${CONFIG_FLAGS} 15 | - make 16 | - make check 17 | 18 | autoconf: 19 | extends: .autoconf 20 | script: 21 | - ./autogen.sh 22 | - ./configure ${CONFIG_FLAGS} 23 | - make 24 | - make distcheck 25 | 26 | fixed-point: 27 | extends: .autoconf 28 | variables: 29 | CONFIG_FLAGS: --enable-fixed-point 30 | 31 | no-float: 32 | extends: .autoconf 33 | variables: 34 | CONFIG_FLAGS: --enable-fixed-point --disable-float-api 35 | 36 | no-examples: 37 | extends: .autoconf 38 | variables: 39 | CONFIG_FLAGS: --disable-examples 40 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2005-09-07 Thomas Vander Stichele 2 | 3 | * libspeex/cb_search.c: (split_cb_search_shape_sign_N1): 4 | add declaration for n, seems like an obvious build fix, slap 5 | me down if it's not 6 | 7 | 2004-02-18 Jean-Marc Valin 8 | Patch for compiling with mingw32 sent by j@thing.net 9 | 10 | 2004-02-18 Jean-Marc Valin 11 | Integrated IRIX patch (getopt stuff) from Michael Pruett 12 | 13 | 2004-02-18 Jean-Marc Valin 14 | Changed the Makefile.am so that KDevelop can parse SUBDIRS correctly 15 | 16 | 2002/03/27 Jean-Marc Valin: 17 | Working encoder and decoder for both narrowband and wideband. 18 | 19 | 2002/02/27 Jean-Marc Valin: 20 | Got the basic encoder working as a demo with quantization only on some 21 | parameters. 22 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | For 1.2: 2 | Major points: 3 | - Make documentation match the actual code (especially jitter buffer, AEC and preprocessor) 4 | - Get AGC to work in fixed-point even if not totally converted 5 | - Stabilise all APIs (need feedback) 6 | - Short-term estimate in jitter buffer 7 | - Control delay in new AEC API. 8 | - NaN checks? 9 | - Better error reporting 10 | - Make kiss-fft 32-bit safe 11 | 12 | Post 1.2: 13 | improve float<->int conversion 14 | split encoder and decoder? 15 | Merge TriMedia stuff 16 | packet dump 17 | Do VAD properly 18 | --enable-{aec,preprocessor,jitter,resampler} 19 | 20 | Optimisations 21 | - Add restrict in a few places? 22 | - use __builtin_expect() (likely()/unlikely()) 23 | 24 | Allocator override (speex_lib_ctl?) 25 | Fixed-point: 26 | - VBR 27 | - Jitter buffer 28 | - AGC 29 | Denoiser: 30 | - Better noise adaptation 31 | AGC: 32 | - Use median filtering instead of "non-linear mean"? 33 | -------------------------------------------------------------------------------- /win32/config.h: -------------------------------------------------------------------------------- 1 | // Microsoft version of 'inline' 2 | #define inline __inline 3 | 4 | // In Visual Studio, _M_IX86_FP=1 means /arch:SSE was used, likewise 5 | // _M_IX86_FP=2 means /arch:SSE2 was used. 6 | // Also, enable both USE_SSE and USE_SSE2 if we're compiling for x86-64 7 | #if _M_IX86_FP >= 1 || defined(_M_X64) 8 | #define USE_SSE 9 | #endif 10 | 11 | #if _M_IX86_FP >= 2 || defined(_M_X64) 12 | #define USE_SSE2 13 | #endif 14 | 15 | // Visual Studio support alloca(), but it always align variables to 16-bit 16 | // boundary, while SSE need 128-bit alignment. So we disable alloca() when 17 | // SSE is enabled. 18 | #ifndef USE_SSE 19 | # define USE_ALLOCA 20 | #endif 21 | 22 | /* Default to floating point */ 23 | #ifndef FIXED_POINT 24 | # define FLOATING_POINT 25 | # define USE_SMALLFT 26 | #else 27 | # define USE_KISS_FFT 28 | #endif 29 | 30 | /* We don't support visibility on Win32 */ 31 | #define EXPORT 32 | -------------------------------------------------------------------------------- /win32/libspeexdsp/libspeexdsp.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "libspeexdsp"=.\libspeexdsp.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "libspeexdsp_dynamic"=.\libspeexdsp_dynamic.dsp - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Global: 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<3> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | -------------------------------------------------------------------------------- /macosx/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | Speex 9 | CFBundleGetInfoString 10 | Speex framework 1.1.12svn, Copyright © 2002-2006 Xiph.Org Foundation 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | org.xiph.speex 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.1.12svn 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.1.12d1 25 | NSHumanReadableCopyright 26 | Speex framework 1.1.12svn, Copyright © 2002-2006 Xiph.Org Foundation 27 | CSResourcesFileMapped 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /libspeexdsp/testdenoise.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include "config.h" 3 | #endif 4 | 5 | #include "speex/speex_preprocess.h" 6 | #include 7 | 8 | #define NN 160 9 | 10 | int main() 11 | { 12 | short in[NN]; 13 | int i; 14 | SpeexPreprocessState *st; 15 | int count=0; 16 | float f; 17 | 18 | st = speex_preprocess_state_init(NN, 8000); 19 | i=1; 20 | speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DENOISE, &i); 21 | i=0; 22 | speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC, &i); 23 | i=8000; 24 | speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_AGC_LEVEL, &i); 25 | i=0; 26 | speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB, &i); 27 | f=.0; 28 | speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f); 29 | f=.0; 30 | speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f); 31 | while (1) 32 | { 33 | int vad; 34 | fread(in, sizeof(short), NN, stdin); 35 | if (feof(stdin)) 36 | break; 37 | vad = speex_preprocess_run(st, in); 38 | /*fprintf (stderr, "%d\n", vad);*/ 39 | fwrite(in, sizeof(short), NN, stdout); 40 | count++; 41 | } 42 | speex_preprocess_state_destroy(st); 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /libspeexdsp/kiss_fftr.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_FTR_H 2 | #define KISS_FTR_H 3 | 4 | #include "kiss_fft.h" 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | 10 | /* 11 | 12 | Real optimized version can save about 45% cpu time vs. complex fft of a real seq. 13 | 14 | 15 | 16 | */ 17 | 18 | typedef struct kiss_fftr_state *kiss_fftr_cfg; 19 | 20 | 21 | kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem); 22 | /* 23 | nfft must be even 24 | 25 | If you don't care to allocate space, use mem = lenmem = NULL 26 | */ 27 | 28 | 29 | void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata); 30 | /* 31 | input timedata has nfft scalar points 32 | output freqdata has nfft/2+1 complex points 33 | */ 34 | 35 | void kiss_fftr2(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_scalar *freqdata); 36 | 37 | void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata); 38 | 39 | void kiss_fftri2(kiss_fftr_cfg st,const kiss_fft_scalar *freqdata, kiss_fft_scalar *timedata); 40 | 41 | /* 42 | input freqdata has nfft/2+1 complex points 43 | output timedata has nfft scalar points 44 | */ 45 | 46 | #define kiss_fftr_free speex_free 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif 52 | -------------------------------------------------------------------------------- /libspeexdsp/testecho.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include "config.h" 3 | #endif 4 | 5 | #include "speex/speex_echo.h" 6 | #include "speex/speex_preprocess.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | #define NN 128 15 | #define TAIL 1024 16 | 17 | int main(int argc, char **argv) 18 | { 19 | FILE *echo_fd, *ref_fd, *e_fd; 20 | short echo_buf[NN], ref_buf[NN], e_buf[NN]; 21 | SpeexEchoState *st; 22 | SpeexPreprocessState *den; 23 | int sampleRate = 8000; 24 | 25 | if (argc != 4) 26 | { 27 | fprintf(stderr, "testecho mic_signal.sw speaker_signal.sw output.sw\n"); 28 | exit(1); 29 | } 30 | echo_fd = fopen(argv[2], "rb"); 31 | ref_fd = fopen(argv[1], "rb"); 32 | e_fd = fopen(argv[3], "wb"); 33 | 34 | st = speex_echo_state_init(NN, TAIL); 35 | den = speex_preprocess_state_init(NN, sampleRate); 36 | speex_echo_ctl(st, SPEEX_ECHO_SET_SAMPLING_RATE, &sampleRate); 37 | speex_preprocess_ctl(den, SPEEX_PREPROCESS_SET_ECHO_STATE, st); 38 | 39 | while (!feof(ref_fd) && !feof(echo_fd)) 40 | { 41 | fread(ref_buf, sizeof(short), NN, ref_fd); 42 | fread(echo_buf, sizeof(short), NN, echo_fd); 43 | speex_echo_cancellation(st, ref_buf, echo_buf, e_buf); 44 | speex_preprocess_run(den, e_buf); 45 | fwrite(e_buf, sizeof(short), NN, e_fd); 46 | } 47 | speex_echo_state_destroy(st); 48 | speex_preprocess_state_destroy(den); 49 | fclose(e_fd); 50 | fclose(echo_fd); 51 | fclose(ref_fd); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /ti/speex_C55_test/speex_C55_test.pjt: -------------------------------------------------------------------------------- 1 | ; Code Composer Project File, Version 2.0 (do not modify or remove this line) 2 | 3 | [Project Settings] 4 | ProjectDir="C:\Speex\speex_14274\ti\speex_C55_test\" 5 | ProjectType=Executable 6 | CPUFamily=TMS320C55XX 7 | Tool="Compiler" 8 | Tool="CustomBuilder" 9 | Tool="DspBiosBuilder" 10 | Tool="Linker" 11 | Config="Debug" 12 | Config="Release" 13 | 14 | [Source Files] 15 | Source="..\..\libspeexdsp\buffer.c" 16 | Source="..\..\libspeexdsp\fftwrap.c" 17 | Source="..\..\libspeexdsp\filterbank.c" 18 | Source="..\..\libspeexdsp\jitter.c" 19 | Source="..\..\libspeexdsp\kiss_fft.c" 20 | Source="..\..\libspeexdsp\kiss_fftr.c" 21 | Source="..\..\libspeexdsp\mdf.c" 22 | Source="..\..\libspeexdsp\preprocess.c" 23 | Source="..\..\libspeexdsp\resample.c" 24 | Source="..\..\libspeexdsp\scal.c" 25 | Source="speex_C55_test.cmd" 26 | 27 | ["Compiler" Settings: "Debug"] 28 | Options=-g -q -o3 -fr"..\ti\speex_C55_test\Debug" -i"..\ti" -i"..\include" -d"_DEBUG" -d"CONFIG_TI_C55X" -d"HAVE_CONFIG_H" -mn 29 | 30 | ["Compiler" Settings: "Release"] 31 | Options=-q -o2 -fr"..\ti\speex_C55_test\Release" -i"..\ti" -i"..\include" -d"CONFIG_TI_C55X" -d"HAVE_CONFIG_H" -mn 32 | 33 | ["DspBiosBuilder" Settings: "Debug"] 34 | Options=-v55 35 | 36 | ["DspBiosBuilder" Settings: "Release"] 37 | Options=-v55 38 | 39 | ["Linker" Settings: "Debug"] 40 | Options=-q -c -m".\Debug\speex_C55_test.map" -o".\Debug\speex_C55_test.out" -w -x 41 | 42 | ["Linker" Settings: "Release"] 43 | Options=-q -c -m".\Release\speex_C55_test.map" -o".\Release\speex_C55_test.out" -w -x 44 | 45 | -------------------------------------------------------------------------------- /ti/speex_C64_test/speex_C64_test.pjt: -------------------------------------------------------------------------------- 1 | ; Code Composer Project File, Version 2.0 (do not modify or remove this line) 2 | 3 | [Project Settings] 4 | ProjectDir="C:\Speex\speex_14274\ti\speex_C64_test\" 5 | ProjectType=Executable 6 | CPUFamily=TMS320C64XX 7 | Tool="Compiler" 8 | Tool="CustomBuilder" 9 | Tool="DspBiosBuilder" 10 | Tool="Linker" 11 | Config="Debug" 12 | Config="Release" 13 | 14 | [Source Files] 15 | Source="..\..\..\..\CCStudio_v3.1\C6000\cgtools\lib\rts6400.lib" 16 | Source="..\..\libspeexdsp\buffer.c" 17 | Source="..\..\libspeexdsp\fftwrap.c" 18 | Source="..\..\libspeexdsp\filterbank.c" 19 | Source="..\..\libspeexdsp\jitter.c" 20 | Source="..\..\libspeexdsp\kiss_fft.c" 21 | Source="..\..\libspeexdsp\kiss_fftr.c" 22 | Source="..\..\libspeexdsp\mdf.c" 23 | Source="..\..\libspeexdsp\preprocess.c" 24 | Source="..\..\libspeexdsp\resample.c" 25 | Source="..\..\libspeexdsp\scal.c" 26 | Source="speex_C64_test.cmd" 27 | 28 | ["Compiler" Settings: "Debug"] 29 | Options=-g -o3 -fr"$(Proj_dir)\Debug" -i"..\ti" -i"..\include" -d"_DEBUG" -d"CONFIG_TI_C6X" -d"HAVE_CONFIG_H" -mv6400 30 | 31 | ["Compiler" Settings: "Release"] 32 | Options=-o3 -fr"$(Proj_dir)\Release" -i"..\ti" -i"..\include" -d"HAVE_CONFIG_H" -mv6400 33 | 34 | ["DspBiosBuilder" Settings: "Debug"] 35 | Options=-v6x 36 | 37 | ["DspBiosBuilder" Settings: "Release"] 38 | Options=-v6x 39 | 40 | ["Linker" Settings: "Debug"] 41 | Options=-c -m".\Debug\speex_C64_test.map" -o".\Debug\speex_C64_test.out" -w -x 42 | 43 | ["Linker" Settings: "Release"] 44 | Options=-c -m".\Release\speex_C64_test.map" -o".\Release\speex_C64_test.out" -w -x 45 | 46 | -------------------------------------------------------------------------------- /ti/speex_C54_test/speex_C54_test.pjt: -------------------------------------------------------------------------------- 1 | ; Code Composer Project File, Version 2.0 (do not modify or remove this line) 2 | 3 | [Project Settings] 4 | ProjectDir="C:\Speex\speex_14274\ti\speex_C54_test\" 5 | ProjectType=Executable 6 | CPUFamily=TMS320C54XX 7 | Tool="Compiler" 8 | Tool="CustomBuilder" 9 | Tool="DspBiosBuilder" 10 | Tool="Linker" 11 | Config="Debug" 12 | Config="Release" 13 | 14 | [Source Files] 15 | Source="..\..\libspeexdsp\buffer.c" 16 | Source="..\..\libspeexdsp\fftwrap.c" 17 | Source="..\..\libspeexdsp\filterbank.c" 18 | Source="..\..\libspeexdsp\jitter.c" 19 | Source="..\..\libspeexdsp\kiss_fft.c" 20 | Source="..\..\libspeexdsp\kiss_fftr.c" 21 | Source="..\..\libspeexdsp\mdf.c" 22 | Source="..\..\libspeexdsp\preprocess.c" 23 | Source="..\..\libspeexdsp\resample.c" 24 | Source="..\..\libspeexdsp\scal.c" 25 | Source="speex_C54_test.cmd" 26 | 27 | ["Compiler" Settings: "Debug"] 28 | Options=-g -q -o3 -fr"..\ti\speex_C54_test\Debug" -i"..\ti" -i"..\include" -d"_DEBUG" -d"CONFIG_TI_C54X" -d"HAVE_CONFIG_H" -d"NO_LONGLONG" -mf -ms 29 | 30 | ["Compiler" Settings: "Release"] 31 | Options=-q -o2 -fr"..\ti\speex_C54_test\Release" -i"..\ti" -i"..\include" -d"CONFIG_TI_C54X" -d"HAVE_CONFIG_H" -d"NO_LONGLONG" -mf -ms 32 | 33 | ["DspBiosBuilder" Settings: "Debug"] 34 | Options=-v54 35 | 36 | ["DspBiosBuilder" Settings: "Release"] 37 | Options=-v54 38 | 39 | ["Linker" Settings: "Debug"] 40 | Options=-q -c -heap4096 -m".\Debug\speex_C54_test.map" -o".\Debug\speex_C54_test.out" -stack4096 -w -x 41 | 42 | ["Linker" Settings: "Release"] 43 | Options=-q -c -m".\Release\speex_C54_test.map" -o".\Release\speex_C54_test.out" -w -x 44 | 45 | -------------------------------------------------------------------------------- /libspeexdsp/smallft.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * 9 | * by the XIPHOPHORUS Company http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: fft transform 14 | last mod: $Id: smallft.h,v 1.3 2003/09/16 18:35:45 jm Exp $ 15 | 16 | ********************************************************************/ 17 | /** 18 | @file smallft.h 19 | @brief Discrete Rotational Fourier Transform (DRFT) 20 | */ 21 | 22 | #ifndef _V_SMFT_H_ 23 | #define _V_SMFT_H_ 24 | 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /** Discrete Rotational Fourier Transform lookup */ 31 | struct drft_lookup{ 32 | int n; 33 | float *trigcache; 34 | int *splitcache; 35 | }; 36 | 37 | extern void spx_drft_forward(struct drft_lookup *l,float *data); 38 | extern void spx_drft_backward(struct drft_lookup *l,float *data); 39 | extern void spx_drft_init(struct drft_lookup *l,int n); 40 | extern void spx_drft_clear(struct drft_lookup *l); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /libspeexdsp/Makefile.am: -------------------------------------------------------------------------------- 1 | # Disable automatic dependency tracking if using other tools than gcc and gmake 2 | #AUTOMAKE_OPTIONS = no-dependencies 3 | 4 | EXTRA_DIST=echo_diagnostic.m 5 | 6 | AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include/speex -I$(top_builddir) @FFT_CFLAGS@ 7 | 8 | lib_LTLIBRARIES = libspeexdsp.la 9 | 10 | # Sources for compilation in the library 11 | if BUILD_KISS_FFT 12 | FFTSRC=kiss_fft.c _kiss_fft_guts.h kiss_fft.h kiss_fftr.c kiss_fftr.h 13 | else 14 | if BUILD_SMALLFT 15 | FFTSRC=smallft.c 16 | else 17 | FFTSRC= 18 | endif 19 | endif 20 | 21 | libspeexdsp_la_SOURCES = preprocess.c jitter.c mdf.c fftwrap.c filterbank.c resample.c buffer.c scal.c $(FFTSRC) 22 | 23 | noinst_HEADERS = arch.h bfin.h \ 24 | fixed_arm4.h \ 25 | fixed_arm5e.h fixed_bfin.h fixed_debug.h \ 26 | math_approx.h misc_bfin.h \ 27 | stack_alloc.h fftwrap.h \ 28 | filterbank.h fixed_generic.h os_support.h \ 29 | pseudofloat.h smallft.h vorbis_psy.h resample_sse.h resample_neon.h 30 | 31 | libspeexdsp_la_LDFLAGS = -no-undefined -version-info @SPEEXDSP_LT_CURRENT@:@SPEEXDSP_LT_REVISION@:@SPEEXDSP_LT_AGE@ 32 | libspeexdsp_la_LIBADD = $(LIBM) 33 | 34 | if BUILD_EXAMPLES 35 | noinst_PROGRAMS = testdenoise testecho testjitter testresample testresample2 36 | testdenoise_SOURCES = testdenoise.c 37 | testdenoise_LDADD = libspeexdsp.la @FFT_LIBS@ 38 | testecho_SOURCES = testecho.c 39 | testecho_LDADD = libspeexdsp.la @FFT_LIBS@ 40 | testjitter_SOURCES = testjitter.c 41 | testjitter_LDADD = libspeexdsp.la @FFT_LIBS@ 42 | testresample_SOURCES = testresample.c 43 | testresample_LDADD = libspeexdsp.la @FFT_LIBS@ @LIBM@ 44 | testresample2_SOURCES = testresample2.c 45 | testresample2_LDADD = libspeexdsp.la @FFT_LIBS@ @LIBM@ 46 | endif 47 | -------------------------------------------------------------------------------- /win32/libspeexdsp.def: -------------------------------------------------------------------------------- 1 | LIBRARY libspeexdsp 2 | EXPORTS 3 | 4 | 5 | ; 6 | ; speex_buffer.h 7 | ; 8 | speex_buffer_init 9 | speex_buffer_destroy 10 | speex_buffer_write 11 | speex_buffer_writezeros 12 | speex_buffer_read 13 | speex_buffer_get_available 14 | speex_buffer_resize 15 | 16 | ; 17 | ; speex_echo.h 18 | ; 19 | speex_echo_state_init 20 | speex_echo_state_init_mc 21 | speex_echo_state_destroy 22 | speex_echo_cancellation 23 | speex_echo_cancel 24 | speex_echo_capture 25 | speex_echo_playback 26 | speex_echo_state_reset 27 | speex_echo_ctl 28 | speex_decorrelate_new 29 | speex_decorrelate 30 | speex_decorrelate_destroy 31 | 32 | ; 33 | ; speex_jitter.h 34 | ; 35 | jitter_buffer_init 36 | jitter_buffer_reset 37 | jitter_buffer_destroy 38 | jitter_buffer_put 39 | jitter_buffer_get 40 | jitter_buffer_get_pointer_timestamp 41 | jitter_buffer_tick 42 | jitter_buffer_update_delay 43 | 44 | ; 45 | ; speex_preprocess.h 46 | ; 47 | speex_preprocess_state_init 48 | speex_preprocess_state_destroy 49 | speex_preprocess_run 50 | speex_preprocess 51 | speex_preprocess_estimate_update 52 | speex_preprocess_ctl 53 | 54 | ; 55 | ; speex_resampler.h 56 | ; 57 | speex_resampler_init 58 | speex_resampler_init_frac 59 | speex_resampler_destroy 60 | speex_resampler_process_float 61 | speex_resampler_process_int 62 | speex_resampler_process_interleaved_float 63 | speex_resampler_process_interleaved_int 64 | speex_resampler_set_rate 65 | speex_resampler_get_rate 66 | speex_resampler_set_rate_frac 67 | speex_resampler_get_ratio 68 | speex_resampler_set_quality 69 | speex_resampler_get_quality 70 | speex_resampler_set_input_stride 71 | speex_resampler_get_input_stride 72 | speex_resampler_set_output_stride 73 | speex_resampler_get_output_stride 74 | speex_resampler_skip_zeros 75 | speex_resampler_reset_mem 76 | speex_resampler_strerror 77 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2002-2008 Xiph.org Foundation 2 | Copyright 2002-2008 Jean-Marc Valin 3 | Copyright 2005-2007 Analog Devices Inc. 4 | Copyright 2005-2008 Commonwealth Scientific and Industrial Research 5 | Organisation (CSIRO) 6 | Copyright 1993, 2002, 2006 David Rowe 7 | Copyright 2003 EpicGames 8 | Copyright 1992-1994 Jutta Degener, Carsten Bormann 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions 12 | are met: 13 | 14 | - Redistributions of source code must retain the above copyright 15 | notice, this list of conditions and the following disclaimer. 16 | 17 | - Redistributions in binary form must reproduce the above copyright 18 | notice, this list of conditions and the following disclaimer in the 19 | documentation and/or other materials provided with the distribution. 20 | 21 | - Neither the name of the Xiph.org Foundation nor the names of its 22 | contributors may be used to endorse or promote products derived from 23 | this software without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 29 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 30 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 31 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 32 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 33 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 34 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 35 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /libspeexdsp/testjitter.c: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | #include "config.h" 3 | #endif 4 | 5 | #include "speex/speex_jitter.h" 6 | #include 7 | 8 | union jbpdata { 9 | unsigned int idx; 10 | unsigned char data[4]; 11 | }; 12 | 13 | void synthIn(JitterBufferPacket *in, int idx, int span) { 14 | union jbpdata d; 15 | d.idx = idx; 16 | 17 | in->data = d.data; 18 | in->len = sizeof(d); 19 | in->timestamp = idx * 10; 20 | in->span = span * 10; 21 | in->sequence = idx; 22 | in->user_data = 0; 23 | } 24 | 25 | void jitterFill(JitterBuffer *jb) { 26 | char buffer[65536]; 27 | JitterBufferPacket in, out; 28 | int i; 29 | 30 | out.data = buffer; 31 | 32 | jitter_buffer_reset(jb); 33 | 34 | for(i=0;i<100;++i) { 35 | synthIn(&in, i, 1); 36 | jitter_buffer_put(jb, &in); 37 | 38 | out.len = 65536; 39 | if (jitter_buffer_get(jb, &out, 10, NULL) != JITTER_BUFFER_OK) { 40 | printf("Fill test failed iteration %d\n", i); 41 | } 42 | if (out.timestamp != i * 10) { 43 | printf("Fill test expected %d got %d\n", i*10, out.timestamp); 44 | } 45 | jitter_buffer_tick(jb); 46 | } 47 | } 48 | 49 | int main() 50 | { 51 | char buffer[65536]; 52 | JitterBufferPacket in, out; 53 | int i; 54 | 55 | JitterBuffer *jb = jitter_buffer_init(10); 56 | 57 | out.data = buffer; 58 | 59 | /* Frozen sender case */ 60 | jitterFill(jb); 61 | for(i=0;i<100;++i) { 62 | out.len = 65536; 63 | jitter_buffer_get(jb, &out, 10, NULL); 64 | jitter_buffer_tick(jb); 65 | } 66 | synthIn(&in, 100, 1); 67 | jitter_buffer_put(jb, &in); 68 | out.len = 65536; 69 | if (jitter_buffer_get(jb, &out, 10, NULL) != JITTER_BUFFER_OK) { 70 | printf("Failed frozen sender resynchronize\n"); 71 | } else { 72 | printf("Frozen sender: Jitter %d\n", out.timestamp - 100*10); 73 | } 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /SpeexDSP.spec.in: -------------------------------------------------------------------------------- 1 | %define name @PACKAGE@ 2 | %define ver @VERSION@ 3 | %define rel 1 4 | 5 | Summary: An open-source, patent-free speech codec 6 | Name: %name 7 | Version: %ver 8 | Release: %rel 9 | License: BSD 10 | Group: Application/Devel 11 | Source: http://www.speex.org/download/%{name}-%{ver}.tar.gz 12 | URL: http://www.speex.org/ 13 | Vendor: Speex 14 | Packager: Jean-Marc Valin (jean-marc.valin@usherbrooke.ca) 15 | BuildRoot: /var/tmp/%{name}-build-root 16 | Docdir: /usr/share/doc 17 | 18 | %description 19 | Speex is a patent-free audio codec designed especially for voice (unlike 20 | Vorbis which targets general audio) signals and providing good narrowband 21 | and wideband quality. This project aims to be complementary to the Vorbis 22 | codec. 23 | 24 | %package devel 25 | Summary: Speex development files 26 | Group: Development/Libraries 27 | Requires: %{name} = %{version} 28 | 29 | %description devel 30 | Speex development files. 31 | 32 | %changelog 33 | * Thu Oct 03 2002 Jean-Marc Valin 34 | - Added devel package inspired from PLD spec file 35 | 36 | * Tue Jul 30 2002 Fredrik Rambris 0.5.2 37 | - Added buildroot and docdir and ldconfig. Makes it builadble by non-roots 38 | and also doesn't write to actual library paths when building. 39 | 40 | %prep 41 | %setup 42 | 43 | %build 44 | export CFLAGS='-O3' 45 | ./configure --prefix=/usr --enable-shared --enable-static 46 | make 47 | 48 | %install 49 | rm -rf $RPM_BUILD_ROOT 50 | make DESTDIR=$RPM_BUILD_ROOT install 51 | 52 | %post -p /sbin/ldconfig 53 | %postun -p /sbin/ldconfig 54 | 55 | %files 56 | %defattr(644,root,root,755) 57 | %doc COPYING AUTHORS ChangeLog NEWS README 58 | %doc doc/manual.pdf 59 | %attr(755,root,root) %{_bindir}/speex* 60 | %attr(755,root,root) %{_libdir}/libspeex*.so* 61 | 62 | %files devel 63 | %defattr(644,root,root,755) 64 | %attr(755,root,root) %{_libdir}/libspeex*.la 65 | %{_includedir}/speex/speex*.h 66 | %{_libdir}/pkgconfig/speexdsp.pc 67 | %{_libdir}/libspeex*.a 68 | -------------------------------------------------------------------------------- /doc/sampleenc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /*The frame size in hardcoded for this sample code but it doesn't have to be*/ 5 | #define FRAME_SIZE 160 6 | int main(int argc, char **argv) 7 | { 8 | char *inFile; 9 | FILE *fin; 10 | short in[FRAME_SIZE]; 11 | float input[FRAME_SIZE]; 12 | char cbits[200]; 13 | int nbBytes; 14 | /*Holds the state of the encoder*/ 15 | void *state; 16 | /*Holds bits so they can be read and written to by the Speex routines*/ 17 | SpeexBits bits; 18 | int i, tmp; 19 | 20 | /*Create a new encoder state in narrowband mode*/ 21 | state = speex_encoder_init(&speex_nb_mode); 22 | 23 | /*Set the quality to 8 (15 kbps)*/ 24 | tmp=8; 25 | speex_encoder_ctl(state, SPEEX_SET_QUALITY, &tmp); 26 | 27 | inFile = argv[1]; 28 | fin = fopen(inFile, "r"); 29 | 30 | /*Initialization of the structure that holds the bits*/ 31 | speex_bits_init(&bits); 32 | while (1) 33 | { 34 | /*Read a 16 bits/sample audio frame*/ 35 | fread(in, sizeof(short), FRAME_SIZE, fin); 36 | if (feof(fin)) 37 | break; 38 | /*Copy the 16 bits values to float so Speex can work on them*/ 39 | for (i=0;i 2 | #include 3 | 4 | /*The frame size in hardcoded for this sample code but it doesn't have to be*/ 5 | #define FRAME_SIZE 160 6 | int main(int argc, char **argv) 7 | { 8 | char *outFile; 9 | FILE *fout; 10 | /*Holds the audio that will be written to file (16 bits per sample)*/ 11 | short out[FRAME_SIZE]; 12 | /*Speex handle samples as float, so we need an array of floats*/ 13 | float output[FRAME_SIZE]; 14 | char cbits[200]; 15 | int nbBytes; 16 | /*Holds the state of the decoder*/ 17 | void *state; 18 | /*Holds bits so they can be read and written to by the Speex routines*/ 19 | SpeexBits bits; 20 | int i, tmp; 21 | 22 | /*Create a new decoder state in narrowband mode*/ 23 | state = speex_decoder_init(&speex_nb_mode); 24 | 25 | /*Set the perceptual enhancement on*/ 26 | tmp=1; 27 | speex_decoder_ctl(state, SPEEX_SET_ENH, &tmp); 28 | 29 | outFile = argv[1]; 30 | fout = fopen(outFile, "w"); 31 | 32 | /*Initialization of the structure that holds the bits*/ 33 | speex_bits_init(&bits); 34 | while (1) 35 | { 36 | /*Read the size encoded by sampleenc, this part will likely be 37 | different in your application*/ 38 | fread(&nbBytes, sizeof(int), 1, stdin); 39 | fprintf (stderr, "nbBytes: %d\n", nbBytes); 40 | if (feof(stdin)) 41 | break; 42 | 43 | /*Read the "packet" encoded by sampleenc*/ 44 | fread(cbits, 1, nbBytes, stdin); 45 | /*Copy the data into the bit-stream struct*/ 46 | speex_bits_read_from(&bits, cbits, nbBytes); 47 | 48 | /*Decode the data*/ 49 | speex_decode(state, &bits, output); 50 | 51 | /*Copy from float to short (16 bits) for output*/ 52 | for (i=0;i N/2 27 | b = b-N; 28 | end 29 | printf ("Far end to near end delay is %d samples\n", b); 30 | if (b > .3*tail_length) 31 | printf ('This is too much delay, try delaying the far-end signal a bit\n'); 32 | else if (b < 0) 33 | printf ('You have a negative delay, the echo canceller has no chance to cancel anything!\n'); 34 | else 35 | printf ('Delay looks OK.\n'); 36 | end 37 | end 38 | end 39 | N2 = round(N/2); 40 | corr1 = real(ifft(fft(rec(1:N2)).*conj(fft(play(1:N2))))); 41 | corr2 = real(ifft(fft(rec(N2+1:end)).*conj(fft(play(N2+1:end))))); 42 | 43 | [a,b1] = max(corr1); 44 | if b1 > N2/2 45 | b1 = b1-N2; 46 | end 47 | [a,b2] = max(corr2); 48 | if b2 > N2/2 49 | b2 = b2-N2; 50 | end 51 | drift = (b1-b2)/N2; 52 | printf ('Drift estimate is %f%% (%d samples)\n', 100*drift, b1-b2); 53 | if abs(b1-b2) < 10 54 | printf ('A drift of a few (+-10) samples is normal.\n'); 55 | else 56 | if abs(b1-b2) < 30 57 | printf ('There may be (not sure) excessive clock drift. Is the capture and playback done on the same soundcard?\n'); 58 | else 59 | printf ('Your clock is drifting! No way the AEC will be able to do anything with that. Most likely, you''re doing capture and playback from two different cards.\n'); 60 | end 61 | end 62 | end 63 | acorr(1) = .001+1.00001*acorr(1); 64 | AtA = toeplitz(acorr(1:tail_length)); 65 | bb = corr(1:tail_length); 66 | h = AtA\bb; 67 | 68 | out = (rec - filter(h, 1, play)); 69 | 70 | F=fopen(out_file,'w'); 71 | fwrite(F,out,'short'); 72 | fclose (F); 73 | -------------------------------------------------------------------------------- /libspeexdsp/misc_bfin.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Analog Devices */ 2 | /** 3 | @file misc_bfin.h 4 | @author Jean-Marc Valin 5 | @brief Various compatibility routines for Speex (Blackfin version) 6 | */ 7 | /* 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | - Neither the name of the Xiph.org Foundation nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include "bfin.h" 37 | 38 | #define OVERRIDE_SPEEX_MOVE 39 | void *speex_move (void *dest, void *src, int n) 40 | { 41 | __asm__ __volatile__ 42 | ( 43 | "L0 = 0;\n\t" 44 | "I0 = %0;\n\t" 45 | "R0 = [I0++];\n\t" 46 | "LOOP move%= LC0 = %2;\n\t" 47 | "LOOP_BEGIN move%=;\n\t" 48 | "[%1++] = R0 || R0 = [I0++];\n\t" 49 | "LOOP_END move%=;\n\t" 50 | "[%1++] = R0;\n\t" 51 | : "=a" (src), "=a" (dest) 52 | : "a" ((n>>2)-1), "0" (src), "1" (dest) 53 | : "R0", "I0", "L0", "memory" BFIN_HWLOOP0_REGS 54 | ); 55 | return dest; 56 | } 57 | -------------------------------------------------------------------------------- /include/speex/speex_buffer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Jean-Marc Valin 2 | 3 | File: speex_buffer.h 4 | This is a very simple ring buffer implementation. It is not thread-safe 5 | so you need to do your own locking. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | 3. The name of the author may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef SPEEX_BUFFER_H 35 | #define SPEEX_BUFFER_H 36 | 37 | #include "speexdsp_types.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | struct SpeexBuffer_; 44 | typedef struct SpeexBuffer_ SpeexBuffer; 45 | 46 | SpeexBuffer *speex_buffer_init(int size); 47 | 48 | void speex_buffer_destroy(SpeexBuffer *st); 49 | 50 | int speex_buffer_write(SpeexBuffer *st, void *data, int len); 51 | 52 | int speex_buffer_writezeros(SpeexBuffer *st, int len); 53 | 54 | int speex_buffer_read(SpeexBuffer *st, void *data, int len); 55 | 56 | int speex_buffer_get_available(SpeexBuffer *st); 57 | 58 | int speex_buffer_resize(SpeexBuffer *st, int len); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /libspeexdsp/fftwrap.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Jean-Marc Valin 2 | File: fftwrap.h 3 | 4 | Wrapper for various FFTs 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of the Xiph.org Foundation nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | #ifndef FFTWRAP_H 36 | #define FFTWRAP_H 37 | 38 | #include "arch.h" 39 | 40 | /** Compute tables for an FFT */ 41 | void *spx_fft_init(int size); 42 | 43 | /** Destroy tables for an FFT */ 44 | void spx_fft_destroy(void *table); 45 | 46 | /** Forward (real to half-complex) transform */ 47 | void spx_fft(void *table, spx_word16_t *in, spx_word16_t *out); 48 | 49 | /** Backward (half-complex to real) transform */ 50 | void spx_ifft(void *table, spx_word16_t *in, spx_word16_t *out); 51 | 52 | /** Forward (real to half-complex) transform of float data */ 53 | void spx_fft_float(void *table, float *in, float *out); 54 | 55 | /** Backward (half-complex to real) transform of float data */ 56 | void spx_ifft_float(void *table, float *in, float *out); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /ti/speex_C64_test/speex_C64_test.cmd: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Psi Systems, Inc. 2 | File: speex_C64_test.cmd 3 | Linker command file with memory allocation for TI TMS320C6415 processor 4 | for use with TI Code Composer (TM) DSP development tools. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of the Xiph.org Foundation nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | -stack 0x10000 35 | -heap 0x10000 36 | 37 | 38 | MEMORY 39 | { 40 | VECRAM : origin = 0x0, len = 0x200 41 | IPRAM : origin = 0x200, len = 0x40000 42 | IDRAM : origin = 0x80000, len = 0x70000 43 | } 44 | 45 | SECTIONS 46 | { 47 | .vectors > VECRAM 48 | .text > IPRAM 49 | 50 | .bss > IDRAM 51 | .cinit > IDRAM 52 | .const > IDRAM 53 | .far > IDRAM 54 | .stack > IDRAM 55 | .cio > IDRAM 56 | .sysmem > IDRAM 57 | .switch > IDRAM 58 | .myheap > IDRAM 59 | } 60 | -------------------------------------------------------------------------------- /libspeexdsp/filterbank.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2006 Jean-Marc Valin */ 2 | /** 3 | @file filterbank.h 4 | @brief Converting between psd and filterbank 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | 3. The name of the author may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef FILTERBANK_H 35 | #define FILTERBANK_H 36 | 37 | #include "arch.h" 38 | 39 | typedef struct { 40 | int *bank_left; 41 | int *bank_right; 42 | spx_word16_t *filter_left; 43 | spx_word16_t *filter_right; 44 | #ifndef FIXED_POINT 45 | float *scaling; 46 | #endif 47 | int nb_banks; 48 | int len; 49 | } FilterBank; 50 | 51 | 52 | FilterBank *filterbank_new(int banks, spx_word32_t sampling, int len, int type); 53 | 54 | void filterbank_destroy(FilterBank *bank); 55 | 56 | void filterbank_compute_bank32(FilterBank *bank, spx_word32_t *ps, spx_word32_t *mel); 57 | 58 | void filterbank_compute_psd16(FilterBank *bank, spx_word16_t *mel, spx_word16_t *psd); 59 | 60 | #ifndef FIXED_POINT 61 | void filterbank_compute_bank(FilterBank *bank, float *psd, float *mel); 62 | void filterbank_compute_psd(FilterBank *bank, float *mel, float *psd); 63 | #endif 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /symbian/bld.inf: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 Commonwealth Scientific and Industrial Research 3 | Organisation (CSIRO) Australia 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | - Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | - Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | - Neither the name of CSIRO Australia nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR 24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | PRJ_EXPORTS 34 | 35 | ..\include\speex\speex_bits.h \epoc32\include\speex\speex_bits.h 36 | ..\include\speex\speex_callbacks.h \epoc32\include\speex\speex_callbacks.h 37 | ..\include\speex\speex_config_types.h \epoc32\include\speex\speex_config_types.h 38 | ..\include\speex\speex_echo.h \epoc32\include\speex\speex_echo.h 39 | ..\include\speex\speex.h \epoc32\include\speex\speex.h 40 | ..\include\speex\speex_header.h \epoc32\include\speex\speex_header.h 41 | ..\include\speex\speex_jitter.h \epoc32\include\speex\speex_jitter.h 42 | ..\include\speex\speex_preprocess.h \epoc32\include\speex\speex_preprocess.h 43 | ..\include\speex\speex_stereo.h \epoc32\include\speex\speex_stereo.h 44 | ..\include\speex\speex_types.h \epoc32\include\speex\speex_types.h 45 | 46 | 47 | PRJ_MMPFILES 48 | 49 | speex.mmp 50 | -------------------------------------------------------------------------------- /symbian/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 Commonwealth Scientific and Industrial Research 3 | Organisation (CSIRO) Australia 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | - Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | - Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | - Neither the name of CSIRO Australia nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 23 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR 24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef CONFIG_H 34 | #define CONFIG_H 35 | 36 | /* An inline macro is required for use of the inline keyword as not all C compilers support */ 37 | /* inline. It is officially C99 and C++ only */ 38 | 39 | #ifdef __WINS__ 40 | 41 | #define inline __inline 42 | 43 | /* Disable some pointless/stupid warnings */ 44 | 45 | #pragma warning(disable: 4100) /* unreferenced formal parameter */ 46 | #pragma warning(disable: 4127) /* conditional expression is constant */ 47 | #pragma warning(disable: 4305) /* truncation from '...' to '...' */ 48 | #pragma warning(disable: 4244) /* conversion from '...' to '...', possible loss of data */ 49 | #pragma warning(disable: 4701) /* local variable may be be used without having been initialized */ 50 | 51 | #endif /* ! __WINS__ */ 52 | 53 | /* Use only fixed point arithmetic */ 54 | 55 | #define FIXED_POINT 1 56 | 57 | #endif /* ! CONFIG_H */ 58 | -------------------------------------------------------------------------------- /ti/speex_C55_test/speex_C55_test.cmd: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Psi Systems, Inc. 2 | File: speex_C55_test.cmd 3 | Linker command file with memory allocation for TI TMS320VC5509A processor 4 | for use with TI Code Composer (TM) DSP development tools. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of the Xiph.org Foundation nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | -c 35 | -stack 0x1c00 36 | -heap 0x1000 /* If private memory allocation is used for Speex */ 37 | /*-heap 0x6000 / * If calloc is used for Speex */ 38 | -sysstack 0x200 39 | -lrts55.lib 40 | 41 | MEMORY 42 | { 43 | DARAM: origin = 0x200, len = 0x7e00 44 | DARAM_B: origin = 0x8000, len = 0x8000 45 | VECT: origin = 0x100, len = 0x100 46 | SARAM_A: origin = 0x10000, len = 0x10000 47 | SARAM_B: origin = 0x20000, len = 0x20000 48 | } 49 | 50 | SECTIONS 51 | { 52 | .vectors: {} > VECT 53 | .bootmem: {} > DARAM 54 | .text: {} > SARAM_B 55 | .cinit: {} > SARAM_B 56 | .switch: {} > SARAM_B 57 | .bss: {} > DARAM 58 | /* .far: {} > DARAM*/ 59 | .const: {} > DARAM 60 | .sysmem: {} > DARAM_B 61 | .cio: {} > DARAM 62 | .stack: {} > DARAM 63 | .sysstack: {} > DARAM 64 | .myheap: {} > SARAM_A 65 | } 66 | -------------------------------------------------------------------------------- /tmv/misc_tm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Hong Zhiqian */ 2 | /** 3 | @file misc_tm.h 4 | @author Hong Zhiqian 5 | @brief Various compatibility routines for Speex (TriMedia version) 6 | */ 7 | /* 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | - Neither the name of the Xiph.org Foundation nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | #include 36 | 37 | 38 | #if TM_PROFILE 39 | int __profile_begin; 40 | int __profile_end; 41 | #endif 42 | 43 | #define OVERRIDE_SPEEX_ALLOC 44 | void *speex_alloc (int size) 45 | { 46 | void *ptr; 47 | 48 | if ( tmmlMalloc(0, size, (pVoid*)&ptr, tmmlMallocCacheAligned | tmmlMallocCleared) != TM_OK ) 49 | { return NULL; 50 | } 51 | 52 | return ptr; 53 | } 54 | 55 | 56 | #define OVERRIDE_SPEEX_ALLOC_SCRATCH 57 | void *speex_alloc_scratch (int size) 58 | { 59 | void *ptr; 60 | 61 | if ( tmmlMalloc(0, size, (pVoid*)&ptr, tmmlMallocCacheAligned | tmmlMallocCleared) != TM_OK ) 62 | { return NULL; 63 | } 64 | 65 | return ptr; 66 | } 67 | 68 | 69 | #define OVERRIDE_SPEEX_REALLOC 70 | void *speex_realloc (void *ptr, int size) 71 | { 72 | if ( tmmlRealloc(0, size, (pVoid)ptr, (pVoid*)&ptr, tmmlMallocCacheAligned | tmmlMallocCleared) != TM_OK ) 73 | { return NULL; 74 | } 75 | 76 | return ptr; 77 | } 78 | 79 | 80 | #define OVERRIDE_SPEEX_FREE 81 | void speex_free (void *ptr) 82 | { 83 | tmmlFree(ptr); 84 | } 85 | 86 | 87 | #define OVERRIDE_SPEEX_FREE_SCRATCH 88 | void speex_free_scratch (void *ptr) 89 | { 90 | tmmlFree(ptr); 91 | } 92 | 93 | -------------------------------------------------------------------------------- /libspeexdsp/testresample.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Jean-Marc Valin 2 | 3 | File: testresample.c 4 | Testing the resampling code 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | 3. The name of the author may not be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 24 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 29 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | #ifdef HAVE_CONFIG_H 34 | #include "config.h" 35 | #endif 36 | 37 | #include "speex/speex_resampler.h" 38 | #include 39 | #include 40 | #include 41 | 42 | #define NN 256 43 | 44 | int main() 45 | { 46 | spx_uint32_t i; 47 | short *in; 48 | short *out; 49 | float *fin, *fout; 50 | int count = 0; 51 | SpeexResamplerState *st = speex_resampler_init(1, 8000, 12000, 10, NULL); 52 | speex_resampler_set_rate(st, 96000, 44100); 53 | speex_resampler_skip_zeros(st); 54 | 55 | in = malloc(NN*sizeof(short)); 56 | out = malloc(2*NN*sizeof(short)); 57 | fin = malloc(NN*sizeof(float)); 58 | fout = malloc(2*NN*sizeof(float)); 59 | while (1) 60 | { 61 | spx_uint32_t in_len; 62 | spx_uint32_t out_len; 63 | fread(in, sizeof(short), NN, stdin); 64 | if (feof(stdin)) 65 | break; 66 | for (i=0;i 39 | #include 40 | #include 41 | 42 | #define PERIOD 32 43 | #define INBLOCK 1024 44 | #define RATE 48000 45 | 46 | int main() 47 | { 48 | spx_uint32_t i; 49 | float *fin, *fout; 50 | int rate = 1000, off = 0, avail = INBLOCK; 51 | SpeexResamplerState *st = speex_resampler_init(1, RATE, RATE, 4, NULL); 52 | speex_resampler_set_rate(st, RATE, rate); 53 | speex_resampler_skip_zeros(st); 54 | 55 | fin = malloc(INBLOCK*2*sizeof(float)); 56 | for (i=0; i ", rate, off, in_len, out_len); 70 | 71 | speex_resampler_process_float(st, 0, fin + off, &in_len, fout, &out_len); 72 | 73 | fprintf (stderr, "%d %d\n", in_len, out_len); 74 | off += in_len; 75 | avail = avail - in_len + INBLOCK; 76 | 77 | if (off >= INBLOCK) 78 | off -= INBLOCK; 79 | 80 | fwrite(fout, sizeof(float), out_len, stdout); 81 | 82 | rate += 100; 83 | if (rate > 128000) 84 | break; 85 | 86 | speex_resampler_set_rate(st, RATE, rate); 87 | } 88 | speex_resampler_destroy(st); 89 | free(fin); 90 | free(fout); 91 | return 0; 92 | } 93 | 94 | -------------------------------------------------------------------------------- /libspeexdsp/kiss_fft.h: -------------------------------------------------------------------------------- 1 | #ifndef KISS_FFT_H 2 | #define KISS_FFT_H 3 | 4 | #include 5 | #include 6 | #include "arch.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | /* 13 | ATTENTION! 14 | If you would like a : 15 | -- a utility that will handle the caching of fft objects 16 | -- real-only (no imaginary time component ) FFT 17 | -- a multi-dimensional FFT 18 | -- a command-line utility to perform ffts 19 | -- a command-line utility to perform fast-convolution filtering 20 | 21 | Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c 22 | in the tools/ directory. 23 | */ 24 | 25 | #ifdef USE_SIMD 26 | # include 27 | # define kiss_fft_scalar __m128 28 | #define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes) 29 | #else 30 | #define KISS_FFT_MALLOC speex_alloc 31 | #endif 32 | 33 | 34 | #ifdef FIXED_POINT 35 | #include "arch.h" 36 | # define kiss_fft_scalar spx_int16_t 37 | #else 38 | # ifndef kiss_fft_scalar 39 | /* default is float */ 40 | # define kiss_fft_scalar float 41 | # endif 42 | #endif 43 | 44 | typedef struct { 45 | kiss_fft_scalar r; 46 | kiss_fft_scalar i; 47 | }kiss_fft_cpx; 48 | 49 | typedef struct kiss_fft_state* kiss_fft_cfg; 50 | 51 | /* 52 | * kiss_fft_alloc 53 | * 54 | * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. 55 | * 56 | * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); 57 | * 58 | * The return value from fft_alloc is a cfg buffer used internally 59 | * by the fft routine or NULL. 60 | * 61 | * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc. 62 | * The returned value should be free()d when done to avoid memory leaks. 63 | * 64 | * The state can be placed in a user supplied buffer 'mem': 65 | * If lenmem is not NULL and mem is not NULL and *lenmem is large enough, 66 | * then the function places the cfg in mem and the size used in *lenmem 67 | * and returns mem. 68 | * 69 | * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough), 70 | * then the function returns NULL and places the minimum cfg 71 | * buffer size in *lenmem. 72 | * */ 73 | 74 | kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); 75 | 76 | /* 77 | * kiss_fft(cfg,in_out_buf) 78 | * 79 | * Perform an FFT on a complex input buffer. 80 | * for a forward FFT, 81 | * fin should be f[0] , f[1] , ... ,f[nfft-1] 82 | * fout will be F[0] , F[1] , ... ,F[nfft-1] 83 | * Note that each element is complex and can be accessed like 84 | f[k].r and f[k].i 85 | * */ 86 | void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); 87 | 88 | /* 89 | A more generic version of the above function. It reads its input from every Nth sample. 90 | * */ 91 | void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride); 92 | 93 | /* If kiss_fft_alloc allocated a buffer, it is one contiguous 94 | buffer and can be simply free()d when no longer needed*/ 95 | #define kiss_fft_free speex_free 96 | 97 | /* 98 | Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up 99 | your compiler output to call this before you exit. 100 | */ 101 | void kiss_fft_cleanup(void); 102 | 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /ti/speex_C54_test/speex_C54_test.cmd: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Psi Systems, Inc. 2 | File: speex_C54_test.cmd 3 | Linker command file with memory allocation for TI TMS320VC5416 processor 4 | for use with TI Code Composer (TM) DSP development tools. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of the Xiph.org Foundation nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | -c 35 | -stack 0x2000 36 | -heap 0x1000 /* If private memory allocation is used for Speex */ 37 | /*-heap 0x6000 /* If calloc is used for Speex */ 38 | -lrts_ext.lib 39 | 40 | MEMORY 41 | { 42 | /* PAGE 0: P_DARAM03: origin = 0x80, len = 0x7f00*/ 43 | PAGE 0: P_DARAM03: origin = 0x5000, len = 0x2f80 44 | PAGE 0: VECT: origin = 0x7f80, len = 0x80 45 | PAGE 0: P_DARAM47: origin = 0x18000, len = 0x8000 46 | PAGE 0: SARAM03: origin = 0x28000, len = 0x8000 47 | PAGE 0: SARAM47: origin = 0x38000, len = 0x8000 48 | 49 | PAGE 1: USERREGS: origin = 0x60, len = 0x1a 50 | PAGE 1: BIOSREGS: origin = 0x7c, len = 0x4 51 | PAGE 1: CSLREGS: origin = 0x7a, len = 0x2 52 | D_DARAM03: origin = 0x80, len = 0x4f80 53 | D_DARAM47: origin = 0x8000, len = 0x8000 54 | } 55 | 56 | SECTIONS 57 | { 58 | .vectors: {} > VECT PAGE 0 59 | .bootmem: {rts_ext.lib (.text)} > P_DARAM03 PAGE 0 60 | /* .bootmem: {} > P_DARAM03 PAGE 0 */ 61 | .text: {} > SARAM03 PAGE 0 62 | .cinit: {} > SARAM03 PAGE 0 63 | .switch: {} > SARAM03 PAGE 0 64 | .bss: {} > D_DARAM03 | D_DARAM47 PAGE 1 65 | .far: {} > D_DARAM03 | D_DARAM47 PAGE 1 66 | .const: {} > D_DARAM03 | D_DARAM47 PAGE 1 67 | .sysmem: {} > D_DARAM47 PAGE 1 68 | .cio: {} > D_DARAM03 | D_DARAM47 PAGE 1 69 | .stack: {} > D_DARAM03 | D_DARAM47 PAGE 1 70 | .myheap: {} > D_DARAM47 PAGE 1 71 | } 72 | -------------------------------------------------------------------------------- /ti/config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Psi Systems, Inc. 2 | File: config.h 3 | Main Speex option include file for TI C64xx, C54xx and C55xx processors 4 | for use with TI Code Composer (TM) DSP development tools. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of the Xiph.org Foundation nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #define FIXED_POINT 35 | #define FRAME_SIZE 160 36 | #define DISABLE_WIDEBAND 37 | #define EXPORT 38 | 39 | /* Disable DC block if doing SNR testing */ 40 | #define DISABLE_HIGHPASS 41 | 42 | /* Allow for 2 20ms narrowband blocks per frame, plus a couple of bytes */ 43 | #define MAX_CHARS_PER_FRAME (42/BYTES_PER_CHAR) 44 | 45 | /* for debug */ 46 | #undef DECODE_ONLY 47 | #define VERBOSE_ALLOC 48 | 49 | /* EITHER Allocate from fixed array (C heap not used) */ 50 | /* Enable VERBOSE_ALLOC to see how much is used */ 51 | #define MANUAL_ALLOC 52 | #define OS_SUPPORT_CUSTOM 53 | 54 | /* OR Use CALLOC (heap size must be increased in linker command file) */ 55 | //#undef MANUAL_ALLOC 56 | //#undef OS_SUPPORT_CUSTOM 57 | 58 | #if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) 59 | //#define PRECISION16 60 | 61 | // These values determined by analysis for 8kbps narrowband 62 | #define SPEEXENC_PERSIST_STACK_SIZE 1000 63 | #define SPEEXENC_SCRATCH_STACK_SIZE 3000 64 | #define SPEEXDEC_PERSIST_STACK_SIZE 1000 65 | #define SPEEXDEC_SCRATCH_STACK_SIZE 1000 66 | #else /* C6X */ 67 | #define NO_LONGLONG 68 | 69 | #define SPEEXENC_PERSIST_STACK_SIZE 2000 70 | #define SPEEXENC_SCRATCH_STACK_SIZE 6000 71 | #define SPEEXDEC_PERSIST_STACK_SIZE 2000 72 | #define SPEEXDEC_SCRATCH_STACK_SIZE 2000 73 | #endif 74 | #define SPEEX_PERSIST_STACK_SIZE (SPEEXENC_PERSIST_STACK_SIZE + SPEEXDEC_PERSIST_STACK_SIZE) 75 | #define SPEEX_SCRATCH_STACK_SIZE SPEEXENC_SCRATCH_STACK_SIZE 76 | #define NB_ENC_STACK SPEEXENC_SCRATCH_STACK_SIZE 77 | #define NB_DEC_STACK SPEEXDEC_SCRATCH_STACK_SIZE 78 | 79 | -------------------------------------------------------------------------------- /tmv/fixed_tm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Hong Zhiqian */ 2 | /** 3 | @file fixed_tm.h 4 | @author Hong Zhiqian 5 | @brief Various compatibility routines for Speex (TriMedia version) 6 | */ 7 | /* 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | - Neither the name of the Xiph.org Foundation nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | #ifndef FIXED_TM_H 36 | #define FIXED_TM_H 37 | 38 | #include 39 | 40 | 41 | #undef SATURATE 42 | #undef SATURATE16 43 | #undef SATURATE32 44 | #define SATURATE(x,a) iclipi(x,a) 45 | #define SATURATE16(x,a) iclipi(x,a) 46 | #define SATURATE32(x,a) iclipi(x,a) 47 | 48 | #undef EXTEND32 49 | #define EXTEND32(x) sex16(x) 50 | 51 | #undef NEG16 52 | #undef NEG32 53 | #define NEG16(x) ineg((int)(x)) 54 | #define NEG32(x) ineg(x) 55 | 56 | #undef ABS 57 | #undef ABS16 58 | #undef ABS32 59 | #define ABS(x) iabs(x) 60 | #define ABS32(x) iabs(x) 61 | #define ABS16(x) iabs((int)(x)) 62 | 63 | #undef MIN16 64 | #undef MIN32 65 | #define MIN16(a,b) imin((int)(a),(int)(b)) 66 | #define MIN32(a,b) imin(a,b) 67 | 68 | #undef MAX16 69 | #undef MAX32 70 | #define MAX16(a,b) imax((int)(a),(int)(b)) 71 | #define MAX32(a,b) imax(a,b) 72 | 73 | #undef ADD16 74 | #undef SUB16 75 | #undef ADD32 76 | #undef SUB32 77 | #undef MULT16_16 78 | #undef MULT16_16_16 79 | 80 | #define ADD16(a,b) ((int)(a) + (int)(b)) 81 | #define SUB16(a,b) ((int)(a) - (int)(b)) 82 | #define ADD32(a,b) ((int)(a) + (int)(b)) 83 | #define SUB32(a,b) ((int)(a) - (int)(b)) 84 | #define MULT16_16_16(a,b) ((int)(a) * (int)(b)) 85 | #define MULT16_16(a,b) ((int)(a) * (int)(b)) 86 | 87 | #if TM_DEBUGMEM_ALIGNNMENT 88 | #include 89 | #define TMDEBUG_ALIGNMEM(x) \ 90 | { if( ((int)(x) & (int)(0x00000003)) != 0 ) \ 91 | { printf("memory not align. file: %s, line: %d\n", __FILE__, __LINE__); \ 92 | } \ 93 | } 94 | 95 | #else 96 | #define TMDEBUG_ALIGNMEM(x) 97 | #endif 98 | 99 | #endif 100 | 101 | -------------------------------------------------------------------------------- /libspeexdsp/vorbis_psy.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Jean-Marc Valin, CSIRO, Christopher Montgomery 2 | File: vorbis_psy.h 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | - Neither the name of the Xiph.org Foundation nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef VORBIS_PSY_H 33 | #define VORBIS_PSY_H 34 | 35 | #ifdef VORBIS_PSYCHO 36 | 37 | #include "smallft.h" 38 | #define P_BANDS 17 /* 62Hz to 16kHz */ 39 | #define NOISE_COMPAND_LEVELS 40 40 | 41 | 42 | #define todB(x) ((x)>1e-13?log((x)*(x))*4.34294480f:-30) 43 | #define fromdB(x) (exp((x)*.11512925f)) 44 | 45 | /* The bark scale equations are approximations, since the original 46 | table was somewhat hand rolled. The below are chosen to have the 47 | best possible fit to the rolled tables, thus their somewhat odd 48 | appearance (these are more accurate and over a longer range than 49 | the oft-quoted bark equations found in the texts I have). The 50 | approximations are valid from 0 - 30kHz (nyquist) or so. 51 | 52 | all f in Hz, z in Bark */ 53 | 54 | #define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) 55 | #define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f) 56 | 57 | /* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave 58 | 0.0 */ 59 | 60 | #define toOC(n) (log(n)*1.442695f-5.965784f) 61 | #define fromOC(o) (exp(((o)+5.965784f)*.693147f)) 62 | 63 | 64 | typedef struct { 65 | 66 | float noisewindowlo; 67 | float noisewindowhi; 68 | int noisewindowlomin; 69 | int noisewindowhimin; 70 | int noisewindowfixed; 71 | float noiseoff[P_BANDS]; 72 | float noisecompand[NOISE_COMPAND_LEVELS]; 73 | 74 | } VorbisPsyInfo; 75 | 76 | 77 | 78 | typedef struct { 79 | int n; 80 | int rate; 81 | struct drft_lookup lookup; 82 | VorbisPsyInfo *vi; 83 | 84 | float *window; 85 | float *noiseoffset; 86 | long *bark; 87 | 88 | } VorbisPsy; 89 | 90 | 91 | VorbisPsy *vorbis_psy_init(int rate, int size); 92 | void vorbis_psy_destroy(VorbisPsy *psy); 93 | void compute_curve(VorbisPsy *psy, float *audio, float *curve); 94 | void curve_to_lpc(VorbisPsy *psy, float *curve, float *awk1, float *awk2, int ord); 95 | 96 | #endif 97 | #endif 98 | -------------------------------------------------------------------------------- /tmv/config.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONFIG_H_ 2 | #define _CONFIG_H_ 3 | 4 | #define USE_COMPACT_KISS_FFT 5 | //#define USE_KISS_FFT 6 | 7 | #ifdef WIN32 8 | 9 | //#define FIXED_POINT 10 | 11 | #define inline __inline 12 | #define restrict 13 | 14 | #elif defined (__TCS__) 15 | 16 | #define FIXED_POINT 17 | #define PREPROCESS_MDF_FLOAT 18 | #define TM_ASM 19 | 20 | #define TM_DEBUGMEM_ALIGNNMENT 1 21 | 22 | #define TM_PROFILE 1 23 | #define TM_PROFILE_FIRMEM16 0 24 | #define TM_PROFILE_IIRMEM16 0 25 | #define TM_PROFILE_FILTERMEM16 0 26 | #define TM_PROFILE_VQNBEST 0 27 | #define TM_PROFILE_VQNBESTSIGN 0 28 | #define TM_PROFILE_COMPUTEQUANTWEIGHTS 0 29 | #define TM_PROFILE_LSPQUANT 0 30 | #define TM_PROFILE_LSPWEIGHTQUANT 0 31 | #define TM_PROFILE_LSPENFORCEMARGIN 0 32 | #define TM_PROFILE_LSPTOLPC 0 33 | #define TM_PROFILE_INNERPROD 0 34 | #define TM_PROFILE_PITCHXCORR 0 35 | #define TM_PROFILE_LSP_INTERPOLATE 0 36 | #define TM_PROFILE_CHEBPOLYEVA 0 37 | #define TM_PROFILE_COMPUTEWEIGHTEDCODEBOOK 0 38 | #define TM_PROFILE_TARGETUPDATE 0 39 | #define TM_PROFILE_SPXAUTOCORR 0 40 | #define TM_PROFILE_COMPUTEPITCHERROR 0 41 | #define TM_PROFILE_COMPUTERMS16 0 42 | #define TM_PROFILE_NORMALIZE16 0 43 | #define TM_PROFILE_BWLPC 0 44 | #define TM_PROFILE_HIGHPASS 0 45 | #define TM_PROFILE_SIGNALMUL 0 46 | #define TM_PROFILE_SIGNALDIV 0 47 | #define TM_PROFILE_COMPUTEIMPULSERESPONSE 0 48 | #define TM_PROFILE_PITCHGAINSEARCH3TAPVQ 0 49 | #define TM_PROFILE_OPENLOOPNBESTPITCH 0 50 | #define TM_PROFILE_PREPROCESSANALYSIS 0 51 | #define TM_PROFILE_UPDATENOISEPROB 0 52 | #define TM_PROFILE_COMPUTEGAINFLOOR 0 53 | #define TM_PROFILE_FILTERDCNOTCH16 0 54 | #define TM_PROFILE_MDFINNERPROD 0 55 | #define TM_PROFILE_SPECTRALMULACCUM 0 56 | #define TM_PROFILE_WEIGHTEDSPECTRALMULCONJ 0 57 | #define TM_PROFILE_MDFADJUSTPROP 0 58 | #define TM_PROFILE_SPEEXECHOGETRESIDUAL 0 59 | #define TM_PROFILE_MAXIMIZERANGE 0 60 | #define TM_PROFILE_RENORMRANGE 0 61 | #define TM_PROFILE_POWERSPECTRUM 0 62 | #define TM_PROFILE_QMFSYNTH 0 63 | #define TM_PROFILE_QMFDECOMP 0 64 | #define TM_PROFILE_FILTERBANKCOMPUTEBANK32 0 65 | #define TM_PROFILE_FILTERBANKCOMPUTEPSD16 0 66 | 67 | #define TM_UNROLL 1 68 | #define TM_UNROLL_FILTER 1 69 | #define TM_UNROLL_IIR 1 70 | #define TM_UNROLL_FIR 1 71 | #define TM_UNROLL_HIGHPASS 1 72 | #define TM_UNROLL_SIGNALMUL 1 73 | #define TM_UNROLL_SIGNALDIV 1 74 | #define TM_UNROLL_VQNBEST 1 75 | #define TM_UNROLL_VQSIGNNBEST 1 76 | #define TM_UNROLL__SPXAUTOCORR 1 77 | #define TM_UNROLL_COMPUTERMS16 1 78 | #define TM_UNROLL_COMPUTEIMPULSERESPONSE 1 79 | #define TM_UNROLL_QMFSYNTH 1 80 | #define TM_UNROLL_PITCHGAINSEARCH3TAPVQ 1 81 | #define TM_UNROLL_OPENLOOPNBESTPITCH 1 82 | #define TM_UNROLL_FILTERBANKCOMPUTEBANK32 1 83 | #define TM_UNROLL_FILTERBANKCOMPUTEPSD16 1 84 | #define TM_UNROLL_SPEEXPREPROCESSRUN 1 85 | #define TM_UNROLL_PREPROCESSANALYSIS 1 86 | #define TM_UNROLL_UPDATENOISEPROB 1 87 | #define TM_UNROLL_COMPUTEGAINFLOOR 1 88 | #define TM_UNROLL_SPEEXECHOGETRESIDUAL 1 89 | #define TM_UNROLL_SPEEXECHOCANCELLATION 1 90 | #define TM_UNROLL_FILTERDCNOTCH16 1 91 | #define TM_UNROLL_MDFINNERPRODUCT 1 92 | #define TM_UNROLL_SPECTRALMULACCUM 1 93 | #define TM_UNROLL_MDFADJUSTPROP 1 94 | 95 | #endif 96 | 97 | #endif 98 | 99 | -------------------------------------------------------------------------------- /libspeexdsp/stack_alloc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002 Jean-Marc Valin */ 2 | /** 3 | @file stack_alloc.h 4 | @brief Temporary memory allocation on stack 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef STACK_ALLOC_H 36 | #define STACK_ALLOC_H 37 | 38 | #ifdef USE_ALLOCA 39 | # ifdef WIN32 40 | # include 41 | # else 42 | # ifdef HAVE_ALLOCA_H 43 | # include 44 | # else 45 | # include 46 | # endif 47 | # endif 48 | #endif 49 | 50 | /** 51 | * @def ALIGN(stack, size) 52 | * 53 | * Aligns the stack to a 'size' boundary 54 | * 55 | * @param stack Stack 56 | * @param size New size boundary 57 | */ 58 | 59 | /** 60 | * @def PUSH(stack, size, type) 61 | * 62 | * Allocates 'size' elements of type 'type' on the stack 63 | * 64 | * @param stack Stack 65 | * @param size Number of elements 66 | * @param type Type of element 67 | */ 68 | 69 | /** 70 | * @def VARDECL(var) 71 | * 72 | * Declare variable on stack 73 | * 74 | * @param var Variable to declare 75 | */ 76 | 77 | /** 78 | * @def ALLOC(var, size, type) 79 | * 80 | * Allocate 'size' elements of 'type' on stack 81 | * 82 | * @param var Name of variable to allocate 83 | * @param size Number of elements 84 | * @param type Type of element 85 | */ 86 | 87 | #ifdef ENABLE_VALGRIND 88 | 89 | #include 90 | 91 | #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) 92 | 93 | #define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type))),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) 94 | 95 | #else 96 | 97 | #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) 98 | 99 | #define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) 100 | 101 | #endif 102 | 103 | #if defined(VAR_ARRAYS) 104 | #define VARDECL(var) 105 | #define ALLOC(var, size, type) type var[size] 106 | #elif defined(USE_ALLOCA) 107 | #define VARDECL(var) var 108 | #define ALLOC(var, size, type) var = alloca(sizeof(type)*(size)) 109 | #else 110 | #define VARDECL(var) var 111 | #define ALLOC(var, size, type) var = PUSH(stack, size, type) 112 | #endif 113 | 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | # Configure paths for libogg 2 | # Jack Moffitt 10-21-2000 3 | # Shamelessly stolen from Owen Taylor and Manish Singh 4 | 5 | dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 6 | dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS 7 | dnl 8 | AC_DEFUN([XIPH_PATH_OGG], 9 | [dnl 10 | dnl Get the cflags and libraries 11 | dnl 12 | AC_ARG_WITH(ogg,[ --with-ogg=PFX Prefix where libogg is installed (optional)], ogg_prefix="$withval", ogg_prefix="") 13 | AC_ARG_WITH(ogg-libraries,[ --with-ogg-libraries=DIR Directory where libogg library is installed (optional)], ogg_libraries="$withval", ogg_libraries="") 14 | AC_ARG_WITH(ogg-includes,[ --with-ogg-includes=DIR Directory where libogg header files are installed (optional)], ogg_includes="$withval", ogg_includes="") 15 | AC_ARG_ENABLE(oggtest, [ --disable-oggtest Do not try to compile and run a test Ogg program],, enable_oggtest=yes) 16 | 17 | if test "x$ogg_libraries" != "x" ; then 18 | OGG_LIBS="-L$ogg_libraries" 19 | elif test "x$ogg_prefix" != "x" ; then 20 | OGG_LIBS="-L$ogg_prefix/lib" 21 | elif test "x$prefix" != "xNONE" ; then 22 | OGG_LIBS="-L$prefix/lib" 23 | fi 24 | 25 | OGG_LIBS="$OGG_LIBS -logg" 26 | 27 | if test "x$ogg_includes" != "x" ; then 28 | OGG_CFLAGS="-I$ogg_includes" 29 | elif test "x$ogg_prefix" != "x" ; then 30 | OGG_CFLAGS="-I$ogg_prefix/include" 31 | elif test "x$prefix" != "xNONE"; then 32 | OGG_CFLAGS="-I$prefix/include" 33 | fi 34 | 35 | AC_MSG_CHECKING(for Ogg) 36 | no_ogg="" 37 | 38 | 39 | if test "x$enable_oggtest" = "xyes" ; then 40 | ac_save_CFLAGS="$CFLAGS" 41 | ac_save_LIBS="$LIBS" 42 | CFLAGS="$CFLAGS $OGG_CFLAGS" 43 | LIBS="$LIBS $OGG_LIBS" 44 | dnl 45 | dnl Now check if the installed Ogg is sufficiently new. 46 | dnl 47 | rm -f conf.oggtest 48 | AC_TRY_RUN([ 49 | #include 50 | #include 51 | #include 52 | #include 53 | 54 | int main () 55 | { 56 | system("touch conf.oggtest"); 57 | return 0; 58 | } 59 | 60 | ],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 61 | CFLAGS="$ac_save_CFLAGS" 62 | LIBS="$ac_save_LIBS" 63 | fi 64 | 65 | if test "x$no_ogg" = "x" ; then 66 | AC_MSG_RESULT(yes) 67 | ifelse([$1], , :, [$1]) 68 | else 69 | AC_MSG_RESULT(no) 70 | if test -f conf.oggtest ; then 71 | : 72 | else 73 | echo "*** Could not run Ogg test program, checking why..." 74 | CFLAGS="$CFLAGS $OGG_CFLAGS" 75 | LIBS="$LIBS $OGG_LIBS" 76 | AC_TRY_LINK([ 77 | #include 78 | #include 79 | ], [ return 0; ], 80 | [ echo "*** The test program compiled, but did not run. This usually means" 81 | echo "*** that the run-time linker is not finding Ogg or finding the wrong" 82 | echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your" 83 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 84 | echo "*** to the installed location Also, make sure you have run ldconfig if that" 85 | echo "*** is required on your system" 86 | echo "***" 87 | echo "*** If you have an old version installed, it is best to remove it, although" 88 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 89 | [ echo "*** The test program failed to compile or link. See the file config.log for the" 90 | echo "*** exact error that occured. This usually means Ogg was incorrectly installed" 91 | echo "*** or that you have moved Ogg since it was installed." ]) 92 | CFLAGS="$ac_save_CFLAGS" 93 | LIBS="$ac_save_LIBS" 94 | fi 95 | OGG_CFLAGS="" 96 | OGG_LIBS="" 97 | ifelse([$2], , :, [$2]) 98 | fi 99 | AC_SUBST(OGG_CFLAGS) 100 | AC_SUBST(OGG_LIBS) 101 | rm -f conf.oggtest 102 | ]) 103 | -------------------------------------------------------------------------------- /include/speex/speexdsp_types.h: -------------------------------------------------------------------------------- 1 | /* speexdsp_types.h taken from libogg */ 2 | /******************************************************************** 3 | * * 4 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 8 | * * 9 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 10 | * by the Xiph.Org Foundation http://www.xiph.org/ * 11 | * * 12 | ******************************************************************** 13 | 14 | function: #ifdef jail to whip a few platforms into the UNIX ideal. 15 | last mod: $Id: os_types.h 7524 2004-08-11 04:20:36Z conrad $ 16 | 17 | ********************************************************************/ 18 | /** 19 | @file speexdsp_types.h 20 | @brief Speex types 21 | */ 22 | #ifndef _SPEEX_TYPES_H 23 | #define _SPEEX_TYPES_H 24 | 25 | #if defined(_WIN32) 26 | 27 | # if defined(__CYGWIN__) 28 | # include <_G_config.h> 29 | typedef _G_int32_t spx_int32_t; 30 | typedef _G_uint32_t spx_uint32_t; 31 | typedef _G_int16_t spx_int16_t; 32 | typedef _G_uint16_t spx_uint16_t; 33 | # elif defined(__MINGW32__) 34 | typedef short spx_int16_t; 35 | typedef unsigned short spx_uint16_t; 36 | typedef int spx_int32_t; 37 | typedef unsigned int spx_uint32_t; 38 | # elif defined(__MWERKS__) 39 | typedef int spx_int32_t; 40 | typedef unsigned int spx_uint32_t; 41 | typedef short spx_int16_t; 42 | typedef unsigned short spx_uint16_t; 43 | # else 44 | /* MSVC/Borland */ 45 | typedef __int32 spx_int32_t; 46 | typedef unsigned __int32 spx_uint32_t; 47 | typedef __int16 spx_int16_t; 48 | typedef unsigned __int16 spx_uint16_t; 49 | # endif 50 | 51 | #elif defined(__MACOS__) 52 | 53 | # include 54 | typedef SInt16 spx_int16_t; 55 | typedef UInt16 spx_uint16_t; 56 | typedef SInt32 spx_int32_t; 57 | typedef UInt32 spx_uint32_t; 58 | 59 | #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ 60 | 61 | # include 62 | typedef int16_t spx_int16_t; 63 | typedef u_int16_t spx_uint16_t; 64 | typedef int32_t spx_int32_t; 65 | typedef u_int32_t spx_uint32_t; 66 | 67 | #elif defined(__BEOS__) 68 | 69 | /* Be */ 70 | # include 71 | typedef int16_t spx_int16_t; 72 | typedef u_int16_t spx_uint16_t; 73 | typedef int32_t spx_int32_t; 74 | typedef u_int32_t spx_uint32_t; 75 | 76 | #elif defined (__EMX__) 77 | 78 | /* OS/2 GCC */ 79 | typedef short spx_int16_t; 80 | typedef unsigned short spx_uint16_t; 81 | typedef int spx_int32_t; 82 | typedef unsigned int spx_uint32_t; 83 | 84 | #elif defined (DJGPP) 85 | 86 | /* DJGPP */ 87 | typedef short spx_int16_t; 88 | typedef int spx_int32_t; 89 | typedef unsigned int spx_uint32_t; 90 | 91 | #elif defined(R5900) 92 | 93 | /* PS2 EE */ 94 | typedef int spx_int32_t; 95 | typedef unsigned spx_uint32_t; 96 | typedef short spx_int16_t; 97 | 98 | #elif defined(__SYMBIAN32__) 99 | 100 | /* Symbian GCC */ 101 | typedef signed short spx_int16_t; 102 | typedef unsigned short spx_uint16_t; 103 | typedef signed int spx_int32_t; 104 | typedef unsigned int spx_uint32_t; 105 | 106 | #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) 107 | 108 | typedef short spx_int16_t; 109 | typedef unsigned short spx_uint16_t; 110 | typedef long spx_int32_t; 111 | typedef unsigned long spx_uint32_t; 112 | 113 | #elif defined(CONFIG_TI_C6X) 114 | 115 | typedef short spx_int16_t; 116 | typedef unsigned short spx_uint16_t; 117 | typedef int spx_int32_t; 118 | typedef unsigned int spx_uint32_t; 119 | 120 | #else 121 | 122 | #include "speexdsp_config_types.h" 123 | 124 | #endif 125 | 126 | #endif /* _SPEEX_TYPES_H */ 127 | -------------------------------------------------------------------------------- /README.Trimedia: -------------------------------------------------------------------------------- 1 | ################# REMOVE warnings on trimedia compiler ############################## 2 | ################# Not critical to compilation ############################## 3 | 4 | 1. Change the following statements to remove warning for constant expression 5 | (i) mdf.c [if(0) --> #if 0] 6 | (ii) preprocess.c [if(1) --> #if 1] 7 | 8 | 2. add REMARK_ON macro to remove warning on not reference variable 9 | -- uses (void) to remove warning on not referenced variable 10 | -- #define REMARK_ON 11 | -- (void) 12 | -- #endif 13 | -- search for REMARK_ON on the following files 14 | (i) jitter.c 15 | (ii) mdf.c 16 | (iii) filterbank.c 17 | (iv) preprocess.c 18 | 19 | 3. commented out the following in pseudofloat.h for unused variable 20 | //static const spx_float_t FLOAT_HALF = {16384,-15}; 21 | 22 | ################# Patches for trimedia compiler ############################## 23 | ################# Critical to compilation ############################## 24 | 25 | -- added the #elif defined (TM_ASM) to the following files for optimized codes 26 | (1) arch.h 27 | (2) fftwrap.c 28 | (3) filterbank.c 29 | (4) kiss_fft.c 30 | (5) kiss_fftr.c 31 | (6) mdf.c 32 | (7) preprocess.c 33 | 34 | -- added macro PREPROCESS_MDF_FLOAT to allow using of floating point 35 | -- in mdf and preprocess while keeping fixed point in encoder/decoder 36 | -- This is due to the fact that preprocess/mdf run faster on floating 37 | -- point on trimedia 38 | -- added the following 3 lines to the files below 39 | #ifdef PREPROCESS_MDF_FLOAT 40 | #undef FIXED_POINT 41 | #endif 42 | (1) mdf.c 43 | (2) preprocess.c 44 | (3) filterbank.c 45 | (4) fftwrap.c 46 | (5) kiss_fft.c 47 | (6) kiss_fftr.c 48 | 49 | -- created a new USE_COMPACT_KISS_FFT for fftwrap.c and shifted defination 50 | -- to config file so that user configure the usage of fft on config.h 51 | -- TOEXPLORE:is it possible to share table between mdf/preprocess? 52 | -- Introducing this macro made the following changes in C code 53 | -- New macro to facilitate integration 54 | (grouping real/complex for dc and nyquist frequency seems to require a large 55 | amount of memory for mdf, therefore did not made the changes for that) 56 | (1) modify preprocess.c on init and destroy 57 | (2) modify mdf.c on init and destroy 58 | (3) shifted power_spectrum to fftwrap.c to share optimised code between 59 | preprocess.c and mdf.c 60 | 61 | ################# NOTES ############################## 62 | (1) fixed point encoding/decoding is tested on narrowband 63 | - some of the QX fractions are packed together to 64 | (frac1 * a + frac2 * a) >> X (should be more accurate in rounding) 65 | instead of 66 | ((frac1 * a) >> X) + ((frac2 * a) >> X) 67 | will cause some different between optimized and unoptimized code. 68 | tried decoding/encoding optimized code on some audio files retains 69 | the clearity of the word 70 | 71 | - wideband/ultrawideband is not heavily tested yet 72 | 73 | (2) optimized fixed point code requires memory alignment 74 | - used config to debug on functions where memory is not align 75 | 76 | (3) floating point optimization for preprocess/mdf is tested 77 | fixed point is not tested yet (except fft/filterbank) 78 | Note (1) also applies to sround in fft for fixed point 79 | some optimization is provided for fixed point as it requires lesser 80 | memory compared to floating point. 81 | 82 | (4) unroll configurations provided to reduce code size if required 83 | 84 | (5) use profile options only if compiler profiling fails to work 85 | 86 | (6) can't include the makefile as it is close proprietary 87 | 88 | ################# TODO:For Trimedia ############################## 89 | (1) Optimizations for fixed point in mdf/preprocess 90 | 91 | ################# Added Files ############################## 92 | - _kiss_fft_guts_tm.h 93 | - fftwrap_tm.h 94 | - filterbank_tm.h 95 | - filters_tm.h 96 | - fixed_tm.h 97 | - kiss_fft_tm.h 98 | - kiss_fftr_tm.h 99 | - mdf_tm.h 100 | - misc_tm.h 101 | - preprocess_tm.h 102 | - config.h 103 | - speex_config_types.h 104 | -------------------------------------------------------------------------------- /libspeexdsp/fixed_bfin.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005 Analog Devices 2 | Author: Jean-Marc Valin */ 3 | /** 4 | @file fixed_bfin.h 5 | @brief Blackfin fixed-point operations 6 | */ 7 | /* 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | - Neither the name of the Xiph.org Foundation nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #ifndef FIXED_BFIN_H 37 | #define FIXED_BFIN_H 38 | 39 | #include "bfin.h" 40 | 41 | #undef PDIV32_16 42 | static inline spx_word16_t PDIV32_16(spx_word32_t a, spx_word16_t b) 43 | { 44 | spx_word32_t res, bb; 45 | bb = b; 46 | a += b>>1; 47 | __asm__ ( 48 | "P0 = 15;\n\t" 49 | "R0 = %1;\n\t" 50 | "R1 = %2;\n\t" 51 | //"R0 = R0 + R1;\n\t" 52 | "R0 <<= 1;\n\t" 53 | "DIVS (R0, R1);\n\t" 54 | "LOOP divide%= LC0 = P0;\n\t" 55 | "LOOP_BEGIN divide%=;\n\t" 56 | "DIVQ (R0, R1);\n\t" 57 | "LOOP_END divide%=;\n\t" 58 | "R0 = R0.L;\n\t" 59 | "%0 = R0;\n\t" 60 | : "=m" (res) 61 | : "m" (a), "m" (bb) 62 | : "P0", "R0", "R1", "ASTAT" BFIN_HWLOOP0_REGS); 63 | return res; 64 | } 65 | 66 | #undef DIV32_16 67 | static inline spx_word16_t DIV32_16(spx_word32_t a, spx_word16_t b) 68 | { 69 | spx_word32_t res, bb; 70 | bb = b; 71 | /* Make the roundinf consistent with the C version 72 | (do we need to do that?)*/ 73 | if (a<0) 74 | a += (b-1); 75 | __asm__ ( 76 | "P0 = 15;\n\t" 77 | "R0 = %1;\n\t" 78 | "R1 = %2;\n\t" 79 | "R0 <<= 1;\n\t" 80 | "DIVS (R0, R1);\n\t" 81 | "LOOP divide%= LC0 = P0;\n\t" 82 | "LOOP_BEGIN divide%=;\n\t" 83 | "DIVQ (R0, R1);\n\t" 84 | "LOOP_END divide%=;\n\t" 85 | "R0 = R0.L;\n\t" 86 | "%0 = R0;\n\t" 87 | : "=m" (res) 88 | : "m" (a), "m" (bb) 89 | : "P0", "R0", "R1", "ASTAT" BFIN_HWLOOP0_REGS); 90 | return res; 91 | } 92 | 93 | #undef MAX16 94 | static inline spx_word16_t MAX16(spx_word16_t a, spx_word16_t b) 95 | { 96 | spx_word32_t res; 97 | __asm__ ( 98 | "%1 = %1.L (X);\n\t" 99 | "%2 = %2.L (X);\n\t" 100 | "%0 = MAX(%1,%2);" 101 | : "=d" (res) 102 | : "%d" (a), "d" (b) 103 | : "ASTAT" 104 | ); 105 | return res; 106 | } 107 | 108 | #undef MULT16_32_Q15 109 | static inline spx_word32_t MULT16_32_Q15(spx_word16_t a, spx_word32_t b) 110 | { 111 | spx_word32_t res; 112 | __asm__ 113 | ( 114 | "A1 = %2.L*%1.L (M);\n\t" 115 | "A1 = A1 >>> 15;\n\t" 116 | "%0 = (A1 += %2.L*%1.H) ;\n\t" 117 | : "=&W" (res), "=&d" (b) 118 | : "d" (a), "1" (b) 119 | : "A1", "ASTAT" 120 | ); 121 | return res; 122 | } 123 | 124 | #undef MAC16_32_Q15 125 | static inline spx_word32_t MAC16_32_Q15(spx_word32_t c, spx_word16_t a, spx_word32_t b) 126 | { 127 | spx_word32_t res; 128 | __asm__ 129 | ( 130 | "A1 = %2.L*%1.L (M);\n\t" 131 | "A1 = A1 >>> 15;\n\t" 132 | "%0 = (A1 += %2.L*%1.H);\n\t" 133 | "%0 = %0 + %4;\n\t" 134 | : "=&W" (res), "=&d" (b) 135 | : "d" (a), "1" (b), "d" (c) 136 | : "A1", "ASTAT" 137 | ); 138 | return res; 139 | } 140 | 141 | #endif 142 | -------------------------------------------------------------------------------- /libspeexdsp/fixed_arm4.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 Jean-Marc Valin */ 2 | /** 3 | @file fixed_arm4.h 4 | @brief ARM4 fixed-point operations 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef FIXED_ARM4_H 36 | #define FIXED_ARM4_H 37 | 38 | #undef MULT16_32_Q15 39 | static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) { 40 | int res; 41 | int dummy; 42 | asm ( 43 | "smull %0,%1,%2,%3 \n\t" 44 | "mov %0, %0, lsr #15 \n\t" 45 | "add %0, %0, %1, lsl #17 \n\t" 46 | : "=&r"(res), "=&r" (dummy) 47 | : "r"(y),"r"((int)x)); 48 | return(res); 49 | } 50 | 51 | #undef DIV32_16 52 | static inline short DIV32_16(int a, int b) 53 | { 54 | int res=0; 55 | int dead1, dead2, dead3, dead4, dead5; 56 | __asm__ __volatile__ ( 57 | "\teor %5, %0, %1\n" 58 | "\tmovs %4, %0\n" 59 | "\trsbmi %0, %0, #0 \n" 60 | "\tmovs %4, %1\n" 61 | "\trsbmi %1, %1, #0 \n" 62 | "\tmov %4, #1\n" 63 | 64 | "\tsubs %3, %0, %1, asl #14 \n" 65 | "\tmovpl %0, %3 \n" 66 | "\torrpl %2, %2, %4, asl #14 \n" 67 | 68 | "\tsubs %3, %0, %1, asl #13 \n" 69 | "\tmovpl %0, %3 \n" 70 | "\torrpl %2, %2, %4, asl #13 \n" 71 | 72 | "\tsubs %3, %0, %1, asl #12 \n" 73 | "\tmovpl %0, %3 \n" 74 | "\torrpl %2, %2, %4, asl #12 \n" 75 | 76 | "\tsubs %3, %0, %1, asl #11 \n" 77 | "\tmovpl %0, %3 \n" 78 | "\torrpl %2, %2, %4, asl #11 \n" 79 | 80 | "\tsubs %3, %0, %1, asl #10 \n" 81 | "\tmovpl %0, %3 \n" 82 | "\torrpl %2, %2, %4, asl #10 \n" 83 | 84 | "\tsubs %3, %0, %1, asl #9 \n" 85 | "\tmovpl %0, %3 \n" 86 | "\torrpl %2, %2, %4, asl #9 \n" 87 | 88 | "\tsubs %3, %0, %1, asl #8 \n" 89 | "\tmovpl %0, %3 \n" 90 | "\torrpl %2, %2, %4, asl #8 \n" 91 | 92 | "\tsubs %3, %0, %1, asl #7 \n" 93 | "\tmovpl %0, %3 \n" 94 | "\torrpl %2, %2, %4, asl #7 \n" 95 | 96 | "\tsubs %3, %0, %1, asl #6 \n" 97 | "\tmovpl %0, %3 \n" 98 | "\torrpl %2, %2, %4, asl #6 \n" 99 | 100 | "\tsubs %3, %0, %1, asl #5 \n" 101 | "\tmovpl %0, %3 \n" 102 | "\torrpl %2, %2, %4, asl #5 \n" 103 | 104 | "\tsubs %3, %0, %1, asl #4 \n" 105 | "\tmovpl %0, %3 \n" 106 | "\torrpl %2, %2, %4, asl #4 \n" 107 | 108 | "\tsubs %3, %0, %1, asl #3 \n" 109 | "\tmovpl %0, %3 \n" 110 | "\torrpl %2, %2, %4, asl #3 \n" 111 | 112 | "\tsubs %3, %0, %1, asl #2 \n" 113 | "\tmovpl %0, %3 \n" 114 | "\torrpl %2, %2, %4, asl #2 \n" 115 | 116 | "\tsubs %3, %0, %1, asl #1 \n" 117 | "\tmovpl %0, %3 \n" 118 | "\torrpl %2, %2, %4, asl #1 \n" 119 | 120 | "\tsubs %3, %0, %1 \n" 121 | "\tmovpl %0, %3 \n" 122 | "\torrpl %2, %2, %4 \n" 123 | 124 | "\tmovs %5, %5, lsr #31 \n" 125 | "\trsbne %2, %2, #0 \n" 126 | : "=r" (dead1), "=r" (dead2), "=r" (res), 127 | "=r" (dead3), "=r" (dead4), "=r" (dead5) 128 | : "0" (a), "1" (b), "2" (res) 129 | : "cc" 130 | ); 131 | return res; 132 | } 133 | 134 | 135 | #endif 136 | -------------------------------------------------------------------------------- /doc/programming.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Speex Programming 5 | 6 | 8 | 9 | 10 | 11 |
12 |

Speex Programming

13 | 14 |
15 |

Encoding

16 | In order to encode speech using Speex, you first need to:
17 | 18 |
19 |
#include <speex.h>
20 |
21 | You then need to declare a Speex bit-packing struct
22 | 23 |
24 |
SpeexBits bits;
25 |
26 | and a Speex encoder state
27 | 28 |
29 |
void *enc_state;
30 |
31 | The two are initialized by:
32 | 33 |
34 |
speex_bits_init(&bits);
35 | 36 |
enc_state = speex_encoder_init(&speex_nb_mode);
37 |
38 | For wideband coding, speex_nb_mode will be replaced by speex_wb_mode 39 | . In most cases, you will need to know the frame size used by the mode you 40 | are using. You can get that value in the frame_size variable with:
41 |
speex_encoder_ctl(enc_state, SPEEX_GET_FRAME_SIZE, &frame_size);
42 |
43 | For every input frame:
44 | 45 |
46 |
speex_bits_reset(&bits);
47 | 48 |
speex_encode(enc_state, input_frame, &bits);
49 | 50 |
nbBytes = speex_bits_write(&bits, byte_ptr, MAX_NB_BYTES);
51 |
52 | where input_frame is a (float *) pointing to the beginning 53 | of a speech frame, byte_ptr is a (char *) where the encoded frame will 54 | be written, MAX_NB_BYTES is the maximum number of bytes that can be 55 | written to byte_ptr without causing an overflow and nbBytes 56 | is the number of bytes actually written to byte_ptr (the encoded 57 | size in bytes).
58 |
59 | After you're done with the encoding, free all resources with:
60 | 61 |
62 |
speex_bits_destroy(&bits);
63 | 64 |
speex_encoder_destroy(&enc_state);
65 |
66 | That's about it for the encoder.
67 | 68 |

Decoding

69 | In order to encode speech using Speex, you first need to:
70 | 71 |
72 |
#include <speex.h>
73 |
74 | You then need to declare a Speex bit-packing struct
75 | 76 |
77 |
SpeexBits bits;
78 |
79 | and a Speex encoder state
80 | 81 |
82 |
void *dec_state;
83 |
84 | The two are initialized by:
85 | 86 |
87 |
speex_bits_init(&bits);
88 | 89 |
dec_state = speex_decoder_init(&speex_nb_mode);
90 |
91 | For wideband decoding, speex_nb_mode will be replaced by speex_wb_mode 92 | . You can get that value in the frame_size variable with:
93 | 94 |
speex_decoder_ctl(dec_state, SPEEX_GET_FRAME_SIZE, &frame_size);
95 |
96 | There is also a parameter that can be set for the decoder: whether or not 97 | to use a perceptual post-filter. This can be set by:
98 |
speex_decoder_ctl(dec_state, SPEEX_SET_PF, &pf);
99 |
100 | where pf is an int that with value 0 to have the post-filter 101 | disabled and 1 to have it enabled.
102 |
103 | For every input frame:
104 | 105 |
106 |
speex_bits_read_from(&bits, input_bytes, nbBytes);
107 | 108 |
speex_decode(st, &bits, output_frame, 0);
109 |
110 | where input_bytes is a (char *) containing the bit-stream 111 | data received for a frame, nbBytes is the size (in bytes) of that 112 | bit-stream, and output_frame is a (float *) and points to the 113 | area where the decoded speech frame will be written. The last argument indicates 114 | whether the frame we'd like to decode was lost. A value of 0 indicates the 115 | normal case where bits points to the bit of the current frame. A value of 116 | 1 indicates that we don't have the bits for the current frame, in which case 117 | the bits argument should be the same as the bits for the last correctly received 118 | frame. When a frame is lost, the Speex decoder will do its best to "guess" 119 | the sorrect signal.
120 |
121 |
122 |
123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /ti/os_support_custom.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Psi Systems, Inc. 2 | Author: Jean-Marc Valin 3 | File: os_support_custom.h 4 | Memory Allocation overrides to allow user control rather than C alloc/free. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | - Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | - Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of the Xiph.org Foundation nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifdef MANUAL_ALLOC 35 | 36 | /* To avoid changing the Speex call model, this file relies on four static variables 37 | The user main creates two linear buffers, and initializes spxGlobalHeap/ScratchPtr 38 | to point to the start of the two buffers, and initializes spxGlobalHeap/ScratchEnd 39 | to point to the first address following the last byte of the two buffers. 40 | 41 | This mechanism allows, for example, data caching for multichannel applications, 42 | where the Speex state is swapped from a large slow memory to a small fast memory 43 | each time the codec runs. 44 | 45 | Persistent data is allocated in spxGlobalHeap (instead of calloc), while scratch 46 | data is allocated in spxGlobalScratch. 47 | */ 48 | 49 | extern char *spxGlobalHeapPtr, *spxGlobalHeapEnd; 50 | extern char *spxGlobalScratchPtr, *spxGlobalScratchEnd; 51 | 52 | /* Make sure that all structures are aligned to largest type */ 53 | #define BLOCK_MASK (sizeof(long double)-1) 54 | extern inline void speex_warning(const char *str); 55 | 56 | #define OVERRIDE_SPEEX_ALLOC 57 | static inline void *speex_alloc (int size) 58 | { 59 | void *ptr; 60 | 61 | ptr = (void *) (((int)spxGlobalHeapPtr + BLOCK_MASK) & ~BLOCK_MASK); //Start on 8 boundary 62 | 63 | spxGlobalHeapPtr = (char *)((int)ptr + size); // Update pointer to next free location 64 | 65 | if (spxGlobalHeapPtr > spxGlobalHeapEnd ) 66 | { 67 | #ifdef VERBOSE_ALLOC 68 | fprintf (stderr, "insufficient space for persistent alloc request %d bytes\n", size); 69 | #endif 70 | return 0; 71 | } 72 | 73 | #ifdef VERBOSE_ALLOC 74 | fprintf (stderr, "Persist Allocated %d chars at %x, %d remaining\n", size, ptr, ((int)spxGlobalHeapEnd - (int)spxGlobalHeapPtr)); 75 | #endif 76 | memset(ptr, 0, size); 77 | return ptr; 78 | } 79 | 80 | #define OVERRIDE_SPEEX_ALLOC_SCRATCH 81 | static inline void *speex_alloc_scratch (int size) 82 | { 83 | void *ptr; 84 | 85 | ptr = (void *) (((int)spxGlobalScratchPtr + BLOCK_MASK) & ~BLOCK_MASK); //Start on 8 boundary 86 | 87 | spxGlobalScratchPtr = (char *)((int)ptr + size); // Update pointer to next free location 88 | 89 | if (spxGlobalScratchPtr > spxGlobalScratchEnd ) 90 | { 91 | #ifdef VERBOSE_ALLOC 92 | fprintf (stderr, "insufficient space for scratch alloc request %d bytes\n", size); 93 | #endif 94 | return 0; 95 | } 96 | 97 | #ifdef VERBOSE_ALLOC 98 | fprintf (stderr, "Scratch Allocated %d chars at %x, %d remaining\n", size, ptr, ((int)spxGlobalScratchEnd - (int)spxGlobalScratchPtr)); 99 | #endif 100 | memset(ptr, 0, size); 101 | return ptr; 102 | } 103 | 104 | #define OVERRIDE_SPEEX_REALLOC 105 | static inline void *speex_realloc (void *ptr, int size) 106 | { 107 | #ifdef VERBOSE_ALLOC 108 | speex_warning("realloc attempted, not allowed"); 109 | #endif 110 | return 0; 111 | } 112 | 113 | #define OVERRIDE_SPEEX_FREE 114 | static inline void speex_free (void *ptr) 115 | { 116 | #ifdef VERBOSE_ALLOC 117 | speex_warning("at speex_free"); 118 | #endif 119 | } 120 | #define OVERRIDE_SPEEX_FREE_SCRATCH 121 | static inline void speex_free_scratch (void *ptr) 122 | { 123 | #ifdef VERBOSE_ALLOC 124 | speex_warning("at speex_free_scratch"); 125 | #endif 126 | } 127 | 128 | #endif /* !MANUAL_ALLOC */ 129 | -------------------------------------------------------------------------------- /libspeexdsp/resample_sse.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007-2008 Jean-Marc Valin 2 | * Copyright (C) 2008 Thorvald Natvig 3 | */ 4 | /** 5 | @file resample_sse.h 6 | @brief Resampler functions (SSE version) 7 | */ 8 | /* 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions 11 | are met: 12 | 13 | - Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | 16 | - Redistributions in binary form must reproduce the above copyright 17 | notice, this list of conditions and the following disclaimer in the 18 | documentation and/or other materials provided with the distribution. 19 | 20 | - Neither the name of the Xiph.org Foundation nor the names of its 21 | contributors may be used to endorse or promote products derived from 22 | this software without specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 28 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 29 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 31 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 32 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #include 38 | 39 | #define OVERRIDE_INNER_PRODUCT_SINGLE 40 | static inline float inner_product_single(const float *a, const float *b, unsigned int len) 41 | { 42 | int i; 43 | float ret; 44 | __m128 sum = _mm_setzero_ps(); 45 | for (i=0;i 76 | #define OVERRIDE_INNER_PRODUCT_DOUBLE 77 | 78 | static inline double inner_product_double(const float *a, const float *b, unsigned int len) 79 | { 80 | int i; 81 | double ret; 82 | __m128d sum = _mm_setzero_pd(); 83 | __m128 t; 84 | for (i=0;i> (shift)) 46 | #define SHL16(a,shift) ((a) << (shift)) 47 | #define SHR32(a,shift) ((a) >> (shift)) 48 | #define SHL32(a,shift) ((a) << (shift)) 49 | #define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift)) 50 | #define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift)) 51 | #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) 52 | #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) 53 | #define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) 54 | 55 | #define SATURATE32PSHR(x,shift,a) (((x)>=(SHL32(a,shift))) ? (a) : \ 56 | (x)<=-(SHL32(a,shift)) ? -(a) : \ 57 | (PSHR32(x, shift))) 58 | 59 | #define SHR(a,shift) ((a) >> (shift)) 60 | #define SHL(a,shift) ((spx_word32_t)(a) << (shift)) 61 | #define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift)) 62 | #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) 63 | 64 | 65 | #define ADD16(a,b) ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b))) 66 | #define SUB16(a,b) ((spx_word16_t)(a)-(spx_word16_t)(b)) 67 | #define ADD32(a,b) ((spx_word32_t)(a)+(spx_word32_t)(b)) 68 | #define SUB32(a,b) ((spx_word32_t)(a)-(spx_word32_t)(b)) 69 | 70 | 71 | /* result fits in 16 bits */ 72 | #define MULT16_16_16(a,b) (((spx_word16_t)(a))*((spx_word16_t)(b))) 73 | /* result fits in 32 bits */ 74 | #define MULT16_32_32(a,b) (((spx_word16_t)(a))*((spx_word32_t)(b))) 75 | 76 | /* (spx_word32_t)(spx_word16_t) gives TI compiler a hint that it's 16x16->32 multiply */ 77 | #define MULT16_16(a,b) (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b))) 78 | 79 | #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) 80 | 81 | #define MULT16_32_P15(a,b) ADD32(MULT16_32_32(a,SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15)) 82 | #define MULT16_32_Q15(a,b) ADD32(MULT16_32_32(a,SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)) 83 | #define MAC16_32_Q15(c,a,b) ADD32(c,MULT16_32_Q15(a,b)) 84 | 85 | 86 | #define MAC16_16_Q11(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),11))) 87 | #define MAC16_16_Q13(c,a,b) (ADD32((c),SHR(MULT16_16((a),(b)),13))) 88 | #define MAC16_16_P13(c,a,b) (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13))) 89 | 90 | #define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11)) 91 | #define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13)) 92 | #define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14)) 93 | #define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15)) 94 | 95 | #define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13)) 96 | #define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14)) 97 | #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) 98 | 99 | #define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15)) 100 | 101 | #define DIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b)))) 102 | #define PDIV32_16(a,b) ((spx_word16_t)(((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word16_t)(b)))) 103 | #define DIV32(a,b) (((spx_word32_t)(a))/((spx_word32_t)(b))) 104 | #define PDIV32(a,b) (((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word32_t)(b))) 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /libspeexdsp/fixed_arm5e.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2003 Jean-Marc Valin */ 2 | /** 3 | @file fixed_arm5e.h 4 | @brief ARM-tuned fixed-point operations 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions 9 | are met: 10 | 11 | - Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 14 | - Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | - Neither the name of the Xiph.org Foundation nor the names of its 19 | contributors may be used to endorse or promote products derived from 20 | this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef FIXED_ARM5E_H 36 | #define FIXED_ARM5E_H 37 | 38 | #undef MULT16_16 39 | static inline spx_word32_t MULT16_16(spx_word16_t x, spx_word16_t y) { 40 | int res; 41 | asm ("smulbb %0,%1,%2;\n" 42 | : "=&r"(res) 43 | : "%r"(x),"r"(y)); 44 | return(res); 45 | } 46 | 47 | #undef MAC16_16 48 | static inline spx_word32_t MAC16_16(spx_word32_t a, spx_word16_t x, spx_word32_t y) { 49 | int res; 50 | asm ("smlabb %0,%1,%2,%3;\n" 51 | : "=&r"(res) 52 | : "%r"(x),"r"(y),"r"(a)); 53 | return(res); 54 | } 55 | 56 | #undef MULT16_32_Q15 57 | static inline spx_word32_t MULT16_32_Q15(spx_word16_t x, spx_word32_t y) { 58 | int res; 59 | asm ("smulwb %0,%1,%2;\n" 60 | : "=&r"(res) 61 | : "%r"(y<<1),"r"(x)); 62 | return(res); 63 | } 64 | 65 | #undef MAC16_32_Q15 66 | static inline spx_word32_t MAC16_32_Q15(spx_word32_t a, spx_word16_t x, spx_word32_t y) { 67 | int res; 68 | asm ("smlawb %0,%1,%2,%3;\n" 69 | : "=&r"(res) 70 | : "%r"(y<<1),"r"(x),"r"(a)); 71 | return(res); 72 | } 73 | 74 | #undef DIV32_16 75 | static inline short DIV32_16(int a, int b) 76 | { 77 | int res=0; 78 | int dead1, dead2, dead3, dead4, dead5; 79 | __asm__ __volatile__ ( 80 | "\teor %5, %0, %1\n" 81 | "\tmovs %4, %0\n" 82 | "\trsbmi %0, %0, #0 \n" 83 | "\tmovs %4, %1\n" 84 | "\trsbmi %1, %1, #0 \n" 85 | "\tmov %4, #1\n" 86 | 87 | "\tsubs %3, %0, %1, asl #14 \n" 88 | "\torrpl %2, %2, %4, asl #14 \n" 89 | "\tmovpl %0, %3 \n" 90 | 91 | "\tsubs %3, %0, %1, asl #13 \n" 92 | "\torrpl %2, %2, %4, asl #13 \n" 93 | "\tmovpl %0, %3 \n" 94 | 95 | "\tsubs %3, %0, %1, asl #12 \n" 96 | "\torrpl %2, %2, %4, asl #12 \n" 97 | "\tmovpl %0, %3 \n" 98 | 99 | "\tsubs %3, %0, %1, asl #11 \n" 100 | "\torrpl %2, %2, %4, asl #11 \n" 101 | "\tmovpl %0, %3 \n" 102 | 103 | "\tsubs %3, %0, %1, asl #10 \n" 104 | "\torrpl %2, %2, %4, asl #10 \n" 105 | "\tmovpl %0, %3 \n" 106 | 107 | "\tsubs %3, %0, %1, asl #9 \n" 108 | "\torrpl %2, %2, %4, asl #9 \n" 109 | "\tmovpl %0, %3 \n" 110 | 111 | "\tsubs %3, %0, %1, asl #8 \n" 112 | "\torrpl %2, %2, %4, asl #8 \n" 113 | "\tmovpl %0, %3 \n" 114 | 115 | "\tsubs %3, %0, %1, asl #7 \n" 116 | "\torrpl %2, %2, %4, asl #7 \n" 117 | "\tmovpl %0, %3 \n" 118 | 119 | "\tsubs %3, %0, %1, asl #6 \n" 120 | "\torrpl %2, %2, %4, asl #6 \n" 121 | "\tmovpl %0, %3 \n" 122 | 123 | "\tsubs %3, %0, %1, asl #5 \n" 124 | "\torrpl %2, %2, %4, asl #5 \n" 125 | "\tmovpl %0, %3 \n" 126 | 127 | "\tsubs %3, %0, %1, asl #4 \n" 128 | "\torrpl %2, %2, %4, asl #4 \n" 129 | "\tmovpl %0, %3 \n" 130 | 131 | "\tsubs %3, %0, %1, asl #3 \n" 132 | "\torrpl %2, %2, %4, asl #3 \n" 133 | "\tmovpl %0, %3 \n" 134 | 135 | "\tsubs %3, %0, %1, asl #2 \n" 136 | "\torrpl %2, %2, %4, asl #2 \n" 137 | "\tmovpl %0, %3 \n" 138 | 139 | "\tsubs %3, %0, %1, asl #1 \n" 140 | "\torrpl %2, %2, %4, asl #1 \n" 141 | "\tmovpl %0, %3 \n" 142 | 143 | "\tsubs %3, %0, %1 \n" 144 | "\torrpl %2, %2, %4 \n" 145 | "\tmovpl %0, %3 \n" 146 | 147 | "\tmovs %5, %5, lsr #31 \n" 148 | "\trsbne %2, %2, #0 \n" 149 | : "=r" (dead1), "=r" (dead2), "=r" (res), 150 | "=r" (dead3), "=r" (dead4), "=r" (dead5) 151 | : "0" (a), "1" (b), "2" (res) 152 | : "memory", "cc" 153 | ); 154 | return res; 155 | } 156 | 157 | 158 | 159 | 160 | #endif 161 | -------------------------------------------------------------------------------- /libspeexdsp/buffer.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Jean-Marc Valin 2 | 3 | File: buffer.c 4 | This is a very simple ring buffer implementation. It is not thread-safe 5 | so you need to do your own locking. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | 3. The name of the author may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifdef HAVE_CONFIG_H 35 | #include "config.h" 36 | #endif 37 | 38 | 39 | #include "os_support.h" 40 | #include "arch.h" 41 | #include "speex/speex_buffer.h" 42 | 43 | struct SpeexBuffer_ { 44 | char *data; 45 | int size; 46 | int read_ptr; 47 | int write_ptr; 48 | int available; 49 | }; 50 | 51 | EXPORT SpeexBuffer *speex_buffer_init(int size) 52 | { 53 | SpeexBuffer *st = speex_alloc(sizeof(SpeexBuffer)); 54 | st->data = speex_alloc(size); 55 | st->size = size; 56 | st->read_ptr = 0; 57 | st->write_ptr = 0; 58 | st->available = 0; 59 | return st; 60 | } 61 | 62 | EXPORT void speex_buffer_destroy(SpeexBuffer *st) 63 | { 64 | speex_free(st->data); 65 | speex_free(st); 66 | } 67 | 68 | EXPORT int speex_buffer_write(SpeexBuffer *st, void *_data, int len) 69 | { 70 | int end; 71 | int end1; 72 | char *data = _data; 73 | if (len > st->size) 74 | { 75 | data += len-st->size; 76 | len = st->size; 77 | } 78 | end = st->write_ptr + len; 79 | end1 = end; 80 | if (end1 > st->size) 81 | end1 = st->size; 82 | SPEEX_COPY(st->data + st->write_ptr, data, end1 - st->write_ptr); 83 | if (end > st->size) 84 | { 85 | end -= st->size; 86 | SPEEX_COPY(st->data, data+end1 - st->write_ptr, end); 87 | } 88 | st->available += len; 89 | if (st->available > st->size) 90 | { 91 | st->available = st->size; 92 | st->read_ptr = st->write_ptr; 93 | } 94 | st->write_ptr += len; 95 | if (st->write_ptr > st->size) 96 | st->write_ptr -= st->size; 97 | return len; 98 | } 99 | 100 | EXPORT int speex_buffer_writezeros(SpeexBuffer *st, int len) 101 | { 102 | /* This is almost the same as for speex_buffer_write() but using 103 | SPEEX_MEMSET() instead of SPEEX_COPY(). Update accordingly. */ 104 | int end; 105 | int end1; 106 | if (len > st->size) 107 | { 108 | len = st->size; 109 | } 110 | end = st->write_ptr + len; 111 | end1 = end; 112 | if (end1 > st->size) 113 | end1 = st->size; 114 | SPEEX_MEMSET(st->data + st->write_ptr, 0, end1 - st->write_ptr); 115 | if (end > st->size) 116 | { 117 | end -= st->size; 118 | SPEEX_MEMSET(st->data, 0, end); 119 | } 120 | st->available += len; 121 | if (st->available > st->size) 122 | { 123 | st->available = st->size; 124 | st->read_ptr = st->write_ptr; 125 | } 126 | st->write_ptr += len; 127 | if (st->write_ptr > st->size) 128 | st->write_ptr -= st->size; 129 | return len; 130 | } 131 | 132 | EXPORT int speex_buffer_read(SpeexBuffer *st, void *_data, int len) 133 | { 134 | int end, end1; 135 | char *data = _data; 136 | if (len > st->available) 137 | { 138 | SPEEX_MEMSET(data+st->available, 0, len - st->available); 139 | len = st->available; 140 | } 141 | end = st->read_ptr + len; 142 | end1 = end; 143 | if (end1 > st->size) 144 | end1 = st->size; 145 | SPEEX_COPY(data, st->data + st->read_ptr, end1 - st->read_ptr); 146 | 147 | if (end > st->size) 148 | { 149 | end -= st->size; 150 | SPEEX_COPY(data+end1 - st->read_ptr, st->data, end); 151 | } 152 | st->available -= len; 153 | st->read_ptr += len; 154 | if (st->read_ptr > st->size) 155 | st->read_ptr -= st->size; 156 | return len; 157 | } 158 | 159 | EXPORT int speex_buffer_get_available(SpeexBuffer *st) 160 | { 161 | return st->available; 162 | } 163 | 164 | EXPORT int speex_buffer_resize(SpeexBuffer *st, int len) 165 | { 166 | int old_len = st->size; 167 | if (len > old_len) 168 | { 169 | st->data = speex_realloc(st->data, len); 170 | /* FIXME: move data/pointers properly for growing the buffer */ 171 | } else { 172 | /* FIXME: move data/pointers properly for shrinking the buffer */ 173 | st->data = speex_realloc(st->data, len); 174 | } 175 | return len; 176 | } 177 | -------------------------------------------------------------------------------- /libspeexdsp/os_support.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Jean-Marc Valin 2 | 3 | File: os_support.h 4 | This is the (tiny) OS abstraction layer. Aside from math.h, this is the 5 | only place where system headers are allowed. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | 3. The name of the author may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef OS_SUPPORT_H 35 | #define OS_SUPPORT_H 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #ifdef HAVE_CONFIG_H 42 | #include "config.h" 43 | #endif 44 | #ifdef OS_SUPPORT_CUSTOM 45 | #include "os_support_custom.h" 46 | #endif 47 | 48 | /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_free 49 | NOTE: speex_alloc needs to CLEAR THE MEMORY */ 50 | #ifndef OVERRIDE_SPEEX_ALLOC 51 | static inline void *speex_alloc (int size) 52 | { 53 | /* WARNING: this is not equivalent to malloc(). If you want to use malloc() 54 | or your own allocator, YOU NEED TO CLEAR THE MEMORY ALLOCATED. Otherwise 55 | you will experience strange bugs */ 56 | return calloc(size,1); 57 | } 58 | #endif 59 | 60 | /** Same as speex_alloc, except that the area is only needed inside a Speex call (might cause problem with wideband though) */ 61 | #ifndef OVERRIDE_SPEEX_ALLOC_SCRATCH 62 | static inline void *speex_alloc_scratch (int size) 63 | { 64 | /* Scratch space doesn't need to be cleared */ 65 | return calloc(size,1); 66 | } 67 | #endif 68 | 69 | /** Speex wrapper for realloc. To do your own dynamic allocation, all you need to do is replace this function, speex_alloc and speex_free */ 70 | #ifndef OVERRIDE_SPEEX_REALLOC 71 | static inline void *speex_realloc (void *ptr, int size) 72 | { 73 | return realloc(ptr, size); 74 | } 75 | #endif 76 | 77 | /** Speex wrapper for calloc. To do your own dynamic allocation, all you need to do is replace this function, speex_realloc and speex_alloc */ 78 | #ifndef OVERRIDE_SPEEX_FREE 79 | static inline void speex_free (void *ptr) 80 | { 81 | free(ptr); 82 | } 83 | #endif 84 | 85 | /** Same as speex_free, except that the area is only needed inside a Speex call (might cause problem with wideband though) */ 86 | #ifndef OVERRIDE_SPEEX_FREE_SCRATCH 87 | static inline void speex_free_scratch (void *ptr) 88 | { 89 | free(ptr); 90 | } 91 | #endif 92 | 93 | /** Copy n elements from src to dst. The 0* term provides compile-time type checking */ 94 | #ifndef OVERRIDE_SPEEX_COPY 95 | #define SPEEX_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) 96 | #endif 97 | 98 | /** Copy n elements from src to dst, allowing overlapping regions. The 0* term 99 | provides compile-time type checking */ 100 | #ifndef OVERRIDE_SPEEX_MOVE 101 | #define SPEEX_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) 102 | #endif 103 | 104 | /** For n elements worth of memory, set every byte to the value of c, starting at address dst */ 105 | #ifndef OVERRIDE_SPEEX_MEMSET 106 | #define SPEEX_MEMSET(dst, c, n) (memset((dst), (c), (n)*sizeof(*(dst)))) 107 | #endif 108 | 109 | 110 | #ifndef OVERRIDE_SPEEX_FATAL 111 | static inline void _speex_fatal(const char *str, const char *file, int line) 112 | { 113 | fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); 114 | exit(1); 115 | } 116 | #endif 117 | 118 | #ifndef OVERRIDE_SPEEX_WARNING 119 | static inline void speex_warning(const char *str) 120 | { 121 | #ifndef DISABLE_WARNINGS 122 | fprintf (stderr, "warning: %s\n", str); 123 | #endif 124 | } 125 | #endif 126 | 127 | #ifndef OVERRIDE_SPEEX_WARNING_INT 128 | static inline void speex_warning_int(const char *str, int val) 129 | { 130 | #ifndef DISABLE_WARNINGS 131 | fprintf (stderr, "warning: %s %d\n", str, val); 132 | #endif 133 | } 134 | #endif 135 | 136 | #ifndef OVERRIDE_SPEEX_NOTIFY 137 | static inline void speex_notify(const char *str) 138 | { 139 | #ifndef DISABLE_NOTIFICATIONS 140 | fprintf (stderr, "notification: %s\n", str); 141 | #endif 142 | } 143 | #endif 144 | 145 | #ifndef OVERRIDE_SPEEX_PUTC 146 | /** Speex wrapper for putc */ 147 | static inline void _speex_putc(int ch, void *file) 148 | { 149 | FILE *f = (FILE *)file; 150 | fprintf(f, "%c", ch); 151 | } 152 | #endif 153 | 154 | #define speex_fatal(str) _speex_fatal(str, __FILE__, __LINE__); 155 | #define speex_assert(cond) {if (!(cond)) {speex_fatal("assertion failed: " #cond);}} 156 | 157 | #ifndef RELEASE 158 | static inline void print_vec(float *vec, int len, char *name) 159 | { 160 | int i; 161 | printf ("%s ", name); 162 | for (i=0;i 36 | #include "profile_tm.h" 37 | 38 | #ifdef FIXED_POINT 39 | 40 | #define OVERRIDE_MAXIMIZE_RANGE 41 | static int maximize_range(Int16 *in, Int16 *out, int bound, int len) 42 | { 43 | register int max_val=0; 44 | register int shift=0; 45 | register int i, j; 46 | 47 | TMDEBUG_ALIGNMEM(in); 48 | TMDEBUG_ALIGNMEM(out); 49 | 50 | MAXIMIZERANGE_START(); 51 | 52 | len >>= 1; 53 | 54 | for ( i=0 ; i>1) && max_val != 0 ) 80 | { max_val <<= 1; 81 | shift++; 82 | } 83 | 84 | if ( shift != 0 ) 85 | { 86 | for ( i=0,j=0 ; i>1); 123 | s = pack16lsb(s,s); 124 | 125 | len >>= 1; 126 | l = len & (int)0xFFFFFFFE; 127 | 128 | for ( i=0,j=0 ; i>= 1; 178 | 179 | for( i=1 ; i(b) ? (a):(b)) 17 | 18 | /* kiss_fft.h 19 | defines kiss_fft_scalar as either short or a float type 20 | and defines 21 | typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */ 22 | #include "kiss_fft.h" 23 | #include "math_approx.h" 24 | 25 | #define MAXFACTORS 32 26 | /* e.g. an fft of length 128 has 4 factors 27 | as far as kissfft is concerned 28 | 4*4*4*2 29 | */ 30 | 31 | struct kiss_fft_state{ 32 | int nfft; 33 | int inverse; 34 | int factors[2*MAXFACTORS]; 35 | kiss_fft_cpx twiddles[1]; 36 | }; 37 | 38 | /* 39 | Explanation of macros dealing with complex math: 40 | 41 | C_MUL(m,a,b) : m = a*b 42 | C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise 43 | C_SUB( res, a,b) : res = a - b 44 | C_SUBFROM( res , a) : res -= a 45 | C_ADDTO( res , a) : res += a 46 | * */ 47 | #ifdef FIXED_POINT 48 | #include "arch.h" 49 | # define FRACBITS 15 50 | # define SAMPPROD spx_int32_t 51 | #define SAMP_MAX 32767 52 | 53 | #define SAMP_MIN -SAMP_MAX 54 | 55 | #if defined(CHECK_OVERFLOW) 56 | # define CHECK_OVERFLOW_OP(a,op,b) \ 57 | if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \ 58 | fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); } 59 | #endif 60 | 61 | 62 | # define smul(a,b) ( (SAMPPROD)(a)*(b) ) 63 | # define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS ) 64 | 65 | # define S_MUL(a,b) sround( smul(a,b) ) 66 | 67 | # define C_MUL(m,a,b) \ 68 | do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \ 69 | (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0) 70 | 71 | # define C_MUL4(m,a,b) \ 72 | do{ (m).r = PSHR32( smul((a).r,(b).r) - smul((a).i,(b).i),17 ); \ 73 | (m).i = PSHR32( smul((a).r,(b).i) + smul((a).i,(b).r),17 ); }while(0) 74 | 75 | # define DIVSCALAR(x,k) \ 76 | (x) = sround( smul( x, SAMP_MAX/k ) ) 77 | 78 | # define C_FIXDIV(c,div) \ 79 | do { DIVSCALAR( (c).r , div); \ 80 | DIVSCALAR( (c).i , div); }while (0) 81 | 82 | # define C_MULBYSCALAR( c, s ) \ 83 | do{ (c).r = sround( smul( (c).r , s ) ) ;\ 84 | (c).i = sround( smul( (c).i , s ) ) ; }while(0) 85 | 86 | #else /* not FIXED_POINT*/ 87 | 88 | # define S_MUL(a,b) ( (a)*(b) ) 89 | #define C_MUL(m,a,b) \ 90 | do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ 91 | (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) 92 | 93 | #define C_MUL4(m,a,b) C_MUL(m,a,b) 94 | 95 | # define C_FIXDIV(c,div) /* NOOP */ 96 | # define C_MULBYSCALAR( c, s ) \ 97 | do{ (c).r *= (s);\ 98 | (c).i *= (s); }while(0) 99 | #endif 100 | 101 | #ifndef CHECK_OVERFLOW_OP 102 | # define CHECK_OVERFLOW_OP(a,op,b) /* noop */ 103 | #endif 104 | 105 | #define C_ADD( res, a,b)\ 106 | do { \ 107 | CHECK_OVERFLOW_OP((a).r,+,(b).r)\ 108 | CHECK_OVERFLOW_OP((a).i,+,(b).i)\ 109 | (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ 110 | }while(0) 111 | #define C_SUB( res, a,b)\ 112 | do { \ 113 | CHECK_OVERFLOW_OP((a).r,-,(b).r)\ 114 | CHECK_OVERFLOW_OP((a).i,-,(b).i)\ 115 | (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ 116 | }while(0) 117 | #define C_ADDTO( res , a)\ 118 | do { \ 119 | CHECK_OVERFLOW_OP((res).r,+,(a).r)\ 120 | CHECK_OVERFLOW_OP((res).i,+,(a).i)\ 121 | (res).r += (a).r; (res).i += (a).i;\ 122 | }while(0) 123 | 124 | #define C_SUBFROM( res , a)\ 125 | do {\ 126 | CHECK_OVERFLOW_OP((res).r,-,(a).r)\ 127 | CHECK_OVERFLOW_OP((res).i,-,(a).i)\ 128 | (res).r -= (a).r; (res).i -= (a).i; \ 129 | }while(0) 130 | 131 | 132 | #ifdef FIXED_POINT 133 | # define KISS_FFT_COS(phase) floor(MIN(32767,MAX(-32767,.5+32768 * cos (phase)))) 134 | # define KISS_FFT_SIN(phase) floor(MIN(32767,MAX(-32767,.5+32768 * sin (phase)))) 135 | # define HALF_OF(x) ((x)>>1) 136 | #elif defined(USE_SIMD) 137 | # define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) ) 138 | # define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) ) 139 | # define HALF_OF(x) ((x)*_mm_set1_ps(.5)) 140 | #else 141 | # define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase) 142 | # define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase) 143 | # define HALF_OF(x) ((x)*.5) 144 | #endif 145 | 146 | #define kf_cexp(x,phase) \ 147 | do{ \ 148 | (x)->r = KISS_FFT_COS(phase);\ 149 | (x)->i = KISS_FFT_SIN(phase);\ 150 | }while(0) 151 | #define kf_cexp2(x,phase) \ 152 | do{ \ 153 | (x)->r = spx_cos_norm((phase));\ 154 | (x)->i = spx_cos_norm((phase)-32768);\ 155 | }while(0) 156 | 157 | 158 | /* a debugging function */ 159 | #define pcpx(c)\ 160 | fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) ) 161 | -------------------------------------------------------------------------------- /tmv/_kiss_fft_guts_tm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2007 Hong Zhiqian */ 2 | /** 3 | @file _kiss_fft_guts_tm.h 4 | @author Hong Zhiqian 5 | @brief Various compatibility routines for Speex (TriMedia version) 6 | */ 7 | /* 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions 10 | are met: 11 | 12 | - Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | - Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | - Neither the name of the Xiph.org Foundation nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #ifndef _KISS_FFT_GUTS_TM_ 37 | #define _KISS_FFT_GUTS_TM_ 38 | 39 | #ifdef TM_ASM 40 | 41 | #include 42 | 43 | #ifdef FIXED_POINT 44 | 45 | #undef sround 46 | #define sround(x) sex16(((x) + (1<<(FRACBITS-1)) ) >> FRACBITS) 47 | 48 | #undef MIN 49 | #undef MAX 50 | #define MIN(a,b) imin(a,b) 51 | #define MAX(a,b) imax(a,b) 52 | 53 | #define TM_MUL(res,a,b) \ 54 | { register int a0, a1, b0, b1; \ 55 | \ 56 | a0 = sex16((a)); \ 57 | a1 = asri(16,(a)); \ 58 | b0 = sex16((b)); \ 59 | b1 = asri(16,(b)); \ 60 | (res)= pack16lsb( \ 61 | sround(ifir16((a),funshift2((b),(b)))), \ 62 | sround(a0*b0-a1*b1)); \ 63 | } \ 64 | 65 | #define TM_ADD(res,a,b) \ 66 | { (res)=dspidualadd((a),(b)); \ 67 | } \ 68 | 69 | #define TM_SUB(res,a,b) \ 70 | { (res)=dspidualsub((a),(b)); \ 71 | } \ 72 | 73 | #define TM_SHR(res,a,shift) \ 74 | { (res)=dualasr((a),(shift)); \ 75 | } \ 76 | 77 | #define TM_DIV(res,c,frac) \ 78 | { register int c1, c0; \ 79 | \ 80 | c1 = asri(16,(c)); \ 81 | c0 = sex16((c)); \ 82 | (res) = pack16lsb(sround(c1 * (32767/(frac))), sround(c0 * (32767/(frac))));\ 83 | } \ 84 | 85 | #define TM_NEGMSB(res, a) \ 86 | { (res) = pack16lsb((ineg(asri(16,(a)))), (a)); \ 87 | } \ 88 | 89 | #else 90 | 91 | #undef MIN 92 | #undef MAX 93 | #define MIN(a,b) fmin(a,b) 94 | #define MAX(a,b) fmax(a,b) 95 | 96 | #endif 97 | #endif 98 | 99 | #undef CHECKBUF 100 | #define CHECKBUF(buf,nbuf,n) \ 101 | { \ 102 | if ( nbuf < (size_t)(n) ) { \ 103 | speex_free(buf); \ 104 | buf = (kiss_fft_cpx*)KISS_FFT_MALLOC(sizeof(kiss_fft_cpx)*(n)); \ 105 | nbuf = (size_t)(n); \ 106 | } \ 107 | } \ 108 | 109 | #undef C_ADD 110 | #define C_ADD( res, a,b) \ 111 | { \ 112 | CHECK_OVERFLOW_OP((a).r,+,(b).r) \ 113 | CHECK_OVERFLOW_OP((a).i,+,(b).i) \ 114 | (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ 115 | } \ 116 | 117 | 118 | #undef C_SUB 119 | #define C_SUB( res, a,b) \ 120 | { \ 121 | CHECK_OVERFLOW_OP((a).r,-,(b).r) \ 122 | CHECK_OVERFLOW_OP((a).i,-,(b).i) \ 123 | (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ 124 | } \ 125 | 126 | #undef C_ADDTO 127 | #define C_ADDTO( res , a) \ 128 | { \ 129 | CHECK_OVERFLOW_OP((res).r,+,(a).r) \ 130 | CHECK_OVERFLOW_OP((res).i,+,(a).i) \ 131 | (res).r += (a).r; (res).i += (a).i; \ 132 | } \ 133 | 134 | #undef C_SUBFROM 135 | #define C_SUBFROM( res, a) \ 136 | { \ 137 | CHECK_OVERFLOW_OP((res).r,-,(a).r) \ 138 | CHECK_OVERFLOW_OP((res).i,-,(a).i) \ 139 | (res).r -= (a).r; (res).i -= (a).i; \ 140 | } \ 141 | 142 | #undef kf_cexp 143 | #define kf_cexp(x,phase) \ 144 | { (x)->r = KISS_FFT_COS(phase); \ 145 | (x)->i = KISS_FFT_SIN(phase); } \ 146 | 147 | #undef kf_cexp2 148 | #define kf_cexp2(x,phase) \ 149 | { (x)->r = spx_cos_norm((phase)); \ 150 | (x)->i = spx_cos_norm((phase)-32768); } \ 151 | 152 | 153 | #ifdef FIXED_POINT 154 | 155 | #undef C_MUL 156 | #define C_MUL(m,a,b) \ 157 | { (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \ 158 | (m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); } \ 159 | 160 | #undef C_FIXDIV 161 | #define C_FIXDIV(c,div) \ 162 | { DIVSCALAR( (c).r , div); \ 163 | DIVSCALAR( (c).i , div); } \ 164 | 165 | #undef C_MULBYSCALAR 166 | #define C_MULBYSCALAR( c, s ) \ 167 | { (c).r = sround( smul( (c).r , s ) ) ; \ 168 | (c).i = sround( smul( (c).i , s ) ) ; } \ 169 | 170 | #else 171 | 172 | #undef C_MUL 173 | #define C_MUL(m,a,b) \ 174 | { (m).r = (a).r*(b).r - (a).i*(b).i; \ 175 | (m).i = (a).r*(b).i + (a).i*(b).r; } \ 176 | 177 | 178 | #undef C_MULBYSCALAR 179 | #define C_MULBYSCALAR( c, s ) \ 180 | { (c).r *= (s); \ 181 | (c).i *= (s); } \ 182 | 183 | 184 | 185 | #endif 186 | 187 | #endif 188 | 189 | -------------------------------------------------------------------------------- /win32/libspeexdsp/libspeexdsp.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="libspeexdsp" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=libspeexdsp - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "libspeexdsp.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "libspeexdsp.mak" CFG="libspeexdsp - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "libspeexdsp - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "libspeexdsp - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "libspeexdsp - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | F90=df.exe 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 45 | # ADD CPP /nologo /MD /W1 /GX- /O2 /I "../../include" /I "../" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "HAVE_CONFIG_H" /FD /c 46 | # SUBTRACT CPP /YX 47 | # ADD BASE RSC /l 0x419 /d "NDEBUG" 48 | # ADD RSC /l 0x809 /d "NDEBUG" 49 | BSC32=bscmake.exe 50 | # ADD BASE BSC32 /nologo 51 | # ADD BSC32 /nologo 52 | LIB32=link.exe -lib 53 | # ADD BASE LIB32 /nologo 54 | # ADD LIB32 /nologo /out:"..\..\lib\libspeexdsp.lib" 55 | 56 | !ELSEIF "$(CFG)" == "libspeexdsp - Win32 Debug" 57 | 58 | # PROP BASE Use_MFC 0 59 | # PROP BASE Use_Debug_Libraries 1 60 | # PROP BASE Output_Dir "libspeexdsp___Win32_Debug" 61 | # PROP BASE Intermediate_Dir "libspeexdsp___Win32_Debug" 62 | # PROP BASE Target_Dir "" 63 | # PROP Use_MFC 0 64 | # PROP Use_Debug_Libraries 1 65 | # PROP Output_Dir "libspeexdsp___Win32_Debug" 66 | # PROP Intermediate_Dir "libspeexdsp___Win32_Debug" 67 | # PROP Target_Dir "" 68 | F90=df.exe 69 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 70 | # ADD CPP /nologo /MDd /W3 /Gm- /GX- /Zi /Od /I "../../include" /I "../" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "HAVE_CONFIG_H" /FD /GZ /c 71 | # SUBTRACT CPP /YX 72 | # ADD BASE RSC /l 0x419 /d "_DEBUG" 73 | # ADD RSC /l 0x809 /d "_DEBUG" 74 | BSC32=bscmake.exe 75 | # ADD BASE BSC32 /nologo 76 | # ADD BSC32 /nologo 77 | LIB32=link.exe -lib 78 | # ADD BASE LIB32 /nologo 79 | # ADD LIB32 /nologo /out:"..\..\lib\libspeexdsp.lib" 80 | 81 | !ENDIF 82 | 83 | # Begin Target 84 | 85 | # Name "libspeexdsp - Win32 Release" 86 | # Name "libspeexdsp - Win32 Debug" 87 | # Begin Group "Source Files" 88 | 89 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 90 | # Begin Source File 91 | 92 | SOURCE=..\..\libspeex\buffer.c 93 | # End Source File 94 | # Begin Source File 95 | 96 | SOURCE=..\..\libspeex\fftwrap.c 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=..\..\libspeex\filterbank.c 101 | # End Source File 102 | # Begin Source File 103 | 104 | SOURCE=..\..\libspeex\jitter.c 105 | # End Source File 106 | # Begin Source File 107 | 108 | SOURCE=..\..\libspeex\kiss_fft.c 109 | # End Source File 110 | # Begin Source File 111 | 112 | SOURCE=..\..\libspeex\kiss_fftr.c 113 | # End Source File 114 | # Begin Source File 115 | 116 | SOURCE=..\..\libspeex\mdf.c 117 | # End Source File 118 | # Begin Source File 119 | 120 | SOURCE=..\..\libspeex\preprocess.c 121 | # End Source File 122 | # Begin Source File 123 | 124 | SOURCE=..\..\libspeex\resample.c 125 | # End Source File 126 | # Begin Source File 127 | 128 | SOURCE=..\..\libspeex\scal.c 129 | # End Source File 130 | # Begin Source File 131 | 132 | SOURCE=..\..\libspeex\smallft.c 133 | # End Source File 134 | # End Group 135 | # Begin Group "Header Files" 136 | 137 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 138 | # Begin Source File 139 | 140 | SOURCE=..\..\libspeex\_kiss_fft_guts.h 141 | # End Source File 142 | # Begin Source File 143 | 144 | SOURCE=..\..\libspeex\arch.h 145 | # End Source File 146 | # Begin Source File 147 | 148 | SOURCE=..\..\libspeex\fftwrap.h 149 | # End Source File 150 | # Begin Source File 151 | 152 | SOURCE=..\..\libspeex\filterbank.h 153 | # End Source File 154 | # Begin Source File 155 | 156 | SOURCE=..\..\libspeex\fixed_debug.h 157 | # End Source File 158 | # Begin Source File 159 | 160 | SOURCE=..\..\libspeex\fixed_generic.h 161 | # End Source File 162 | # Begin Source File 163 | 164 | SOURCE=..\..\libspeex\kiss_fft.h 165 | # End Source File 166 | # Begin Source File 167 | 168 | SOURCE=..\..\libspeex\kiss_fftr.h 169 | # End Source File 170 | # Begin Source File 171 | 172 | SOURCE=..\..\libspeex\math_approx.h 173 | # End Source File 174 | # Begin Source File 175 | 176 | SOURCE=..\..\libspeex\os_support.h 177 | # End Source File 178 | # Begin Source File 179 | 180 | SOURCE=..\..\libspeex\pseudofloat.h 181 | # End Source File 182 | # Begin Source File 183 | 184 | SOURCE=..\..\libspeex\smallft.h 185 | # End Source File 186 | # End Group 187 | # Begin Group "Public Header Files" 188 | 189 | # PROP Default_Filter "" 190 | # Begin Source File 191 | 192 | SOURCE=..\..\include\speex\speex.h 193 | # End Source File 194 | # Begin Source File 195 | 196 | SOURCE=..\..\include\speex\speex_bits.h 197 | # End Source File 198 | # Begin Source File 199 | 200 | SOURCE=..\..\include\speex\speex_buffer.h 201 | # End Source File 202 | # Begin Source File 203 | 204 | SOURCE=..\..\include\speex\speex_echo.h 205 | # End Source File 206 | # Begin Source File 207 | 208 | SOURCE=..\..\include\speex\speex_jitter.h 209 | # End Source File 210 | # Begin Source File 211 | 212 | SOURCE=..\..\include\speex\speex_preprocess.h 213 | # End Source File 214 | # Begin Source File 215 | 216 | SOURCE=..\..\include\speex\speex_resampler.h 217 | # End Source File 218 | # Begin Source File 219 | 220 | SOURCE=..\..\include\speex\speex_types.h 221 | # End Source File 222 | # End Group 223 | # Begin Source File 224 | 225 | SOURCE=..\config.h 226 | # End Source File 227 | # End Target 228 | # End Project 229 | -------------------------------------------------------------------------------- /win32/VS2003/tests/testecho.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 32 | 34 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 65 | 72 | 91 | 93 | 105 | 107 | 109 | 111 | 113 | 115 | 117 | 119 | 121 | 123 | 125 | 126 | 133 | 153 | 155 | 167 | 169 | 171 | 173 | 175 | 177 | 179 | 181 | 183 | 185 | 187 | 188 | 189 | 190 | 191 | 192 | 196 | 198 | 199 | 200 | 204 | 205 | 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /win32/VS2003/tests/testdenoise.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 32 | 34 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 65 | 72 | 91 | 93 | 105 | 107 | 109 | 111 | 113 | 115 | 117 | 119 | 121 | 123 | 125 | 126 | 133 | 153 | 155 | 167 | 169 | 171 | 173 | 175 | 177 | 179 | 181 | 183 | 185 | 187 | 188 | 189 | 190 | 191 | 192 | 196 | 198 | 199 | 200 | 204 | 205 | 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /win32/VS2003/tests/testresample.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 32 | 34 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 65 | 72 | 91 | 93 | 105 | 107 | 109 | 111 | 113 | 115 | 117 | 119 | 121 | 123 | 125 | 126 | 133 | 153 | 155 | 167 | 169 | 171 | 173 | 175 | 177 | 179 | 181 | 183 | 185 | 187 | 188 | 189 | 190 | 191 | 192 | 196 | 198 | 199 | 200 | 204 | 205 | 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /include/speex/speex_echo.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) Jean-Marc Valin */ 2 | /** 3 | @file speex_echo.h 4 | @brief Echo cancellation 5 | */ 6 | /* 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | 18 | 3. The name of the author may not be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef SPEEX_ECHO_H 35 | #define SPEEX_ECHO_H 36 | /** @defgroup SpeexEchoState SpeexEchoState: Acoustic echo canceller 37 | * This is the acoustic echo canceller module. 38 | * @{ 39 | */ 40 | #include "speexdsp_types.h" 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | /** Obtain frame size used by the AEC */ 47 | #define SPEEX_ECHO_GET_FRAME_SIZE 3 48 | 49 | /** Set sampling rate */ 50 | #define SPEEX_ECHO_SET_SAMPLING_RATE 24 51 | /** Get sampling rate */ 52 | #define SPEEX_ECHO_GET_SAMPLING_RATE 25 53 | 54 | /* Can't set window sizes */ 55 | /** Get size of impulse response (int32) */ 56 | #define SPEEX_ECHO_GET_IMPULSE_RESPONSE_SIZE 27 57 | 58 | /* Can't set window content */ 59 | /** Get impulse response (int32[]) */ 60 | #define SPEEX_ECHO_GET_IMPULSE_RESPONSE 29 61 | 62 | /** Internal echo canceller state. Should never be accessed directly. */ 63 | struct SpeexEchoState_; 64 | 65 | /** @class SpeexEchoState 66 | * This holds the state of the echo canceller. You need one per channel. 67 | */ 68 | 69 | /** Internal echo canceller state. Should never be accessed directly. */ 70 | typedef struct SpeexEchoState_ SpeexEchoState; 71 | 72 | /** Creates a new echo canceller state 73 | * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms) 74 | * @param filter_length Number of samples of echo to cancel (should generally correspond to 100-500 ms) 75 | * @return Newly-created echo canceller state 76 | */ 77 | SpeexEchoState *speex_echo_state_init(int frame_size, int filter_length); 78 | 79 | /** Creates a new multi-channel echo canceller state 80 | * @param frame_size Number of samples to process at one time (should correspond to 10-20 ms) 81 | * @param filter_length Number of samples of echo to cancel (should generally correspond to 100-500 ms) 82 | * @param nb_mic Number of microphone channels 83 | * @param nb_speakers Number of speaker channels 84 | * @return Newly-created echo canceller state 85 | */ 86 | SpeexEchoState *speex_echo_state_init_mc(int frame_size, int filter_length, int nb_mic, int nb_speakers); 87 | 88 | /** Destroys an echo canceller state 89 | * @param st Echo canceller state 90 | */ 91 | void speex_echo_state_destroy(SpeexEchoState *st); 92 | 93 | /** Performs echo cancellation a frame, based on the audio sent to the speaker (no delay is added 94 | * to playback in this form) 95 | * 96 | * @param st Echo canceller state 97 | * @param rec Signal from the microphone (near end + far end echo) 98 | * @param play Signal played to the speaker (received from far end) 99 | * @param out Returns near-end signal with echo removed 100 | */ 101 | void speex_echo_cancellation(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out); 102 | 103 | /** Performs echo cancellation a frame (deprecated) */ 104 | void speex_echo_cancel(SpeexEchoState *st, const spx_int16_t *rec, const spx_int16_t *play, spx_int16_t *out, spx_int32_t *Yout); 105 | 106 | /** Perform echo cancellation using internal playback buffer, which is delayed by two frames 107 | * to account for the delay introduced by most soundcards (but it could be off!) 108 | * @param st Echo canceller state 109 | * @param rec Signal from the microphone (near end + far end echo) 110 | * @param out Returns near-end signal with echo removed 111 | */ 112 | void speex_echo_capture(SpeexEchoState *st, const spx_int16_t *rec, spx_int16_t *out); 113 | 114 | /** Let the echo canceller know that a frame was just queued to the soundcard 115 | * @param st Echo canceller state 116 | * @param play Signal played to the speaker (received from far end) 117 | */ 118 | void speex_echo_playback(SpeexEchoState *st, const spx_int16_t *play); 119 | 120 | /** Reset the echo canceller to its original state 121 | * @param st Echo canceller state 122 | */ 123 | void speex_echo_state_reset(SpeexEchoState *st); 124 | 125 | /** Used like the ioctl function to control the echo canceller parameters 126 | * 127 | * @param st Echo canceller state 128 | * @param request ioctl-type request (one of the SPEEX_ECHO_* macros) 129 | * @param ptr Data exchanged to-from function 130 | * @return 0 if no error, -1 if request in unknown 131 | */ 132 | int speex_echo_ctl(SpeexEchoState *st, int request, void *ptr); 133 | 134 | 135 | 136 | struct SpeexDecorrState_; 137 | 138 | typedef struct SpeexDecorrState_ SpeexDecorrState; 139 | 140 | 141 | /** Create a state for the channel decorrelation algorithm 142 | This is useful for multi-channel echo cancellation only 143 | * @param rate Sampling rate 144 | * @param channels Number of channels (it's a bit pointless if you don't have at least 2) 145 | * @param frame_size Size of the frame to process at ones (counting samples *per* channel) 146 | */ 147 | SpeexDecorrState *speex_decorrelate_new(int rate, int channels, int frame_size); 148 | 149 | /** Remove correlation between the channels by modifying the phase and possibly 150 | adding noise in a way that is not (or little) perceptible. 151 | * @param st Decorrelator state 152 | * @param in Input audio in interleaved format 153 | * @param out Result of the decorrelation (out *may* alias in) 154 | * @param strength How much alteration of the audio to apply from 0 to 100. 155 | */ 156 | void speex_decorrelate(SpeexDecorrState *st, const spx_int16_t *in, spx_int16_t *out, int strength); 157 | 158 | /** Destroy a Decorrelation state 159 | * @param st State to destroy 160 | */ 161 | void speex_decorrelate_destroy(SpeexDecorrState *st); 162 | 163 | 164 | #ifdef __cplusplus 165 | } 166 | #endif 167 | 168 | 169 | /** @}*/ 170 | #endif 171 | --------------------------------------------------------------------------------