extra/TWM.m
Go to the documentation of this file.
1 
2 function [f0, f0error] = TWM (ploc, pmag, N, fs, minf0, maxf0)
3 % Two-way mismatch algorithm (by Beauchamp&Maher)
4 % ploc, pmag: peak locations and magnitudes, N: size of complex spectrum
5 % fs: sampling rate of sound, minf0: minimum f0, maxf0: maximum f0
6 % f0: fundamental frequency detected, f0error: error measure
7 pfreq = (ploc-1)/N*fs; % frequency in Hertz of peaks
8 [zvalue,zindex] = min(pfreq);
9 if (zvalue==0) % avoid zero frequency peak
10  pfreq(zindex) = 1;
11  pmag(zindex) = -100;
12 end
14 [Mmag1,Mloc1] = max(ival2); % find peak with maximum magnitude
15 ival2(Mloc1) = -100; % clear max peak
16 [Mmag2,Mloc2]= max(ival2); % find second maximum magnitude peak
17 ival2(Mloc2) = -100; % clear second max peak
18 [Mmag3,Mloc3]= max(ival2); % find third maximum magnitude peak
19 nCand = 3; % number of possible f0 candidates for each max peak
20 f0c = zeros(1,3*nCand); % initialize array of candidates
21 f0c(1:nCand)=(pfreq(Mloc1)*ones(1,nCand))./((nCand+1-(1:nCand))); % candidates
22 f0c(nCand+1:nCand*2)=(pfreq(Mloc2)*ones(1,nCand))./((nCand+1-(1:nCand)));
23 f0c(nCand*2+1:nCand*3)=(pfreq(Mloc3)*ones(1,nCand))./((nCand+1-(1:nCand)));
24 f0c = f0c((f0c<maxf0)&(f0c>minf0)); % candidates within boundaries
25 if (isempty(f0c)) % if no candidates exit
26  f0 = 0; f0error=100;
27  return
28 end
30 ErrorPM = zeros(fliplr(size(harmonic))); % initialize PM errors
32 for i=1:MaxNPM % predicted to measured mismatch error
33  difmatrixPM = harmonic' * ones(size(pfreq))';
34  difmatrixPM = abs(difmatrixPM-ones(fliplr(size(harmonic)))*pfreq');
35  [FreqDistance,peakloc] = min(difmatrixPM,[],2);
36  Ponddif = FreqDistance .* (harmonic'.^(-0.5));
37  PeakMag = pmag(peakloc);
38  MagFactor = 10.^((PeakMag-Mmag1)./20);
39  ErrorPM = ErrorPM+(Ponddif+MagFactor.*(1.4*Ponddif-0.5));
41 end
42 ErrorMP = zeros(fliplr(size(harmonic))); % initialize MP errors
43 MaxNMP = min(10,length(pfreq));
44 for i=1:length(f0c) % measured to predicted mismatch error
45  nharm = round(pfreq(1:MaxNMP)/f0c(i));
46  nharm = (nharm>=1).*nharm + (nharm<1);
47  FreqDistance = abs(pfreq(1:MaxNMP) - nharm*f0c(i));
48  Ponddif = FreqDistance.* (pfreq(1:MaxNMP).^(-0.5));
49  PeakMag = pmag(1:MaxNMP);
50  MagFactor = 10.^((PeakMag-Mmag1)./20);
51  ErrorMP(i) = sum(MagFactor.*(Ponddif+MagFactor.*(1.4*Ponddif-0.5)));
52 end
53 Error = (ErrorPM/MaxNPM) + (0.3*ErrorMP/MaxNMP); % total errors
54 [f0error, f0index] = min(Error); % get the smallest error
55 f0 = f0c(f0index); % f0 with the smallest error
nharm
Definition: extra/TWM.m:46
if max(w)>1 w=0.9 *w/max(w)
end Error
Definition: extra/TWM.m:53
About Git write you should know how to use GIT properly Luckily Git comes with excellent documentation git help man git shows you the available git< command > help man git< command > shows information about the subcommand< command > The most comprehensive manual is the website Git Reference visit they are quite exhaustive You do not need a special username or password All you need is to provide a ssh public key to the Git server admin What follows now is a basic introduction to Git and some FFmpeg specific guidelines Read it at least if you are granted commit privileges to the FFmpeg project you are expected to be familiar with these rules I if not You can get git from etc no matter how small Every one of them has been saved from looking like a fool by this many times It s very easy for stray debug output or cosmetic modifications to slip in
Definition: git-howto.txt:5
N, 1 zeros()
function ploc
get the smallest error f0
Definition: extra/TWM.m:55
the buffer and buffer reference mechanism is intended to as much as possible
end end
Plot spectral magnitude
frequency in Hertz of peaks[zvalue, zindex]
Definition: extra/TWM.m:8
return end harmonic
Definition: extra/TWM.m:29
pmag(zindex)
pmag N
Definition: extra/TWM.m:2
for i
Definition: extra/TWM.m:32
Ponddif
Definition: extra/TWM.m:36
#define zero
Definition: regdef.h:64
static av_always_inline av_const double round(double x)
Definition: libm.h:162
int size
MagFactor
Definition: extra/TWM.m:38
clear max peak[Mmag2, Mloc2]
Definition: extra/TWM.m:16
pmag maxf0
Definition: extra/TWM.m:2
initialize MP errors MaxNMP
Definition: extra/TWM.m:43
end ErrorMP
Definition: extra/TWM.m:42
pmag f0error
Definition: extra/TWM.m:2
number of possible f0 candidates for each max peak f0c
Definition: extra/TWM.m:20
the buffer and buffer reference mechanism is intended to avoid
ErrorPM
Definition: extra/TWM.m:30
FreqDistance
Definition: extra/TWM.m:47
pmag minf0
Definition: extra/TWM.m:2
FFmpeg Automated Testing Environment ************************************Table of Contents *****************FFmpeg Automated Testing Environment Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass target exec to configure or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script tests fate sh from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at doc fate_config sh template Create a configuration that suits your based on the configuration template The slot configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern< arch >< os >< compiler >< compiler version > The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the fate_recv variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ssh command with one or more v options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory FATE makefile targets and variables *************************************Makefile can be set to
Definition: fate.txt:142
total errors[f0error, f0index]
Definition: extra/TWM.m:54
function fs
initialize PM errors MaxNPM
Definition: extra/TWM.m:31
find third maximum magnitude peak nCand
Definition: extra/TWM.m:19
difmatrixPM
Definition: extra/TWM.m:34
PeakMag
Definition: extra/TWM.m:37
const char int length
Definition: avisynth_c.h:668
float min
end ival2
Definition: extra/TWM.m:13