├── TEST ├── RES │ ├── 3.pm │ ├── 0.pm │ ├── 1.pm │ ├── 2.pm │ ├── 0.s16 │ ├── 1.s16 │ ├── 2.s16 │ ├── 3.s16 │ ├── 0.f0 │ ├── 3.f0 │ ├── 1.f0 │ └── 2.f0 ├── .f0 ├── test.f0 ├── test ├── .mbe ├── WAV │ ├── 1.d16 │ ├── 2.d16 │ ├── 3.d16 │ └── 4.d16 ├── test.mbe ├── SORTIE.dba ├── SORTIE.raw ├── .syn ├── SORTIE.mrk ├── test.syn ├── test.seg ├── generate_mbrola ├── readme.md ├── test.mak └── generate_make.pl ├── AnaMBE ├── mbe.cpp ├── pitchana.h ├── Makefile ├── func.h ├── constant.h ├── anaf0.cpp ├── fmobject.h ├── complex.h ├── func.cpp ├── anambe.cpp ├── mbefunc.h ├── signalpr.h ├── autocorr.h ├── mbeanaly.h ├── mbeparam.h ├── errorexc.h ├── mbefunc.cpp ├── complex.cpp ├── soundfil.h ├── datatype.cpp ├── datatype.h └── pitchana.cpp ├── Resynthesis ├── Src │ ├── COEF_FILTER │ │ ├── lp16_10.m │ │ ├── lp20_16.m │ │ ├── lp16_10_vincent.m │ │ ├── lp16_8.m │ │ ├── filtr16_8 │ │ ├── filtr20_16 │ │ ├── filtr16_11 │ │ └── filtr16_10 │ ├── filter_file.c │ └── diphone_resynth_equalize.c └── Makefile └── README.md /TEST/RES/3.pm: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /TEST/RES/0.pm: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /TEST/RES/1.pm: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /TEST/RES/2.pm: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /TEST/.f0: -------------------------------------------------------------------------------- 1 | Freq= 16000 2 | FrameLength= 512 3 | FrameShift= 80 4 | -------------------------------------------------------------------------------- /TEST/test.f0: -------------------------------------------------------------------------------- 1 | Freq= 16000 2 | FrameLength= 512 3 | FrameShift= 80 4 | -------------------------------------------------------------------------------- /TEST/test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/test -------------------------------------------------------------------------------- /TEST/.mbe: -------------------------------------------------------------------------------- 1 | Nfft=1024 2 | Freq=16000 3 | FrameLength=360 4 | FrameShift=120 5 | -------------------------------------------------------------------------------- /AnaMBE/mbe.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/AnaMBE/mbe.cpp -------------------------------------------------------------------------------- /TEST/RES/0.s16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/RES/0.s16 -------------------------------------------------------------------------------- /TEST/RES/1.s16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/RES/1.s16 -------------------------------------------------------------------------------- /TEST/RES/2.s16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/RES/2.s16 -------------------------------------------------------------------------------- /TEST/RES/3.s16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/RES/3.s16 -------------------------------------------------------------------------------- /TEST/WAV/1.d16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/WAV/1.d16 -------------------------------------------------------------------------------- /TEST/WAV/2.d16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/WAV/2.d16 -------------------------------------------------------------------------------- /TEST/WAV/3.d16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/WAV/3.d16 -------------------------------------------------------------------------------- /TEST/WAV/4.d16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/WAV/4.d16 -------------------------------------------------------------------------------- /TEST/test.mbe: -------------------------------------------------------------------------------- 1 | Nfft=1024 2 | Freq=16000 3 | FrameLength=360 4 | FrameShift=120 5 | -------------------------------------------------------------------------------- /TEST/SORTIE.dba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/SORTIE.dba -------------------------------------------------------------------------------- /TEST/SORTIE.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/TEST/SORTIE.raw -------------------------------------------------------------------------------- /AnaMBE/pitchana.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/numediart/MBROLATOR/HEAD/AnaMBE/pitchana.h -------------------------------------------------------------------------------- /TEST/.syn: -------------------------------------------------------------------------------- 1 | Freq=16000 2 | LastPhaseReset=10 3 | VUVLimTra=0.55 4 | VUVLimVoiced=1.2 5 | ElimTrans=5e8 6 | ElimVoiced=5e8 7 | -------------------------------------------------------------------------------- /TEST/SORTIE.mrk: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /TEST/test.syn: -------------------------------------------------------------------------------- 1 | Freq=16000 2 | LastPhaseReset=10 3 | VUVLimTra=0.55 4 | VUVLimVoiced=1.2 5 | ElimTrans=5e8 6 | ElimVoiced=5e8 7 | -------------------------------------------------------------------------------- /TEST/test.seg: -------------------------------------------------------------------------------- 1 | 1.d16 _ a 2000 3810 2929 2 | 2.d16 a k 2000 3927 2939 3 | 3.d16 i _ 2000 4554 3228 4 | 4.d16 k i 2000 3782 3150 5 | -------------------------------------------------------------------------------- /Resynthesis/Src/COEF_FILTER/lp16_10.m: -------------------------------------------------------------------------------- 1 | f80=[0 4750 5250 40000]/40000 2 | amp=[1 1 .001 .001] 3 | filtre=remez(300,f80,amp) 4 | showamp(filtre,1) 5 | save filtr16_10 filtre /ascii 6 | -------------------------------------------------------------------------------- /Resynthesis/Src/COEF_FILTER/lp20_16.m: -------------------------------------------------------------------------------- 1 | f80=[0 7900 8100 40000]/40000 2 | amp=[1 1 .001 .001] 3 | filtre=remez(512,f80,amp) 4 | freqz(filtre,1,512) 5 | save filtr20_16 filtre /ascii 6 | -------------------------------------------------------------------------------- /Resynthesis/Src/COEF_FILTER/lp16_10_vincent.m: -------------------------------------------------------------------------------- 1 | f80=[0 5150 5250 104000]/104000 2 | amp=[1 1 .001 .001] 3 | filtre=remez(512,f80,amp) 4 | showamp(filtre,1) 5 | save filtr16_10 filtre /ascii 6 | -------------------------------------------------------------------------------- /Resynthesis/Src/COEF_FILTER/lp16_8.m: -------------------------------------------------------------------------------- 1 | f80=[0 7900 8100 16000]/16000 2 | amp=[1 1 .0001 .001] 3 | filtre=remez(200,f80,amp) 4 | freqz(filtre,1) 5 | zoom on 6 | save filtr16_8 filtre /ascii 7 | -------------------------------------------------------------------------------- /TEST/RES/0.f0: -------------------------------------------------------------------------------- 1 | 512 80 2000 3810 2 | 275.86 3 | 271.19 4 | 285.71 5 | 285.71 6 | 285.71 7 | 285.71 8 | 285.71 9 | 285.71 10 | 285.71 11 | 285.71 12 | 148.84 13 | 124.03 14 | 124.03 15 | 124.03 16 | 123.55 17 | 123.08 18 | 122.61 19 | 122.14 20 | 120.30 21 | 118.52 22 | 118.52 23 | 118.52 24 | -------------------------------------------------------------------------------- /TEST/RES/3.f0: -------------------------------------------------------------------------------- 1 | 512 80 2000 3782 2 | 210.53 3 | 262.30 4 | 285.71 5 | 111.11 6 | 80.00 7 | 80.00 8 | 80.00 9 | 275.86 10 | 166.67 11 | 139.13 12 | 140.35 13 | 146.12 14 | 166.67 15 | 164.95 16 | 152.38 17 | 123.08 18 | 119.40 19 | 112.68 20 | 111.89 21 | 112.68 22 | 112.68 23 | 112.28 24 | -------------------------------------------------------------------------------- /TEST/RES/1.f0: -------------------------------------------------------------------------------- 1 | 512 80 2000 3927 2 | 103.23 3 | 101.27 4 | 100.63 5 | 100.63 6 | 100.00 7 | 99.38 8 | 98.77 9 | 99.38 10 | 100.00 11 | 99.38 12 | 99.38 13 | 95.81 14 | 90.91 15 | 86.96 16 | 80.00 17 | 82.90 18 | 100.00 19 | 98.16 20 | 98.16 21 | 262.30 22 | 251.97 23 | 240.60 24 | 80.00 25 | 169.31 26 | -------------------------------------------------------------------------------- /TEST/RES/2.f0: -------------------------------------------------------------------------------- 1 | 512 80 2000 4554 2 | 110.34 3 | 105.96 4 | 102.56 5 | 99.38 6 | 95.81 7 | 93.02 8 | 92.49 9 | 91.43 10 | 91.95 11 | 94.67 12 | 95.24 13 | 96.97 14 | 96.39 15 | 97.56 16 | 95.81 17 | 94.12 18 | 94.67 19 | 104.23 20 | 115.11 21 | 108.84 22 | 103.90 23 | 111.11 24 | 114.29 25 | 111.89 26 | 109.59 27 | 108.47 28 | 108.84 29 | 112.68 30 | 121.21 31 | 106.67 32 | 107.38 33 | -------------------------------------------------------------------------------- /TEST/generate_mbrola: -------------------------------------------------------------------------------- 1 | echo "Freq= 16000" > $1.f0 2 | echo "FrameLength= 512" >> $1.f0 3 | echo "FrameShift= 80" >> $1.f0 4 | 5 | echo "Nfft=1024" > $1.mbe 6 | echo "Freq=16000" >> $1.mbe 7 | echo "FrameLength=360" >> $1.mbe 8 | echo "FrameShift=120" >> $1.mbe 9 | 10 | echo "Freq=16000 " > $1.syn 11 | echo "LastPhaseReset=10" >> $1.syn 12 | echo "VUVLimTra=0.55" >> $1.syn 13 | echo "VUVLimVoiced=1.2" >> $1.syn 14 | echo "ElimTrans=5e8" >> $1.syn 15 | echo "ElimVoiced=5e8" >> $1.syn 16 | -------------------------------------------------------------------------------- /TEST/readme.md: -------------------------------------------------------------------------------- 1 | Audio files ( the .d16 in the example below) respect LITTLE ENDIAN 2 | format that is PC architecture. 3 | 4 | Format of label.txt, each fields separated with spaces 5 | 6 | ``` 7 | file name 8 | | diphone name 9 | | | first sample 10 | | | | last sample 11 | v | | | middle 12 | V V V v 13 | 1.d16 _ a 2000 3910 2929 14 | 2.d16 a k 2000 4027 2939 15 | 3.d16 i _ 2000 4654 3228 16 | 4.d16 k i 2000 3882 3150 17 | ``` 18 | 19 | The phoneme names can be as long as you want and contain non alphabetic 20 | chars such as { as found in the SAMPA alphabet. You may wish to call the 21 | d16 files with something else than numbers... WARNING: DONT INCLUDE NON 22 | ALPHABETIC CHARS IN THE FILE NAME OR UPERCASE LOWERCASE DISTINCTION 23 | (if you work with Windows we loose the upper/lower disctinction and it's 24 | a lot of wasted time). 25 | 26 | -------------------------------------------------------------------------------- /TEST/test.mak: -------------------------------------------------------------------------------- 1 | test : diph_resynth 2 | database_build test RES/ RES/ 2.069 16000 120 1 3 | RES/0.f0 : WAV/1.d16 test.f0 4 | anaf0 'WAV/1.d16' RES/0.f0 2000 3810 test.f0 5 | RES/0.mbe: RES/0.f0 test.mbe 6 | anambe WAV/1.d16 RES/0.f0 RES/0.mbe 2000 3810 test.mbe 7 | RES/0.s16 : RES/0.mbe test.syn 8 | resynth WAV/1.d16 RES/0.mbe RES/0 test.syn 9 | 10 | RES/1.f0 : WAV/2.d16 test.f0 11 | anaf0 'WAV/2.d16' RES/1.f0 2000 3927 test.f0 12 | RES/1.mbe: RES/1.f0 test.mbe 13 | anambe WAV/2.d16 RES/1.f0 RES/1.mbe 2000 3927 test.mbe 14 | RES/1.s16 : RES/1.mbe test.syn 15 | resynth WAV/2.d16 RES/1.mbe RES/1 test.syn 16 | 17 | RES/2.f0 : WAV/3.d16 test.f0 18 | anaf0 'WAV/3.d16' RES/2.f0 2000 4554 test.f0 19 | RES/2.mbe: RES/2.f0 test.mbe 20 | anambe WAV/3.d16 RES/2.f0 RES/2.mbe 2000 4554 test.mbe 21 | RES/2.s16 : RES/2.mbe test.syn 22 | resynth WAV/3.d16 RES/2.mbe RES/2 test.syn 23 | 24 | RES/3.f0 : WAV/4.d16 test.f0 25 | anaf0 'WAV/4.d16' RES/3.f0 2000 3782 test.f0 26 | RES/3.mbe: RES/3.f0 test.mbe 27 | anambe WAV/4.d16 RES/3.f0 RES/3.mbe 2000 3782 test.mbe 28 | RES/3.s16 : RES/3.mbe test.syn 29 | resynth WAV/4.d16 RES/3.mbe RES/3 test.syn 30 | 31 | diph_resynth: RES/0.s16 RES/1.s16 RES/2.s16 RES/3.s16 32 | -------------------------------------------------------------------------------- /AnaMBE/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | # This program is free software: you can redistribute it and/or modify 3 | # it under the terms of the GNU Affero General Public License as published by 4 | # the Free Software Foundation, either version 3 of the License, or 5 | # (at your option) any later version. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU Affero General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU Affero General Public License 13 | # along with this program. If not, see . 14 | 15 | CC = g++ 16 | 17 | AR = ar 18 | 19 | CFLAGS= 20 | # CFLAGS += -g 21 | # CFLAGS += -DALPHA 22 | 23 | CFLAGS += -O6 24 | #CFLAGS += -DLITTLE_ENDIAN 25 | #CFLAGS += -DBIG_ENDIAN 26 | #CFLAGS += -m32 27 | 28 | ANAF0SRCS = anaf0.cpp soundfil.cpp pitchana.cpp mbefunc.cpp datatype.cpp func.cpp 29 | MBESRCS = complex.cpp signalpr.cpp mbe.cpp soundfil.cpp pitchana.cpp mbefunc.cpp datatype.cpp func.cpp anambe.cpp 30 | 31 | BINDIR = Obj 32 | 33 | ANAF0OBJS = $(ANAF0SRCS:%.cpp=$(BINDIR)/%.o) 34 | MBEOBJS = $(MBESRCS:%.cpp=$(BINDIR)/%.o) 35 | 36 | PROJ = anaf0 anambe 37 | 38 | all: $(BINDIR) $(PROJ) 39 | 40 | $(BINDIR): 41 | @if ! [ -d $(BINDIR) ]; then mkdir -p $(BINDIR); fi 42 | 43 | anaf0: $(ANAF0OBJS) 44 | $(CC) $(CFLAGS) -o $(BINDIR)/anaf0 $(ANAF0OBJS) -lm 45 | 46 | anambe : $(MBEOBJS) 47 | $(CC) $(CFLAGS) -o $(BINDIR)/anambe $(MBEOBJS) -lm 48 | 49 | clean: 50 | rm -f $(ANAF0OBJS) $(MBEOBJS) $(PROJ) $(PROJ).a core TAGS 51 | 52 | $(BINDIR)/%.o: %.cpp 53 | $(CC) $(CFLAGS) -o $@ -c $< 54 | -------------------------------------------------------------------------------- /Resynthesis/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | # This program is free software: you can redistribute it and/or modify 3 | # it under the terms of the GNU Affero General Public License as published by 4 | # the Free Software Foundation, either version 3 of the License, or 5 | # (at your option) any later version. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU Affero General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU Affero General Public License 13 | # along with this program. If not, see . 14 | 15 | CC = gcc 16 | CFLAGS += -O5 17 | # CFLAGS += -Wall 18 | #CFLAGS += -DLITTLE_ENDIAN 19 | #CFLAGS += -DBIG_ENDIAN 20 | 21 | all: database_build resynth resynth_debug resynth_female resynth_resample16_8 resynth_resample16_11 22 | 23 | resynth: Src/resynth.c 24 | $(CC) $(CFLAGS) -o resynth Src/resynth.c -lm 25 | 26 | resynth_debug: Src/resynth.c 27 | $(CC) $(CFLAGS) -DDEBUG -o resynth_debug Src/resynth.c -lm 28 | 29 | resynth_female: Src/resynth.c 30 | $(CC) $(CFLAGS) -DFEMALE -o resynth_female Src/resynth.c -lm 31 | 32 | resynth_sybil: Src/resynth.c 33 | $(CC) $(CFLAGS) -DSYBIL -o resynth_sybil Src/resynth.c -lm 34 | 35 | resynth_resample16_8: Src/resynth.c 36 | $(CC) $(CFLAGS) -c -DRESAMPLING16_8 -o Src/filter_file.o Src/filter_file.c 37 | $(CC) $(CFLAGS) -c -DRESAMPLING -DRESAMPLING16_8 -o Src/resynth.o Src/resynth.c 38 | $(CC) $(CFLAGS) -o resynth_resample16_8 Src/resynth.o Src/filter_file.o -lm 39 | 40 | resynth_resample16_11: Src/resynth.c 41 | $(CC) $(CFLAGS) -c -DRESAMPLING16_11 -o Src/filter_file.o Src/filter_file.c 42 | $(CC) $(CFLAGS) -c -DRESAMPLING -DRESAMPLING16_11 -o Src/resynth.o Src/resynth.c 43 | $(CC) $(CFLAGS) -o resynth_resample16_11 Src/resynth.o Src/filter_file.o -lm 44 | 45 | database_build: Src/database_build.c 46 | $(CC) $(CFLAGS) -o database_build Src/database_build.c -lm 47 | 48 | clean : 49 | \rm -f Src/*.o resynth_resample resynth_female resynth_debug resynth database_build 50 | -------------------------------------------------------------------------------- /AnaMBE/func.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // func.h func.cpp 16 | // 17 | // functions: minab(int,int) 18 | // maxab(int,int) 19 | // round(double) 20 | // Convert16to8(SoundFile*,const char*) 21 | // Convert16to4(SoundFile*,const char*) 22 | // 23 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 24 | // 25 | // History: 03.10.1995: Creation 26 | // 23.11.1995: Formalisation 27 | // 11.03.1996: #ifndef et define _INC_FUNC 28 | // 30.07.1996: Convert16to8 and Convert16to4 29 | // 30 | // ---------------------------------------------------------------------------- 31 | // Documentation: 32 | // 33 | // ============================================================================ 34 | 35 | #define _INC_FUNC 36 | 37 | #ifndef _INC_SOUNDFIL 38 | #include "soundfil.h" 39 | #endif 40 | 41 | // Give the minimum of a and b 42 | int minab(int a,int b); 43 | 44 | // Give the maximum of a and b 45 | int maxab(int a,int b); 46 | 47 | // Give the rounded value of a 48 | //int round(double a); 49 | 50 | // Convert a sound file sampled a 16kHz to one sampled at 8kHz 51 | void Convert16to8(SoundFile* Son,const char* Name); 52 | 53 | // Convert a sound file sampled a 16kHz to one sampled at 4kHz 54 | void Convert16to4(SoundFile* Son,const char* Name); 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /AnaMBE/constant.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // constant.h 16 | // 17 | // No classes 18 | // 19 | // Author : Fabrice Malfrere - TCTS Labs - FRIA Researcher 20 | // 21 | // History: 08.03.1996: Creation 22 | // 10.03.1996: Error messages 23 | // 12.03.1996: VOICED and UNVOICED constants 24 | // 25 | // ---------------------------------------------------------------------------- 26 | // Documentation: 27 | // 28 | // ============================================================================ 29 | 30 | #define _INC_CONSTANT // Include or not this file 31 | 32 | #ifndef TRUE // TRUE constant 33 | #define TRUE 1 34 | #endif 35 | 36 | #ifndef FALSE // FALSE constant 37 | #define FALSE 0 38 | #endif 39 | 40 | #ifndef NULL // NULL constant 41 | #define NULL 0 42 | #endif 43 | 44 | #ifndef VOICED // VOICED constant 45 | #define VOICED 1 46 | #endif 47 | 48 | #ifndef UNVOICED // UNVOICED constant 49 | #define UNVOICED 0 50 | #endif 51 | 52 | #ifndef PI 53 | #define PI 3.14159265358979323846 54 | #endif 55 | 56 | // ============================================================================ 57 | 58 | // Error Messages 59 | 60 | #ifndef ERROR_NAME 61 | #define ERROR_NAME "Memory error object name: " 62 | #endif 63 | 64 | #ifndef ERROR_INDEX 65 | #define ERROR_INDEX "Index not allowed: " 66 | #endif 67 | 68 | #ifndef ERROR_MEMORY 69 | #define ERROR_MEMORY "Memory error: " 70 | #endif 71 | 72 | #ifndef ERROR_FILE 73 | #define ERROR_FILE "File Error: " 74 | #endif 75 | 76 | #ifndef ERROR_DIVISION 77 | #define ERROR_DIVISION "Division by zero: " 78 | #endif 79 | 80 | -------------------------------------------------------------------------------- /AnaMBE/anaf0.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | 15 | #include 16 | #include 17 | 18 | #ifndef _INC_PITCHANA 19 | #include "pitchana.h" 20 | #endif 21 | 22 | int main(int argc, char **argv) 23 | { 24 | char *f0_file_name,*s16_file_name, output_s16[255],output_pm[255]; 25 | int Freq=16000,FrameLength=512, FrameShift=80, FirstSample=0, LastSample=0 ; 26 | 27 | MBEPitchAnalyserNoVoicing_A *a_PitchAnalyser; 28 | FrameMBEPitch_A *a_FramePitch; 29 | SoundRAW *a_SoundFile; 30 | PitchObject *a_PitchCurve; 31 | 32 | if ( (argc!=8) && 33 | (argc!=6)) 34 | { 35 | fprintf(stderr,"USAGE: %s input_s16_file f0_ouput_filename FirstSample=%i LastSample=%i " 36 | "[ Freq=%i FrameLength=%i FrameShift=%f ]\n", 37 | argv[0], FirstSample, LastSample, Freq, FrameLength, FrameShift); 38 | exit(1); 39 | } 40 | 41 | s16_file_name=argv[1]; 42 | f0_file_name=argv[2]; 43 | FirstSample = atoi(argv[3]); 44 | LastSample = atoi(argv[4]); 45 | 46 | if (argc==8) 47 | { 48 | Freq=atoi(argv[5]); 49 | FrameLength=atoi(argv[6]); 50 | FrameShift = atoi(argv[7]); 51 | } 52 | else 53 | { 54 | FILE *init_file; 55 | 56 | init_file=fopen(argv[5],"rt"); 57 | if ( (fscanf(init_file," Freq= %i ",&Freq)!=1) || 58 | (fscanf(init_file," FrameLength= %i ",&FrameLength)!=1) || 59 | (fscanf(init_file," FrameShift= %i ",&FrameShift)!=1)) 60 | { 61 | fprintf(stderr,"Param: Freq, FrameLength, FrameShift\n"); 62 | exit(1); 63 | } 64 | 65 | fclose(init_file); 66 | } 67 | 68 | int nb_tranche= (LastSample-FirstSample+1)/FrameShift; 69 | a_PitchCurve= new PitchObject(nb_tranche+2,FrameLength,FrameShift,FirstSample,LastSample); 70 | 71 | a_SoundFile= new SoundRAW(s16_file_name, s16_file_name, Freq); 72 | a_SoundFile->SetFrame(FrameLength, FrameShift); 73 | 74 | a_FramePitch= new FrameMBEPitch_A(FrameLength,Freq); 75 | a_PitchAnalyser= new MBEPitchAnalyserNoVoicing_A(a_FramePitch); 76 | 77 | a_PitchAnalyser->IO_Def(a_SoundFile,FirstSample,LastSample,a_PitchCurve); 78 | a_PitchAnalyser->Process(); 79 | a_PitchCurve->SaveParameters(f0_file_name); 80 | return(0); 81 | } 82 | -------------------------------------------------------------------------------- /Resynthesis/Src/COEF_FILTER/filtr16_8: -------------------------------------------------------------------------------- 1 | 9.5084056e-07, -1.8662054e-02, -1.1088391e-06, 1.7908561e-03, 2.8432213e-07, -1.8780030e-03, -5.2954808e-07, 1.9693342e-03, 2.4790182e-07, -2.0635938e-03, -5.7723915e-07, 2.1639751e-03, 1.7149290e-06, -2.2664356e-03, 1.0502200e-06, 2.3745391e-03, 1.6771291e-06, -2.4894063e-03, -7.2851565e-07, 2.6066231e-03, -3.8909459e-07, -2.7303368e-03, 1.4547896e-06, 2.8597628e-03, -1.5425858e-06, -2.9964020e-03, 1.1912674e-06, 3.1378810e-03, -4.7497619e-07, -3.2873877e-03, 1.5167160e-06, 3.4424862e-03, -8.2830544e-07, -3.6068395e-03, 1.3258030e-06, 3.7790110e-03, -8.8472069e-07, -3.9618146e-03, 7.8399272e-07, 4.1550897e-03, 9.4238633e-07, -4.3612484e-03, -6.5476180e-07, 4.5798384e-03, 1.3147521e-06, -4.8158850e-03, 1.1060948e-06, 5.0668900e-03, -1.0068683e-06, -5.3375312e-03, 1.8923675e-06, 5.6257590e-03, -2.7600843e-06, -5.9366718e-03, 2.6151017e-06, 6.2655681e-03, 1.0952164e-06, -6.6234263e-03, -1.4409153e-06, 7.0078422e-03, 6.5568488e-06, -7.4474002e-03, 4.1755624e-06, 7.9485692e-03, -5.1738090e-07, -8.4451517e-03, -3.2200931e-06, 9.0422301e-03, -1.9446022e-07, -9.6977951e-03, -4.2498211e-07, 1.0441319e-02, 3.1125733e-07, -1.1293168e-02, -5.7311410e-07, 1.2267049e-02, -3.4413803e-06, -1.3413091e-02, -2.0913325e-06, 1.4770901e-02, 3.9203370e-07, -1.6399631e-02, 5.7135869e-07, 1.8405483e-02, -1.0601923e-06, -2.0938453e-02, 2.0605780e-06, 2.4239809e-02, 6.1669459e-07, -2.8730677e-02, 1.8451799e-06, 3.5195558e-02, 2.2839939e-07, -4.5341797e-02, 9.1616020e-06, 6.3556367e-02, -9.5154755e-07, -1.0605793e-01, 9.3506883e-05, 3.1807849e-01, 5.0026962e-01, 3.1807849e-01, 9.3506883e-05, -1.0605793e-01, -9.5154755e-07, 6.3556367e-02, 9.1616020e-06, -4.5341797e-02, 2.2839939e-07, 3.5195558e-02, 1.8451799e-06, -2.8730677e-02, 6.1669459e-07, 2.4239809e-02, 2.0605780e-06, -2.0938453e-02, -1.0601923e-06, 1.8405483e-02, 5.7135869e-07, -1.6399631e-02, 3.9203370e-07, 1.4770901e-02, -2.0913325e-06, -1.3413091e-02, -3.4413803e-06, 1.2267049e-02, -5.7311410e-07, -1.1293168e-02, 3.1125733e-07, 1.0441319e-02, -4.2498211e-07, -9.6977951e-03, -1.9446022e-07, 9.0422301e-03, -3.2200931e-06, -8.4451517e-03, -5.1738090e-07, 7.9485692e-03, 4.1755624e-06, -7.4474002e-03, 6.5568488e-06, 7.0078422e-03, -1.4409153e-06, -6.6234263e-03, 1.0952164e-06, 6.2655681e-03, 2.6151017e-06, -5.9366718e-03, -2.7600843e-06, 5.6257590e-03, 1.8923675e-06, -5.3375312e-03, -1.0068683e-06, 5.0668900e-03, 1.1060948e-06, -4.8158850e-03, 1.3147521e-06, 4.5798384e-03, -6.5476180e-07, -4.3612484e-03, 9.4238633e-07, 4.1550897e-03, 7.8399272e-07, -3.9618146e-03, -8.8472069e-07, 3.7790110e-03, 1.3258030e-06, -3.6068395e-03, -8.2830544e-07, 3.4424862e-03, 1.5167160e-06, -3.2873877e-03, -4.7497619e-07, 3.1378810e-03, 1.1912674e-06, -2.9964020e-03, -1.5425858e-06, 2.8597628e-03, 1.4547896e-06, -2.7303368e-03, -3.8909459e-07, 2.6066231e-03, -7.2851565e-07, -2.4894063e-03, 1.6771291e-06, 2.3745391e-03, 1.0502200e-06, -2.2664356e-03, 1.7149290e-06, 2.1639751e-03, -5.7723915e-07, -2.0635938e-03, 2.4790182e-07, 1.9693342e-03, -5.2954808e-07, -1.8780030e-03, 2.8432213e-07, 1.7908561e-03, -1.1088391e-06, -1.8662054e-02, 9.5084056e-07 2 | -------------------------------------------------------------------------------- /AnaMBE/fmobject.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // fmobject.h 16 | // 17 | // classes: FMObject 18 | // 19 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 20 | // 21 | // History: 11.03.1996: Creation 22 | // 23 | // ---------------------------------------------------------------------------- 24 | // Documentation: 25 | // 26 | // The FMObject is a base object that defines the naming capabilities of every 27 | // derived object. 28 | // 29 | // ============================================================================ 30 | 31 | #define _INC_FMOBJECT 32 | 33 | #ifndef _INC_STRING 34 | #include 35 | #endif 36 | 37 | #ifndef _INC_CONSTANT 38 | #include "constant.h" 39 | #endif 40 | 41 | #ifndef _INC_ERROREXC 42 | #include "errorexc.h" 43 | #endif 44 | 45 | // ============================================================================ 46 | 47 | class FMObject 48 | { 49 | public: 50 | // Default constructor 51 | FMObject() 52 | { 53 | strcpy(ObjectName,"No Name"); 54 | }; 55 | // Contructor that gives a name to the object 56 | FMObject(const char *Name) // Exception 57 | { 58 | if (strlen(Name)+1<50) 59 | { 60 | strcpy(ObjectName,Name); 61 | } 62 | else 63 | { 64 | strcpy(ObjectName,"Name too long"); 65 | } 66 | }; 67 | // Destructor 68 | ~FMObject() 69 | { 70 | }; 71 | 72 | // Give a name to the object 73 | void SetName(const char *Name) 74 | { 75 | if (strlen(Name)+1<50) 76 | { 77 | strcpy(ObjectName,Name); 78 | } 79 | else 80 | { 81 | strcpy(ObjectName,"Name too long"); 82 | } 83 | 84 | }; 85 | // Give the name of the object 86 | char *GetName() 87 | { 88 | return ObjectName; 89 | }; 90 | 91 | protected: 92 | char ObjectName[50]; 93 | }; 94 | -------------------------------------------------------------------------------- /AnaMBE/complex.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // complex.h complex.cpp 16 | // 17 | // classes: CComplex 18 | // 19 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 20 | // 21 | // History: 21.03.1996: Creation 22 | // 23 | // ---------------------------------------------------------------------------- 24 | // Documentation: 25 | // 26 | // ============================================================================ 27 | 28 | #define _INC_COMPLEX 29 | 30 | // ============================================================================ 31 | // This class is useful for working with complex number. 32 | // ============================================================================ 33 | 34 | 35 | class CComplex 36 | { 37 | public: 38 | // Public Data Members 39 | double Real,Imaginary; 40 | // double Module,Phase; 41 | // Public Function Members 42 | CComplex(); // Default Constructor 43 | CComplex(double a,double b,int type=0); // if type=0 then Real=a 44 | // and Imaginary=b 45 | // if type=1 then Module=a 46 | // and Phase=b 47 | ~CComplex(); 48 | /*friend CComplex operator+(CComplex c1,CComplex c2); 49 | friend CComplex operator+(CComplex c1,double c2); 50 | friend CComplex operator+(double c1,CComplex c2); 51 | friend CComplex operator-(CComplex c1,CComplex c2); 52 | friend CComplex operator-(CComplex c1,double c2); 53 | friend CComplex operator-(double c1,CComplex c2); 54 | friend CComplex operator*(CComplex c1,CComplex c2); 55 | friend CComplex operator*(CComplex c1,double c2); 56 | friend CComplex operator*(double c1,CComplex c2); 57 | friend CComplex operator/(CComplex c1,CComplex c2); 58 | friend CComplex operator/(CComplex c1,double c2); 59 | friend CComplex operator/(double c1,CComplex c2); 60 | friend CComplex operator^(CComplex c1,double c2);*/ 61 | friend int operator==(CComplex c1,CComplex c2); 62 | CComplex operator=(CComplex c1); 63 | CComplex operator=(double c1); 64 | friend CComplex Conjugate(CComplex c1); 65 | double GetModule(); 66 | double GetPhase(); 67 | 68 | public: 69 | void RIToMP(); // Convert a complex (real,imaginary) number 70 | // into a complex (Module,Phase) number 71 | void MPToRI(); // Convert a complex (Module,Phase) number 72 | // into a complex (Real,Imaginary) number 73 | }; 74 | -------------------------------------------------------------------------------- /AnaMBE/func.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // func.cpp 16 | // 17 | // functions: minab(int,int) (func.h) 18 | // maxab(int,int) (func.h) 19 | // round(double) (func.h) 20 | // Convert16to8(SoundFile*,const char*) 21 | // Convert16to4(SoundFile*,const char*) 22 | // 23 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 24 | // 25 | // History: 03.10.1995: Creation 26 | // 23.11.1995: Formalisation 27 | // 11.03.1996: #define #ifndef 28 | // 30.07.1996: Convert16to8 and Convert16to8 29 | // 30 | // ---------------------------------------------------------------------------- 31 | // Documentation: 32 | // 33 | // ============================================================================ 34 | 35 | #ifndef _INC_STDLIB 36 | #include 37 | #endif 38 | 39 | #ifndef _INC_FUNC 40 | #include "func.h" 41 | #endif 42 | 43 | // ============================================================================ 44 | 45 | // Give the minimum of a and b 46 | int minab(int a,int b) 47 | { 48 | if (a>b) // If a=b return b 49 | { 50 | return b; 51 | } 52 | else 53 | { 54 | return a; 55 | } 56 | }; 57 | 58 | // ============================================================================ 59 | 60 | // Give the maximum of a and b 61 | int maxab(int a,int b) 62 | { 63 | if (a>b) // If a=b return b 64 | { 65 | return a; 66 | } 67 | else 68 | { 69 | return b; 70 | } 71 | }; 72 | 73 | // ============================================================================ 74 | 75 | // Give the rounded value of a 76 | int round(double a) 77 | { 78 | int value; 79 | double diff; 80 | value=int(a); 81 | diff=a-value; 82 | if (diff>=0) 83 | { 84 | if (diff>=0.5) 85 | { 86 | value++; 87 | } 88 | } 89 | else 90 | { 91 | if (diff<=-0.5) 92 | { 93 | value--; 94 | } 95 | } 96 | return value ; 97 | }; 98 | 99 | // ============================================================================ 100 | 101 | // Convert a sound file from 16kHz to 4kHz 102 | void Convert16to4(SoundFile* Son,const char* Name) 103 | { 104 | long int i; 105 | short* SAMPLE=new short[Son->Length()]; 106 | Son->LoadSamples(Son->Length(),0,SAMPLE); 107 | FILE* ficconv; 108 | ficconv=fopen(Name,"wb"); 109 | for(i=0;iLength();i=i+4) 110 | { 111 | fwrite(SAMPLE+i,sizeof(short),1,ficconv); 112 | } 113 | fclose(ficconv); 114 | delete SAMPLE; 115 | }; 116 | 117 | // ============================================================================ 118 | 119 | // Convert a sound file from 16kHz to 8kHz 120 | void Convert16to8(SoundFile* Son,const char* Name) 121 | { 122 | long int i; 123 | short* SAMPLE=new short[Son->Length()]; 124 | Son->LoadSamples(Son->Length(),0,SAMPLE); 125 | FILE* ficconv; 126 | ficconv=fopen(Name,"wb"); 127 | for(i=0;iLength();i=i+2) 128 | { 129 | fwrite(SAMPLE+i,sizeof(short),1,ficconv); 130 | } 131 | fclose(ficconv); 132 | delete SAMPLE; 133 | }; 134 | -------------------------------------------------------------------------------- /AnaMBE/anambe.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | 15 | #include 16 | #include 17 | 18 | #ifndef _INC_PITCHANA 19 | #include "pitchana.h" 20 | #endif 21 | 22 | #ifndef _INC_MBEPARAM 23 | #include "mbeparam.h" 24 | #endif 25 | 26 | #ifndef _INC_MBEANALY 27 | #include "mbeanaly.h" 28 | #endif 29 | 30 | #ifndef _INC_MATH 31 | #include "math.h" 32 | #endif 33 | 34 | int main(int argc, char **argv) 35 | { 36 | char *mbe_file_name,*f0_file_name,*s16_file_name, output_s16[255],output_pm[255]; 37 | int Freq=16000,FrameLength=512, FrameShift=80, Nfft=512; 38 | long int FirstSample=0, LastSample=0; 39 | 40 | MBEPitchAnalyserNoVoicing_A *a_PitchAnalyser; 41 | FrameMBEPitch_A *a_FramePitch; 42 | SoundRAW *a_SoundFile; 43 | PitchObject *a_PitchCurve; 44 | 45 | if ( (argc!=10) && 46 | (argc!=7)) 47 | { 48 | fprintf(stderr,"USAGE: %s s16_data f0_data mbe_res " 49 | "FirstSample=%li LastSample=%li " 50 | "[FFT=%i Freq=%i FrameLength=%i FrameShift=%i ]\n", 51 | argv[0],FirstSample,LastSample,Nfft,Freq,FrameLength,FrameShift); 52 | exit(1); 53 | } 54 | 55 | s16_file_name=argv[1]; 56 | f0_file_name=argv[2]; 57 | mbe_file_name=argv[3]; 58 | FirstSample=atoi(argv[4]); 59 | LastSample=atoi(argv[5]); 60 | 61 | if (argc==10) 62 | { 63 | Nfft=atoi(argv[6]); 64 | Freq=atoi(argv[7]); 65 | FrameLength=atoi(argv[8]); 66 | FrameShift=atoi(argv[9]); 67 | } 68 | else 69 | { 70 | FILE *init_file; 71 | 72 | init_file=fopen(argv[6],"rt"); 73 | if ((fscanf(init_file," Nfft= %i ",&Nfft)!=1) || 74 | (fscanf(init_file," Freq= %i ",&Freq)!=1) || 75 | (fscanf(init_file," FrameLength= %i ",&FrameLength)!=1) || 76 | (fscanf(init_file," FrameShift= %i ",&FrameShift)!=1)) 77 | { 78 | fprintf(stderr,"Parameters: Nfft, Freq, FrameLength, FrameShift\n"); 79 | exit(1); 80 | } 81 | fclose(init_file); 82 | } 83 | 84 | 85 | a_SoundFile= new SoundRAW(s16_file_name, s16_file_name, Freq); 86 | 87 | int nb_tranche= ((FrameLength-FrameShift)/2 +LastSample-FirstSample)/ FrameShift; 88 | int MaxRaie=80; 89 | int Comp=1; 90 | 91 | a_PitchCurve= new PitchObject(nb_tranche, FrameLength, FrameShift,FirstSample,LastSample); 92 | a_PitchCurve->LoadParameters(f0_file_name); 93 | 94 | AnalyseParameters par(Freq,FrameLength,FrameShift,FirstSample,LastSample); 95 | MBE_Parameters mbepar("MBE Parameters",0,nb_tranche,MaxRaie,Comp,par); 96 | MBE_Analyser_A mbeanalyser("MBE Analyser",FrameLength,FrameShift,Nfft,MaxRaie,MaxRaie); 97 | mbeanalyser.IO_Def(a_SoundFile, a_PitchCurve, &mbepar); 98 | mbeanalyser.Process(); 99 | mbepar.SaveParameters(mbe_file_name); 100 | 101 | return(0); 102 | } 103 | -------------------------------------------------------------------------------- /AnaMBE/mbefunc.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // mbefunc.h mbe.cpp 16 | // 17 | // functions: InnerProduct 18 | // Interpola 19 | // GetErrorValue 20 | // PosMin 21 | // LowPassFilter 22 | // HammingWindow 23 | // Windowing 24 | // AutoCorrelation 25 | // 26 | // Author: Fabrice Malfrère - TCTS Labs - FRIA Researcher 27 | // 28 | // History: 15.03.1996: Creation from pitchmbe.h 29 | // 30 | // ---------------------------------------------------------------------------- 31 | // Documentation: 32 | // 33 | // ============================================================================ 34 | 35 | #define _INC_MBEFUNC 36 | 37 | // ---------------------------------------------------------------------------- 38 | // Compute the inner product of two vectors. The dimension of the vectors is 39 | // given by Dim 40 | double InnerProduct(double *Signal1, double *Signal2, 41 | short int Dim); // Excepttion 42 | 43 | // ---------------------------------------------------------------------------- 44 | 45 | // Determine by interpolation the signal's value in NewIndex position 46 | double Interpola(double *Signal,short int Dim,double NewIndex); // Exception 47 | 48 | // ---------------------------------------------------------------------------- 49 | 50 | // Evaluate the error function for a value specified of the double of the 51 | // period 52 | double GetErrorValue(int Period2,short int Width, 53 | double Energy,double Sommw4,double *Autocorr);// Exception 54 | 55 | // ---------------------------------------------------------------------------- 56 | 57 | // Determine the position of the signal's minimum 58 | short int PosMin(double *Signal,short int Dim); // Exception 59 | 60 | // ---------------------------------------------------------------------------- 61 | 62 | // Determine the position of the signal's maximum 63 | short int PosMax(double *Signal,short int Dim); 64 | 65 | // ---------------------------------------------------------------------------- 66 | 67 | // Low-Pass filtering 68 | double *LowPassFilter(double *Coef,short int Order, 69 | double *Signal,long int Length); // Exception 70 | 71 | // ---------------------------------------------------------------------------- 72 | 73 | // Create Hamming window 74 | void HammingWindow(double *wind,short int Width); // Exception 75 | 76 | // ---------------------------------------------------------------------------- 77 | 78 | // Compute the product Signal1*Signal2 79 | void Windowing(double *Signal1,double *Signal2,short int Dim); // Exception 80 | 81 | // ---------------------------------------------------------------------------- 82 | 83 | // Compute the autocorrelation of Signal 84 | void Autocorrelation(double *Signal,double *Autocorr, 85 | short int Length,short int Order); // Exception 86 | -------------------------------------------------------------------------------- /AnaMBE/signalpr.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // signalpr.h signalpr.cpp 16 | // 17 | // functions: 18 | // 19 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 20 | // 21 | // History: 21.03.1996: Creation from mathlib.c and dsplib.c (T.Dutoit) 22 | // 25.03.1996: Modification of Norm2_CV (vectord + first + last) 23 | // 24 | // ---------------------------------------------------------------------------- 25 | // Documentation: 26 | // 27 | // ============================================================================ 28 | 29 | #define _INC_SIGNALPR 30 | 31 | #ifndef _INC_DATATYPE 32 | #include "datatype.h" 33 | #endif 34 | 35 | #ifndef _INC_COMPLEX 36 | #include "complex.h" 37 | #endif 38 | 39 | // ============================================================================ 40 | 41 | // Compute the product element dy element of two vector 42 | void eltmult_V(Vectord v1,Vectord v2, Vectord* Result); 43 | 44 | // ============================================================================ 45 | 46 | // Divide a complex vector by a real vector 47 | void div_CVV(VectorComplex v1,Vectord v2,CComplex* Result); 48 | 49 | // ============================================================================ 50 | 51 | // Norm of a vector (double) 52 | double norm2_V(Vectord v1); 53 | 54 | // ============================================================================ 55 | 56 | // Norm of a complex vector 57 | double norm2_CV(VectorComplex *v1,unsigned short First=0, 58 | unsigned short Last=-1); 59 | 60 | // ============================================================================ 61 | 62 | // Innerproduct of a double vector with a complex vector 63 | CComplex innerproduct_VCV(Vectord v1,VectorComplex v2); 64 | 65 | // ============================================================================ 66 | 67 | // Abs of a vector (double) 68 | void abs_V(Vectord v1,Vectord* result); 69 | 70 | // ============================================================================ 71 | 72 | // Abs of a complex vector 73 | void abs_CV(VectorComplex v1,Vectord* result); 74 | 75 | // ============================================================================ 76 | 77 | // Sum of a vector (double) 78 | double sum_V(Vectord v1); 79 | 80 | // ============================================================================ 81 | 82 | // 83 | void freqz_FIR(Vectord ZCoef,short first,short last,Vectord Omega, 84 | VectorComplex* FreqResp); 85 | 86 | // ============================================================================ 87 | 88 | // Compute the complex FFT of a real signal 89 | void fft_R(Vectord Signal,VectorComplex* ComplexFFT); 90 | void initialisation_RFFT(int N,Vectord* cossin); 91 | 92 | // ============================================================================ 93 | 94 | // FFT with a split radix method of length (N/2) 95 | void rfft(VectorComplex* v1,Vectord* cossin,int N); // Reorganisation 96 | void fft(VectorComplex* v1,Vectord* cossin,int N); 97 | -------------------------------------------------------------------------------- /AnaMBE/autocorr.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // autocorr.h lpccep.cpp 16 | // 17 | // classes: AutoCorr_E 18 | // AutoCorr_A 19 | // AutoCorr2_A 20 | // 21 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 22 | // 23 | // History: 13.03.1996: Creation from lpccep.h 24 | // Exception handling 25 | // 16.06.1996: new block for autocorrelation (used in pda) 26 | // AutoCorr2_A 27 | // 28 | // ---------------------------------------------------------------------------- 29 | // Documentation: 30 | // 31 | // ============================================================================ 32 | 33 | #define _INC_AUTOCORR 34 | 35 | #ifndef _INC_CONSTANT 36 | #include "constant.h" 37 | #endif 38 | 39 | #ifndef _INC_ERROREXC 40 | #include "errorexc.h" 41 | #endif 42 | 43 | #ifndef _INC_FMOBJECT 44 | #include "fmobject.h" 45 | #endif 46 | 47 | #ifndef _INC_DATATYPE 48 | #include "datatype.h" 49 | #endif 50 | 51 | // ============================================================================ 52 | // Compute an autocorrelation on a frame 53 | // ============================================================================ 54 | 55 | // ------- 56 | // Entity 57 | // ------- 58 | 59 | class AutoCorr_E : public FMObject 60 | { 61 | public: 62 | // Default constructor 63 | AutoCorr_E() {}; 64 | // Destructor 65 | ~AutoCorr_E() {}; 66 | 67 | // Define the I/O 68 | virtual void IO_Def(Vectord *Frame,Vectord *AutoCorrCoef)=0; 69 | // Process 70 | virtual int Process()=0; 71 | // Reset of the bloc 72 | virtual void Reset()=0; 73 | 74 | // Order of the autocorrelation analysis 75 | int Order; 76 | // Width of the frame 77 | int Width; 78 | 79 | protected: 80 | Vectord *Sampl; // input (frame samples) 81 | Vectord *AutoCorr; // output (auto-correlation coefficients) 82 | }; 83 | 84 | // ------------- 85 | // Architecture 86 | // ------------- 87 | 88 | // Width-1 89 | // a[i]= + [s(j)*s(j+i)] 0<=i<=Order 90 | // j=0 91 | class AutoCorr_A : public AutoCorr_E 92 | { 93 | public: 94 | // Default constructor 95 | AutoCorr_A(); 96 | // Constructor with name 97 | AutoCorr_A(const char *Name); 98 | // Destructor 99 | ~AutoCorr_A(); 100 | 101 | // Define the I/O 102 | virtual void IO_Def(Vectord *Frame,Vectord *AutoCorrCoef); 103 | // Process 104 | virtual int Process(); 105 | // Reset the block 106 | virtual void Reset(); 107 | }; 108 | 109 | // Width-1 110 | // a[i]= + [s(j)*s(j-i)] first<=i<=last 111 | // j=0 112 | class AutoCorr2_A : public AutoCorr_E 113 | { 114 | public: 115 | // Default constructor 116 | AutoCorr2_A(); 117 | // Constructor with name 118 | AutoCorr2_A(const char *Name,short int Dec,short int First,short int Last); 119 | // Destructor 120 | ~AutoCorr2_A(); 121 | 122 | // Define the I/O 123 | virtual void IO_Def(Vectord *Frame,Vectord *AutoCorrCoef); 124 | // Process 125 | virtual int Process(); 126 | // Reset the block 127 | virtual void Reset(); 128 | protected: 129 | // Internal Variables 130 | short int dec,first,last; 131 | }; 132 | 133 | -------------------------------------------------------------------------------- /AnaMBE/mbeanaly.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // mbeanalsy.h mbe.cpp 16 | // 17 | // classes: MBE_Analyser_A 18 | // 19 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 20 | // 21 | // History: 21.03.1996: Creation from T.Dutoit pascal program 22 | // 23 | // ---------------------------------------------------------------------------- 24 | // Documentation: 25 | // 26 | // ============================================================================ 27 | 28 | #define _INC_MBEANALY 29 | 30 | #ifndef _INC_FMOBJECT 31 | #include "fmobject.h" 32 | #endif 33 | 34 | #ifndef _INC_DATATYPE 35 | #include "datatype.h" 36 | #endif 37 | 38 | #ifndef _INC_COMPLEX 39 | #include "complex.h" 40 | #endif 41 | 42 | // ============================================================================ 43 | // Class MBE_Analyser 44 | // ============================================================================ 45 | 46 | #define NptsError 9 47 | 48 | // ------------------------- 49 | // Architecture (No entity) 50 | // ------------------------- 51 | 52 | class MBE_Analyser_A : public FMObject 53 | { 54 | public: 55 | // Constructor 56 | MBE_Analyser_A(const char *Name,unsigned short WindowLength, 57 | unsigned short WindowShift,unsigned short NpointsFFT, 58 | unsigned short NMax_Raie,unsigned short NMaxRaiesAnal); 59 | // Destructor 60 | ~MBE_Analyser_A(); 61 | 62 | // Define the I/O 63 | virtual void IO_Def(SoundFile *Son,PitchObject *Pitch,MBE_Parameters *MBE); 64 | // Process 65 | virtual int Process(); 66 | // Reset the block 67 | virtual void Reset(); 68 | protected: 69 | SoundFile *son; // Input sound 70 | PitchObject *pitch; // Input first estimation of the pitch 71 | MBE_Parameters *mbe; // Output MBE parameters 72 | 73 | // Internal Variables 74 | Vectord *SigDoub; 75 | VectorComplex *SigSpectrum; 76 | VectorComplex *SigSpectrum2; 77 | long int DebutFen; 78 | short int OffSet; 79 | double SearchFreq; 80 | double Norm2Sig; 81 | double Sommw; 82 | double Sommw2; 83 | double Sommw4; 84 | unsigned short FirstRaieSpect,LastRaieSpect; 85 | unsigned short WinLength; 86 | unsigned short WinShift; 87 | 88 | unsigned short NMaxRaies; 89 | unsigned short NRaiesAnal; 90 | unsigned short NFFT; 91 | Vectord *HammingW; 92 | Vectord *RealHamSpect; 93 | Vectord *ErrorTab; 94 | 95 | private: 96 | // Estimation of the magnitude of the sinusoidal wave 97 | void GetSinAmpPhase(double SinFreq,unsigned short int FirstRaie, 98 | unsigned short int LastRaie,int FreqRelease, 99 | double *SinAmplitude,double *SinPhase); 100 | // Estimation of the standard deviation of the noise 101 | double GetNoiseSigma(unsigned short FirstRaie,unsigned short LastRaie); 102 | // Estimation of the standard deviation of the noise in contiguous 103 | // frequency bands (bandwith 150 Hz) 104 | void GetNoiseBandSigma(MBE_Parameters* AnalysisParam,short frame); 105 | // Estimation of the minimal relative error of modelisation 106 | double GetErrorVal(double SinFreq,int FreqRelease, 107 | MBE_Parameters* AnalysisParam,short frame); 108 | }; 109 | 110 | -------------------------------------------------------------------------------- /Resynthesis/Src/filter_file.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | * This program is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU Affero General Public License as published by 4 | * the Free Software Foundation, either version 3 of the License, or 5 | * (at your option) any later version. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU Affero General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU Affero General Public License 13 | * along with this program. If not, see . 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #if defined __powerpc__ || defined __m86k__ 22 | #define SWAP_MACHINE 23 | #endif 24 | 25 | #ifdef RESAMPLING16_8 26 | 27 | /* Alien sample rate for resynthesis */ 28 | int TargetFreq=8000; 29 | 30 | /* Coef such that in_coef*in_len=out_coef*out_len */ 31 | int in_coef=1; /* 16000*1 = 8000*2 */ 32 | int out_coef=2; 33 | 34 | double filter_coef[]={ 35 | #include "COEF_FILTER/filtr16_8" 36 | }; 37 | #endif 38 | 39 | #ifdef RESAMPLING16_11 40 | /* Alien sample rate for resynthesis */ 41 | int TargetFreq=11000; 42 | 43 | /* Coef such that in_coef*in_len=out_coef*out_len */ 44 | int in_coef=11; /* 16000*11 = 11000*16 */ 45 | int out_coef=16; 46 | 47 | double filter_coef[]={ 48 | #include "COEF_FILTER/filtr16_11" 49 | }; 50 | #endif 51 | 52 | #define NB_COEF sizeof(filter_coef)/sizeof(double) 53 | 54 | /* 55 | * Resample a Little Endian audio file 56 | */ 57 | void filter_file(char *name_filtered, char *name_source) 58 | { 59 | FILE *filtered, *source; 60 | short *in_buff, *out_buff; 61 | long in_pos,out_pos; /* Position in in_buff and out_buff (step are different) */ 62 | long coef_base; /* Position of the first coef being used */ 63 | long in_base; /* Position of the first in value being used */ 64 | int Order; /* Order of the filter */ 65 | int HalfOrder; 66 | long i, nb_read,in_length; 67 | 68 | 69 | /* Check if the work is already done */ 70 | if ((filtered=fopen(name_filtered,"r"))!=NULL) 71 | { 72 | fclose(filtered); 73 | fprintf(stderr,"\nALLREADY RESAMPLED %s!\n",name_filtered); 74 | return; 75 | } 76 | 77 | if ((filtered=fopen(name_filtered,"w"))==NULL) 78 | { 79 | fprintf(stderr,"Fatal error with %s!\n",name_filtered); 80 | exit(1); 81 | } 82 | 83 | if ((source=fopen(name_source,"r"))==NULL) 84 | { 85 | fprintf(stderr,"Fatal error with %s!\n",name_source); 86 | exit(1); 87 | } 88 | 89 | Order= NB_COEF; 90 | 91 | fseek(source,(long)0,SEEK_END); 92 | in_length= ftell(source) / sizeof(short); 93 | fseek(source,(long)0,SEEK_SET); 94 | 95 | in_buff=(short *) calloc(in_length+Order+2, sizeof(short)); 96 | out_buff= (short *) calloc( ((in_length+Order+1)*in_coef)/out_coef, sizeof(short)); 97 | 98 | /* Head Filled up to Half Order with 0 */ 99 | for(i=0; 2*i< Order/in_coef; i++) 100 | in_buff[i]=0; 101 | HalfOrder=i; 102 | 103 | nb_read= fread(&in_buff[HalfOrder], sizeof(short), in_length, source); 104 | #ifdef SWAP_MACHINE 105 | swab((char *) &in_buff[HalfOrder], (char *) &in_buff[HalfOrder], sizeof(short)*in_length); 106 | #endif 107 | 108 | /* Tail filled up to half order with 0 */ 109 | for(i=0; i< HalfOrder; i++) 110 | in_buff[i+nb_read+HalfOrder]=0; 111 | 112 | /* Loop on output values */ 113 | for(coef_base=0,out_pos=0,in_base=0 ; 114 | out_pos*out_coef < nb_read*in_coef; 115 | out_pos++) 116 | { 117 | double out_double; 118 | 119 | /* Step in the input buffer ? */ 120 | while (in_base*in_coef< out_pos*out_coef) 121 | in_base++; 122 | 123 | coef_base= in_base*in_coef - out_pos*out_coef; 124 | 125 | out_double=0.0; 126 | for(in_pos=0; in_pos*in_coef+coef_base < Order; in_pos++) 127 | out_double+= filter_coef[in_pos*in_coef+coef_base] 128 | * (double) in_buff[in_pos+in_base]; 129 | 130 | out_double*= in_coef; 131 | 132 | if (out_double>32768.0) 133 | { 134 | fprintf(stderr,"CLIPPING %f\n",out_double); 135 | out_double=32767; 136 | } 137 | if (out_double<-32767.0) 138 | { 139 | fprintf(stderr,"CLIPPING %f\n",out_double); 140 | out_double=-32767; 141 | } 142 | out_buff[out_pos]= (short) out_double; 143 | } 144 | 145 | #ifdef SWAP_MACHINE 146 | swab((char*) out_buff,(char *) out_buff, sizeof(short) *out_pos); 147 | #endif 148 | fwrite(out_buff, sizeof(short), out_pos, filtered); 149 | 150 | fclose(filtered); 151 | fclose(source); 152 | } 153 | 154 | /* 155 | main() 156 | { 157 | filter_file("test1.tmp","test2.tmp"); 158 | } 159 | */ 160 | -------------------------------------------------------------------------------- /AnaMBE/mbeparam.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // mbeparam.h mbe.cpp 16 | // 17 | // classes: MBE_Parameters 18 | // 19 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 20 | // 21 | // History: 08.03.1996: Creation (MatchProsody not implemented) 22 | // 10.03.1996: Adding object name 23 | // 11.03.1996: Creating base object containing the name 24 | // Frame parameters object 25 | // 26 | // ---------------------------------------------------------------------------- 27 | // Documentation: 28 | // 29 | // ============================================================================ 30 | 31 | #define _INC_MBEPARAM // Include or not this file 32 | 33 | #ifndef _INC_FMOBJECT 34 | #include "fmobject.h" 35 | #endif 36 | 37 | #ifndef _INC_DATATYPE 38 | #include "datatype.h" 39 | #endif 40 | 41 | // ============================================================================ 42 | 43 | class MBE_Parameters : public FMObject 44 | { 45 | public: 46 | AnalyseParameters Param; // Sample frequency, width, shift, ... 47 | unsigned short NMaxTrchs; // Max number of synthesis frames 48 | unsigned char NMaxRaies; // Max number of harmonics 49 | unsigned char NRaiesNV; // Number of noise bands 50 | // (Freq div 2 div 150) 51 | unsigned char PhaseComp; // TRUE if phases are to be stored 52 | unsigned short NTranches; // Number of frames 53 | 54 | Vectoruc *NbreRaies; // Number of harmonics f(F0) 55 | // The number of noise bands 56 | // is constant 57 | Vectorus *NPoints; // Number of analysis synthesis points 58 | Vectord *F0; // Synthesis pitch 59 | Vectord *Energy; // Energy mesured on the FFT 60 | Vectord *LSError; // Harmonics modelisation Error 61 | // Normalized by complex least square 62 | 63 | Vectord **Amp; // Magnitudes vector of the spectrum lines 64 | Vectord **Phases; // Phases vector of the spectrum lines 65 | Vectord **Sigma; // V/NV ratio of the spectrum lines 66 | 67 | public: 68 | // Default constructor 69 | MBE_Parameters(); 70 | // Constructor: Name of the object 71 | // Number of frames 72 | // Max number of frames 73 | // Max number of spectrum lines 74 | // Phase computation or not 75 | // Sample frequency 76 | MBE_Parameters(const char *Name,short int NumberOfFrames, 77 | unsigned char NMaxFr,unsigned char NMaxRa, 78 | unsigned char Comp,AnalyseParameters Fr); // Exception 79 | // Constructor: Number of frames 80 | // Max number of frames 81 | // Max number of spectrum lines 82 | // Phase computation or not 83 | // Sample frequency 84 | MBE_Parameters(short int NumberOfFrames,unsigned char NMaxFr, 85 | unsigned char NMaxRa,unsigned char Comp, 86 | AnalyseParameters Fr); // Exception 87 | ~MBE_Parameters(); // Destructor 88 | 89 | // Load the parameters from the file FileName 90 | // Return 1 if no troubles 91 | // -1 if troubles 92 | virtual int LoadParameters(const char *FileName); // Exception 93 | // Save the parameters to the file FileName 94 | // Return 1 if no troubles 95 | // -1 if troubles 96 | virtual int SaveParameters(const char *FileName); // Exception 97 | // Copy the parameters of a frame to another 98 | // Return 1 if no troubles 99 | // -1 if troubles 100 | virtual int CopyFrameParam(short int source, 101 | short int destination); // Exception 102 | // Adapt the parameters to the desired prosody 103 | // Return 1 if no troubles 104 | // -1 if troubles 105 | virtual int MatchProsody(Vectord *Pitch,Vectord *Timing); // Exception 106 | }; 107 | -------------------------------------------------------------------------------- /AnaMBE/errorexc.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // errorexc.h 16 | // 17 | // classes: FMError 18 | // 19 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 20 | // 21 | // History: 08.03.1996: Creation 22 | // 10.03.1996: Identification number of the error 23 | // 13.03.1996: New constructors 24 | // 25 | // ---------------------------------------------------------------------------- 26 | // Documentation: 27 | // 28 | // ============================================================================ 29 | 30 | #define _INC_ERROREXC 31 | 32 | #ifndef _INC_STRING 33 | #include 34 | #endif 35 | 36 | #ifndef _INC_CONSTANT 37 | #include "constant.h" 38 | #endif 39 | 40 | // ============================================================================ 41 | 42 | class FMError 43 | { 44 | public: 45 | // Constructor: Error Message 46 | FMError(const char *ErrorMessage) 47 | { 48 | if (strlen(ErrorMessage)+1<1000) 49 | { 50 | strcpy(Message,ErrorMessage); 51 | } 52 | else 53 | { 54 | strcpy(Message,"Message too long"); 55 | } 56 | IDError=-1; // IDError not used 57 | }; 58 | // Construct a new FMError with a completed message 59 | FMError(const char *Mes1,const char *Mes2,FMError Error1) 60 | { 61 | if ((strlen(Mes1)+strlen(Mes2)+strlen(Error1.GetErrorMessage())+3) 62 | <1000) 63 | { 64 | strcpy(Message,Mes1); 65 | strcat(Message,Mes2); 66 | strcat(Message,Error1.GetErrorMessage()); 67 | } 68 | else 69 | { 70 | strcpy(Message,"Message too long"); 71 | } 72 | IDError=-1; 73 | }; 74 | // Construct a new FMError with a new message 75 | FMError(const char *Mes1,const char *Mes2) 76 | { 77 | if ((strlen(Mes1)+strlen(Mes2)+2)<1000) 78 | { 79 | strcpy(Message,Mes1); 80 | strcat(Message,Mes2); 81 | } 82 | else 83 | { 84 | strcpy(Message,"Message too long"); 85 | } 86 | IDError=-1; 87 | }; 88 | // Construct a new FMError with a new message 89 | FMError(const char *Mes1,const char *Mes2,const char *Mes3) 90 | { 91 | if ((strlen(Mes1)+strlen(Mes2)+strlen(Mes3)+3)<1000) 92 | { 93 | strcpy(Message,Mes1); 94 | strcat(Message,Mes2); 95 | strcat(Message,Mes3); 96 | } 97 | else 98 | { 99 | strcpy(Message,"Message too long"); 100 | } 101 | IDError=-1; 102 | }; 103 | // Constructor: Error ID 104 | FMError(short int Number) 105 | { 106 | IDError=Number; 107 | strcpy(Message,"NU"); // Message not used 108 | }; 109 | // Constructor: Error ID and Error Message 110 | FMError(const char *ErrorMessage,short int Number) 111 | { 112 | IDError=Number; 113 | if (strlen(ErrorMessage)+1<1000) 114 | { 115 | strcpy(Message,ErrorMessage); 116 | } 117 | else 118 | { 119 | strcpy(Message,"Message too long"); 120 | } 121 | }; 122 | // Default constructor: 'NE',0 123 | FMError() 124 | { 125 | strcpy(Message,"N0 ERROR MESSAGE DEFINED"); 126 | IDError=0; // No error ==> IDError=0; 127 | }; 128 | // Destructor 129 | ~FMError() 130 | { 131 | }; 132 | 133 | // Return a pointer to the Message 134 | virtual const char *GetErrorMessage() 135 | { 136 | return Message; 137 | }; 138 | // Set the Message to the value of ErrorMessage 139 | virtual void SetErrorMessage(const char *ErrorMessage) 140 | { 141 | if (strlen(ErrorMessage)+1<1000) 142 | { 143 | strcpy(Message,ErrorMessage); 144 | } 145 | }; 146 | 147 | protected: 148 | char Message[1000]; 149 | short int IDError; 150 | }; 151 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /TEST/generate_make.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # 3 | # Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Affero General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Affero General Public License 15 | # along with this program. If not, see . 16 | # 17 | # Purpose: light weight system to construct a Unix makefile dedicated 18 | # to build a Mbrola diphone database 19 | 20 | if (@ARGV < 4) 21 | { 22 | die("usage: generate_make.pl database path_raw path_mbe path_res [sampling_rate]"); 23 | } 24 | 25 | my $database_name = shift @ARGV || die("Waiting for database_name"); 26 | my $raw_path = shift @ARGV || die("Waiting for raw_path"); 27 | my $mbe_path = shift @ARGV || die("Waiting for mbe_path"); 28 | my $res_path = shift @ARGV || die("Waiting for res_path"); 29 | 30 | my $real_sampling_rate = shift @ARGV || 16000 ; # may not be there 31 | 32 | open(SEG_FILE,"<$database_name.seg") || die("can't read $database_name.seg"); 33 | open(MAK_FILE,">$database_name.mak") || die("can't write $database_name.mak"); 34 | 35 | # Read frame length param from .mbe file... 36 | open(MBE_FILE,"<$database_name.mbe") || die("can't read $database_name.mbe"); 37 | my $mbe_frame_length; 38 | my $mbe_frame_shift; 39 | while () 40 | { 41 | if ($_ =~ /FrameLength[]*=[ ]*([0-9]+)/) 42 | { $mbe_frame_length= $1; } 43 | if ($_ =~ /FrameShift[]*=[ ]*([0-9]+)/) 44 | { $mbe_frame_shift= $1; } 45 | } 46 | close(MBE_FILE); 47 | ($mbe_frame_length && $mbe_frame_shift) || die("FATAL: .mbe file doesn't define FrameLength and FrameShift\n"); 48 | 49 | # Test if the fr1.build file exist, if yes, defer the database_buid operation to this script */ 50 | if (-f "$database_name.build") 51 | { 52 | print MAK_FILE "$database_name : diph_resynth\n"; 53 | print MAK_FILE "\t$database_name.build\n"; 54 | } 55 | else 56 | { 57 | # older scheme: build command is inside the .mak file 58 | # database_build ce6 SYN/ 2.040 16000 90 1 59 | print MAK_FILE "$database_name : diph_resynth\n"; 60 | print MAK_FILE "\tdatabase_build $database_name $res_path $res_path 2.069 $real_sampling_rate $mbe_frame_shift 1\n"; 61 | } 62 | 63 | # Build the list of target diphones 64 | my $target_diphones=""; 65 | my $line_counter=0; 66 | while ($line=) 67 | { 68 | my ($wave_name, $left_name, $right_name, $begin, $end, $middle, $dummy) = split(/\s+/,$line,7); 69 | if ( !$wave_name || !$left_name || !$right_name || !$begin || !$end || !$middle ) 70 | { print "not a seg $line\n"; } 71 | else 72 | { 73 | # First, some sanity checks.... 74 | if (! open(WAVE_FILE,"<$raw_path$wave_name")) 75 | { 76 | print STDERR "***** FATAL ERROR\n$raw_path$wave_name does not exist\n"; 77 | next; 78 | } 79 | seek(WAVE_FILE,0,2); # seek(0,SEEK_END) 80 | my $file_size= tell(WAVE_FILE); 81 | close(WAVE_FILE); 82 | 83 | $file_size = int($file_size / 2) ; # number of samples 84 | 85 | # print "FILE SIZE= $raw_path$wave_name $file_size\n"; 86 | if ($begin - $mbe_frame_length < 0) 87 | { 88 | print STDERR "BEGIN_IS_SHORT $wave_name $left_name $right_name $begin $end $middle\n"; 89 | $begin = $mbe_frame_length + $mbe_frame_shift; 90 | } 91 | if ($end + $mbe_frame_length > $file_size) 92 | { 93 | print STDERR "END_IS_SHORT $wave_name $left_name $right_name $begin $end $middle\n"; 94 | $end = $file_size - $mbe_frame_length - $mbe_frame_shift; 95 | } 96 | 97 | # The diphone is correct !?!? 98 | if ( ($begin < $end) && ($begin < $middle) && ($middle < $end)) 99 | { 100 | # RULE TO GENERATE THE F0 FILE 101 | # RES/a-m.f0: RAW/cece.wav ce6.f0 102 | # anaf0 RAW/cece.wav RES/a-m.f0 1500 3504 ce6.f0 103 | my $out_name= "$mbe_path$line_counter"; 104 | my $source_name = "$raw_path$wave_name"; 105 | print MAK_FILE "$out_name.f0 : $source_name $database_name.f0\n"; 106 | print MAK_FILE "\tanaf0 '$source_name' $out_name.f0 $begin $end $database_name.f0\n"; 107 | 108 | # RULE TO GENERATE THE MBE FILE 109 | # RES/a-m.mbe: RES/a-m.f0 ce6.mbe 110 | # anambe RAW/cece.wav RES/a-m.f0 RES/a-m.mbe 1500 3504 ce6.mbe 111 | print MAK_FILE "$out_name.mbe: $out_name.f0 $database_name.mbe\n"; 112 | print MAK_FILE "\tanambe $source_name $out_name.f0 $out_name.mbe $begin $end $database_name.mbe\n"; 113 | 114 | # RULE TO GENERATE THE .s16 and .pm RESYNTH FILES 115 | # S16/a-m.s16: RES/a-m.mbe ce6.syn 116 | # resynth RAW/cece.wav RES/a-m.mbe S16/a-m ce6.syn 117 | print MAK_FILE "$res_path$line_counter.s16 : $out_name.mbe $database_name.syn\n"; 118 | print MAK_FILE "\t resynth $source_name $out_name.mbe $res_path$line_counter $database_name.syn\n"; 119 | print MAK_FILE "\n"; 120 | 121 | $target_diphones .= "$res_path$line_counter.s16 "; # collect the list of targets 122 | } 123 | else 124 | { 125 | print STDERR "****** FATAL ERROR\nCOULD NOT CORRECT $wave_name $left_name $right_name $begin $end $middle\n"; 126 | } 127 | $line_counter ++; 128 | } 129 | } 130 | 131 | print MAK_FILE "diph_resynth: $target_diphones\n"; 132 | close(MAK_FILE); 133 | 134 | close(SEG_FILE); 135 | -------------------------------------------------------------------------------- /AnaMBE/mbefunc.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | 15 | #ifndef _INC_STDLIB 16 | #include 17 | #endif 18 | 19 | #ifndef _INC_MATH 20 | #include 21 | #endif 22 | 23 | #ifndef _INC_MBEPARAM 24 | #include "mbeparam.h" 25 | #endif 26 | 27 | #ifndef _INC_MBEFUNC 28 | #include "mbefunc.h" 29 | #endif 30 | 31 | #ifndef _INC_PITCHANA 32 | #include "pitchana.h" 33 | #endif 34 | 35 | #ifndef _INC_ERROREXC 36 | #include "errorexc.h" 37 | #endif 38 | 39 | #ifndef _INC_CONSTANT 40 | #include "constant.h" 41 | #endif 42 | 43 | #ifndef _INC_MBEANALY 44 | #include "mbeanaly.h" 45 | #endif 46 | 47 | #ifndef _INC_SIGNALPR 48 | #include "signalpr.h" 49 | #endif 50 | 51 | // ============================================================================ 52 | // Functions 53 | // ============================================================================ 54 | 55 | // Compute the inner product of two vectors. The dimension of the vectors is 56 | // given by Dim 57 | double InnerProduct(double *Signal1, double *Signal2, short int Dim) 58 | { 59 | double temp=0; 60 | try 61 | { 62 | short int i; 63 | for(i=0;i Error \n"); 71 | } 72 | return temp; 73 | }; 74 | 75 | // ============================================================================ 76 | 77 | // Determine by interpolation the signal's value in NewIndex position 78 | double Interpola(double *Signal,short int Dim,double NewIndex) 79 | { 80 | try 81 | { 82 | //printf("\n %f\n",NewIndex); 83 | double prev,next; 84 | if ((NewIndex>Dim-1)||(NewIndex<0)) 85 | { 86 | throw FMError("\nFunction Interpola => New index not allowed\n"); 87 | } 88 | prev=Signal[(int)floor(NewIndex)]; 89 | next=Signal[(int)floor(NewIndex+1)]; 90 | return (prev+(NewIndex-floor(NewIndex))*(next-prev)); 91 | } 92 | catch (FMError& Error1) 93 | { 94 | throw Error1; 95 | } 96 | catch (...) 97 | { 98 | throw FMError("\nFunction Interpola => Error\n"); 99 | } 100 | }; 101 | 102 | // ============================================================================ 103 | 104 | // Evaluate the error function for a value specified of the double of the 105 | // period 106 | double GetErrorValue(int Period2,short int WindowWidth,double Energy, 107 | double Sommw4,double *Autocorr) 108 | { 109 | double temp1=0,temp2; 110 | try 111 | { 112 | int i; 113 | temp2=(double)(WindowWidth-1)*2/(double)Period2;// attention: 114 | // oversampling by 2 115 | for(i=1;i<=int(temp2);i++) 116 | { 117 | temp1+=Autocorr[i*Period2]; 118 | } 119 | temp2=(double)Period2/2; 120 | temp1=(2*temp1+Autocorr[0])*temp2; 121 | if (Energy==double(0)) 122 | { 123 | return 1E98; 124 | } 125 | } 126 | catch (...) 127 | { 128 | throw FMError("\nFunction GetErrorValue => Error\n"); 129 | } 130 | return ((Energy-temp1)/Energy/(1-temp2*Sommw4)); 131 | }; 132 | 133 | // ============================================================================ 134 | 135 | // Determine the position of the signal's minimum 136 | short int PosMin(double *Signal,short int Dim) 137 | { 138 | short int PosTemp=0; 139 | try 140 | { 141 | short int i; 142 | double temp; 143 | temp=1E99; 144 | for(i=0;i Error\n"); 156 | } 157 | return (PosTemp); 158 | }; 159 | 160 | // ============================================================================ 161 | 162 | // Determine the position of the signal's maximum 163 | short int PosMax(double *Signal,short int Dim) 164 | { 165 | short int PosTemp=0; 166 | try 167 | { 168 | short int i; 169 | double temp; 170 | temp=-1E99; 171 | for(i=0;itemp) 174 | { 175 | temp=Signal[i]; 176 | PosTemp=i; 177 | } 178 | } 179 | } 180 | catch (...) 181 | { 182 | throw FMError("\nFunction PosMax => Error\n"); 183 | } 184 | return (PosTemp); 185 | }; 186 | 187 | // ============================================================================ 188 | 189 | // This function must become a block in the futur 190 | // Low-Pass filtering 191 | double *LowPassFilter(double *Coef,short int Order,double *Signal,long int Length) 192 | { 193 | try 194 | { 195 | long int j,k; 196 | for(j=Order-1;j<(Length+Order-1);j ++) 197 | { 198 | Signal[j]=Coef[0]*Signal[j]; 199 | for(k=0;k<(Order-1);k++) 200 | { 201 | Signal[j]=Signal[j]+Coef[k+1]*(Signal[j+k+1]+Signal[j-k-1]); 202 | } 203 | } 204 | } 205 | catch (...) 206 | { 207 | throw FMError("\nFunction LowPassFilter => Error\n"); 208 | } 209 | return (Signal); 210 | }; 211 | 212 | // ============================================================================ 213 | 214 | // Create Hamming window 215 | void HammingWindow(double *wind,short int Width) 216 | { 217 | try 218 | { 219 | short int i; 220 | for(i=0;i Error\n"); 228 | } 229 | 230 | }; 231 | 232 | // ============================================================================ 233 | 234 | // Compute the product Signal1*Signal2. Result in Signal1 235 | void Windowing(double *Signal1,double *Signal2,short int Dim) 236 | { 237 | try 238 | { 239 | short int i; 240 | for(i=0;i Error\n"); 248 | } 249 | }; 250 | 251 | // ============================================================================ 252 | 253 | // Compute the autocorrelation of Signal 254 | void Autocorrelation(double *Signal,double *Autocorr, 255 | short int Length, short int Order) 256 | { 257 | try 258 | { 259 | double vr; 260 | short int i,j,k; 261 | for(i=0;i Error\n"); 275 | } 276 | }; 277 | -------------------------------------------------------------------------------- /Resynthesis/Src/COEF_FILTER/filtr20_16: -------------------------------------------------------------------------------- 1 | -2.5983886e-03, 6.3875042e-04, 6.7880864e-04, 7.2820222e-04, 7.2843649e-04, 6.4332791e-04, 4.7391797e-04, 2.5833353e-04, 5.8315253e-05, -6.5216342e-05, -7.6010980e-05, 2.1240508e-05, 1.8145942e-04, 3.3431424e-04, 4.1135460e-04, 3.7207297e-04, 2.2151826e-04, 9.1040279e-06, -1.8843015e-04, -2.9710403e-04, -2.7402485e-04, -1.2641042e-04, 9.0356545e-05, 2.9157800e-04, 3.9649477e-04, 3.5874892e-04, 1.8706400e-04, -5.7733256e-05, -2.8297817e-04, -4.0122347e-04, -3.6241008e-04, -1.7744620e-04, 8.7338481e-05, 3.2771792e-04, 4.5627279e-04, 4.0373153e-04, 1.9733971e-04, -9.0375477e-05, -3.5283954e-04, -4.8525607e-04, -4.3173074e-04, -2.0642968e-04, 1.0754103e-04, 3.9054918e-04, 5.3039887e-04, 4.6800709e-04, 2.2079505e-04, -1.2031941e-04, -4.2533259e-04, -5.7360161e-04, -5.0244911e-04, -2.3245754e-04, 1.3691519e-04, 4.6472140e-04, 6.2132740e-04, 5.4042022e-04, 2.4592872e-04, -1.5355321e-04, -5.0557488e-04, -6.7097725e-04, -5.7970720e-04, -2.5919424e-04, 1.7212264e-04, 5.4960007e-04, 7.2380178e-04, 6.2105410e-04, 2.7224625e-04, -1.9232365e-04, -5.9742807e-04, -7.7943142e-04, -6.6333509e-04, -2.8584319e-04, 2.1494953e-04, 6.4670922e-04, 8.3884857e-04, 7.0907275e-04, 2.9887140e-04, -2.4001933e-04, -7.0094586e-04, -9.0200204e-04, -7.5709696e-04, -3.1289506e-04, 2.6607823e-04, 7.5775460e-04, 9.6801311e-04, 8.0673753e-04, 3.2638308e-04, -2.9488697e-04, -8.1868075e-04, -1.0381281e-03, -8.5899187e-04, -3.4005375e-04, 3.2602141e-04, 8.8351998e-04, 1.1121789e-03, 9.1348060e-04, 3.5317635e-04, -3.6055288e-04, -9.5346113e-04, -1.1913927e-03, -9.7120261e-04, -3.6695356e-04, 3.9767884e-04, 1.0277171e-03, 1.2746002e-03, 1.0321396e-03, 3.8048904e-04, -4.3735735e-04, -1.1071489e-03, -1.3636433e-03, -1.0958333e-03, -3.9369759e-04, 4.8087142e-04, 1.1919008e-03, 1.4577407e-03, 1.1627738e-03, 4.0657931e-04, -5.2861419e-04, -1.2833563e-03, -1.5585445e-03, -1.2339896e-03, -4.1973238e-04, 5.8018899e-04, 1.3813255e-03, 1.6660347e-03, 1.3094448e-03, 4.3292452e-04, -6.3604620e-04, -1.4863019e-03, -1.7804313e-03, -1.3888249e-03, -4.4520797e-04, 6.9761851e-04, 1.6000725e-03, 1.9035011e-03, 1.4738196e-03, 4.5767686e-04, -7.6456691e-04, -1.7224356e-03, -2.0358774e-03, -1.5644248e-03, -4.7015301e-04, 8.3766870e-04, 1.8552178e-03, 2.1780702e-03, 1.6610103e-03, 4.8215890e-04, -9.1767659e-04, -1.9990414e-03, -2.3315619e-03, -1.7644277e-03, -4.9329691e-04, 1.0064197e-03, 2.1565879e-03, 2.4989329e-03, 1.8767689e-03, 5.0494989e-04, -1.1034401e-03, -2.3281481e-03, -2.6806015e-03, -1.9978237e-03, -5.1576725e-04, 1.2112564e-03, 2.5169007e-03, 2.8795804e-03, 2.1295844e-03, 5.2617074e-04, -1.3312186e-03, -2.7254595e-03, -3.0988762e-03, -2.2741785e-03, -5.3633096e-04, 1.4648173e-03, 2.9569523e-03, 3.3414744e-03, 2.4332624e-03, 5.4574278e-04, -1.6155816e-03, -3.2159474e-03, -3.6122187e-03, -2.6102274e-03, -5.5495009e-04, 1.7859413e-03, 3.5077548e-03, 3.9168508e-03, 2.8086075e-03, 5.6366741e-04, -1.9801934e-03, -3.8393057e-03, -4.2626123e-03, -3.0332382e-03, -5.7198727e-04, 2.2036379e-03, 4.2196845e-03, 4.6589710e-03, 3.2899981e-03, 5.7917652e-04, -2.4643761e-03, -4.6623160e-03, -5.1202879e-03, -3.5888943e-03, -5.8654764e-04, 2.7710917e-03, 5.1832474e-03, 5.6638884e-03, 3.9408962e-03, 5.9322295e-04, -3.1385854e-03, -5.8073443e-03, -6.3161594e-03, -4.3636099e-03, -5.9878422e-04, 3.5876047e-03, 6.5708723e-03, 7.1168041e-03, 4.8841727e-03, 6.0456273e-04, -4.1478733e-03, -7.5272685e-03, -8.1241037e-03, -5.5415028e-03, -6.0913723e-04, 4.8696509e-03, 8.7652781e-03, 9.4362399e-03, 6.4032107e-03, 6.1323731e-04, -5.8353329e-03, -1.0434886e-02, -1.1222074e-02, -7.5872249e-03, -6.1712450e-04, 7.1964231e-03, 1.2816497e-02, 1.3803589e-02, 9.3228142e-03, 6.1956916e-04, -9.2663628e-03, -1.6505027e-02, -1.7884647e-02, -1.2129559e-02, -6.2216851e-04, 1.2801448e-02, 2.3005409e-02, 2.5337477e-02, 1.7466290e-02, 6.2388703e-04, -2.0244413e-02, -3.7591047e-02, -4.3388904e-02, -3.1660182e-02, -6.2452217e-04, 4.6247925e-02, 1.0068714e-01, 1.5153012e-01, 1.8758083e-01, 2.0070518e-01, 1.8758083e-01, 1.5153012e-01, 1.0068714e-01, 4.6247925e-02, -6.2452217e-04, -3.1660182e-02, -4.3388904e-02, -3.7591047e-02, -2.0244413e-02, 6.2388703e-04, 1.7466290e-02, 2.5337477e-02, 2.3005409e-02, 1.2801448e-02, -6.2216851e-04, -1.2129559e-02, -1.7884647e-02, -1.6505027e-02, -9.2663628e-03, 6.1956916e-04, 9.3228142e-03, 1.3803589e-02, 1.2816497e-02, 7.1964231e-03, -6.1712450e-04, -7.5872249e-03, -1.1222074e-02, -1.0434886e-02, -5.8353329e-03, 6.1323731e-04, 6.4032107e-03, 9.4362399e-03, 8.7652781e-03, 4.8696509e-03, -6.0913723e-04, -5.5415028e-03, -8.1241037e-03, -7.5272685e-03, -4.1478733e-03, 6.0456273e-04, 4.8841727e-03, 7.1168041e-03, 6.5708723e-03, 3.5876047e-03, -5.9878422e-04, -4.3636099e-03, -6.3161594e-03, -5.8073443e-03, -3.1385854e-03, 5.9322295e-04, 3.9408962e-03, 5.6638884e-03, 5.1832474e-03, 2.7710917e-03, -5.8654764e-04, -3.5888943e-03, -5.1202879e-03, -4.6623160e-03, -2.4643761e-03, 5.7917652e-04, 3.2899981e-03, 4.6589710e-03, 4.2196845e-03, 2.2036379e-03, -5.7198727e-04, -3.0332382e-03, -4.2626123e-03, -3.8393057e-03, -1.9801934e-03, 5.6366741e-04, 2.8086075e-03, 3.9168508e-03, 3.5077548e-03, 1.7859413e-03, -5.5495009e-04, -2.6102274e-03, -3.6122187e-03, -3.2159474e-03, -1.6155816e-03, 5.4574278e-04, 2.4332624e-03, 3.3414744e-03, 2.9569523e-03, 1.4648173e-03, -5.3633096e-04, -2.2741785e-03, -3.0988762e-03, -2.7254595e-03, -1.3312186e-03, 5.2617074e-04, 2.1295844e-03, 2.8795804e-03, 2.5169007e-03, 1.2112564e-03, -5.1576725e-04, -1.9978237e-03, -2.6806015e-03, -2.3281481e-03, -1.1034401e-03, 5.0494989e-04, 1.8767689e-03, 2.4989329e-03, 2.1565879e-03, 1.0064197e-03, -4.9329691e-04, -1.7644277e-03, -2.3315619e-03, -1.9990414e-03, -9.1767659e-04, 4.8215890e-04, 1.6610103e-03, 2.1780702e-03, 1.8552178e-03, 8.3766870e-04, -4.7015301e-04, -1.5644248e-03, -2.0358774e-03, -1.7224356e-03, -7.6456691e-04, 4.5767686e-04, 1.4738196e-03, 1.9035011e-03, 1.6000725e-03, 6.9761851e-04, -4.4520797e-04, -1.3888249e-03, -1.7804313e-03, -1.4863019e-03, -6.3604620e-04, 4.3292452e-04, 1.3094448e-03, 1.6660347e-03, 1.3813255e-03, 5.8018899e-04, -4.1973238e-04, -1.2339896e-03, -1.5585445e-03, -1.2833563e-03, -5.2861419e-04, 4.0657931e-04, 1.1627738e-03, 1.4577407e-03, 1.1919008e-03, 4.8087142e-04, -3.9369759e-04, -1.0958333e-03, -1.3636433e-03, -1.1071489e-03, -4.3735735e-04, 3.8048904e-04, 1.0321396e-03, 1.2746002e-03, 1.0277171e-03, 3.9767884e-04, -3.6695356e-04, -9.7120261e-04, -1.1913927e-03, -9.5346113e-04, -3.6055288e-04, 3.5317635e-04, 9.1348060e-04, 1.1121789e-03, 8.8351998e-04, 3.2602141e-04, -3.4005375e-04, -8.5899187e-04, -1.0381281e-03, -8.1868075e-04, -2.9488697e-04, 3.2638308e-04, 8.0673753e-04, 9.6801311e-04, 7.5775460e-04, 2.6607823e-04, -3.1289506e-04, -7.5709696e-04, -9.0200204e-04, -7.0094586e-04, -2.4001933e-04, 2.9887140e-04, 7.0907275e-04, 8.3884857e-04, 6.4670922e-04, 2.1494953e-04, -2.8584319e-04, -6.6333509e-04, -7.7943142e-04, -5.9742807e-04, -1.9232365e-04, 2.7224625e-04, 6.2105410e-04, 7.2380178e-04, 5.4960007e-04, 1.7212264e-04, -2.5919424e-04, -5.7970720e-04, -6.7097725e-04, -5.0557488e-04, -1.5355321e-04, 2.4592872e-04, 5.4042022e-04, 6.2132740e-04, 4.6472140e-04, 1.3691519e-04, -2.3245754e-04, -5.0244911e-04, -5.7360161e-04, -4.2533259e-04, -1.2031941e-04, 2.2079505e-04, 4.6800709e-04, 5.3039887e-04, 3.9054918e-04, 1.0754103e-04, -2.0642968e-04, -4.3173074e-04, -4.8525607e-04, -3.5283954e-04, -9.0375477e-05, 1.9733971e-04, 4.0373153e-04, 4.5627279e-04, 3.2771792e-04, 8.7338481e-05, -1.7744620e-04, -3.6241008e-04, -4.0122347e-04, -2.8297817e-04, -5.7733256e-05, 1.8706400e-04, 3.5874892e-04, 3.9649477e-04, 2.9157800e-04, 9.0356545e-05, -1.2641042e-04, -2.7402485e-04, -2.9710403e-04, -1.8843015e-04, 9.1040279e-06, 2.2151826e-04, 3.7207297e-04, 4.1135460e-04, 3.3431424e-04, 1.8145942e-04, 2.1240508e-05, -7.6010980e-05, -6.5216342e-05, 5.8315253e-05, 2.5833353e-04, 4.7391797e-04, 6.4332791e-04, 7.2843649e-04, 7.2820222e-04, 6.7880864e-04, 6.3875042e-04, -2.5983886e-03 2 | -------------------------------------------------------------------------------- /AnaMBE/complex.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | //============================================================================ 15 | // complex.cpp 16 | // 17 | // classes: CComplex 18 | // 19 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 20 | // 21 | // History: 21.03.1996: Creation 22 | // 23 | //---------------------------------------------------------------------------- 24 | // Documentation: 25 | // 26 | //============================================================================ 27 | 28 | #ifndef _INC_COMPLEX 29 | #include "complex.h" 30 | #endif 31 | 32 | #ifndef _INC_MATH 33 | #include 34 | #endif 35 | 36 | // ============================================================================ 37 | // Class CComplex 38 | // ============================================================================ 39 | 40 | CComplex::CComplex() // Default Constructor 41 | { 42 | Real=0; 43 | Imaginary=0; 44 | //Module=0; 45 | //Phase=0; 46 | }; 47 | 48 | // ---------------------------------------------------------------------------- 49 | 50 | CComplex::CComplex(double a,double b,int type) 51 | // if type=0 then Real=a 52 | { 53 | if (type==0) // and Imaginary=b 54 | { 55 | Real=a; // if type=1 then Module=a 56 | Imaginary=b; // and Phase=b 57 | RIToMP(); 58 | } 59 | else 60 | { 61 | if (type==1) 62 | { 63 | //Module=a; 64 | //Phase=b; 65 | MPToRI(); 66 | } 67 | else 68 | { 69 | Real=0; 70 | Imaginary=0; 71 | //Module=0; 72 | //Phase=0; 73 | } 74 | } 75 | }; 76 | 77 | // ---------------------------------------------------------------------------- 78 | 79 | CComplex::~CComplex() 80 | { 81 | }; 82 | 83 | // ---------- 84 | // Operators 85 | // ---------- 86 | 87 | /*CComplex operator+(CComplex c1,CComplex c2) 88 | { 89 | CComplex a(c1.Real+c2.Real,c1.Imaginary+c2.Imaginary,0); 90 | return a; 91 | }; 92 | 93 | // ---------------------------------------------------------------------------- 94 | 95 | CComplex operator+(CComplex c1,double c2) 96 | { 97 | CComplex a(c1.Real+c2,c1.Imaginary,0); 98 | return a; 99 | }; 100 | 101 | // ---------------------------------------------------------------------------- 102 | 103 | CComplex operator+(double c1,CComplex c2) 104 | { 105 | CComplex a(c1+c2.Real,c2.Imaginary,0); 106 | return a; 107 | }; 108 | 109 | // ---------------------------------------------------------------------------- 110 | 111 | CComplex operator-(CComplex c1,CComplex c2) 112 | { 113 | CComplex a(c1.Real-c2.Real,c1.Imaginary-c2.Imaginary,0); 114 | return a; 115 | }; 116 | 117 | // ---------------------------------------------------------------------------- 118 | 119 | CComplex operator-(CComplex c1,double c2) 120 | { 121 | CComplex a(c1.Real-c2,c1.Imaginary,0); 122 | return a; 123 | }; 124 | 125 | // ---------------------------------------------------------------------------- 126 | 127 | CComplex operator-(double c1,CComplex c2) 128 | { 129 | CComplex a(c1+c2.Real,c2.Imaginary,0); 130 | return a; 131 | }; 132 | 133 | // ---------------------------------------------------------------------------- 134 | 135 | CComplex operator*(CComplex c1,CComplex c2) 136 | { 137 | CComplex a(c1.Module*c2.Module,c1.Phase+c2.Phase,1); 138 | return a; 139 | }; 140 | 141 | // ---------------------------------------------------------------------------- 142 | 143 | CComplex operator*(CComplex c1,double c2) 144 | { 145 | CComplex a(c1.Module*c2,c1.Phase,1); 146 | return a; 147 | }; 148 | 149 | // ---------------------------------------------------------------------------- 150 | 151 | CComplex operator*(double c1,CComplex c2) 152 | { 153 | CComplex a(c1*c2.Module,c2.Phase,1); 154 | return a; 155 | }; 156 | 157 | // ---------------------------------------------------------------------------- 158 | 159 | CComplex operator/(CComplex c1,CComplex c2) 160 | { 161 | if (c2.Module==0.0) 162 | { 163 | CComplex a(1E308,c1.Phase-c2.Phase,1); 164 | return a; 165 | } 166 | else 167 | { 168 | CComplex a(c1.Module/c2.Module,c1.Phase-c2.Phase,1); 169 | return a; 170 | } 171 | }; 172 | 173 | // ---------------------------------------------------------------------------- 174 | 175 | CComplex operator/(CComplex c1,double c2) 176 | { 177 | if (c2==0.0) 178 | { 179 | CComplex a(1E308,c1.Phase,1); 180 | return a; 181 | } 182 | else 183 | { 184 | CComplex a(c1.Module/c2,c1.Phase,1); 185 | return a; 186 | } 187 | }; 188 | 189 | // ---------------------------------------------------------------------------- 190 | 191 | CComplex operator/(double c1,CComplex c2) 192 | { 193 | if (c2.Module==0.0) 194 | { 195 | CComplex a(1E308,-c2.Phase,1); 196 | return a; 197 | } 198 | else 199 | { 200 | CComplex a(c1/c2.Module,-c2.Phase,1); 201 | return a; 202 | } 203 | }; 204 | 205 | // ---------------------------------------------------------------------------- 206 | 207 | CComplex operator^(CComplex c1,double c2) 208 | { 209 | CComplex a; 210 | a.Module=pow(c1.Module,c2); 211 | a.Phase=c1.Phase*c2; 212 | a.MPToRI(); 213 | return a; 214 | }; 215 | */ 216 | // ---------------------------------------------------------------------------- 217 | 218 | CComplex CComplex::operator=(CComplex c1) 219 | { 220 | Real=c1.Real; 221 | Imaginary=c1.Imaginary; 222 | // Module=c1.Module; 223 | // Phase=c1.Phase; 224 | return *this; 225 | }; 226 | 227 | // ---------------------------------------------------------------------------- 228 | 229 | CComplex CComplex::operator=(double c1) 230 | { 231 | Real=c1; 232 | Imaginary=0; 233 | // Module=c1; 234 | // Phase=0; 235 | return *this; 236 | }; 237 | 238 | // ---------------------------------------------------------------------------- 239 | 240 | int operator==(CComplex c1,CComplex c2) 241 | { 242 | if ((c1.Real==c2.Real)&&(c1.Imaginary==c2.Imaginary)) 243 | { 244 | return 1; 245 | } 246 | else 247 | { 248 | return 0; 249 | } 250 | }; 251 | 252 | // ---------- 253 | // Functions 254 | // ---------- 255 | 256 | CComplex Conjugate(CComplex c1) 257 | { 258 | CComplex a(c1.Real,-c1.Imaginary,0); 259 | return a; 260 | }; 261 | 262 | // ---------------------------------------------------------------------------- 263 | 264 | double CComplex::GetModule() 265 | { 266 | //RIToMP(); 267 | double Module; 268 | Module=sqrt(Real*Real+Imaginary*Imaginary); 269 | return Module; 270 | }; 271 | 272 | // ---------------------------------------------------------------------------- 273 | 274 | double CComplex::GetPhase() 275 | { 276 | //RIToMP(); 277 | double Phase; 278 | Phase=atan2(Imaginary,Real); 279 | return Phase; 280 | }; 281 | 282 | // ---------------------------------------------------------------------------- 283 | 284 | void CComplex::RIToMP() // Convert a complex (real,imaginary) number 285 | { // into a complex (Module,Phase) number 286 | // Module=sqrt(Real*Real+Imaginary*Imaginary); 287 | // Phase=atan2(Imaginary,Real); 288 | }; 289 | 290 | // ---------------------------------------------------------------------------- 291 | 292 | void CComplex::MPToRI() // Convert a complex (Module,Phase) number 293 | { 294 | // Real=Module*cos(Phase); // into a complex (Real,Imaginary) number 295 | // Imaginary=Module*sin(Phase); 296 | }; 297 | -------------------------------------------------------------------------------- /AnaMBE/soundfil.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // soundfil.h soundfil.cpp 16 | // 17 | // classes: SoundFile 18 | // SoundRAW 19 | // SoundAU 20 | // SoundWAV 21 | // 22 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 23 | // 24 | // History: 12.09.1995: Creation 25 | // 21.09.1995: Updating 26 | // 22.11.1995: Formalisation 27 | // 17.01.1996: Frame Loading 28 | // 10.03.1996: Object name 29 | // 11.03.1996: Use of FMObject and exception handling 30 | // 12.06.1996: SoundWav 31 | // 32 | // ---------------------------------------------------------------------------- 33 | // Documentation: 34 | // 35 | // SoundAU used for SUN format (.au) 36 | // SoundRAW used for RAW format (.raw,.snd) 37 | // 38 | // ============================================================================ 39 | 40 | #define _INC_SOUNDFIL 41 | 42 | #ifndef _INC_STRING 43 | #include 44 | #endif 45 | 46 | #ifndef _INC_CONSTANT 47 | #include "constant.h" 48 | #endif 49 | 50 | #ifndef _INC_FMOBJECT 51 | #include "fmobject.h" 52 | #endif 53 | 54 | #ifndef _INC_ERROREXC 55 | #include "errorexc.h" 56 | #endif 57 | 58 | // ============================================================================ 59 | 60 | class SoundFile : public FMObject 61 | { 62 | protected: 63 | // Internal variables 64 | long int Nb; // Sample number 65 | short int Freq; // Sampling frequency 66 | short int *Samples; // Sample buffer 67 | FILE *soundFile; // Pointer to the sound file 68 | char* FILENAME; // Pointer to the File name of the sound 69 | short int WIDTH,SHIFT; // Width and Shift of the frame 70 | short int *BUFFER; // Buffer used to store the overlapped 71 | // part of the frame 72 | short int FrameNummer; // Nummer of the current frame 73 | 74 | public: 75 | // Constructor 76 | SoundFile(){}; 77 | // Destructor 78 | ~SoundFile(){}; 79 | 80 | // Show the sampling frequency of the sound file 81 | virtual short int Frequency()=0; 82 | // Show the sample number 83 | virtual long int Length()=0; 84 | // Read in the sound file a number N of samples beginninng at 85 | // position Pos. Return the number of samples read 86 | virtual void LoadSamples(long int N, long int Pos, 87 | short int *Sampl)=0; 88 | virtual void LoadSamples(short int *Sampl)=0; 89 | // Activate the Frame Loading 90 | virtual void SetFrame(short int Width,short int Shift)=0; 91 | // Give the name of the sound file associated 92 | virtual char* GetFileName()=0; 93 | }; 94 | 95 | // ============================================================================ 96 | 97 | class SoundAu : public SoundFile 98 | { 99 | public: 100 | // Constructors 101 | SoundAu(char *FileName,const char *Name); // File's name and object name 102 | // Exception 103 | // Destructor 104 | ~SoundAu(); 105 | 106 | // Show the sampling frequency 107 | virtual short int Frequency() 108 | { 109 | return (Freq); 110 | }; 111 | // Show the sample number 112 | virtual long int Length() 113 | { 114 | return (Nb); 115 | }; 116 | // Read in the sound file a number N of samples beginninng at 117 | // position Pos. Return the number of samples read 118 | virtual void LoadSamples(long int N, long int Pos, 119 | short int *Sampl); 120 | // Activate the Frame Loading 121 | // The frame loading is used to read frame by frame a sound file with 122 | // a specified shift 123 | virtual void SetFrame(short int Width,short int Shift); 124 | // Frame Loading 125 | virtual void LoadSamples(short int *Sampl); 126 | // Give the name of the sound file associated 127 | virtual char* GetFileName() 128 | { 129 | return FILENAME; 130 | }; 131 | }; 132 | 133 | // ============================================================================ 134 | 135 | class SoundRAW : public SoundFile 136 | { 137 | public: 138 | // Constructors 139 | SoundRAW(char *FileName,const char *Name,int Freq); // Sound file name, 140 | // object name, 141 | // sample frequency 142 | // Exception 143 | // Destructor 144 | ~SoundRAW(); 145 | 146 | // Show the sampling frequency 147 | virtual short int Frequency() 148 | { 149 | return (Freq); 150 | }; 151 | // Show the sample number 152 | virtual long int Length() 153 | { 154 | return (Nb); 155 | }; 156 | // Read in the sound file a number N of samples beginninng at 157 | // position Pos. Return the number of samples read 158 | virtual void LoadSamples(long int N, long int Pos, 159 | short int *Sampl); 160 | // Activate the Frame Loading 161 | // The frame loading is used to read frame by frame a sound file with 162 | // a specified shift 163 | virtual void SetFrame(short int Width,short int Shift); 164 | // Frame Loading 165 | virtual void LoadSamples(short int *Sampl); 166 | // Give the name of the sound file associated 167 | virtual char* GetFileName() 168 | { 169 | return FILENAME; 170 | }; 171 | }; 172 | 173 | // =========================================================================== 174 | 175 | class SoundWAV : public SoundFile 176 | { 177 | public: 178 | // Constructors 179 | SoundWAV(char *FileName,const char *Name); // Sound file name, 180 | // object name, 181 | 182 | // Destructor 183 | ~SoundWAV(); 184 | 185 | // Show the sampling frequency 186 | virtual short int Frequency() 187 | { 188 | return (Freq); 189 | }; 190 | // Show the sample number 191 | virtual long int Length() 192 | { 193 | return (Nb); 194 | }; 195 | // Read in the sound file a number N of samples beginninng at 196 | // position Pos. Return the number of samples read 197 | virtual void LoadSamples(long int N, long int Pos, 198 | short int *Sampl); 199 | // Activate the Frame Loading 200 | // The frame loading is used to read frame by frame a sound file with 201 | // a specified shift 202 | virtual void SetFrame(short int Width,short int Shift); 203 | // Frame Loading 204 | virtual void LoadSamples(short int *Sampl); 205 | // Give the name of the sound file associated 206 | virtual char* GetFileName() 207 | { 208 | return FILENAME; 209 | }; 210 | }; 211 | 212 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MBROLA database creation tool 2 | 3 | This guide describes how to create voice database for the [MBROLA](https://github.com/numediart/MBROLA) 4 | speech synthesizer. 5 | 6 | __General steps__ 7 | 8 | - [PHASE 0: compile tools](#phase-0-compile-tools) 9 | - [PHASE 1: check the data](#phase-1-checking-the-data) 10 | - [PHASE 2: generate analysis parameter files](#phase-2-generate-analysis-parameter-files) 11 | - [PHASE 3: generate the makefile](#phase-3-generate-the-makefile) 12 | - [PHASE 4: execute makefile](#phase-4-execute-makefile) 13 | - [PHASE 5: test the result](#phase-5-test-the-result) 14 | - [PHASE 6: debugging?](#phase-6-debugging) 15 | - [ADDENDUM:](#addendum) 16 | - [ADDENDUM: 22Khz databases!!!!](#addendum-22khz-databases) 17 | - [ADDENDUM: running on windows....](#addendum-running-on-windows) 18 | 19 | ## PHASE 0: compile tools 20 | 21 | 1) Compiling MBE analysis 22 | 1. in AnaMBE directory, type `make` 23 | 1. you get some warnings about conversion from int to double, 24 | hopefully nothing lethal. 25 | 1. resulting binaries Obj/anaf0 Obj/anambe must be copied with root 26 | privilege under /usr/local/bin (or any other searchable path). 27 | 28 | 2) Compile resynthesis and database_build 29 | 1. in Resynthesis directory, type `make` 30 | 1. copy resynth* and database_build binaries in /usr/local/bin 31 | (or any other searchable path). 32 | 33 | 3) Then you need to know about the diphone provider instruction 34 | file... because here you're going to compile what the diphone provider 35 | gives you. 36 | 37 | ## PHASE 1: check the data 38 | 39 | you need audio file encoded as linear 16 bits, 16khz, little endian 40 | (PC format), and a text segmentation file containing something that 41 | looks like: 42 | 43 | ``` 44 | file name 45 | | diphone name 46 | | | first sample 47 | | | | last sample 48 | v | | | middle sample 49 | V V V v 50 | ##a.d16 _ a 2000 3910 2929 51 | ak.d16 a k 2000 4027 2939 52 | i#.d16 i _ 2000 4654 3228 53 | ki.d16 k i 2000 3882 3150 54 | ``` 55 | 56 | First source of problems: names in the .seg file and file names do not 57 | correspond well — uppercase and lowercase sometimes need to be 58 | updated by yourself or by the provider. 59 | 60 | Second source of problems: strange diphone names — for example, 61 | silence better be "_", rather than "#" (which is Flush 62 | character). Although it can be parametrized under mbrola it's looking 63 | for trouble. 64 | 65 | Third source of problems: people sometimes mess up segmentation 66 | boundaries order, or they write bytes instead of samples — whatever, it 67 | will generate an error later. 68 | 69 | Fourth source of problems: if diphone **\_-\_** (silence silence) is 70 | provided it *must* be the last diphone of the database in the seg 71 | file. But generally it is advised to remove that phoneme as it is looking 72 | for trouble (MBE analysis dies on numeric silence). 73 | 74 | Fifth source of problems mentioned above: never never never introduce 75 | any numeric silence (sequence of 0). First absolute 0 are not natural, 76 | second anambe crashes badly trying to compute infinite decibel 77 | spectral slices... 78 | 79 | ## PHASE 2: generate analysis parameter files 80 | 81 | If we have audio files in a directory, say WAV directory for example, and 82 | `br1w5.seg` segmentation file. Final database's name will be 83 | `br1w5`. One has to build different parameter files for speech analysis: 84 | 85 | ``` 86 | generate_mbrola br1w5 87 | ``` 88 | will automatically build "default" files: 89 | 90 | ``` 91 | -rw-r--r-- 1 user program 44 Jul 25 11:24 br1w5.f0 92 | -rw-r--r-- 1 user program 52 Jul 25 11:24 br1w5.mbe 93 | -rw-r--r-- 1 user program 91 Jul 25 11:24 br1w5.syn 94 | ``` 95 | 96 | They resp. contain data for three different analysis: 97 | 98 | 1) f0 analysis (pitch, with anaf0 binary) br1w5.f0 99 | 2) harmonic/noise analysis (MBE model with anambe binary) br1w5.mbe 100 | 3) mbrola format frame resynthesis (resynth binary) br1w5.syn 101 | 102 | In a first approach keep default values, only mbe and syn need be 103 | changed in the following. Let's do it now for mbe — listen to some of 104 | your audio files to get an idea of speaker's average pitch, then 105 | measure the length of 1 pitch period in samples (for example using 106 | wavesurfer or any audio editor you like). E.g. on the brazilian voice 107 | we find 144 samples (i.e. a 90Hz pitch), so edit .mbe file 108 | 109 | ``` 110 | Nfft=1024 111 | Freq=16000 112 | FrameLength=360 113 | FrameShift=120 114 | ``` 115 | 116 | Replace FrameShift field with 144, and FrameLength field with 144*3 117 | (it's empirical but it works!) that is 432. 118 | 119 | ## PHASE 3: generate the makefile 120 | 121 | Three analysis (f0, mbe, resynthesis) are done on each audio file and 122 | generate an s16 result. To avoid manual handling on updates of 123 | segmentation use `make` or `pmake` (historical reason: in 1996 Mbrola 124 | analysis was quite slow on 1 machine, hence `pmake` was used to 125 | distribute analysis/resynthesis of a database on several Unix machines 126 | while we were having a beer on the Grand Place of Mons). 127 | 128 | ``` 129 | generate_make.pl br1w5 WAV/ RES/ RES/ 130 | ``` 131 | will generate `br1w5.mak` that's gonna use audio files in WAV/ (don't 132 | forget the slash), and put result and intermediate files in RES/. 133 | 134 | Example of a block in the mak file: 135 | 136 | ``` 137 | RES/0.f0 : WAV/1.d16 test.f0 138 | anaf0 'WAV/1.d16' RES/0.f0 2000 3810 test.f0 139 | RES/0.mbe: RES/0.f0 test.mbe 140 | anambe WAV/1.d16 RES/0.f0 RES/0.mbe 2000 3810 test.mbe 141 | RES/0.s16 : RES/0.mbe test.syn 142 | resynth WAV/1.d16 RES/0.mbe RES/0 test.syn 143 | ``` 144 | 145 | This block describes the construction of 0.f0 , 0.mbe and 0.s16 146 | files from WAV/1.d16 and parameters in br1w5.f0 br1w5.mbe 147 | br1w5.syn. 148 | 149 | ## PHASE 4: execute makefile 150 | 151 | make -f br1w5.mak 152 | 153 | Some errors might occur — one of the major reason for errors is 154 | insufficient audio context for a diphone. I usually ask for 800 155 | samples for safety, but some smart guys sometimes provide shorter 156 | context, as a result, even though segmentation boundaries are inside 157 | of the wav file, due to the size of analysis windows, it's reading 158 | outside. 159 | Solution: either shorten the diphone a little bit, either send a note 160 | to the provider for a greater audio context (and come on, audio 161 | context doesn't mean adding *silence* on both sides, wicked idea...) 162 | 163 | ## PHASE 5: test the result 164 | 165 | Usually make command ends with a line like: 166 | 167 | 168 | database_build br1w5 RES/ 2.069 16000 144 1 169 | 170 | 171 | If no _-_ diphone was provided, database_build automatically includes 172 | one. No worry. 173 | If you have a br1w5.info text file in the directory, it is included at 174 | the end of the database as provider's data (can be read with mbrola -i). 175 | 176 | Yes, yes you can now test an audio output! 177 | 178 | mbrola br1w5 TEST/testw1.pho test.wav 179 | 180 | Voila! It should sound ok. Now, one can do fine tuning.... one can set 181 | voiced/unvoiced ratios in resynthesis .syn parameters: 182 | 183 | ``` 184 | Freq=16000 185 | LastPhaseReset=10 186 | VUVLimTra=0.55 187 | VUVLimVoiced=1.2 188 | ElimTrans=5e8 189 | ElimVoiced=5e8 190 | ``` 191 | 192 | Mainly ElimTrans and ElimVoiced have the same value, and indicate 193 | energy level below which we consider we have silence (if the database 194 | dynamic is weak one has to lower this value). 195 | 196 | VUVLimVoiced is the main parameter to tune voiced/unvoiced effect (if 197 | the database is over-voiced, for example you may spot that /S/ is 198 | voiced). 199 | 200 | VUVLimTra tune smoothing level — the higher, the more mbrola's going 201 | to smooth (even when it's harmfull, e.g. between two parts of a 202 | /b/). This value corresponds to "transition threshold" — when we 203 | declare that an MBE frame is a transition it means "no smoothing 204 | beyond" (e.g. plosives, sonorant where formants move quickly). 205 | 206 | When you modify .syn parameters, simply launch make again — you'll 207 | notice everything goes faster because .f0 and .mbe files are not 208 | recomputed (mbe analysis is by far the most greedy part of the 209 | process). 210 | 211 | If you modify the segmentation boundaries of a diphone, simply execute 212 | `touch WAV/my_file.wav` on corresponding audio file to force make 213 | rebuild of its parameters. 214 | 215 | There's a special "resynth_debug" version of "resynth" binary that 216 | generates .m and .mm matlab files. It displays under matlab f0 and mbe 217 | coefficients which comes handy to set sound thresholds. 218 | 219 | Another special version is "resynth_female", to process high female 220 | pitches — edit .mbe param file to double analysis frame length (goes 221 | 1 harmonic higher), edit .mak file to use resynth_female instead of 222 | resynth_male and launch make. What happens next? During resynthesis, 223 | pitch is doubled (analysis frame was multiplied by 2, then pitch is 224 | divided by 2). At the same time, when doubling the pitch, I associate 225 | phases with their correct harmonic, and duplicate them for odd 226 | harmonics (one has to invent phases for those harmonics). 227 | 228 | ## PHASE 6: debugging? 229 | 230 | listen to your mbrola output to track any over/under smoothing on 231 | unvoiced/voiced plosives or fricatives. 232 | 233 | You're all set. 234 | 235 | ## ADDENDUM: 236 | 237 | Downsampling a database... Edit .mak to use resynth_resample instead 238 | of resynth (filter can be modified in Resynthesis/Src/COEF_FILTER 239 | depending on target freq). Actually every .s16 file is downsampled 240 | into a .s10 file. 241 | 242 | You may also to modify the make file: 243 | 244 | database_build br1w5 RES/ 2.060 16000 144 1 245 | becomes: 246 | 247 | database_build br1w5 RES/ 2.060 8000 77 1 16000 248 | 249 | AVAILABLE RESAMPLING: 16khz to 8khz (resynth_resample16_8, works for 250 | every 1/2 ratios, e.g. from 22050 to 11025), and 22050Hz to 8000Hz 251 | with resynth_resample22_8 252 | 253 | ### 22Khz databases!!!! 254 | 255 | It's the hack of the hack... *never* try to replace 16000 parameters 256 | in your .mbe or .f0 or .syn files, it could make sense, but it's a 257 | trap. All those programs were handcrafted a very long time ago by 258 | Thierry Dutoit and *everything* has been designed for 16000Hz (some 259 | band pass filters inside, some frequency dependent obscure constants). 260 | 261 | The hack of the hack is: don't touch anything, pretend you work at 262 | 16000Hz on 22050Hz files (you get quite long periods generally but who 263 | cares). Simply indicate real sample rate at the very last minute on 264 | "database_build". 265 | 266 | ### running on windows.... 267 | 268 | Well, what does it take to run this on windows? Well either Cygwin 269 | tools :-) 270 | 271 | Or simply modify generate_make.pl so that instead of building a .mak 272 | with dependencies between files, it builds a .bat with explicit 273 | commands. Nowadays building a mbrola database is a cinch for any PC, 274 | which renders usage of .mak somehow obsolete (it used to be elegant). 275 | -------------------------------------------------------------------------------- /AnaMBE/datatype.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // datatype.cpp 16 | // 17 | // classes: PitchObject 18 | // PitchList 19 | // 20 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 21 | // 22 | // History: 12.03.1996: Creation from data.cpp (PitchObject) 23 | // PitchList 24 | // 25 | // ---------------------------------------------------------------------------- 26 | // Documentation: 27 | // 28 | // ============================================================================ 29 | 30 | #ifndef _INC_STRING 31 | #include 32 | #endif 33 | 34 | #ifndef _INC_CONSTANT 35 | #include "constant.h" 36 | #endif 37 | 38 | #ifndef _INC_ERROREXC 39 | #include "errorexc.h" 40 | #endif 41 | 42 | #ifndef _INC_DATATYPE 43 | #include "datatype.h" 44 | #endif 45 | 46 | // ============================================================================ 47 | // Class PitchObject 48 | // ============================================================================ 49 | 50 | // Constructor: Initialise the object and allocate memory 51 | PitchObject::PitchObject(int NbPitchParameters, 52 | short int Wwidth, 53 | short int Wshift, 54 | long int first, 55 | long int last) 56 | { 57 | try 58 | { 59 | FMObject::SetName("No Name"); 60 | Curve=new double[NbPitchParameters]; 61 | Voicing=new short int[NbPitchParameters]; 62 | Nb=NbPitchParameters; 63 | Width=Wwidth; 64 | Shift=Wshift; 65 | LastSample=last; 66 | FirstSample=first; 67 | } 68 | catch (...) 69 | { 70 | throw FMError("\nPitchObject Constructor\n",ObjectName); 71 | } 72 | }; 73 | 74 | // ============================================================================ 75 | 76 | // Constructor with naming capabilities 77 | PitchObject::PitchObject(const char *Name,int NbPitchParameters, 78 | short int Wwidth,short int Wshift,long int first, 79 | long int last) 80 | { 81 | try 82 | { 83 | FMObject::SetName(Name); 84 | Curve=new double[NbPitchParameters]; 85 | Voicing=new short int[NbPitchParameters]; 86 | Nb=NbPitchParameters; 87 | Width=Wwidth; 88 | Shift=Wshift; 89 | FirstSample=first; 90 | LastSample=last; 91 | } 92 | catch (...) 93 | { 94 | throw FMError("\nPitchObject Constructor\n",ObjectName); 95 | } 96 | }; 97 | 98 | // ============================================================================ 99 | 100 | // Remove 2 pitch points 101 | void PitchObject::Trim() 102 | { 103 | try 104 | { 105 | double *CurveBis; 106 | 107 | // Clone the old Curve 108 | CurveBis= new double[Nb-2]; 109 | memcpy(CurveBis, &Curve[1], (Nb-2)*sizeof(double)); 110 | 111 | // Remove 2 elements and delete old curve 112 | Nb-=2; 113 | delete [] Curve; 114 | Curve= CurveBis; 115 | } 116 | catch (...) 117 | { 118 | throw FMError("\nPitchObject Trim\n",ObjectName); 119 | } 120 | } 121 | 122 | // Destructor: Free the memory 123 | PitchObject::~PitchObject() 124 | { 125 | try 126 | { 127 | delete [] Curve; 128 | delete [] Voicing; 129 | } 130 | catch (...) 131 | { 132 | throw FMError("\nPitchObject destructor\n",ObjectName); 133 | } 134 | }; 135 | 136 | // ============================================================================ 137 | 138 | // Save the pitch parameters in a specified file 139 | int PitchObject::SaveParameters(const char *FileName) 140 | { 141 | FILE *foutput; 142 | int i; 143 | foutput=fopen(FileName,"w"); 144 | if (!foutput) 145 | { // Error while opening the file 146 | throw FMError("\nPitchObject SaveParameters => opening file\n", 147 | FileName,ObjectName); 148 | } 149 | fprintf(foutput,"%hd ",Width); // Save the width and the shift of the 150 | fprintf(foutput,"%hd ",Shift); // frame used to perform the analysis 151 | fprintf(foutput,"%ld ",FirstSample); // first sample of the analysis 152 | fprintf(foutput,"%ld\n ",LastSample); // last sample of the analysis 153 | for(i=0;i opening file\n", 173 | FileName,ObjectName); 174 | } 175 | // fscanf(foutput,"%d", &Nb); // Retrieve the number of parameters 176 | fscanf(foutput," %hd ",&Width); // Retrieve the width and the shift of 177 | fscanf(foutput," %hd ",&Shift); // the frame used for the analsyis 178 | fscanf(foutput," %ld ",&FirstSample); // first sample of the analysis 179 | fscanf(foutput," %ld \n",&LastSample); // last sample of the analysis 180 | 181 | Nb= (LastSample-FirstSample+1)/Shift; 182 | 183 | if (Curve!=NULL) 184 | { 185 | delete [] Curve; 186 | } 187 | if (Voicing!=NULL) 188 | { 189 | delete [] Voicing; 190 | } 191 | Curve=new double[Nb]; 192 | Voicing=new short int[Nb]; 193 | for(i=0;i opening file\n", 213 | FileName,ObjectName); 214 | } 215 | fwrite(&Nb,sizeof(int),1,foutput); // Save the number of parameters 216 | fwrite(&Width,sizeof(short int),1,foutput); // Save the characteristics of 217 | fwrite(&Shift,sizeof(short int),1,foutput); // the frame of the analysis 218 | fwrite(&FirstSample,sizeof(long int),1,foutput); // the first and the last 219 | fwrite(&LastSample,sizeof(long int),1,foutput); // sample of the analysis 220 | fwrite(&Curve,sizeof(double),Nb,foutput); // Save the pitch value 221 | fwrite(&Voicing,sizeof(short int),Nb,foutput); // Save the voicing 222 | // character 223 | fclose(foutput); 224 | return (0); 225 | }; 226 | 227 | // ============================================================================ 228 | 229 | // Load the parameters from a binary file 230 | int PitchObject::Load(const char *FileName) 231 | { 232 | FILE *foutput; 233 | foutput=fopen(FileName,"rb"); 234 | if (!foutput) 235 | { // Error while opening the file 236 | throw FMError("\nPitchObject Save => opening file\n", 237 | FileName,ObjectName); 238 | } 239 | fread(&Nb,sizeof(int),1,foutput); // Retrieve the number of parameters 240 | fread(&Width,sizeof(short int),1,foutput); // Retrieve the frame parameters 241 | fread(&Shift,sizeof(short int),1,foutput); 242 | fread(&FirstSample,sizeof(long int),1,foutput); // the first and the last 243 | fread(&LastSample,sizeof(long int),1,foutput); // sample of the analysis 244 | fread(&Curve,sizeof(double),Nb,foutput); // Retrieve the pitch curve 245 | fread(&Voicing,sizeof(short int),Nb,foutput); // Retrieve the voicing curve 246 | fclose(foutput); 247 | return (0); 248 | }; 249 | 250 | // ============================================================================ 251 | 252 | // Reset the parameters 253 | void PitchObject::ResetParameters(int NbPitchParameters, 254 | short int Wwidth, 255 | short int Wshift, 256 | long int first, 257 | long int last) 258 | { 259 | try 260 | { 261 | delete [] Curve; 262 | delete [] Voicing; 263 | Curve=new double[NbPitchParameters]; 264 | Voicing=new short int[NbPitchParameters]; 265 | Nb=NbPitchParameters; 266 | Width=Wwidth; 267 | Shift=Wshift; 268 | FirstSample=first; 269 | LastSample=last; 270 | } 271 | catch (...) 272 | { 273 | throw FMError("\nPitchObject ResetParameters\n",ObjectName); 274 | } 275 | }; 276 | 277 | // ============================================================================ 278 | 279 | // Send an index error exception 280 | void PitchObject::SendErrorMessage(int index,const char *func) 281 | { 282 | char *Message; 283 | int l; 284 | l=strlen("PitchObject "); 285 | l+=strlen(func); 286 | l+=strlen("\nIndex ######### not allowed\n"); 287 | l+=strlen(ObjectName); 288 | Message=new char[l]; 289 | sprintf(Message,"PitchObject %s\n Index %i not allowed\n%s\n", 290 | func,index,ObjectName); 291 | throw FMError(Message); 292 | }; 293 | 294 | // ============================================================================ 295 | 296 | // Get the pitch value at sample position pos 297 | double PitchObject::GetPitch_Step(long int pos) 298 | { 299 | short CurrentFrame; 300 | CurrentFrame=((pos-FirstSample)/Shift)+1; 301 | if (CurrentFrame<(Nb-1)) 302 | { 303 | return Curve[CurrentFrame]; 304 | } 305 | else 306 | { 307 | return Curve[Nb-1]; 308 | } 309 | }; 310 | 311 | // ============================================================================ 312 | // Class PitchList 313 | // ============================================================================ 314 | 315 | // Default constructor 316 | PitchList::PitchList() 317 | { 318 | FMObject::SetName("No Name"); // Default object name 319 | F0S=NULL; // Current marker 320 | First=NULL; // First marker 321 | Number=-1; // Number of markers 322 | }; 323 | 324 | // ============================================================================ 325 | 326 | // Constructor with Name 327 | PitchList::PitchList(const char *Name) 328 | { 329 | FMObject::SetName(Name); // Set the object name 330 | F0S=NULL; // Current marker 331 | First=0; // First marker 332 | Number=-1; // Number of markers 333 | }; 334 | 335 | // ============================================================================ 336 | 337 | // Destructor 338 | PitchList::~PitchList() 339 | { 340 | try 341 | { 342 | if (Number!=-1) 343 | { 344 | while (First->Prev!=First->Next) 345 | { 346 | F0S=First->Prev; 347 | First->Prev->Next=First->Next; 348 | First->Next->Prev=First->Prev; 349 | delete First; 350 | First=F0S->Prev; 351 | } 352 | if (First!=0) 353 | { 354 | delete First; 355 | } 356 | } 357 | } 358 | catch (...) 359 | { 360 | throw FMError("PitchList destructor Error\n",ObjectName); 361 | } 362 | }; 363 | 364 | // ============================================================================ 365 | 366 | // Add a new marker to the list 367 | void PitchList::AddNew(short int a,long int pos) 368 | { 369 | try 370 | { 371 | if (Number==-1) // If there is no elements into the list 372 | { 373 | F0S=new PitchMarker; 374 | F0S->Value=a; 375 | F0S->Position=pos; 376 | F0S->Next=NULL; 377 | F0S->Prev=NULL; 378 | First=F0S; 379 | Number=1; 380 | } 381 | else 382 | { F0S->Next=new PitchMarker; 383 | F0S->Next->Prev=F0S; 384 | F0S->Next->Next=First; 385 | First->Prev=F0S->Next; 386 | F0S=F0S->Next; 387 | F0S->Value=a; 388 | F0S->Position=pos; 389 | Number++; 390 | } 391 | } 392 | catch (...) 393 | { 394 | throw FMError("PitchList AddNew Error\n",ObjectName); 395 | }; 396 | }; 397 | 398 | // ============================================================================ 399 | 400 | // Go to the next marker 401 | void PitchList::Next() 402 | { 403 | F0S=F0S->Next; 404 | }; 405 | 406 | // ============================================================================ 407 | 408 | // Go to the previous marker 409 | void PitchList::Prev() 410 | { 411 | F0S=F0S->Prev; 412 | }; 413 | -------------------------------------------------------------------------------- /AnaMBE/datatype.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 1995-2019 Faculté polytechnique de Mons (TCTS lab) 2 | // This program is free software: you can redistribute it and/or modify 3 | // it under the terms of the GNU Affero General Public License as published by 4 | // the Free Software Foundation, either version 3 of the License, or 5 | // (at your option) any later version. 6 | // 7 | // This program is distributed in the hope that it will be useful, 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | // GNU Affero General Public License for more details. 11 | // 12 | // You should have received a copy of the GNU Affero General Public License 13 | // along with this program. If not, see . 14 | // ============================================================================ 15 | // datatype.h datatype.cpp 16 | // 17 | // structures: PitchMarker 18 | // Pointd 19 | // Pointi 20 | // Label 21 | // 22 | // classes: AnalyseParameters 23 | // PitchObject 24 | // PitchList 25 | // 26 | // templates: Vector 27 | // 28 | // predefined templates: Vectord (double) 29 | // Vectorsi (short int) 30 | // Vectoruc (unsigned char) 31 | // Vectorus (unsigned short) 32 | // Vectorf (float) 33 | // VectorComplex (CComplex) 34 | // VectorPointi 35 | // VectorPointd 36 | // VectorLabel 37 | // 38 | // Author: Fabrice Malfrere - TCTS Labs - FRIA Researcher 39 | // 40 | // History: 11.03.1996: Created from data.h 41 | // 12.03.1996: PitchObject reviewed 42 | // 21.03.1996: CComplex Vector template 43 | // 27.03.1996: PitchObject::GetPitch_Step function 44 | // 07.06.1996: Pointi,Pointd,Label and vectors associated 45 | // 46 | // ---------------------------------------------------------------------------- 47 | // Documentation: 48 | // 49 | // ============================================================================ 50 | 51 | #define _INC_DATATYPE 52 | 53 | #ifndef _INC_STDIO 54 | #include 55 | #endif 56 | 57 | #ifndef _INC_STRING 58 | #include 59 | #endif 60 | 61 | #ifndef _INC_COMPLEX 62 | #include "complex.h" 63 | #endif 64 | 65 | #ifndef _INC_CONSTANT 66 | #include "constant.h" 67 | #endif 68 | 69 | #ifndef _INC_ERROREXC 70 | #include "errorexc.h" 71 | #endif 72 | 73 | #ifndef _INC_FMOBJECT 74 | #include "fmobject.h" 75 | #endif 76 | 77 | // ============================================================================ 78 | // struct Pointd: define the coordinates of a point (double) 79 | // ============================================================================ 80 | typedef struct 81 | { 82 | double X,Y; 83 | } Pointd; 84 | 85 | // ============================================================================ 86 | // struct Pointi: define the coordinates of a point (int) 87 | // ============================================================================ 88 | typedef struct 89 | { 90 | int X,Y; 91 | } Pointi; 92 | 93 | // ============================================================================ 94 | // struct Label: define a label 95 | // ============================================================================ 96 | typedef struct 97 | { 98 | double X; 99 | char label[10]; 100 | } Label; 101 | 102 | // ============================================================================ 103 | 104 | template class Vector 105 | { 106 | public: 107 | T *Value; // Vector values 108 | 109 | public: 110 | long int Length; // Length of the vector 111 | char Name[50]; // Name of the vector 112 | 113 | public: 114 | Vector(long int Size) // Constructor with the size of the 115 | { 116 | Value=new T[Size]; // vector. Default name: 'No Name' 117 | Length=Size; // Exception 118 | strcpy(Name,"No Name"); 119 | if (Value==NULL) 120 | { 121 | throw FMError("\nVector constructor => Memory Error\n",Name); 122 | } 123 | }; 124 | Vector(long int Size,const char *name) // Constructor with 125 | { 126 | Value=new T[Size]; // size and name 127 | Length=Size; // Exception 128 | if (strlen(name)+1<50) 129 | { 130 | strcpy(Name,name); 131 | } 132 | else 133 | { 134 | strcpy(Name,"Name too long"); 135 | } 136 | if (Value==NULL) 137 | { 138 | throw FMError("\nVector constructor => Memory Error\n",Name); 139 | } 140 | }; 141 | // Copy constructor 142 | Vector(const Vector& v) 143 | { 144 | Value=new T[v.Length]; 145 | Length=v.Length; 146 | for(int i=0;i Memory Error\n",Name); 164 | } 165 | }; 166 | 167 | int GetLength() // Get the length of the vector 168 | { 169 | return Length; 170 | }; 171 | char *GetName() // Get the name of the vector 172 | { 173 | return Name; 174 | }; 175 | T & operator[](long int index) // Operator [] 176 | { // Exception 177 | if ((index>=Length)||(index<0)) 178 | { 179 | char Message[200]; 180 | sprintf(Message,"\nIndex %hi not allowed\n%s\n",index,Name); 181 | throw FMError(Message); 182 | } 183 | return Value[index]; 184 | }; 185 | }; 186 | 187 | // Predefined templates 188 | 189 | typedef Vector Vectord; // double 190 | typedef Vector Vectorsi; // short int 191 | typedef Vector Vectoruc; // unsigned char 192 | typedef Vector Vectorus; // unsigned short 193 | typedef Vector Vectorf; // float 194 | typedef Vector VectorComplex; // Complex number 195 | typedef Vector VectorPointd; // Point (double) 196 | typedef Vector VectorPointi; // Point (int) 197 | typedef Vector