如何增加/减少(频率/音调)信号

时间:2011-04-04 20:42:37

标签: matlab octave fft

如何使用fft / ifft增加/减少(频率/音高)和相位我认为我有基本代码,但我不知道下一步该做什么

我被告知repmat和resample可能会有所帮助,是的,我想要线性移动所有组件。我想随着时间的推移调整相位,以便产生驻波。一个信号的相位在一个方向上变化,另一个信号的相位在相反的方向上变化

PS:它是在Octave / matlab代码中完成的

示例我有一个信号,每秒重复1次,我想让它每秒重复3次。

%Voiceprint raise lower freq phase conjugate signal
tic
clear all, clc,clf,tic
%% Sound /beep calculation complete
filerawbeepStr='calculations_complete.wav';
filerawbeeppathStr='/home/rat/Documents/octave/raw/';
filevoiceprepathStr='/home/rat/Documents/octave/eq_research/main/transform/voice/';
filewavpathStr='/home/rat/Documents/octave/eq_research/main/transform/wav/';
[ybeep, Fsbeep, nbitsbeep] = wavread(strcat(filerawbeeppathStr,filerawbeepStr));
%addpath(”/home/rat/Documents/octave/eq_research/main/transform/”); %add path to location of functions

%1a voice print import
[vp_sig_orig, fs_rate, nbitsraw] = wavread(strcat(filevoiceprepathStr,'voice8000fs.wav')); 

%vp_sig_orig=vp_sig_orig’;
vp_sig_len=length(vp_sig_orig);

%2a create frequency domain
ya_fft = fft(vp_sig_orig);
vp_sig_phase_orig = unwrap(angle(ya_fft));

%get Magnitude
ya_fft_mag = abs(ya_fft);

%3a frequency back to time domain
ya_ifft=real(ifft(ya_fft));

%adjust frequency/phase here? How?
vp_sig_new=real(ifft(ya_fft_mag.*exp(i*vp_sig_phase_orig)));

subplot(3,1,1), plot(vp_sig_orig),title('1 original time domain')
subplot(3,1,2), plot(ya_ifft),title('2 rebuild time domain')
subplot(3,1,3), plot(vp_sig_new),title('3 adjusted time')

1 个答案:

答案 0 :(得分:0)

这是一种方法,但如果信号很大,你可能需要增加信号的点数

clear,clc
fs = 44100;                   % Sampling frequency
t=linspace(0,1,fs);
freq=1;
ya = sin(2*pi*freq*t)'; %+ 1*sin(2*pi*250*t); 


num_per_sec=5
yb=repmat(ya,num_per_sec,1);%replicate matrix 
xxo=linspace(0,1,length(yb))'; %go from 0 to 1 sec can change speed by incr/decr 1
xxi=linspace(0,1,length(ya))'; %go from 0 to 1 sec and get total samplerate from total y value
yi_t=interp1(xxo,yb,xxi,'linear');

plot(yi_t)