mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-04 19:31:56 +00:00
i've tested, now you can too
This commit is contained in:
@@ -484,8 +484,8 @@ convey the exclusion of warranty; and each file should have at least the
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
License along with this library; if not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
|
||||
@@ -1,236 +0,0 @@
|
||||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that the
|
||||
`configure' script does not know about. Run `./configure --help' for
|
||||
details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' installs the package's commands under
|
||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||
can specify an installation prefix other than `/usr/local' by giving
|
||||
`configure' the option `--prefix=PREFIX'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out automatically,
|
||||
but needs to determine by the type of machine the package will run on.
|
||||
Usually, assuming the package is built to be run on the _same_
|
||||
architectures, `configure' can figure that out, but if it prints a
|
||||
message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the option `--target=TYPE' to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share, you
|
||||
can create a site shell script called `config.site' that gives default
|
||||
values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||
overridden in the site shell script). Here is a another example:
|
||||
|
||||
/bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
|
||||
configuration-related scripts to be executed by `/bin/bash'.
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
|
||||
+14
-18
@@ -1,11 +1,9 @@
|
||||
AM_CFLAGS = -Isrc -Wall -lm
|
||||
AUTOMAKE_OPTIONS = gnu
|
||||
NAME = libcodec2
|
||||
AM_CFLAGS = -Isrc -fPIC -Wall -O3 -lm
|
||||
AUTOMAKE_OPTS = gnu
|
||||
NAME = codec2
|
||||
AM_CPPFLAGS = $(AM_CFLAGS)
|
||||
|
||||
EXTRA_DIST = pitch/hts1a.p \
|
||||
pitch/hts2a.p \
|
||||
octave/glottal.m \
|
||||
EXTRA_DIST = octave/glottal.m \
|
||||
octave/lsp_pdf.m \
|
||||
octave/phase.m \
|
||||
octave/pl2.m \
|
||||
@@ -68,11 +66,6 @@ wav/hts2a_g729a.wav \
|
||||
wav/m2400.wav \
|
||||
wav/morig_speex_8k.wav \
|
||||
src/globals.c \
|
||||
doc/A_m.gif \
|
||||
doc/omega_0.gif \
|
||||
doc/phi_m.gif \
|
||||
doc/s_n.gif \
|
||||
doc/s_n.txt \
|
||||
unittest/lsp2.txt \
|
||||
unittest/lsp7.txt \
|
||||
unittest/lspd78.txt \
|
||||
@@ -87,12 +80,15 @@ unittest/lspd123.txt \
|
||||
unittest/lsp1.txt \
|
||||
unittest/lsp6.txt \
|
||||
unittest/lspd456.txt \
|
||||
src/codeall.sh \
|
||||
src/fq20.sh \
|
||||
src/listen1.sh \
|
||||
src/listen.sh \
|
||||
src/listensim.sh \
|
||||
src/sim.sh
|
||||
|
||||
src/codebook/lsp1.txt \
|
||||
src/codebook/lsp2.txt \
|
||||
src/codebook/lsp3.txt \
|
||||
src/codebook/lsp4.txt \
|
||||
src/codebook/lsp5.txt \
|
||||
src/codebook/lsp6.txt \
|
||||
src/codebook/lsp7.txt \
|
||||
src/codebook/lsp8.txt \
|
||||
src/codebook/lsp9.txt \
|
||||
src/codebook/lsp10.txt
|
||||
|
||||
SUBDIRS = src unittest
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
Codec 2 README
|
||||
--------------
|
||||
|
||||
Codec 2 is an open source (LGPL licensed) speech codec for 2400 bit/s
|
||||
and below. For more information please see:
|
||||
|
||||
http://rowetel.com/codec2.html
|
||||
|
||||
Also included is a FDMDV modem, see README_fdmdv.txt
|
||||
|
||||
Quickstart
|
||||
----------
|
||||
|
||||
1/ Listen to Codec 2:
|
||||
|
||||
$ ./configure && make
|
||||
$ cd src
|
||||
$ ./c2demo ../raw/hts1a.raw hts1a_c2.raw
|
||||
$ ../script/menu.sh ../raw/hts1a.raw hts1a_c2.raw
|
||||
|
||||
NOTE: For playback testing, menu.sh requires either the 'play',
|
||||
'aplay' or 'ossplay' programs to be installed (see
|
||||
http://sox.sourceforge.net/, http://www.alsa-project.org/, or
|
||||
http://www.opensound.com/ respectively).
|
||||
|
||||
2/ Compress and Decompress a file:
|
||||
|
||||
$ ./c2enc 2400 ../raw/hts1a.raw hts1a_c2.bit
|
||||
$ ./c2dec 2400 hts1a_c2.bit hts1a_c2.raw
|
||||
|
||||
3/ Same thing with pipes:
|
||||
|
||||
$ ./c2enc 1400 ../raw/hts1a.raw - | ./c2dec 1400 - - | play -t raw -r 8000 -s -2 -
|
||||
|
||||
Programs
|
||||
--------
|
||||
|
||||
1/ c2demo encodes a file of speech samples, then decodes them and
|
||||
saves the result.
|
||||
|
||||
2/ c2enc encodes a file of speech samples to a compressed file of
|
||||
encoded bits.
|
||||
|
||||
3/ c2dec decodes a compressed file of bits to a file of speech
|
||||
samples.
|
||||
|
||||
4/ c2sim is a simulation/development version of Codec 2. It allows
|
||||
selective use of the various Codec 2 algorithms. For example
|
||||
switching phase modelling or LSP quantisation on and off.
|
||||
|
||||
Debugging
|
||||
---------
|
||||
|
||||
1/ For dump file support:
|
||||
|
||||
$ cd codec2
|
||||
$ CFLAGS=-DDUMP ./configure
|
||||
$ make clean && make
|
||||
|
||||
2/ To use gdb:
|
||||
|
||||
$ libtool --mode=execute gdb c2sim
|
||||
|
||||
Directories
|
||||
-----------
|
||||
|
||||
fltk - FLTK GUI programs(s)
|
||||
octave - Octave scripts used for visualising internal signals
|
||||
during development
|
||||
portaudio - Portaudio test programs
|
||||
script - shell scripts for playing and converting raw files
|
||||
src - C source code
|
||||
raw - speech files in raw format (16 bits signed linear 8 kHz)
|
||||
unittest - unit test source code
|
||||
voicing - hand-estimated voicing files, used for development
|
||||
wav - speech files in wave file format
|
||||
win32 - Support for building Windows DLL version of Codec 2 and FDMDV libraries
|
||||
|
||||
TODO
|
||||
----
|
||||
|
||||
[ ] Get win32/Makefile integrated into Automake system, such that if
|
||||
i586-mingw32msvc exists the Win32 code gets automatically built.
|
||||
[ ] Same for fltk & portaudio, build these conditionally if libs exist
|
||||
@@ -2,8 +2,8 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.59])
|
||||
AC_INIT(libcodec2, 1.0, david@rowetel.com)
|
||||
AM_INIT_AUTOMAKE(libcodec2,1.0)
|
||||
AC_INIT(codec2, 0.2, david@rowetel.com)
|
||||
AM_INIT_AUTOMAKE(codec2,0.2)
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
|
||||
@@ -11,13 +11,17 @@ kexc = [ 8, -16, 26, -48, 86, -162, 294, -502, 718, -728, 184 672, -610, -67
|
||||
kexc = shift(kexc,sh);
|
||||
kexc = [kexc(1:sh) zeros(1,512-25) kexc(sh+1:25)];
|
||||
figure(1)
|
||||
clf
|
||||
plot(kexc)
|
||||
figure(2)
|
||||
G = fft(kexc);
|
||||
subplot(211)
|
||||
plot((1:256)*(4000/256),unwrap(angle(G(1:256))))
|
||||
subplot(212)
|
||||
plot(20*log10(abs(G)))
|
||||
|
||||
f=fopen("glottal.c","wt");
|
||||
fprintf(f,"float glottal[]={\n");
|
||||
fprintf(f,"const float glottal[]={\n");
|
||||
for m=1:255
|
||||
fprintf(f," %f,\n",angle(G(m)));
|
||||
endfor
|
||||
|
||||
@@ -7,14 +7,19 @@ function lsp_pdf(lsp)
|
||||
|
||||
% LSPs
|
||||
|
||||
figure(3);
|
||||
figure(1);
|
||||
clf;
|
||||
[x,y] = hist(lsp(:,1),100);
|
||||
plot(y*4000/pi,x,";1;");
|
||||
plot(y*4000/pi,x,"+;1;");
|
||||
hold on;
|
||||
for i=2:c
|
||||
for i=2:5
|
||||
[x,y] = hist(lsp(:,i),100);
|
||||
legend = sprintf(";%d;",i);
|
||||
legend = sprintf("+%d;%d;",i,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
endfor
|
||||
for i=6:c
|
||||
[x,y] = hist(lsp(:,i),100);
|
||||
legend = sprintf("+%d;%d;",i-5,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
endfor
|
||||
hold off;
|
||||
@@ -22,29 +27,65 @@ function lsp_pdf(lsp)
|
||||
|
||||
% LSP differences
|
||||
|
||||
figure(4);
|
||||
figure(2);
|
||||
clf;
|
||||
subplot(211)
|
||||
[x,y] = hist(lsp(:,1),100);
|
||||
plot(y,x,";1;");
|
||||
plot(y*4000/pi,x,"1;1;");
|
||||
hold on;
|
||||
for i=2:5
|
||||
[x,y] = hist(lsp(:,i) - lsp(:,i-1),100);
|
||||
legend = sprintf(";%d;",i);
|
||||
plot(y,x,legend);
|
||||
legend = sprintf("%d;%d;",i,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
endfor
|
||||
hold off;
|
||||
grid;
|
||||
|
||||
subplot(212)
|
||||
[x,y] = hist(lsp(:,6)-lsp(:,5),100);
|
||||
plot(y,x,";6;");
|
||||
plot(y*4000/pi,x,"1;6;");
|
||||
hold on;
|
||||
for i=7:c
|
||||
[x,y] = hist(lsp(:,i) - lsp(:,i-1),100);
|
||||
legend = sprintf(";%d;",i);
|
||||
plot(y,x,legend);
|
||||
legend = sprintf("%d;%d;",i-5,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
endfor
|
||||
hold off;
|
||||
grid;
|
||||
|
||||
% LSP differences delta from last frame
|
||||
|
||||
lspd(:,1) = lsp(:,1);
|
||||
lspd(:,2:10) = lsp(:,2:10) - lsp(:,1:9);
|
||||
|
||||
[m,n] = size(lspd);
|
||||
lspdd = lspd(5:m,:) - lspd(1:m-4,:);
|
||||
|
||||
figure(3);
|
||||
clf;
|
||||
subplot(211)
|
||||
for i=1:5
|
||||
[x,y] = hist(lspdd(:,i),100);
|
||||
legend = sprintf("%d;%d;",i,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
hold on;
|
||||
endfor
|
||||
hold off;
|
||||
grid;
|
||||
axis([-200 200 0 35000]);
|
||||
|
||||
subplot(212)
|
||||
for i=6:10
|
||||
[x,y] = hist(lspdd(:,i),100);
|
||||
legend = sprintf("%d;%d;",i-5,i);
|
||||
plot(y*4000/pi,x,legend);
|
||||
hold on;
|
||||
endfor
|
||||
hold off;
|
||||
grid;
|
||||
axis([-200 200 0 16000]);
|
||||
|
||||
figure(4);
|
||||
clf;
|
||||
plot((4000/pi)*(lsp(2:r,3)-lsp(1:r-1,3)))
|
||||
endfunction
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
function phase2(samname, png)
|
||||
N = 16000;
|
||||
|
||||
f=45;
|
||||
model = load("../src/hts1a_model.txt");
|
||||
f=43;
|
||||
model = load("../src/hts1a_phase_model.txt");
|
||||
phase = load("../src/hts1a_phase_phase.txt");
|
||||
Wo = model(f,1);
|
||||
P=2*pi/Wo;
|
||||
@@ -15,13 +15,13 @@ function phase2(samname, png)
|
||||
A = model(f,3:(L+2));
|
||||
phi = phase(f,1:L);
|
||||
phi = zeros(1,L);
|
||||
for m=L/2:L
|
||||
phi(m) = 2*pi*rand(1,1);
|
||||
end
|
||||
phi(3) = -pi/2;
|
||||
phi(4) = -pi/4;
|
||||
phi(5) = pi/2;
|
||||
|
||||
s = zeros(1,N);
|
||||
|
||||
for m=1:L
|
||||
for m=3:5
|
||||
s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m));
|
||||
s = s + s_m;
|
||||
endfor
|
||||
@@ -30,6 +30,13 @@ function phase2(samname, png)
|
||||
clf;
|
||||
plot(s(1:250));
|
||||
|
||||
figure(2);
|
||||
clf;
|
||||
subplot(211)
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(A),'+');
|
||||
subplot(212)
|
||||
plot((1:L)*Wo*4000/pi, phi,'+');
|
||||
|
||||
fs=fopen(samname,"wb");
|
||||
fwrite(fs,s,"short");
|
||||
fclose(fs);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
% Copyright David Rowe 2009
|
||||
% This program is distributed under the terms of the GNU General Public License
|
||||
% Version 2
|
||||
%
|
||||
% Plots a raw speech sample file, you can optionally specify the start and end
|
||||
% samples and create a large and small PNGs
|
||||
|
||||
function pl(samname1, start_sam, end_sam, pngname)
|
||||
|
||||
@@ -19,7 +22,7 @@ function pl(samname1, start_sam, end_sam, pngname)
|
||||
figure(1);
|
||||
clf;
|
||||
plot(s(st:en));
|
||||
axis([1 en-st min(s) max(s)]);
|
||||
axis([1 en-st 1.1*min(s) 1.1*max(s)]);
|
||||
|
||||
if (nargin == 4)
|
||||
|
||||
|
||||
@@ -4,8 +4,16 @@
|
||||
%
|
||||
% Plot ampltiude modelling information from dump files.
|
||||
|
||||
function plamp(samname, f)
|
||||
function plamp(samname, f, samname2)
|
||||
|
||||
% switch some stuff off to unclutter display
|
||||
|
||||
plot_lsp = 0;
|
||||
plot_snr = 0;
|
||||
plot_vsnr = 0;
|
||||
plot_sw = 0;
|
||||
plot_pw = 0;
|
||||
|
||||
sn_name = strcat(samname,"_sn.txt");
|
||||
Sn = load(sn_name);
|
||||
|
||||
@@ -17,6 +25,16 @@ function plamp(samname, f)
|
||||
Sw_ = load(sw__name);
|
||||
endif
|
||||
|
||||
ew_name = strcat(samname,"_ew.txt");
|
||||
if (file_in_path(".",ew_name))
|
||||
Ew = load(ew_name);
|
||||
endif
|
||||
|
||||
rk_name = strcat(samname,"_rk.txt");
|
||||
if (file_in_path(".",rk_name))
|
||||
Rk = load(rk_name);
|
||||
endif
|
||||
|
||||
model_name = strcat(samname,"_model.txt");
|
||||
model = load(model_name);
|
||||
|
||||
@@ -50,12 +68,24 @@ function plamp(samname, f)
|
||||
snr = load(snr_name);
|
||||
endif
|
||||
|
||||
% optional second file, for exploring post filter
|
||||
|
||||
model2q_name = " ";
|
||||
if nargin == 3
|
||||
model2q_name = strcat(samname2,"_qmodel.txt");
|
||||
if file_in_path(".",modelq_name)
|
||||
model2q = load(model2q_name);
|
||||
end
|
||||
end
|
||||
|
||||
Ew_on = 1;
|
||||
k = ' ';
|
||||
do
|
||||
figure(1);
|
||||
clf;
|
||||
% s = [ Sn(2*(f-2)-1,:) Sn(2*(f-2),:) ];
|
||||
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
|
||||
size(s);
|
||||
plot(s);
|
||||
axis([1 length(s) -20000 20000]);
|
||||
|
||||
@@ -66,13 +96,14 @@ function plamp(samname, f)
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(Am),";Am;r");
|
||||
axis([1 4000 -10 80]);
|
||||
hold on;
|
||||
% plot((0:255)*4000/256, Sw(f-2,:),";Sw;");
|
||||
plot((0:255)*4000/256, Sw(f,:),";Sw;");
|
||||
|
||||
if plot_sw
|
||||
plot((0:255)*4000/256, Sw(f,:),";Sw;");
|
||||
end
|
||||
|
||||
if (file_in_path(".",modelq_name))
|
||||
Amq = modelq(f,3:(L+2));
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(Amq),";Amq;g" );
|
||||
if (file_in_path(".",pw_name))
|
||||
if (file_in_path(".",pw_name) && plot_pw)
|
||||
plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;c");
|
||||
endif
|
||||
signal = Am * Am';
|
||||
@@ -82,8 +113,13 @@ function plamp(samname, f)
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label);
|
||||
endif
|
||||
|
||||
if (file_in_path(".",snr_name))
|
||||
snr_label = sprintf(";phase SNR %4.2f dB;",snr(f));
|
||||
if file_in_path(".",model2q_name)
|
||||
Amq2 = model2q(f,3:(L+2));
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(Amq2),";Amq2;m" );
|
||||
end
|
||||
|
||||
if (file_in_path(".",snr_name) && plot_vsnr)
|
||||
snr_label = sprintf(";Voicing SNR %4.2f dB;",snr(f));
|
||||
plot(1,1,snr_label);
|
||||
endif
|
||||
|
||||
@@ -96,11 +132,11 @@ function plamp(samname, f)
|
||||
noise = (orig-synth) * (orig-synth)';
|
||||
snr_phase = 10*log10(signal/noise);
|
||||
|
||||
phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr_phase);
|
||||
plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
|
||||
%phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr_phase);
|
||||
%plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
|
||||
endif
|
||||
|
||||
if (file_in_path(".",lsp_name))
|
||||
if (file_in_path(".",lsp_name) && plot_lsp)
|
||||
for l=1:10
|
||||
plot([lsp(f,l)*4000/pi lsp(f,l)*4000/pi], [60 80], 'r');
|
||||
endfor
|
||||
@@ -108,33 +144,21 @@ function plamp(samname, f)
|
||||
|
||||
hold off;
|
||||
|
||||
if (file_in_path(".",phase_name))
|
||||
figure(3);
|
||||
plot((1:L)*Wo*4000/pi, phase(f,1:L), ";phase;");
|
||||
axis;
|
||||
if (file_in_path(".",phase_name_))
|
||||
hold on;
|
||||
plot((1:L)*Wo*4000/pi, phase_(f,1:L), ";phase_;");
|
||||
hold off;
|
||||
endif
|
||||
figure(2);
|
||||
endif
|
||||
|
||||
% autocorrelation function to research voicing est
|
||||
|
||||
%M = length(s);
|
||||
%sw = s .* hanning(M)';
|
||||
%for k=0:159
|
||||
% R(k+1) = sw(1:320-k) * sw(1+k:320)';
|
||||
%endfor
|
||||
%figure(4);
|
||||
%R_label = sprintf(";R(k) %3.2f;",max(R(20:159))/R(1));
|
||||
%plot(R/R(1),R_label);
|
||||
%grid
|
||||
%if (file_in_path(".",phase_name))
|
||||
%figure(3);
|
||||
%plot((1:L)*Wo*4000/pi, phase(f,1:L), ";phase;");
|
||||
%axis;
|
||||
%if (file_in_path(".",phase_name_))
|
||||
%hold on;
|
||||
%plot((1:L)*Wo*4000/pi, phase_(f,1:L), ";phase_;");
|
||||
%hold off;
|
||||
%endif
|
||||
%figure(2);
|
||||
%endif
|
||||
|
||||
% interactive menu
|
||||
|
||||
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
|
||||
printf("\rframe: %d menu: n-next b-back p-png q-quit e-toggle Ew", f);
|
||||
fflush(stdout);
|
||||
k = kbhit();
|
||||
if (k == 'n')
|
||||
@@ -143,6 +167,13 @@ function plamp(samname, f)
|
||||
if (k == 'b')
|
||||
f = f - 1;
|
||||
endif
|
||||
if (k == 'e')
|
||||
if (Ew_on == 1)
|
||||
Ew_on = 0;
|
||||
else
|
||||
Ew_on = 1;
|
||||
endif
|
||||
endif
|
||||
|
||||
% optional print to PNG
|
||||
|
||||
@@ -157,7 +188,7 @@ function plamp(samname, f)
|
||||
pngname = sprintf("%s_%d_sw.png",samname,f);
|
||||
print(pngname, '-dpng', "-S500,500")
|
||||
pngname = sprintf("%s_%d_sw_large.png",samname,f);
|
||||
print(pngname, '-dpng', "-S800,600")
|
||||
print(pngname, '-dpng', "-S1200,800")
|
||||
endif
|
||||
|
||||
until (k == 'q')
|
||||
|
||||
@@ -112,7 +112,7 @@ function plphase(samname, f)
|
||||
axis;
|
||||
if (file_in_path(".", phase_name_))
|
||||
hold on;
|
||||
plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, "g;phase_;");
|
||||
plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, "g;phase after;");
|
||||
grid
|
||||
hold off;
|
||||
endif
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
files=0
|
||||
items="Q-Quit\n"
|
||||
@@ -52,19 +51,30 @@ do
|
||||
shift
|
||||
done
|
||||
|
||||
readchar=1
|
||||
echo -n -e "\r" $items"- "
|
||||
while [ $readchar -ne 0 ]
|
||||
do
|
||||
while true ; do
|
||||
echo -n -e "\r -"
|
||||
stty cbreak # or stty raw
|
||||
readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
|
||||
stty cbreak # or stty raw. Stty uses file descriptor 0, not /dev/tty.
|
||||
readchar=`dd bs=1 count=1 2>/dev/null`
|
||||
stty -cbreak
|
||||
if [ $readchar == 'q' ] ; then
|
||||
readchar=0
|
||||
fi
|
||||
if [ $readchar -ne 0 ] ; then
|
||||
play -r 8000 -s -2 ${file[$readchar]} $dsp 2> /dev/null
|
||||
if [ -n "$readchar" ] ; then
|
||||
if [ x$readchar == 'xq' -o x$readchar == 'xQ' ] ; then
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
if [ -z ${file[$readchar]} ] ; then
|
||||
echo -n -e "\nUnknown input\n" $items"- "
|
||||
continue
|
||||
fi
|
||||
if ( play --version ) >/dev/null 2>&1; then
|
||||
play -r 8000 -s -2 ${file[$readchar]} $dsp 2> /dev/null
|
||||
elif ( aplay --version ) > /dev/null 2>&1; then
|
||||
aplay -r 8000 -f S16_LE ${file[$readchar]} 2> /dev/null
|
||||
elif ( ossplay -f? ) > /dev/null 2>&1; then
|
||||
ossplay -s8000 -fS16_LE ${file[$readchar]} 2> /dev/null
|
||||
else
|
||||
echo "could not find play, aplay or ossplay program"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo
|
||||
|
||||
+154
-26
@@ -1,8 +1,120 @@
|
||||
AM_CFLAGS = -I../src -Wall -DFLOATING_POINT -DVAR_ARRAYS
|
||||
AUTOMAKE_OPTIONS = gnu
|
||||
NAME = libcodec2
|
||||
AM_CFLAGS = -I../src -fPIC -Wall -O3 -g
|
||||
AUTOMAKE_OPTS = gnu
|
||||
NAME = codec2
|
||||
AM_CPPFLAGS = $(AM_CFLAGS)
|
||||
|
||||
D=codebook
|
||||
|
||||
# lsp quantisers
|
||||
|
||||
CODEBOOKS= \
|
||||
$D/lsp1.txt \
|
||||
$D/lsp2.txt \
|
||||
$D/lsp3.txt \
|
||||
$D/lsp4.txt \
|
||||
$D/lsp5.txt \
|
||||
$D/lsp6.txt \
|
||||
$D/lsp7.txt \
|
||||
$D/lsp8.txt \
|
||||
$D/lsp9.txt \
|
||||
$D/lsp10.txt
|
||||
|
||||
# lspd quantisers
|
||||
|
||||
CODEBOOKSD= \
|
||||
$D/dlsp1.txt \
|
||||
$D/dlsp2.txt \
|
||||
$D/dlsp3.txt \
|
||||
$D/dlsp4.txt \
|
||||
$D/dlsp5.txt \
|
||||
$D/dlsp6.txt \
|
||||
$D/dlsp7.txt \
|
||||
$D/dlsp8.txt \
|
||||
$D/dlsp9.txt \
|
||||
$D/dlsp10.txt
|
||||
|
||||
# lspd VQ quantisers
|
||||
|
||||
CODEBOOKSVQ= \
|
||||
$D/lsp1.txt \
|
||||
$D/lsp2.txt \
|
||||
$D/lsp3.txt \
|
||||
$D/lsp4.txt \
|
||||
$(top_srcdir)/unittest/lsp45678910.txt
|
||||
|
||||
CODEBOOKSJND= \
|
||||
$D/lsp1.txt \
|
||||
$D/lsp2.txt \
|
||||
$D/lsp3.txt \
|
||||
$D/lsp4.txt \
|
||||
$(top_srcdir)/unittest/lspjnd5-10.txt
|
||||
|
||||
CODEBOOKSDT= \
|
||||
$D/lspdt1.txt \
|
||||
$D/lspdt2.txt \
|
||||
$D/lspdt3.txt \
|
||||
$D/lspdt4.txt \
|
||||
$D/lspdt5.txt \
|
||||
$D/lspdt6.txt \
|
||||
$D/lspdt7.txt \
|
||||
$D/lspdt8.txt \
|
||||
$D/lspdt9.txt \
|
||||
$D/lspdt10.txt
|
||||
|
||||
CODEBOOKSJVM= \
|
||||
$D/lspjvm1.txt \
|
||||
$D/lspjvm2.txt \
|
||||
$D/lspjvm3.txt
|
||||
|
||||
CODEBOOKSVQANSSI= \
|
||||
$D/lspvqanssi1.txt \
|
||||
$D/lspvqanssi2.txt \
|
||||
$D/lspvqanssi3.txt \
|
||||
$D/lspvqanssi4.txt
|
||||
|
||||
CODEBOOKSGE= \
|
||||
$D/gecb.txt
|
||||
|
||||
noinst_PROGRAMS = generate_codebook genlspdtcb
|
||||
|
||||
codebook.$(OBJEXT): codebook.c
|
||||
codebookd.$(OBJEXT): codebookd.c
|
||||
codebookdt.$(OBJEXT): codebookdt.c
|
||||
codebookvq.$(OBJEXT): codebookvq.c
|
||||
codebookjnd.$(OBJEXT): codebookjnd.c
|
||||
codebookjvm.$(OBJEXT): codebookjvm.c
|
||||
codebookvqanssi.$(OBJEXT): codebookvqanssi.c
|
||||
codebookge.$(OBJEXT): codebookge.c
|
||||
|
||||
codebook.lo: codebook.c
|
||||
|
||||
codebook.c: generate_codebook $(CODEBOOKS)
|
||||
./generate_codebook lsp_cb $(CODEBOOKS) > codebook.c
|
||||
|
||||
codebookd.c: generate_codebook $(CODEBOOKSD)
|
||||
./generate_codebook lsp_cbd $(CODEBOOKSD) > codebookd.c
|
||||
|
||||
codebookdt.c: generate_codebook $(CODEBOOKSDT)
|
||||
./generate_codebook lsp_cbdt $(CODEBOOKSDT) > codebookdt.c
|
||||
|
||||
codebookvq.c: generate_codebook $(CODEBOOKSVQ)
|
||||
./generate_codebook lsp_cbvq $(CODEBOOKSVQ) > codebookvq.c
|
||||
|
||||
codebookjnd.c: generate_codebook $(CODEBOOKSJND)
|
||||
./generate_codebook lsp_cbjnd $(CODEBOOKSJND) > codebookjnd.c
|
||||
|
||||
codebookjvm.c: generate_codebook $(CODEBOOKSJVM)
|
||||
./generate_codebook lsp_cbjvm $(CODEBOOKSJVM) > codebookjvm.c
|
||||
|
||||
codebookvqanssi.c: generate_codebook $(CODEBOOKSVQANSSI)
|
||||
./generate_codebook lsp_cbvqanssi $(CODEBOOKSVQANSSI) > codebookvqanssi.c
|
||||
|
||||
codebookge.c: generate_codebook $(CODEBOOKSGE)
|
||||
./generate_codebook ge_cb $(CODEBOOKSGE) > codebookge.c
|
||||
|
||||
clean-local:
|
||||
-rm -f codebook.c codebookd.c codebookdvq.c codebookjnd.c codebookdt.c codebookjvm.c codebookge.c codebookvqanssi.c
|
||||
|
||||
lib_LTLIBRARIES = libcodec2.la
|
||||
libcodec2_la_SOURCES = dump.c \
|
||||
lpc.c \
|
||||
@@ -10,44 +122,60 @@ nlp.c \
|
||||
postfilter.c \
|
||||
sine.c \
|
||||
codec2.c \
|
||||
four1.c \
|
||||
fifo.c \
|
||||
fdmdv.c \
|
||||
kiss_fft.c \
|
||||
interp.c \
|
||||
lsp.c \
|
||||
phase.c \
|
||||
quantise.c \
|
||||
pack.c \
|
||||
codebook.c
|
||||
codebook.c \
|
||||
codebookd.c \
|
||||
codebookvq.c \
|
||||
codebookjnd.c \
|
||||
codebookjvm.c \
|
||||
codebookvqanssi.c \
|
||||
codebookdt.c \
|
||||
codebookge.c
|
||||
|
||||
|
||||
libcodec2_la_CFLAGS = $(AM_CFLAGS)
|
||||
libcodec2_la_LDFLAGS = $(LIBS)
|
||||
|
||||
library_includedir = $(prefix)
|
||||
library_include_HEADERS = codec2.h \
|
||||
defines.h \
|
||||
four1.h \
|
||||
interp.h \
|
||||
lsp.h \
|
||||
phase.h \
|
||||
quantise.h \
|
||||
comp.h \
|
||||
dump.h \
|
||||
globals.h \
|
||||
lpc.h \
|
||||
nlp.h \
|
||||
postfilter.h \
|
||||
sine.h \
|
||||
codebook.h
|
||||
library_includedir = $(prefix)/include
|
||||
library_include_HEADERS = codec2.h
|
||||
|
||||
bin_PROGRAMS = c2dec c2enc c2sim
|
||||
bin_PROGRAMS = c2demo c2enc c2dec c2sim fdmdv_get_test_bits fdmdv_mod fdmdv_demod fdmdv_put_test_bits fdmdv_interleave
|
||||
|
||||
c2dec_SOURCES = c2dec.c
|
||||
c2dec_LDADD = $(lib_LTLIBRARIES)
|
||||
c2dec_LDFLAGS = $(LIBS)
|
||||
c2demo_SOURCES = c2demo.c
|
||||
c2demo_LDADD = $(lib_LTLIBRARIES)
|
||||
c2demo_LDFLAGS = $(LIBS)
|
||||
|
||||
c2enc_SOURCES = c2enc.c
|
||||
c2enc_LDADD = $(lib_LTLIBRARIES)
|
||||
c2enc_LDFLAGS = $(LIBS)
|
||||
|
||||
c2sim_SOURCES = c2sim.c
|
||||
c2dec_SOURCES = c2dec.c
|
||||
c2dec_LDADD = $(lib_LTLIBRARIES)
|
||||
c2dec_LDFLAGS = $(LIBS)
|
||||
|
||||
c2sim_SOURCES = c2sim.c ampexp.c phaseexp.c
|
||||
c2sim_LDADD = $(lib_LTLIBRARIES)
|
||||
c2sim_LDFLAGS = $(LIBS)
|
||||
|
||||
fdmdv_get_test_bits_SOURCES = fdmdv_get_test_bits.c fdmdv.c kiss_fft.c
|
||||
fdmdv_get_test_bits_LDFLAGS = $(LIBS)
|
||||
|
||||
fdmdv_mod_SOURCES = fdmdv_mod.c fdmdv.c kiss_fft.c
|
||||
fdmdv_mod_LDFLAGS = $(LIBS)
|
||||
|
||||
fdmdv_demod_SOURCES = fdmdv_demod.c fdmdv.c kiss_fft.c octave.c
|
||||
fdmdv_demod_LDFLAGS = $(LIBS)
|
||||
|
||||
fdmdv_put_test_bits_SOURCES = fdmdv_put_test_bits.c fdmdv.c kiss_fft.c
|
||||
fdmdv_put_test_bits_LDFLAGS = $(LIBS)
|
||||
|
||||
fdmdv_interleave_SOURCES = fdmdv_interleave.c
|
||||
fdmdv_interleave_LDFLAGS = $(LIBS)
|
||||
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
Copyright (c) 2003-2010, Mark Borgerding
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* kiss_fft.h
|
||||
defines kiss_fft_scalar as either short or a float type
|
||||
and defines
|
||||
typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */
|
||||
#include "kiss_fft.h"
|
||||
#include <limits.h>
|
||||
|
||||
#define MAXFACTORS 32
|
||||
/* e.g. an fft of length 128 has 4 factors
|
||||
as far as kissfft is concerned
|
||||
4*4*4*2
|
||||
*/
|
||||
|
||||
struct kiss_fft_state{
|
||||
int nfft;
|
||||
int inverse;
|
||||
int factors[2*MAXFACTORS];
|
||||
kiss_fft_cpx twiddles[1];
|
||||
};
|
||||
|
||||
/*
|
||||
Explanation of macros dealing with complex math:
|
||||
|
||||
C_MUL(m,a,b) : m = a*b
|
||||
C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise
|
||||
C_SUB( res, a,b) : res = a - b
|
||||
C_SUBFROM( res , a) : res -= a
|
||||
C_ADDTO( res , a) : res += a
|
||||
* */
|
||||
#ifdef FIXED_POINT
|
||||
#if (FIXED_POINT==32)
|
||||
# define FRACBITS 31
|
||||
# define SAMPPROD int64_t
|
||||
#define SAMP_MAX 2147483647
|
||||
#else
|
||||
# define FRACBITS 15
|
||||
# define SAMPPROD int32_t
|
||||
#define SAMP_MAX 32767
|
||||
#endif
|
||||
|
||||
#define SAMP_MIN -SAMP_MAX
|
||||
|
||||
#if defined(CHECK_OVERFLOW)
|
||||
# define CHECK_OVERFLOW_OP(a,op,b) \
|
||||
if ( (SAMPPROD)(a) op (SAMPPROD)(b) > SAMP_MAX || (SAMPPROD)(a) op (SAMPPROD)(b) < SAMP_MIN ) { \
|
||||
fprintf(stderr,"WARNING:overflow @ " __FILE__ "(%d): (%d " #op" %d) = %ld\n",__LINE__,(a),(b),(SAMPPROD)(a) op (SAMPPROD)(b) ); }
|
||||
#endif
|
||||
|
||||
|
||||
# define smul(a,b) ( (SAMPPROD)(a)*(b) )
|
||||
# define sround( x ) (kiss_fft_scalar)( ( (x) + (1<<(FRACBITS-1)) ) >> FRACBITS )
|
||||
|
||||
# define S_MUL(a,b) sround( smul(a,b) )
|
||||
|
||||
# define C_MUL(m,a,b) \
|
||||
do{ (m).r = sround( smul((a).r,(b).r) - smul((a).i,(b).i) ); \
|
||||
(m).i = sround( smul((a).r,(b).i) + smul((a).i,(b).r) ); }while(0)
|
||||
|
||||
# define DIVSCALAR(x,k) \
|
||||
(x) = sround( smul( x, SAMP_MAX/k ) )
|
||||
|
||||
# define C_FIXDIV(c,div) \
|
||||
do { DIVSCALAR( (c).r , div); \
|
||||
DIVSCALAR( (c).i , div); }while (0)
|
||||
|
||||
# define C_MULBYSCALAR( c, s ) \
|
||||
do{ (c).r = sround( smul( (c).r , s ) ) ;\
|
||||
(c).i = sround( smul( (c).i , s ) ) ; }while(0)
|
||||
|
||||
#else /* not FIXED_POINT*/
|
||||
|
||||
# define S_MUL(a,b) ( (a)*(b) )
|
||||
#define C_MUL(m,a,b) \
|
||||
do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
|
||||
(m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
|
||||
# define C_FIXDIV(c,div) /* NOOP */
|
||||
# define C_MULBYSCALAR( c, s ) \
|
||||
do{ (c).r *= (s);\
|
||||
(c).i *= (s); }while(0)
|
||||
#endif
|
||||
|
||||
#ifndef CHECK_OVERFLOW_OP
|
||||
# define CHECK_OVERFLOW_OP(a,op,b) /* noop */
|
||||
#endif
|
||||
|
||||
#define C_ADD( res, a,b)\
|
||||
do { \
|
||||
CHECK_OVERFLOW_OP((a).r,+,(b).r)\
|
||||
CHECK_OVERFLOW_OP((a).i,+,(b).i)\
|
||||
(res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
|
||||
}while(0)
|
||||
#define C_SUB( res, a,b)\
|
||||
do { \
|
||||
CHECK_OVERFLOW_OP((a).r,-,(b).r)\
|
||||
CHECK_OVERFLOW_OP((a).i,-,(b).i)\
|
||||
(res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
|
||||
}while(0)
|
||||
#define C_ADDTO( res , a)\
|
||||
do { \
|
||||
CHECK_OVERFLOW_OP((res).r,+,(a).r)\
|
||||
CHECK_OVERFLOW_OP((res).i,+,(a).i)\
|
||||
(res).r += (a).r; (res).i += (a).i;\
|
||||
}while(0)
|
||||
|
||||
#define C_SUBFROM( res , a)\
|
||||
do {\
|
||||
CHECK_OVERFLOW_OP((res).r,-,(a).r)\
|
||||
CHECK_OVERFLOW_OP((res).i,-,(a).i)\
|
||||
(res).r -= (a).r; (res).i -= (a).i; \
|
||||
}while(0)
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
# define KISS_FFT_COS(phase) floor(.5+SAMP_MAX * cos (phase))
|
||||
# define KISS_FFT_SIN(phase) floor(.5+SAMP_MAX * sin (phase))
|
||||
# define HALF_OF(x) ((x)>>1)
|
||||
#elif defined(USE_SIMD)
|
||||
# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) )
|
||||
# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) )
|
||||
# define HALF_OF(x) ((x)*_mm_set1_ps(.5))
|
||||
#else
|
||||
# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
|
||||
# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
|
||||
# define HALF_OF(x) ((x)*.5)
|
||||
#endif
|
||||
|
||||
#define kf_cexp(x,phase) \
|
||||
do{ \
|
||||
(x)->r = KISS_FFT_COS(phase);\
|
||||
(x)->i = KISS_FFT_SIN(phase);\
|
||||
}while(0)
|
||||
|
||||
|
||||
/* a debugging function */
|
||||
#define pcpx(c)\
|
||||
fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) )
|
||||
|
||||
|
||||
#ifdef KISS_FFT_USE_ALLOCA
|
||||
// define this to allow use of alloca instead of malloc for temporary buffers
|
||||
// Temporary buffers are used in two case:
|
||||
// 1. FFT sizes that have "bad" factors. i.e. not 2,3 and 5
|
||||
// 2. "in-place" FFTs. Notice the quotes, since kissfft does not really do an in-place transform.
|
||||
#include <alloca.h>
|
||||
#define KISS_FFT_TMP_ALLOC(nbytes) alloca(nbytes)
|
||||
#define KISS_FFT_TMP_FREE(ptr)
|
||||
#else
|
||||
#define KISS_FFT_TMP_ALLOC(nbytes) KISS_FFT_MALLOC(nbytes)
|
||||
#define KISS_FFT_TMP_FREE(ptr) KISS_FFT_FREE(ptr)
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: ampexp.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: & August 2012
|
||||
|
||||
Functions for experimenting with amplitude quantisation.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not,see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __AMPEX__
|
||||
#define __AMPEXP__
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
struct AEXP;
|
||||
|
||||
struct AEXP *amp_experiment_create();
|
||||
void amp_experiment_destroy(struct AEXP *aexp);
|
||||
void amp_experiment(struct AEXP *aexp, MODEL *model, char *arg);
|
||||
|
||||
#endif
|
||||
+129
-29
@@ -4,12 +4,7 @@
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 23/8/2010
|
||||
|
||||
Decodes a file of bits to a file of raw speech samples using codec2. Demo
|
||||
program for codec2.
|
||||
|
||||
NOTE: the bit file is not packed, 51 bits/frame actually consumes 51
|
||||
bytes/frame on disk. If you are using this for a real world
|
||||
application you may want to pack the 51 bytes into 7 bytes.
|
||||
Decodes a file of bits to a file of raw speech samples using codec2.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@@ -27,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "codec2.h"
|
||||
@@ -38,41 +32,147 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define NONE 0 /* no bit errors */
|
||||
#define UNIFORM 1 /* random bit errors */
|
||||
#define TWO_STATE 2 /* Two state error model */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
static const int bitsSize = ((CODEC2_BITS_PER_FRAME + 7) / 8);
|
||||
void *codec2;
|
||||
FILE *fin;
|
||||
FILE *fout;
|
||||
short buf[CODEC2_SAMPLES_PER_FRAME];
|
||||
unsigned char bits[bitsSize];
|
||||
int mode;
|
||||
void *codec2;
|
||||
FILE *fin;
|
||||
FILE *fout;
|
||||
short *buf;
|
||||
unsigned char *bits;
|
||||
int nsam, nbit, nbyte, i, byte, frames, bit_errors, error_mode;
|
||||
int state, next_state;
|
||||
float ber, r, pstate0, pstate1;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("usage: %s InputBitFile OutputRawSpeechFile\n", argv[0]);
|
||||
if (argc < 4) {
|
||||
printf("basic usage...............: c2dec 3200|2400|1400|1200 InputBitFile OutputRawSpeechFile\n");
|
||||
printf("uniform errors usage.......: c2dec 3200|2400|1400|1200 InputBitFile OutputRawSpeechFile uniformBER\n");
|
||||
printf("two state fading usage....: c2dec 3200|2400|1400|1200 InputBitFile OutputRawSpeechFile probGood probBad\n");
|
||||
printf("e.g c2dec 1400 hts1a.c2 hts1a_1400.raw\n");
|
||||
printf("e.g c2dec 1400 hts1a.c2 hts1a_1400.raw 0.9\n");
|
||||
printf("e.g c2dec 1400 hts1a.c2 hts1a_1400.raw 0.99 0.9\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( (fin = fopen(argv[1],"rb")) == NULL ) {
|
||||
|
||||
if (strcmp(argv[1],"3200") == 0)
|
||||
mode = CODEC2_MODE_3200;
|
||||
else if (strcmp(argv[1],"2400") == 0)
|
||||
mode = CODEC2_MODE_2400;
|
||||
else if (strcmp(argv[1],"1400") == 0)
|
||||
mode = CODEC2_MODE_1400;
|
||||
else if (strcmp(argv[1],"1200") == 0)
|
||||
mode = CODEC2_MODE_1200;
|
||||
else {
|
||||
fprintf(stderr, "Error in mode: %s. Must be 4800, 3200, 2400, 1400 or 1200\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[2], "-") == 0) fin = stdin;
|
||||
else if ( (fin = fopen(argv[2],"rb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening input bit file: %s: %s.\n",
|
||||
argv[1], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( (fout = fopen(argv[2],"wb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening output speech file: %s: %s.\n",
|
||||
argv[2], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
codec2 = codec2_create();
|
||||
|
||||
while(fread(bits, sizeof(char), bitsSize, fin) == bitsSize) {
|
||||
codec2_decode(codec2, buf, bits);
|
||||
fwrite(buf, sizeof(short), CODEC2_SAMPLES_PER_FRAME, fout);
|
||||
if (strcmp(argv[3], "-") == 0) fout = stdout;
|
||||
else if ( (fout = fopen(argv[3],"wb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening output speech file: %s: %s.\n",
|
||||
argv[3], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
error_mode = NONE;
|
||||
ber = 0.0;
|
||||
pstate0 = pstate1 = 0.0;
|
||||
|
||||
if (argc == 5) {
|
||||
error_mode = UNIFORM;
|
||||
ber = atof(argv[4]);
|
||||
}
|
||||
|
||||
if (argc == 6) {
|
||||
error_mode = TWO_STATE;
|
||||
pstate0 = atof(argv[4]);
|
||||
pstate1 = atof(argv[5]);
|
||||
state = 0;
|
||||
}
|
||||
|
||||
codec2 = codec2_create(mode);
|
||||
nsam = codec2_samples_per_frame(codec2);
|
||||
nbit = codec2_bits_per_frame(codec2);
|
||||
buf = (short*)malloc(nsam*sizeof(short));
|
||||
nbyte = (nbit + 7) / 8;
|
||||
bits = (unsigned char*)malloc(nbyte*sizeof(char));
|
||||
frames = bit_errors = 0;
|
||||
|
||||
while(fread(bits, sizeof(char), nbyte, fin) == (size_t)nbyte) {
|
||||
frames++;
|
||||
if (error_mode == UNIFORM) {
|
||||
for(i=0; i<nbit; i++) {
|
||||
r = (float)rand()/RAND_MAX;
|
||||
if (r < ber) {
|
||||
byte = i/8;
|
||||
//printf("nbyte %d nbit %d i %d byte %d\n", nbyte, nbit, i, byte);
|
||||
bits[byte] ^= 1 << (i - byte*8);
|
||||
bit_errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (error_mode == TWO_STATE) {
|
||||
next_state = state;
|
||||
switch(state) {
|
||||
case 0:
|
||||
|
||||
/* clear channel state - no bit errors */
|
||||
|
||||
r = (float)rand()/RAND_MAX;
|
||||
if (r > pstate0)
|
||||
next_state = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
/* burst error state - 50% bit error rate */
|
||||
|
||||
for(i=0; i<nbit; i++) {
|
||||
r = (float)rand()/RAND_MAX;
|
||||
if (r < 0.5) {
|
||||
byte = i/8;
|
||||
bits[byte] ^= 1 << (i - byte*8);
|
||||
bit_errors++;
|
||||
}
|
||||
}
|
||||
|
||||
r = (float)rand()/RAND_MAX;
|
||||
if (r > pstate1)
|
||||
next_state = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
state = next_state;
|
||||
}
|
||||
|
||||
codec2_decode(codec2, buf, bits);
|
||||
fwrite(buf, sizeof(short), nsam, fout);
|
||||
//if this is in a pipeline, we probably don't want the usual
|
||||
//buffering to occur
|
||||
if (fout == stdout) fflush(stdout);
|
||||
if (fin == stdin) fflush(stdin);
|
||||
}
|
||||
|
||||
if (ber != 0.0)
|
||||
fprintf(stderr, "actual BER: %1.3f\n", (float)bit_errors/(frames*nbit));
|
||||
|
||||
codec2_destroy(codec2);
|
||||
|
||||
free(buf);
|
||||
free(bits);
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: c2demo.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 15/11/2010
|
||||
|
||||
Encodes and decodes a file of raw speech samples using Codec 2.
|
||||
Demonstrates use of Codec 2 function API.
|
||||
|
||||
Note to convert a wave file to raw and vice-versa:
|
||||
|
||||
$ sox file.wav -r 8000 -s -2 file.raw
|
||||
$ sox -r 8000 -s -2 file.raw file.wav
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2010 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "codec2.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define BITS_SIZE ((CODEC2_BITS_PER_FRAME + 7) / 8)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct CODEC2 *codec2;
|
||||
FILE *fin;
|
||||
FILE *fout;
|
||||
short *buf;
|
||||
unsigned char *bits;
|
||||
int nsam, nbit;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("usage: %s InputRawSpeechFile OutputRawSpeechFile\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( (fin = fopen(argv[1],"rb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening input speech file: %s: %s.\n",
|
||||
argv[1], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( (fout = fopen(argv[2],"wb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening output speech file: %s: %s.\n",
|
||||
argv[2], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Note only one set of Codec 2 states is required for an encoder
|
||||
and decoder pair. */
|
||||
|
||||
codec2 = codec2_create(CODEC2_MODE_1400);
|
||||
nsam = codec2_samples_per_frame(codec2);
|
||||
buf = (short*)malloc(nsam*sizeof(short));
|
||||
nbit = codec2_bits_per_frame(codec2);
|
||||
bits = (unsigned char*)malloc(nbit*sizeof(char));
|
||||
|
||||
while(fread(buf, sizeof(short), nsam, fin) == (size_t)nsam) {
|
||||
codec2_encode(codec2, bits, buf);
|
||||
codec2_decode(codec2, buf, bits);
|
||||
fwrite(buf, sizeof(short), nsam, fout);
|
||||
}
|
||||
|
||||
free(buf);
|
||||
free(bits);
|
||||
codec2_destroy(codec2);
|
||||
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+49
-27
@@ -4,13 +4,8 @@
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 23/8/2010
|
||||
|
||||
Encodes a file of raw speech samples using codec2 and ouputs a file
|
||||
of bits (each bit is stored in the LSB or each output byte). Demo
|
||||
program for codec2.
|
||||
|
||||
NOTE: the bit file is not packed, 51 bits/frame actually consumes 51
|
||||
bytes/frame on disk. If you are using this for a real world
|
||||
application you may want to pack the 51 bytes into 7 bytes.
|
||||
Encodes a file of raw speech samples using codec2 and outputs a file
|
||||
of bits.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@@ -28,8 +23,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "codec2.h"
|
||||
@@ -41,40 +35,68 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
static const int bitsSize = ((CODEC2_BITS_PER_FRAME + 7) / 8);
|
||||
void *codec2;
|
||||
FILE *fin;
|
||||
FILE *fout;
|
||||
short buf[CODEC2_SAMPLES_PER_FRAME];
|
||||
unsigned char bits[bitsSize];
|
||||
|
||||
if (argc != 3) {
|
||||
printf("usage: %s InputRawspeechFile OutputBitFile\n", argv[0]);
|
||||
int mode;
|
||||
void *codec2;
|
||||
FILE *fin;
|
||||
FILE *fout;
|
||||
short *buf;
|
||||
unsigned char *bits;
|
||||
int nsam, nbit, nbyte;
|
||||
|
||||
if (argc != 4) {
|
||||
printf("usage: c2enc 3200|2400|1400|1200 InputRawspeechFile OutputBitFile\n");
|
||||
printf("e.g c2enc 1400 ../raw/hts1a.raw hts1a.c2\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( (fin = fopen(argv[1],"rb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening input bit file: %s: %s.\n",
|
||||
argv[1], strerror(errno));
|
||||
if (strcmp(argv[1],"3200") == 0)
|
||||
mode = CODEC2_MODE_3200;
|
||||
else if (strcmp(argv[1],"2400") == 0)
|
||||
mode = CODEC2_MODE_2400;
|
||||
else if (strcmp(argv[1],"1400") == 0)
|
||||
mode = CODEC2_MODE_1400;
|
||||
else if (strcmp(argv[1],"1200") == 0)
|
||||
mode = CODEC2_MODE_1200;
|
||||
else {
|
||||
fprintf(stderr, "Error in mode: %s. Must be 3200, 2400, 1400 or 1200\n", argv[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( (fout = fopen(argv[2],"wb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening output speech file: %s: %s.\n",
|
||||
if (strcmp(argv[2], "-") == 0) fin = stdin;
|
||||
else if ( (fin = fopen(argv[2],"rb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening input speech file: %s: %s.\n",
|
||||
argv[2], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
codec2 = codec2_create();
|
||||
if (strcmp(argv[3], "-") == 0) fout = stdout;
|
||||
else if ( (fout = fopen(argv[3],"wb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening output compressed bit file: %s: %s.\n",
|
||||
argv[3], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while(fread(buf, sizeof(short), CODEC2_SAMPLES_PER_FRAME, fin) ==
|
||||
CODEC2_SAMPLES_PER_FRAME) {
|
||||
codec2 = codec2_create(mode);
|
||||
nsam = codec2_samples_per_frame(codec2);
|
||||
nbit = codec2_bits_per_frame(codec2);
|
||||
buf = (short*)malloc(nsam*sizeof(short));
|
||||
nbyte = (nbit + 7) / 8;
|
||||
|
||||
bits = (unsigned char*)malloc(nbyte*sizeof(char));
|
||||
|
||||
while(fread(buf, sizeof(short), nsam, fin) == (size_t)nsam) {
|
||||
codec2_encode(codec2, bits, buf);
|
||||
fwrite(bits, sizeof(char), bitsSize, fout);
|
||||
fwrite(bits, sizeof(char), nbyte, fout);
|
||||
// if this is in a pipeline, we probably don't want the usual
|
||||
// buffering to occur
|
||||
if (fout == stdout) fflush(stdout);
|
||||
if (fin == stdin) fflush(stdin);
|
||||
}
|
||||
|
||||
codec2_destroy(codec2);
|
||||
|
||||
free(buf);
|
||||
free(bits);
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
|
||||
|
||||
+818
-307
File diff suppressed because it is too large
Load Diff
+242
-159
@@ -1,162 +1,245 @@
|
||||
float codebook_lsp1[] = {
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,0,0,0,0,0,0,0,0,0,0
|
||||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* codebook/lsp1.txt */
|
||||
static const float codes0[] = {
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600
|
||||
};
|
||||
/* codebook/lsp2.txt */
|
||||
static const float codes1[] = {
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700
|
||||
};
|
||||
/* codebook/lsp3.txt */
|
||||
static const float codes2[] = {
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650,
|
||||
700,
|
||||
750,
|
||||
800,
|
||||
850,
|
||||
900,
|
||||
950,
|
||||
1000,
|
||||
1050,
|
||||
1100,
|
||||
1150,
|
||||
1200,
|
||||
1250
|
||||
};
|
||||
/* codebook/lsp4.txt */
|
||||
static const float codes3[] = {
|
||||
700,
|
||||
800,
|
||||
900,
|
||||
1000,
|
||||
1100,
|
||||
1200,
|
||||
1300,
|
||||
1400,
|
||||
1500,
|
||||
1600,
|
||||
1700,
|
||||
1800,
|
||||
1900,
|
||||
2000,
|
||||
2100,
|
||||
2200
|
||||
};
|
||||
/* codebook/lsp5.txt */
|
||||
static const float codes4[] = {
|
||||
950,
|
||||
1050,
|
||||
1150,
|
||||
1250,
|
||||
1350,
|
||||
1450,
|
||||
1550,
|
||||
1650,
|
||||
1750,
|
||||
1850,
|
||||
1950,
|
||||
2050,
|
||||
2150,
|
||||
2250,
|
||||
2350,
|
||||
2450
|
||||
};
|
||||
/* codebook/lsp6.txt */
|
||||
static const float codes5[] = {
|
||||
1100,
|
||||
1200,
|
||||
1300,
|
||||
1400,
|
||||
1500,
|
||||
1600,
|
||||
1700,
|
||||
1800,
|
||||
1900,
|
||||
2000,
|
||||
2100,
|
||||
2200,
|
||||
2300,
|
||||
2400,
|
||||
2500,
|
||||
2600
|
||||
};
|
||||
/* codebook/lsp7.txt */
|
||||
static const float codes6[] = {
|
||||
1500,
|
||||
1600,
|
||||
1700,
|
||||
1800,
|
||||
1900,
|
||||
2000,
|
||||
2100,
|
||||
2200,
|
||||
2300,
|
||||
2400,
|
||||
2500,
|
||||
2600,
|
||||
2700,
|
||||
2800,
|
||||
2900,
|
||||
3000
|
||||
};
|
||||
/* codebook/lsp8.txt */
|
||||
static const float codes7[] = {
|
||||
2300,
|
||||
2400,
|
||||
2500,
|
||||
2600,
|
||||
2700,
|
||||
2800,
|
||||
2900,
|
||||
3000
|
||||
};
|
||||
/* codebook/lsp9.txt */
|
||||
static const float codes8[] = {
|
||||
2500,
|
||||
2600,
|
||||
2700,
|
||||
2800,
|
||||
2900,
|
||||
3000,
|
||||
3100,
|
||||
3200
|
||||
};
|
||||
/* codebook/lsp10.txt */
|
||||
static const float codes9[] = {
|
||||
2900,
|
||||
3100,
|
||||
3300,
|
||||
3500
|
||||
};
|
||||
|
||||
float codebook_lsp2[] = {
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,0,0,0,0,0,0,0,0,0,0
|
||||
const struct lsp_codebook lsp_cb[] = {
|
||||
/* codebook/lsp1.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes0
|
||||
},
|
||||
/* codebook/lsp2.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes1
|
||||
},
|
||||
/* codebook/lsp3.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes2
|
||||
},
|
||||
/* codebook/lsp4.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes3
|
||||
},
|
||||
/* codebook/lsp5.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes4
|
||||
},
|
||||
/* codebook/lsp6.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes5
|
||||
},
|
||||
/* codebook/lsp7.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes6
|
||||
},
|
||||
/* codebook/lsp8.txt */
|
||||
{
|
||||
1,
|
||||
3,
|
||||
8,
|
||||
codes7
|
||||
},
|
||||
/* codebook/lsp9.txt */
|
||||
{
|
||||
1,
|
||||
3,
|
||||
8,
|
||||
codes8
|
||||
},
|
||||
/* codebook/lsp10.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes9
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
float codebook_lsp3[] = {
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650,
|
||||
700,
|
||||
750,
|
||||
800,
|
||||
850,
|
||||
900,
|
||||
950,
|
||||
1000,
|
||||
1050,
|
||||
1100,
|
||||
1150,
|
||||
1200,
|
||||
1250,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
float codebook_lsp4[] = {
|
||||
700,
|
||||
800,
|
||||
900,
|
||||
1000,
|
||||
1100,
|
||||
1200,
|
||||
1300,
|
||||
1400,
|
||||
1500,
|
||||
1600,
|
||||
1700,
|
||||
1800,
|
||||
1900,
|
||||
2000,
|
||||
2100,
|
||||
2200,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
float codebook_lsp5[] = {
|
||||
950,
|
||||
1050,
|
||||
1150,
|
||||
1250,
|
||||
1350,
|
||||
1450,
|
||||
1550,
|
||||
1650,
|
||||
1750,
|
||||
1850,
|
||||
1950,
|
||||
2050,
|
||||
2150,
|
||||
2250,
|
||||
2350,
|
||||
2450,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
float codebook_lsp6[] = {
|
||||
1100,
|
||||
1200,
|
||||
1300,
|
||||
1400,
|
||||
1500,
|
||||
1600,
|
||||
1700,
|
||||
1800,
|
||||
1900,
|
||||
2000,
|
||||
2100,
|
||||
2200,
|
||||
2300,
|
||||
2400,
|
||||
2500,
|
||||
2600,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
float codebook_lsp7[] = {
|
||||
1500,
|
||||
1600,
|
||||
1700,
|
||||
1800,
|
||||
1900,
|
||||
2000,
|
||||
2100,
|
||||
2200,
|
||||
2300,
|
||||
2400,
|
||||
2500,
|
||||
2600,
|
||||
2700,
|
||||
2800,
|
||||
2900,
|
||||
3000,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
float codebook_lsp8[] = {
|
||||
2300,
|
||||
2400,
|
||||
2500,
|
||||
2600,
|
||||
2700,
|
||||
2800,
|
||||
2900,
|
||||
3000,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
float codebook_lsp9[] = {
|
||||
2500,
|
||||
2600,
|
||||
2700,
|
||||
2800,
|
||||
2900,
|
||||
3000,
|
||||
3100,
|
||||
3200,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
float codebook_lsp10[] = {
|
||||
2900,
|
||||
3100,
|
||||
3300,
|
||||
3500,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,433 @@
|
||||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* codebook/dlsp1.txt */
|
||||
static const float codes0[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp2.txt */
|
||||
static const float codes1[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp3.txt */
|
||||
static const float codes2[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp4.txt */
|
||||
static const float codes3[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
250,
|
||||
300,
|
||||
350,
|
||||
400,
|
||||
450,
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650,
|
||||
700,
|
||||
750,
|
||||
800,
|
||||
850,
|
||||
900,
|
||||
950,
|
||||
1000,
|
||||
1050,
|
||||
1100,
|
||||
1150,
|
||||
1200,
|
||||
1250,
|
||||
1300,
|
||||
1350,
|
||||
1400
|
||||
};
|
||||
/* codebook/dlsp5.txt */
|
||||
static const float codes4[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
250,
|
||||
300,
|
||||
350,
|
||||
400,
|
||||
450,
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650,
|
||||
700,
|
||||
750,
|
||||
800,
|
||||
850,
|
||||
900,
|
||||
950,
|
||||
1000,
|
||||
1050,
|
||||
1100,
|
||||
1150,
|
||||
1200,
|
||||
1250,
|
||||
1300,
|
||||
1350,
|
||||
1400
|
||||
};
|
||||
/* codebook/dlsp6.txt */
|
||||
static const float codes5[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
250,
|
||||
300,
|
||||
350,
|
||||
400,
|
||||
450,
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650,
|
||||
700,
|
||||
750,
|
||||
800,
|
||||
850,
|
||||
900,
|
||||
950,
|
||||
1000,
|
||||
1050,
|
||||
1100,
|
||||
1150,
|
||||
1200,
|
||||
1250,
|
||||
1300,
|
||||
1350,
|
||||
1400
|
||||
};
|
||||
/* codebook/dlsp7.txt */
|
||||
static const float codes6[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp8.txt */
|
||||
static const float codes7[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp9.txt */
|
||||
static const float codes8[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
/* codebook/dlsp10.txt */
|
||||
static const float codes9[] = {
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
125,
|
||||
150,
|
||||
175,
|
||||
200,
|
||||
225,
|
||||
250,
|
||||
275,
|
||||
300,
|
||||
325,
|
||||
350,
|
||||
375,
|
||||
400,
|
||||
425,
|
||||
450,
|
||||
475,
|
||||
500,
|
||||
525,
|
||||
550,
|
||||
575,
|
||||
600,
|
||||
625,
|
||||
650,
|
||||
675,
|
||||
700,
|
||||
725,
|
||||
750,
|
||||
775,
|
||||
800
|
||||
};
|
||||
|
||||
const struct lsp_codebook lsp_cbd[] = {
|
||||
/* codebook/dlsp1.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes0
|
||||
},
|
||||
/* codebook/dlsp2.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes1
|
||||
},
|
||||
/* codebook/dlsp3.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes2
|
||||
},
|
||||
/* codebook/dlsp4.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes3
|
||||
},
|
||||
/* codebook/dlsp5.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes4
|
||||
},
|
||||
/* codebook/dlsp6.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes5
|
||||
},
|
||||
/* codebook/dlsp7.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes6
|
||||
},
|
||||
/* codebook/dlsp8.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes7
|
||||
},
|
||||
/* codebook/dlsp9.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes8
|
||||
},
|
||||
/* codebook/dlsp10.txt */
|
||||
{
|
||||
1,
|
||||
5,
|
||||
32,
|
||||
codes9
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
@@ -0,0 +1,153 @@
|
||||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* codebook/lspdt1.txt */
|
||||
static const float codes0[] = {
|
||||
-75,
|
||||
-50,
|
||||
-25,
|
||||
0,
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt2.txt */
|
||||
static const float codes1[] = {
|
||||
-75,
|
||||
-50,
|
||||
-25,
|
||||
0,
|
||||
25,
|
||||
50,
|
||||
75,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt3.txt */
|
||||
static const float codes2[] = {
|
||||
-50,
|
||||
0,
|
||||
50,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt4.txt */
|
||||
static const float codes3[] = {
|
||||
-50,
|
||||
0,
|
||||
50,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt5.txt */
|
||||
static const float codes4[] = {
|
||||
-50,
|
||||
0,
|
||||
50,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt6.txt */
|
||||
static const float codes5[] = {
|
||||
-50,
|
||||
0,
|
||||
50,
|
||||
100
|
||||
};
|
||||
/* codebook/lspdt7.txt */
|
||||
static const float codes6[] = {
|
||||
-50,
|
||||
50
|
||||
};
|
||||
/* codebook/lspdt8.txt */
|
||||
static const float codes7[] = {
|
||||
-50,
|
||||
50
|
||||
};
|
||||
/* codebook/lspdt9.txt */
|
||||
static const float codes8[] = {
|
||||
-50,
|
||||
50
|
||||
};
|
||||
/* codebook/lspdt10.txt */
|
||||
static const float codes9[] = {
|
||||
-50,
|
||||
50
|
||||
};
|
||||
|
||||
const struct lsp_codebook lsp_cbdt[] = {
|
||||
/* codebook/lspdt1.txt */
|
||||
{
|
||||
1,
|
||||
3,
|
||||
8,
|
||||
codes0
|
||||
},
|
||||
/* codebook/lspdt2.txt */
|
||||
{
|
||||
1,
|
||||
3,
|
||||
8,
|
||||
codes1
|
||||
},
|
||||
/* codebook/lspdt3.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes2
|
||||
},
|
||||
/* codebook/lspdt4.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes3
|
||||
},
|
||||
/* codebook/lspdt5.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes4
|
||||
},
|
||||
/* codebook/lspdt6.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes5
|
||||
},
|
||||
/* codebook/lspdt7.txt */
|
||||
{
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
codes6
|
||||
},
|
||||
/* codebook/lspdt8.txt */
|
||||
{
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
codes7
|
||||
},
|
||||
/* codebook/lspdt9.txt */
|
||||
{
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
codes8
|
||||
},
|
||||
/* codebook/lspdt10.txt */
|
||||
{
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
codes9
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
@@ -0,0 +1,279 @@
|
||||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* codebook/gecb.txt */
|
||||
static const float codes0[] = {
|
||||
2.71, 12.0184,
|
||||
0.04675, -2.73881,
|
||||
0.120993, 8.38895,
|
||||
-1.58028, -0.892307,
|
||||
1.19307, -1.91561,
|
||||
0.187101, -3.27679,
|
||||
0.332251, -7.66455,
|
||||
-1.47944, 31.2461,
|
||||
1.52761, 27.7095,
|
||||
-0.524379, 5.25012,
|
||||
0.55333, 7.4388,
|
||||
-0.843451, -1.95299,
|
||||
2.26389, 8.61029,
|
||||
0.143143, 2.36549,
|
||||
0.616506, 1.28427,
|
||||
-1.71133, 22.0967,
|
||||
1.00813, 17.3965,
|
||||
-0.106718, 1.41891,
|
||||
-0.136246, 14.2736,
|
||||
-1.70909, -20.5319,
|
||||
1.65787, -3.39107,
|
||||
0.138049, -4.95785,
|
||||
0.536729, -1.94375,
|
||||
0.196307, 36.8519,
|
||||
1.27248, 22.5565,
|
||||
-0.670219, -1.90604,
|
||||
0.382092, 6.40113,
|
||||
-0.756911, -4.90102,
|
||||
1.82931, 4.6138,
|
||||
0.318794, 0.73683,
|
||||
0.612815, -2.07505,
|
||||
-0.410151, 24.7871,
|
||||
1.77602, 13.1909,
|
||||
0.106457, -0.104492,
|
||||
0.192206, 10.1838,
|
||||
-1.82442, -7.71565,
|
||||
0.931346, 4.34835,
|
||||
0.308813, -4.086,
|
||||
0.397143, -11.8089,
|
||||
-0.048715, 41.2273,
|
||||
0.877342, 35.8503,
|
||||
-0.759794, 0.476634,
|
||||
0.978593, 7.67467,
|
||||
-1.19506, 3.03883,
|
||||
2.63989, -3.41106,
|
||||
0.191127, 3.60351,
|
||||
0.402932, 1.0843,
|
||||
-2.15202, 18.1076,
|
||||
1.5468, 8.32271,
|
||||
-0.143089, -4.07592,
|
||||
-0.150142, 5.86674,
|
||||
-1.40844, -3.2507,
|
||||
1.56615, -10.4132,
|
||||
0.178171, -10.2267,
|
||||
0.362164, -0.028556,
|
||||
-0.070125, 24.3907,
|
||||
0.594752, 17.4828,
|
||||
-0.28698, -6.90407,
|
||||
0.464818, 10.2055,
|
||||
-1.00684, -14.3572,
|
||||
2.32957, -3.69161,
|
||||
0.335745, 2.40714,
|
||||
1.01966, -3.15565,
|
||||
-1.25945, 7.9919,
|
||||
2.38369, 19.6806,
|
||||
-0.094947, -2.41374,
|
||||
0.20933, 6.66477,
|
||||
-2.22103, 1.37986,
|
||||
1.29239, 2.04633,
|
||||
0.243626, -0.890741,
|
||||
0.428773, -7.19366,
|
||||
-1.11374, 41.3414,
|
||||
2.6098, 31.1405,
|
||||
-0.446468, 2.53419,
|
||||
0.490104, 4.62757,
|
||||
-1.11723, -3.24174,
|
||||
1.79156, 8.41493,
|
||||
0.156012, 0.183336,
|
||||
0.532447, 3.15455,
|
||||
-0.764484, 18.514,
|
||||
0.952395, 11.7713,
|
||||
-0.332567, 0.346987,
|
||||
0.202165, 14.7168,
|
||||
-2.12924, -15.559,
|
||||
1.35358, -1.92679,
|
||||
-0.010963, -16.3364,
|
||||
0.399053, -2.79057,
|
||||
0.750657, 31.1483,
|
||||
0.655743, 24.4819,
|
||||
-0.45321, -0.735879,
|
||||
0.2869, 6.5467,
|
||||
-0.715673, -12.3578,
|
||||
1.54849, 3.87217,
|
||||
0.271874, 0.802339,
|
||||
0.502073, -4.85485,
|
||||
-0.497037, 17.7619,
|
||||
1.19116, 13.9544,
|
||||
0.01563, 1.33157,
|
||||
0.341867, 8.93537,
|
||||
-2.31601, -5.39506,
|
||||
0.75861, 1.9645,
|
||||
0.24132, -3.23769,
|
||||
0.267151, -11.2344,
|
||||
-0.273126, 32.6248,
|
||||
1.75352, 40.432,
|
||||
-0.784011, 3.04576,
|
||||
0.705987, 5.66118,
|
||||
-1.3864, 1.35356,
|
||||
2.37646, 1.67485,
|
||||
0.242973, 4.73218,
|
||||
0.491227, 0.354061,
|
||||
-1.60676, 8.65895,
|
||||
1.16711, 5.9871,
|
||||
-0.137601, -12.0417,
|
||||
-0.251375, 10.3972,
|
||||
-1.43151, -8.90411,
|
||||
0.98828, -13.209,
|
||||
0.261484, -6.35497,
|
||||
0.395932, -0.702529,
|
||||
0.283704, 26.8996,
|
||||
0.420959, 15.4418,
|
||||
-0.355804, -13.7278,
|
||||
0.527372, 12.3985,
|
||||
-1.16956, -15.9985,
|
||||
1.90669, -5.81605,
|
||||
0.354492, 3.85157,
|
||||
0.82576, -4.16264,
|
||||
-0.49019, 13.0572,
|
||||
2.25577, 13.5264,
|
||||
-0.004956, -3.23713,
|
||||
0.026709, 7.86645,
|
||||
-1.81037, -0.451183,
|
||||
1.08383, -0.18362,
|
||||
0.135836, -2.26658,
|
||||
0.375812, -5.51225,
|
||||
-1.96644, 38.6829,
|
||||
1.97799, 24.5655,
|
||||
-0.704656, 6.35881,
|
||||
0.480786, 7.05175,
|
||||
-0.976417, -2.42273,
|
||||
2.50215, 6.75935,
|
||||
0.083588, 3.2588,
|
||||
0.543629, 0.910013,
|
||||
-1.23196, 23.0915,
|
||||
0.785492, 14.807,
|
||||
-0.213554, 1.688,
|
||||
0.004748, 18.1718,
|
||||
-1.54719, -16.1168,
|
||||
1.50104, -3.28114,
|
||||
0.080133, -4.63472,
|
||||
0.476592, -2.18093,
|
||||
0.44247, 40.304,
|
||||
1.07277, 27.592,
|
||||
-0.594738, -4.16681,
|
||||
0.42248, 7.61609,
|
||||
-0.927521, -7.27441,
|
||||
1.99162, 1.29636,
|
||||
0.291307, 2.39878,
|
||||
0.721081, -1.95062,
|
||||
-0.804256, 24.9295,
|
||||
1.64839, 19.1197,
|
||||
0.060852, -0.590639,
|
||||
0.266085, 9.10325,
|
||||
-1.9574, -2.88461,
|
||||
1.11693, 2.6724,
|
||||
0.35458, -2.74854,
|
||||
0.330733, -14.1561,
|
||||
-0.527851, 39.5756,
|
||||
0.991152, 43.195,
|
||||
-0.589619, 1.26919,
|
||||
0.787401, 8.73071,
|
||||
-1.0138, 1.02507,
|
||||
2.8254, 1.89538,
|
||||
0.24089, 2.74557,
|
||||
0.427195, 2.54446,
|
||||
-1.95311, 12.244,
|
||||
1.44862, 12.0607,
|
||||
-0.210492, -3.37906,
|
||||
-0.056713, 10.204,
|
||||
-1.65237, -5.10274,
|
||||
1.29475, -12.2708,
|
||||
0.111608, -8.67592,
|
||||
0.326634, -1.16763,
|
||||
0.021781, 31.1258,
|
||||
0.455335, 21.4684,
|
||||
-0.37544, -3.37121,
|
||||
0.39362, 11.302,
|
||||
-0.851456, -19.4149,
|
||||
2.10703, -2.22886,
|
||||
0.373233, 1.92406,
|
||||
0.884438, -1.72058,
|
||||
-0.975127, 9.84013,
|
||||
2.0033, 17.3954,
|
||||
-0.036915, -1.11137,
|
||||
0.148456, 5.39997,
|
||||
-1.91441, 4.77382,
|
||||
1.44791, 0.537122,
|
||||
0.194979, -1.03818,
|
||||
0.495771, -9.95502,
|
||||
-1.05899, 32.9471,
|
||||
2.01122, 32.4544,
|
||||
-0.30965, 4.71911,
|
||||
0.436082, 4.63552,
|
||||
-1.23711, -1.25428,
|
||||
2.02274, 9.42834,
|
||||
0.190342, 1.46077,
|
||||
0.479017, 2.48479,
|
||||
-1.07848, 16.2217,
|
||||
1.20764, 9.65421,
|
||||
-0.258087, -1.67236,
|
||||
0.071852, 13.416,
|
||||
-1.87723, -16.072,
|
||||
1.28957, -4.87118,
|
||||
0.067713, -13.4427,
|
||||
0.435551, -4.1655,
|
||||
0.46614, 30.5895,
|
||||
0.904895, 21.598,
|
||||
-0.518369, -2.53205,
|
||||
0.337363, 5.63726,
|
||||
-0.554975, -17.4005,
|
||||
1.69188, 1.14574,
|
||||
0.227934, 0.889297,
|
||||
0.587303, -5.72973,
|
||||
-0.262133, 18.6666,
|
||||
1.39505, 17.0029,
|
||||
-0.01909, 4.30838,
|
||||
0.304235, 12.6699,
|
||||
-2.07406, -6.46084,
|
||||
0.920546, 1.21296,
|
||||
0.284927, -1.78547,
|
||||
0.209724, -16.024,
|
||||
-0.636067, 31.5768,
|
||||
1.34989, 34.6775,
|
||||
-0.971625, 5.30086,
|
||||
0.590249, 4.44971,
|
||||
-1.56787, 3.60239,
|
||||
2.1455, 4.51666,
|
||||
0.296022, 4.12017,
|
||||
0.445299, 0.868772,
|
||||
-1.44193, 14.1284,
|
||||
1.35575, 6.0074,
|
||||
-0.012814, -7.49657,
|
||||
-0.43, 8.50012,
|
||||
-1.20469, -7.11326,
|
||||
1.10102, -6.83682,
|
||||
0.196463, -6.234,
|
||||
0.436747, -1.12979,
|
||||
0.141052, 22.8549,
|
||||
0.290821, 18.8114,
|
||||
-0.529536, -7.73251,
|
||||
0.63428, 10.7898,
|
||||
-1.33472, -20.3258,
|
||||
1.81564, -1.90332,
|
||||
0.394778, 3.79758,
|
||||
0.732682, -8.18382,
|
||||
-0.741244, 11.7683
|
||||
};
|
||||
|
||||
const struct lsp_codebook ge_cb[] = {
|
||||
/* codebook/gecb.txt */
|
||||
{
|
||||
2,
|
||||
8,
|
||||
256,
|
||||
codes0
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,97 @@
|
||||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* ../src/codebook/lspres_centre1.txt */
|
||||
static const float codes0[] = {
|
||||
300,
|
||||
350,
|
||||
400,
|
||||
450,
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650
|
||||
};
|
||||
/* ../src/codebook/lspres_bw1.txt */
|
||||
static const float codes1[] = {
|
||||
35,
|
||||
80,
|
||||
140,
|
||||
250
|
||||
};
|
||||
/* ../src/codebook/lsp3.txt */
|
||||
static const float codes2[] = {
|
||||
500,
|
||||
550,
|
||||
600,
|
||||
650,
|
||||
700,
|
||||
750,
|
||||
800,
|
||||
850,
|
||||
900,
|
||||
950,
|
||||
1000,
|
||||
1050,
|
||||
1100,
|
||||
1150,
|
||||
1200,
|
||||
1250
|
||||
};
|
||||
/* ../src/codebook/lsp4.txt */
|
||||
static const float codes3[] = {
|
||||
700,
|
||||
800,
|
||||
900,
|
||||
1000,
|
||||
1100,
|
||||
1200,
|
||||
1300,
|
||||
1400,
|
||||
1500,
|
||||
1600,
|
||||
1700,
|
||||
1800,
|
||||
1900,
|
||||
2000,
|
||||
2100,
|
||||
2200
|
||||
};
|
||||
|
||||
const struct lsp_codebook lsp_cbres[] = {
|
||||
/* ../src/codebook/lspres_centre1.txt */
|
||||
{
|
||||
1,
|
||||
3,
|
||||
8,
|
||||
codes0
|
||||
},
|
||||
/* ../src/codebook/lspres_bw1.txt */
|
||||
{
|
||||
1,
|
||||
2,
|
||||
4,
|
||||
codes1
|
||||
},
|
||||
/* ../src/codebook/lsp3.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes2
|
||||
},
|
||||
/* ../src/codebook/lsp4.txt */
|
||||
{
|
||||
1,
|
||||
4,
|
||||
16,
|
||||
codes3
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,565 @@
|
||||
/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */
|
||||
|
||||
/*
|
||||
* This intermediary file and the files that used to create it are under
|
||||
* The LGPL. See the file COPYING.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
/* codebook/lspvqanssi1.txt */
|
||||
static const float codes0[] = {
|
||||
0.5862, 0.7213, 0.9146, 1.0909, 1.291, 1.4954, 1.837, 2.084, 2.3771, 2.5518,
|
||||
0.0871, 0.2049, 0.5849, 0.8552, 1.2096, 1.4686, 1.821, 2.0926, 2.4508, 2.7389,
|
||||
0.2274, 0.3126, 0.6088, 0.8338, 1.1824, 1.5948, 1.8228, 1.9856, 2.1832, 2.4793,
|
||||
0.1827, 0.2706, 0.5842, 0.7761, 1.0301, 1.2462, 1.6313, 1.9786, 2.3479, 2.679,
|
||||
0.3055, 0.3863, 0.7194, 1.1609, 1.3303, 1.5017, 1.7265, 1.9412, 2.4659, 2.6315,
|
||||
0.1794, 0.2522, 0.5477, 0.7892, 1.3887, 1.7101, 1.9471, 2.1667, 2.4361, 2.631,
|
||||
0.1825, 0.2729, 0.4185, 0.6024, 1.2531, 1.7291, 1.9937, 2.1849, 2.5865, 2.7748,
|
||||
0.3219, 0.4045, 0.7357, 1.2708, 1.4626, 1.6439, 1.9388, 2.1212, 2.5005, 2.6749,
|
||||
0.2234, 0.3496, 0.5054, 0.6981, 0.8672, 1.0431, 1.7091, 2.069, 2.329, 2.6195,
|
||||
0.3009, 0.3957, 0.7576, 0.9751, 1.1955, 1.7727, 2.0383, 2.2474, 2.5612, 2.7188,
|
||||
0.3841, 0.5544, 0.9209, 1.1811, 1.5441, 1.8126, 2.1175, 2.3192, 2.5486, 2.6935,
|
||||
0.2153, 0.3105, 0.5597, 0.8313, 1.2168, 1.4512, 1.7012, 1.8962, 2.3893, 2.5852,
|
||||
0.3196, 0.4814, 0.7629, 1.0869, 1.5517, 1.778, 2.0462, 2.2547, 2.5023, 2.6706,
|
||||
0.1964, 0.3055, 0.4307, 0.7178, 1.426, 1.624, 1.8392, 2.0576, 2.2976, 2.5492,
|
||||
0.426, 0.6888, 1.2019, 1.4194, 1.6437, 1.8221, 2.0469, 2.2508, 2.5142, 2.6795,
|
||||
0.3004, 0.3944, 0.5847, 1.005, 1.1812, 1.3559, 1.5479, 1.7847, 2.4924, 2.6703,
|
||||
0.1595, 0.2398, 0.4336, 0.9228, 1.2602, 1.5064, 1.7915, 1.984, 2.232, 2.5692,
|
||||
0.1832, 0.2985, 0.4205, 0.598, 0.762, 0.9894, 1.7499, 2.1151, 2.4814, 2.7214,
|
||||
0.2234, 0.3207, 0.5457, 0.9799, 1.2074, 1.7079, 1.9734, 2.1742, 2.4575, 2.6366,
|
||||
0.3598, 0.4819, 0.6385, 0.8878, 1.3226, 1.491, 1.7257, 1.9456, 2.2061, 2.4579,
|
||||
0.4671, 0.5911, 0.8513, 1.0923, 1.5104, 1.7043, 1.9727, 2.1839, 2.4484, 2.6111,
|
||||
0.2418, 0.3937, 0.542, 0.8971, 1.1152, 1.3054, 1.7928, 1.9796, 2.5441, 2.7572,
|
||||
0.3541, 0.473, 0.6546, 0.9063, 1.0792, 1.2743, 1.8545, 2.0555, 2.3083, 2.5404,
|
||||
0.3121, 0.4016, 0.7137, 0.8835, 1.0736, 1.5907, 1.8624, 2.0857, 2.5075, 2.6668,
|
||||
0.2232, 0.3631, 0.5273, 0.7438, 1.0492, 1.2235, 1.5449, 2.2198, 2.516, 2.6852,
|
||||
0.2557, 0.3528, 0.5051, 0.6528, 0.8351, 1.5688, 1.8838, 2.1056, 2.4401, 2.6111,
|
||||
0.4342, 0.5318, 0.9234, 1.1146, 1.3015, 1.5198, 1.8211, 2.034, 2.3694, 2.5506,
|
||||
0.431, 0.5269, 0.7431, 0.9018, 1.0734, 1.5196, 1.8267, 2.0244, 2.4508, 2.6177,
|
||||
0.215, 0.3249, 0.4966, 0.9434, 1.1627, 1.3497, 1.8003, 2.0045, 2.3567, 2.5909,
|
||||
0.2798, 0.4111, 0.5786, 0.7971, 1.0414, 1.2142, 1.6947, 2.0866, 2.3351, 2.5545,
|
||||
0.1688, 0.2693, 0.4004, 0.6337, 1.3058, 1.5064, 1.7535, 1.9689, 2.5542, 2.7424,
|
||||
0.4419, 0.6209, 1.0127, 1.2135, 1.4104, 1.6111, 1.882, 2.1005, 2.4238, 2.5966,
|
||||
0.3645, 0.512, 0.8977, 1.2209, 1.5286, 1.7204, 1.9787, 2.1779, 2.439, 2.6114,
|
||||
0.2897, 0.4136, 0.5504, 0.8515, 1.2641, 1.4334, 1.8079, 2.0656, 2.3509, 2.7593,
|
||||
0.1611, 0.4723, 0.742, 1.0071, 1.2571, 1.5891, 1.9224, 2.2345, 2.5647, 2.7991,
|
||||
0.2528, 0.4178, 0.8909, 1.3117, 1.6622, 1.8641, 2.1017, 2.2974, 2.5299, 2.6982,
|
||||
0.1749, 0.27, 0.4116, 0.6036, 1.143, 1.7776, 2.0394, 2.222, 2.4667, 2.6598,
|
||||
0.3451, 0.4325, 0.6194, 0.7406, 0.9176, 1.554, 1.8426, 2.0479, 2.4401, 2.5965,
|
||||
0.3672, 0.5164, 0.6558, 0.8441, 1.2332, 1.4114, 1.6955, 2.0875, 2.3674, 2.5471,
|
||||
0.2194, 0.3467, 0.7384, 1.1079, 1.5398, 1.8437, 2.1212, 2.3296, 2.58, 2.7403,
|
||||
0.1525, 0.2343, 0.3915, 0.6843, 1.0517, 1.502, 1.7905, 1.9667, 2.2027, 2.6725,
|
||||
0.3531, 0.5908, 0.7462, 0.9441, 1.2774, 1.4743, 1.8268, 2.1059, 2.4478, 2.6484,
|
||||
0.3611, 0.4981, 0.7598, 0.9676, 1.4024, 1.633, 1.9094, 2.1433, 2.4408, 2.613,
|
||||
0.2153, 0.3366, 0.4974, 0.6693, 1.1944, 1.6791, 1.9002, 2.1105, 2.41, 2.5922,
|
||||
0.2421, 0.3392, 0.5123, 0.9818, 1.5411, 1.7092, 1.9989, 2.1981, 2.5659, 2.7656,
|
||||
0.2116, 0.325, 0.4845, 0.8021, 1.0088, 1.2158, 1.8038, 2.0223, 2.2975, 2.581,
|
||||
0.1902, 0.2942, 0.8003, 1.1086, 1.3606, 1.6008, 1.8956, 2.1328, 2.4481, 2.6405,
|
||||
0.2772, 0.3914, 0.5826, 0.7654, 0.9495, 1.124, 1.3949, 2.0411, 2.3891, 2.5959,
|
||||
0.2678, 0.522, 0.763, 1.1, 1.3747, 1.6432, 1.9391, 2.2237, 2.5511, 2.7893,
|
||||
0.32, 0.4245, 0.6174, 0.9904, 1.1662, 1.3882, 1.7601, 1.9524, 2.3998, 2.5819,
|
||||
0.1702, 0.4871, 0.837, 1.0989, 1.3593, 1.583, 1.875, 2.1277, 2.4666, 2.6885,
|
||||
0.228, 0.3748, 0.6554, 0.9113, 1.2081, 1.4619, 1.8181, 2.0541, 2.3791, 2.5701,
|
||||
0.1752, 0.4363, 0.6454, 0.8798, 1.1079, 1.5367, 1.8667, 2.1716, 2.4804, 2.7249,
|
||||
0.3804, 0.47, 0.8224, 1.0099, 1.1892, 1.5906, 1.8879, 2.0907, 2.4544, 2.6238,
|
||||
0.1808, 0.291, 0.4683, 0.7059, 0.898, 1.4031, 1.7063, 1.9444, 2.4658, 2.6776,
|
||||
0.2418, 0.3803, 0.5443, 0.7589, 1.1496, 1.3185, 1.5451, 1.7433, 2.131, 2.6523,
|
||||
0.2698, 0.369, 0.5362, 1.0732, 1.2921, 1.4696, 1.744, 1.947, 2.5051, 2.6841,
|
||||
0.4099, 0.5102, 0.6983, 1.0468, 1.2459, 1.4185, 1.8851, 2.0815, 2.3464, 2.5605,
|
||||
0.0669, 0.1354, 0.3764, 0.8433, 1.1719, 1.4834, 1.8181, 2.1312, 2.4626, 2.8044,
|
||||
0.1614, 0.2372, 0.3878, 0.5708, 1.2759, 1.495, 1.8052, 2.0807, 2.3485, 2.6293,
|
||||
0.1688, 0.2875, 0.4301, 0.9059, 1.2361, 1.4054, 1.8057, 1.9924, 2.5589, 2.7495,
|
||||
0.2864, 0.3783, 0.7032, 1.0817, 1.2382, 1.5741, 1.8619, 2.0656, 2.5139, 2.6848,
|
||||
0.3829, 0.4781, 0.6766, 0.834, 1.0056, 1.4147, 1.665, 1.884, 2.3922, 2.5619,
|
||||
0.3259, 0.4187, 0.6139, 0.7338, 1.1831, 1.6497, 1.9, 2.1278, 2.4322, 2.593,
|
||||
0.2569, 0.379, 0.5426, 0.839, 0.9871, 1.485, 1.8652, 2.0732, 2.4314, 2.6005,
|
||||
0.1408, 0.2283, 0.4024, 0.8784, 1.1485, 1.4003, 1.7004, 1.9205, 2.3723, 2.6522,
|
||||
0.2971, 0.5039, 0.8005, 1.1212, 1.4232, 1.7801, 2.1255, 2.3907, 2.6795, 2.8487,
|
||||
0.1515, 0.2344, 0.4684, 0.804, 1.0401, 1.3774, 1.8329, 2.1235, 2.5555, 2.777,
|
||||
0.5778, 0.7157, 0.891, 1.0966, 1.4235, 1.6482, 1.9551, 2.1831, 2.4572, 2.6234,
|
||||
0.3017, 0.4161, 0.8088, 0.9971, 1.2, 1.4419, 1.7867, 2.0224, 2.3473, 2.54,
|
||||
0.1208, 0.2814, 0.6564, 0.9448, 1.2377, 1.5663, 1.9084, 2.2112, 2.5583, 2.8155,
|
||||
0.2127, 0.3127, 0.4635, 0.6416, 0.8449, 1.6652, 2.0577, 2.2656, 2.5811, 2.7434,
|
||||
0.1942, 0.3011, 0.4212, 0.6901, 1.5369, 1.7639, 1.9608, 2.1766, 2.4435, 2.6663,
|
||||
0.351, 0.4345, 0.7146, 0.9086, 1.0678, 1.2579, 1.4425, 2.0265, 2.4574, 2.6252,
|
||||
0.3225, 0.4323, 0.6168, 0.858, 1.5388, 1.791, 1.9927, 2.2013, 2.4494, 2.616,
|
||||
0.2271, 0.4488, 0.6287, 0.7857, 1.2086, 1.383, 1.6194, 2.1955, 2.5236, 2.6945,
|
||||
0.2568, 0.351, 0.5613, 1.05, 1.2521, 1.4359, 1.6995, 1.9187, 2.2148, 2.4275,
|
||||
0.2933, 0.3941, 0.6128, 0.8899, 1.072, 1.2862, 1.5331, 1.8301, 2.1553, 2.3865,
|
||||
0.348, 0.4626, 0.6009, 0.763, 0.9044, 1.1225, 1.8539, 2.1845, 2.5035, 2.7091,
|
||||
0.1337, 0.4722, 0.8099, 1.1273, 1.4252, 1.699, 2.0188, 2.2922, 2.6018, 2.8168,
|
||||
0.1138, 0.3263, 0.8059, 1.0473, 1.3262, 1.6202, 1.9439, 2.2007, 2.5347, 2.7702,
|
||||
0.1979, 0.313, 0.4635, 0.8504, 1.1143, 1.3221, 2.0371, 2.2421, 2.5406, 2.7491,
|
||||
0.3321, 0.4194, 0.8239, 1.0458, 1.1981, 1.3733, 1.5661, 1.9985, 2.3747, 2.5416,
|
||||
0.3729, 0.5958, 0.9551, 1.265, 1.5484, 1.9255, 2.2256, 2.4809, 2.7276, 2.8935,
|
||||
0.1664, 0.2516, 0.5347, 0.7545, 1.1971, 1.4089, 1.74, 2.0871, 2.4098, 2.6795,
|
||||
0.237, 0.3178, 0.6123, 1.3315, 1.547, 1.7257, 2.0063, 2.1977, 2.5449, 2.7252,
|
||||
0.203, 0.3328, 0.4766, 0.7357, 1.278, 1.4439, 1.7229, 1.9405, 2.2278, 2.6816,
|
||||
0.1702, 0.2919, 0.4598, 0.7123, 0.9077, 1.145, 1.8632, 2.0806, 2.499, 2.71,
|
||||
0.2421, 0.3578, 0.54, 0.7217, 0.8971, 1.4898, 1.8518, 2.1205, 2.6077, 2.7894,
|
||||
0.303, 0.3935, 0.5812, 0.7404, 0.9425, 1.8342, 2.0887, 2.2811, 2.5596, 2.7118,
|
||||
0.1322, 0.1997, 0.3466, 0.6981, 1.1811, 1.4849, 1.8594, 2.1114, 2.4708, 2.7804,
|
||||
0.2317, 0.3069, 0.686, 1.4306, 1.7121, 1.8671, 2.1249, 2.2995, 2.5705, 2.7456,
|
||||
0.3778, 0.4863, 0.6639, 0.9163, 1.156, 1.3186, 1.5389, 1.7169, 2.1603, 2.5797,
|
||||
0.2118, 0.3499, 0.5259, 0.72, 1.1348, 1.314, 1.5657, 2.0241, 2.2873, 2.5184,
|
||||
0.2902, 0.4368, 0.6331, 0.8971, 1.3102, 1.5219, 1.8674, 2.1512, 2.4708, 2.6809,
|
||||
0.1418, 0.3988, 0.6251, 0.8544, 1.1268, 1.3964, 1.7585, 2.0322, 2.3964, 2.6928,
|
||||
0.2314, 0.3462, 0.7282, 0.9211, 1.1766, 1.4941, 1.7368, 1.9546, 2.517, 2.7066,
|
||||
0.2076, 0.3251, 0.7423, 0.959, 1.1936, 1.5329, 1.8887, 2.1588, 2.4667, 2.6709,
|
||||
0.2058, 0.4139, 0.5745, 0.7832, 0.9595, 1.1688, 1.7561, 1.9562, 2.484, 2.7001,
|
||||
0.1834, 0.2971, 0.4643, 0.6625, 0.8802, 1.1137, 1.5183, 1.8417, 2.3842, 2.7042,
|
||||
0.1688, 0.4218, 0.707, 1.0465, 1.4496, 1.6953, 1.956, 2.2174, 2.5172, 2.7404,
|
||||
0.2323, 0.3981, 0.5489, 0.7227, 1.2886, 1.5221, 1.7158, 2.1184, 2.4066, 2.5898,
|
||||
0.347, 0.5265, 0.814, 1.0152, 1.3206, 1.5411, 1.849, 2.0588, 2.3556, 2.5393,
|
||||
0.1707, 0.2595, 0.6762, 0.9037, 1.2781, 1.4903, 1.7946, 2.061, 2.3741, 2.5771,
|
||||
0.1457, 0.2318, 0.6039, 1.0078, 1.3461, 1.5908, 1.8818, 2.1248, 2.4432, 2.6714,
|
||||
0.6574, 0.8086, 1.0243, 1.2183, 1.4837, 1.7129, 2.0197, 2.2464, 2.5059, 2.6716,
|
||||
0.2546, 0.4983, 0.8674, 1.2536, 1.6704, 1.9529, 2.2134, 2.4319, 2.6532, 2.8109,
|
||||
0.2455, 0.3379, 0.4632, 0.8635, 1.5286, 1.8047, 1.9909, 2.1806, 2.4031, 2.5729,
|
||||
0.4772, 0.6742, 1, 1.2474, 1.5288, 1.7415, 2.0102, 2.2168, 2.477, 2.6449,
|
||||
0.3357, 0.4382, 0.6033, 1.1317, 1.3681, 1.5576, 1.9251, 2.1119, 2.5548, 2.7395,
|
||||
0.2588, 0.7015, 0.8953, 1.083, 1.2828, 1.516, 1.8965, 2.1921, 2.515, 2.7258,
|
||||
0.2466, 0.3512, 0.5047, 0.6646, 0.8161, 1.2577, 1.8046, 2.0214, 2.4447, 2.6491,
|
||||
0.1631, 0.2283, 0.407, 0.5955, 1.1126, 1.3894, 1.8978, 2.1849, 2.5384, 2.7382,
|
||||
0.3424, 0.4748, 0.6222, 0.802, 0.9706, 1.1568, 1.7044, 1.9297, 2.2127, 2.5627,
|
||||
0.2088, 0.5143, 0.74, 0.9277, 1.1032, 1.3561, 1.8841, 2.2004, 2.5882, 2.7993,
|
||||
0.2016, 0.3488, 0.5894, 0.7419, 1.1488, 1.3626, 1.5566, 1.9694, 2.5488, 2.7209,
|
||||
0.2558, 0.3914, 0.536, 0.7521, 1.433, 1.6955, 1.8886, 2.1428, 2.419, 2.5966,
|
||||
0.4021, 0.5034, 0.6653, 0.8123, 0.9586, 1.2825, 1.9184, 2.112, 2.409, 2.597,
|
||||
0.2343, 0.48, 0.6934, 0.8523, 1.2786, 1.4763, 1.7235, 2.04, 2.3602, 2.5562,
|
||||
0.246, 0.3687, 0.5325, 0.7044, 1.1488, 1.3608, 1.8112, 2.0757, 2.4183, 2.663,
|
||||
0.1616, 0.3644, 0.5725, 0.9166, 1.2481, 1.4938, 1.8388, 2.1175, 2.4712, 2.7464,
|
||||
0.376, 0.4841, 0.635, 1.0082, 1.211, 1.4003, 1.8127, 2.0018, 2.5199, 2.7238,
|
||||
0.1988, 0.2824, 0.6553, 1.0337, 1.5413, 1.7369, 1.9751, 2.1751, 2.4372, 2.6265,
|
||||
0.2728, 0.4094, 0.7498, 1.0645, 1.3516, 1.5946, 1.991, 2.2172, 2.483, 2.6614,
|
||||
0.1657, 0.5327, 0.7281, 0.9966, 1.2385, 1.4629, 1.8119, 2.0973, 2.4469, 2.6979,
|
||||
0.1413, 0.2098, 0.354, 0.5492, 0.8486, 1.1288, 1.632, 1.9056, 2.2805, 2.5438,
|
||||
0.2856, 0.3666, 0.6259, 1.1424, 1.6605, 1.8197, 2.0147, 2.1986, 2.4121, 2.5919,
|
||||
0.2725, 0.4829, 0.765, 1.0119, 1.2977, 1.5488, 1.8755, 2.1155, 2.4383, 2.6377,
|
||||
0.2736, 0.3804, 0.5537, 1.0258, 1.2269, 1.4186, 1.9718, 2.1468, 2.5665, 2.7689,
|
||||
0.2341, 0.5953, 1.103, 1.4549, 1.7361, 1.9758, 2.2126, 2.4213, 2.6405, 2.8181,
|
||||
0.2273, 0.4638, 0.6228, 0.85, 1.1016, 1.2823, 1.7094, 1.9523, 2.2669, 2.7029,
|
||||
0.2438, 0.3798, 0.7299, 0.96, 1.3765, 1.6104, 1.8644, 2.1161, 2.5073, 2.7137,
|
||||
0.1551, 0.4869, 0.8676, 1.2274, 1.5069, 1.8857, 2.1868, 2.4411, 2.7106, 2.8767,
|
||||
0.2746, 0.5454, 0.7589, 0.9458, 1.1597, 1.3349, 1.6653, 2.1142, 2.4356, 2.6239,
|
||||
0.1793, 0.2646, 0.4344, 0.7482, 1.1502, 1.3733, 1.8558, 2.0817, 2.3248, 2.5171,
|
||||
0.2698, 0.4202, 0.5765, 0.8301, 1.0073, 1.2101, 1.9714, 2.2051, 2.5138, 2.7395,
|
||||
0.1929, 0.3091, 0.446, 0.6266, 1.1805, 1.3672, 1.599, 2.1514, 2.4729, 2.6468,
|
||||
0.1901, 0.3047, 0.4607, 1.1019, 1.3168, 1.5343, 1.9234, 2.1365, 2.5924, 2.7807,
|
||||
0.3139, 0.5009, 0.67, 0.8268, 1.0117, 1.181, 1.6539, 2.1984, 2.4828, 2.6576,
|
||||
0.1403, 0.2173, 0.4117, 0.7302, 1.0038, 1.2732, 1.7392, 2.0337, 2.3809, 2.7386,
|
||||
0.4166, 0.5101, 0.7449, 1.1663, 1.3492, 1.5543, 1.9, 2.0941, 2.4588, 2.6365,
|
||||
0.3342, 0.4335, 0.616, 0.8559, 1.0112, 1.2097, 1.4029, 1.6361, 2.4129, 2.6324,
|
||||
0.4543, 0.6159, 0.7932, 0.9843, 1.2562, 1.4308, 1.7116, 1.9919, 2.2671, 2.4631,
|
||||
0.2153, 0.3609, 0.5302, 0.7089, 0.8756, 1.0376, 1.6496, 2.2826, 2.568, 2.7441,
|
||||
0.438, 0.6439, 0.8282, 1.0651, 1.365, 1.5829, 1.8838, 2.1005, 2.4006, 2.5771,
|
||||
0.2523, 0.3636, 0.5879, 1.1628, 1.3542, 1.6756, 2.0488, 2.2543, 2.6093, 2.7953,
|
||||
0.4179, 0.5426, 0.7065, 0.8996, 1.0684, 1.3146, 1.9705, 2.2021, 2.5051, 2.7061,
|
||||
0.1659, 0.286, 0.6693, 0.9229, 1.3959, 1.6544, 1.9709, 2.2257, 2.5236, 2.746,
|
||||
0.254, 0.4356, 0.5946, 0.7627, 1.2274, 1.4222, 1.6573, 1.9601, 2.2514, 2.4711,
|
||||
0.1633, 0.2337, 0.3698, 0.5421, 1.1757, 1.5916, 2.1561, 2.3371, 2.5534, 2.7737,
|
||||
0.1953, 0.273, 0.4521, 1.2005, 1.7062, 1.8627, 2.1313, 2.3266, 2.5906, 2.7667,
|
||||
0.3053, 0.4054, 0.5651, 0.747, 0.891, 1.172, 1.8864, 2.1074, 2.3705, 2.5744,
|
||||
0.1761, 0.3033, 0.6501, 0.8268, 1.0369, 1.2687, 1.8534, 2.1889, 2.5074, 2.7339,
|
||||
0.2265, 0.399, 1.1359, 1.4137, 1.6839, 1.8912, 2.0948, 2.3042, 2.5489, 2.7234,
|
||||
0.3326, 0.54, 0.8711, 1.0948, 1.3752, 1.6155, 1.936, 2.1537, 2.4451, 2.6133,
|
||||
0.2162, 0.3522, 0.5309, 0.747, 0.9677, 1.1747, 1.5056, 1.7942, 2.1615, 2.48,
|
||||
0.1872, 0.2761, 0.4053, 0.7469, 1.5858, 1.8945, 2.1198, 2.3197, 2.5819, 2.7758,
|
||||
0.5381, 0.8651, 1.2695, 1.4918, 1.7774, 1.9696, 2.1865, 2.3687, 2.5739, 2.7158,
|
||||
0.2663, 0.3422, 0.6098, 1.212, 1.4516, 1.6092, 1.8506, 2.0376, 2.2929, 2.5088,
|
||||
0.1904, 0.3051, 0.5663, 0.7391, 1.1589, 1.5705, 1.8756, 2.1653, 2.5518, 2.7693,
|
||||
0.1543, 0.3519, 0.6976, 1.0664, 1.3696, 1.7817, 2.1308, 2.4259, 2.707, 2.8753,
|
||||
0.3304, 0.4283, 0.5942, 0.7425, 0.8906, 1.4067, 2.0676, 2.246, 2.5394, 2.7006,
|
||||
0.208, 0.3215, 0.6278, 0.7882, 1.3123, 1.5592, 1.8048, 2.0831, 2.4303, 2.6266,
|
||||
0.1188, 0.2481, 0.827, 1.242, 1.5824, 1.8976, 2.1816, 2.4248, 2.6645, 2.8459,
|
||||
0.0635, 0.1528, 0.5973, 0.9377, 1.2653, 1.5465, 1.8818, 2.1681, 2.5089, 2.7924,
|
||||
0.3249, 0.5179, 0.9143, 1.2973, 1.4966, 1.755, 2.0715, 2.3166, 2.65, 2.8305,
|
||||
0.1918, 0.3107, 0.4506, 0.6994, 1.3463, 1.5348, 1.8447, 2.1903, 2.448, 2.6877,
|
||||
0.3405, 0.4644, 0.7232, 0.9199, 1.2611, 1.5175, 1.8446, 2.0652, 2.3915, 2.5781,
|
||||
0.3289, 0.5152, 0.6602, 1.0213, 1.1886, 1.5496, 1.9553, 2.1883, 2.5394, 2.7362,
|
||||
0.3, 0.4097, 0.8372, 1.0793, 1.3095, 1.5684, 1.8746, 2.0783, 2.3643, 2.549,
|
||||
0.2421, 0.328, 0.5288, 0.9261, 1.6911, 1.8959, 2.1013, 2.2823, 2.5238, 2.696,
|
||||
0.107, 0.3131, 0.6226, 0.8881, 1.1808, 1.4867, 1.8146, 2.1088, 2.4594, 2.7186,
|
||||
0.44, 0.5533, 0.7025, 0.9206, 1.4089, 1.582, 1.808, 2.0832, 2.3577, 2.53,
|
||||
0.225, 0.3434, 0.4808, 0.6721, 0.8198, 1.1446, 2.0201, 2.2625, 2.552, 2.7604,
|
||||
0.1671, 0.2551, 0.4603, 0.6777, 0.9661, 1.5579, 1.8659, 2.1196, 2.4425, 2.6551,
|
||||
0.391, 0.5877, 1.0287, 1.3547, 1.6899, 1.9166, 2.1451, 2.3337, 2.5519, 2.7071,
|
||||
0.1435, 0.2165, 0.3968, 0.8376, 1.2572, 1.5298, 1.8791, 2.1352, 2.4636, 2.7011,
|
||||
0.1756, 0.2799, 0.412, 0.5808, 0.7573, 1.334, 1.8235, 2.12, 2.4993, 2.7365,
|
||||
0.1332, 0.2174, 0.4716, 0.9483, 1.2723, 1.6028, 1.9272, 2.219, 2.5588, 2.799,
|
||||
0.2122, 0.3143, 0.7042, 0.8849, 1.1312, 1.3711, 1.6832, 1.9633, 2.2685, 2.5156,
|
||||
0.2089, 0.3339, 0.4817, 0.8526, 1.0657, 1.2741, 1.5747, 1.8, 2.486, 2.6843,
|
||||
0.1636, 0.2617, 0.44, 0.7357, 1.0355, 1.2638, 1.5672, 1.8504, 2.1904, 2.6588,
|
||||
0.1945, 0.2934, 0.4869, 0.8567, 1.1262, 1.3604, 1.6898, 1.9143, 2.1475, 2.3503,
|
||||
0.1606, 0.2442, 0.3931, 0.9237, 1.5811, 1.7529, 2.0133, 2.2272, 2.525, 2.7265,
|
||||
0.4866, 0.7045, 1.0593, 1.2795, 1.5326, 1.8221, 2.1461, 2.3665, 2.6041, 2.7599,
|
||||
0.4012, 0.4911, 0.7103, 0.8585, 1.0495, 1.7244, 2.0116, 2.2041, 2.5189, 2.6643,
|
||||
0.4365, 0.6694, 0.8644, 1.133, 1.451, 1.7627, 2.1032, 2.369, 2.628, 2.8306,
|
||||
0.2072, 0.4018, 0.6227, 0.8913, 1.3038, 1.6056, 1.9704, 2.2816, 2.6135, 2.8182,
|
||||
0.3302, 0.4968, 0.8713, 1.0761, 1.2576, 1.4654, 1.8152, 2.14, 2.5404, 2.7493,
|
||||
0.1385, 0.2292, 0.353, 0.6006, 1.4699, 1.6571, 1.9438, 2.1663, 2.5027, 2.7308,
|
||||
0.1894, 0.2915, 0.4345, 0.6341, 1.0024, 1.1896, 1.6896, 2.0966, 2.4086, 2.6768,
|
||||
0.3841, 0.5197, 0.8889, 1.148, 1.4383, 1.6285, 1.8642, 2.0669, 2.3466, 2.5325,
|
||||
0.2008, 0.3097, 0.4664, 0.6638, 1.2798, 1.494, 1.727, 2.0264, 2.2915, 2.475,
|
||||
0.1864, 0.2857, 0.4481, 1.1025, 1.3096, 1.5035, 1.7614, 1.9891, 2.4255, 2.6031,
|
||||
0.4081, 0.6134, 0.9514, 1.1818, 1.3943, 1.6361, 1.9891, 2.2395, 2.5547, 2.7287,
|
||||
0.2964, 0.3876, 0.945, 1.2247, 1.3906, 1.5882, 1.8241, 2.0589, 2.4188, 2.5871,
|
||||
0.3127, 0.4038, 0.6168, 1.081, 1.3067, 1.4759, 1.8817, 2.0781, 2.3394, 2.5539,
|
||||
0.2066, 0.3059, 0.4989, 0.7132, 0.9066, 1.446, 1.7584, 1.9755, 2.221, 2.4741,
|
||||
0.2634, 0.3956, 0.5667, 0.8777, 1.0517, 1.6029, 2.059, 2.2607, 2.6064, 2.7647,
|
||||
0.4331, 0.5315, 0.7764, 1.0444, 1.2269, 1.4311, 1.7093, 1.9187, 2.4337, 2.6149,
|
||||
0.2161, 0.4429, 0.6851, 0.8336, 1.1037, 1.2966, 1.5283, 2.0299, 2.3407, 2.5384,
|
||||
0.2814, 0.3637, 0.5416, 0.9475, 1.5137, 1.6945, 1.8892, 2.1017, 2.319, 2.5007,
|
||||
0.4454, 0.6883, 1.1402, 1.4098, 1.7435, 2.0014, 2.2521, 2.4457, 2.6495, 2.7985,
|
||||
0.1641, 0.4083, 0.6426, 1.0592, 1.3258, 1.5754, 1.8666, 2.1381, 2.4572, 2.7177,
|
||||
0.3391, 0.4607, 0.6072, 0.8463, 1.4207, 1.6062, 1.8303, 2.0887, 2.3615, 2.5348,
|
||||
0.2414, 0.3396, 0.51, 0.747, 1.3329, 1.8618, 2.0751, 2.2564, 2.5147, 2.6874,
|
||||
0.1694, 0.2535, 0.4156, 0.8302, 1.2853, 1.5838, 2.0907, 2.3085, 2.5929, 2.7951,
|
||||
0.2047, 0.3652, 0.65, 0.8068, 1.0178, 1.1865, 1.4889, 2.0671, 2.5966, 2.7634,
|
||||
0.2425, 0.3247, 0.602, 1.2226, 1.4272, 1.5996, 1.8377, 2.0413, 2.5333, 2.7021,
|
||||
0.3842, 0.503, 0.6541, 0.8771, 1.0576, 1.2612, 1.6744, 1.8735, 2.4781, 2.6803,
|
||||
0.2042, 0.328, 0.7283, 0.8985, 1.1444, 1.3299, 1.6032, 2.1539, 2.4739, 2.6547,
|
||||
0.1268, 0.1924, 0.3208, 0.5153, 1.1304, 1.4443, 1.8047, 2.0552, 2.4385, 2.7572,
|
||||
0.2713, 0.3659, 0.5395, 1.0705, 1.4228, 1.5836, 1.9763, 2.1641, 2.4459, 2.6301,
|
||||
0.3047, 0.4043, 0.5727, 0.7368, 0.8997, 1.3242, 1.6473, 1.8879, 2.433, 2.6295,
|
||||
0.1224, 0.3948, 0.6903, 0.9199, 1.2852, 1.5516, 1.8645, 2.1231, 2.4657, 2.7044,
|
||||
0.2157, 0.3281, 0.5036, 0.9272, 1.0975, 1.5285, 1.808, 2.0569, 2.5448, 2.7221,
|
||||
0.167, 0.249, 0.3696, 0.5921, 1.3019, 1.8398, 2.2165, 2.3725, 2.6142, 2.8338,
|
||||
0.3899, 0.5573, 0.81, 1.0732, 1.3966, 1.6598, 2.0001, 2.2517, 2.5548, 2.7403,
|
||||
0.4905, 0.6064, 0.8222, 0.9966, 1.1912, 1.5714, 1.9628, 2.1727, 2.53, 2.7055,
|
||||
0.1309, 0.2342, 0.6232, 0.8795, 1.1283, 1.3655, 1.7371, 2.0251, 2.3992, 2.6885,
|
||||
0.1805, 0.2672, 0.4297, 1.244, 1.4967, 1.6796, 1.9592, 2.1784, 2.5439, 2.7289,
|
||||
0.228, 0.5429, 0.6967, 0.8732, 1.4074, 1.6074, 1.9516, 2.2124, 2.5486, 2.7722,
|
||||
0.2339, 0.3379, 0.4924, 0.9061, 1.3074, 1.4719, 1.8884, 2.111, 2.3618, 2.5545,
|
||||
0.1384, 0.2291, 0.5127, 1.045, 1.4017, 1.7884, 2.1134, 2.3664, 2.6588, 2.8435,
|
||||
0.2196, 0.6359, 0.91, 1.2007, 1.4589, 1.7053, 2.0128, 2.2722, 2.552, 2.7643,
|
||||
0.1698, 0.2615, 0.381, 0.5706, 1.4297, 1.8686, 2.0728, 2.2559, 2.486, 2.6701,
|
||||
0.1445, 0.2158, 0.3658, 0.5451, 0.9389, 1.3669, 1.79, 2.0846, 2.3924, 2.7161,
|
||||
0.2789, 0.3816, 0.5277, 0.8487, 1.3751, 1.5461, 1.7832, 2.0264, 2.2695, 2.4665,
|
||||
0.1733, 0.3023, 0.9216, 1.2368, 1.4776, 1.7229, 1.9952, 2.2471, 2.539, 2.7265,
|
||||
0.3374, 0.5033, 1.0951, 1.3262, 1.5284, 1.7336, 1.9733, 2.2009, 2.4992, 2.6751,
|
||||
0.1293, 0.2743, 0.7533, 1.0166, 1.2416, 1.4444, 1.7962, 2.0851, 2.477, 2.7204,
|
||||
0.3106, 0.4176, 0.6358, 0.9434, 1.1419, 1.3458, 1.9638, 2.1678, 2.439, 2.6235,
|
||||
0.4533, 0.576, 0.7392, 0.9136, 1.0829, 1.2759, 1.7903, 2.036, 2.3124, 2.5325,
|
||||
0.3702, 0.5218, 0.6977, 0.8776, 1.1096, 1.2855, 1.5612, 1.948, 2.217, 2.4361,
|
||||
0.1637, 0.2647, 0.4185, 0.6666, 1.1584, 1.327, 1.7829, 1.9821, 2.4361, 2.7094,
|
||||
0.1769, 0.2767, 0.3942, 0.5746, 1.3595, 1.711, 1.9176, 2.1405, 2.3722, 2.5705,
|
||||
0.2712, 0.382, 0.6524, 0.8317, 1.0341, 1.3972, 1.7312, 1.9918, 2.3854, 2.5886,
|
||||
0.1003, 0.2046, 0.7261, 1.1004, 1.4057, 1.6697, 1.9903, 2.2603, 2.5813, 2.8009,
|
||||
0.2534, 0.3752, 0.7192, 0.9323, 1.3698, 1.5955, 1.8653, 2.0656, 2.3368, 2.534,
|
||||
0.3589, 0.4508, 0.6631, 1.0521, 1.5065, 1.6697, 1.8929, 2.1074, 2.3466, 2.5242,
|
||||
0.1955, 0.2862, 0.6111, 0.8053, 1.0501, 1.5218, 1.7996, 2.0303, 2.3788, 2.5973,
|
||||
0.2982, 0.4033, 0.566, 0.8924, 1.1933, 1.3465, 1.7895, 2.0173, 2.2606, 2.5069,
|
||||
0.3356, 0.4711, 0.631, 0.8491, 1.0049, 1.4364, 1.8176, 2.0292, 2.571, 2.7525,
|
||||
0.2016, 0.2912, 0.4363, 0.98, 1.4897, 1.6494, 1.8862, 2.0819, 2.3636, 2.6091,
|
||||
0.4549, 0.6491, 0.845, 1.0209, 1.1747, 1.3745, 1.8824, 2.113, 2.376, 2.5768,
|
||||
0.251, 0.3524, 0.5171, 0.8931, 1.4094, 1.571, 1.8536, 2.0478, 2.4766, 2.732,
|
||||
0.1576, 0.2547, 0.3891, 0.8551, 1.4282, 1.588, 1.8583, 2.0521, 2.5359, 2.734,
|
||||
0.3481, 0.4382, 0.772, 1.1289, 1.3203, 1.5019, 1.7665, 1.957, 2.2231, 2.4465,
|
||||
0.3116, 0.4068, 0.6991, 0.8894, 1.0912, 1.5356, 1.8084, 2.0006, 2.2323, 2.4367,
|
||||
0.2706, 0.4033, 0.8272, 1.0851, 1.482, 1.6927, 1.9292, 2.1267, 2.4049, 2.5857,
|
||||
0.2745, 0.355, 0.8663, 1.3742, 1.5545, 1.7324, 1.9664, 2.1538, 2.4581, 2.6245,
|
||||
0.1736, 0.2553, 0.5357, 0.9009, 1.1888, 1.5132, 1.8579, 2.1181, 2.4273, 2.6847,
|
||||
0.3026, 0.4148, 0.9044, 1.1695, 1.3657, 1.7036, 1.9891, 2.2226, 2.5441, 2.7085,
|
||||
0.3998, 0.5108, 0.7205, 0.9848, 1.1828, 1.3716, 1.7154, 1.9191, 2.1875, 2.4257,
|
||||
0.2141, 0.3095, 0.7428, 1.0426, 1.2851, 1.5571, 1.7901, 1.9804, 2.2462, 2.5265,
|
||||
0.1574, 0.229, 0.3869, 0.5735, 1.0925, 1.3383, 1.6598, 1.9364, 2.2095, 2.4195
|
||||
};
|
||||
/* codebook/lspvqanssi2.txt */
|
||||
static const float codes1[] = {
|
||||
0.012, 0.0022, 0.0068, -0.0112, -0.0508, -0.049, 0.2249, 0.1476, 0.0133, -0.0379,
|
||||
0.0598, 0.0477, 0.038, 0.066, 0.0517, 0.015, 0.0617, 0.0081, -0.0768, -0.1007,
|
||||
-0.0087, -0.044, 0.0873, 0.0882, 0.0391, -0.006, 0.11, 0.0569, -0.0241, -0.0468,
|
||||
0.0146, -0.0005, 0.0322, -0.065, -0.0778, -0.078, -0.0255, -0.0527, -0.0301, -0.0401,
|
||||
-0.024, -0.056, -0.0374, 0.0274, 0.0484, -0.0227, 0.0328, 0.1135, 0.0117, -0.03,
|
||||
-0.0324, -0.0574, 0.0302, 0.0137, -0.0603, -0.1194, -0.0105, -0.0513, 0.0698, 0.0538,
|
||||
0.0635, 0.0382, 0.0531, 0.0897, 0.0495, 0.0039, -0.0421, -0.0919, 0.0407, 0.0167,
|
||||
0.0954, 0.0854, 0.036, -0.0025, -0.0252, -0.0528, -0.0435, -0.0561, -0.0405, -0.0432,
|
||||
0.011, -0.001, -0.0433, -0.0167, 0.1402, 0.0738, 0.0423, -0.0024, -0.092, -0.1099,
|
||||
0.0179, 0.0184, -0.0041, -0.064, 0.1004, 0.0608, -0.0023, -0.0357, 0.1509, 0.1262,
|
||||
-0.0145, -0.024, -0.0595, -0.1063, 0.0597, -0.004, -0.0886, 0.1184, 0.038, 0.0126,
|
||||
-0.0072, 0.0172, 0.0076, 0.0288, 0.081, 0.0278, 0.0709, 0.0051, 0.0214, -0.0301,
|
||||
0.0127, -0.0126, -0.0434, 0.161, 0.1178, 0.0704, 0.0257, -0.0073, -0.0425, -0.061,
|
||||
-0.0165, -0.0369, -0.0785, 0.1007, 0.0309, -0.0651, 0.0142, -0.0614, 0.0426, 0.0289,
|
||||
-0.0374, -0.0712, 0.0049, -0.0382, 0.0472, 0.0095, -0.0268, -0.0747, -0.0457, -0.0758,
|
||||
-0.0211, -0.0432, -0.0547, -0.0446, -0.1078, 0.009, -0.0565, -0.1298, 0.0721, 0.0351,
|
||||
-0.0014, -0.0072, -0.0283, -0.0324, -0.0208, -0.0703, 0.0979, 0.0865, -0.0007, 0.1881,
|
||||
-0.0077, -0.0302, 0.1231, 0.0905, 0.0786, 0.0432, -0.0286, -0.0661, -0.0055, -0.0275,
|
||||
0.001, 0.0043, 0.0044, 0.038, -0.1201, -0.0098, -0.0166, 0.0105, 0.0153, 0.0134,
|
||||
0.0843, 0.0636, 0.0416, -0.0004, -0.057, -0.0592, 0.1158, 0.059, 0.0126, 0.0034,
|
||||
0.0346, 0.029, -0.0037, -0.0026, -0.0457, 0.1824, 0.1469, 0.087, 0.0291, -0.0074,
|
||||
0.0066, 0.0682, -0.0148, 0.0287, 0.0095, -0.0563, 0.1296, 0.0426, 0.1215, 0.0886,
|
||||
-0.0132, -0.0399, 0.096, 0.0474, 0.014, 0.0306, -0.0192, -0.0703, -0.1559, -0.1556,
|
||||
-0.06, 0.0482, 0.1257, 0.0521, 0.0229, -0.0031, 0.0817, 0.0571, -0.0138, -0.0277,
|
||||
0.0013, -0.0103, -0.047, -0.0687, -0.1444, 0.0181, 0.135, 0.0559, -0.0177, -0.0598,
|
||||
-0.0215, -0.0318, -0.0689, -0.0268, 0.0917, 0.0307, 0.0135, -0.0184, -0.0857, 0.1231,
|
||||
0.0137, -0.0152, 0.0199, -0.0291, -0.0685, 0.0438, -0.1137, 0.0231, -0.0632, -0.0802,
|
||||
-0.0011, 0.0314, 0.0535, -0.0135, -0.0291, -0.0579, -0.1049, 0.0288, -0.0628, 0.1355,
|
||||
-0.0901, 0.0041, -0.017, 0.0351, 0.0144, -0.0505, 0.0396, 0.0638, -0.0145, 0.0141,
|
||||
-0.04, -0.0603, -0.0714, 0.0329, -0.0049, -0.0529, -0.1251, 0.0022, -0.0449, -0.0778,
|
||||
0.0247, 0.0296, 0.0239, 0.0122, -0.0348, -0.1224, -0.0033, 0.1237, -0.0016, -0.0436,
|
||||
0.0246, 0.005, 0.0322, 0.0818, 0.0203, 0.0846, 0.0022, 0.0876, 0.0149, -0.0184,
|
||||
-0.0204, -0.0228, 0.0365, -0.0164, 0.1087, 0.0374, -0.055, 0.033, -0.0582, -0.0736,
|
||||
-0.0305, -0.0485, -0.0572, 0.0275, -0.0271, -0.0436, 0.1217, 0.07, 0.1253, 0.099,
|
||||
-0.0079, -0.0204, -0.0325, 0.0491, 0.0158, -0.0365, -0.1309, -0.1812, 0.1428, 0.1148,
|
||||
0.068, 0.0547, 0.0309, 0.0079, -0.0332, 0.0391, -0.0287, 0.1258, 0.1123, 0.1016,
|
||||
-0.0264, -0.0409, -0.0538, -0.0192, -0.0393, -0.0713, -0.0618, -0.1078, -0.185, 0.0532,
|
||||
0.0081, -0.0115, -0.009, 0.1201, -0.0413, -0.0995, 0.0445, -0.0032, -0.0286, -0.0497,
|
||||
-0.0023, -0.0184, -0.0358, 0.1279, 0.0847, 0.053, 0.023, -0.0212, 0.1245, 0.0965,
|
||||
0.0111, 0.1038, 0.0597, 0.0413, 0.0533, 0.0011, 0.0031, 0.0705, 0.0242, 0.0198,
|
||||
0.002, -0.0071, -0.0262, -0.0496, -0.075, -0.1273, -0.1785, 0.0606, -0.0223, -0.0583,
|
||||
-0.0202, 0.0669, 0.0081, 0.0335, -0.0218, -0.1073, -0.0146, -0.0673, 0.049, 0.021,
|
||||
-0.0108, -0.023, -0.0614, -0.0986, 0.0629, 0.0006, 0.1496, 0.1099, 0.0316, 0.0098,
|
||||
-0.0368, -0.0685, 0.0138, -0.0213, -0.0009, 0.0344, -0.0249, 0.0311, 0.0803, 0.0759,
|
||||
0.0038, -0.0158, 0.0142, 0.0254, 0.097, 0.0021, -0.1029, 0.0006, 0.0576, 0.0261,
|
||||
-0.0083, 0.0698, 0.0406, -0.0348, 0.02, 0.0833, 0.0186, -0.0145, -0.0725, -0.0872,
|
||||
-0.0506, -0.0673, 0.0776, -0.0172, -0.0444, -0.0531, -0.0799, 0.0005, -0.0359, -0.0446,
|
||||
0.0368, 0.0376, -0.0407, -0.019, 0.0987, 0.0212, -0.0349, -0.0951, -0.0084, -0.0342,
|
||||
-0.0309, -0.0561, 0.095, -0.0125, -0.1028, -0.0133, 0.092, 0.0965, 0.0668, 0.0409,
|
||||
-0.0898, 0.0036, -0.0353, -0.0024, -0.0365, -0.0259, -0.0485, -0.0843, -0.0063, -0.0167,
|
||||
-0.0255, -0.0407, -0.0456, -0.0931, -0.0892, -0.0293, -0.051, 0.0183, -0.0104, 0.0472,
|
||||
-0.0172, -0.0399, -0.0731, 0.0546, 0.032, -0.0283, 0.0415, -0.0107, -0.1237, -0.1102,
|
||||
0.021, 0.0294, -0.0038, -0.009, -0.0551, -0.0922, 0.0261, -0.0334, -0.1181, -0.1536,
|
||||
0.0092, 0.0032, -0.0162, 0.0398, 0.0205, 0.1266, -0.0107, -0.0858, 0.0392, 0.0032,
|
||||
-0.0038, -0.0269, -0.0737, 0.1138, 0.0263, -0.0031, -0.1188, 0.1621, 0.0831, 0.0526,
|
||||
0.0023, -0.0149, -0.0497, 0.0898, 0.0456, -0.0145, -0.0928, -0.1507, -0.0611, -0.0938,
|
||||
0.012, 0.0124, -0.0286, -0.1319, 0.0219, 0.0311, -0.0398, -0.0465, -0.0008, -0.0375,
|
||||
0.0138, 0.0023, 0.0024, 0.1072, 0.0531, 0.0006, 0.0292, -0.0115, -0.062, 0.165,
|
||||
0.007, -0.0251, 0.0715, 0.038, -0.0404, 0.123, 0.0629, 0.0096, 0.0973, 0.0641,
|
||||
-0.0586, 0.0772, 0.0128, 0.106, 0.0715, 0.0374, -0.0074, -0.0365, -0.0543, -0.0489,
|
||||
-0.0392, 0.0871, -0.0069, -0.1084, 0.0264, -0.0495, 0.0396, 0.0005, -0.0293, -0.024,
|
||||
-0.0327, 0.0605, 0.0662, 0.01, -0.0007, -0.0525, -0.0812, -0.0686, -0.0873, -0.083,
|
||||
0.0119, 0.0058, 0.003, -0.0307, 0.065, 0.0175, -0.0741, -0.15, -0.1947, 0.0881,
|
||||
0.0572, 0.0411, 0.0152, -0.0127, -0.0589, -0.051, -0.0212, -0.0834, 0.1434, 0.1318,
|
||||
0.0518, 0.0417, -0.043, 0.0963, -0.0014, 0.0173, 0.0234, -0.0273, 0.0359, -0.0118,
|
||||
0.0652, 0.0587, 0.0013, -0.07, 0.1262, 0.0975, 0.068, 0.0598, 0.0048, -0.0305,
|
||||
-0.0185, -0.044, 0.1178, 0.0656, 0.0052, -0.0534, -0.1151, 0.1116, 0.0659, 0.0344,
|
||||
0.0788, 0.0577, 0.0452, 0.0283, -0.0278, 0.0911, 0.028, -0.0254, 0.0029, -0.0361,
|
||||
-0.0165, -0.0322, -0.0526, -0.1057, 0.0927, 0.0293, -0.1026, -0.1671, 0.047, 0.0355,
|
||||
0.01, 0.0001, -0.0221, -0.0775, -0.1109, -0.1416, 0.0884, 0.0441, 0.0632, 0.0409,
|
||||
0.0204, 0.0432, 0.0141, -0.0296, 0.1073, 0.058, 0.0383, 0.027, -0.0857, 0.1246,
|
||||
0.0488, 0.0231, 0.0648, -0.0179, 0.0747, 0.0156, -0.0384, -0.0733, -0.0732, -0.097,
|
||||
0.0005, -0.0199, -0.026, -0.0511, -0.111, 0.067, -0.0413, 0.1571, 0.0498, 0.0191,
|
||||
0.0037, -0.0085, -0.0796, 0.0086, -0.0852, 0.085, 0.0115, -0.0065, 0.1161, 0.0727,
|
||||
0.0023, 0.0483, 0.0285, -0.0642, -0.0477, 0.0175, 0.0346, 0.0452, 0.0655, 0.0284,
|
||||
-0.0986, 0.0463, 0.0326, -0.0055, 0.0702, 0.0194, -0.0423, -0.0107, 0.0338, 0.0619,
|
||||
0.0126, -0.0138, -0.1115, 0.0159, -0.0331, 0.0217, -0.0376, -0.0407, -0.0222, -0.0503,
|
||||
0.0222, 0.0071, -0.049, 0.1017, 0.0551, -0.0164, 0.1578, 0.1059, 0.0025, -0.0107,
|
||||
0.0124, -0.009, 0.0322, 0.093, 0.0281, -0.0403, -0.0781, 0.0125, -0.067, -0.1058,
|
||||
0.0363, 0.0077, 0.1052, 0.0039, 0.0676, 0.0891, 0.0433, 0.0252, 0.0224, -0.0043,
|
||||
-0.0045, -0.0194, -0.0193, -0.048, -0.064, -0.0695, -0.1597, -0.003, 0.1728, 0.1231,
|
||||
0.0297, 0.0025, 0.0619, -0.0347, -0.1171, 0.1043, 0.0868, 0.0191, -0.0739, -0.1075,
|
||||
0.0073, 0.0914, 0.0367, -0.0236, 0.0232, 0.0304, -0.0787, -0.1099, 0.046, 0.0082,
|
||||
0.0296, 0.0297, -0.0444, 0.0184, 0.0602, -0.0295, -0.0934, 0.0636, -0.0347, -0.0722,
|
||||
-0.029, -0.0629, 0.0598, 0.0013, 0.0064, 0.1431, 0.092, 0.0468, -0.0311, -0.0614,
|
||||
-0.0152, -0.0311, -0.05, -0.0672, -0.1257, -0.0134, -0.022, -0.0612, -0.1131, -0.1417,
|
||||
0.0371, 0.0153, -0.0817, -0.0007, 0.0837, 0.0481, 0.046, 0.0678, 0.0524, 0.0432,
|
||||
0.0126, -0.0069, -0.0092, -0.0693, -0.025, 0.151, 0.0098, -0.0683, -0.0566, -0.0769,
|
||||
-0.0199, -0.0423, 0.0806, 0.0562, 0.0009, -0.0563, -0.1358, -0.1578, -0.0456, 0.0032,
|
||||
0.0091, 0.0101, -0.009, -0.0279, -0.0489, -0.1038, -0.0815, 0.2184, 0.1172, 0.0902,
|
||||
-0.0024, -0.0135, 0.0392, 0.0028, 0.0792, 0.0404, 0.0867, 0.161, 0.0954, 0.0846,
|
||||
-0.0004, -0.022, -0.0282, -0.1022, -0.0799, 0.1278, 0.0765, 0.0402, 0.085, 0.0611,
|
||||
0.0443, 0.032, -0.0384, -0.0964, 0.003, -0.0398, -0.073, -0.0052, -0.0267, 0.1209,
|
||||
-0.0706, 0.1151, 0.0722, -0.0175, -0.0927, -0.0559, 0.0316, 0.0186, 0.0105, 0.0314,
|
||||
-0.0145, -0.0263, -0.0564, 0.0248, -0.0181, -0.0817, -0.0938, 0.0366, -0.0315, 0.1253,
|
||||
0.0307, 0.0039, 0.129, 0.0402, -0.0439, -0.0384, 0.0044, -0.0177, -0.0172, -0.031,
|
||||
0.0447, 0.0298, 0.0287, 0.0273, -0.035, -0.0708, -0.1829, -0.0317, 0.0643, 0.0057,
|
||||
-0.082, -0.0326, 0.0209, -0.0711, 0.0084, 0.0111, 0.0426, 0.0262, -0.0061, 0.0005,
|
||||
0.0545, 0.0377, -0.0417, -0.0625, 0.0114, -0.0405, 0.0573, 0.0191, -0.0263, -0.0472,
|
||||
-0.0053, -0.0049, -0.0255, -0.0578, -0.0237, -0.0721, -0.1487, -0.1636, 0.0046, -0.0355,
|
||||
0.0309, 0.0107, 0.0163, 0.0132, -0.0536, -0.0009, -0.0706, -0.135, -0.0514, -0.096,
|
||||
0.0306, 0.0003, 0.0494, 0.0701, 0.0027, -0.0458, 0.078, 0.0327, 0.0937, 0.0605,
|
||||
-0.0017, -0.0275, 0.0797, -0.0268, -0.1014, 0.0593, -0.0528, -0.1103, 0.0682, 0.0322,
|
||||
-0.0507, -0.0806, -0.0646, -0.0052, -0.0576, 0.0451, 0.0489, 0.015, 0.0029, -0.0189,
|
||||
0.027, 0.0143, -0.0375, -0.0071, -0.0607, -0.1157, -0.0345, -0.1115, 0.0201, -0.0104,
|
||||
-0.0807, -0.1088, 0.0845, 0.072, 0.0441, 0.0301, 0.0043, 0.0052, 0.0016, 0.0201,
|
||||
-0.029, -0.0532, 0.0036, -0.0201, -0.0723, -0.1321, 0.0867, 0.0479, -0.0556, -0.085,
|
||||
-0.0271, 0.0126, 0.1283, 0.0533, -0.003, -0.0352, -0.0326, -0.0553, 0.1402, 0.1121,
|
||||
-0.0358, -0.0518, -0.108, 0.0134, 0.095, 0.0384, -0.004, -0.0254, 0.0026, -0.0217,
|
||||
-0.0152, -0.0375, -0.0827, 0.0916, 0.0188, 0.1306, 0.0983, 0.0606, 0.0381, 0.008,
|
||||
-0.0107, -0.0269, -0.0573, -0.1189, 0.0258, 0.1009, 0.0565, 0.027, -0.0557, -0.0778,
|
||||
-0.0193, -0.0242, -0.0784, -0.0816, 0.0287, -0.0484, 0.0292, -0.0414, 0.1124, 0.0767,
|
||||
0.0177, -0.0148, 0.0472, -0.0808, 0.0623, -0.0636, 0.075, -0.0107, 0.0673, 0.0425,
|
||||
-0.022, 0.0577, -0.0769, -0.0247, -0.0321, 0.0341, -0.0108, 0.0109, -0.0142, 0.0122,
|
||||
0.0194, 0.0248, -0.0096, -0.0205, -0.046, -0.116, 0.0492, -0.0188, -0.1535, 0.0816,
|
||||
0.0301, -0.0286, -0.0077, -0.0117, -0.0036, -0.0026, 0.0133, -0.0032, 0.0007, -0.016,
|
||||
0.0115, -0.0111, 0.0246, -0.0639, 0.0325, -0.0313, 0.0808, 0.0435, -0.0777, -0.1108,
|
||||
-0.0079, -0.0334, -0.0144, -0.0539, 0.1564, 0.1175, 0.0549, 0.034, 0.0319, 0.0027,
|
||||
-0.0155, -0.0275, -0.0739, -0.0932, 0.0108, -0.0698, 0.0036, -0.0213, -0.0486, -0.067,
|
||||
-0.0234, -0.0567, 0.002, 0.0908, -0.0151, 0.046, -0.0175, -0.0523, 0.0098, -0.0237,
|
||||
0.0057, -0.0066, -0.0418, 0.0418, -0.0449, 0.1069, 0.0629, -0.0016, -0.1068, -0.1492,
|
||||
-0.0791, 0.0403, -0.0009, 0.0285, -0.0065, 0.0963, 0.055, 0.0634, 0.0693, 0.0694,
|
||||
-0.0068, -0.0197, -0.0919, 0.0071, -0.0551, -0.1173, 0.0926, 0.0413, 0.0127, -0.0158,
|
||||
0.054, 0.0389, -0.0195, -0.08, -0.1383, 0.044, -0.0139, -0.0405, 0.0147, -0.0183,
|
||||
0.038, 0.0248, 0.052, -0.0609, 0.0339, -0.007, -0.0974, 0.1182, 0.0221, -0.031,
|
||||
0.0043, 0.0046, -0.0274, -0.0502, 0.0326, -0.0143, -0.0586, -0.0866, -0.1673, -0.1624,
|
||||
0.0428, 0.0385, -0.0228, 0.0704, 0.0069, -0.0145, -0.0623, -0.0639, -0.1479, 0.0212,
|
||||
-0.0078, -0.0297, 0.0025, -0.0239, -0.0793, 0.0896, 0.0315, -0.0546, -0.1309, 0.108
|
||||
};
|
||||
/* codebook/lspvqanssi3.txt */
|
||||
static const float codes2[] = {
|
||||
-0.0291, 0.0272, -0.0364, -0.0313, -0.0487, -0.0205, 0.0501, 0.0225, 0.0178, 0.008,
|
||||
-0.0406, -0.0383, 0.0013, -0.0155, -0.0261, -0.0598, 0.0003, -0.0242, 0.0151, -0.014,
|
||||
-0.0445, 0.0356, 0.018, -0.0272, -0.0018, -0.0177, -0.0703, 0.0471, 0.0128, -0.0068,
|
||||
-0.0033, -0.0285, -0.056, -0.0186, -0.0499, -0.007, 0.0068, -0.0126, 0.0388, -0.0097,
|
||||
-0.0071, -0.0114, -0.0308, -0.0094, -0.0541, -0.0272, -0.0756, 0.0477, -0.0234, 0.0678,
|
||||
0.0048, 0.0307, -0.0174, -0.0593, 0.0097, -0.0134, 0.0034, -0.0212, -0.0418, 0.0869,
|
||||
-0.0189, 0.0165, -0.0269, 0.0744, 0.0344, -0.0177, -0.0603, 0.0212, -0.0104, 0.0345,
|
||||
-0.013, -0.0352, -0.0086, -0.0257, -0.0286, 0.0409, 0.0656, 0.0106, -0.0598, 0.0252,
|
||||
0.0041, 0.0097, -0.0032, -0.0154, -0.0405, 0.067, -0.0164, 0.0451, 0.0774, 0.0504,
|
||||
0.001, -0.0091, -0.0345, 0.0511, 0.0016, 0.0011, 0.0684, 0.0167, 0.0601, 0.0512,
|
||||
0.0204, -0.0038, -0.0426, 0.0185, -0.0191, -0.063, 0.0295, -0.0153, -0.0559, 0.056,
|
||||
-0.0461, -0.0041, 0.0515, 0.0219, 0.0322, 0.0093, 0.0044, 0.0106, -0.0329, -0.0521,
|
||||
0.0304, 0.0017, 0.0209, -0.0002, 0.0689, 0.0136, 0.0216, -0.0268, -0.0682, 0.0333,
|
||||
-0.0175, -0.0425, 0.0153, -0.005, -0.0113, 0.0297, -0.0659, -0.0344, 0.0302, -0.0272,
|
||||
-0.0217, -0.0362, 0.0426, 0.0233, -0.0393, 0.0052, 0.0138, 0.0657, 0.0427, 0.022,
|
||||
-0.0039, -0.0011, -0.0002, -0.0453, -0.0835, 0.0144, -0.0268, -0.0589, -0.0185, 0.0133,
|
||||
0.0081, -0.0032, 0.0638, 0.0032, 0.006, 0.0002, -0.0303, -0.0823, 0.0124, -0.0308,
|
||||
0.0108, 0.0011, 0.0059, 0.0396, 0.0392, 0.0351, -0.0045, -0.0323, -0.0512, -0.0975,
|
||||
-0.0144, -0.0306, -0.0302, -0.007, 0.0123, -0.0042, -0.0083, -0.0514, 0.012, 0.1116,
|
||||
-0.0046, -0.0131, 0.0472, 0.0144, -0.0296, -0.0518, 0.0337, -0.0145, -0.0733, 0.0793,
|
||||
-0.0064, -0.0162, -0.0327, -0.0711, 0.0108, -0.0131, 0.0025, -0.0254, -0.0277, -0.068,
|
||||
-0.0306, 0.0055, 0.0272, -0.0189, -0.0173, 0.0221, 0.0773, 0.0043, 0.0458, -0.0169,
|
||||
-0.0006, 0.0299, 0.0259, 0.0227, -0.053, -0.0596, -0.0271, -0.0091, 0.0181, -0.0233,
|
||||
-0.0116, -0.0398, 0.0089, 0.0708, -0.0028, -0.0084, -0.0206, -0.0354, -0.0275, -0.0037,
|
||||
0.0259, -0.0064, -0.038, 0.0572, 0.0083, 0.0286, -0.0565, 0.0158, 0.0396, -0.0123,
|
||||
0.0552, 0.0331, -0.0052, -0.0346, -0.018, -0.0194, -0.0237, 0.0184, 0.0056, -0.0199,
|
||||
0.0143, 0.0131, -0.0166, 0.0196, 0.0154, 0.031, -0.0048, 0.0901, -0.0333, 0.0761,
|
||||
0.0118, -0.0107, 0.0099, 0.0078, 0.0002, -0.0716, -0.0233, 0.0793, 0.0516, 0.03,
|
||||
0.0204, 0.0243, 0.0192, 0.0181, 0.0001, -0.0243, -0.0764, -0.0622, -0.0324, 0.064,
|
||||
0.0132, 0.0016, -0.0187, -0.0425, 0.0627, 0.0094, -0.0786, 0.0304, 0.0294, -0.0146,
|
||||
-0.0221, -0.0154, 0.0285, -0.0709, 0.0406, 0.0114, 0.0073, -0.0199, 0.0081, 0.0268,
|
||||
0.0227, 0.0055, 0.0163, -0.0447, 0.0246, 0.0795, 0.0239, 0.0211, -0.0145, -0.0576,
|
||||
-0.0119, 0.0637, 0.0278, 0.0202, -0.0086, 0.0389, 0.032, -0.0049, -0.0272, -0.0274,
|
||||
0.004, -0.0211, 0.0426, 0.048, 0.0415, 0.0659, 0.0408, 0.0198, 0.0327, 0.0029,
|
||||
0.043, 0.0311, 0.0083, 0.0353, 0.025, 0.0143, 0.0106, -0.0305, 0.0633, 0.0227,
|
||||
-0.0277, 0.0302, 0.0337, 0.0176, 0.0191, -0.0156, 0.0231, 0.0118, 0.0465, 0.0875,
|
||||
0.0221, 0.0146, 0.0147, -0.0211, -0.0317, -0.0179, -0.0049, -0.0297, -0.1078, -0.0413,
|
||||
-0.0531, 0.018, -0.0066, 0.0365, -0.0033, 0.009, -0.0158, -0.0698, 0.0315, -0.0048,
|
||||
0.0289, 0.0053, 0.0082, 0.0077, -0.0664, 0.0474, 0.0407, -0.0096, 0.0028, -0.0526,
|
||||
-0.0106, -0.0129, -0.0315, 0.0335, -0.0217, -0.0427, 0.0582, 0.0193, -0.0288, -0.0777,
|
||||
-0.0003, -0.0141, -0.0102, 0.0007, -0.0077, -0.0517, -0.0909, 0.0128, -0.0349, -0.0769,
|
||||
-0.0227, -0.0159, -0.0327, 0.0011, 0.0312, 0.01, -0.018, -0.0537, -0.0997, 0.0122,
|
||||
0.019, -0.0139, 0.0341, -0.0131, -0.0368, -0.0138, -0.0074, -0.0415, 0.0791, 0.0503,
|
||||
0.0182, 0.0027, 0.0032, -0.0325, -0.0309, -0.0898, 0.0509, -0.017, 0.0301, -0.0137,
|
||||
0.0233, 0.01, 0.0231, 0.073, 0.0212, -0.0299, 0.044, 0.0041, -0.0101, -0.0251,
|
||||
0.0074, -0.0033, -0.0285, -0.035, 0.0101, 0.0735, 0.0036, -0.0659, 0.0429, -0.0052,
|
||||
0.0148, -0.0035, -0.0233, 0.0079, -0.0142, -0.0402, -0.0358, -0.0985, -0.008, -0.0549,
|
||||
0.0203, 0.0057, -0.0604, 0.0098, 0.0402, 0.0151, 0.05, 0.0058, -0.0086, -0.0401,
|
||||
0.0056, -0.0381, 0.042, -0.0125, 0.0157, -0.0268, 0.0433, 0.0123, -0.0176, -0.0685,
|
||||
0.003, 0.0502, 0.0067, -0.0222, 0.0405, -0.0226, 0.002, -0.0401, -0.0026, -0.0521,
|
||||
0.0317, 0.0089, 0.062, 0.0251, 0.0066, 0.0089, -0.0565, 0.0414, 0.0005, -0.0365,
|
||||
-0.0058, 0.0086, -0.0291, -0.0164, -0.0134, -0.049, -0.0427, -0.0451, 0.0869, 0.0334,
|
||||
0.0024, 0.0328, -0.0415, 0.0003, -0.0287, 0.0193, -0.0547, -0.0222, -0.0196, -0.0571,
|
||||
-0.0271, -0.0397, -0.0431, -0.0043, 0.0332, 0.0093, 0.0082, 0.0585, 0.0282, 0.0004,
|
||||
-0.0251, -0.0167, -0.0289, 0.0196, -0.0363, 0.085, 0.0028, 0.0319, -0.0202, -0.0512,
|
||||
0.0389, 0.0226, 0.0401, -0.0091, -0.0152, 0.0001, 0.0738, 0.0402, 0.0097, 0.031,
|
||||
-0.0126, 0.013, -0.0046, -0.0216, 0.0298, -0.0344, 0.0713, 0.0547, -0.047, -0.0294,
|
||||
0.0125, 0.0044, -0.0028, 0.0209, -0.02, 0.0854, 0.0018, -0.0386, -0.0703, 0.0778,
|
||||
-0.0036, -0.0347, 0.0309, -0.0184, 0.029, -0.0025, -0.0644, 0.0347, -0.0523, 0.0644,
|
||||
0.0064, 0.0295, -0.0017, 0.0282, 0.0176, 0.0027, 0.0246, 0.0967, 0.0401, -0.0231,
|
||||
0.0054, -0.0109, 0.0055, -0.0479, -0.049, -0.0136, -0.0245, 0.0839, 0.0026, -0.0493,
|
||||
0.0128, -0.005, -0.0219, -0.0621, 0.0313, 0.0019, 0.0696, 0.0459, 0.0574, 0.0299,
|
||||
-0.0091, -0.029, -0.0068, 0.0276, 0.0645, -0.015, 0.0015, -0.0374, 0.0415, -0.0124,
|
||||
-0.0171, 0.0177, -0.0138, 0.0034, 0.084, 0.0584, 0.0233, 0.01, 0.0122, 0.0047
|
||||
};
|
||||
/* codebook/lspvqanssi4.txt */
|
||||
static const float codes3[] = {
|
||||
0.0221, -0.0035, -0.0032, -0.0177, -0.0327, 0.0518, -0.011, -0.015, -0.0136, -0.0327,
|
||||
0.0099, -0.0059, 0.0031, -0.0174, 0.0464, -0.024, 0.0251, -0.027, 0.0454, -0.0082,
|
||||
-0.0029, 0.0025, -0.0267, -0.0318, -0.0157, 0.0173, 0.0253, 0.0063, -0.0481, 0.0419,
|
||||
-0.0332, -0.0179, -0.0042, 0.0241, 0.0044, -0.0098, -0.0081, 0.0024, -0.0414, 0.0339,
|
||||
-0.006, 0.0182, -0.0051, -0.0479, 0.0016, -0.0179, 0.0316, 0.0222, -0.0029, -0.0351,
|
||||
0.0074, 0.0015, 0.0337, -0.0082, -0.0008, 0.0129, 0.0001, 0.065, 0.0175, 0.0309,
|
||||
-0.0212, -0.0261, 0.0196, -0.0309, 0.0093, -0.0272, 0.026, 0.0169, 0.0132, 0.0116,
|
||||
-0.001, 0.0202, 0.0228, -0.0227, -0.0141, 0.0192, -0.0423, -0.0097, -0.0342, 0.0338,
|
||||
-0.0149, -0.011, -0.0156, 0.029, 0.0028, 0.0123, -0.035, -0.0501, 0.0272, -0.0245,
|
||||
-0.0005, -0.0194, 0.046, -0.0001, -0.028, 0.0216, -0.0028, -0.0162, 0.0177, -0.0254,
|
||||
-0.0109, -0.0026, 0.0038, -0.015, -0.0421, -0.0422, 0.0164, -0.0436, 0.0054, -0.0098,
|
||||
0.0061, -0.0106, 0.0062, 0.0207, -0.0329, 0.0177, -0.0578, 0.0408, 0.0077, -0.026,
|
||||
0.0001, -0.0098, 0.0106, -0.0003, -0.0292, 0.0032, 0.056, 0.0311, -0.0282, -0.0445,
|
||||
0.0033, 0.0345, -0.0022, -0.0029, -0.0228, 0.0242, 0.0197, -0.0286, 0.0194, -0.0328,
|
||||
0.0094, -0.001, 0.0121, 0.0229, 0.0161, 0.0363, -0.0124, 0.0179, -0.0626, 0.002,
|
||||
-0.007, -0.0272, -0.0171, -0.0249, -0.0039, 0.0254, 0.0317, -0.0324, 0.0276, -0.009,
|
||||
-0.0002, 0.0057, -0.0204, 0.0512, -0.017, 0.0113, 0.0157, 0.0427, -0.0024, 0.0162,
|
||||
-0.0064, -0.0144, 0.0216, 0.0053, -0.0361, 0.0287, 0.023, -0.0161, -0.0189, 0.0589,
|
||||
0.0091, -0.0059, -0.0308, 0.0171, -0.0137, -0.0033, -0.0505, -0.0155, -0.0527, 0.0133,
|
||||
-0.0121, -0.0051, 0.0219, 0.0136, 0.0476, -0.009, -0.046, 0.0208, 0.0072, -0.0076,
|
||||
0.0098, -0.0328, -0.0211, 0.0054, -0.0146, -0.0263, 0.0248, 0.0045, -0.0183, 0.0301,
|
||||
0.0101, 0.0139, -0.0073, 0.0234, 0.0083, -0.0194, -0.0365, 0.0307, 0.058, 0.0153,
|
||||
-0.0111, 0.0019, 0.0265, -0.015, 0.0311, 0.0362, 0.0244, -0.0213, -0.0224, -0.0299,
|
||||
0.0061, 0.0082, -0.0181, 0.0081, -0.0344, 0.0133, -0.0095, -0.0411, 0.0462, 0.0371,
|
||||
0.0089, -0.0157, 0.0179, -0.0256, -0.0118, -0.0302, -0.0329, 0.0212, -0.0463, -0.0162,
|
||||
-0.0313, 0.0096, -0.004, 0.0186, 0.0248, -0.0126, 0.0472, -0.0079, 0.0115, -0.027,
|
||||
0.0055, 0.0044, 0.0172, 0.0079, -0.0089, -0.0202, -0.0233, -0.0397, -0.0305, -0.062,
|
||||
-0.0282, -0.0104, -0.0071, -0.0242, -0.0255, 0.0204, -0.0187, -0.0103, -0.0227, -0.0424,
|
||||
-0.0056, 0.0065, 0.0151, -0.0376, 0.0039, 0.0009, -0.0507, -0.004, 0.0393, -0.0201,
|
||||
0.0128, -0.0228, 0.0115, -0.0446, 0.0316, 0.0266, -0.0036, 0.0117, -0.0009, 0.0048,
|
||||
-0.0088, 0.0226, 0.0125, 0.009, 0.0008, -0.0341, 0.0243, -0.0178, -0.0589, 0.0278,
|
||||
0.0151, 0.0021, -0.0349, -0.0365, -0.0098, -0.0179, -0.0212, -0.0313, 0.0109, -0.0164,
|
||||
-0.0211, -0.0112, -0.0446, 0.0014, -0.0034, -0.0179, 0.011, 0.0176, 0.0286, 0.0045,
|
||||
0.0034, -0.0151, 0.038, 0.0331, -0.0034, -0.0439, 0.0145, 0.012, 0.0036, 0.0017,
|
||||
-0.0348, 0.0192, 0.0167, 0.0069, -0.0266, -0.0085, -0.0076, 0.026, 0.0234, 0.0075,
|
||||
-0.0237, 0.015, -0.0094, -0.0201, 0.0234, -0.0041, -0.016, -0.0549, -0.0021, 0.0239,
|
||||
-0.0019, 0.0173, 0.0295, 0.0443, 0.0081, 0.0181, -0.0039, -0.027, 0.0155, 0.0107,
|
||||
0.0065, -0.0055, -0.0368, 0.0232, 0.037, 0.0367, 0.0046, -0.0167, 0.0047, 0.0173,
|
||||
0.0116, 0.0053, -0.0229, 0.0382, 0.016, -0.0453, 0.0057, -0.0267, 0.002, -0.0051,
|
||||
-0.014, 0.0302, -0.0208, 0.0106, 0.0101, -0.0049, -0.0319, 0.0227, -0.0206, -0.0371,
|
||||
-0.0007, -0.0109, -0.0053, 0.0078, 0.041, -0.0001, 0.0543, 0.0328, -0.0196, 0.0332,
|
||||
-0.0043, -0.0028, -0.0246, 0.0285, -0.0248, 0.0153, 0.0303, -0.031, -0.0335, -0.0315,
|
||||
-0.0417, 0.1029, 0.0377, 0.0069, 0.0012, 0.0065, 0.0007, -0.0144, -0.0083, 0.0004,
|
||||
0.0295, 0.0099, -0.0144, -0.0145, 0.0141, -0.0013, 0.0362, -0.0142, -0.0428, -0.0161,
|
||||
-0.0095, -0.0206, 0.0116, 0.0132, 0.0164, 0.0158, 0.0012, -0.0024, 0.064, 0.0364,
|
||||
0.0005, -0.0022, -0.0165, -0.0057, 0.0263, 0.0339, 0.0014, 0.0541, 0.0164, -0.0411,
|
||||
0.0039, -0.0143, -0.0107, 0.0032, -0.016, -0.0502, 0.001, 0.0272, 0.0161, -0.05,
|
||||
0.0083, 0.0292, -0.0076, -0.0201, 0.0313, 0.0213, 0.012, 0.0087, 0.0285, 0.0332,
|
||||
0.017, 0.0018, 0.0001, 0.0205, 0.0106, -0.0064, -0.0082, -0.0083, -0.0082, 0.0886,
|
||||
0.0075, -0.0078, -0.0038, -0.0337, -0.0491, 0.0048, 0.0069, 0.03, 0.0369, 0.0088,
|
||||
-0.0091, -0.0327, 0.0041, 0.0376, 0.017, 0.0154, 0.0126, 0.0153, -0.0024, -0.0353,
|
||||
0.0289, -0.008, 0.0063, 0.0274, -0.0061, 0.0208, 0.039, -0.006, 0.0294, -0.0088,
|
||||
-0.0037, -0.0195, 0.0058, 0.0023, -0.0149, -0.036, -0.0587, -0.0248, 0.0288, 0.0203,
|
||||
-0.0031, 0.0081, -0.0112, -0.0221, 0.0067, -0.0505, -0.0233, 0.0353, -0.0131, 0.0417,
|
||||
0.0243, 0.0231, -0.0013, 0.0049, -0.0423, -0.0245, -0.0029, 0.0184, -0.0162, -0.001,
|
||||
0.0045, 0.0101, -0.0042, 0.0014, -0.0133, -0.0321, 0.0642, 0.0153, 0.0377, 0.0277,
|
||||
0.0275, 0.0083, 0.0286, -0.0243, -0.0084, -0.0236, 0.0027, -0.0289, 0.0201, 0.0235,
|
||||
0.0281, 0.0078, 0.0038, 0.0069, 0.0302, 0.017, -0.0423, -0.034, 0.0104, -0.0181,
|
||||
0.0334, -0.0034, -0.0257, -0.0061, 0.014, -0.0099, -0.0195, 0.0529, 0.0019, 0.001,
|
||||
-0.0114, 0.0012, -0.0038, -0.0016, -0.014, 0.0697, 0.0372, 0.0243, 0.0172, 0.0066,
|
||||
0.0192, 0.0149, 0.0285, 0.0077, 0.0246, -0.0135, 0.0145, 0.0317, -0.0074, -0.0438,
|
||||
-0.0034, -0.0175, -0.0245, -0.0153, 0.0357, -0.0102, -0.0062, -0.0053, -0.0308, -0.0499,
|
||||
0.0025, -0.0253, 0.0148, 0.0031, 0.0189, -0.0023, -0.0085, -0.0596, -0.0337, 0.0175,
|
||||
-0.0091, -0.0171, -0.0217, -0.0189, 0.0056, 0.0249, -0.0499, 0.0236, 0.0042, 0.0449
|
||||
};
|
||||
|
||||
const struct lsp_codebook lsp_cbvqanssi[] = {
|
||||
/* codebook/lspvqanssi1.txt */
|
||||
{
|
||||
10,
|
||||
8,
|
||||
256,
|
||||
codes0
|
||||
},
|
||||
/* codebook/lspvqanssi2.txt */
|
||||
{
|
||||
10,
|
||||
7,
|
||||
128,
|
||||
codes1
|
||||
},
|
||||
/* codebook/lspvqanssi3.txt */
|
||||
{
|
||||
10,
|
||||
6,
|
||||
64,
|
||||
codes2
|
||||
},
|
||||
/* codebook/lspvqanssi4.txt */
|
||||
{
|
||||
10,
|
||||
6,
|
||||
64,
|
||||
codes3
|
||||
},
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
+835
-113
File diff suppressed because it is too large
Load Diff
+42
-13
@@ -2,10 +2,10 @@
|
||||
|
||||
FILE........: codec2.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 21/8/2010
|
||||
DATE CREATED: 21 August 2010
|
||||
|
||||
Codec2 fully quantised encoder and decoder functions. If you want use
|
||||
codec2, these are the functions you need to call.
|
||||
Codec 2 fully quantised encoder and decoder functions. If you want use
|
||||
Codec 2, these are the functions you need to call.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@@ -23,21 +23,50 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __CODEC2__
|
||||
#define __CODEC2__
|
||||
#include "codebook.h"
|
||||
|
||||
#define CODEC2_SAMPLES_PER_FRAME 160
|
||||
#define CODEC2_BITS_PER_FRAME 51
|
||||
/* set up the calling convention for DLL function import/export for
|
||||
WIN32 cross compiling */
|
||||
|
||||
void *codec2_create();
|
||||
void codec2_destroy(void *codec2_state);
|
||||
void codec2_encode(void *codec2_state, unsigned char * bits, short speech_in[]);
|
||||
void codec2_decode(void *codec2_state, short speech_out[],
|
||||
const unsigned char * bits);
|
||||
#ifdef __CODEC2_WIN32__
|
||||
#ifdef __CODEC2_BUILDING_DLL__
|
||||
#define CODEC2_WIN32SUPPORT __declspec(dllexport) __stdcall
|
||||
#else
|
||||
#define CODEC2_WIN32SUPPORT __declspec(dllimport) __stdcall
|
||||
#endif
|
||||
#else
|
||||
#define CODEC2_WIN32SUPPORT
|
||||
#endif
|
||||
|
||||
#define CODEC2_MODE_3200 0
|
||||
#define CODEC2_MODE_2400 1
|
||||
#define CODEC2_MODE_1400 2
|
||||
#define CODEC2_MODE_1200 3
|
||||
|
||||
struct CODEC2;
|
||||
|
||||
struct CODEC2 * CODEC2_WIN32SUPPORT codec2_create(int mode);
|
||||
void CODEC2_WIN32SUPPORT codec2_destroy(struct CODEC2 *codec2_state);
|
||||
void CODEC2_WIN32SUPPORT codec2_encode(struct CODEC2 *codec2_state, unsigned char * bits, short speech_in[]);
|
||||
void CODEC2_WIN32SUPPORT codec2_decode(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits);
|
||||
int CODEC2_WIN32SUPPORT codec2_samples_per_frame(struct CODEC2 *codec2_state);
|
||||
int CODEC2_WIN32SUPPORT codec2_bits_per_frame(struct CODEC2 *codec2_state);
|
||||
|
||||
void CODEC2_WIN32SUPPORT codec2_set_lpc_post_filter(struct CODEC2 *codec2_state, int enable, int bass_boost, float beta, float gamma);
|
||||
int CODEC2_WIN32SUPPORT codec2_get_spare_bit_index(struct CODEC2 *codec2_state);
|
||||
int CODEC2_WIN32SUPPORT codec2_rebuild_spare_bit(struct CODEC2 *codec2_state, int unpacked_bits[]);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: codec2_internal.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: April 16 2012
|
||||
|
||||
Header file for Codec2 internal states, exposed via this header
|
||||
file to assist in testing.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CODEC2_INTERNAL__
|
||||
#define __CODEC2_INTERNAL__
|
||||
|
||||
struct CODEC2 {
|
||||
int mode;
|
||||
kiss_fft_cfg fft_fwd_cfg; /* forward FFT config */
|
||||
float w[M]; /* time domain hamming window */
|
||||
COMP W[FFT_ENC]; /* DFT of w[] */
|
||||
float Pn[2*N]; /* trapezoidal synthesis window */
|
||||
float Sn[M]; /* input speech */
|
||||
float hpf_states[2]; /* high pass filter states */
|
||||
void *nlp; /* pitch predictor states */
|
||||
|
||||
kiss_fft_cfg fft_inv_cfg; /* inverse FFT config */
|
||||
float Sn_[2*N]; /* synthesised output speech */
|
||||
float ex_phase; /* excitation model phase track */
|
||||
float bg_est; /* background noise estimate for post filter */
|
||||
float prev_Wo_enc; /* previous frame's pitch estimate */
|
||||
MODEL prev_model_dec; /* previous frame's model parameters */
|
||||
float prev_lsps_dec[LPC_ORD]; /* previous frame's LSPs */
|
||||
float prev_e_dec; /* previous frame's LPC energy */
|
||||
|
||||
int lpc_pf; /* LPC post filter on */
|
||||
int bass_boost; /* LPC post filter bass boost */
|
||||
float beta; /* LPC post filter parameters */
|
||||
float gamma;
|
||||
|
||||
float xq_enc[2]; /* joint pitch and energy VQ states */
|
||||
float xq_dec[2];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __COMP__
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: defines.h
|
||||
AUTHOR......: David Rowe
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 23/4/93
|
||||
|
||||
Defines and structures used throughout the codec.
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __DEFINES__
|
||||
@@ -48,7 +47,7 @@
|
||||
#define FFT_ENC 512 /* size of FFT used for encoder */
|
||||
#define FFT_DEC 512 /* size of FFT used in decoder */
|
||||
#define TW 40 /* Trapezoidal synthesis window overlap */
|
||||
#define V_THRESH 4.0 /* voicing threshold in dB */
|
||||
#define V_THRESH 6.0 /* voicing threshold in dB */
|
||||
#define LPC_MAX 20 /* maximum LPC order */
|
||||
#define LPC_ORD 10 /* phase modelling LPC order */
|
||||
|
||||
@@ -64,21 +63,32 @@
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Complex number */
|
||||
|
||||
typedef struct {
|
||||
float real;
|
||||
float imag;
|
||||
} COMP;
|
||||
|
||||
/* Structure to hold model parameters for one frame */
|
||||
|
||||
typedef struct {
|
||||
float Wo; /* fundamental frequency estimate in radians */
|
||||
int L; /* number of harmonics */
|
||||
float A[MAX_AMP]; /* amplitiude of each harmonic */
|
||||
float phi[MAX_AMP]; /* phase of each harmonic */
|
||||
float A[MAX_AMP+1]; /* amplitiude of each harmonic */
|
||||
float phi[MAX_AMP+1]; /* phase of each harmonic */
|
||||
int voiced; /* non-zero if this frame is voiced */
|
||||
} MODEL;
|
||||
|
||||
/* describes each codebook */
|
||||
|
||||
struct lsp_codebook {
|
||||
int k; /* dimension of vector */
|
||||
int log2m; /* number of bits in m */
|
||||
int m; /* elements in codebook */
|
||||
const float * cb; /* The elements */
|
||||
};
|
||||
|
||||
extern const struct lsp_codebook lsp_cb[];
|
||||
extern const struct lsp_codebook lsp_cbd[];
|
||||
extern const struct lsp_codebook lsp_cbvq[];
|
||||
extern const struct lsp_codebook lsp_cbjnd[];
|
||||
extern const struct lsp_codebook lsp_cbdt[];
|
||||
extern const struct lsp_codebook lsp_cbjvm[];
|
||||
extern const struct lsp_codebook lsp_cbvqanssi[];
|
||||
extern const struct lsp_codebook ge_cb[];
|
||||
|
||||
#endif
|
||||
|
||||
+189
-4
@@ -1,7 +1,7 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: dump.c
|
||||
AUTHOR......: David Rowe
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 25/8/09
|
||||
|
||||
Routines to dump data to text files for Octave analysis.
|
||||
@@ -20,11 +20,11 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "comp.h"
|
||||
#include "dump.h"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
@@ -32,15 +32,21 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef DUMP
|
||||
static int dumpon = 0;
|
||||
|
||||
static FILE *fsn = NULL;
|
||||
static FILE *fsw = NULL;
|
||||
static FILE *few = NULL;
|
||||
static FILE *fsw_ = NULL;
|
||||
static FILE *fmodel = NULL;
|
||||
static FILE *fqmodel = NULL;
|
||||
static FILE *fpwb = NULL;
|
||||
static FILE *fpw = NULL;
|
||||
static FILE *frw = NULL;
|
||||
static FILE *flsp = NULL;
|
||||
static FILE *fweights = NULL;
|
||||
static FILE *flsp_ = NULL;
|
||||
static FILE *fphase = NULL;
|
||||
static FILE *fphase_ = NULL;
|
||||
static FILE *ffw = NULL;
|
||||
@@ -48,9 +54,13 @@ static FILE *fe = NULL;
|
||||
static FILE *fsq = NULL;
|
||||
static FILE *fdec = NULL;
|
||||
static FILE *fsnr = NULL;
|
||||
static FILE *flpcsnr = NULL;
|
||||
static FILE *fak = NULL;
|
||||
static FILE *fak_ = NULL;
|
||||
static FILE *fbg = NULL;
|
||||
static FILE *fE = NULL;
|
||||
static FILE *frk = NULL;
|
||||
static FILE *fhephase = NULL;
|
||||
|
||||
static char prefix[MAX_STR];
|
||||
|
||||
@@ -66,14 +76,24 @@ void dump_off(){
|
||||
fclose(fsw);
|
||||
if (fsw_ != NULL)
|
||||
fclose(fsw_);
|
||||
if (few != NULL)
|
||||
fclose(few);
|
||||
if (fmodel != NULL)
|
||||
fclose(fmodel);
|
||||
if (fqmodel != NULL)
|
||||
fclose(fqmodel);
|
||||
if (fpwb != NULL)
|
||||
fclose(fpwb);
|
||||
if (fpw != NULL)
|
||||
fclose(fpw);
|
||||
if (frw != NULL)
|
||||
fclose(frw);
|
||||
if (flsp != NULL)
|
||||
fclose(flsp);
|
||||
if (fweights != NULL)
|
||||
fclose(fweights);
|
||||
if (flsp_ != NULL)
|
||||
fclose(flsp_);
|
||||
if (fphase != NULL)
|
||||
fclose(fphase);
|
||||
if (fphase_ != NULL)
|
||||
@@ -88,12 +108,20 @@ void dump_off(){
|
||||
fclose(fdec);
|
||||
if (fsnr != NULL)
|
||||
fclose(fsnr);
|
||||
if (flpcsnr != NULL)
|
||||
fclose(flpcsnr);
|
||||
if (fak != NULL)
|
||||
fclose(fak);
|
||||
if (fak_ != NULL)
|
||||
fclose(fak_);
|
||||
if (fbg != NULL)
|
||||
fclose(fbg);
|
||||
if (fE != NULL)
|
||||
fclose(fE);
|
||||
if (frk != NULL)
|
||||
fclose(frk);
|
||||
if (fhephase != NULL)
|
||||
fclose(fhephase);
|
||||
}
|
||||
|
||||
void dump_Sn(float Sn[]) {
|
||||
@@ -155,6 +183,24 @@ void dump_Sw_(COMP Sw_[]) {
|
||||
fprintf(fsw_,"\n");
|
||||
}
|
||||
|
||||
void dump_Ew(COMP Ew[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (few == NULL) {
|
||||
sprintf(s,"%s_ew.txt", prefix);
|
||||
few = fopen(s, "wt");
|
||||
assert(few != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(few,"%f\t",
|
||||
10.0*log10(Ew[i].real*Ew[i].real + Ew[i].imag*Ew[i].imag));
|
||||
fprintf(few,"\n");
|
||||
}
|
||||
|
||||
void dump_model(MODEL *model) {
|
||||
int l;
|
||||
char s[MAX_STR];
|
||||
@@ -234,6 +280,25 @@ void dump_phase_(float phase_[], int L) {
|
||||
fprintf(fphase_,"\n");
|
||||
}
|
||||
|
||||
|
||||
void dump_hephase(int ind[], int dim) {
|
||||
int m;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fhephase == NULL) {
|
||||
sprintf(s,"%s_hephase.txt", prefix);
|
||||
fhephase = fopen(s, "wt");
|
||||
assert(fhephase != NULL);
|
||||
}
|
||||
|
||||
for(m=0; m<dim; m++)
|
||||
fprintf(fhephase,"%d\t",ind[m]);
|
||||
fprintf(fhephase,"\n");
|
||||
}
|
||||
|
||||
|
||||
void dump_snr(float snr) {
|
||||
char s[MAX_STR];
|
||||
|
||||
@@ -248,6 +313,39 @@ void dump_snr(float snr) {
|
||||
fprintf(fsnr,"%f\n",snr);
|
||||
}
|
||||
|
||||
void dump_lpc_snr(float snr) {
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (flpcsnr == NULL) {
|
||||
sprintf(s,"%s_lpc_snr.txt", prefix);
|
||||
flpcsnr = fopen(s, "wt");
|
||||
assert(flpcsnr != NULL);
|
||||
}
|
||||
|
||||
fprintf(flpcsnr,"%f\n",snr);
|
||||
}
|
||||
|
||||
/* Pw "before" post filter so we can plot before and after */
|
||||
|
||||
void dump_Pwb(COMP Pwb[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fpwb == NULL) {
|
||||
sprintf(s,"%s_pwb.txt", prefix);
|
||||
fpwb = fopen(s, "wt");
|
||||
assert(fpwb != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(fpwb,"%f\t",Pwb[i].real);
|
||||
fprintf(fpwb,"\n");
|
||||
}
|
||||
|
||||
void dump_Pw(COMP Pw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
@@ -260,11 +358,45 @@ void dump_Pw(COMP Pw[]) {
|
||||
assert(fpw != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_DEC/2; i++)
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(fpw,"%f\t",Pw[i].real);
|
||||
fprintf(fpw,"\n");
|
||||
}
|
||||
|
||||
void dump_Rw(float Rw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (frw == NULL) {
|
||||
sprintf(s,"%s_rw.txt", prefix);
|
||||
frw = fopen(s, "wt");
|
||||
assert(frw != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(frw,"%f\t",Rw[i]);
|
||||
fprintf(frw,"\n");
|
||||
}
|
||||
|
||||
void dump_weights(float w[], int order) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fweights == NULL) {
|
||||
sprintf(s,"%s_weights.txt", prefix);
|
||||
fweights = fopen(s, "wt");
|
||||
assert(fweights != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<order; i++)
|
||||
fprintf(fweights,"%f\t", w[i]);
|
||||
fprintf(fweights,"\n");
|
||||
}
|
||||
|
||||
void dump_lsp(float lsp[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
@@ -282,6 +414,23 @@ void dump_lsp(float lsp[]) {
|
||||
fprintf(flsp,"\n");
|
||||
}
|
||||
|
||||
void dump_lsp_(float lsp_[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (flsp_ == NULL) {
|
||||
sprintf(s,"%s_lsp_.txt", prefix);
|
||||
flsp_ = fopen(s, "wt");
|
||||
assert(flsp_ != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<10; i++)
|
||||
fprintf(flsp_,"%f\t",lsp_[i]);
|
||||
fprintf(flsp_,"\n");
|
||||
}
|
||||
|
||||
void dump_ak(float ak[], int order) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
@@ -299,6 +448,23 @@ void dump_ak(float ak[], int order) {
|
||||
fprintf(fak,"\n");
|
||||
}
|
||||
|
||||
void dump_ak_(float ak_[], int order) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fak_ == NULL) {
|
||||
sprintf(s,"%s_ak_.txt", prefix);
|
||||
fak_ = fopen(s, "wt");
|
||||
assert(fak_ != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<=order; i++)
|
||||
fprintf(fak_,"%f\t",ak_[i]);
|
||||
fprintf(fak_,"\n");
|
||||
}
|
||||
|
||||
void dump_Fw(COMP Fw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
@@ -400,3 +566,22 @@ void dump_E(float E) {
|
||||
|
||||
fprintf(fE,"%f\n", 10.0*log10(E));
|
||||
}
|
||||
|
||||
void dump_Rk(float Rk[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (frk == NULL) {
|
||||
sprintf(s,"%s_rk.txt", prefix);
|
||||
frk = fopen(s, "wt");
|
||||
assert(frk != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<P_MAX; i++)
|
||||
fprintf(frk,"%f\t",Rk[i]);
|
||||
fprintf(frk,"\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,34 +20,43 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __DUMP__
|
||||
#define __DUMP__
|
||||
|
||||
#include "comp.h"
|
||||
|
||||
void dump_on(char filename_prefix[]);
|
||||
void dump_off();
|
||||
|
||||
void dump_Sn(float Sn[]);
|
||||
void dump_Sw(COMP Sw[]);
|
||||
void dump_Sw_(COMP Sw_[]);
|
||||
void dump_Ew(COMP Ew[]);
|
||||
|
||||
/* amplitude modelling */
|
||||
|
||||
void dump_model(MODEL *m);
|
||||
void dump_quantised_model(MODEL *m);
|
||||
void dump_Pwn(COMP Pw[]);
|
||||
void dump_Pw(COMP Pw[]);
|
||||
void dump_Rw(float Rw[]);
|
||||
void dump_lsp(float lsp[]);
|
||||
void dump_weights(float w[], int ndim);
|
||||
void dump_lsp_(float lsp_[]);
|
||||
void dump_ak(float ak[], int order);
|
||||
void dump_ak_(float ak[], int order);
|
||||
void dump_E(float E);
|
||||
void dump_lpc_snr(float snr);
|
||||
|
||||
/* phase modelling */
|
||||
|
||||
void dump_snr(float snr);
|
||||
void dump_phase(float phase[], int L);
|
||||
void dump_phase_(float phase[], int L);
|
||||
void dump_hephase(int ind[], int dim);
|
||||
|
||||
/* NLP states */
|
||||
|
||||
@@ -55,6 +64,7 @@ void dump_sq(float sq[]);
|
||||
void dump_dec(COMP Fw[]);
|
||||
void dump_Fw(COMP Fw[]);
|
||||
void dump_e(float e_hz[]);
|
||||
void dump_Rk(float Rk[]);
|
||||
|
||||
/* post filter */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,114 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fdmdv.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: April 14 2012
|
||||
|
||||
A 1400 bit/s Frequency Division Multiplexed Digital Voice (FDMDV)
|
||||
modem. Used for digital audio over HF SSB. See README_fdmdv.txt for
|
||||
more information, and fdmdv_mod.c and fdmdv_demod.c for example
|
||||
usage.
|
||||
|
||||
References:
|
||||
|
||||
[1] http://n1su.com/fdmdv/FDMDV_Docs_Rel_1_4b.pdf
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __FDMDV__
|
||||
#define __FDMDV__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* set up the calling convention for DLL function import/export for
|
||||
WIN32 cross compiling */
|
||||
|
||||
#ifdef __CODEC2_WIN32__
|
||||
#ifdef __CODEC2_BUILDING_DLL__
|
||||
#define CODEC2_WIN32SUPPORT __declspec(dllexport) __stdcall
|
||||
#else
|
||||
#define CODEC2_WIN32SUPPORT __declspec(dllimport) __stdcall
|
||||
#endif
|
||||
#else
|
||||
#define CODEC2_WIN32SUPPORT
|
||||
#endif
|
||||
|
||||
#include "comp.h"
|
||||
|
||||
#define FDMDV_BITS_PER_FRAME 28 /* 20ms frames, 1400 bit/s */
|
||||
#define FDMDV_NOM_SAMPLES_PER_FRAME 160 /* modulator output samples/frame and nominal demod samples/frame */
|
||||
/* at 8000 Hz sample rate */
|
||||
#define FDMDV_MAX_SAMPLES_PER_FRAME 200 /* max demod samples/frame, use this to allocate storage */
|
||||
#define FDMDV_SCALE 1000 /* suggested scaling for 16 bit shorts */
|
||||
#define FDMDV_NSYM 15
|
||||
#define FDMDV_FCENTRE 1500 /* Centre frequency, Nc/2 carriers below this, Nc/2 carriers above (Hz) */
|
||||
|
||||
/* 8 to 48 kHz sample rate conversion */
|
||||
|
||||
#define FDMDV_OS 6 /* oversampling rate */
|
||||
#define FDMDV_OS_TAPS 48 /* number of OS filter taps */
|
||||
|
||||
/* FFT points */
|
||||
|
||||
#define FDMDV_NSPEC 512
|
||||
#define FDMDV_MAX_F_HZ 4000
|
||||
|
||||
/* FDMDV states and stats structures */
|
||||
|
||||
struct FDMDV;
|
||||
|
||||
struct FDMDV_STATS {
|
||||
float snr_est; /* estimated SNR of rx signal in dB (3 kHz noise BW) */
|
||||
COMP rx_symbols[FDMDV_NSYM]; /* latest received symbols, for scatter plot */
|
||||
int fest_coarse_fine; /* freq est state, 0-coarse 1-fine */
|
||||
float foff; /* estimated freq offset in Hz */
|
||||
float rx_timing; /* estimated optimum timing offset in samples */
|
||||
float clock_offset; /* Estimated tx/rx sample clock offset in ppm */
|
||||
};
|
||||
|
||||
struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(void);
|
||||
void CODEC2_WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv_state);
|
||||
|
||||
void CODEC2_WIN32SUPPORT fdmdv_mod(struct FDMDV *fdmdv_state, COMP tx_fdm[], int tx_bits[], int *sync_bit);
|
||||
void CODEC2_WIN32SUPPORT fdmdv_demod(struct FDMDV *fdmdv_state, int rx_bits[], int *sync_bit, COMP rx_fdm[], int *nin);
|
||||
|
||||
void CODEC2_WIN32SUPPORT fdmdv_get_test_bits(struct FDMDV *fdmdv_state, int tx_bits[]);
|
||||
void CODEC2_WIN32SUPPORT fdmdv_put_test_bits(struct FDMDV *f, int *sync, int *bit_errors, int *ntest_bits, int rx_bits[]);
|
||||
|
||||
void CODEC2_WIN32SUPPORT fdmdv_get_demod_stats(struct FDMDV *fdmdv_state, struct FDMDV_STATS *fdmdv_stats);
|
||||
void CODEC2_WIN32SUPPORT fdmdv_get_rx_spectrum(struct FDMDV *fdmdv_state, float mag_dB[], COMP rx_fdm[], int nin);
|
||||
|
||||
void CODEC2_WIN32SUPPORT fdmdv_8_to_48(float out48k[], float in8k[], int n);
|
||||
void CODEC2_WIN32SUPPORT fdmdv_48_to_8(float out8k[], float in48k[], int n);
|
||||
|
||||
void CODEC2_WIN32SUPPORT fdmdv_freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, COMP *foff_rect, COMP *foff_phase_rect, int nin);
|
||||
|
||||
/* debug/development function(s) */
|
||||
|
||||
void CODEC2_WIN32SUPPORT fdmdv_dump_osc_mags(struct FDMDV *f);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fdmdv_demod.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: April 30 2012
|
||||
|
||||
Given an input raw file (8kHz, 16 bit shorts) of FDMDV modem samples
|
||||
outputs a file of bits. The output file is assumed to be arranged
|
||||
as codec frames of 56 bits (7 bytes) which are received as two 28
|
||||
bit modem frames.
|
||||
|
||||
Demod states can be optionally logged to an Octave file for display
|
||||
using the Octave script fdmdv_demod_c.m. This is useful for
|
||||
checking demod performance.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "fdmdv.h"
|
||||
#include "octave.h"
|
||||
|
||||
#define BITS_PER_CODEC_FRAME (2*FDMDV_BITS_PER_FRAME)
|
||||
#define BYTES_PER_CODEC_FRAME (BITS_PER_CODEC_FRAME/8)
|
||||
|
||||
/* lof of information we want to dump to Octave */
|
||||
|
||||
#define MAX_FRAMES 50*60 /* 1 minute at 50 symbols/s */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fin, *fout;
|
||||
struct FDMDV *fdmdv;
|
||||
char packed_bits[BYTES_PER_CODEC_FRAME];
|
||||
int rx_bits[FDMDV_BITS_PER_FRAME];
|
||||
int codec_bits[2*FDMDV_BITS_PER_FRAME];
|
||||
COMP rx_fdm[FDMDV_MAX_SAMPLES_PER_FRAME];
|
||||
short rx_fdm_scaled[FDMDV_MAX_SAMPLES_PER_FRAME];
|
||||
int i, bit, byte, c;
|
||||
int nin, nin_prev;
|
||||
int sync_bit;
|
||||
int state, next_state;
|
||||
int f;
|
||||
FILE *foct = NULL;
|
||||
struct FDMDV_STATS stats;
|
||||
float *rx_fdm_log;
|
||||
int rx_fdm_log_col_index;
|
||||
COMP rx_symbols_log[FDMDV_NSYM][MAX_FRAMES];
|
||||
int coarse_fine_log[MAX_FRAMES];
|
||||
float rx_timing_log[MAX_FRAMES];
|
||||
float foff_log[MAX_FRAMES];
|
||||
int sync_bit_log[MAX_FRAMES];
|
||||
int rx_bits_log[FDMDV_BITS_PER_FRAME*MAX_FRAMES];
|
||||
float snr_est_log[MAX_FRAMES];
|
||||
float *rx_spec_log;
|
||||
int max_frames_reached;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("usage: %s InputModemRawFile OutputBitFile [OctaveDumpFile]\n", argv[0]);
|
||||
printf("e.g %s hts1a_fdmdv.raw hts1a.c2\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "-") == 0) fin = stdin;
|
||||
else if ( (fin = fopen(argv[1],"rb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening input modem sample file: %s: %s.\n",
|
||||
argv[1], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[2], "-") == 0) fout = stdout;
|
||||
else if ( (fout = fopen(argv[2],"wb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening output bit file: %s: %s.\n",
|
||||
argv[2], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* malloc some of the bigger variables to prevent out of stack problems */
|
||||
|
||||
rx_fdm_log = (float*)malloc(sizeof(float)*FDMDV_MAX_SAMPLES_PER_FRAME*MAX_FRAMES);
|
||||
assert(rx_fdm_log != NULL);
|
||||
rx_spec_log = (float*)malloc(sizeof(float)*FDMDV_NSPEC*MAX_FRAMES);
|
||||
assert(rx_spec_log != NULL);
|
||||
|
||||
fdmdv = fdmdv_create();
|
||||
f = 0;
|
||||
state = 0;
|
||||
nin = FDMDV_NOM_SAMPLES_PER_FRAME;
|
||||
rx_fdm_log_col_index = 0;
|
||||
max_frames_reached = 0;
|
||||
|
||||
while(fread(rx_fdm_scaled, sizeof(short), nin, fin) == nin)
|
||||
{
|
||||
for(i=0; i<nin; i++) {
|
||||
rx_fdm[i].real = (float)rx_fdm_scaled[i]/FDMDV_SCALE;
|
||||
rx_fdm[i].imag = 0;
|
||||
}
|
||||
nin_prev = nin;
|
||||
fdmdv_demod(fdmdv, rx_bits, &sync_bit, rx_fdm, &nin);
|
||||
|
||||
/* log data for optional Octave dump */
|
||||
|
||||
if (f < MAX_FRAMES) {
|
||||
fdmdv_get_demod_stats(fdmdv, &stats);
|
||||
|
||||
/* log modem states for later dumping to Octave log file */
|
||||
|
||||
memcpy(&rx_fdm_log[rx_fdm_log_col_index], rx_fdm, sizeof(float)*nin_prev);
|
||||
rx_fdm_log_col_index += nin_prev;
|
||||
|
||||
for(c=0; c<FDMDV_NSYM; c++)
|
||||
rx_symbols_log[c][f] = stats.rx_symbols[c];
|
||||
foff_log[f] = stats.foff;
|
||||
rx_timing_log[f] = stats.rx_timing;
|
||||
coarse_fine_log[f] = stats.fest_coarse_fine;
|
||||
sync_bit_log[f] = sync_bit;
|
||||
memcpy(&rx_bits_log[FDMDV_BITS_PER_FRAME*f], rx_bits, sizeof(int)*FDMDV_BITS_PER_FRAME);
|
||||
snr_est_log[f] = stats.snr_est;
|
||||
|
||||
fdmdv_get_rx_spectrum(fdmdv, &rx_spec_log[f*FDMDV_NSPEC], rx_fdm, nin_prev);
|
||||
|
||||
f++;
|
||||
}
|
||||
|
||||
if ((f == MAX_FRAMES) && !max_frames_reached) {
|
||||
fprintf(stderr,"MAX_FRAMES exceed in Octave log, log truncated\n");
|
||||
max_frames_reached = 1;
|
||||
}
|
||||
|
||||
/* state machine to output codec bits only if we have a 0,1
|
||||
sync bit sequence */
|
||||
|
||||
next_state = state;
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (sync_bit == 0) {
|
||||
next_state = 1;
|
||||
memcpy(codec_bits, rx_bits, FDMDV_BITS_PER_FRAME*sizeof(int));
|
||||
}
|
||||
else
|
||||
next_state = 0;
|
||||
break;
|
||||
case 1:
|
||||
if (sync_bit == 1) {
|
||||
memcpy(&codec_bits[FDMDV_BITS_PER_FRAME], rx_bits, FDMDV_BITS_PER_FRAME*sizeof(int));
|
||||
|
||||
/* pack bits, MSB received first */
|
||||
|
||||
bit = 7; byte = 0;
|
||||
memset(packed_bits, 0, BYTES_PER_CODEC_FRAME);
|
||||
for(i=0; i<BITS_PER_CODEC_FRAME; i++) {
|
||||
packed_bits[byte] |= (codec_bits[i] << bit);
|
||||
bit--;
|
||||
if (bit < 0) {
|
||||
bit = 7;
|
||||
byte++;
|
||||
}
|
||||
}
|
||||
assert(byte == BYTES_PER_CODEC_FRAME);
|
||||
|
||||
fwrite(packed_bits, sizeof(char), BYTES_PER_CODEC_FRAME, fout);
|
||||
}
|
||||
next_state = 0;
|
||||
break;
|
||||
}
|
||||
state = next_state;
|
||||
|
||||
/* if this is in a pipeline, we probably don't want the usual
|
||||
buffering to occur */
|
||||
|
||||
if (fout == stdout) fflush(stdout);
|
||||
if (fin == stdin) fflush(stdin);
|
||||
}
|
||||
|
||||
/* Optional dump to Octave log file */
|
||||
|
||||
if (argc == 4) {
|
||||
|
||||
/* make sure 3rd arg is not just the pipe command */
|
||||
|
||||
if (strcmp(argv[3],"|")) {
|
||||
if ((foct = fopen(argv[3],"wt")) == NULL ) {
|
||||
fprintf(stderr, "Error opening Octave dump file: %s: %s.\n",
|
||||
argv[3], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
octave_save_float(foct, "rx_fdm_log_c", rx_fdm_log, 1, rx_fdm_log_col_index, FDMDV_MAX_SAMPLES_PER_FRAME);
|
||||
octave_save_complex(foct, "rx_symbols_log_c", (COMP*)rx_symbols_log, FDMDV_NSYM, f, MAX_FRAMES);
|
||||
octave_save_float(foct, "foff_log_c", foff_log, 1, f, MAX_FRAMES);
|
||||
octave_save_float(foct, "rx_timing_log_c", rx_timing_log, 1, f, MAX_FRAMES);
|
||||
octave_save_int(foct, "coarse_fine_log_c", coarse_fine_log, 1, f);
|
||||
octave_save_int(foct, "rx_bits_log_c", rx_bits_log, 1, FDMDV_BITS_PER_FRAME*f);
|
||||
octave_save_int(foct, "sync_bit_log_c", sync_bit_log, 1, f);
|
||||
octave_save_float(foct, "snr_est_log_c", snr_est_log, 1, f, MAX_FRAMES);
|
||||
octave_save_float(foct, "rx_spec_log_c", rx_spec_log, f, FDMDV_NSPEC, FDMDV_NSPEC);
|
||||
fclose(foct);
|
||||
}
|
||||
}
|
||||
|
||||
//fdmdv_dump_osc_mags(fdmdv);
|
||||
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
free(rx_fdm_log);
|
||||
free(rx_spec_log);
|
||||
fdmdv_destroy(fdmdv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fdmdv_get_test_bits.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 1 May 2012
|
||||
|
||||
Generates a file of packed test bits, useful for input to fdmdv_mod.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "fdmdv.h"
|
||||
|
||||
#define BITS_PER_CODEC_FRAME (2*FDMDV_BITS_PER_FRAME)
|
||||
#define BYTES_PER_CODEC_FRAME (BITS_PER_CODEC_FRAME/8)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fout;
|
||||
struct FDMDV *fdmdv;
|
||||
char packed_bits[BYTES_PER_CODEC_FRAME];
|
||||
int tx_bits[2*FDMDV_BITS_PER_FRAME];
|
||||
int n, i, bit, byte;
|
||||
int numBits, nCodecFrames;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("usage: %s OutputBitFile numBits\n", argv[0]);
|
||||
printf("e.g %s test.c2 1400\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "-") == 0) fout = stdout;
|
||||
else if ( (fout = fopen(argv[1],"wb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening output bit file: %s: %s.\n",
|
||||
argv[1], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
numBits = atoi(argv[2]);
|
||||
nCodecFrames = numBits/BITS_PER_CODEC_FRAME;
|
||||
|
||||
fdmdv = fdmdv_create();
|
||||
|
||||
for(n=0; n<nCodecFrames; n++) {
|
||||
|
||||
fdmdv_get_test_bits(fdmdv, tx_bits);
|
||||
fdmdv_get_test_bits(fdmdv, &tx_bits[FDMDV_BITS_PER_FRAME]);
|
||||
|
||||
/* pack bits, MSB received first */
|
||||
|
||||
bit = 7; byte = 0;
|
||||
memset(packed_bits, 0, BYTES_PER_CODEC_FRAME);
|
||||
for(i=0; i<BITS_PER_CODEC_FRAME; i++) {
|
||||
packed_bits[byte] |= (tx_bits[i] << bit);
|
||||
bit--;
|
||||
if (bit < 0) {
|
||||
bit = 7;
|
||||
byte++;
|
||||
}
|
||||
}
|
||||
assert(byte == BYTES_PER_CODEC_FRAME);
|
||||
|
||||
fwrite(packed_bits, sizeof(char), BYTES_PER_CODEC_FRAME, fout);
|
||||
|
||||
/* if this is in a pipeline, we probably don't want the usual
|
||||
buffering to occur */
|
||||
|
||||
if (fout == stdout) fflush(stdout);
|
||||
}
|
||||
|
||||
fclose(fout);
|
||||
fdmdv_destroy(fdmdv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fdmdv_interleave.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: May 27 2012
|
||||
|
||||
Given an input file of bits outputs an interleaved or optionally
|
||||
de-intervleaved file of bits.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "fdmdv.h"
|
||||
|
||||
#define MAX_INTERLEAVER 1024
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fin, *fout, *finter;
|
||||
int interleaver[MAX_INTERLEAVER];
|
||||
char *packed_bits;
|
||||
int *bits;
|
||||
int *interleaved_bits;
|
||||
int i, bit, byte, m, mpacked, frames, interleave, src_bit, dest_bit;
|
||||
|
||||
if (argc < 4) {
|
||||
printf("usage: %s InputBitFile OutputBitFile InterleaverFile [de]\n", argv[0]);
|
||||
printf("e.g %s hts1a.c2 hts1a_interleaved.c2 interleaver.txt\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "-") == 0) fin = stdin;
|
||||
else if ( (fin = fopen(argv[1],"rb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening input bit file: %s: %s.\n",
|
||||
argv[1], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[2], "-") == 0) fout = stdout;
|
||||
else if ( (fout = fopen(argv[2],"wb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening output bit file: %s: %s.\n",
|
||||
argv[2], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((finter = fopen(argv[3],"rt")) == NULL ) {
|
||||
fprintf(stderr, "Error opening interleaver file: %s: %s.\n",
|
||||
argv[3], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (argc == 5)
|
||||
interleave = 1;
|
||||
else
|
||||
interleave = 0;
|
||||
|
||||
/* load interleaver, size determines block size we will process */
|
||||
|
||||
src_bit = 0;
|
||||
while(fscanf(finter, "%d\n", &dest_bit) == 1) {
|
||||
if (interleave)
|
||||
interleaver[dest_bit] = src_bit;
|
||||
else
|
||||
interleaver[src_bit] = dest_bit;
|
||||
|
||||
src_bit++;
|
||||
if (src_bit == MAX_INTERLEAVER) {
|
||||
fprintf(stderr, "Error interleaver too big\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
fclose(finter);
|
||||
|
||||
m = src_bit;
|
||||
fprintf(stderr, "Interleaver size m = %d interleave = %d\n", m, interleave);
|
||||
mpacked = m/8;
|
||||
|
||||
packed_bits = (char*)malloc(mpacked*sizeof(char));
|
||||
assert(packed_bits != NULL);
|
||||
bits = (int*)malloc(m*sizeof(int));
|
||||
assert(bits != NULL);
|
||||
interleaved_bits = (int*)malloc(m*sizeof(int));
|
||||
assert(interleaved_bits != NULL);
|
||||
|
||||
frames = 0;
|
||||
|
||||
while(fread(packed_bits, sizeof(char), mpacked, fin) == mpacked) {
|
||||
frames++;
|
||||
|
||||
/* unpack bits, MSB first */
|
||||
|
||||
bit = 7; byte = 0;
|
||||
for(i=0; i<m; i++) {
|
||||
bits[i] = (packed_bits[byte] >> bit) & 0x1;
|
||||
bit--;
|
||||
if (bit < 0) {
|
||||
bit = 7;
|
||||
byte++;
|
||||
}
|
||||
}
|
||||
assert(byte == mpacked);
|
||||
|
||||
/* (de) interleave */
|
||||
|
||||
for(i=0; i<m; i++)
|
||||
interleaved_bits[i] = bits[interleaver[i]];
|
||||
|
||||
/* pack bits, MSB sent first */
|
||||
|
||||
bit = 7; byte = 0;
|
||||
memset(packed_bits, 0, mpacked);
|
||||
for(i=0; i<m; i++) {
|
||||
packed_bits[byte] |= (interleaved_bits[i] << bit);
|
||||
bit--;
|
||||
if (bit < 0) {
|
||||
bit = 7;
|
||||
byte++;
|
||||
}
|
||||
}
|
||||
assert(byte == mpacked);
|
||||
|
||||
fwrite(packed_bits, sizeof(char), mpacked, fout);
|
||||
|
||||
/* if this is in a pipeline, we probably don't want the usual
|
||||
buffering to occur */
|
||||
|
||||
if (fout == stdout) fflush(stdout);
|
||||
if (fin == stdin) fflush(stdin);
|
||||
}
|
||||
|
||||
free(packed_bits);
|
||||
free(bits);
|
||||
free(interleaved_bits);
|
||||
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fdmdv_internal.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: April 16 2012
|
||||
|
||||
Header file for FDMDV internal functions, exposed via this header
|
||||
file for testing.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __FDMDV_INTERNAL__
|
||||
#define __FDMDV_INTERNAL__
|
||||
|
||||
#include "comp.h"
|
||||
#include "fdmdv.h"
|
||||
#include "kiss_fft.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
DEFINES
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#define PI 3.141592654
|
||||
#define FS 8000 /* sample rate in Hz */
|
||||
#define T (1.0/FS) /* sample period in seconds */
|
||||
#define RS 50 /* symbol rate in Hz */
|
||||
#define NC 14 /* number of data carriers (plus one pilot in the centre) */
|
||||
#define NB 2 /* Bits/symbol for QPSK modulation */
|
||||
#define RB (NC*RS*NB) /* bit rate */
|
||||
#define M (FS/RS) /* oversampling factor */
|
||||
#define NSYM 6 /* number of symbols to filter over */
|
||||
#define NFILTER (NSYM*M) /* size of tx/rx filters at sample rate M */
|
||||
|
||||
#define FSEP 75 /* Separation between carriers (Hz) */
|
||||
|
||||
#define NT 5 /* number of symbols we estimate timing over */
|
||||
#define P 4 /* oversample factor used for initial rx symbol filtering */
|
||||
#define NFILTERTIMING (M+NFILTER+M) /* filter memory used for resampling after timing estimation */
|
||||
|
||||
#define NTEST_BITS (NC*NB*4) /* length of test bit sequence */
|
||||
|
||||
#define NPILOT_LUT (4*M) /* number of pilot look up table samples */
|
||||
#define NPILOTCOEFF 30 /* number of FIR filter coeffs in LP filter */
|
||||
#define NPILOTBASEBAND (NPILOTCOEFF+M+M/P) /* number of pilot baseband samples reqd for pilot LPF */
|
||||
#define NPILOTLPF (4*M) /* number of samples we DFT pilot over, pilot est window */
|
||||
#define MPILOTFFT 256
|
||||
|
||||
/* freq offset sestimation states */
|
||||
|
||||
#define COARSE 0
|
||||
#define FINE 1
|
||||
|
||||
/* averaging filter coeffs */
|
||||
|
||||
#define TRACK_COEFF 0.5
|
||||
#define SNR_COEFF 0.9 /* SNR est averaging filter coeff */
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
STRUCT for States
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
struct FDMDV {
|
||||
/* test data (test frame) states */
|
||||
|
||||
int current_test_bit;
|
||||
int rx_test_bits_mem[NTEST_BITS];
|
||||
|
||||
/* Modulator */
|
||||
|
||||
int tx_pilot_bit;
|
||||
COMP prev_tx_symbols[NC+1];
|
||||
COMP tx_filter_memory[NC+1][NSYM];
|
||||
COMP phase_tx[NC+1];
|
||||
COMP freq[NC+1];
|
||||
|
||||
/* Pilot generation at demodulator */
|
||||
|
||||
COMP pilot_lut[NPILOT_LUT];
|
||||
int pilot_lut_index;
|
||||
int prev_pilot_lut_index;
|
||||
|
||||
/* freq offset estimation states */
|
||||
|
||||
kiss_fft_cfg fft_pilot_cfg;
|
||||
COMP pilot_baseband1[NPILOTBASEBAND];
|
||||
COMP pilot_baseband2[NPILOTBASEBAND];
|
||||
COMP pilot_lpf1[NPILOTLPF];
|
||||
COMP pilot_lpf2[NPILOTLPF];
|
||||
COMP S1[MPILOTFFT];
|
||||
COMP S2[MPILOTFFT];
|
||||
|
||||
/* freq offset correction states */
|
||||
|
||||
float foff;
|
||||
COMP foff_rect;
|
||||
COMP foff_phase_rect;
|
||||
|
||||
/* Demodulator */
|
||||
|
||||
COMP phase_rx[NC+1];
|
||||
COMP rx_filter_memory[NC+1][NFILTER];
|
||||
COMP rx_filter_mem_timing[NC+1][NT*P];
|
||||
COMP rx_baseband_mem_timing[NC+1][NFILTERTIMING];
|
||||
float rx_timing;
|
||||
COMP phase_difference[NC+1];
|
||||
COMP prev_rx_symbols[NC+1];
|
||||
|
||||
/* freq est state machine */
|
||||
|
||||
int fest_state;
|
||||
int coarse_fine;
|
||||
|
||||
/* SNR estimation states */
|
||||
|
||||
float sig_est[NC+1];
|
||||
float noise_est[NC+1];
|
||||
|
||||
/* Buf for FFT/waterfall */
|
||||
|
||||
float fft_buf[2*FDMDV_NSPEC];
|
||||
kiss_fft_cfg fft_cfg;
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION PROTOTYPES
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void bits_to_dqpsk_symbols(COMP tx_symbols[], COMP prev_tx_symbols[], int tx_bits[], int *pilot_bit);
|
||||
void tx_filter(COMP tx_baseband[NC+1][M], COMP tx_symbols[], COMP tx_filter_memory[NC+1][NSYM]);
|
||||
void fdm_upconvert(COMP tx_fdm[], COMP tx_baseband[NC+1][M], COMP phase_tx[], COMP freq_tx[]);
|
||||
void generate_pilot_fdm(COMP *pilot_fdm, int *bit, float *symbol, float *filter_mem, COMP *phase, COMP *freq);
|
||||
void generate_pilot_lut(COMP pilot_lut[], COMP *pilot_freq);
|
||||
float rx_est_freq_offset(struct FDMDV *f, COMP rx_fdm[], int nin);
|
||||
void lpf_peak_pick(float *foff, float *max, COMP pilot_baseband[], COMP pilot_lpf[], kiss_fft_cfg fft_pilot_cfg, COMP S[], int nin);
|
||||
void freq_shift(COMP rx_fdm_fcorr[], COMP rx_fdm[], float foff, COMP *foff_rect, COMP *foff_phase_rect, int nin);
|
||||
void fdm_downconvert(COMP rx_baseband[NC+1][M+M/P], COMP rx_fdm[], COMP phase_rx[], COMP freq[], int nin);
|
||||
void rx_filter(COMP rx_filt[NC+1][P+1], COMP rx_baseband[NC+1][M+M/P], COMP rx_filter_memory[NC+1][NFILTER], int nin);
|
||||
float rx_est_timing(COMP rx_symbols[],
|
||||
COMP rx_filt[NC+1][P+1],
|
||||
COMP rx_baseband[NC+1][M+M/P],
|
||||
COMP rx_filter_mem_timing[NC+1][NT*P],
|
||||
float env[],
|
||||
COMP rx_baseband_mem_timing[NC+1][NFILTERTIMING],
|
||||
int nin);
|
||||
float qpsk_to_bits(int rx_bits[], int *sync_bit, COMP phase_difference[], COMP prev_rx_symbols[], COMP rx_symbols[]);
|
||||
void snr_update(float sig_est[], float noise_est[], COMP phase_difference[]);
|
||||
int freq_state(int sync_bit, int *state);
|
||||
float calc_snr(float sig_est[], float noise_est[]);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,124 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fdmdv_mod.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: April 28 2012
|
||||
|
||||
Given an input file of bits outputs a raw file (8kHz, 16 bit shorts)
|
||||
of FDMDV modem samples ready to send over a HF radio channel. The
|
||||
input file is assumed to be arranged as codec frames of 56 bits (7
|
||||
bytes) which we send as two 28 bit modem frames.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "fdmdv.h"
|
||||
|
||||
#define BITS_PER_CODEC_FRAME (2*FDMDV_BITS_PER_FRAME)
|
||||
#define BYTES_PER_CODEC_FRAME (BITS_PER_CODEC_FRAME/8)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fin, *fout;
|
||||
struct FDMDV *fdmdv;
|
||||
char packed_bits[BYTES_PER_CODEC_FRAME];
|
||||
int tx_bits[2*FDMDV_BITS_PER_FRAME];
|
||||
COMP tx_fdm[2*FDMDV_NOM_SAMPLES_PER_FRAME];
|
||||
short tx_fdm_scaled[2*FDMDV_NOM_SAMPLES_PER_FRAME];
|
||||
int frames;
|
||||
int i, bit, byte;
|
||||
int sync_bit;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("usage: %s InputBitFile OutputModemRawFile\n", argv[0]);
|
||||
printf("e.g %s hts1a.c2 hts1a_fdmdv.raw\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "-") == 0) fin = stdin;
|
||||
else if ( (fin = fopen(argv[1],"rb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening input bit file: %s: %s.\n",
|
||||
argv[1], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[2], "-") == 0) fout = stdout;
|
||||
else if ( (fout = fopen(argv[2],"wb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening output modem sample file: %s: %s.\n",
|
||||
argv[2], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fdmdv = fdmdv_create();
|
||||
frames = 0;
|
||||
|
||||
while(fread(packed_bits, sizeof(char), BYTES_PER_CODEC_FRAME, fin) == BYTES_PER_CODEC_FRAME) {
|
||||
frames++;
|
||||
|
||||
/* unpack bits, MSB first */
|
||||
|
||||
bit = 7; byte = 0;
|
||||
for(i=0; i<BITS_PER_CODEC_FRAME; i++) {
|
||||
tx_bits[i] = (packed_bits[byte] >> bit) & 0x1;
|
||||
bit--;
|
||||
if (bit < 0) {
|
||||
bit = 7;
|
||||
byte++;
|
||||
}
|
||||
}
|
||||
assert(byte == BYTES_PER_CODEC_FRAME);
|
||||
|
||||
/* modulate even and odd frames */
|
||||
|
||||
fdmdv_mod(fdmdv, tx_fdm, tx_bits, &sync_bit);
|
||||
assert(sync_bit == 1);
|
||||
|
||||
fdmdv_mod(fdmdv, &tx_fdm[FDMDV_NOM_SAMPLES_PER_FRAME], &tx_bits[FDMDV_BITS_PER_FRAME], &sync_bit);
|
||||
assert(sync_bit == 0);
|
||||
|
||||
/* scale and save to disk as shorts */
|
||||
|
||||
for(i=0; i<2*FDMDV_NOM_SAMPLES_PER_FRAME; i++)
|
||||
tx_fdm_scaled[i] = FDMDV_SCALE * tx_fdm[i].real;
|
||||
|
||||
fwrite(tx_fdm_scaled, sizeof(short), 2*FDMDV_NOM_SAMPLES_PER_FRAME, fout);
|
||||
|
||||
/* if this is in a pipeline, we probably don't want the usual
|
||||
buffering to occur */
|
||||
|
||||
if (fout == stdout) fflush(stdout);
|
||||
if (fin == stdin) fflush(stdin);
|
||||
}
|
||||
|
||||
//fdmdv_dump_osc_mags(fdmdv);
|
||||
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
fdmdv_destroy(fdmdv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fdmdv_put_test_bits.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 1 May 2012
|
||||
|
||||
Using a file of packed test bits as input, determines bit error
|
||||
rate. Useful for testing fdmdv_demod.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "fdmdv.h"
|
||||
|
||||
#define BITS_PER_CODEC_FRAME (2*FDMDV_BITS_PER_FRAME)
|
||||
#define BYTES_PER_CODEC_FRAME (BITS_PER_CODEC_FRAME/8)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fin;
|
||||
struct FDMDV *fdmdv;
|
||||
char packed_bits[BYTES_PER_CODEC_FRAME];
|
||||
int rx_bits[2*FDMDV_BITS_PER_FRAME];
|
||||
int i, bit, byte;
|
||||
int test_frame_sync, bit_errors, total_bit_errors, total_bits, ntest_bits;
|
||||
|
||||
if (argc < 2) {
|
||||
printf("usage: %s InputBitFile\n", argv[0]);
|
||||
printf("e.g %s test.c2\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "-") == 0) fin = stdin;
|
||||
else if ( (fin = fopen(argv[1],"rb")) == NULL ) {
|
||||
fprintf(stderr, "Error opening input bit file: %s: %s.\n",
|
||||
argv[1], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fdmdv = fdmdv_create();
|
||||
total_bit_errors = 0;
|
||||
total_bits = 0;
|
||||
|
||||
while(fread(packed_bits, sizeof(char), BYTES_PER_CODEC_FRAME, fin) == BYTES_PER_CODEC_FRAME) {
|
||||
/* unpack bits, MSB first */
|
||||
|
||||
bit = 7; byte = 0;
|
||||
for(i=0; i<BITS_PER_CODEC_FRAME; i++) {
|
||||
rx_bits[i] = (packed_bits[byte] >> bit) & 0x1;
|
||||
//printf("%d 0x%x %d\n", i, packed_bits[byte], rx_bits[i]);
|
||||
bit--;
|
||||
if (bit < 0) {
|
||||
bit = 7;
|
||||
byte++;
|
||||
}
|
||||
}
|
||||
assert(byte == BYTES_PER_CODEC_FRAME);
|
||||
|
||||
fdmdv_put_test_bits(fdmdv, &test_frame_sync, &bit_errors, &ntest_bits, rx_bits);
|
||||
if (test_frame_sync == 1) {
|
||||
total_bit_errors += bit_errors;
|
||||
total_bits = total_bits + ntest_bits;
|
||||
printf("+");
|
||||
}
|
||||
else
|
||||
printf("-");
|
||||
fdmdv_put_test_bits(fdmdv, &test_frame_sync, &bit_errors, &ntest_bits, &rx_bits[FDMDV_BITS_PER_FRAME]);
|
||||
if (test_frame_sync == 1) {
|
||||
total_bit_errors += bit_errors;
|
||||
total_bits = total_bits + ntest_bits;
|
||||
printf("+");
|
||||
}
|
||||
else
|
||||
printf("-");
|
||||
|
||||
/* if this is in a pipeline, we probably don't want the usual
|
||||
buffering to occur */
|
||||
|
||||
if (fin == stdin) fflush(stdin);
|
||||
}
|
||||
|
||||
fclose(fin);
|
||||
fdmdv_destroy(fdmdv);
|
||||
|
||||
printf("\nbits %d errors %d BER %1.4f\n", total_bits, total_bit_errors, (float)total_bit_errors/(1E-6+total_bits) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fifo.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: Oct 15 2012
|
||||
|
||||
A FIFO design useful in gluing the FDMDV modem and codec together in
|
||||
integrated applications. The unittest/tfifo indicates these
|
||||
routines are thread safe without the need for syncronisation
|
||||
object, e.g. a different thread can read and write to a fifo at the
|
||||
same time.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "fifo.h"
|
||||
|
||||
struct FIFO {
|
||||
short *buf;
|
||||
short *pin;
|
||||
short *pout;
|
||||
int nshort;
|
||||
};
|
||||
|
||||
struct FIFO *fifo_create(int nshort) {
|
||||
struct FIFO *fifo;
|
||||
|
||||
fifo = (struct FIFO *)malloc(sizeof(struct FIFO));
|
||||
assert(fifo != NULL);
|
||||
|
||||
fifo->buf = (short*)malloc(sizeof(short)*nshort);
|
||||
assert(fifo->buf != NULL);
|
||||
fifo->pin = fifo->buf;
|
||||
fifo->pout = fifo->buf;
|
||||
fifo->nshort = nshort;
|
||||
|
||||
return fifo;
|
||||
}
|
||||
|
||||
void fifo_destroy(struct FIFO *fifo) {
|
||||
assert(fifo != NULL);
|
||||
free(fifo->buf);
|
||||
free(fifo);
|
||||
}
|
||||
|
||||
int fifo_write(struct FIFO *fifo, short data[], int n) {
|
||||
int i;
|
||||
int fifo_free;
|
||||
short *pdata;
|
||||
short *pin = fifo->pin;
|
||||
|
||||
assert(fifo != NULL);
|
||||
assert(data != NULL);
|
||||
|
||||
// available storage is one less than nshort as prd == pwr
|
||||
// is reserved for empty rather than full
|
||||
|
||||
fifo_free = fifo->nshort - fifo_used(fifo) - 1;
|
||||
|
||||
if (n > fifo_free) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
/* This could be made more efficient with block copies
|
||||
using memcpy */
|
||||
|
||||
pdata = data;
|
||||
for(i=0; i<n; i++) {
|
||||
*pin++ = *pdata++;
|
||||
if (pin == (fifo->buf + fifo->nshort))
|
||||
pin = fifo->buf;
|
||||
}
|
||||
fifo->pin = pin;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fifo_read(struct FIFO *fifo, short data[], int n)
|
||||
{
|
||||
int i;
|
||||
short *pdata;
|
||||
short *pin = fifo->pin;
|
||||
short *pout = fifo->pout;
|
||||
|
||||
assert(fifo != NULL);
|
||||
assert(data != NULL);
|
||||
|
||||
if (n > fifo_used(fifo)) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
|
||||
/* This could be made more efficient with block copies
|
||||
using memcpy */
|
||||
|
||||
pdata = data;
|
||||
for(i=0; i<n; i++) {
|
||||
*pdata++ = *pout++;
|
||||
if (pout == (fifo->buf + fifo->nshort))
|
||||
pout = fifo->buf;
|
||||
}
|
||||
fifo->pout = pout;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fifo_used(struct FIFO *fifo)
|
||||
{
|
||||
short *pin = fifo->pin;
|
||||
short *pout = fifo->pout;
|
||||
unsigned int used;
|
||||
|
||||
assert(fifo != NULL);
|
||||
if (pin >= pout)
|
||||
used = pin - pout;
|
||||
else
|
||||
used = fifo->nshort + (unsigned int)(pin - pout);
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: fifo.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: Oct 15 2012
|
||||
|
||||
A FIFO design useful in gluing the FDMDV modem and codec together in
|
||||
integrated applications.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __FIFO__
|
||||
#define __FIFO__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct FIFO;
|
||||
|
||||
struct FIFO *fifo_create(int nshort);
|
||||
void fifo_destroy(struct FIFO *fifo);
|
||||
int fifo_write(struct FIFO *fifo, short data[], int n);
|
||||
int fifo_read(struct FIFO *fifo, short data[], int n);
|
||||
int fifo_used(struct FIFO *fifo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,179 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: generate_codebook.c
|
||||
AUTHOR......: Bruce Perens
|
||||
DATE CREATED: 29 Sep 2010
|
||||
|
||||
Generate header files containing LSP quantisers, runs at compile time.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
static const char usage[] =
|
||||
"Usage: %s filename array_name [filename ...]\n"
|
||||
"\tCreate C code for codebook tables.\n";
|
||||
|
||||
static const char format[] =
|
||||
"The table format must be:\n"
|
||||
"\tTwo integers describing the dimensions of the codebook.\n"
|
||||
"\tThen, enough numbers to fill the specified dimensions.\n";
|
||||
|
||||
static const char header[] =
|
||||
"/* THIS IS A GENERATED FILE. Edit generate_codebook.c and its input */\n\n"
|
||||
"/*\n"
|
||||
" * This intermediary file and the files that used to create it are under \n"
|
||||
" * The LGPL. See the file COPYING.\n"
|
||||
" */\n\n"
|
||||
"#include \"defines.h\"\n\n";
|
||||
|
||||
struct codebook {
|
||||
unsigned int k;
|
||||
unsigned int log2m;
|
||||
unsigned int m;
|
||||
float * cb;
|
||||
};
|
||||
|
||||
static void
|
||||
dump_array(const struct codebook * b, int index)
|
||||
{
|
||||
int limit = b->k * b->m;
|
||||
int i;
|
||||
|
||||
printf("static const float codes%d[] = {\n", index);
|
||||
for ( i = 0; i < limit; i++ ) {
|
||||
printf(" %g", b->cb[i]);
|
||||
if ( i < limit - 1 )
|
||||
printf(",");
|
||||
|
||||
/* organise VQs by rows, looks prettier */
|
||||
if ( ((i+1) % b->k) == 0 )
|
||||
printf("\n");
|
||||
}
|
||||
printf("};\n");
|
||||
}
|
||||
|
||||
static void
|
||||
dump_structure(const struct codebook * b, int index)
|
||||
{
|
||||
printf(" {\n");
|
||||
printf(" %d,\n", b->k);
|
||||
printf(" %g,\n", log(b->m) / log(2));
|
||||
printf(" %d,\n", b->m);
|
||||
printf(" codes%d\n", index);
|
||||
printf(" }");
|
||||
}
|
||||
|
||||
float
|
||||
get_float(FILE * in, const char * name, char * * cursor, char * buffer,
|
||||
int size)
|
||||
{
|
||||
for ( ; ; ) {
|
||||
char * s = *cursor;
|
||||
char c;
|
||||
|
||||
while ( (c = *s) != '\0' && !isdigit(c) && c != '-' && c != '.' )
|
||||
s++;
|
||||
|
||||
/* Comments start with "#" and continue to the end of the line. */
|
||||
if ( c != '\0' && c != '#' ) {
|
||||
char * end = 0;
|
||||
float f = 0;
|
||||
|
||||
f = strtod(s, &end);
|
||||
|
||||
if ( end != s )
|
||||
*cursor = end;
|
||||
return f;
|
||||
}
|
||||
|
||||
if ( fgets(buffer, size, in) == NULL ) {
|
||||
fprintf(stderr, "%s: Format error. %s\n", name, format);
|
||||
exit(1);
|
||||
}
|
||||
*cursor = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
static struct codebook *
|
||||
load(FILE * file, const char * name)
|
||||
{
|
||||
char line[1024];
|
||||
char * cursor = line;
|
||||
struct codebook * b = malloc(sizeof(struct codebook));
|
||||
int i;
|
||||
int size;
|
||||
|
||||
*cursor = '\0';
|
||||
|
||||
b->k = (int)get_float(file, name, &cursor, line, sizeof(line));
|
||||
b->m = (int)get_float(file, name ,&cursor, line, sizeof(line));
|
||||
size = b->k * b->m;
|
||||
|
||||
b->cb = (float *)malloc(size * sizeof(float));
|
||||
|
||||
for ( i = 0; i < size; i++ )
|
||||
b->cb[i] = get_float(file, name, &cursor, line, sizeof(line));
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char * * argv)
|
||||
{
|
||||
struct codebook * * cb = malloc(argc * sizeof(struct codebook *));
|
||||
int i;
|
||||
|
||||
if ( argc < 2 ) {
|
||||
fprintf(stderr, usage, argv[0]);
|
||||
fprintf(stderr, format);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for ( i = 0; i < argc - 2; i++ ) {
|
||||
FILE * in = fopen(argv[i + 2], "r");
|
||||
|
||||
if ( in == NULL ) {
|
||||
perror(argv[i + 2]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cb[i] = load(in, argv[i + 2]);
|
||||
|
||||
fclose(in);
|
||||
}
|
||||
|
||||
printf(header);
|
||||
for ( i = 0; i < argc - 2; i++ ) {
|
||||
printf(" /* %s */\n", argv[i + 2]);
|
||||
dump_array(cb[i], i);
|
||||
}
|
||||
printf("\nconst struct lsp_codebook %s[] = {\n", argv[1]);
|
||||
for ( i = 0; i < argc - 2; i++ ) {
|
||||
printf(" /* %s */\n", argv[i + 2]);
|
||||
dump_structure(cb[i], i);
|
||||
printf(",\n");
|
||||
}
|
||||
printf(" { 0, 0, 0, 0 }\n");
|
||||
printf("};\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: genlspdtcb.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 2 Nov 2011
|
||||
|
||||
Generates codebooks (quantisation tables) for LSP delta-T VQ.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
#define MAX_ROWS 10
|
||||
|
||||
float lsp1to4[] = {
|
||||
-25,0,25,
|
||||
-25,0,25,
|
||||
-50,0,50,
|
||||
-50,0,50
|
||||
};
|
||||
|
||||
float lsp5to10[] = {
|
||||
-50,0,50,
|
||||
-50,0,50,
|
||||
-50,0,50,
|
||||
-50,0,50,
|
||||
-50,0,50,
|
||||
-50,0,50
|
||||
};
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
void create_codebook_text_file(char filename[], float lsp[],
|
||||
int rows, int cols);
|
||||
|
||||
int main(void) {
|
||||
create_codebook_text_file("codebook/lspdt1-4.txt", lsp1to4, 4, 3);
|
||||
create_codebook_text_file("codebook/lspdt5-10.txt", lsp5to10, 6, 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void create_codebook_text_file(char filename[], float lsp[],
|
||||
int rows, int cols)
|
||||
{
|
||||
FILE *f;
|
||||
int i, digits[MAX_ROWS];
|
||||
|
||||
f = fopen(filename, "wt");
|
||||
if (f == NULL) {
|
||||
printf("Can't open codebook text file %s\n", filename);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(i=0; i<rows; i++)
|
||||
digits[i] = 0;
|
||||
|
||||
fprintf(f, "%d %d\n", rows, (int)pow(cols, rows));
|
||||
|
||||
do {
|
||||
for(i=0; i<rows; i++)
|
||||
fprintf(f, "%4.0f ", lsp[cols*i + digits[i]]);
|
||||
fprintf(f, "\n");
|
||||
digits[0]++;
|
||||
for(i=0; i<rows-1; i++)
|
||||
if (digits[i]== cols) {
|
||||
digits[i] = 0;
|
||||
digits[i+1]++;
|
||||
}
|
||||
} while (digits[rows-1] != cols);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "sine.h" /* global defines for coder */
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Globals used in encoder and decoder */
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
const float glottal[]={
|
||||
0.000000,
|
||||
-0.057687,
|
||||
-0.115338,
|
||||
-0.172917,
|
||||
-0.230385,
|
||||
-0.287707,
|
||||
-0.344845,
|
||||
-0.401762,
|
||||
-0.458419,
|
||||
-0.514781,
|
||||
-0.570809,
|
||||
-0.626467,
|
||||
-0.681721,
|
||||
-0.736537,
|
||||
-0.790884,
|
||||
-0.844733,
|
||||
-0.898057,
|
||||
-0.950834,
|
||||
-1.003044,
|
||||
-1.054670,
|
||||
-1.105700,
|
||||
-1.156124,
|
||||
-1.205936,
|
||||
-1.255132,
|
||||
-1.303711,
|
||||
-1.351675,
|
||||
-1.399026,
|
||||
-1.445769,
|
||||
-1.491908,
|
||||
-1.537448,
|
||||
-1.582393,
|
||||
-1.626747,
|
||||
-1.670514,
|
||||
-1.713693,
|
||||
-1.756285,
|
||||
-1.798288,
|
||||
-1.839697,
|
||||
-1.880507,
|
||||
-1.920712,
|
||||
-1.960302,
|
||||
-1.999269,
|
||||
-2.037603,
|
||||
-2.075295,
|
||||
-2.112335,
|
||||
-2.148716,
|
||||
-2.184430,
|
||||
-2.219472,
|
||||
-2.253839,
|
||||
-2.287531,
|
||||
-2.320550,
|
||||
-2.352900,
|
||||
-2.384588,
|
||||
-2.415623,
|
||||
-2.446019,
|
||||
-2.475788,
|
||||
-2.504946,
|
||||
-2.533512,
|
||||
-2.561501,
|
||||
-2.588934,
|
||||
-2.615827,
|
||||
-2.642198,
|
||||
-2.668064,
|
||||
-2.693439,
|
||||
-2.718337,
|
||||
-2.742767,
|
||||
-2.766738,
|
||||
-2.790256,
|
||||
-2.813322,
|
||||
-2.835936,
|
||||
-2.858094,
|
||||
-2.879790,
|
||||
-2.901016,
|
||||
-2.921759,
|
||||
-2.942008,
|
||||
-2.961747,
|
||||
-2.980961,
|
||||
-2.999632,
|
||||
-3.017745,
|
||||
-3.035282,
|
||||
-3.052228,
|
||||
-3.068567,
|
||||
-3.084285,
|
||||
-3.099371,
|
||||
-3.113813,
|
||||
-3.127605,
|
||||
-3.140738,
|
||||
3.129975,
|
||||
3.118167,
|
||||
3.107022,
|
||||
3.096537,
|
||||
3.086709,
|
||||
3.077531,
|
||||
3.068996,
|
||||
3.061096,
|
||||
3.053821,
|
||||
3.047159,
|
||||
3.041102,
|
||||
3.035636,
|
||||
3.030753,
|
||||
3.026441,
|
||||
3.022690,
|
||||
3.019491,
|
||||
3.016836,
|
||||
3.014718,
|
||||
3.013132,
|
||||
3.012072,
|
||||
3.011535,
|
||||
3.011521,
|
||||
3.012028,
|
||||
3.013057,
|
||||
3.014612,
|
||||
3.016695,
|
||||
3.019310,
|
||||
3.022463,
|
||||
3.026160,
|
||||
3.030407,
|
||||
3.035212,
|
||||
3.040580,
|
||||
3.046520,
|
||||
3.053038,
|
||||
3.060141,
|
||||
3.067836,
|
||||
3.076128,
|
||||
3.085023,
|
||||
3.094525,
|
||||
3.104639,
|
||||
3.115367,
|
||||
3.126712,
|
||||
3.138674,
|
||||
-3.131930,
|
||||
-3.118731,
|
||||
-3.104915,
|
||||
-3.090485,
|
||||
-3.075444,
|
||||
-3.059795,
|
||||
-3.043543,
|
||||
-3.026695,
|
||||
-3.009254,
|
||||
-2.991229,
|
||||
-2.972625,
|
||||
-2.953449,
|
||||
-2.933710,
|
||||
-2.913414,
|
||||
-2.892567,
|
||||
-2.871176,
|
||||
-2.849248,
|
||||
-2.826787,
|
||||
-2.803798,
|
||||
-2.780284,
|
||||
-2.756247,
|
||||
-2.731689,
|
||||
-2.706609,
|
||||
-2.681005,
|
||||
-2.654875,
|
||||
-2.628213,
|
||||
-2.601015,
|
||||
-2.573272,
|
||||
-2.544977,
|
||||
-2.516121,
|
||||
-2.486694,
|
||||
-2.456686,
|
||||
-2.426084,
|
||||
-2.394879,
|
||||
-2.363060,
|
||||
-2.330616,
|
||||
-2.297538,
|
||||
-2.263816,
|
||||
-2.229444,
|
||||
-2.194416,
|
||||
-2.158727,
|
||||
-2.122375,
|
||||
-2.085359,
|
||||
-2.047682,
|
||||
-2.009347,
|
||||
-1.970361,
|
||||
-1.930732,
|
||||
-1.890470,
|
||||
-1.849587,
|
||||
-1.808098,
|
||||
-1.766017,
|
||||
-1.723360,
|
||||
-1.680145,
|
||||
-1.636388,
|
||||
-1.592105,
|
||||
-1.547313,
|
||||
-1.502025,
|
||||
-1.456256,
|
||||
-1.410016,
|
||||
-1.363314,
|
||||
-1.316157,
|
||||
-1.268547,
|
||||
-1.220486,
|
||||
-1.171971,
|
||||
-1.122997,
|
||||
-1.073555,
|
||||
-1.023636,
|
||||
-0.973227,
|
||||
-0.922312,
|
||||
-0.870875,
|
||||
-0.818899,
|
||||
-0.766366,
|
||||
-0.713257,
|
||||
-0.659554,
|
||||
-0.605242,
|
||||
-0.550303,
|
||||
-0.494723,
|
||||
-0.438492,
|
||||
-0.381598,
|
||||
-0.324036,
|
||||
-0.265800,
|
||||
-0.206889,
|
||||
-0.147303,
|
||||
-0.087046,
|
||||
-0.026121,
|
||||
0.035463,
|
||||
0.097698,
|
||||
0.160576,
|
||||
0.224087,
|
||||
0.288221,
|
||||
0.352969,
|
||||
0.418323,
|
||||
0.484276,
|
||||
0.550822,
|
||||
0.617958,
|
||||
0.685681,
|
||||
0.753991,
|
||||
0.822889,
|
||||
0.892378,
|
||||
0.962462,
|
||||
1.033144,
|
||||
1.104430,
|
||||
1.176325,
|
||||
1.248833,
|
||||
1.321956,
|
||||
1.395696,
|
||||
1.470051,
|
||||
1.545019,
|
||||
1.620593,
|
||||
1.696763,
|
||||
1.773516,
|
||||
1.850837,
|
||||
1.928705,
|
||||
2.007097,
|
||||
2.085987,
|
||||
2.165347,
|
||||
2.245145,
|
||||
2.325347,
|
||||
2.405919,
|
||||
2.486824,
|
||||
2.568025,
|
||||
2.649485,
|
||||
2.731167,
|
||||
2.813033,
|
||||
2.895045,
|
||||
2.977167,
|
||||
3.059362};
|
||||
@@ -0,0 +1,644 @@
|
||||
/* Generated by hanning_file() Octave function */
|
||||
|
||||
const float hanning[]={
|
||||
0,
|
||||
2.4171e-05,
|
||||
9.66816e-05,
|
||||
0.000217525,
|
||||
0.000386689,
|
||||
0.000604158,
|
||||
0.00086991,
|
||||
0.00118392,
|
||||
0.00154616,
|
||||
0.00195659,
|
||||
0.00241517,
|
||||
0.00292186,
|
||||
0.00347661,
|
||||
0.00407937,
|
||||
0.00473008,
|
||||
0.00542867,
|
||||
0.00617507,
|
||||
0.00696922,
|
||||
0.00781104,
|
||||
0.00870045,
|
||||
0.00963736,
|
||||
0.0106217,
|
||||
0.0116533,
|
||||
0.0127322,
|
||||
0.0138581,
|
||||
0.0150311,
|
||||
0.0162509,
|
||||
0.0175175,
|
||||
0.0188308,
|
||||
0.0201906,
|
||||
0.0215968,
|
||||
0.0230492,
|
||||
0.0245478,
|
||||
0.0260923,
|
||||
0.0276826,
|
||||
0.0293186,
|
||||
0.0310001,
|
||||
0.032727,
|
||||
0.034499,
|
||||
0.036316,
|
||||
0.0381779,
|
||||
0.0400844,
|
||||
0.0420354,
|
||||
0.0440307,
|
||||
0.04607,
|
||||
0.0481533,
|
||||
0.0502802,
|
||||
0.0524506,
|
||||
0.0546643,
|
||||
0.056921,
|
||||
0.0592206,
|
||||
0.0615627,
|
||||
0.0639473,
|
||||
0.0663741,
|
||||
0.0688427,
|
||||
0.0713531,
|
||||
0.0739048,
|
||||
0.0764978,
|
||||
0.0791318,
|
||||
0.0818064,
|
||||
0.0845214,
|
||||
0.0872767,
|
||||
0.0900718,
|
||||
0.0929066,
|
||||
0.0957807,
|
||||
0.0986939,
|
||||
0.101646,
|
||||
0.104636,
|
||||
0.107665,
|
||||
0.110732,
|
||||
0.113836,
|
||||
0.116978,
|
||||
0.120156,
|
||||
0.123372,
|
||||
0.126624,
|
||||
0.129912,
|
||||
0.133235,
|
||||
0.136594,
|
||||
0.139989,
|
||||
0.143418,
|
||||
0.146881,
|
||||
0.150379,
|
||||
0.153911,
|
||||
0.157476,
|
||||
0.161074,
|
||||
0.164705,
|
||||
0.168368,
|
||||
0.172063,
|
||||
0.17579,
|
||||
0.179549,
|
||||
0.183338,
|
||||
0.187158,
|
||||
0.191008,
|
||||
0.194888,
|
||||
0.198798,
|
||||
0.202737,
|
||||
0.206704,
|
||||
0.2107,
|
||||
0.214724,
|
||||
0.218775,
|
||||
0.222854,
|
||||
0.226959,
|
||||
0.231091,
|
||||
0.235249,
|
||||
0.239432,
|
||||
0.243641,
|
||||
0.247874,
|
||||
0.252132,
|
||||
0.256414,
|
||||
0.260719,
|
||||
0.265047,
|
||||
0.269398,
|
||||
0.273772,
|
||||
0.278167,
|
||||
0.282584,
|
||||
0.287021,
|
||||
0.29148,
|
||||
0.295958,
|
||||
0.300456,
|
||||
0.304974,
|
||||
0.30951,
|
||||
0.314065,
|
||||
0.318638,
|
||||
0.323228,
|
||||
0.327835,
|
||||
0.332459,
|
||||
0.3371,
|
||||
0.341756,
|
||||
0.346427,
|
||||
0.351113,
|
||||
0.355814,
|
||||
0.360528,
|
||||
0.365256,
|
||||
0.369997,
|
||||
0.374751,
|
||||
0.379516,
|
||||
0.384293,
|
||||
0.389082,
|
||||
0.393881,
|
||||
0.398691,
|
||||
0.40351,
|
||||
0.408338,
|
||||
0.413176,
|
||||
0.418022,
|
||||
0.422876,
|
||||
0.427737,
|
||||
0.432605,
|
||||
0.43748,
|
||||
0.44236,
|
||||
0.447247,
|
||||
0.452138,
|
||||
0.457034,
|
||||
0.461935,
|
||||
0.466839,
|
||||
0.471746,
|
||||
0.476655,
|
||||
0.481568,
|
||||
0.486481,
|
||||
0.491397,
|
||||
0.496313,
|
||||
0.501229,
|
||||
0.506145,
|
||||
0.511061,
|
||||
0.515976,
|
||||
0.520889,
|
||||
0.5258,
|
||||
0.530708,
|
||||
0.535614,
|
||||
0.540516,
|
||||
0.545414,
|
||||
0.550308,
|
||||
0.555197,
|
||||
0.560081,
|
||||
0.564958,
|
||||
0.56983,
|
||||
0.574695,
|
||||
0.579552,
|
||||
0.584402,
|
||||
0.589244,
|
||||
0.594077,
|
||||
0.598901,
|
||||
0.603715,
|
||||
0.60852,
|
||||
0.613314,
|
||||
0.618097,
|
||||
0.622868,
|
||||
0.627628,
|
||||
0.632375,
|
||||
0.63711,
|
||||
0.641831,
|
||||
0.646538,
|
||||
0.651232,
|
||||
0.655911,
|
||||
0.660574,
|
||||
0.665222,
|
||||
0.669855,
|
||||
0.67447,
|
||||
0.679069,
|
||||
0.683651,
|
||||
0.688215,
|
||||
0.69276,
|
||||
0.697287,
|
||||
0.701795,
|
||||
0.706284,
|
||||
0.710752,
|
||||
0.7152,
|
||||
0.719627,
|
||||
0.724033,
|
||||
0.728418,
|
||||
0.73278,
|
||||
0.73712,
|
||||
0.741437,
|
||||
0.74573,
|
||||
0.75,
|
||||
0.754246,
|
||||
0.758467,
|
||||
0.762663,
|
||||
0.766833,
|
||||
0.770978,
|
||||
0.775097,
|
||||
0.779189,
|
||||
0.783254,
|
||||
0.787291,
|
||||
0.791301,
|
||||
0.795283,
|
||||
0.799236,
|
||||
0.80316,
|
||||
0.807055,
|
||||
0.810921,
|
||||
0.814756,
|
||||
0.81856,
|
||||
0.822334,
|
||||
0.826077,
|
||||
0.829788,
|
||||
0.833468,
|
||||
0.837115,
|
||||
0.840729,
|
||||
0.844311,
|
||||
0.847859,
|
||||
0.851374,
|
||||
0.854855,
|
||||
0.858301,
|
||||
0.861713,
|
||||
0.86509,
|
||||
0.868431,
|
||||
0.871737,
|
||||
0.875007,
|
||||
0.87824,
|
||||
0.881437,
|
||||
0.884598,
|
||||
0.887721,
|
||||
0.890806,
|
||||
0.893854,
|
||||
0.896864,
|
||||
0.899835,
|
||||
0.902768,
|
||||
0.905661,
|
||||
0.908516,
|
||||
0.911331,
|
||||
0.914106,
|
||||
0.916841,
|
||||
0.919536,
|
||||
0.92219,
|
||||
0.924804,
|
||||
0.927376,
|
||||
0.929907,
|
||||
0.932397,
|
||||
0.934845,
|
||||
0.93725,
|
||||
0.939614,
|
||||
0.941935,
|
||||
0.944213,
|
||||
0.946448,
|
||||
0.94864,
|
||||
0.950789,
|
||||
0.952894,
|
||||
0.954955,
|
||||
0.956972,
|
||||
0.958946,
|
||||
0.960874,
|
||||
0.962759,
|
||||
0.964598,
|
||||
0.966393,
|
||||
0.968142,
|
||||
0.969846,
|
||||
0.971505,
|
||||
0.973118,
|
||||
0.974686,
|
||||
0.976207,
|
||||
0.977683,
|
||||
0.979112,
|
||||
0.980495,
|
||||
0.981832,
|
||||
0.983122,
|
||||
0.984365,
|
||||
0.985561,
|
||||
0.986711,
|
||||
0.987813,
|
||||
0.988868,
|
||||
0.989876,
|
||||
0.990837,
|
||||
0.99175,
|
||||
0.992616,
|
||||
0.993434,
|
||||
0.994204,
|
||||
0.994927,
|
||||
0.995601,
|
||||
0.996228,
|
||||
0.996807,
|
||||
0.997337,
|
||||
0.99782,
|
||||
0.998255,
|
||||
0.998641,
|
||||
0.998979,
|
||||
0.999269,
|
||||
0.999511,
|
||||
0.999704,
|
||||
0.999849,
|
||||
0.999946,
|
||||
0.999994,
|
||||
0.999994,
|
||||
0.999946,
|
||||
0.999849,
|
||||
0.999704,
|
||||
0.999511,
|
||||
0.999269,
|
||||
0.998979,
|
||||
0.998641,
|
||||
0.998255,
|
||||
0.99782,
|
||||
0.997337,
|
||||
0.996807,
|
||||
0.996228,
|
||||
0.995601,
|
||||
0.994927,
|
||||
0.994204,
|
||||
0.993434,
|
||||
0.992616,
|
||||
0.99175,
|
||||
0.990837,
|
||||
0.989876,
|
||||
0.988868,
|
||||
0.987813,
|
||||
0.986711,
|
||||
0.985561,
|
||||
0.984365,
|
||||
0.983122,
|
||||
0.981832,
|
||||
0.980495,
|
||||
0.979112,
|
||||
0.977683,
|
||||
0.976207,
|
||||
0.974686,
|
||||
0.973118,
|
||||
0.971505,
|
||||
0.969846,
|
||||
0.968142,
|
||||
0.966393,
|
||||
0.964598,
|
||||
0.962759,
|
||||
0.960874,
|
||||
0.958946,
|
||||
0.956972,
|
||||
0.954955,
|
||||
0.952894,
|
||||
0.950789,
|
||||
0.94864,
|
||||
0.946448,
|
||||
0.944213,
|
||||
0.941935,
|
||||
0.939614,
|
||||
0.93725,
|
||||
0.934845,
|
||||
0.932397,
|
||||
0.929907,
|
||||
0.927376,
|
||||
0.924804,
|
||||
0.92219,
|
||||
0.919536,
|
||||
0.916841,
|
||||
0.914106,
|
||||
0.911331,
|
||||
0.908516,
|
||||
0.905661,
|
||||
0.902768,
|
||||
0.899835,
|
||||
0.896864,
|
||||
0.893854,
|
||||
0.890806,
|
||||
0.887721,
|
||||
0.884598,
|
||||
0.881437,
|
||||
0.87824,
|
||||
0.875007,
|
||||
0.871737,
|
||||
0.868431,
|
||||
0.86509,
|
||||
0.861713,
|
||||
0.858301,
|
||||
0.854855,
|
||||
0.851374,
|
||||
0.847859,
|
||||
0.844311,
|
||||
0.840729,
|
||||
0.837115,
|
||||
0.833468,
|
||||
0.829788,
|
||||
0.826077,
|
||||
0.822334,
|
||||
0.81856,
|
||||
0.814756,
|
||||
0.810921,
|
||||
0.807055,
|
||||
0.80316,
|
||||
0.799236,
|
||||
0.795283,
|
||||
0.791301,
|
||||
0.787291,
|
||||
0.783254,
|
||||
0.779189,
|
||||
0.775097,
|
||||
0.770978,
|
||||
0.766833,
|
||||
0.762663,
|
||||
0.758467,
|
||||
0.754246,
|
||||
0.75,
|
||||
0.74573,
|
||||
0.741437,
|
||||
0.73712,
|
||||
0.73278,
|
||||
0.728418,
|
||||
0.724033,
|
||||
0.719627,
|
||||
0.7152,
|
||||
0.710752,
|
||||
0.706284,
|
||||
0.701795,
|
||||
0.697287,
|
||||
0.69276,
|
||||
0.688215,
|
||||
0.683651,
|
||||
0.679069,
|
||||
0.67447,
|
||||
0.669855,
|
||||
0.665222,
|
||||
0.660574,
|
||||
0.655911,
|
||||
0.651232,
|
||||
0.646538,
|
||||
0.641831,
|
||||
0.63711,
|
||||
0.632375,
|
||||
0.627628,
|
||||
0.622868,
|
||||
0.618097,
|
||||
0.613314,
|
||||
0.60852,
|
||||
0.603715,
|
||||
0.598901,
|
||||
0.594077,
|
||||
0.589244,
|
||||
0.584402,
|
||||
0.579552,
|
||||
0.574695,
|
||||
0.56983,
|
||||
0.564958,
|
||||
0.560081,
|
||||
0.555197,
|
||||
0.550308,
|
||||
0.545414,
|
||||
0.540516,
|
||||
0.535614,
|
||||
0.530708,
|
||||
0.5258,
|
||||
0.520889,
|
||||
0.515976,
|
||||
0.511061,
|
||||
0.506145,
|
||||
0.501229,
|
||||
0.496313,
|
||||
0.491397,
|
||||
0.486481,
|
||||
0.481568,
|
||||
0.476655,
|
||||
0.471746,
|
||||
0.466839,
|
||||
0.461935,
|
||||
0.457034,
|
||||
0.452138,
|
||||
0.447247,
|
||||
0.44236,
|
||||
0.43748,
|
||||
0.432605,
|
||||
0.427737,
|
||||
0.422876,
|
||||
0.418022,
|
||||
0.413176,
|
||||
0.408338,
|
||||
0.40351,
|
||||
0.398691,
|
||||
0.393881,
|
||||
0.389082,
|
||||
0.384293,
|
||||
0.379516,
|
||||
0.374751,
|
||||
0.369997,
|
||||
0.365256,
|
||||
0.360528,
|
||||
0.355814,
|
||||
0.351113,
|
||||
0.346427,
|
||||
0.341756,
|
||||
0.3371,
|
||||
0.332459,
|
||||
0.327835,
|
||||
0.323228,
|
||||
0.318638,
|
||||
0.314065,
|
||||
0.30951,
|
||||
0.304974,
|
||||
0.300456,
|
||||
0.295958,
|
||||
0.29148,
|
||||
0.287021,
|
||||
0.282584,
|
||||
0.278167,
|
||||
0.273772,
|
||||
0.269398,
|
||||
0.265047,
|
||||
0.260719,
|
||||
0.256414,
|
||||
0.252132,
|
||||
0.247874,
|
||||
0.243641,
|
||||
0.239432,
|
||||
0.235249,
|
||||
0.231091,
|
||||
0.226959,
|
||||
0.222854,
|
||||
0.218775,
|
||||
0.214724,
|
||||
0.2107,
|
||||
0.206704,
|
||||
0.202737,
|
||||
0.198798,
|
||||
0.194888,
|
||||
0.191008,
|
||||
0.187158,
|
||||
0.183338,
|
||||
0.179549,
|
||||
0.17579,
|
||||
0.172063,
|
||||
0.168368,
|
||||
0.164705,
|
||||
0.161074,
|
||||
0.157476,
|
||||
0.153911,
|
||||
0.150379,
|
||||
0.146881,
|
||||
0.143418,
|
||||
0.139989,
|
||||
0.136594,
|
||||
0.133235,
|
||||
0.129912,
|
||||
0.126624,
|
||||
0.123372,
|
||||
0.120156,
|
||||
0.116978,
|
||||
0.113836,
|
||||
0.110732,
|
||||
0.107665,
|
||||
0.104636,
|
||||
0.101646,
|
||||
0.0986939,
|
||||
0.0957807,
|
||||
0.0929066,
|
||||
0.0900718,
|
||||
0.0872767,
|
||||
0.0845214,
|
||||
0.0818064,
|
||||
0.0791318,
|
||||
0.0764978,
|
||||
0.0739048,
|
||||
0.0713531,
|
||||
0.0688427,
|
||||
0.0663741,
|
||||
0.0639473,
|
||||
0.0615627,
|
||||
0.0592206,
|
||||
0.056921,
|
||||
0.0546643,
|
||||
0.0524506,
|
||||
0.0502802,
|
||||
0.0481533,
|
||||
0.04607,
|
||||
0.0440307,
|
||||
0.0420354,
|
||||
0.0400844,
|
||||
0.0381779,
|
||||
0.036316,
|
||||
0.034499,
|
||||
0.032727,
|
||||
0.0310001,
|
||||
0.0293186,
|
||||
0.0276826,
|
||||
0.0260923,
|
||||
0.0245478,
|
||||
0.0230492,
|
||||
0.0215968,
|
||||
0.0201906,
|
||||
0.0188308,
|
||||
0.0175175,
|
||||
0.0162509,
|
||||
0.0150311,
|
||||
0.0138581,
|
||||
0.0127322,
|
||||
0.0116533,
|
||||
0.0106217,
|
||||
0.00963736,
|
||||
0.00870045,
|
||||
0.00781104,
|
||||
0.00696922,
|
||||
0.00617507,
|
||||
0.00542867,
|
||||
0.00473008,
|
||||
0.00407937,
|
||||
0.00347661,
|
||||
0.00292186,
|
||||
0.00241517,
|
||||
0.00195659,
|
||||
0.00154616,
|
||||
0.00118392,
|
||||
0.00086991,
|
||||
0.000604158,
|
||||
0.000386689,
|
||||
0.000217525,
|
||||
9.66816e-05,
|
||||
2.4171e-05,
|
||||
0
|
||||
};
|
||||
+168
-5
@@ -22,16 +22,18 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "interp.h"
|
||||
#include "lsp.h"
|
||||
#include "quantise.h"
|
||||
|
||||
float sample_log_amp(MODEL *model, float w);
|
||||
|
||||
@@ -48,6 +50,12 @@ float sample_log_amp(MODEL *model, float w);
|
||||
|
||||
This version can interpolate the amplitudes between two frames of
|
||||
different Wo and L.
|
||||
|
||||
This version works by log linear interpolation, but listening tests
|
||||
showed it creates problems in background noise, e.g. hts2a and mmt1.
|
||||
When this function is used (--dec mode) bg noise appears to be
|
||||
amplitude modulated, and gets louder. The interp_lsp() function
|
||||
below seems to do a better job.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@@ -108,15 +116,170 @@ float sample_log_amp(MODEL *model, float w)
|
||||
assert(f <= 1.0);
|
||||
|
||||
if (m < 1) {
|
||||
log_amp = f*log10(model->A[1]);
|
||||
log_amp = f*log10(model->A[1] + 1E-6);
|
||||
}
|
||||
else if ((m+1) > model->L) {
|
||||
log_amp = (1.0-f)*log10(model->A[model->L]);
|
||||
log_amp = (1.0-f)*log10(model->A[model->L] + 1E-6);
|
||||
}
|
||||
else {
|
||||
log_amp = (1.0-f)*log10(model->A[m]) + f*log10(model->A[m+1]);
|
||||
log_amp = (1.0-f)*log10(model->A[m] + 1E-6) +
|
||||
f*log10(model->A[m+1] + 1E-6);
|
||||
}
|
||||
|
||||
return log_amp;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: interp_lsp()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 10 Nov 2010
|
||||
|
||||
Given two frames decribed by model parameters 20ms apart, determines
|
||||
the model parameters of the 10ms frame between them. Assumes
|
||||
voicing is available for middle (interpolated) frame. Outputs are
|
||||
amplitudes and Wo for the interpolated frame.
|
||||
|
||||
This version uses interpolation of LSPs, seems to do a better job
|
||||
with bg noise.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void interpolate_lsp(
|
||||
kiss_fft_cfg fft_fwd_cfg,
|
||||
MODEL *interp, /* interpolated model params */
|
||||
MODEL *prev, /* previous frames model params */
|
||||
MODEL *next, /* next frames model params */
|
||||
float *prev_lsps, /* previous frames LSPs */
|
||||
float prev_e, /* previous frames LPC energy */
|
||||
float *next_lsps, /* next frames LSPs */
|
||||
float next_e, /* next frames LPC energy */
|
||||
float *ak_interp, /* interpolated aks for this frame */
|
||||
float *lsps_interp/* interpolated lsps for this frame */
|
||||
)
|
||||
{
|
||||
int i;
|
||||
float e;
|
||||
float snr;
|
||||
|
||||
/* trap corner case where V est is probably wrong */
|
||||
|
||||
if (interp->voiced && !prev->voiced && !next->voiced) {
|
||||
interp->voiced = 0;
|
||||
}
|
||||
|
||||
/* Wo depends on voicing of this and adjacent frames */
|
||||
|
||||
if (interp->voiced) {
|
||||
if (prev->voiced && next->voiced)
|
||||
interp->Wo = (prev->Wo + next->Wo)/2.0;
|
||||
if (!prev->voiced && next->voiced)
|
||||
interp->Wo = next->Wo;
|
||||
if (prev->voiced && !next->voiced)
|
||||
interp->Wo = prev->Wo;
|
||||
}
|
||||
else {
|
||||
interp->Wo = TWO_PI/P_MAX;
|
||||
}
|
||||
interp->L = PI/interp->Wo;
|
||||
|
||||
//printf(" interp: prev_v: %d next_v: %d prev_Wo: %f next_Wo: %f\n",
|
||||
// prev->voiced, next->voiced, prev->Wo, next->Wo);
|
||||
//printf(" interp: Wo: %1.5f L: %d\n", interp->Wo, interp->L);
|
||||
|
||||
/* interpolate LSPs */
|
||||
|
||||
for(i=0; i<LPC_ORD; i++) {
|
||||
lsps_interp[i] = (prev_lsps[i] + next_lsps[i])/2.0;
|
||||
}
|
||||
|
||||
/* Interpolate LPC energy in log domain */
|
||||
|
||||
e = pow(10.0, (log10(prev_e) + log10(next_e))/2.0);
|
||||
//printf(" interp: e: %f\n", e);
|
||||
|
||||
/* convert back to amplitudes */
|
||||
|
||||
lsp_to_lpc(lsps_interp, ak_interp, LPC_ORD);
|
||||
aks_to_M2(fft_fwd_cfg, ak_interp, LPC_ORD, interp, e, &snr, 0, 0, 1, 1, LPCPF_BETA, LPCPF_GAMMA);
|
||||
//printf(" interp: ak[1]: %f A[1] %f\n", ak_interp[1], interp->A[1]);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: interp_Wo()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 22 May 2012
|
||||
|
||||
Interpolates centre 10ms sample of Wo and L samples given two
|
||||
samples 20ms apart. Assumes voicing is available for centre
|
||||
(interpolated) frame.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void interp_Wo(
|
||||
MODEL *interp, /* interpolated model params */
|
||||
MODEL *prev, /* previous frames model params */
|
||||
MODEL *next /* next frames model params */
|
||||
)
|
||||
{
|
||||
/* trap corner case where voicing est is probably wrong */
|
||||
|
||||
if (interp->voiced && !prev->voiced && !next->voiced) {
|
||||
interp->voiced = 0;
|
||||
}
|
||||
|
||||
/* Wo depends on voicing of this and adjacent frames */
|
||||
|
||||
if (interp->voiced) {
|
||||
if (prev->voiced && next->voiced)
|
||||
interp->Wo = (prev->Wo + next->Wo)/2.0;
|
||||
if (!prev->voiced && next->voiced)
|
||||
interp->Wo = next->Wo;
|
||||
if (prev->voiced && !next->voiced)
|
||||
interp->Wo = prev->Wo;
|
||||
}
|
||||
else {
|
||||
interp->Wo = TWO_PI/P_MAX;
|
||||
}
|
||||
interp->L = PI/interp->Wo;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: interp_energy()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 22 May 2012
|
||||
|
||||
Interpolates centre 10ms sample of energy given two samples 20ms
|
||||
apart.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
float interp_energy(float prev_e, float next_e)
|
||||
{
|
||||
return pow(10.0, (log10(prev_e) + log10(next_e))/2.0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: interpolate_lsp_ver2()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 22 May 2012
|
||||
|
||||
Weighted interpolation of LSPs.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void interpolate_lsp_ver2(float interp[], float prev[], float next[], float weight)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<LPC_ORD; i++)
|
||||
interp[i] = (1.0 - weight)*prev[i] + weight*next[i];
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,22 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __INTERP__
|
||||
#define __INTERP__
|
||||
|
||||
#include "kiss_fft.h"
|
||||
|
||||
void interpolate(MODEL *interp, MODEL *prev, MODEL *next);
|
||||
void interpolate_lsp(kiss_fft_cfg fft_dec_cfg,
|
||||
MODEL *interp, MODEL *prev, MODEL *next,
|
||||
float *prev_lsps, float prev_e,
|
||||
float *next_lsps, float next_e,
|
||||
float *ak_interp, float *lsps_interp);
|
||||
void interp_Wo(MODEL *interp, MODEL *prev, MODEL *next);
|
||||
float interp_energy(float prev, float next);
|
||||
void interpolate_lsp_ver2(float interp[], float prev[], float next[], float weight);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,408 @@
|
||||
/*
|
||||
Copyright (c) 2003-2010, Mark Borgerding
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "_kiss_fft_guts.h"
|
||||
/* The guts header contains all the multiplication and addition macros that are defined for
|
||||
fixed or floating point complex numbers. It also delares the kf_ internal functions.
|
||||
*/
|
||||
|
||||
static void kf_bfly2(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
int m
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx * Fout2;
|
||||
kiss_fft_cpx * tw1 = st->twiddles;
|
||||
kiss_fft_cpx t;
|
||||
Fout2 = Fout + m;
|
||||
do{
|
||||
C_FIXDIV(*Fout,2); C_FIXDIV(*Fout2,2);
|
||||
|
||||
C_MUL (t, *Fout2 , *tw1);
|
||||
tw1 += fstride;
|
||||
C_SUB( *Fout2 , *Fout , t );
|
||||
C_ADDTO( *Fout , t );
|
||||
++Fout2;
|
||||
++Fout;
|
||||
}while (--m);
|
||||
}
|
||||
|
||||
static void kf_bfly4(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
const size_t m
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx *tw1,*tw2,*tw3;
|
||||
kiss_fft_cpx scratch[6];
|
||||
size_t k=m;
|
||||
const size_t m2=2*m;
|
||||
const size_t m3=3*m;
|
||||
|
||||
|
||||
tw3 = tw2 = tw1 = st->twiddles;
|
||||
|
||||
do {
|
||||
C_FIXDIV(*Fout,4); C_FIXDIV(Fout[m],4); C_FIXDIV(Fout[m2],4); C_FIXDIV(Fout[m3],4);
|
||||
|
||||
C_MUL(scratch[0],Fout[m] , *tw1 );
|
||||
C_MUL(scratch[1],Fout[m2] , *tw2 );
|
||||
C_MUL(scratch[2],Fout[m3] , *tw3 );
|
||||
|
||||
C_SUB( scratch[5] , *Fout, scratch[1] );
|
||||
C_ADDTO(*Fout, scratch[1]);
|
||||
C_ADD( scratch[3] , scratch[0] , scratch[2] );
|
||||
C_SUB( scratch[4] , scratch[0] , scratch[2] );
|
||||
C_SUB( Fout[m2], *Fout, scratch[3] );
|
||||
tw1 += fstride;
|
||||
tw2 += fstride*2;
|
||||
tw3 += fstride*3;
|
||||
C_ADDTO( *Fout , scratch[3] );
|
||||
|
||||
if(st->inverse) {
|
||||
Fout[m].r = scratch[5].r - scratch[4].i;
|
||||
Fout[m].i = scratch[5].i + scratch[4].r;
|
||||
Fout[m3].r = scratch[5].r + scratch[4].i;
|
||||
Fout[m3].i = scratch[5].i - scratch[4].r;
|
||||
}else{
|
||||
Fout[m].r = scratch[5].r + scratch[4].i;
|
||||
Fout[m].i = scratch[5].i - scratch[4].r;
|
||||
Fout[m3].r = scratch[5].r - scratch[4].i;
|
||||
Fout[m3].i = scratch[5].i + scratch[4].r;
|
||||
}
|
||||
++Fout;
|
||||
}while(--k);
|
||||
}
|
||||
|
||||
static void kf_bfly3(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
size_t m
|
||||
)
|
||||
{
|
||||
size_t k=m;
|
||||
const size_t m2 = 2*m;
|
||||
kiss_fft_cpx *tw1,*tw2;
|
||||
kiss_fft_cpx scratch[5];
|
||||
kiss_fft_cpx epi3;
|
||||
epi3 = st->twiddles[fstride*m];
|
||||
|
||||
tw1=tw2=st->twiddles;
|
||||
|
||||
do{
|
||||
C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3);
|
||||
|
||||
C_MUL(scratch[1],Fout[m] , *tw1);
|
||||
C_MUL(scratch[2],Fout[m2] , *tw2);
|
||||
|
||||
C_ADD(scratch[3],scratch[1],scratch[2]);
|
||||
C_SUB(scratch[0],scratch[1],scratch[2]);
|
||||
tw1 += fstride;
|
||||
tw2 += fstride*2;
|
||||
|
||||
Fout[m].r = Fout->r - HALF_OF(scratch[3].r);
|
||||
Fout[m].i = Fout->i - HALF_OF(scratch[3].i);
|
||||
|
||||
C_MULBYSCALAR( scratch[0] , epi3.i );
|
||||
|
||||
C_ADDTO(*Fout,scratch[3]);
|
||||
|
||||
Fout[m2].r = Fout[m].r + scratch[0].i;
|
||||
Fout[m2].i = Fout[m].i - scratch[0].r;
|
||||
|
||||
Fout[m].r -= scratch[0].i;
|
||||
Fout[m].i += scratch[0].r;
|
||||
|
||||
++Fout;
|
||||
}while(--k);
|
||||
}
|
||||
|
||||
static void kf_bfly5(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
int m
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4;
|
||||
int u;
|
||||
kiss_fft_cpx scratch[13];
|
||||
kiss_fft_cpx * twiddles = st->twiddles;
|
||||
kiss_fft_cpx *tw;
|
||||
kiss_fft_cpx ya,yb;
|
||||
ya = twiddles[fstride*m];
|
||||
yb = twiddles[fstride*2*m];
|
||||
|
||||
Fout0=Fout;
|
||||
Fout1=Fout0+m;
|
||||
Fout2=Fout0+2*m;
|
||||
Fout3=Fout0+3*m;
|
||||
Fout4=Fout0+4*m;
|
||||
|
||||
tw=st->twiddles;
|
||||
for ( u=0; u<m; ++u ) {
|
||||
C_FIXDIV( *Fout0,5); C_FIXDIV( *Fout1,5); C_FIXDIV( *Fout2,5); C_FIXDIV( *Fout3,5); C_FIXDIV( *Fout4,5);
|
||||
scratch[0] = *Fout0;
|
||||
|
||||
C_MUL(scratch[1] ,*Fout1, tw[u*fstride]);
|
||||
C_MUL(scratch[2] ,*Fout2, tw[2*u*fstride]);
|
||||
C_MUL(scratch[3] ,*Fout3, tw[3*u*fstride]);
|
||||
C_MUL(scratch[4] ,*Fout4, tw[4*u*fstride]);
|
||||
|
||||
C_ADD( scratch[7],scratch[1],scratch[4]);
|
||||
C_SUB( scratch[10],scratch[1],scratch[4]);
|
||||
C_ADD( scratch[8],scratch[2],scratch[3]);
|
||||
C_SUB( scratch[9],scratch[2],scratch[3]);
|
||||
|
||||
Fout0->r += scratch[7].r + scratch[8].r;
|
||||
Fout0->i += scratch[7].i + scratch[8].i;
|
||||
|
||||
scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r);
|
||||
scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r);
|
||||
|
||||
scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i);
|
||||
scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i);
|
||||
|
||||
C_SUB(*Fout1,scratch[5],scratch[6]);
|
||||
C_ADD(*Fout4,scratch[5],scratch[6]);
|
||||
|
||||
scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r);
|
||||
scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r);
|
||||
scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i);
|
||||
scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i);
|
||||
|
||||
C_ADD(*Fout2,scratch[11],scratch[12]);
|
||||
C_SUB(*Fout3,scratch[11],scratch[12]);
|
||||
|
||||
++Fout0;++Fout1;++Fout2;++Fout3;++Fout4;
|
||||
}
|
||||
}
|
||||
|
||||
/* perform the butterfly for one stage of a mixed radix FFT */
|
||||
static void kf_bfly_generic(
|
||||
kiss_fft_cpx * Fout,
|
||||
const size_t fstride,
|
||||
const kiss_fft_cfg st,
|
||||
int m,
|
||||
int p
|
||||
)
|
||||
{
|
||||
int u,k,q1,q;
|
||||
kiss_fft_cpx * twiddles = st->twiddles;
|
||||
kiss_fft_cpx t;
|
||||
int Norig = st->nfft;
|
||||
|
||||
kiss_fft_cpx * scratch = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC(sizeof(kiss_fft_cpx)*p);
|
||||
|
||||
for ( u=0; u<m; ++u ) {
|
||||
k=u;
|
||||
for ( q1=0 ; q1<p ; ++q1 ) {
|
||||
scratch[q1] = Fout[ k ];
|
||||
C_FIXDIV(scratch[q1],p);
|
||||
k += m;
|
||||
}
|
||||
|
||||
k=u;
|
||||
for ( q1=0 ; q1<p ; ++q1 ) {
|
||||
int twidx=0;
|
||||
Fout[ k ] = scratch[0];
|
||||
for (q=1;q<p;++q ) {
|
||||
twidx += fstride * k;
|
||||
if (twidx>=Norig) twidx-=Norig;
|
||||
C_MUL(t,scratch[q] , twiddles[twidx] );
|
||||
C_ADDTO( Fout[ k ] ,t);
|
||||
}
|
||||
k += m;
|
||||
}
|
||||
}
|
||||
KISS_FFT_TMP_FREE(scratch);
|
||||
}
|
||||
|
||||
static
|
||||
void kf_work(
|
||||
kiss_fft_cpx * Fout,
|
||||
const kiss_fft_cpx * f,
|
||||
const size_t fstride,
|
||||
int in_stride,
|
||||
int * factors,
|
||||
const kiss_fft_cfg st
|
||||
)
|
||||
{
|
||||
kiss_fft_cpx * Fout_beg=Fout;
|
||||
const int p=*factors++; /* the radix */
|
||||
const int m=*factors++; /* stage's fft length/p */
|
||||
const kiss_fft_cpx * Fout_end = Fout + p*m;
|
||||
|
||||
#ifdef _OPENMP
|
||||
// use openmp extensions at the
|
||||
// top-level (not recursive)
|
||||
if (fstride==1 && p<=5)
|
||||
{
|
||||
int k;
|
||||
|
||||
// execute the p different work units in different threads
|
||||
# pragma omp parallel for
|
||||
for (k=0;k<p;++k)
|
||||
kf_work( Fout +k*m, f+ fstride*in_stride*k,fstride*p,in_stride,factors,st);
|
||||
// all threads have joined by this point
|
||||
|
||||
switch (p) {
|
||||
case 2: kf_bfly2(Fout,fstride,st,m); break;
|
||||
case 3: kf_bfly3(Fout,fstride,st,m); break;
|
||||
case 4: kf_bfly4(Fout,fstride,st,m); break;
|
||||
case 5: kf_bfly5(Fout,fstride,st,m); break;
|
||||
default: kf_bfly_generic(Fout,fstride,st,m,p); break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m==1) {
|
||||
do{
|
||||
*Fout = *f;
|
||||
f += fstride*in_stride;
|
||||
}while(++Fout != Fout_end );
|
||||
}else{
|
||||
do{
|
||||
// recursive call:
|
||||
// DFT of size m*p performed by doing
|
||||
// p instances of smaller DFTs of size m,
|
||||
// each one takes a decimated version of the input
|
||||
kf_work( Fout , f, fstride*p, in_stride, factors,st);
|
||||
f += fstride*in_stride;
|
||||
}while( (Fout += m) != Fout_end );
|
||||
}
|
||||
|
||||
Fout=Fout_beg;
|
||||
|
||||
// recombine the p smaller DFTs
|
||||
switch (p) {
|
||||
case 2: kf_bfly2(Fout,fstride,st,m); break;
|
||||
case 3: kf_bfly3(Fout,fstride,st,m); break;
|
||||
case 4: kf_bfly4(Fout,fstride,st,m); break;
|
||||
case 5: kf_bfly5(Fout,fstride,st,m); break;
|
||||
default: kf_bfly_generic(Fout,fstride,st,m,p); break;
|
||||
}
|
||||
}
|
||||
|
||||
/* facbuf is populated by p1,m1,p2,m2, ...
|
||||
where
|
||||
p[i] * m[i] = m[i-1]
|
||||
m0 = n */
|
||||
static
|
||||
void kf_factor(int n,int * facbuf)
|
||||
{
|
||||
int p=4;
|
||||
double floor_sqrt;
|
||||
floor_sqrt = floor( sqrt((double)n) );
|
||||
|
||||
/*factor out powers of 4, powers of 2, then any remaining primes */
|
||||
do {
|
||||
while (n % p) {
|
||||
switch (p) {
|
||||
case 4: p = 2; break;
|
||||
case 2: p = 3; break;
|
||||
default: p += 2; break;
|
||||
}
|
||||
if (p > floor_sqrt)
|
||||
p = n; /* no more factors, skip to end */
|
||||
}
|
||||
n /= p;
|
||||
*facbuf++ = p;
|
||||
*facbuf++ = n;
|
||||
} while (n > 1);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* User-callable function to allocate all necessary storage space for the fft.
|
||||
*
|
||||
* The return value is a contiguous block of memory, allocated with malloc. As such,
|
||||
* It can be freed with free(), rather than a kiss_fft-specific function.
|
||||
* */
|
||||
kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem )
|
||||
{
|
||||
kiss_fft_cfg st=NULL;
|
||||
size_t memneeded = sizeof(struct kiss_fft_state)
|
||||
+ sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/
|
||||
|
||||
if ( lenmem==NULL ) {
|
||||
st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded );
|
||||
}else{
|
||||
if (mem != NULL && *lenmem >= memneeded)
|
||||
st = (kiss_fft_cfg)mem;
|
||||
*lenmem = memneeded;
|
||||
}
|
||||
if (st) {
|
||||
int i;
|
||||
st->nfft=nfft;
|
||||
st->inverse = inverse_fft;
|
||||
|
||||
for (i=0;i<nfft;++i) {
|
||||
const double pi=3.141592653589793238462643383279502884197169399375105820974944;
|
||||
double phase = -2*pi*i / nfft;
|
||||
if (st->inverse)
|
||||
phase *= -1;
|
||||
kf_cexp(st->twiddles+i, phase );
|
||||
}
|
||||
|
||||
kf_factor(nfft,st->factors);
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
void kiss_fft_stride(kiss_fft_cfg st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int in_stride)
|
||||
{
|
||||
if (fin == fout) {
|
||||
//NOTE: this is not really an in-place FFT algorithm.
|
||||
//It just performs an out-of-place FFT into a temp buffer
|
||||
kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft);
|
||||
kf_work(tmpbuf,fin,1,in_stride, st->factors,st);
|
||||
memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft);
|
||||
KISS_FFT_TMP_FREE(tmpbuf);
|
||||
}else{
|
||||
kf_work( fout, fin, 1,in_stride, st->factors,st );
|
||||
}
|
||||
}
|
||||
|
||||
void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout)
|
||||
{
|
||||
kiss_fft_stride(cfg,fin,fout,1);
|
||||
}
|
||||
|
||||
|
||||
void kiss_fft_cleanup(void)
|
||||
{
|
||||
// nothing needed any more
|
||||
}
|
||||
|
||||
int kiss_fft_next_fast_size(int n)
|
||||
{
|
||||
while(1) {
|
||||
int m=n;
|
||||
while ( (m%2) == 0 ) m/=2;
|
||||
while ( (m%3) == 0 ) m/=3;
|
||||
while ( (m%5) == 0 ) m/=5;
|
||||
if (m<=1)
|
||||
break; /* n is completely factorable by twos, threes, and fives */
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
#ifndef KISS_FFT_H
|
||||
#define KISS_FFT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
ATTENTION!
|
||||
If you would like a :
|
||||
-- a utility that will handle the caching of fft objects
|
||||
-- real-only (no imaginary time component ) FFT
|
||||
-- a multi-dimensional FFT
|
||||
-- a command-line utility to perform ffts
|
||||
-- a command-line utility to perform fast-convolution filtering
|
||||
|
||||
Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
|
||||
in the tools/ directory.
|
||||
*/
|
||||
|
||||
#ifdef USE_SIMD
|
||||
# include <xmmintrin.h>
|
||||
# define kiss_fft_scalar __m128
|
||||
#define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16)
|
||||
#define KISS_FFT_FREE _mm_free
|
||||
#else
|
||||
#define KISS_FFT_MALLOC malloc
|
||||
#define KISS_FFT_FREE free
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FIXED_POINT
|
||||
#include <sys/types.h>
|
||||
# if (FIXED_POINT == 32)
|
||||
# define kiss_fft_scalar int32_t
|
||||
# else
|
||||
# define kiss_fft_scalar int16_t
|
||||
# endif
|
||||
#else
|
||||
# ifndef kiss_fft_scalar
|
||||
/* default is float */
|
||||
# define kiss_fft_scalar float
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
kiss_fft_scalar r;
|
||||
kiss_fft_scalar i;
|
||||
}kiss_fft_cpx;
|
||||
|
||||
typedef struct kiss_fft_state* kiss_fft_cfg;
|
||||
|
||||
/*
|
||||
* kiss_fft_alloc
|
||||
*
|
||||
* Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
|
||||
*
|
||||
* typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
|
||||
*
|
||||
* The return value from fft_alloc is a cfg buffer used internally
|
||||
* by the fft routine or NULL.
|
||||
*
|
||||
* If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
|
||||
* The returned value should be free()d when done to avoid memory leaks.
|
||||
*
|
||||
* The state can be placed in a user supplied buffer 'mem':
|
||||
* If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
|
||||
* then the function places the cfg in mem and the size used in *lenmem
|
||||
* and returns mem.
|
||||
*
|
||||
* If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
|
||||
* then the function returns NULL and places the minimum cfg
|
||||
* buffer size in *lenmem.
|
||||
* */
|
||||
|
||||
kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
|
||||
|
||||
/*
|
||||
* kiss_fft(cfg,in_out_buf)
|
||||
*
|
||||
* Perform an FFT on a complex input buffer.
|
||||
* for a forward FFT,
|
||||
* fin should be f[0] , f[1] , ... ,f[nfft-1]
|
||||
* fout will be F[0] , F[1] , ... ,F[nfft-1]
|
||||
* Note that each element is complex and can be accessed like
|
||||
f[k].r and f[k].i
|
||||
* */
|
||||
void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
|
||||
|
||||
/*
|
||||
A more generic version of the above function. It reads its input from every Nth sample.
|
||||
* */
|
||||
void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
|
||||
|
||||
/* If kiss_fft_alloc allocated a buffer, it is one contiguous
|
||||
buffer and can be simply free()d when no longer needed*/
|
||||
#define kiss_fft_free free
|
||||
|
||||
/*
|
||||
Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
|
||||
your compiler output to call this before you exit.
|
||||
*/
|
||||
void kiss_fft_cleanup(void);
|
||||
|
||||
|
||||
/*
|
||||
* Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
|
||||
*/
|
||||
int kiss_fft_next_fast_size(int n);
|
||||
|
||||
/* for real ffts, we need an even size */
|
||||
#define kiss_fftr_next_fast_size_real(n) \
|
||||
(kiss_fft_next_fast_size( ((n)+1)>>1)<<1)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -4,6 +4,6 @@
|
||||
#
|
||||
# Listen to files processed with sim.sh
|
||||
|
||||
../script/menu.sh ../raw/$1.raw $1_uq.raw $1_phase0.raw $1_lpc10.raw $1_lsp.raw $1_phase0_lpc10.raw $1_phase0_lsp.raw $1_phase0_lsp_dec.raw $2 $3
|
||||
../script/menu.sh $1_uq.raw $1_lpc10.raw $1_lpcpf.raw $1_phase0.raw $1_phase0_lpcpf.raw $2 $3 $4 $5
|
||||
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
FILE........: lpc.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 30/9/90
|
||||
DATE CREATED: 30 Sep 1990 (!)
|
||||
|
||||
Linear Prediction functions written in C.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
Copyright (C) 2009-2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -22,18 +22,74 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define LPC_MAX_N 512 /* maximum no. of samples in frame */
|
||||
#define PI 3.141592654 /* mathematical constant */
|
||||
|
||||
#define ALPHA 1.0
|
||||
#define BETA 0.94
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "defines.h"
|
||||
#include "lpc.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
pre_emp()
|
||||
|
||||
Pre-emphasise (high pass filter with zero close to 0 Hz) a frame of
|
||||
speech samples. Helps reduce dynamic range of LPC spectrum, giving
|
||||
greater weight and hensea better match to low energy formants.
|
||||
|
||||
Should be balanced by de-emphasis of the output speech.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void pre_emp(
|
||||
float Sn_pre[], /* output frame of speech samples */
|
||||
float Sn[], /* input frame of speech samples */
|
||||
float *mem, /* Sn[-1]single sample memory */
|
||||
int Nsam /* number of speech samples to use */
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<Nsam; i++) {
|
||||
Sn_pre[i] = Sn[i] - ALPHA * mem[0];
|
||||
mem[0] = Sn[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
de_emp()
|
||||
|
||||
De-emphasis filter (low pass filter with polse close to 0 Hz).
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void de_emp(
|
||||
float Sn_de[], /* output frame of speech samples */
|
||||
float Sn[], /* input frame of speech samples */
|
||||
float *mem, /* Sn[-1]single sample memory */
|
||||
int Nsam /* number of speech samples to use */
|
||||
)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<Nsam; i++) {
|
||||
Sn_de[i] = Sn[i] + BETA * mem[0];
|
||||
mem[0] = Sn_de[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
hanning_window()
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
Copyright (C) 2009-2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __LPC__
|
||||
@@ -31,6 +30,8 @@
|
||||
|
||||
#define LPC_MAX_ORDER 20
|
||||
|
||||
void pre_emp(float Sn_pre[], float Sn[], float *mem, int Nsam);
|
||||
void de_emp(float Sn_se[], float Sn[], float *mem, int Nsam);
|
||||
void hanning_window(float Sn[], float Wn[], int Nsam);
|
||||
void autocorrelate(float Sn[], float Rn[], int Nsam, int order);
|
||||
void levinson_durbin(float R[], float lpcs[], int order);
|
||||
|
||||
+325
-323
@@ -1,323 +1,325 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: lsp.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
|
||||
This file contains functions for LPC to LSP conversion and LSP to
|
||||
LPC conversion. Note that the LSP coefficients are not in radians
|
||||
format but in the x domain of the unit circle.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "lsp.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
Introduction to Line Spectrum Pairs (LSPs)
|
||||
------------------------------------------
|
||||
|
||||
LSPs are used to encode the LPC filter coefficients {ak} for
|
||||
transmission over the channel. LSPs have several properties (like
|
||||
less sensitivity to quantisation noise) that make them superior to
|
||||
direct quantisation of {ak}.
|
||||
|
||||
A(z) is a polynomial of order lpcrdr with {ak} as the coefficients.
|
||||
|
||||
A(z) is transformed to P(z) and Q(z) (using a substitution and some
|
||||
algebra), to obtain something like:
|
||||
|
||||
A(z) = 0.5[P(z)(z+z^-1) + Q(z)(z-z^-1)] (1)
|
||||
|
||||
As you can imagine A(z) has complex zeros all over the z-plane. P(z)
|
||||
and Q(z) have the very neat property of only having zeros _on_ the
|
||||
unit circle. So to find them we take a test point z=exp(jw) and
|
||||
evaluate P (exp(jw)) and Q(exp(jw)) using a grid of points between 0
|
||||
and pi.
|
||||
|
||||
The zeros (roots) of P(z) also happen to alternate, which is why we
|
||||
swap coefficients as we find roots. So the process of finding the
|
||||
LSP frequencies is basically finding the roots of 5th order
|
||||
polynomials.
|
||||
|
||||
The root so P(z) and Q(z) occur in symmetrical pairs at +/-w, hence
|
||||
the name Line Spectrum Pairs (LSPs).
|
||||
|
||||
To convert back to ak we just evaluate (1), "clocking" an impulse
|
||||
thru it lpcrdr times gives us the impulse response of A(z) which is
|
||||
{ak}.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: cheb_poly_eva()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function evalutes a series of chebyshev polynomials
|
||||
|
||||
FIXME: performing memory allocation at run time is very inefficient,
|
||||
replace with stack variables of MAX_P size.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
float cheb_poly_eva(float *coef,float x,int m)
|
||||
/* float coef[] coefficients of the polynomial to be evaluated */
|
||||
/* float x the point where polynomial is to be evaluated */
|
||||
/* int m order of the polynomial */
|
||||
{
|
||||
int i;
|
||||
float *T,*t,*u,*v,sum;
|
||||
|
||||
/* Allocate memory for chebyshev series formulation */
|
||||
|
||||
if((T = (float *)malloc((m/2+1)*sizeof(float))) == NULL){
|
||||
fprintf(stderr, "not enough memory to allocate buffer\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Initialise pointers */
|
||||
|
||||
t = T; /* T[i-2] */
|
||||
*t++ = 1.0;
|
||||
u = t--; /* T[i-1] */
|
||||
*u++ = x;
|
||||
v = u--; /* T[i] */
|
||||
|
||||
/* Evaluate chebyshev series formulation using iterative approach */
|
||||
|
||||
for(i=2;i<=m/2;i++)
|
||||
*v++ = (2*x)*(*u++) - *t++; /* T[i] = 2*x*T[i-1] - T[i-2] */
|
||||
|
||||
sum=0.0; /* initialise sum to zero */
|
||||
t = T; /* reset pointer */
|
||||
|
||||
/* Evaluate polynomial and return value also free memory space */
|
||||
|
||||
for(i=0;i<=m/2;i++)
|
||||
sum+=coef[(m/2)-i]**t++;
|
||||
|
||||
free(T);
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: lpc_to_lsp()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function converts LPC coefficients to LSP coefficients.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta)
|
||||
/* float *a lpc coefficients */
|
||||
/* int lpcrdr order of LPC coefficients (10) */
|
||||
/* float *freq LSP frequencies in radians */
|
||||
/* int nb number of sub-intervals (4) */
|
||||
/* float delta grid spacing interval (0.02) */
|
||||
{
|
||||
float psuml,psumr,psumm,temp_xr,xl,xr,xm;
|
||||
float temp_psumr;
|
||||
int i,j,m,flag,k;
|
||||
float *Q; /* ptrs for memory allocation */
|
||||
float *P;
|
||||
float *px; /* ptrs of respective P'(z) & Q'(z) */
|
||||
float *qx;
|
||||
float *p;
|
||||
float *q;
|
||||
float *pt; /* ptr used for cheb_poly_eval()
|
||||
whether P' or Q' */
|
||||
int roots=0; /* number of roots found */
|
||||
flag = 1;
|
||||
m = lpcrdr/2; /* order of P'(z) & Q'(z) polynimials */
|
||||
|
||||
/* Allocate memory space for polynomials */
|
||||
|
||||
Q = (float *) malloc((m+1)*sizeof(float));
|
||||
P = (float *) malloc((m+1)*sizeof(float));
|
||||
if( (P == NULL) || (Q == NULL) ) {
|
||||
fprintf(stderr,"not enough memory to allocate buffer\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* determine P'(z)'s and Q'(z)'s coefficients where
|
||||
P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */
|
||||
|
||||
px = P; /* initilaise ptrs */
|
||||
qx = Q;
|
||||
p = px;
|
||||
q = qx;
|
||||
*px++ = 1.0;
|
||||
*qx++ = 1.0;
|
||||
for(i=1;i<=m;i++){
|
||||
*px++ = a[i]+a[lpcrdr+1-i]-*p++;
|
||||
*qx++ = a[i]-a[lpcrdr+1-i]+*q++;
|
||||
}
|
||||
px = P;
|
||||
qx = Q;
|
||||
for(i=0;i<m;i++){
|
||||
*px = 2**px;
|
||||
*qx = 2**qx;
|
||||
px++;
|
||||
qx++;
|
||||
}
|
||||
px = P; /* re-initialise ptrs */
|
||||
qx = Q;
|
||||
|
||||
/* Search for a zero in P'(z) polynomial first and then alternate to Q'(z).
|
||||
Keep alternating between the two polynomials as each zero is found */
|
||||
|
||||
xr = 0; /* initialise xr to zero */
|
||||
xl = 1.0; /* start at point xl = 1 */
|
||||
|
||||
|
||||
for(j=0;j<lpcrdr;j++){
|
||||
if(j%2) /* determines whether P' or Q' is eval. */
|
||||
pt = qx;
|
||||
else
|
||||
pt = px;
|
||||
|
||||
psuml = cheb_poly_eva(pt,xl,lpcrdr); /* evals poly. at xl */
|
||||
flag = 1;
|
||||
while(flag && (xr >= -1.0)){
|
||||
xr = xl - delta ; /* interval spacing */
|
||||
psumr = cheb_poly_eva(pt,xr,lpcrdr);/* poly(xl-delta_x) */
|
||||
temp_psumr = psumr;
|
||||
temp_xr = xr;
|
||||
|
||||
/* if no sign change increment xr and re-evaluate
|
||||
poly(xr). Repeat til sign change. if a sign change has
|
||||
occurred the interval is bisected and then checked again
|
||||
for a sign change which determines in which interval the
|
||||
zero lies in. If there is no sign change between poly(xm)
|
||||
and poly(xl) set interval between xm and xr else set
|
||||
interval between xl and xr and repeat till root is located
|
||||
within the specified limits */
|
||||
|
||||
if((psumr*psuml)<0.0){
|
||||
roots++;
|
||||
|
||||
psumm=psuml;
|
||||
for(k=0;k<=nb;k++){
|
||||
xm = (xl+xr)/2; /* bisect the interval */
|
||||
psumm=cheb_poly_eva(pt,xm,lpcrdr);
|
||||
if(psumm*psuml>0.){
|
||||
psuml=psumm;
|
||||
xl=xm;
|
||||
}
|
||||
else{
|
||||
psumr=psumm;
|
||||
xr=xm;
|
||||
}
|
||||
}
|
||||
|
||||
/* once zero is found, reset initial interval to xr */
|
||||
freq[j] = (xm);
|
||||
xl = xm;
|
||||
flag = 0; /* reset flag for next search */
|
||||
}
|
||||
else{
|
||||
psuml=temp_psumr;
|
||||
xl=temp_xr;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(P); /* free memory space */
|
||||
free(Q);
|
||||
|
||||
/* convert from x domain to radians */
|
||||
|
||||
for(i=0; i<lpcrdr; i++) {
|
||||
freq[i] = acos(freq[i]);
|
||||
}
|
||||
|
||||
return(roots);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: lsp_to_lpc()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function converts LSP coefficients to LPC coefficients. In the
|
||||
Speex code we worked out a wayto simplify this significantly.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void lsp_to_lpc(float *freq, float *ak, int lpcrdr)
|
||||
/* float *freq array of LSP frequencies in radians */
|
||||
/* float *ak array of LPC coefficients */
|
||||
/* int lpcrdr order of LPC coefficients */
|
||||
|
||||
|
||||
{
|
||||
int i,j;
|
||||
float xout1,xout2,xin1,xin2;
|
||||
float *Wp;
|
||||
float *pw,*n1,*n2,*n3,*n4;
|
||||
int m = lpcrdr/2;
|
||||
|
||||
/* convert from radians to the x=cos(w) domain */
|
||||
|
||||
for(i=0; i<lpcrdr; i++)
|
||||
freq[i] = cos(freq[i]);
|
||||
|
||||
if((Wp = (float *) malloc((4*m+2)*sizeof(float))) == NULL){
|
||||
printf("not enough memory to allocate buffer\n");
|
||||
exit(1);
|
||||
}
|
||||
pw = Wp;
|
||||
|
||||
/* initialise contents of array */
|
||||
|
||||
for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */
|
||||
*pw++ = 0.0;
|
||||
}
|
||||
|
||||
/* Set pointers up */
|
||||
|
||||
pw = Wp;
|
||||
xin1 = 1.0;
|
||||
xin2 = 1.0;
|
||||
|
||||
/* reconstruct P(z) and Q(z) by cascading second order polynomials
|
||||
in form 1 - 2xz(-1) +z(-2), where x is the LSP coefficient */
|
||||
|
||||
for(j=0;j<=lpcrdr;j++){
|
||||
for(i=0;i<m;i++){
|
||||
n1 = pw+(i*4);
|
||||
n2 = n1 + 1;
|
||||
n3 = n2 + 1;
|
||||
n4 = n3 + 1;
|
||||
xout1 = xin1 - 2*(freq[2*i]) * *n1 + *n2;
|
||||
xout2 = xin2 - 2*(freq[2*i+1]) * *n3 + *n4;
|
||||
*n2 = *n1;
|
||||
*n4 = *n3;
|
||||
*n1 = xin1;
|
||||
*n3 = xin2;
|
||||
xin1 = xout1;
|
||||
xin2 = xout2;
|
||||
}
|
||||
xout1 = xin1 + *(n4+1);
|
||||
xout2 = xin2 - *(n4+2);
|
||||
ak[j] = (xout1 + xout2)*0.5;
|
||||
*(n4+1) = xin1;
|
||||
*(n4+2) = xin2;
|
||||
|
||||
xin1 = 0.0;
|
||||
xin2 = 0.0;
|
||||
}
|
||||
free(Wp);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: lsp.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
|
||||
This file contains functions for LPC to LSP conversion and LSP to
|
||||
LPC conversion. Note that the LSP coefficients are not in radians
|
||||
format but in the x domain of the unit circle.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "lsp.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Only 10 gets used, so far. */
|
||||
#define LSP_MAX_ORDER 20
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
Introduction to Line Spectrum Pairs (LSPs)
|
||||
------------------------------------------
|
||||
|
||||
LSPs are used to encode the LPC filter coefficients {ak} for
|
||||
transmission over the channel. LSPs have several properties (like
|
||||
less sensitivity to quantisation noise) that make them superior to
|
||||
direct quantisation of {ak}.
|
||||
|
||||
A(z) is a polynomial of order lpcrdr with {ak} as the coefficients.
|
||||
|
||||
A(z) is transformed to P(z) and Q(z) (using a substitution and some
|
||||
algebra), to obtain something like:
|
||||
|
||||
A(z) = 0.5[P(z)(z+z^-1) + Q(z)(z-z^-1)] (1)
|
||||
|
||||
As you can imagine A(z) has complex zeros all over the z-plane. P(z)
|
||||
and Q(z) have the very neat property of only having zeros _on_ the
|
||||
unit circle. So to find them we take a test point z=exp(jw) and
|
||||
evaluate P (exp(jw)) and Q(exp(jw)) using a grid of points between 0
|
||||
and pi.
|
||||
|
||||
The zeros (roots) of P(z) also happen to alternate, which is why we
|
||||
swap coefficients as we find roots. So the process of finding the
|
||||
LSP frequencies is basically finding the roots of 5th order
|
||||
polynomials.
|
||||
|
||||
The root so P(z) and Q(z) occur in symmetrical pairs at +/-w, hence
|
||||
the name Line Spectrum Pairs (LSPs).
|
||||
|
||||
To convert back to ak we just evaluate (1), "clocking" an impulse
|
||||
thru it lpcrdr times gives us the impulse response of A(z) which is
|
||||
{ak}.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: cheb_poly_eva()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function evalutes a series of chebyshev polynomials
|
||||
|
||||
FIXME: performing memory allocation at run time is very inefficient,
|
||||
replace with stack variables of MAX_P size.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
static float
|
||||
cheb_poly_eva(float *coef,float x,int m)
|
||||
/* float coef[] coefficients of the polynomial to be evaluated */
|
||||
/* float x the point where polynomial is to be evaluated */
|
||||
/* int m order of the polynomial */
|
||||
{
|
||||
int i;
|
||||
float *t,*u,*v,sum;
|
||||
float T[(LSP_MAX_ORDER / 2) + 1];
|
||||
|
||||
/* Initialise pointers */
|
||||
|
||||
t = T; /* T[i-2] */
|
||||
*t++ = 1.0;
|
||||
u = t--; /* T[i-1] */
|
||||
*u++ = x;
|
||||
v = u--; /* T[i] */
|
||||
|
||||
/* Evaluate chebyshev series formulation using iterative approach */
|
||||
|
||||
for(i=2;i<=m/2;i++)
|
||||
*v++ = (2*x)*(*u++) - *t++; /* T[i] = 2*x*T[i-1] - T[i-2] */
|
||||
|
||||
sum=0.0; /* initialise sum to zero */
|
||||
t = T; /* reset pointer */
|
||||
|
||||
/* Evaluate polynomial and return value also free memory space */
|
||||
|
||||
for(i=0;i<=m/2;i++)
|
||||
sum+=coef[(m/2)-i]**t++;
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: lpc_to_lsp()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function converts LPC coefficients to LSP coefficients.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta)
|
||||
/* float *a lpc coefficients */
|
||||
/* int lpcrdr order of LPC coefficients (10) */
|
||||
/* float *freq LSP frequencies in radians */
|
||||
/* int nb number of sub-intervals (4) */
|
||||
/* float delta grid spacing interval (0.02) */
|
||||
{
|
||||
float psuml,psumr,psumm,temp_xr,xl,xr,xm = 0;
|
||||
float temp_psumr;
|
||||
int i,j,m,flag,k;
|
||||
float *px; /* ptrs of respective P'(z) & Q'(z) */
|
||||
float *qx;
|
||||
float *p;
|
||||
float *q;
|
||||
float *pt; /* ptr used for cheb_poly_eval()
|
||||
whether P' or Q' */
|
||||
int roots=0; /* number of roots found */
|
||||
float Q[LSP_MAX_ORDER + 1];
|
||||
float P[LSP_MAX_ORDER + 1];
|
||||
|
||||
flag = 1;
|
||||
m = lpcrdr/2; /* order of P'(z) & Q'(z) polynimials */
|
||||
|
||||
/* Allocate memory space for polynomials */
|
||||
|
||||
/* determine P'(z)'s and Q'(z)'s coefficients where
|
||||
P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */
|
||||
|
||||
px = P; /* initilaise ptrs */
|
||||
qx = Q;
|
||||
p = px;
|
||||
q = qx;
|
||||
*px++ = 1.0;
|
||||
*qx++ = 1.0;
|
||||
for(i=1;i<=m;i++){
|
||||
*px++ = a[i]+a[lpcrdr+1-i]-*p++;
|
||||
*qx++ = a[i]-a[lpcrdr+1-i]+*q++;
|
||||
}
|
||||
px = P;
|
||||
qx = Q;
|
||||
for(i=0;i<m;i++){
|
||||
*px = 2**px;
|
||||
*qx = 2**qx;
|
||||
px++;
|
||||
qx++;
|
||||
}
|
||||
px = P; /* re-initialise ptrs */
|
||||
qx = Q;
|
||||
|
||||
/* Search for a zero in P'(z) polynomial first and then alternate to Q'(z).
|
||||
Keep alternating between the two polynomials as each zero is found */
|
||||
|
||||
xr = 0; /* initialise xr to zero */
|
||||
xl = 1.0; /* start at point xl = 1 */
|
||||
|
||||
|
||||
for(j=0;j<lpcrdr;j++){
|
||||
if(j%2) /* determines whether P' or Q' is eval. */
|
||||
pt = qx;
|
||||
else
|
||||
pt = px;
|
||||
|
||||
psuml = cheb_poly_eva(pt,xl,lpcrdr); /* evals poly. at xl */
|
||||
flag = 1;
|
||||
while(flag && (xr >= -1.0)){
|
||||
xr = xl - delta ; /* interval spacing */
|
||||
psumr = cheb_poly_eva(pt,xr,lpcrdr);/* poly(xl-delta_x) */
|
||||
temp_psumr = psumr;
|
||||
temp_xr = xr;
|
||||
|
||||
/* if no sign change increment xr and re-evaluate
|
||||
poly(xr). Repeat til sign change. if a sign change has
|
||||
occurred the interval is bisected and then checked again
|
||||
for a sign change which determines in which interval the
|
||||
zero lies in. If there is no sign change between poly(xm)
|
||||
and poly(xl) set interval between xm and xr else set
|
||||
interval between xl and xr and repeat till root is located
|
||||
within the specified limits */
|
||||
|
||||
if((psumr*psuml)<0.0){
|
||||
roots++;
|
||||
|
||||
psumm=psuml;
|
||||
for(k=0;k<=nb;k++){
|
||||
xm = (xl+xr)/2; /* bisect the interval */
|
||||
psumm=cheb_poly_eva(pt,xm,lpcrdr);
|
||||
if(psumm*psuml>0.){
|
||||
psuml=psumm;
|
||||
xl=xm;
|
||||
}
|
||||
else{
|
||||
psumr=psumm;
|
||||
xr=xm;
|
||||
}
|
||||
}
|
||||
|
||||
/* once zero is found, reset initial interval to xr */
|
||||
freq[j] = (xm);
|
||||
xl = xm;
|
||||
flag = 0; /* reset flag for next search */
|
||||
}
|
||||
else{
|
||||
psuml=temp_psumr;
|
||||
xl=temp_xr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* convert from x domain to radians */
|
||||
|
||||
for(i=0; i<lpcrdr; i++) {
|
||||
freq[i] = acos(freq[i]);
|
||||
}
|
||||
|
||||
return(roots);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: lsp_to_lpc()
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 24/2/93
|
||||
|
||||
This function converts LSP coefficients to LPC coefficients. In the
|
||||
Speex code we worked out a way to simplify this significantly.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void lsp_to_lpc(float *lsp, float *ak, int lpcrdr)
|
||||
/* float *freq array of LSP frequencies in radians */
|
||||
/* float *ak array of LPC coefficients */
|
||||
/* int lpcrdr order of LPC coefficients */
|
||||
|
||||
|
||||
{
|
||||
int i,j;
|
||||
float xout1,xout2,xin1,xin2;
|
||||
float *pw,*n1,*n2,*n3,*n4 = 0;
|
||||
int m = lpcrdr/2;
|
||||
float freq[LSP_MAX_ORDER];
|
||||
float Wp[(LSP_MAX_ORDER * 4) + 2];
|
||||
|
||||
/* convert from radians to the x=cos(w) domain */
|
||||
|
||||
for(i=0; i<lpcrdr; i++)
|
||||
freq[i] = cos(lsp[i]);
|
||||
|
||||
pw = Wp;
|
||||
|
||||
/* initialise contents of array */
|
||||
|
||||
for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */
|
||||
*pw++ = 0.0;
|
||||
}
|
||||
|
||||
/* Set pointers up */
|
||||
|
||||
pw = Wp;
|
||||
xin1 = 1.0;
|
||||
xin2 = 1.0;
|
||||
|
||||
/* reconstruct P(z) and Q(z) by cascading second order polynomials
|
||||
in form 1 - 2xz(-1) +z(-2), where x is the LSP coefficient */
|
||||
|
||||
for(j=0;j<=lpcrdr;j++){
|
||||
for(i=0;i<m;i++){
|
||||
n1 = pw+(i*4);
|
||||
n2 = n1 + 1;
|
||||
n3 = n2 + 1;
|
||||
n4 = n3 + 1;
|
||||
xout1 = xin1 - 2*(freq[2*i]) * *n1 + *n2;
|
||||
xout2 = xin2 - 2*(freq[2*i+1]) * *n3 + *n4;
|
||||
*n2 = *n1;
|
||||
*n4 = *n3;
|
||||
*n1 = xin1;
|
||||
*n3 = xin2;
|
||||
xin1 = xout1;
|
||||
xin2 = xout2;
|
||||
}
|
||||
xout1 = xin1 + *(n4+1);
|
||||
xout2 = xin2 - *(n4+2);
|
||||
ak[j] = (xout1 + xout2)*0.5;
|
||||
*(n4+1) = xin1;
|
||||
*(n4+2) = xin2;
|
||||
|
||||
xin1 = 0.0;
|
||||
xin2 = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,23 @@
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __LSP__
|
||||
#define __LSP__
|
||||
|
||||
|
||||
+210
-28
@@ -4,8 +4,8 @@
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 23/3/93
|
||||
|
||||
Non Linear Pitch (NLP) estimation functions.
|
||||
|
||||
Non Linear Pitch (NLP) estimation functions.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
@@ -22,14 +22,13 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "nlp.h"
|
||||
#include "dump.h"
|
||||
#include "four1.h"
|
||||
#include "kiss_fft.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
@@ -60,7 +59,7 @@
|
||||
|
||||
/* 48 tap 600Hz low pass FIR filter coefficients */
|
||||
|
||||
float nlp_fir[] = {
|
||||
const float nlp_fir[] = {
|
||||
-1.0818124e-03,
|
||||
-1.1008344e-03,
|
||||
-9.2768838e-04,
|
||||
@@ -112,12 +111,14 @@ float nlp_fir[] = {
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
float sq[PMAX_M]; /* squared speech samples */
|
||||
float mem_x,mem_y; /* memory for notch filter */
|
||||
float mem_fir[NLP_NTAP]; /* decimation FIR filter memory */
|
||||
float sq[PMAX_M]; /* squared speech samples */
|
||||
float mem_x,mem_y; /* memory for notch filter */
|
||||
float mem_fir[NLP_NTAP]; /* decimation FIR filter memory */
|
||||
kiss_fft_cfg fft_cfg; /* kiss FFT config */
|
||||
} NLP;
|
||||
|
||||
float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax);
|
||||
float test_candidate_mbe(COMP Sw[], COMP W[], float f0);
|
||||
float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax, COMP Sw[], COMP W[], float *prev_Wo);
|
||||
float post_process_sub_multiples(COMP Fw[],
|
||||
int pmin, int pmax, float gmax, int gmax_bin,
|
||||
float *prev_Wo);
|
||||
@@ -146,20 +147,27 @@ void *nlp_create()
|
||||
for(i=0; i<NLP_NTAP; i++)
|
||||
nlp->mem_fir[i] = 0.0;
|
||||
|
||||
nlp->fft_cfg = kiss_fft_alloc (PE_FFT_SIZE, 0, NULL, NULL);
|
||||
assert(nlp->fft_cfg != NULL);
|
||||
|
||||
return (void*)nlp;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
nlp_destory()
|
||||
nlp_destroy()
|
||||
|
||||
Initialisation function for NLP pitch estimator.
|
||||
Shut down function for NLP pitch estimator.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void nlp_destroy(void *nlp_state)
|
||||
{
|
||||
NLP *nlp;
|
||||
assert(nlp_state != NULL);
|
||||
nlp = (NLP*)nlp_state;
|
||||
|
||||
KISS_FFT_FREE(nlp->fft_cfg);
|
||||
free(nlp_state);
|
||||
}
|
||||
|
||||
@@ -198,27 +206,30 @@ float nlp(
|
||||
float Sn[], /* input speech vector */
|
||||
int n, /* frames shift (no. new samples in Sn[]) */
|
||||
int m, /* analysis window size */
|
||||
int pmin, /* minimum pitch value */
|
||||
int pmin, /* minimum pitch value */
|
||||
int pmax, /* maximum pitch value */
|
||||
float *pitch, /* estimated pitch period in samples */
|
||||
COMP Sw[], /* Freq domain version of Sn[] */
|
||||
COMP W[], /* Freq domain window */
|
||||
float *prev_Wo
|
||||
)
|
||||
{
|
||||
NLP *nlp;
|
||||
float notch; /* current notch filter output */
|
||||
COMP Fw[PE_FFT_SIZE]; /* DFT of squared signal */
|
||||
float notch; /* current notch filter output */
|
||||
COMP fw[PE_FFT_SIZE]; /* DFT of squared signal (input) */
|
||||
COMP Fw[PE_FFT_SIZE]; /* DFT of squared signal (output) */
|
||||
float gmax;
|
||||
int gmax_bin;
|
||||
int i,j;
|
||||
float best_f0;
|
||||
|
||||
assert(nlp_state != NULL);
|
||||
assert(m <= PMAX_M);
|
||||
nlp = (NLP*)nlp_state;
|
||||
|
||||
/* Square, notch filter at DC, and LP filter vector */
|
||||
|
||||
for(i=m-n; i<M; i++) /* square latest speech samples */
|
||||
for(i=m-n; i<m; i++) /* square latest speech samples */
|
||||
nlp->sq[i] = Sn[i]*Sn[i];
|
||||
|
||||
for(i=m-n; i<m; i++) { /* notch filter at DC */
|
||||
@@ -226,7 +237,14 @@ float nlp(
|
||||
notch += COEFF*nlp->mem_y;
|
||||
nlp->mem_x = nlp->sq[i];
|
||||
nlp->mem_y = notch;
|
||||
nlp->sq[i] = notch;
|
||||
nlp->sq[i] = notch + 1.0; /* With 0 input vectors to codec,
|
||||
kiss_fft() would take a long
|
||||
time to execute when running in
|
||||
real time. Problem was traced
|
||||
to kiss_fft function call in
|
||||
this function. Adding this small
|
||||
constant fixed problem. Not
|
||||
exactly sure why. */
|
||||
}
|
||||
|
||||
for(i=m-n; i<m; i++) { /* FIR filter vector */
|
||||
@@ -243,19 +261,24 @@ float nlp(
|
||||
/* Decimate and DFT */
|
||||
|
||||
for(i=0; i<PE_FFT_SIZE; i++) {
|
||||
Fw[i].real = 0.0;
|
||||
Fw[i].imag = 0.0;
|
||||
fw[i].real = 0.0;
|
||||
fw[i].imag = 0.0;
|
||||
}
|
||||
for(i=0; i<m/DEC; i++) {
|
||||
Fw[i].real = nlp->sq[i*DEC]*(0.5 - 0.5*cos(2*PI*i/(m/DEC-1)));
|
||||
fw[i].real = nlp->sq[i*DEC]*(0.5 - 0.5*cos(2*PI*i/(m/DEC-1)));
|
||||
}
|
||||
#ifdef DUMP
|
||||
dump_dec(Fw);
|
||||
four1(&Fw[-1].imag,PE_FFT_SIZE,1);
|
||||
#endif
|
||||
|
||||
kiss_fft(nlp->fft_cfg, (kiss_fft_cpx *)fw, (kiss_fft_cpx *)Fw);
|
||||
for(i=0; i<PE_FFT_SIZE; i++)
|
||||
Fw[i].real = Fw[i].real*Fw[i].real + Fw[i].imag*Fw[i].imag;
|
||||
|
||||
#ifdef DUMP
|
||||
dump_sq(nlp->sq);
|
||||
dump_Fw(Fw);
|
||||
#endif
|
||||
|
||||
/* find global peak */
|
||||
|
||||
@@ -267,9 +290,13 @@ float nlp(
|
||||
gmax_bin = i;
|
||||
}
|
||||
}
|
||||
|
||||
best_f0 = post_process_sub_multiples(Fw, pmin, pmax, gmax, gmax_bin,
|
||||
prev_Wo);
|
||||
|
||||
//#define POST_PROCESS_MBE
|
||||
#ifdef POST_PROCESS_MBE
|
||||
best_f0 = post_process_mbe(Fw, pmin, pmax, gmax, Sw, W, prev_Wo);
|
||||
#else
|
||||
best_f0 = post_process_sub_multiples(Fw, pmin, pmax, gmax, gmax_bin, prev_Wo);
|
||||
#endif
|
||||
|
||||
/* Shift samples in buffer to make room for new samples */
|
||||
|
||||
@@ -286,7 +313,7 @@ float nlp(
|
||||
|
||||
post_process_sub_multiples()
|
||||
|
||||
Given the global maximma of Fw[] we search interger submultiples for
|
||||
Given the global maximma of Fw[] we search integer submultiples for
|
||||
local maxima. If local maxima exist and they are above an
|
||||
experimentally derived threshold (OK a magic number I pulled out of
|
||||
the air) we choose the submultiple as the F0 estimate.
|
||||
@@ -317,10 +344,10 @@ float post_process_sub_multiples(COMP Fw[],
|
||||
/* post process estimate by searching submultiples */
|
||||
|
||||
mult = 2;
|
||||
min_bin = PE_FFT_SIZE*DEC/pmax;
|
||||
min_bin = PE_FFT_SIZE*DEC/pmax;
|
||||
cmax_bin = gmax_bin;
|
||||
prev_f0_bin = *prev_Wo*(4000.0/PI)*(PE_FFT_SIZE*DEC)/SAMPLE_RATE;
|
||||
|
||||
|
||||
while(gmax_bin/mult >= min_bin) {
|
||||
|
||||
b = gmax_bin/mult; /* determine search interval */
|
||||
@@ -339,7 +366,7 @@ float post_process_sub_multiples(COMP Fw[],
|
||||
|
||||
lmax = 0;
|
||||
lmax_bin = bmin;
|
||||
for (b=bmin; b<=bmax; b++) /* look for maximum in interval */
|
||||
for (b=bmin; b<=bmax; b++) /* look for maximum in interval */
|
||||
if (Fw[b].real > lmax) {
|
||||
lmax = Fw[b].real;
|
||||
lmax_bin = b;
|
||||
@@ -359,3 +386,158 @@ float post_process_sub_multiples(COMP Fw[],
|
||||
return best_f0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
post_process_mbe()
|
||||
|
||||
Use the MBE pitch estimation algorithm to evaluate pitch candidates. This
|
||||
works OK but the accuracy at low F0 is affected by NW, the analysis window
|
||||
size used for the DFT of the input speech Sw[]. Also favours high F0 in
|
||||
the presence of background noise which causes periodic artifacts in the
|
||||
synthesised speech.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
float post_process_mbe(COMP Fw[], int pmin, int pmax, float gmax, COMP Sw[], COMP W[], float *prev_Wo)
|
||||
{
|
||||
float candidate_f0;
|
||||
float f0,best_f0; /* fundamental frequency */
|
||||
float e,e_min; /* MBE cost function */
|
||||
int i;
|
||||
float e_hz[F0_MAX];
|
||||
int bin;
|
||||
float f0_min, f0_max;
|
||||
float f0_start, f0_end;
|
||||
|
||||
f0_min = (float)SAMPLE_RATE/pmax;
|
||||
f0_max = (float)SAMPLE_RATE/pmin;
|
||||
|
||||
/* Now look for local maxima. Each local maxima is a candidate
|
||||
that we test using the MBE pitch estimation algotithm */
|
||||
|
||||
for(i=0; i<F0_MAX; i++)
|
||||
e_hz[i] = -1;
|
||||
e_min = 1E32;
|
||||
best_f0 = 50;
|
||||
for(i=PE_FFT_SIZE*DEC/pmax; i<=PE_FFT_SIZE*DEC/pmin; i++) {
|
||||
if ((Fw[i].real > Fw[i-1].real) && (Fw[i].real > Fw[i+1].real)) {
|
||||
|
||||
/* local maxima found, lets test if it's big enough */
|
||||
|
||||
if (Fw[i].real > T*gmax) {
|
||||
|
||||
/* OK, sample MBE cost function over +/- 10Hz range in 2.5Hz steps */
|
||||
|
||||
candidate_f0 = (float)i*SAMPLE_RATE/(PE_FFT_SIZE*DEC);
|
||||
f0_start = candidate_f0-20;
|
||||
f0_end = candidate_f0+20;
|
||||
if (f0_start < f0_min) f0_start = f0_min;
|
||||
if (f0_end > f0_max) f0_end = f0_max;
|
||||
|
||||
for(f0=f0_start; f0<=f0_end; f0+= 2.5) {
|
||||
e = test_candidate_mbe(Sw, W, f0);
|
||||
bin = floor(f0); assert((bin > 0) && (bin < F0_MAX));
|
||||
e_hz[bin] = e;
|
||||
if (e < e_min) {
|
||||
e_min = e;
|
||||
best_f0 = f0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* finally sample MBE cost function around previous pitch estimate
|
||||
(form of pitch tracking) */
|
||||
|
||||
candidate_f0 = *prev_Wo * SAMPLE_RATE/TWO_PI;
|
||||
f0_start = candidate_f0-20;
|
||||
f0_end = candidate_f0+20;
|
||||
if (f0_start < f0_min) f0_start = f0_min;
|
||||
if (f0_end > f0_max) f0_end = f0_max;
|
||||
|
||||
for(f0=f0_start; f0<=f0_end; f0+= 2.5) {
|
||||
e = test_candidate_mbe(Sw, W, f0);
|
||||
bin = floor(f0); assert((bin > 0) && (bin < F0_MAX));
|
||||
e_hz[bin] = e;
|
||||
if (e < e_min) {
|
||||
e_min = e;
|
||||
best_f0 = f0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DUMP
|
||||
dump_e(e_hz);
|
||||
#endif
|
||||
|
||||
return best_f0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
test_candidate_mbe()
|
||||
|
||||
Returns the error of the MBE cost function for the input f0.
|
||||
|
||||
Note: I think a lot of the operations below can be simplified as
|
||||
W[].imag = 0 and has been normalised such that den always equals 1.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
float test_candidate_mbe(
|
||||
COMP Sw[],
|
||||
COMP W[],
|
||||
float f0
|
||||
)
|
||||
{
|
||||
COMP Sw_[FFT_ENC]; /* DFT of all voiced synthesised signal */
|
||||
int l,al,bl,m; /* loop variables */
|
||||
COMP Am; /* amplitude sample for this band */
|
||||
int offset; /* centers Hw[] about current harmonic */
|
||||
float den; /* denominator of Am expression */
|
||||
float error; /* accumulated error between originl and synthesised */
|
||||
float Wo; /* current "test" fundamental freq. */
|
||||
int L;
|
||||
|
||||
L = floor((SAMPLE_RATE/2.0)/f0);
|
||||
Wo = f0*(2*PI/SAMPLE_RATE);
|
||||
|
||||
error = 0.0;
|
||||
|
||||
/* Just test across the harmonics in the first 1000 Hz (L/4) */
|
||||
|
||||
for(l=1; l<L/4; l++) {
|
||||
Am.real = 0.0;
|
||||
Am.imag = 0.0;
|
||||
den = 0.0;
|
||||
al = ceil((l - 0.5)*Wo*FFT_ENC/TWO_PI);
|
||||
bl = ceil((l + 0.5)*Wo*FFT_ENC/TWO_PI);
|
||||
|
||||
/* Estimate amplitude of harmonic assuming harmonic is totally voiced */
|
||||
|
||||
for(m=al; m<bl; m++) {
|
||||
offset = FFT_ENC/2 + m - l*Wo*FFT_ENC/TWO_PI + 0.5;
|
||||
Am.real += Sw[m].real*W[offset].real + Sw[m].imag*W[offset].imag;
|
||||
Am.imag += Sw[m].imag*W[offset].real - Sw[m].real*W[offset].imag;
|
||||
den += W[offset].real*W[offset].real + W[offset].imag*W[offset].imag;
|
||||
}
|
||||
|
||||
Am.real = Am.real/den;
|
||||
Am.imag = Am.imag/den;
|
||||
|
||||
/* Determine error between estimated harmonic and original */
|
||||
|
||||
for(m=al; m<bl; m++) {
|
||||
offset = FFT_ENC/2 + m - l*Wo*FFT_ENC/TWO_PI + 0.5;
|
||||
Sw_[m].real = Am.real*W[offset].real - Am.imag*W[offset].imag;
|
||||
Sw_[m].imag = Am.real*W[offset].imag + Am.imag*W[offset].real;
|
||||
error += (Sw[m].real - Sw_[m].real)*(Sw[m].real - Sw_[m].real);
|
||||
error += (Sw[m].imag - Sw_[m].imag)*(Sw[m].imag - Sw_[m].imag);
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,17 +22,17 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __NLP__
|
||||
#define __NLP__
|
||||
|
||||
#include "comp.h"
|
||||
|
||||
void *nlp_create();
|
||||
void nlp_destroy(void *nlp_state);
|
||||
float nlp(void *nlp_state, float Sn[], int n, int m, int pmin, int pmax,
|
||||
float *pitch, COMP Sw[], float *prev_Wo);
|
||||
float test_candidate_mbe(COMP Sw[], float f0, COMP Sw_[]);
|
||||
float *pitch, COMP Sw[], COMP W[], float *prev_Wo);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: octave.c
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: April 28 2012
|
||||
|
||||
Functions to save C arrays in GNU Octave matrix format. The output text
|
||||
file can be directly read into Octave using "load filename".
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "octave.h"
|
||||
|
||||
void octave_save_int(FILE *f, char name[], int data[], int rows, int cols)
|
||||
{
|
||||
int r,c;
|
||||
|
||||
fprintf(f, "# name: %s\n", name);
|
||||
fprintf(f, "# type: matrix\n");
|
||||
fprintf(f, "# rows: %d\n", rows);
|
||||
fprintf(f, "# columns: %d\n", cols);
|
||||
|
||||
for(r=0; r<rows; r++) {
|
||||
for(c=0; c<cols; c++)
|
||||
fprintf(f, " %d", data[r*cols+c]);
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
|
||||
fprintf(f, "\n\n");
|
||||
}
|
||||
|
||||
void octave_save_float(FILE *f, char name[], float data[], int rows, int cols, int col_len)
|
||||
{
|
||||
int r,c;
|
||||
|
||||
fprintf(f, "# name: %s\n", name);
|
||||
fprintf(f, "# type: matrix\n");
|
||||
fprintf(f, "# rows: %d\n", rows);
|
||||
fprintf(f, "# columns: %d\n", cols);
|
||||
|
||||
for(r=0; r<rows; r++) {
|
||||
for(c=0; c<cols; c++)
|
||||
fprintf(f, " %f", data[r*col_len+c]);
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
|
||||
fprintf(f, "\n\n");
|
||||
}
|
||||
|
||||
void octave_save_complex(FILE *f, char name[], COMP data[], int rows, int cols, int col_len)
|
||||
{
|
||||
int r,c;
|
||||
|
||||
fprintf(f, "# name: %s\n", name);
|
||||
fprintf(f, "# type: complex matrix\n");
|
||||
fprintf(f, "# rows: %d\n", rows);
|
||||
fprintf(f, "# columns: %d\n", cols);
|
||||
|
||||
for(r=0; r<rows; r++) {
|
||||
for(c=0; c<cols; c++)
|
||||
fprintf(f, " (%f,%f)", data[r*col_len+c].real, data[r*col_len+c].imag);
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
|
||||
fprintf(f, "\n\n");
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: octave.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: April 28 2012
|
||||
|
||||
Functions to save C arrays in Octave matrix format. the output text
|
||||
file can be directly read into octave using "load filename".
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __OCTAVE__
|
||||
#define __OCTAVE__
|
||||
|
||||
#include "comp.h"
|
||||
|
||||
void octave_save_int(FILE *f, char name[], int data[], int rows, int cols);
|
||||
void octave_save_float(FILE *f, char name[], float data[], int rows, int cols, int col_len);
|
||||
void octave_save_complex(FILE *f, char name[], COMP data[], int rows, int cols, int col_len);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/* Generate using fir1(47,1/6) in Octave */
|
||||
|
||||
const float fdmdv_os_filter[]= {
|
||||
-3.55606818e-04,
|
||||
-8.98615286e-04,
|
||||
-1.40119781e-03,
|
||||
-1.71713852e-03,
|
||||
-1.56471179e-03,
|
||||
-6.28128960e-04,
|
||||
1.24522223e-03,
|
||||
3.83138676e-03,
|
||||
6.41309478e-03,
|
||||
7.85893186e-03,
|
||||
6.93514929e-03,
|
||||
2.79361991e-03,
|
||||
-4.51051400e-03,
|
||||
-1.36671853e-02,
|
||||
-2.21034939e-02,
|
||||
-2.64084653e-02,
|
||||
-2.31425052e-02,
|
||||
-9.84218694e-03,
|
||||
1.40648474e-02,
|
||||
4.67316298e-02,
|
||||
8.39615986e-02,
|
||||
1.19925275e-01,
|
||||
1.48381174e-01,
|
||||
1.64097819e-01,
|
||||
1.64097819e-01,
|
||||
1.48381174e-01,
|
||||
1.19925275e-01,
|
||||
8.39615986e-02,
|
||||
4.67316298e-02,
|
||||
1.40648474e-02,
|
||||
-9.84218694e-03,
|
||||
-2.31425052e-02,
|
||||
-2.64084653e-02,
|
||||
-2.21034939e-02,
|
||||
-1.36671853e-02,
|
||||
-4.51051400e-03,
|
||||
2.79361991e-03,
|
||||
6.93514929e-03,
|
||||
7.85893186e-03,
|
||||
6.41309478e-03,
|
||||
3.83138676e-03,
|
||||
1.24522223e-03,
|
||||
-6.28128960e-04,
|
||||
-1.56471179e-03,
|
||||
-1.71713852e-03,
|
||||
-1.40119781e-03,
|
||||
-8.98615286e-04,
|
||||
-3.55606818e-04
|
||||
};
|
||||
|
||||
+14
-13
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright (C) 2010 Perens LLC <bruce@perens.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
All rights reserved.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
*/
|
||||
#include "defines.h"
|
||||
#include "quantise.h"
|
||||
#include <stdio.h>
|
||||
@@ -81,7 +81,8 @@ unpack(
|
||||
unsigned int fieldWidth/* Width of the field in BITS, not bytes. */
|
||||
)
|
||||
{
|
||||
unsigned int field = 0;
|
||||
unsigned int field = 0;
|
||||
unsigned int t;
|
||||
|
||||
do {
|
||||
unsigned int bI = *bitIndex;
|
||||
@@ -96,7 +97,7 @@ unpack(
|
||||
} while ( fieldWidth != 0 );
|
||||
|
||||
/* Convert from Gray code to binary. Works for maximum 8-bit fields. */
|
||||
unsigned int t = field ^ (field >> 8);
|
||||
t = field ^ (field >> 8);
|
||||
t ^= (t >> 4);
|
||||
t ^= (t >> 2);
|
||||
t ^= (t >> 1);
|
||||
|
||||
+63
-44
@@ -22,20 +22,22 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not,see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "phase.h"
|
||||
#include "four1.h"
|
||||
#include "kiss_fft.h"
|
||||
#include "comp.h"
|
||||
#include "glottal.c"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define VTHRESH 4.0
|
||||
#define GLOTTAL_FFT_SIZE 512
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
@@ -47,6 +49,7 @@
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void aks_to_H(
|
||||
kiss_fft_cfg fft_fwd_cfg,
|
||||
MODEL *model, /* model parameters */
|
||||
float aks[], /* LPC's */
|
||||
float G, /* energy term */
|
||||
@@ -54,7 +57,8 @@ void aks_to_H(
|
||||
int order
|
||||
)
|
||||
{
|
||||
COMP Pw[FFT_DEC]; /* power spectrum */
|
||||
COMP pw[FFT_ENC]; /* power spectrum (input) */
|
||||
COMP Pw[FFT_ENC]; /* power spectrum (output) */
|
||||
int i,m; /* loop variables */
|
||||
int am,bm; /* limits of current band */
|
||||
float r; /* no. rads/bin */
|
||||
@@ -63,19 +67,19 @@ void aks_to_H(
|
||||
int b; /* centre bin of harmonic */
|
||||
float phi_; /* phase of LPC spectra */
|
||||
|
||||
r = TWO_PI/(FFT_DEC);
|
||||
r = TWO_PI/(FFT_ENC);
|
||||
|
||||
/* Determine DFT of A(exp(jw)) ------------------------------------------*/
|
||||
|
||||
for(i=0; i<FFT_DEC; i++) {
|
||||
Pw[i].real = 0.0;
|
||||
Pw[i].imag = 0.0;
|
||||
for(i=0; i<FFT_ENC; i++) {
|
||||
pw[i].real = 0.0;
|
||||
pw[i].imag = 0.0;
|
||||
}
|
||||
|
||||
for(i=0; i<=order; i++)
|
||||
Pw[i].real = aks[i];
|
||||
pw[i].real = aks[i];
|
||||
|
||||
four1(&Pw[-1].imag,FFT_DEC,-1);
|
||||
kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)pw, (kiss_fft_cpx *)Pw);
|
||||
|
||||
/* Sample magnitude and phase at harmonics */
|
||||
|
||||
@@ -149,24 +153,26 @@ void aks_to_H(
|
||||
This E[m] then gets passed through the LPC synthesis filter to
|
||||
determine the final harmonic phase.
|
||||
|
||||
For a while there were prolems with low pitched males like hts1
|
||||
sounding "clicky". The synthesied time domain waveform also looked
|
||||
clicky. Many methods were tried to improve the sounds quality of
|
||||
low pitched males. Finally adding a small amount of jitter to each
|
||||
harmonic worked.
|
||||
Comparing to speech synthesised using original phases:
|
||||
|
||||
The current result sounds very close to the original phases, with
|
||||
only 1 voicing bit per frame. For example hts1a using original
|
||||
amplitudes and this phase model produces speech hard to distinguish
|
||||
from speech synthesise with the orginal phases. The sound quality
|
||||
of this patrtiallyuantised codec (nb original amplitudes) is higher
|
||||
than g729, even though all the phase information has been
|
||||
discarded.
|
||||
- Through headphones speech synthesised with this model is not as
|
||||
good. Through a loudspeaker it is very close to original phases.
|
||||
|
||||
- If there are voicing errors, the speech can sound clicky or
|
||||
staticy. If V speech is mistakenly declared UV, this model tends to
|
||||
synthesise impulses or clicks, as there is usually very little shift or
|
||||
dispersion through the LPC filter.
|
||||
|
||||
- When combined with LPC amplitude modelling there is an additional
|
||||
drop in quality. I am not sure why, theory is interformant energy
|
||||
is raised making any phase errors more obvious.
|
||||
|
||||
NOTES:
|
||||
|
||||
1/ This synthesis model is effectvely the same as simple LPC-10
|
||||
vocoders, and yet sounds much better. Why?
|
||||
1/ This synthesis model is effectively the same as a simple LPC-10
|
||||
vocoders, and yet sounds much better. Why? Conventional wisdom
|
||||
(AMBE, MELP) says mixed voicing is required for high quality
|
||||
speech.
|
||||
|
||||
2/ I am pretty sure the Lincoln Lab sinusoidal coding guys (like xMBE
|
||||
also from MIT) first described this zero phase model, I need to look
|
||||
@@ -182,52 +188,64 @@ void aks_to_H(
|
||||
a small delta-W to make phase tracks line up for voiced
|
||||
harmonics.
|
||||
|
||||
4/ Why does this sound so great with 1 V/UV decision? Conventional
|
||||
wisdom says mixed voicing is required for high qaulity speech.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void phase_synth_zero_order(
|
||||
kiss_fft_cfg fft_fwd_cfg,
|
||||
MODEL *model,
|
||||
float aks[],
|
||||
float *ex_phase /* excitation phase of fundamental */
|
||||
float *ex_phase, /* excitation phase of fundamental */
|
||||
int order
|
||||
)
|
||||
{
|
||||
int m;
|
||||
float new_phi;
|
||||
COMP Ex[MAX_AMP]; /* excitation samples */
|
||||
COMP A_[MAX_AMP]; /* synthesised harmonic samples */
|
||||
COMP H[MAX_AMP]; /* LPC freq domain samples */
|
||||
COMP Ex[MAX_AMP+1]; /* excitation samples */
|
||||
COMP A_[MAX_AMP+1]; /* synthesised harmonic samples */
|
||||
COMP H[MAX_AMP+1]; /* LPC freq domain samples */
|
||||
float G;
|
||||
float jitter;
|
||||
float jitter = 0.0;
|
||||
float r;
|
||||
int b;
|
||||
|
||||
G = 1.0;
|
||||
aks_to_H(model,aks,G,H,LPC_ORD);
|
||||
aks_to_H(fft_fwd_cfg, model, aks, G, H, order);
|
||||
|
||||
/*
|
||||
Update excitation fundamental phase track, this sets the position
|
||||
of each pitch pulse during voiced speech. After much experiment
|
||||
I found that using just this frame Wo improved quality for UV
|
||||
I found that using just this frame's Wo improved quality for UV
|
||||
sounds compared to interpolating two frames Wo like this:
|
||||
|
||||
ex_phase[0] += (*prev_Wo+mode->Wo)*N/2;
|
||||
ex_phase[0] += (*prev_Wo+model->Wo)*N/2;
|
||||
*/
|
||||
|
||||
ex_phase[0] += (model->Wo)*N;
|
||||
ex_phase[0] -= TWO_PI*floor(ex_phase[0]/TWO_PI + 0.5);
|
||||
r = TWO_PI/GLOTTAL_FFT_SIZE;
|
||||
|
||||
for(m=1; m<=model->L; m++) {
|
||||
|
||||
|
||||
/* generate excitation */
|
||||
|
||||
|
||||
if (model->voiced) {
|
||||
/* This method of adding jitter really helped remove the clicky
|
||||
sound in low pitched makes like hts1a. This moves the onset
|
||||
of each harmonic over at +/- 0.25 of a sample.
|
||||
//float rnd;
|
||||
|
||||
b = floor(m*model->Wo/r + 0.5);
|
||||
if (b > ((GLOTTAL_FFT_SIZE/2)-1)) {
|
||||
b = (GLOTTAL_FFT_SIZE/2)-1;
|
||||
}
|
||||
|
||||
/* I think adding a little jitter helps improve low pitch
|
||||
males like hts1a. This moves the onset of each harmonic
|
||||
over +/- 0.25 of a sample.
|
||||
*/
|
||||
jitter = 0.25*(1.0 - 2.0*rand()/RAND_MAX);
|
||||
Ex[m].real = cos(ex_phase[0]*m - jitter*model->Wo*m);
|
||||
Ex[m].imag = sin(ex_phase[0]*m - jitter*model->Wo*m);
|
||||
//jitter = 0.25*(1.0 - 2.0*rand()/RAND_MAX);
|
||||
jitter = 0;
|
||||
|
||||
//rnd = (PI/8)*(1.0 - 2.0*rand()/RAND_MAX);
|
||||
Ex[m].real = cos(ex_phase[0]*m/* - jitter*model->Wo*m + glottal[b]*/);
|
||||
Ex[m].imag = sin(ex_phase[0]*m/* - jitter*model->Wo*m + glottal[b]*/);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -252,3 +270,4 @@ void phase_synth_zero_order(
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,18 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __PHASE__
|
||||
#define __PHASE__
|
||||
|
||||
void phase_synth_zero_order(MODEL *model, float aks[], float *ex_phase);
|
||||
#include "kiss_fft.h"
|
||||
|
||||
void phase_synth_zero_order(kiss_fft_cfg fft_dec_cfg,
|
||||
MODEL *model,
|
||||
float aks[],
|
||||
float *ex_phase,
|
||||
int order);
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: phaseexp.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: June 2012
|
||||
|
||||
Experimental functions for quantising, modelling and synthesising phase.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2012 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2.1, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __PHASEEXP__
|
||||
#define __PHASEEXP__
|
||||
|
||||
#include "kiss_fft.h"
|
||||
|
||||
struct PEXP;
|
||||
|
||||
struct PEXP * phase_experiment_create();
|
||||
void phase_experiment_destroy(struct PEXP *pexp);
|
||||
void phase_experiment(struct PEXP *pexp, MODEL *model, char *arg);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
/* Generated by pilot_coeff_file() Octave function */
|
||||
|
||||
const float pilot_coeff[]={
|
||||
0.00204705,
|
||||
0.00276339,
|
||||
0.00432595,
|
||||
0.00697042,
|
||||
0.0108452,
|
||||
0.0159865,
|
||||
0.0223035,
|
||||
0.029577,
|
||||
0.0374709,
|
||||
0.045557,
|
||||
0.0533491,
|
||||
0.0603458,
|
||||
0.0660751,
|
||||
0.070138,
|
||||
0.0722452,
|
||||
0.0722452,
|
||||
0.070138,
|
||||
0.0660751,
|
||||
0.0603458,
|
||||
0.0533491,
|
||||
0.045557,
|
||||
0.0374709,
|
||||
0.029577,
|
||||
0.0223035,
|
||||
0.0159865,
|
||||
0.0108452,
|
||||
0.00697042,
|
||||
0.00432595,
|
||||
0.00276339,
|
||||
0.00204705
|
||||
};
|
||||
@@ -24,15 +24,16 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "comp.h"
|
||||
#include "dump.h"
|
||||
#include "postfilter.h"
|
||||
|
||||
@@ -44,6 +45,11 @@
|
||||
|
||||
#define BG_THRESH 40.0 /* only consider low levels signals for bg_est */
|
||||
#define BG_BETA 0.1 /* averaging filter constant */
|
||||
#define BG_MARGIN 6.0 /* harmonics this far above BG noise are
|
||||
randomised. Helped make bg noise less
|
||||
spikey (impulsive) for mmt1, but speech was
|
||||
perhaps a little rougher.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
@@ -61,7 +67,7 @@
|
||||
(5-12) are required to transmit the frequency selective voicing
|
||||
information. Mixed excitation also requires accurate voicing
|
||||
estimation (parameter estimators always break occasionally under
|
||||
exceptional condition).
|
||||
exceptional conditions).
|
||||
|
||||
In our case we use a post filter approach which requires no
|
||||
additional bits to be transmitted. The decoder measures the average
|
||||
@@ -105,6 +111,7 @@ void postfilter(
|
||||
for(m=1; m<=model->L; m++)
|
||||
e += model->A[m]*model->A[m];
|
||||
|
||||
assert(e > 0.0);
|
||||
e = 10.0*log10(e/model->L);
|
||||
|
||||
/* If beneath threhold, update bg estimate. The idea
|
||||
@@ -121,11 +128,13 @@ void postfilter(
|
||||
uv = 0;
|
||||
if (model->voiced)
|
||||
for(m=1; m<=model->L; m++)
|
||||
if (20.0*log10(model->A[m]) < *bg_est) {
|
||||
if (20.0*log10(model->A[m]) < (*bg_est + BG_MARGIN)) {
|
||||
model->phi[m] = TWO_PI*(float)rand()/RAND_MAX;
|
||||
uv++;
|
||||
}
|
||||
|
||||
#ifdef DUMP
|
||||
dump_bg(e, *bg_est, 100.0*uv/model->L);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __POSTFILTER__
|
||||
|
||||
+1468
-303
File diff suppressed because it is too large
Load Diff
@@ -20,65 +20,104 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __QUANTISE__
|
||||
#define __QUANTISE__
|
||||
|
||||
#define WO_BITS 7
|
||||
#define WO_LEVELS (1<<WO_BITS)
|
||||
#define E_BITS 5
|
||||
#define E_LEVELS (1<<E_BITS)
|
||||
#define E_MIN_DB -10.0
|
||||
#define E_MAX_DB 40.0
|
||||
#include "kiss_fft.h"
|
||||
|
||||
#define WO_BITS 7
|
||||
#define WO_LEVELS (1<<WO_BITS)
|
||||
#define WO_DT_BITS 3
|
||||
|
||||
#define E_BITS 5
|
||||
#define E_LEVELS (1<<E_BITS)
|
||||
#define E_MIN_DB -10.0
|
||||
#define E_MAX_DB 40.0
|
||||
|
||||
#define LSP_SCALAR_INDEXES 10
|
||||
#define LSPD_SCALAR_INDEXES 10
|
||||
#define LSP_PRED_VQ_INDEXES 3
|
||||
#define LSP_DIFF_FREQ_INDEXES 5
|
||||
#define LSP_DIFF_TIME_BITS 7
|
||||
|
||||
#define LSPDT_ALL 0
|
||||
#define LSPDT_LOW 1
|
||||
#define LSPDT_HIGH 2
|
||||
|
||||
#define WO_E_BITS 8
|
||||
|
||||
#define LPCPF_GAMMA 0.5
|
||||
#define LPCPF_BETA 0.2
|
||||
|
||||
void quantise_init();
|
||||
float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order,
|
||||
int lsp,float ak[]);
|
||||
void aks_to_M2(float ak[], int order, MODEL *model, float E, float *snr,
|
||||
int dump);
|
||||
float get_gmin(void);
|
||||
void aks_to_M2(kiss_fft_cfg fft_fwd_cfg, float ak[], int order, MODEL *model,
|
||||
float E, float *snr, int dump, int sim_pf,
|
||||
int pf, int bass_boost, float beta, float gamma);
|
||||
|
||||
int encode_Wo(float Wo);
|
||||
float decode_Wo(int index);
|
||||
int encode_Wo_dt(float Wo, float prev_Wo);
|
||||
float decode_Wo_dt(int index, float prev_Wo);
|
||||
void encode_lsps_scalar(int indexes[], float lsp[], int order);
|
||||
void decode_lsps_scalar(float lsp[], int indexes[], int order);
|
||||
void encode_lspds_scalar(int indexes[], float lsp[], int order);
|
||||
void decode_lspds_scalar(float lsp[], int indexes[], int order);
|
||||
void encode_lsps_diff_freq_vq(int indexes[], float lsp[], int order);
|
||||
void decode_lsps_diff_freq_vq(float lsp_[], int indexes[], int order);
|
||||
void encode_lsps_diff_time(int indexes[],
|
||||
float lsp[],
|
||||
float lsp__prev[],
|
||||
int order);
|
||||
void decode_lsps_diff_time(float lsp_[],
|
||||
int indexes[],
|
||||
float lsp__prev[],
|
||||
int order);
|
||||
|
||||
void encode_lsps(int indexes[], float lsp[], int order);
|
||||
void decode_lsps(float lsp[], int indexes[], int order);
|
||||
void encode_lsps_vq(int *indexes, float *x, float *xq, int ndim);
|
||||
void decode_lsps_vq(int *indexes, float *xq, int ndim);
|
||||
|
||||
long quantise(const float * cb, float vec[], float w[], int k, int m, float *se);
|
||||
void lspvq_quantise(float lsp[], float lsp_[], int order);
|
||||
void lspjnd_quantise(float lsp[], float lsp_[], int order);
|
||||
void lspdt_quantise(float lsps[], float lsps_[], float lsps__prev[], int mode);
|
||||
void lspjvm_quantise(float lsps[], float lsps_[], int order);
|
||||
void lspanssi_quantise(float lsps[], float lsps_[], int order, int mbest_entries);
|
||||
|
||||
void quantise_WoE(MODEL *model, float *e, float xq[]);
|
||||
int encode_WoE(MODEL *model, float e, float xq[]);
|
||||
void decode_WoE(MODEL *model, float *e, float xq[], int n1);
|
||||
|
||||
int encode_energy(float e);
|
||||
float decode_energy(int index);
|
||||
|
||||
void encode_amplitudes(int lsp_indexes[],
|
||||
int *lpc_correction,
|
||||
int *energy_index,
|
||||
MODEL *model,
|
||||
float Sn[],
|
||||
float w[]);
|
||||
|
||||
float decode_amplitudes(MODEL *model,
|
||||
float ak[],
|
||||
int lsp_indexes[],
|
||||
int lpc_correction,
|
||||
int energy_index);
|
||||
|
||||
void pack(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits);
|
||||
int unpack(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits);
|
||||
|
||||
int lsp_bits(int i);
|
||||
int lspd_bits(int i);
|
||||
int lspdt_bits(int i);
|
||||
int lsp_pred_vq_bits(int i);
|
||||
|
||||
int need_lpc_correction(MODEL *model, float ak[], float E);
|
||||
void apply_lpc_correction(MODEL *model, int lpc_correction);
|
||||
void apply_lpc_correction(MODEL *model);
|
||||
float speech_to_uq_lsps(float lsp[],
|
||||
float ak[],
|
||||
float Sn[],
|
||||
float w[],
|
||||
int order
|
||||
);
|
||||
void bw_expand_lsps(float lsp[],
|
||||
int order
|
||||
);
|
||||
void decode_lsps(float lsp[], int indexes[], int order);
|
||||
int check_lsp_order(float lsp[], int lpc_order);
|
||||
void bw_expand_lsps(float lsp[], int order);
|
||||
void locate_lsps_jnd_steps(float lsp[], int order);
|
||||
float decode_amplitudes(MODEL *model,
|
||||
float ak[],
|
||||
int lsp_indexes[],
|
||||
int energy_index,
|
||||
float lsps[],
|
||||
float *e);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,964 @@
|
||||
/* Generated by rn_file() Octave function */
|
||||
|
||||
const float gt_alpha5_root[]={
|
||||
2.86997e-05,
|
||||
2.2286e-05,
|
||||
1.82863e-05,
|
||||
1.42303e-05,
|
||||
1.04905e-05,
|
||||
6.70859e-06,
|
||||
3.05918e-06,
|
||||
-6.22187e-07,
|
||||
-4.22748e-06,
|
||||
-7.85603e-06,
|
||||
-1.14317e-05,
|
||||
-1.50227e-05,
|
||||
-1.85712e-05,
|
||||
-2.21275e-05,
|
||||
-2.56455e-05,
|
||||
-2.91642e-05,
|
||||
-3.26453e-05,
|
||||
-3.61199e-05,
|
||||
-3.95556e-05,
|
||||
-4.29778e-05,
|
||||
-4.63581e-05,
|
||||
-4.97179e-05,
|
||||
-5.3032e-05,
|
||||
-5.63184e-05,
|
||||
-5.95548e-05,
|
||||
-6.27565e-05,
|
||||
-6.59032e-05,
|
||||
-6.90085e-05,
|
||||
-7.20538e-05,
|
||||
-7.50509e-05,
|
||||
-7.7983e-05,
|
||||
-8.08605e-05,
|
||||
-8.36678e-05,
|
||||
-8.64141e-05,
|
||||
-8.9085e-05,
|
||||
-9.16888e-05,
|
||||
-9.42119e-05,
|
||||
-9.66619e-05,
|
||||
-9.9026e-05,
|
||||
-0.000101311,
|
||||
-0.000103505,
|
||||
-0.000105614,
|
||||
-0.000107627,
|
||||
-0.00010955,
|
||||
-0.000111372,
|
||||
-0.000113099,
|
||||
-0.00011472,
|
||||
-0.000116241,
|
||||
-0.000117652,
|
||||
-0.000118959,
|
||||
-0.000120152,
|
||||
-0.000121235,
|
||||
-0.000122201,
|
||||
-0.000123053,
|
||||
-0.000123784,
|
||||
-0.000124397,
|
||||
-0.000124884,
|
||||
-0.00012525,
|
||||
-0.000125487,
|
||||
-0.000125598,
|
||||
-0.000125578,
|
||||
-0.000125428,
|
||||
-0.000125145,
|
||||
-0.000124729,
|
||||
-0.000124185,
|
||||
-0.000123518,
|
||||
-0.000122709,
|
||||
-0.000121766,
|
||||
-0.000120685,
|
||||
-0.000119471,
|
||||
-0.000118119,
|
||||
-0.000116633,
|
||||
-0.000115009,
|
||||
-0.000113251,
|
||||
-0.000111356,
|
||||
-0.000109326,
|
||||
-0.00010716,
|
||||
-0.00010486,
|
||||
-0.000102424,
|
||||
-9.98553e-05,
|
||||
-9.71528e-05,
|
||||
-9.43199e-05,
|
||||
-9.13551e-05,
|
||||
-8.82623e-05,
|
||||
-8.50404e-05,
|
||||
-8.16936e-05,
|
||||
-7.82211e-05,
|
||||
-7.46271e-05,
|
||||
-7.09109e-05,
|
||||
-6.70773e-05,
|
||||
-6.31256e-05,
|
||||
-5.90607e-05,
|
||||
-5.48823e-05,
|
||||
-5.05954e-05,
|
||||
-4.62001e-05,
|
||||
-4.17016e-05,
|
||||
-3.71002e-05,
|
||||
-3.24015e-05,
|
||||
-2.7606e-05,
|
||||
-2.27195e-05,
|
||||
-1.77428e-05,
|
||||
-1.2682e-05,
|
||||
-7.53795e-06,
|
||||
-2.31702e-06,
|
||||
2.97965e-06,
|
||||
8.34567e-06,
|
||||
1.37796e-05,
|
||||
1.9275e-05,
|
||||
2.483e-05,
|
||||
3.04382e-05,
|
||||
3.60975e-05,
|
||||
4.18011e-05,
|
||||
4.75467e-05,
|
||||
5.33273e-05,
|
||||
5.91403e-05,
|
||||
6.49787e-05,
|
||||
7.08393e-05,
|
||||
7.67152e-05,
|
||||
8.26029e-05,
|
||||
8.84957e-05,
|
||||
9.43895e-05,
|
||||
0.000100278,
|
||||
0.000106157,
|
||||
0.00011202,
|
||||
0.000117864,
|
||||
0.000123681,
|
||||
0.000129468,
|
||||
0.000135218,
|
||||
0.000140929,
|
||||
0.000146583,
|
||||
0.000152183,
|
||||
0.000157725,
|
||||
0.000163202,
|
||||
0.000168608,
|
||||
0.000173938,
|
||||
0.000179183,
|
||||
0.00018434,
|
||||
0.0001894,
|
||||
0.00019436,
|
||||
0.000199211,
|
||||
0.000203949,
|
||||
0.000208568,
|
||||
0.000213063,
|
||||
0.000217426,
|
||||
0.000221654,
|
||||
0.00022574,
|
||||
0.000229678,
|
||||
0.000233463,
|
||||
0.000237089,
|
||||
0.000240551,
|
||||
0.000243843,
|
||||
0.000246959,
|
||||
0.000249895,
|
||||
0.000252644,
|
||||
0.000255202,
|
||||
0.000257562,
|
||||
0.000259721,
|
||||
0.000261672,
|
||||
0.000263411,
|
||||
0.000264933,
|
||||
0.000266234,
|
||||
0.000267308,
|
||||
0.000268152,
|
||||
0.00026876,
|
||||
0.000269128,
|
||||
0.000269253,
|
||||
0.000269129,
|
||||
0.000268754,
|
||||
0.000268123,
|
||||
0.000267232,
|
||||
0.000266079,
|
||||
0.000264658,
|
||||
0.000262968,
|
||||
0.000261006,
|
||||
0.000258767,
|
||||
0.000256251,
|
||||
0.000253453,
|
||||
0.000250373,
|
||||
0.000247007,
|
||||
0.000243354,
|
||||
0.000239412,
|
||||
0.00023518,
|
||||
0.000230655,
|
||||
0.000225837,
|
||||
0.000220723,
|
||||
0.000215314,
|
||||
0.000209608,
|
||||
0.000203605,
|
||||
0.000197304,
|
||||
0.000190706,
|
||||
0.000183812,
|
||||
0.000176621,
|
||||
0.000169145,
|
||||
0.000161363,
|
||||
0.000153275,
|
||||
0.000144895,
|
||||
0.000136224,
|
||||
0.000127266,
|
||||
0.00011802,
|
||||
0.000108491,
|
||||
9.8679e-05,
|
||||
8.85877e-05,
|
||||
7.82196e-05,
|
||||
6.7577e-05,
|
||||
5.66636e-05,
|
||||
4.54822e-05,
|
||||
3.40369e-05,
|
||||
2.23311e-05,
|
||||
1.03695e-05,
|
||||
-1.844e-06,
|
||||
-1.43041e-05,
|
||||
-2.70061e-05,
|
||||
-3.99444e-05,
|
||||
-5.31139e-05,
|
||||
-6.65082e-05,
|
||||
-8.01218e-05,
|
||||
-9.39481e-05,
|
||||
-0.000107981,
|
||||
-0.000122213,
|
||||
-0.000136638,
|
||||
-0.000151248,
|
||||
-0.000166036,
|
||||
-0.000180995,
|
||||
-0.000196115,
|
||||
-0.00021139,
|
||||
-0.000226811,
|
||||
-0.000242369,
|
||||
-0.000258056,
|
||||
-0.000273861,
|
||||
-0.000289776,
|
||||
-0.000305792,
|
||||
-0.000321898,
|
||||
-0.000338084,
|
||||
-0.000354342,
|
||||
-0.00037066,
|
||||
-0.000387027,
|
||||
-0.000403434,
|
||||
-0.00041987,
|
||||
-0.000436324,
|
||||
-0.000452784,
|
||||
-0.00046924,
|
||||
-0.00048568,
|
||||
-0.000502091,
|
||||
-0.000518464,
|
||||
-0.000534785,
|
||||
-0.000551043,
|
||||
-0.000567225,
|
||||
-0.000583319,
|
||||
-0.000599314,
|
||||
-0.000615196,
|
||||
-0.000630955,
|
||||
-0.000646575,
|
||||
-0.000662049,
|
||||
-0.000677361,
|
||||
-0.000692506,
|
||||
-0.000707464,
|
||||
-0.00072229,
|
||||
-0.000736922,
|
||||
-0.000751266,
|
||||
-0.000765372,
|
||||
-0.000779217,
|
||||
-0.000792798,
|
||||
-0.000806094,
|
||||
-0.000819098,
|
||||
-0.000831793,
|
||||
-0.000844168,
|
||||
-0.000856207,
|
||||
-0.000867898,
|
||||
-0.000879227,
|
||||
-0.00089018,
|
||||
-0.000900744,
|
||||
-0.000910906,
|
||||
-0.000920652,
|
||||
-0.00092997,
|
||||
-0.000938844,
|
||||
-0.000947263,
|
||||
-0.000955214,
|
||||
-0.000962682,
|
||||
-0.000969654,
|
||||
-0.000976119,
|
||||
-0.000982062,
|
||||
-0.00098747,
|
||||
-0.000992332,
|
||||
-0.000996634,
|
||||
-0.00100036,
|
||||
-0.00100351,
|
||||
-0.00100606,
|
||||
-0.001008,
|
||||
-0.00100932,
|
||||
-0.00101,
|
||||
-0.00101005,
|
||||
-0.00100943,
|
||||
-0.00100816,
|
||||
-0.0010062,
|
||||
-0.00100356,
|
||||
-0.00100021,
|
||||
-0.000996162,
|
||||
-0.000991392,
|
||||
-0.000985892,
|
||||
-0.000979654,
|
||||
-0.000972668,
|
||||
-0.000964925,
|
||||
-0.000956415,
|
||||
-0.000947131,
|
||||
-0.000937065,
|
||||
-0.000926208,
|
||||
-0.000914552,
|
||||
-0.00090209,
|
||||
-0.000888816,
|
||||
-0.000874721,
|
||||
-0.0008598,
|
||||
-0.000844046,
|
||||
-0.000827453,
|
||||
-0.000810015,
|
||||
-0.000791726,
|
||||
-0.000772581,
|
||||
-0.000752576,
|
||||
-0.000731704,
|
||||
-0.000709965,
|
||||
-0.00068735,
|
||||
-0.000663865,
|
||||
-0.000639509,
|
||||
-0.000614269,
|
||||
-0.000588146,
|
||||
-0.000561139,
|
||||
-0.000533246,
|
||||
-0.000504468,
|
||||
-0.000474802,
|
||||
-0.000444251,
|
||||
-0.000412813,
|
||||
-0.00038049,
|
||||
-0.000347281,
|
||||
-0.000313189,
|
||||
-0.000278215,
|
||||
-0.000242361,
|
||||
-0.000205629,
|
||||
-0.000168024,
|
||||
-0.000129546,
|
||||
-9.02024e-05,
|
||||
-4.99954e-05,
|
||||
-8.93026e-06,
|
||||
3.2988e-05,
|
||||
7.57537e-05,
|
||||
0.000119361,
|
||||
0.000163804,
|
||||
0.000209075,
|
||||
0.000255167,
|
||||
0.000302074,
|
||||
0.000349786,
|
||||
0.000398297,
|
||||
0.000447596,
|
||||
0.000497676,
|
||||
0.000548526,
|
||||
0.000600136,
|
||||
0.000652497,
|
||||
0.000705598,
|
||||
0.000759427,
|
||||
0.000813972,
|
||||
0.000869223,
|
||||
0.000925166,
|
||||
0.000981789,
|
||||
0.00103908,
|
||||
0.00109702,
|
||||
0.00115561,
|
||||
0.00121482,
|
||||
0.00127464,
|
||||
0.00133505,
|
||||
0.00139605,
|
||||
0.00145762,
|
||||
0.00151973,
|
||||
0.00158238,
|
||||
0.00164555,
|
||||
0.00170922,
|
||||
0.00177337,
|
||||
0.00183799,
|
||||
0.00190305,
|
||||
0.00196854,
|
||||
0.00203445,
|
||||
0.00210075,
|
||||
0.00216742,
|
||||
0.00223445,
|
||||
0.00230181,
|
||||
0.00236949,
|
||||
0.00243747,
|
||||
0.00250572,
|
||||
0.00257423,
|
||||
0.00264296,
|
||||
0.00271192,
|
||||
0.00278107,
|
||||
0.00285039,
|
||||
0.00291986,
|
||||
0.00298947,
|
||||
0.00305918,
|
||||
0.00312898,
|
||||
0.00319884,
|
||||
0.00326874,
|
||||
0.00333866,
|
||||
0.00340857,
|
||||
0.00347846,
|
||||
0.00354831,
|
||||
0.00361808,
|
||||
0.00368775,
|
||||
0.00375731,
|
||||
0.00382673,
|
||||
0.00389599,
|
||||
0.00396506,
|
||||
0.00403393,
|
||||
0.00410256,
|
||||
0.00417094,
|
||||
0.00423904,
|
||||
0.00430684,
|
||||
0.00437431,
|
||||
0.00444144,
|
||||
0.0045082,
|
||||
0.00457457,
|
||||
0.00464052,
|
||||
0.00470603,
|
||||
0.00477108,
|
||||
0.00483565,
|
||||
0.00489972,
|
||||
0.00496325,
|
||||
0.00502623,
|
||||
0.00508865,
|
||||
0.00515046,
|
||||
0.00521166,
|
||||
0.00527223,
|
||||
0.00533213,
|
||||
0.00539135,
|
||||
0.00544987,
|
||||
0.00550766,
|
||||
0.00556472,
|
||||
0.005621,
|
||||
0.00567651,
|
||||
0.00573121,
|
||||
0.00578508,
|
||||
0.00583811,
|
||||
0.00589028,
|
||||
0.00594157,
|
||||
0.00599196,
|
||||
0.00604143,
|
||||
0.00608996,
|
||||
0.00613754,
|
||||
0.00618415,
|
||||
0.00622977,
|
||||
0.00627439,
|
||||
0.00631798,
|
||||
0.00636054,
|
||||
0.00640204,
|
||||
0.0064425,
|
||||
0.00648186,
|
||||
0.00652009,
|
||||
0.00655722,
|
||||
0.00659322,
|
||||
0.00662808,
|
||||
0.00666179,
|
||||
0.00669433,
|
||||
0.00672571,
|
||||
0.00675589,
|
||||
0.00678488,
|
||||
0.00681266,
|
||||
0.00683921,
|
||||
0.00686454,
|
||||
0.00688863,
|
||||
0.00691147,
|
||||
0.00693305,
|
||||
0.00695336,
|
||||
0.0069724,
|
||||
0.00699016,
|
||||
0.00700663,
|
||||
0.00702181,
|
||||
0.00703569,
|
||||
0.00704826,
|
||||
0.00705952,
|
||||
0.00706947,
|
||||
0.00707809,
|
||||
0.0070854,
|
||||
0.00709138,
|
||||
0.00709604,
|
||||
0.00709937,
|
||||
0.00710136,
|
||||
0.00710203,
|
||||
0.00710136,
|
||||
0.00709937,
|
||||
0.00709604,
|
||||
0.00709138,
|
||||
0.0070854,
|
||||
0.00707809,
|
||||
0.00706947,
|
||||
0.00705952,
|
||||
0.00704826,
|
||||
0.00703569,
|
||||
0.00702181,
|
||||
0.00700663,
|
||||
0.00699016,
|
||||
0.0069724,
|
||||
0.00695336,
|
||||
0.00693305,
|
||||
0.00691147,
|
||||
0.00688863,
|
||||
0.00686454,
|
||||
0.00683921,
|
||||
0.00681266,
|
||||
0.00678488,
|
||||
0.00675589,
|
||||
0.00672571,
|
||||
0.00669433,
|
||||
0.00666179,
|
||||
0.00662808,
|
||||
0.00659322,
|
||||
0.00655722,
|
||||
0.00652009,
|
||||
0.00648186,
|
||||
0.0064425,
|
||||
0.00640204,
|
||||
0.00636054,
|
||||
0.00631798,
|
||||
0.00627439,
|
||||
0.00622977,
|
||||
0.00618415,
|
||||
0.00613754,
|
||||
0.00608996,
|
||||
0.00604143,
|
||||
0.00599196,
|
||||
0.00594157,
|
||||
0.00589028,
|
||||
0.00583811,
|
||||
0.00578508,
|
||||
0.00573121,
|
||||
0.00567651,
|
||||
0.005621,
|
||||
0.00556472,
|
||||
0.00550766,
|
||||
0.00544987,
|
||||
0.00539135,
|
||||
0.00533213,
|
||||
0.00527223,
|
||||
0.00521166,
|
||||
0.00515046,
|
||||
0.00508865,
|
||||
0.00502623,
|
||||
0.00496325,
|
||||
0.00489972,
|
||||
0.00483565,
|
||||
0.00477108,
|
||||
0.00470603,
|
||||
0.00464052,
|
||||
0.00457457,
|
||||
0.0045082,
|
||||
0.00444144,
|
||||
0.00437431,
|
||||
0.00430684,
|
||||
0.00423904,
|
||||
0.00417094,
|
||||
0.00410256,
|
||||
0.00403393,
|
||||
0.00396506,
|
||||
0.00389599,
|
||||
0.00382673,
|
||||
0.00375731,
|
||||
0.00368775,
|
||||
0.00361808,
|
||||
0.00354831,
|
||||
0.00347846,
|
||||
0.00340857,
|
||||
0.00333866,
|
||||
0.00326874,
|
||||
0.00319884,
|
||||
0.00312898,
|
||||
0.00305918,
|
||||
0.00298947,
|
||||
0.00291986,
|
||||
0.00285039,
|
||||
0.00278107,
|
||||
0.00271192,
|
||||
0.00264296,
|
||||
0.00257423,
|
||||
0.00250572,
|
||||
0.00243747,
|
||||
0.00236949,
|
||||
0.00230181,
|
||||
0.00223445,
|
||||
0.00216742,
|
||||
0.00210075,
|
||||
0.00203445,
|
||||
0.00196854,
|
||||
0.00190305,
|
||||
0.00183799,
|
||||
0.00177337,
|
||||
0.00170922,
|
||||
0.00164555,
|
||||
0.00158238,
|
||||
0.00151973,
|
||||
0.00145762,
|
||||
0.00139605,
|
||||
0.00133505,
|
||||
0.00127464,
|
||||
0.00121482,
|
||||
0.00115561,
|
||||
0.00109702,
|
||||
0.00103908,
|
||||
0.000981789,
|
||||
0.000925166,
|
||||
0.000869223,
|
||||
0.000813972,
|
||||
0.000759427,
|
||||
0.000705598,
|
||||
0.000652497,
|
||||
0.000600136,
|
||||
0.000548526,
|
||||
0.000497676,
|
||||
0.000447596,
|
||||
0.000398297,
|
||||
0.000349786,
|
||||
0.000302074,
|
||||
0.000255167,
|
||||
0.000209075,
|
||||
0.000163804,
|
||||
0.000119361,
|
||||
7.57537e-05,
|
||||
3.2988e-05,
|
||||
-8.93026e-06,
|
||||
-4.99954e-05,
|
||||
-9.02024e-05,
|
||||
-0.000129546,
|
||||
-0.000168024,
|
||||
-0.000205629,
|
||||
-0.000242361,
|
||||
-0.000278215,
|
||||
-0.000313189,
|
||||
-0.000347281,
|
||||
-0.00038049,
|
||||
-0.000412813,
|
||||
-0.000444251,
|
||||
-0.000474802,
|
||||
-0.000504468,
|
||||
-0.000533246,
|
||||
-0.000561139,
|
||||
-0.000588146,
|
||||
-0.000614269,
|
||||
-0.000639509,
|
||||
-0.000663865,
|
||||
-0.00068735,
|
||||
-0.000709965,
|
||||
-0.000731704,
|
||||
-0.000752576,
|
||||
-0.000772581,
|
||||
-0.000791726,
|
||||
-0.000810015,
|
||||
-0.000827453,
|
||||
-0.000844046,
|
||||
-0.0008598,
|
||||
-0.000874721,
|
||||
-0.000888816,
|
||||
-0.00090209,
|
||||
-0.000914552,
|
||||
-0.000926208,
|
||||
-0.000937065,
|
||||
-0.000947131,
|
||||
-0.000956415,
|
||||
-0.000964925,
|
||||
-0.000972668,
|
||||
-0.000979654,
|
||||
-0.000985892,
|
||||
-0.000991392,
|
||||
-0.000996162,
|
||||
-0.00100021,
|
||||
-0.00100356,
|
||||
-0.0010062,
|
||||
-0.00100816,
|
||||
-0.00100943,
|
||||
-0.00101005,
|
||||
-0.00101,
|
||||
-0.00100932,
|
||||
-0.001008,
|
||||
-0.00100606,
|
||||
-0.00100351,
|
||||
-0.00100036,
|
||||
-0.000996634,
|
||||
-0.000992332,
|
||||
-0.00098747,
|
||||
-0.000982062,
|
||||
-0.000976119,
|
||||
-0.000969654,
|
||||
-0.000962682,
|
||||
-0.000955214,
|
||||
-0.000947263,
|
||||
-0.000938844,
|
||||
-0.00092997,
|
||||
-0.000920652,
|
||||
-0.000910906,
|
||||
-0.000900744,
|
||||
-0.00089018,
|
||||
-0.000879227,
|
||||
-0.000867898,
|
||||
-0.000856207,
|
||||
-0.000844168,
|
||||
-0.000831793,
|
||||
-0.000819098,
|
||||
-0.000806094,
|
||||
-0.000792798,
|
||||
-0.000779217,
|
||||
-0.000765372,
|
||||
-0.000751266,
|
||||
-0.000736922,
|
||||
-0.00072229,
|
||||
-0.000707464,
|
||||
-0.000692506,
|
||||
-0.000677361,
|
||||
-0.000662049,
|
||||
-0.000646575,
|
||||
-0.000630955,
|
||||
-0.000615196,
|
||||
-0.000599314,
|
||||
-0.000583319,
|
||||
-0.000567225,
|
||||
-0.000551043,
|
||||
-0.000534785,
|
||||
-0.000518464,
|
||||
-0.000502091,
|
||||
-0.00048568,
|
||||
-0.00046924,
|
||||
-0.000452784,
|
||||
-0.000436324,
|
||||
-0.00041987,
|
||||
-0.000403434,
|
||||
-0.000387027,
|
||||
-0.00037066,
|
||||
-0.000354342,
|
||||
-0.000338084,
|
||||
-0.000321898,
|
||||
-0.000305792,
|
||||
-0.000289776,
|
||||
-0.000273861,
|
||||
-0.000258056,
|
||||
-0.000242369,
|
||||
-0.000226811,
|
||||
-0.00021139,
|
||||
-0.000196115,
|
||||
-0.000180995,
|
||||
-0.000166036,
|
||||
-0.000151248,
|
||||
-0.000136638,
|
||||
-0.000122213,
|
||||
-0.000107981,
|
||||
-9.39481e-05,
|
||||
-8.01218e-05,
|
||||
-6.65082e-05,
|
||||
-5.31139e-05,
|
||||
-3.99444e-05,
|
||||
-2.70061e-05,
|
||||
-1.43041e-05,
|
||||
-1.844e-06,
|
||||
1.03695e-05,
|
||||
2.23311e-05,
|
||||
3.40369e-05,
|
||||
4.54822e-05,
|
||||
5.66636e-05,
|
||||
6.7577e-05,
|
||||
7.82196e-05,
|
||||
8.85877e-05,
|
||||
9.8679e-05,
|
||||
0.000108491,
|
||||
0.00011802,
|
||||
0.000127266,
|
||||
0.000136224,
|
||||
0.000144895,
|
||||
0.000153275,
|
||||
0.000161363,
|
||||
0.000169145,
|
||||
0.000176621,
|
||||
0.000183812,
|
||||
0.000190706,
|
||||
0.000197304,
|
||||
0.000203605,
|
||||
0.000209608,
|
||||
0.000215314,
|
||||
0.000220723,
|
||||
0.000225837,
|
||||
0.000230655,
|
||||
0.00023518,
|
||||
0.000239412,
|
||||
0.000243354,
|
||||
0.000247007,
|
||||
0.000250373,
|
||||
0.000253453,
|
||||
0.000256251,
|
||||
0.000258767,
|
||||
0.000261006,
|
||||
0.000262968,
|
||||
0.000264658,
|
||||
0.000266079,
|
||||
0.000267232,
|
||||
0.000268123,
|
||||
0.000268754,
|
||||
0.000269129,
|
||||
0.000269253,
|
||||
0.000269128,
|
||||
0.00026876,
|
||||
0.000268152,
|
||||
0.000267308,
|
||||
0.000266234,
|
||||
0.000264933,
|
||||
0.000263411,
|
||||
0.000261672,
|
||||
0.000259721,
|
||||
0.000257562,
|
||||
0.000255202,
|
||||
0.000252644,
|
||||
0.000249895,
|
||||
0.000246959,
|
||||
0.000243843,
|
||||
0.000240551,
|
||||
0.000237089,
|
||||
0.000233463,
|
||||
0.000229678,
|
||||
0.00022574,
|
||||
0.000221654,
|
||||
0.000217426,
|
||||
0.000213063,
|
||||
0.000208568,
|
||||
0.000203949,
|
||||
0.000199211,
|
||||
0.00019436,
|
||||
0.0001894,
|
||||
0.00018434,
|
||||
0.000179183,
|
||||
0.000173938,
|
||||
0.000168608,
|
||||
0.000163202,
|
||||
0.000157725,
|
||||
0.000152183,
|
||||
0.000146583,
|
||||
0.000140929,
|
||||
0.000135218,
|
||||
0.000129468,
|
||||
0.000123681,
|
||||
0.000117864,
|
||||
0.00011202,
|
||||
0.000106157,
|
||||
0.000100278,
|
||||
9.43895e-05,
|
||||
8.84957e-05,
|
||||
8.26029e-05,
|
||||
7.67152e-05,
|
||||
7.08393e-05,
|
||||
6.49787e-05,
|
||||
5.91403e-05,
|
||||
5.33273e-05,
|
||||
4.75467e-05,
|
||||
4.18011e-05,
|
||||
3.60975e-05,
|
||||
3.04382e-05,
|
||||
2.483e-05,
|
||||
1.9275e-05,
|
||||
1.37796e-05,
|
||||
8.34567e-06,
|
||||
2.97965e-06,
|
||||
-2.31702e-06,
|
||||
-7.53795e-06,
|
||||
-1.2682e-05,
|
||||
-1.77428e-05,
|
||||
-2.27195e-05,
|
||||
-2.7606e-05,
|
||||
-3.24015e-05,
|
||||
-3.71002e-05,
|
||||
-4.17016e-05,
|
||||
-4.62001e-05,
|
||||
-5.05954e-05,
|
||||
-5.48823e-05,
|
||||
-5.90607e-05,
|
||||
-6.31256e-05,
|
||||
-6.70773e-05,
|
||||
-7.09109e-05,
|
||||
-7.46271e-05,
|
||||
-7.82211e-05,
|
||||
-8.16936e-05,
|
||||
-8.50404e-05,
|
||||
-8.82623e-05,
|
||||
-9.13551e-05,
|
||||
-9.43199e-05,
|
||||
-9.71528e-05,
|
||||
-9.98553e-05,
|
||||
-0.000102424,
|
||||
-0.00010486,
|
||||
-0.00010716,
|
||||
-0.000109326,
|
||||
-0.000111356,
|
||||
-0.000113251,
|
||||
-0.000115009,
|
||||
-0.000116633,
|
||||
-0.000118119,
|
||||
-0.000119471,
|
||||
-0.000120685,
|
||||
-0.000121766,
|
||||
-0.000122709,
|
||||
-0.000123518,
|
||||
-0.000124185,
|
||||
-0.000124729,
|
||||
-0.000125145,
|
||||
-0.000125428,
|
||||
-0.000125578,
|
||||
-0.000125598,
|
||||
-0.000125487,
|
||||
-0.00012525,
|
||||
-0.000124884,
|
||||
-0.000124397,
|
||||
-0.000123784,
|
||||
-0.000123053,
|
||||
-0.000122201,
|
||||
-0.000121235,
|
||||
-0.000120152,
|
||||
-0.000118959,
|
||||
-0.000117652,
|
||||
-0.000116241,
|
||||
-0.00011472,
|
||||
-0.000113099,
|
||||
-0.000111372,
|
||||
-0.00010955,
|
||||
-0.000107627,
|
||||
-0.000105614,
|
||||
-0.000103505,
|
||||
-0.000101311,
|
||||
-9.9026e-05,
|
||||
-9.66619e-05,
|
||||
-9.42119e-05,
|
||||
-9.16888e-05,
|
||||
-8.9085e-05,
|
||||
-8.64141e-05,
|
||||
-8.36678e-05,
|
||||
-8.08605e-05,
|
||||
-7.7983e-05,
|
||||
-7.50509e-05,
|
||||
-7.20538e-05,
|
||||
-6.90085e-05,
|
||||
-6.59032e-05,
|
||||
-6.27565e-05,
|
||||
-5.95548e-05,
|
||||
-5.63184e-05,
|
||||
-5.3032e-05,
|
||||
-4.97179e-05,
|
||||
-4.63581e-05,
|
||||
-4.29778e-05,
|
||||
-3.95556e-05,
|
||||
-3.61199e-05,
|
||||
-3.26453e-05,
|
||||
-2.91642e-05,
|
||||
-2.56455e-05,
|
||||
-2.21275e-05,
|
||||
-1.85712e-05,
|
||||
-1.50227e-05,
|
||||
-1.14317e-05,
|
||||
-7.85603e-06,
|
||||
-4.22748e-06,
|
||||
-6.22187e-07,
|
||||
3.05918e-06,
|
||||
6.70859e-06,
|
||||
1.04905e-05,
|
||||
1.42303e-05,
|
||||
1.82863e-05,
|
||||
2.2286e-05
|
||||
};
|
||||
@@ -10,9 +10,13 @@
|
||||
|
||||
../src/c2sim ../raw/$1.raw -o $1_uq.raw
|
||||
../src/c2sim ../raw/$1.raw --phase0 -o $1_phase0.raw --postfilter
|
||||
../src/c2sim ../raw/$1.raw --lpc 10 -o $1_lpc10.raw
|
||||
../src/c2sim ../raw/$1.raw --lpc 10 --lsp -o $1_lsp.raw
|
||||
../src/c2sim ../raw/$1.raw --lpc 10 -o $1_lpc10.raw --postfilter
|
||||
../src/c2sim ../raw/$1.raw --phase0 --lpc 10 -o $1_phase0_lpc10.raw --postfilter
|
||||
../src/c2sim ../raw/$1.raw --phase0 --lpc 10 --lsp -o $1_phase0_lsp.raw --postfilter
|
||||
../src/c2sim ../raw/$1.raw --phase0 --lpc 10 --lsp -o $1_phase0_lsp_dec.raw --postfilter --dec
|
||||
../src/c2sim ../raw/$1.raw --phase0 --lpc 10 --dec -o $1_phase0_lpc10_dec.raw --postfilter
|
||||
../src/c2sim ../raw/$1.raw --phase0 --lpc 10 --lsp --dec -o $1_phase0_lsp_dec.raw --postfilter
|
||||
|
||||
#../src/c2sim ../raw/$1.raw --lpc 10 --lsp -o $1_lsp.raw
|
||||
#../src/c2sim ../raw/$1.raw --phase0 --lpc 10 -o $1_phase0_lpc10.raw --postfilter
|
||||
#../src/c2sim ../raw/$1.raw --phase0 --lpc 10 --lsp -o $1_phase0_lsp.raw --postfilter
|
||||
#../src/c2sim ../raw/$1.raw --phase0 --lpc 10 --lsp -o $1_phase0_lsp_dec.raw --postfilter --dec
|
||||
|
||||
|
||||
+163
-45
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@@ -38,7 +37,9 @@
|
||||
|
||||
#include "defines.h"
|
||||
#include "sine.h"
|
||||
#include "four1.h"
|
||||
#include "kiss_fft.h"
|
||||
|
||||
#define HPF_BETA 0.125
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
@@ -65,9 +66,10 @@ void hs_pitch_refinement(MODEL *model, COMP Sw[], float pmin, float pmax,
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void make_analysis_window(float w[],COMP W[])
|
||||
void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[])
|
||||
{
|
||||
float m;
|
||||
COMP wshift[FFT_ENC];
|
||||
COMP temp;
|
||||
int i,j;
|
||||
|
||||
@@ -122,15 +124,15 @@ void make_analysis_window(float w[],COMP W[])
|
||||
*/
|
||||
|
||||
for(i=0; i<FFT_ENC; i++) {
|
||||
W[i].real = 0.0;
|
||||
W[i].imag = 0.0;
|
||||
wshift[i].real = 0.0;
|
||||
wshift[i].imag = 0.0;
|
||||
}
|
||||
for(i=0; i<NW/2; i++)
|
||||
W[i].real = w[i+M/2];
|
||||
wshift[i].real = w[i+M/2];
|
||||
for(i=FFT_ENC-NW/2,j=M/2-NW/2; i<FFT_ENC; i++,j++)
|
||||
W[i].real = w[j];
|
||||
wshift[i].real = w[j];
|
||||
|
||||
four1(&W[-1].imag,FFT_ENC,-1); /* "Numerical Recipes in C" FFT */
|
||||
kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)wshift, (kiss_fft_cpx *)W);
|
||||
|
||||
/*
|
||||
Re-arrange W[] to be symmetrical about FFT_ENC/2. Makes later
|
||||
@@ -167,6 +169,26 @@ void make_analysis_window(float w[],COMP W[])
|
||||
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: hpf
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 16 Nov 2010
|
||||
|
||||
High pass filter with a -3dB point of about 160Hz.
|
||||
|
||||
y(n) = -HPF_BETA*y(n-1) + x(n) - x(n-1)
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
float hpf(float x, float states[])
|
||||
{
|
||||
states[0] += -HPF_BETA*states[0] + x - states[1];
|
||||
states[1] = x;
|
||||
|
||||
return states[0];
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FUNCTION....: dft_speech
|
||||
@@ -177,13 +199,14 @@ void make_analysis_window(float w[],COMP W[])
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void dft_speech(COMP Sw[], float Sn[], float w[])
|
||||
void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[])
|
||||
{
|
||||
int i;
|
||||
|
||||
int i;
|
||||
COMP sw[FFT_ENC];
|
||||
|
||||
for(i=0; i<FFT_ENC; i++) {
|
||||
Sw[i].real = 0.0;
|
||||
Sw[i].imag = 0.0;
|
||||
sw[i].real = 0.0;
|
||||
sw[i].imag = 0.0;
|
||||
}
|
||||
|
||||
/* Centre analysis window on time axis, we need to arrange input
|
||||
@@ -192,14 +215,14 @@ void dft_speech(COMP Sw[], float Sn[], float w[])
|
||||
/* move 2nd half to start of FFT input vector */
|
||||
|
||||
for(i=0; i<NW/2; i++)
|
||||
Sw[i].real = Sn[i+M/2]*w[i+M/2];
|
||||
sw[i].real = Sn[i+M/2]*w[i+M/2];
|
||||
|
||||
/* move 1st half to end of FFT input vector */
|
||||
|
||||
for(i=0; i<NW/2; i++)
|
||||
Sw[FFT_ENC-NW/2+i].real = Sn[i+M/2-NW/2]*w[i+M/2-NW/2];
|
||||
sw[FFT_ENC-NW/2+i].real = Sn[i+M/2-NW/2]*w[i+M/2-NW/2];
|
||||
|
||||
four1(&Sw[-1].imag,FFT_ENC,-1);
|
||||
kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)sw, (kiss_fft_cpx *)Sw);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@@ -362,38 +385,38 @@ float est_voicing_mbe(
|
||||
MODEL *model,
|
||||
COMP Sw[],
|
||||
COMP W[],
|
||||
float f0,
|
||||
COMP Sw_[] /* DFT of all voiced synthesised signal for f0 */
|
||||
/* useful for debugging/dump file */
|
||||
)
|
||||
COMP Sw_[], /* DFT of all voiced synthesised signal */
|
||||
/* useful for debugging/dump file */
|
||||
COMP Ew[], /* DFT of error */
|
||||
float prev_Wo)
|
||||
{
|
||||
int i,l,al,bl,m; /* loop variables */
|
||||
COMP Am; /* amplitude sample for this band */
|
||||
int offset; /* centers Hw[] about current harmonic */
|
||||
float den; /* denominator of Am expression */
|
||||
float error; /* accumulated error between originl and synthesised */
|
||||
float Wo; /* current "test" fundamental freq. */
|
||||
int L;
|
||||
float error; /* accumulated error between original and synthesised */
|
||||
float Wo;
|
||||
float sig, snr;
|
||||
float elow, ehigh, eratio;
|
||||
float dF0, sixty;
|
||||
|
||||
sig = 0.0;
|
||||
sig = 1E-4;
|
||||
for(l=1; l<=model->L/4; l++) {
|
||||
sig += model->A[l]*model->A[l];
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_ENC; i++) {
|
||||
Sw_[i].real = 0.0;
|
||||
Sw_[i].imag = 0.0;
|
||||
Ew[i].real = 0.0;
|
||||
Ew[i].imag = 0.0;
|
||||
}
|
||||
|
||||
L = floor((FS/2.0)/f0);
|
||||
Wo = f0*(TWO_PI/FS);
|
||||
|
||||
error = 0.0;
|
||||
Wo = model->Wo;
|
||||
error = 1E-4;
|
||||
|
||||
/* Just test across the harmonics in the first 1000 Hz (L/4) */
|
||||
|
||||
for(l=1; l<=L/4; l++) {
|
||||
for(l=1; l<=model->L/4; l++) {
|
||||
Am.real = 0.0;
|
||||
Am.imag = 0.0;
|
||||
den = 0.0;
|
||||
@@ -418,16 +441,73 @@ float est_voicing_mbe(
|
||||
offset = FFT_ENC/2 + m - l*Wo*FFT_ENC/TWO_PI + 0.5;
|
||||
Sw_[m].real = Am.real*W[offset].real - Am.imag*W[offset].imag;
|
||||
Sw_[m].imag = Am.real*W[offset].imag + Am.imag*W[offset].real;
|
||||
error += (Sw[m].real - Sw_[m].real)*(Sw[m].real - Sw_[m].real);
|
||||
error += (Sw[m].imag - Sw_[m].imag)*(Sw[m].imag - Sw_[m].imag);
|
||||
Ew[m].real = Sw[m].real - Sw_[m].real;
|
||||
Ew[m].imag = Sw[m].imag - Sw_[m].imag;
|
||||
error += Ew[m].real*Ew[m].real;
|
||||
error += Ew[m].imag*Ew[m].imag;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
snr = 10.0*log10(sig/error);
|
||||
if (snr > V_THRESH)
|
||||
model->voiced = 1;
|
||||
else
|
||||
model->voiced = 0;
|
||||
|
||||
/* post processing, helps clean up some voicing errors ------------------*/
|
||||
|
||||
/*
|
||||
Determine the ratio of low freqency to high frequency energy,
|
||||
voiced speech tends to be dominated by low frequency energy,
|
||||
unvoiced by high frequency. This measure can be used to
|
||||
determine if we have made any gross errors.
|
||||
*/
|
||||
|
||||
elow = ehigh = 1E-4;
|
||||
for(l=1; l<=model->L/2; l++) {
|
||||
elow += model->A[l]*model->A[l];
|
||||
}
|
||||
for(l=model->L/2; l<=model->L; l++) {
|
||||
ehigh += model->A[l]*model->A[l];
|
||||
}
|
||||
eratio = 10.0*log10(elow/ehigh);
|
||||
dF0 = 0.0;
|
||||
|
||||
/* Look for Type 1 errors, strongly V speech that has been
|
||||
accidentally declared UV */
|
||||
|
||||
if (model->voiced == 0)
|
||||
if (eratio > 10.0)
|
||||
model->voiced = 1;
|
||||
|
||||
/* Look for Type 2 errors, strongly UV speech that has been
|
||||
accidentally declared V */
|
||||
|
||||
if (model->voiced == 1) {
|
||||
if (eratio < -10.0)
|
||||
model->voiced = 0;
|
||||
|
||||
/* If pitch is jumping about it's likely this is UV */
|
||||
|
||||
/* 13 Feb 2012 - this seems to add some V errors so comment out for now. Maybe
|
||||
double check on bg noise files
|
||||
|
||||
dF0 = (model->Wo - prev_Wo)*FS/TWO_PI;
|
||||
if (fabs(dF0) > 15.0)
|
||||
model->voiced = 0;
|
||||
*/
|
||||
|
||||
/* A common source of Type 2 errors is the pitch estimator
|
||||
gives a low (50Hz) estimate for UV speech, which gives a
|
||||
good match with noise due to the close harmoonic spacing.
|
||||
These errors are much more common than people with 50Hz3
|
||||
pitch, so we have just a small eratio threshold. */
|
||||
|
||||
sixty = 60.0*TWO_PI/FS;
|
||||
if ((eratio < -4.0) && (model->Wo <= sixty))
|
||||
model->voiced = 0;
|
||||
}
|
||||
//printf(" v: %d snr: %f eratio: %3.2f %f\n",model->voiced,snr,eratio,dF0);
|
||||
|
||||
return snr;
|
||||
}
|
||||
@@ -471,20 +551,22 @@ void make_synthesis_window(float Pn[])
|
||||
DATE CREATED: 20/2/95
|
||||
|
||||
Synthesise a speech signal in the frequency domain from the
|
||||
sinusodal model parameters. Uses overlap-add a triangular window to
|
||||
smoothly interpolate betwen frames.
|
||||
sinusodal model parameters. Uses overlap-add with a trapezoidal
|
||||
window to smoothly interpolate betwen frames.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
void synthesise(
|
||||
float Sn_[], /* time domain synthesised signal */
|
||||
MODEL *model, /* ptr to model parameters for this frame */
|
||||
float Pn[], /* time domain Parzen window */
|
||||
int shift /* used to handle transition frames */
|
||||
kiss_fft_cfg fft_inv_cfg,
|
||||
float Sn_[], /* time domain synthesised signal */
|
||||
MODEL *model, /* ptr to model parameters for this frame */
|
||||
float Pn[], /* time domain Parzen window */
|
||||
int shift /* flag used to handle transition frames */
|
||||
)
|
||||
{
|
||||
int i,l,j,b; /* loop variables */
|
||||
COMP Sw_[FFT_DEC]; /* DFT of synthesised signal */
|
||||
COMP sw_[FFT_DEC]; /* synthesised signal */
|
||||
|
||||
if (shift) {
|
||||
/* Update memories */
|
||||
@@ -500,10 +582,30 @@ void synthesise(
|
||||
Sw_[i].imag = 0.0;
|
||||
}
|
||||
|
||||
/* Now set up frequency domain synthesised speech */
|
||||
/*
|
||||
Nov 2010 - found that synthesis using time domain cos() functions
|
||||
gives better results for synthesis frames greater than 10ms. Inverse
|
||||
FFT synthesis using a 512 pt FFT works well for 10ms window. I think
|
||||
(but am not sure) that the problem is related to the quantisation of
|
||||
the harmonic frequencies to the FFT bin size, e.g. there is a
|
||||
8000/512 Hz step between FFT bins. For some reason this makes
|
||||
the speech from longer frame > 10ms sound poor. The effect can also
|
||||
be seen when synthesising test signals like single sine waves, some
|
||||
sort of amplitude modulation at the frame rate.
|
||||
|
||||
Another possibility is using a larger FFT size (1024 or 2048).
|
||||
*/
|
||||
|
||||
#define FFT_SYNTHESIS
|
||||
#ifdef FFT_SYNTHESIS
|
||||
/* Now set up frequency domain synthesised speech */
|
||||
for(l=1; l<=model->L; l++) {
|
||||
//for(l=model->L/2; l<=model->L; l++) {
|
||||
//for(l=1; l<=model->L/4; l++) {
|
||||
b = floor(l*model->Wo*FFT_DEC/TWO_PI + 0.5);
|
||||
if (b > ((FFT_DEC/2)-1)) {
|
||||
b = (FFT_DEC/2)-1;
|
||||
}
|
||||
Sw_[b].real = model->A[l]*cos(model->phi[l]);
|
||||
Sw_[b].imag = model->A[l]*sin(model->phi[l]);
|
||||
Sw_[FFT_DEC-b].real = Sw_[b].real;
|
||||
@@ -512,19 +614,35 @@ void synthesise(
|
||||
|
||||
/* Perform inverse DFT */
|
||||
|
||||
four1(&Sw_[-1].imag,FFT_DEC,1);
|
||||
kiss_fft(fft_inv_cfg, (kiss_fft_cpx *)Sw_, (kiss_fft_cpx *)sw_);
|
||||
#else
|
||||
/*
|
||||
Direct time domain synthesis using the cos() function. Works
|
||||
well at 10ms and 20ms frames rates. Note synthesis window is
|
||||
still used to handle overlap-add between adjacent frames. This
|
||||
could be simplified as we don't need to synthesise where Pn[]
|
||||
is zero.
|
||||
*/
|
||||
for(l=1; l<=model->L; l++) {
|
||||
for(i=0,j=-N+1; i<N-1; i++,j++) {
|
||||
Sw_[FFT_DEC-N+1+i].real += 2.0*model->A[l]*cos(j*model->Wo*l + model->phi[l]);
|
||||
}
|
||||
for(i=N-1,j=0; i<2*N; i++,j++)
|
||||
Sw_[j].real += 2.0*model->A[l]*cos(j*model->Wo*l + model->phi[l]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Overlap add to previous samples */
|
||||
|
||||
for(i=0; i<N-1; i++) {
|
||||
Sn_[i] += Sw_[FFT_DEC-N+1+i].real*Pn[i];
|
||||
Sn_[i] += sw_[FFT_DEC-N+1+i].real*Pn[i];
|
||||
}
|
||||
|
||||
if (shift)
|
||||
for(i=N-1,j=0; i<2*N; i++,j++)
|
||||
Sn_[i] = Sw_[j].real*Pn[i];
|
||||
Sn_[i] = sw_[j].real*Pn[i];
|
||||
else
|
||||
for(i=N-1,j=0; i<2*N; i++,j++)
|
||||
Sn_[i] += Sw_[j].real*Pn[i];
|
||||
Sn_[i] += sw_[j].real*Pn[i];
|
||||
}
|
||||
|
||||
|
||||
@@ -22,19 +22,24 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SINE__
|
||||
#define __SINE__
|
||||
|
||||
void make_analysis_window(float w[], COMP W[]);
|
||||
void dft_speech(COMP Sw[], float Sn[], float w[]);
|
||||
#include "defines.h"
|
||||
#include "comp.h"
|
||||
#include "kiss_fft.h"
|
||||
|
||||
void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[]);
|
||||
float hpf(float x, float states[]);
|
||||
void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[]);
|
||||
void two_stage_pitch_refinement(MODEL *model, COMP Sw[]);
|
||||
void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[]);
|
||||
float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], float f0, COMP Sw_[]);
|
||||
float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[],
|
||||
float prev_Wo);
|
||||
void make_synthesis_window(float Pn[]);
|
||||
void synthesise(float Sn_[], MODEL *model, float Pn[], int shift);
|
||||
void synthesise(kiss_fft_cfg fft_inv_cfg, float Sn_[], MODEL *model, float Pn[], int shift);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/* Generated by test_bits_file() Octave function */
|
||||
|
||||
const int test_bits[]={
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0
|
||||
};
|
||||
@@ -1,41 +1,105 @@
|
||||
AM_CFLAGS = -I../src -g -DFLOATING_POINT -DVAR_ARRAYS
|
||||
AUTOMAKE_OPTIONS = gnu
|
||||
AM_CFLAGS = -I../src -fPIC -g -DFLOATING_POINT -DVAR_ARRAYS -O2 -Wall
|
||||
AUTOMAKE_OPTS = gnu
|
||||
NAME = libcodec2
|
||||
AM_CPPFLAGS = $(AM_CFLAGS)
|
||||
|
||||
bin_PROGRAMS = genres genlsp extract vqtrain tnlp tinterp tquant tcodec2
|
||||
noinst_PROGRAMS = genres genlsp extract vqtrain vqtrainjnd tnlp tinterp tquant vq_train_jvm scalarlsptest tfdmdv t48_8 lspsync create_interleaver tlspsens vqtrainph genphdata genampdata polar2rect vqtrainsp tprede pre de tfifo
|
||||
|
||||
|
||||
genres_SOURCES = genres.c ../src/lpc.c ../src/codebook.c
|
||||
genres_SOURCES = genres.c ../src/lpc.c
|
||||
genres_LDADD = $(lib_LTLIBRARIES)
|
||||
genres_LDFLAGS = $(LIBS)
|
||||
|
||||
genlsp_SOURCES = genlsp.c ../src/lpc.c ../src/lsp.c ../src/codebook.c
|
||||
genlsp_SOURCES = genlsp.c ../src/lpc.c ../src/lsp.c
|
||||
genlsp_LDADD = $(lib_LTLIBRARIES)
|
||||
genlsp_LDFLAGS = $(LIBS)
|
||||
|
||||
extract_SOURCES = extract.c ../src/codebook.c
|
||||
extract_SOURCES = extract.c
|
||||
extract_LDADD = $(lib_LTLIBRARIES)
|
||||
extract_LDFLAGS = $(LIBS)
|
||||
|
||||
vqtrain_SOURCES = vqtrain.c ../src/codebook.c
|
||||
vqtrain_SOURCES = vqtrain.c
|
||||
vqtrain_LDADD = $(lib_LTLIBRARIES)
|
||||
vqtrain_LDFLAGS = $(LIBS)
|
||||
|
||||
tnlp_SOURCES = tnlp.c ../src/sine.c ../src/nlp.c ../src/four1.c ../src/dump.c ../src/codebook.c
|
||||
vqtrainjnd_SOURCES = vqtrainjnd.c
|
||||
vqtrainjnd_LDADD = $(lib_LTLIBRARIES)
|
||||
vqtrainjnd_LDFLAGS = $(LIBS)
|
||||
|
||||
vqtrainph_SOURCES = vqtrainph.c
|
||||
vqtrainph_LDADD = $(lib_LTLIBRARIES)
|
||||
vqtrainph_LDFLAGS = $(LIBS)
|
||||
|
||||
vqtrainsp_SOURCES = vqtrainsp.c
|
||||
vqtrainsp_LDADD = $(lib_LTLIBRARIES)
|
||||
vqtrainsp_LDFLAGS = $(LIBS)
|
||||
|
||||
genphdata_SOURCES = genphdata.c
|
||||
genphdata_LDADD = $(lib_LTLIBRARIES)
|
||||
genphdata_LDFLAGS = $(LIBS)
|
||||
|
||||
genampdata_SOURCES = genampdata.c
|
||||
genampdata_LDADD = $(lib_LTLIBRARIES)
|
||||
genampdata_LDFLAGS = $(LIBS)
|
||||
|
||||
polar2rect_SOURCES = polar2rect.c
|
||||
polar2rect_LDADD = $(lib_LTLIBRARIES)
|
||||
polar2rect_LDFLAGS = $(LIBS)
|
||||
|
||||
vq_train_jvm_SOURCES = vq_train_jvm.c
|
||||
vq_train_jvm_LDADD = $(lib_LTLIBRARIES)
|
||||
vq_train_jvm_LDFLAGS = $(LIBS)
|
||||
|
||||
CODEBOOKS = ../src/codebook.c ../src/codebookd.c ../src/codebookvq.c ../src/codebookjnd.c ../src/codebookdt.c ../src/codebookjvm.c ../src/codebookvqanssi.c ../src/codebookge.c
|
||||
|
||||
tnlp_SOURCES = tnlp.c ../src/sine.c ../src/nlp.c ../src/kiss_fft.c ../src/dump.c
|
||||
tnlp_LDADD = $(lib_LTLIBRARIES)
|
||||
tnlp_LDFLAGS = $(LIBS)
|
||||
|
||||
tinterp_SOURCES = tinterp.c ../src/sine.c ../src/four1.c ../src/interp.c ../src/codebook.c
|
||||
tinterp_SOURCES = tinterp.c ../src/sine.c ../src/kiss_fft.c ../src/interp.c ../src/lpc.c ../src/lsp.c ../src/quantise.c $(CODEBOOKS) ../src/dump.c
|
||||
tinterp_LDADD = $(lib_LTLIBRARIES)
|
||||
tinterp_LDFLAGS = $(LIBS)
|
||||
|
||||
tquant_SOURCES = tquant.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/four1.c ../src/codebook.c
|
||||
tquant_SOURCES = tquant.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c $(CODEBOOKS)
|
||||
tquant_LDADD = $(lib_LTLIBRARIES)
|
||||
tquant_LDFLAGS = $(LIBS)
|
||||
|
||||
tcodec2_SOURCES = tcodec2.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/four1.c \
|
||||
../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c ../src/codebook.c
|
||||
tcodec2_LDADD = $(lib_LTLIBRARIES)
|
||||
tcodec2_LDFLAGS = $(LIBS)
|
||||
scalarlsptest_SOURCES = scalarlsptest.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c $(CODEBOOKS)
|
||||
scalarlsptest_LDADD = $(lib_LTLIBRARIES)
|
||||
scalarlsptest_LDFLAGS = $(LIBS)
|
||||
|
||||
tfdmdv_SOURCES = tfdmdv.c ../src/fdmdv.c ../src/kiss_fft.c ../src/octave.c
|
||||
tfdmdv_LDADD = $(lib_LTLIBRARIES)
|
||||
tfdmdv_LDFLAGS = $(LIBS)
|
||||
|
||||
t48_8_SOURCES = t48_8.c ../src/fdmdv.c ../src/kiss_fft.c
|
||||
t48_8_LDADD = $(lib_LTLIBRARIES)
|
||||
t48_8_LDFLAGS = $(LIBS)
|
||||
|
||||
lspsync_SOURCES = lspsync.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c \
|
||||
../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c $(CODEBOOKS)
|
||||
lspsync_LDADD = $(lib_LTLIBRARIES)
|
||||
lspsync_LDFLAGS = $(LIBS)
|
||||
|
||||
create_interleaver_SOURCES = create_interleaver.c
|
||||
create_interleaver_LDADD = $(lib_LTLIBRARIES)
|
||||
create_interleaver_LDFLAGS = $(LIBS)
|
||||
|
||||
tlspsens_SOURCES = tlspsens.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/kiss_fft.c ../src/codec2.c ../src/sine.c ../src/nlp.c ../src/pack.c ../src/interp.c ../src/postfilter.c ../src/phase.c $(CODEBOOKS)
|
||||
tlspsens_LDADD = $(lib_LTLIBRARIES)
|
||||
tlspsens_LDFLAGS = $(LIBS)
|
||||
|
||||
tprede_SOURCES = tprede.c ../src/lpc.c
|
||||
tprede_LDADD = $(lib_LTLIBRARIES)
|
||||
tprede_LDFLAGS = $(LIBS)
|
||||
|
||||
pre_SOURCES = pre.c ../src/lpc.c
|
||||
pre_LDADD = $(lib_LTLIBRARIES)
|
||||
pre_LDFLAGS = $(LIBS)
|
||||
|
||||
de_SOURCES = de.c ../src/lpc.c
|
||||
de_LDADD = $(lib_LTLIBRARIES)
|
||||
de_LDFLAGS = $(LIBS)
|
||||
|
||||
tfifo_SOURCES = tfifo.c ../src/fifo.c
|
||||
tfifo_LDADD = $(lib_LTLIBRARIES) -lpthread
|
||||
tfifo_LDFLAGS = $(LIBS)
|
||||
|
||||
@@ -25,15 +25,16 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define MAX_STR 256 /* maximum string length */
|
||||
#define MAX_STR 2048 /* maximum string length */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
|
||||
void scan_line(FILE *fp, float f[], int n);
|
||||
|
||||
@@ -45,8 +46,8 @@ int main(int argc, char *argv[]) {
|
||||
long lines; /* lines read so far */
|
||||
|
||||
if (argc != 5) {
|
||||
printf("usage: extract TextFile FloatFile start end\n");
|
||||
exit(0);
|
||||
printf("usage: %s TextFile FloatFile start(1 .. 10) end(1 .. 10)\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* read command line arguments and open files */
|
||||
@@ -75,8 +76,10 @@ int main(int argc, char *argv[]) {
|
||||
lines = 0;
|
||||
while(!feof(ftext)) {
|
||||
scan_line(ftext, buf, en);
|
||||
fwrite(&buf[st-1], sizeof(float), en-st+1, ffloat);
|
||||
printf("\r%ld lines",lines++);
|
||||
if (!feof(ftext)) {
|
||||
fwrite(&buf[st-1], sizeof(float), en-st+1, ffloat);
|
||||
printf("\r%ld lines",++lines);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
@@ -108,9 +111,11 @@ void scan_line(FILE *fp, float f[], int n)
|
||||
char s[MAX_STR];
|
||||
char *ps,*pe;
|
||||
int i;
|
||||
|
||||
fgets(s,MAX_STR,fp);
|
||||
ps = pe = s;
|
||||
|
||||
memset(s, 0, MAX_STR);
|
||||
ps = pe = fgets(s,MAX_STR,fp);
|
||||
if (ps == NULL)
|
||||
return;
|
||||
for(i=0; i<n; i++) {
|
||||
while( isspace(*pe)) pe++;
|
||||
while( !isspace(*pe)) pe++;
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define P 10 /* LP order */
|
||||
#define LSP_DELTA1 0.05 /* grid spacing for LSP root searches */
|
||||
#define P 12 /* LP order */
|
||||
#define LSP_DELTA1 0.01 /* grid spacing for LSP root searches */
|
||||
#define NW 279 /* frame size in samples */
|
||||
#define N 80 /* frame to frame shift */
|
||||
#define THRESH 40.0 /* threshold energy/sample for frame inclusion */
|
||||
#define PI 3.141592654 /* mathematical constant */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -61,19 +61,22 @@ int main(int argc, char *argv[]) {
|
||||
float Sn[NW]; /* float input speech samples */
|
||||
float ak[P+1]; /* LPCs for current frame */
|
||||
float lsp[P]; /* LSPs for current frame */
|
||||
float lsp_prev[P]; /* LSPs for previous frame */
|
||||
float E; /* frame energy */
|
||||
long f; /* number of frames */
|
||||
long af; /* number frames with "active" speech */
|
||||
float Eres; /* LPC residual energy */
|
||||
int i;
|
||||
int roots;
|
||||
int unstables;
|
||||
int lspd;
|
||||
int lspd, log, lspdt;
|
||||
float diff;
|
||||
|
||||
/* Initialise ------------------------------------------------------*/
|
||||
|
||||
if (argc < 3) {
|
||||
printf("usage: gentest RawFile LSPTextFile [--lspd]\n");
|
||||
exit(0);
|
||||
printf("usage: %s RawFile LSPTextFile [--lspd] [--log] [--lspdt] \n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Open files */
|
||||
@@ -91,13 +94,15 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
lspd = switch_present("--lspd", argc, argv);
|
||||
log = switch_present("--log", argc, argv);
|
||||
lspdt = switch_present("--lspdt", argc, argv);
|
||||
|
||||
for(i=0; i<NW; i++)
|
||||
Sn[i] = 0.0;
|
||||
|
||||
/* Read SPC file, and determine aks[] for each frame ------------------*/
|
||||
|
||||
af = 0;
|
||||
f = af = 0;
|
||||
unstables = 0;
|
||||
while(fread(buf,sizeof(short),N,fspc) == N) {
|
||||
|
||||
@@ -117,30 +122,59 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
/* If energy high enough, include this frame */
|
||||
|
||||
f++;
|
||||
if (E > THRESH) {
|
||||
af++;
|
||||
printf("Active Frame: %ld unstables: %d\n",af, unstables);
|
||||
|
||||
find_aks(Sn, ak, NW, P, &Eres);
|
||||
roots = lpc_to_lsp(&ak[1], P , lsp, 5, LSP_DELTA1);
|
||||
roots = lpc_to_lsp(ak, P , lsp, 5, LSP_DELTA1);
|
||||
if (roots == P) {
|
||||
if (lspd) {
|
||||
fprintf(flsp,"%f ",lsp[0]);
|
||||
for(i=1; i<P; i++)
|
||||
fprintf(flsp,"%f ",lsp[i]-lsp[i-1]);
|
||||
if (log) {
|
||||
fprintf(flsp,"%f ",log10(lsp[0]));
|
||||
for(i=1; i<P; i++) {
|
||||
diff = lsp[i]-lsp[i-1];
|
||||
if (diff < (PI/4000.0)*25.0) diff = (PI/4000.0)*25.0;
|
||||
fprintf(flsp,"%f ",log10(diff));
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(flsp,"%f ",lsp[0]);
|
||||
for(i=1; i<P; i++)
|
||||
fprintf(flsp,"%f ",lsp[i]-lsp[i-1]);
|
||||
}
|
||||
|
||||
fprintf(flsp,"\n");
|
||||
|
||||
}
|
||||
else if (lspdt) {
|
||||
for(i=0; i<P; i++)
|
||||
fprintf(flsp,"%f ",lsp[i]-lsp_prev[i]);
|
||||
fprintf(flsp,"\n");
|
||||
|
||||
}
|
||||
else {
|
||||
for(i=0; i<P; i++)
|
||||
fprintf(flsp,"%f ",lsp[i]);
|
||||
fprintf(flsp,"\n");
|
||||
}
|
||||
if (log) {
|
||||
for(i=0; i<P; i++)
|
||||
fprintf(flsp,"%f ",log10(lsp[i]));
|
||||
fprintf(flsp,"\n");
|
||||
}
|
||||
else {
|
||||
for(i=0; i<P; i++)
|
||||
fprintf(flsp,"%f ",lsp[i]);
|
||||
fprintf(flsp,"\n");
|
||||
}
|
||||
|
||||
}
|
||||
memcpy(lsp_prev, lsp, sizeof(lsp));
|
||||
}
|
||||
else
|
||||
unstables++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%3.2f %% active frames\n", 100.0*(float)af/f);
|
||||
fclose(fspc);
|
||||
fclose(flsp);
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -47,7 +46,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (argc < 3) {
|
||||
printf("usage: %s InputFile ResidualFile\n", argv[0]);
|
||||
exit(0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Open files */
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define MAX_N 2048 /* maximum DFT size */
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*--------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: sd.h
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 22/7/93
|
||||
|
||||
Function to determine spectral distortion between two sets of LPCs.
|
||||
|
||||
\*--------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2009 David Rowe
|
||||
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License version 2, as
|
||||
published by the Free Software Foundation. This program is
|
||||
distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __SD__
|
||||
#define __SD__
|
||||
|
||||
float spectral_dist(float ak1[], float ak2[], int p, int n);
|
||||
|
||||
#endif /* __SD__ */
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
@@ -32,39 +31,43 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "defines.h"
|
||||
#include "comp.h"
|
||||
#include "codec2.h"
|
||||
#include "quantise.h"
|
||||
#include "interp.h"
|
||||
|
||||
/* CODEC2 struct copies from codec2.c to help with testing */
|
||||
|
||||
typedef struct {
|
||||
float Sn[M]; /* input speech */
|
||||
float w[M]; /* time domain hamming window */
|
||||
COMP W[FFT_ENC]; /* DFT of w[] */
|
||||
float Pn[2*N]; /* trapezoidal synthesis window */
|
||||
float Sn_[2*N]; /* synthesised speech */
|
||||
float prev_Wo; /* previous frame's pitch estimate */
|
||||
float ex_phase; /* excitation model phase track */
|
||||
float bg_est; /* background noise estimate for post filter */
|
||||
MODEL prev_model; /* model parameters from 20ms ago */
|
||||
} CODEC2;
|
||||
struct CODEC2 {
|
||||
int mode;
|
||||
float w[M]; /* time domain hamming window */
|
||||
COMP W[FFT_ENC]; /* DFT of w[] */
|
||||
float Pn[2*N]; /* trapezoidal synthesis window */
|
||||
float Sn[M]; /* input speech */
|
||||
float hpf_states[2]; /* high pass filter states */
|
||||
void *nlp; /* pitch predictor states */
|
||||
float Sn_[2*N]; /* synthesised output speech */
|
||||
float ex_phase; /* excitation model phase track */
|
||||
float bg_est; /* background noise estimate for post filter */
|
||||
float prev_Wo; /* previous frame's pitch estimate */
|
||||
MODEL prev_model; /* previous frame's model parameters */
|
||||
float prev_lsps_[LPC_ORD]; /* previous frame's LSPs */
|
||||
float prev_energy; /* previous frame's LPC energy */
|
||||
};
|
||||
|
||||
void analyse_one_frame(CODEC2 *c2, MODEL *model, short speech[]);
|
||||
void synthesise_one_frame(CODEC2 *c2, short speech[], MODEL *model, float ak[]);
|
||||
void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[]);
|
||||
void synthesise_one_frame(struct CODEC2 *c2, short speech[], MODEL *model, float ak[]);
|
||||
|
||||
int test1()
|
||||
{
|
||||
FILE *fin, *fout;
|
||||
short buf[N];
|
||||
void *c2;
|
||||
CODEC2 *c3;
|
||||
struct CODEC2 *c2;
|
||||
MODEL model;
|
||||
float ak[LPC_ORD+1];
|
||||
float lsps[LPC_ORD];
|
||||
|
||||
c2 = codec2_create();
|
||||
c3 = (CODEC2*)c2;
|
||||
c2 = codec2_create(CODEC2_MODE_2400);
|
||||
|
||||
fin = fopen("../raw/hts1a.raw", "rb");
|
||||
assert(fin != NULL);
|
||||
@@ -72,9 +75,9 @@ int test1()
|
||||
assert(fout != NULL);
|
||||
|
||||
while(fread(buf, sizeof(short), N, fin) == N) {
|
||||
analyse_one_frame(c3, &model, buf);
|
||||
speech_to_uq_lsps(lsps, ak, c3->Sn, c3->w, LPC_ORD);
|
||||
synthesise_one_frame(c3, buf, &model, ak);
|
||||
analyse_one_frame(c2, &model, buf);
|
||||
speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD);
|
||||
synthesise_one_frame(c2, buf, &model, ak);
|
||||
fwrite(buf, sizeof(short), N, fout);
|
||||
}
|
||||
|
||||
@@ -90,22 +93,22 @@ int test2()
|
||||
{
|
||||
FILE *fin, *fout;
|
||||
short buf[2*N];
|
||||
void *c2;
|
||||
CODEC2 *c3;
|
||||
struct CODEC2 *c2;
|
||||
MODEL model, model_interp;
|
||||
float ak[LPC_ORD+1];
|
||||
int voiced1, voiced2;
|
||||
int lsp_indexes[LPC_ORD];
|
||||
int lpc_correction;
|
||||
int energy_index;
|
||||
int Wo_index;
|
||||
char bits[CODEC2_BITS_PER_FRAME];
|
||||
char *bits;
|
||||
int nbit;
|
||||
int i;
|
||||
|
||||
c2 = codec2_create();
|
||||
c3 = (CODEC2*)c2;
|
||||
|
||||
float lsps[LPC_ORD];
|
||||
float e;
|
||||
|
||||
c2 = codec2_create(CODEC2_MODE_2400);
|
||||
bits = (char*)malloc(codec2_bits_per_frame(c2));
|
||||
assert(bits != NULL);
|
||||
fin = fopen("../raw/hts1a.raw", "rb");
|
||||
assert(fin != NULL);
|
||||
fout = fopen("hts1a_test.raw", "wb");
|
||||
@@ -114,60 +117,57 @@ int test2()
|
||||
while(fread(buf, sizeof(short), 2*N, fin) == 2*N) {
|
||||
/* first 10ms analysis frame - we just want voicing */
|
||||
|
||||
analyse_one_frame(c3, &model, buf);
|
||||
analyse_one_frame(c2, &model, buf);
|
||||
voiced1 = model.voiced;
|
||||
|
||||
/* second 10ms analysis frame */
|
||||
|
||||
analyse_one_frame(c3, &model, &buf[N]);
|
||||
analyse_one_frame(c2, &model, &buf[N]);
|
||||
voiced2 = model.voiced;
|
||||
|
||||
Wo_index = encode_Wo(model.Wo);
|
||||
encode_amplitudes(lsp_indexes,
|
||||
&lpc_correction,
|
||||
&energy_index,
|
||||
&model,
|
||||
c3->Sn,
|
||||
c3->w);
|
||||
e = speech_to_uq_lsps(lsps, ak, c2->Sn, c2->w, LPC_ORD);
|
||||
encode_lsps_scalar(lsp_indexes, lsps, LPC_ORD);
|
||||
energy_index = encode_energy(e);
|
||||
nbit = 0;
|
||||
pack(bits, &nbit, Wo_index, WO_BITS);
|
||||
pack((unsigned char*)bits, (unsigned *)&nbit, Wo_index, WO_BITS);
|
||||
for(i=0; i<LPC_ORD; i++) {
|
||||
pack(bits, &nbit, lsp_indexes[i], lsp_bits(i));
|
||||
pack((unsigned char*)bits, (unsigned *)&nbit, lsp_indexes[i], lsp_bits(i));
|
||||
}
|
||||
pack(bits, &nbit, lpc_correction, 1);
|
||||
pack(bits, &nbit, energy_index, E_BITS);
|
||||
pack(bits, &nbit, voiced1, 1);
|
||||
pack(bits, &nbit, voiced2, 1);
|
||||
pack((unsigned char*)bits, (unsigned *)&nbit, energy_index, E_BITS);
|
||||
pack((unsigned char*)bits, (unsigned *)&nbit, voiced1, 1);
|
||||
pack((unsigned char*)bits, (unsigned *)&nbit, voiced2, 1);
|
||||
|
||||
nbit = 0;
|
||||
Wo_index = unpack(bits, &nbit, WO_BITS);
|
||||
Wo_index = unpack((unsigned char*)bits, (unsigned *)&nbit, WO_BITS);
|
||||
for(i=0; i<LPC_ORD; i++) {
|
||||
lsp_indexes[i] = unpack(bits, &nbit, lsp_bits(i));
|
||||
lsp_indexes[i] = unpack((unsigned char*)bits, (unsigned *)&nbit, lsp_bits(i));
|
||||
}
|
||||
lpc_correction = unpack(bits, &nbit, 1);
|
||||
energy_index = unpack(bits, &nbit, E_BITS);
|
||||
voiced1 = unpack(bits, &nbit, 1);
|
||||
voiced2 = unpack(bits, &nbit, 1);
|
||||
energy_index = unpack((unsigned char*)bits, (unsigned *)&nbit, E_BITS);
|
||||
voiced1 = unpack((unsigned char*)bits, (unsigned *)&nbit, 1);
|
||||
voiced2 = unpack((unsigned char*)bits, (unsigned *)&nbit, 1);
|
||||
|
||||
model.Wo = decode_Wo(Wo_index);
|
||||
model.L = PI/model.Wo;
|
||||
decode_amplitudes(&model,
|
||||
ak,
|
||||
lsp_indexes,
|
||||
lpc_correction,
|
||||
energy_index);
|
||||
energy_index,
|
||||
lsps,
|
||||
&e);
|
||||
|
||||
model.voiced = voiced2;
|
||||
model_interp.voiced = voiced1;
|
||||
interpolate(&model_interp, &c3->prev_model, &model);
|
||||
interpolate(&model_interp, &c2->prev_model, &model);
|
||||
|
||||
synthesise_one_frame(c3, buf, &model_interp, ak);
|
||||
synthesise_one_frame(c3, &buf[N], &model, ak);
|
||||
synthesise_one_frame(c2, buf, &model_interp, ak);
|
||||
synthesise_one_frame(c2, &buf[N], &model, ak);
|
||||
|
||||
memcpy(&c3->prev_model, &model, sizeof(MODEL));
|
||||
memcpy(&c2->prev_model, &model, sizeof(MODEL));
|
||||
fwrite(buf, sizeof(short), 2*N, fout);
|
||||
}
|
||||
|
||||
free(bits);
|
||||
codec2_destroy(c2);
|
||||
|
||||
fclose(fin);
|
||||
@@ -181,10 +181,14 @@ int test3()
|
||||
FILE *fin, *fout, *fbits;
|
||||
short buf1[2*N];
|
||||
short buf2[2*N];
|
||||
char bits[CODEC2_BITS_PER_FRAME];
|
||||
void *c2;
|
||||
char *bits;
|
||||
struct CODEC2 *c2;
|
||||
|
||||
c2 = codec2_create();
|
||||
c2 = codec2_create(CODEC2_MODE_2400);
|
||||
int numBits = codec2_bits_per_frame(c2);
|
||||
int numBytes = (numBits+7)>>3;
|
||||
|
||||
bits = (char*)malloc(numBytes);
|
||||
|
||||
fin = fopen("../raw/hts1a.raw", "rb");
|
||||
assert(fin != NULL);
|
||||
@@ -194,12 +198,13 @@ int test3()
|
||||
assert(fout != NULL);
|
||||
|
||||
while(fread(buf1, sizeof(short), 2*N, fin) == 2*N) {
|
||||
codec2_encode(c2, bits, buf1);
|
||||
fwrite(bits, sizeof(char), CODEC2_BITS_PER_FRAME, fbits);
|
||||
codec2_decode(c2, buf2, bits);
|
||||
fwrite(buf2, sizeof(short), CODEC2_SAMPLES_PER_FRAME, fout);
|
||||
codec2_encode(c2, (void*)bits, buf1);
|
||||
fwrite(bits, sizeof(char), numBytes, fbits);
|
||||
codec2_decode(c2, buf2, (void*)bits);
|
||||
fwrite(buf2, sizeof(short), numBytes, fout);
|
||||
}
|
||||
|
||||
free(bits);
|
||||
codec2_destroy(c2);
|
||||
|
||||
fclose(fin);
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define N 80 /* frame size */
|
||||
@@ -103,8 +102,8 @@ char *argv[];
|
||||
float f0;
|
||||
|
||||
if (argc < 3) {
|
||||
printf("\nusage: tcontphase OutputRawSpeechFile F0\n");
|
||||
exit(0);
|
||||
printf("\nusage: %s OutputRawSpeechFile F0\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Output file */
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
@@ -32,6 +31,9 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "sine.h"
|
||||
@@ -60,13 +62,14 @@ void write_amp(char file[], MODEL *model)
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
char *get_next_float(char *s, float *num)
|
||||
const char *get_next_float(const char *s, float *num)
|
||||
{
|
||||
char *p = s;
|
||||
const char *p = s;
|
||||
char tmp[MAX_STR];
|
||||
|
||||
while(*p && !isspace(*p))
|
||||
p++;
|
||||
assert((p-s) < (int)(sizeof(tmp)-1));
|
||||
memcpy(tmp, s, p-s);
|
||||
tmp[p-s] = 0;
|
||||
*num = atof(tmp);
|
||||
@@ -74,13 +77,14 @@ char *get_next_float(char *s, float *num)
|
||||
return p+1;
|
||||
}
|
||||
|
||||
char *get_next_int(char *s, int *num)
|
||||
const char *get_next_int(const char *s, int *num)
|
||||
{
|
||||
char *p = s;
|
||||
const char *p = s;
|
||||
char tmp[MAX_STR];
|
||||
|
||||
while(*p && !isspace(*p))
|
||||
p++;
|
||||
assert((p-s) < (int)(sizeof(tmp)-1));
|
||||
memcpy(tmp, s, p-s);
|
||||
tmp[p-s] = 0;
|
||||
*num = atoi(tmp);
|
||||
@@ -88,18 +92,20 @@ char *get_next_int(char *s, int *num)
|
||||
return p+1;
|
||||
}
|
||||
|
||||
void load_amp(MODEL *model, char file[], int frame)
|
||||
void load_amp(MODEL *model, const char * file, int frame)
|
||||
{
|
||||
FILE *f;
|
||||
int i;
|
||||
char s[1024];
|
||||
char *ps;
|
||||
const char *ps;
|
||||
|
||||
f = fopen(file,"rt");
|
||||
assert(f);
|
||||
|
||||
for(i=0; i<frame; i++)
|
||||
fgets(s, 1023, f);
|
||||
ps = fgets(s, 1023, f);
|
||||
|
||||
/// can frame ever be 0? what if fgets fails?
|
||||
ps = s;
|
||||
ps = get_next_float(ps, &model->Wo);
|
||||
ps = get_next_int(ps, &model->L);
|
||||
@@ -109,13 +115,30 @@ void load_amp(MODEL *model, char file[], int frame)
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void load_or_make_amp(MODEL *model,
|
||||
const char * filename, int frame,
|
||||
float f0, float cdB, float mdBHz)
|
||||
{
|
||||
struct stat buf;
|
||||
int rc = stat(filename, &buf);
|
||||
if (rc || !S_ISREG(buf.st_mode) || ((buf.st_mode & S_IRUSR) != S_IRUSR))
|
||||
{
|
||||
make_amp(model, f0, cdB, mdBHz);
|
||||
}
|
||||
else
|
||||
{
|
||||
load_amp(model, filename, frame);
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
MODEL prev, next, interp;
|
||||
|
||||
//make_amp(&prev, 50.0, 60.0, 6E-3);
|
||||
//make_amp(&next, 50.0, 40.0, 6E-3);
|
||||
load_amp(&prev, "../src/hts1a_model.txt", 32);
|
||||
load_amp(&next, "../src/hts1a_model.txt", 34);
|
||||
load_or_make_amp(&prev,
|
||||
"../src/hts1a_model.txt", 32,
|
||||
50.0, 60.0, 6E-3);
|
||||
load_or_make_amp(&next,
|
||||
"../src/hts1a_model.txt", 34,
|
||||
50.0, 40.0, 6E-3);
|
||||
|
||||
interp.voiced = 1;
|
||||
interpolate(&interp, &prev, &next);
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define N 80 /* frame size */
|
||||
@@ -41,6 +40,7 @@
|
||||
#include "dump.h"
|
||||
#include "sine.h"
|
||||
#include "nlp.h"
|
||||
#include "kiss_fft.h"
|
||||
|
||||
int frames;
|
||||
|
||||
@@ -81,19 +81,22 @@ char *argv[];
|
||||
FILE *fin,*fout;
|
||||
short buf[N];
|
||||
float Sn[M]; /* float input speech samples */
|
||||
kiss_fft_cfg fft_fwd_cfg;
|
||||
COMP Sw[FFT_ENC]; /* DFT of Sn[] */
|
||||
float w[M]; /* time domain hamming window */
|
||||
COMP W[FFT_ENC]; /* DFT of w[] */
|
||||
float pitch;
|
||||
int i;
|
||||
int dump;
|
||||
float prev_Wo;
|
||||
void *nlp_states;
|
||||
#ifdef DUMP
|
||||
int dump;
|
||||
#endif
|
||||
|
||||
if (argc < 3) {
|
||||
printf("\nusage: tnlp InputRawSpeechFile OutputPitchTextFile "
|
||||
"[--dump DumpFile]\n");
|
||||
exit(0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Input file */
|
||||
@@ -110,12 +113,18 @@ char *argv[];
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef DUMP
|
||||
dump = switch_present("--dump",argc,argv);
|
||||
if (dump)
|
||||
dump_on(argv[dump+1]);
|
||||
#else
|
||||
/// TODO
|
||||
/// #warning "Compile with -DDUMP if you expect to dump anything."
|
||||
#endif
|
||||
|
||||
nlp_states = nlp_create();
|
||||
make_analysis_window(w,W);
|
||||
fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL);
|
||||
make_analysis_window(fft_fwd_cfg, w, W);
|
||||
|
||||
frames = 0;
|
||||
prev_Wo = 0;
|
||||
@@ -128,10 +137,12 @@ char *argv[];
|
||||
Sn[i] = Sn[i+N];
|
||||
for(i=0; i<N; i++)
|
||||
Sn[i+M-N] = buf[i];
|
||||
dft_speech(Sw, Sn, w);
|
||||
dft_speech(fft_fwd_cfg, Sw, Sn, w);
|
||||
#ifdef DUMP
|
||||
dump_Sn(Sn); dump_Sw(Sw);
|
||||
#endif
|
||||
|
||||
nlp(nlp_states,Sn,N,M,PITCH_MIN,PITCH_MAX,&pitch,Sw,&prev_Wo);
|
||||
nlp(nlp_states,Sn,N,M,PITCH_MIN,PITCH_MAX,&pitch,Sw,W, &prev_Wo);
|
||||
prev_Wo = TWO_PI/pitch;
|
||||
|
||||
fprintf(fout,"%f\n",pitch);
|
||||
@@ -139,7 +150,9 @@ char *argv[];
|
||||
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
#ifdef DUMP
|
||||
if (dump) dump_off();
|
||||
#endif
|
||||
nlp_destroy(nlp_states);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
@@ -123,8 +122,8 @@ int test_lsp(int lsp_number, int levels, float max_error_hz) {
|
||||
|
||||
for(i=0; i<levels; i++) {
|
||||
indexes_in[lsp_number] = i;
|
||||
decode_lsps(lsp, indexes_in, LPC_ORD);
|
||||
encode_lsps(indexes_out, lsp,LPC_ORD);
|
||||
decode_lsps_scalar(lsp, indexes_in, LPC_ORD);
|
||||
encode_lsps_scalar(indexes_out, lsp,LPC_ORD);
|
||||
if (indexes_in[lsp_number] != indexes_out[lsp_number]) {
|
||||
printf("freq: %f index_in: %d index_out: %d\n",
|
||||
lsp[lsp_number]+1, indexes_in[lsp_number],
|
||||
@@ -136,18 +135,18 @@ int test_lsp(int lsp_number, int levels, float max_error_hz) {
|
||||
for(i=0; i<LPC_ORD; i++)
|
||||
indexes[i] = 0;
|
||||
indexes[lsp_number] = 0;
|
||||
decode_lsps(lsp, indexes, LPC_ORD);
|
||||
decode_lsps_scalar(lsp, indexes, LPC_ORD);
|
||||
lowf = lsp[lsp_number];
|
||||
indexes[lsp_number] = levels - 1;
|
||||
decode_lsps(lsp, indexes, LPC_ORD);
|
||||
decode_lsps_scalar(lsp, indexes, LPC_ORD);
|
||||
highf = lsp[lsp_number];
|
||||
sprintf(s,"lsp%d_err.txt", lsp_number+1);
|
||||
flsp = fopen(s, "wt");
|
||||
|
||||
for(f=lowf; f<highf; f +=(highf-lowf)/1000.0) {
|
||||
lsp[lsp_number] = f;
|
||||
encode_lsps(indexes, lsp, LPC_ORD);
|
||||
decode_lsps(lsp, indexes, LPC_ORD);
|
||||
encode_lsps_scalar(indexes, lsp, LPC_ORD);
|
||||
decode_lsps_scalar(lsp, indexes, LPC_ORD);
|
||||
error = f - lsp[lsp_number];
|
||||
fprintf(flsp, "%f\n", error);
|
||||
if (fabs(error) > max_error_rads) {
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------*\
|
||||
@@ -38,6 +37,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*-----------------------------------------------------------------------*\
|
||||
|
||||
@@ -59,7 +59,7 @@ void acc(float v1[], float v2[], int k);
|
||||
void norm(float v[], int k, long n);
|
||||
long quantise(float cb[], float vec[], int k, int m, float *se);
|
||||
|
||||
/*-----------------------------------------------------------------------*\
|
||||
/*-----------------------------------------------------------------------* \
|
||||
|
||||
MAIN
|
||||
|
||||
@@ -79,12 +79,13 @@ int main(int argc, char *argv[]) {
|
||||
float delta; /* improvement in distortion */
|
||||
FILE *ftrain; /* file containing training set */
|
||||
FILE *fvq; /* file containing vector quantiser */
|
||||
int ret;
|
||||
|
||||
/* Interpret command line arguments */
|
||||
|
||||
if (argc != 5) {
|
||||
printf("usage: vqtrain TrainFile K M VQFile\n");
|
||||
exit(0);
|
||||
printf("usage: %s TrainFile K(dimension) M(codebook size) VQFile\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Open training file */
|
||||
@@ -99,7 +100,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
k = atol(argv[2]);
|
||||
m = atol(argv[3]);
|
||||
printf("dimension K=%ld number of entries M=%ld\n", k,m);
|
||||
printf("dimension K=%ld number of entries M=%ld\n", k, m);
|
||||
vec = (float*)malloc(sizeof(float)*k);
|
||||
cb = (float*)malloc(sizeof(float)*k*m);
|
||||
cent = (float*)malloc(sizeof(float)*k*m);
|
||||
@@ -112,14 +113,14 @@ int main(int argc, char *argv[]) {
|
||||
/* determine size of training set */
|
||||
|
||||
J = 0;
|
||||
while(fread(vec, sizeof(float), k, ftrain) == k)
|
||||
while(fread(vec, sizeof(float), k, ftrain) == (size_t)k)
|
||||
J++;
|
||||
printf("J=%ld entries in training set\n", J);
|
||||
|
||||
/* set up initial codebook state from samples of training set */
|
||||
|
||||
rewind(ftrain);
|
||||
fread(cb, sizeof(float), k*m, ftrain);
|
||||
ret = fread(cb, sizeof(float), k*m, ftrain);
|
||||
|
||||
/* main loop */
|
||||
|
||||
@@ -140,7 +141,7 @@ int main(int argc, char *argv[]) {
|
||||
se = 0.0;
|
||||
rewind(ftrain);
|
||||
for(i=0; i<J; i++) {
|
||||
fread(vec, sizeof(float), k, ftrain);
|
||||
ret = fread(vec, sizeof(float), k, ftrain);
|
||||
ind = quantise(cb, vec, k, m, &se);
|
||||
n[ind]++;
|
||||
acc(¢[ind*k], vec, k);
|
||||
@@ -151,7 +152,7 @@ int main(int argc, char *argv[]) {
|
||||
printf("\r Iteration %ld, Dn = %f, Delta = %e\n", j, Dn, delta);
|
||||
j++;
|
||||
|
||||
/* determine new codebook from centriods */
|
||||
/* determine new codebook from centroids */
|
||||
|
||||
if (delta > DELTAQ)
|
||||
for(i=0; i<m; i++) {
|
||||
@@ -171,6 +172,7 @@ int main(int argc, char *argv[]) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(fvq,"%ld %ld\n",k,m);
|
||||
for(j=0; j<m; j++) {
|
||||
for(i=0; i<k; i++)
|
||||
fprintf(fvq,"%f ",cb[j*k+i]);
|
||||
@@ -277,13 +279,16 @@ long quantise(float cb[], float vec[], int k, int m, float *se)
|
||||
float beste; /* best error so far */
|
||||
long j;
|
||||
int i;
|
||||
float diff;
|
||||
|
||||
besti = 0;
|
||||
beste = 1E32;
|
||||
for(j=0; j<m; j++) {
|
||||
e = 0.0;
|
||||
for(i=0; i<k; i++)
|
||||
e += pow(cb[j*k+i]-vec[i],2.0);
|
||||
for(i=0; i<k; i++) {
|
||||
diff = cb[j*k+i]-vec[i];
|
||||
e += pow(diff,2.0);
|
||||
}
|
||||
if (e < beste) {
|
||||
beste = e;
|
||||
besti = j;
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#define CODEC2_DEBUG
|
||||
*/
|
||||
|
||||
#define CODEC2_SAMPLES_PER_FRAME 160
|
||||
|
||||
#ifdef CODEC2_DEBUG
|
||||
#define codec2_assert(_x) switch_assert(_x)
|
||||
#else
|
||||
@@ -80,11 +82,11 @@ static switch_status_t switch_codec2_init(switch_codec_t *codec, switch_codec_fl
|
||||
}
|
||||
|
||||
if (encoding) {
|
||||
context->encoder = codec2_create();
|
||||
context->encoder = codec2_create(CODEC2_MODE_2400);
|
||||
}
|
||||
|
||||
if (decoding) {
|
||||
context->decoder = codec2_create();
|
||||
context->decoder = codec2_create(CODEC2_MODE_2400);
|
||||
}
|
||||
|
||||
codec->private_info = context;
|
||||
|
||||
Reference in New Issue
Block a user