“混沌动力系统可以在脉冲响应方面提供无限多种音色。以下是生成单Duffing IR所需的MATLAB代码模型。” link to the article我收到错误“在此上下文中不允许使用函数定义。”
function [] = create_duffing() % the main function
global gamma omega epsilon GAM OMEG % declaration of global variables
gamma=0.1; omega=1; epsilon=0.25; OMEG=2; % system paramaters
length = 16000 ; % IR length settings in samples
[t x]=ode45(@A_duffing,0:2*pi/OMEG/50:length,[0 1]); % actual system calculation
X = x(:,1); % retrieval of one of the variables
XF = fft(X); % FFT
XF = XF(1:length(XF)/2); % takes the first half of FFT
X = real(XF).^2 + imag(XF).^2; % calculates the power spectrum
wavwrite(X,44100,24,'filename.wav'); % writes the file
end % closes the function
function xdot=duffing(t,x) % the system function
global gamma omega epsilon GAM OMEG % declaration of global variables
xdot(1)=-gamma*x(1)+omega^2*x(2)-epsilon*x(2)^3+GAM*cos(OMEG*t); % system equation, line 1
xdot(2)=x(1); % system equation, line 2
xdot=xdot'; % system equation, line 3
end % closes the function