How can I generate 9 sounds on matlab at 100Hz, 500ms long, 20ms rise and fall, that each have a different timbre?
1 次查看(过去 30 天)
显示 更早的评论
How can I generate 9 sounds on matlab at 100Hz, 500ms long, 20ms rise and fall, that each have a different timbre?
0 个评论
回答(1 个)
Star Strider
2015-5-19
One possible approach:
Fs = 44100; % Sampling Frequency
Ts = 1/Fs; % Sampling Interval (s)
T = 0:Ts:(Fs*Ts); % One Second
Frq = 100; % Fundamental Frequency
Len = 0.5; % Length Of Sound (s)
t = linspace(0, 2*pi*Frq, fix(Len*Fs)); % Length = 0.5s
rise = [0:Fs/5*0.1]/(Fs/5*0.1); % Rise-Fall
Env = [rise ones(1,size(t,2)-2*length(rise)) fliplr(rise)];
for k1 = 1:9
S(k1,:) = k1*sum(sin([1:k1:2*k1]'*t)).*Env;
pause(1)
sound(S(k1,:))
end
%
figure(1)
plot(T(1:length(Env)), Env)
grid
title('Envelope')
xlabel('Time (s)')
ylabel('Amplitude')
The ‘Env’ assignment is the envelope to produce the desired rise and fall. The plot call plots it, and is simply there to demonstrate its shape and is not necessary for the code.
The ‘S’ matrix stores all the sounds in one (9x22050) matrix.
I’m not exactly sure what you mean by ‘timbre’, however all these have a fundamental frequency of 100 Hz, with varying harmonics.
This will provide you with code to begin whatever project you are working on. You will have to experiment with it to get the result you want.
Have fun!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!