matlab - 颤音函数matlab中的wavread错误

标签 matlab audio signal-processing

我正在尝试编译我在互联网上找到的颤音音效代码。该代码有一个函数调用wavread ,在这个函数中matlab显示错误,我搜索了另一个代码来做到这一点,每个代码都使用这个函数打开de wav文件,有人发生了什么?下面的代码:

颤音脚本:

clear all;
close all;
clc;

infile = 'musica.wav';

% read in wav sample
[ x, Fs, N ] = wavread(infile);


%set Parameters for vibrato
% Change these to experiment with vibrato

Modfreq = 10; %10 Khz
Width = 0.0008; % 0.8 Milliseconds

% Do vibrato

yvib = vibrato(x, Fs, Modfreq, Width);

% write output wav files
wavwrite(yvib, Fs,  'out_vibrato.wav');

% plot the original and equalised waveforms

figure(1)
hold on
plot(x(1:500),'r');
plot(yvib(1:500),'b');
title('Vibrato First 500 Samples');

颤音功能:
% Vibrato 
function y=vibrato(x,SAMPLERATE,Modfreq,Width)
ya_alt=0;
Delay=Width; % basic delay of input sample in sec
DELAY=round(Delay*SAMPLERATE); % basic delay in # samples
WIDTH=round(Width*SAMPLERATE); % modulation width in # samples
if WIDTH>DELAY 
  error('delay greater than basic delay !!!');
  return;
end
MODFREQ=Modfreq/SAMPLERATE; % modulation frequency in # samples
LEN=length(x);        % # of samples in WAV-file
L=2+DELAY+WIDTH*2;    % length of the entire delay  
Delayline=zeros(L,1); % memory allocation for delay
y=zeros(size(x));     % memory allocation for output vector

for n=1:(LEN-1)
   M=MODFREQ;
   MOD=sin(M*2*pi*n);
   ZEIGER=1+DELAY+WIDTH*MOD;
   i=floor(ZEIGER);
   frac=ZEIGER-i;
   Delayline=[x(n);Delayline(1:L-1)]; 
   %---Linear Interpolation-----------------------------
   y(n,1)=Delayline(i+1)*frac+Delayline(i)*(1-frac); 

   %---Allpass Interpolation------------------------------
   %y(n,1)=(Delayline(i+1)+(1-frac)*Delayline(i)-(1-frac)*ya_alt);  
   %ya_alt=ya(n,1);
end 

出现的错误:
Undefined function or variable 'wavread' .

在行中:
[ x, Fs, N ] = wavread(infile);

最佳答案

函数wavreadnot supported从 Matlab R2015b 开始。

此功能已替换为 audioread ,并且原型(prototype)略有变化。

请更换故障线路

% read in wav sample
[x, Fs] = audioread(infile);

那么情况与wavwrite相同已替换为 audiowrite .

你应该把它改成
% write output wav files
audiowrite('out_vibrato.wav', yvib, Fs);

关于matlab - 颤音函数matlab中的wavread错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40533703/

相关文章:

android - 在后台服务中录制音频

Java声音API : Attempt to Do Live Microphone Input Monitoring is Slow

android - 在Android中将WAV文件转换为矢量

audio - 对齐FFT帧

matlab - 使用递归 MATLAB 函数还是优化?

matlab - 查找矩阵单元格中所有索引的最大值和索引的最佳方法

arrays - 如何在 matlab 中使用预分配数组中的零?

java - 在Android设备上使用Java/Kotlin检测音频文件(amr)中的静音

c++11 - 未定义对天鹰座的引用::WaveFile

matlab - 循环播放声音序列时的用户输入[matlab]