stft_peak.m
Go to the documentation of this file.
1 function X = stft_peak(x, w, N, H, threshold)
2 % Analysis/synthesis of a sound using the short-time fourier transform
3 % x: input sound,
4 % w: analysis window (odd number of samples required)
5 % N: FFT size,
6 % H: hop size
7 % y: output sound
8 lengthx = length(x); % length of sound signal
9 w = w/sum(w); % normalize window
10 W = length(w); % window size (odd)
11 W2 = (W-1)/2; % half window
12 N2 = N/2+1; % half FFT size
13 
14 p_start = 1+W2; % first frame pointer
15 p_end = lengthx-W2; % last frame pointer
16 fft_buffer = zeros(N,1); % FFT buffer
17 for g=p_start:H:p_end % advance hop size each loop
18  % ANALYSIS
19  xw = w(1:W)'.*x(g-W2:g+W2); % multiply window by input frame
20  fft_buffer(1:W2+1) = xw(W2+1:W); % adjust buffer for zero-phase computation
21  fft_buffer(N-W2+1:N) = xw(1:W2);
22  X = fft(fft_buffer); % FFT of current buffer
23  mX = 20*log10(abs(X(1:N2))); % magnitude spectrum
24  pX = unwrap(angle(X(1:N2))); % phase spectrum (unwrapped)
25  ploc = 1+find((mX(2:N2-1)>threshold).*(mX(2:N2-1)>mX(3:N2)).*(mX(2:N2-1)>mX(1:N2-2)));
26  pmag = mX(ploc);
27  pphase = pX(ploc);
28  plength = length(ploc);
29  if(mod((g-p_start)/H+1,(floor(p_end/H/5)))==0) % select only 5 equally distributed frames of the sound
30  figure
31  subplot(2,1,1)
32  plot(mX) % plot magnitude and phase spectrums
33  hold on
34  plot(ploc(1:plength),pmag(1:plength),'xr'); % add peaks to the plot
35  xlim([1 N2])
36  ylim([-80 0])
37  title('Magnitude spectrum of frame')
38  ylabel('Magnitude spectrum (dB)')
39  xlabel('Frequency (rad)')
40  display(['Peak positions: ' num2str(ploc')]);
41  hold off
42  subplot(2,1,2)
43  plot(pX) % same with the phase
44  hold on
45  plot(ploc(1:plength),pphase(1:plength),'xr');
46  xlim([1 N2])
47 % ylim([-pi pi])
48 % pause()
49  hold off
50  end
51 end
magnitude spectrum pX
Definition: stft_peak.m:24
title('Sinusoid at 1/4 the Spampling Rate')
Frequency(cycles/sample) n
N, 1 zeros()
plot(ejex, abs(X3),'*')
function ploc
Interpolated time axis hold on
FFT size for synthesis(even) H
FFT of current buffer mX
Definition: stft_peak.m:23
#define W2
pphase
Definition: stft_peak.m:27
window size(odd) W2
end end
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
function H
Definition: stft_peak.m:1
#define N
Definition: vf_pp7.c:200
figure
Definition: genspecsines2.m:3
Plot spectral magnitude
last frame pointer fft_buffer
Definition: stft_peak.m:16
pmag
Definition: stft_peak.m:26
frame
Definition: stft.m:14
Discrete Time axis x
#define zero
Definition: regdef.h:64
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an input
phase spectrum(unwrapped) ploc
overlapping window(triangular window to avoid too much overlapping) ovidx
plength
Definition: stft_peak.m:28
FFT buffer for g
Definition: stft_peak.m:17
ylabel('Amplitude')
use a maximum of peaks[f0, f0error]
if it could not because there are no more frames
if(mod((g-p_start)/H+1,(floor(p_end/H/5)))==0)%select only 5 equally distributed frames of the sound figure subplot(2
sound(x3, Fs)
subplot(3, 1, 1)
static int loop
Definition: ffplay.c:305
pause
Definition: plot_peaks.m:14
function X
Definition: stft_peak.m:1
half window N2
Definition: stft_peak.m:12
fftbuffer, N fft()
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
function w
Definition: stft_peak.m:1
1:W2 xw()
first frame pointer p_end
Definition: stft_peak.m:15
the buffer and buffer reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFilterBuffer structures They must not be accessed but through references stored in AVFilterBufferRef structures Several references can point to the same buffer
xlabel('Time(samples)')
half FFT size p_start
Definition: stft_peak.m:14
Filter the word “frame” indicates either a video frame or a group of audio samples
const char int length
Definition: avisynth_c.h:668
for(j=16;j >0;--j)
normalize window W
Definition: stft_peak.m:10