Generate acoustic signal with difference rise time and fall time

3 ビュー (過去 30 日間)
BoWen Han
BoWen Han 2022 年 3 月 11 日
コメント済み: Scott MacKenzie 2022 年 3 月 15 日
Hi
Can someone help me for this one? I would like to plot a signal that can be similair with acoustic emission signal with difference rise time and fall time. There is not specific parameters but I just want to know if there's a way to generate?
Thanks
  2 件のコメント
Scott MacKenzie
Scott MacKenzie 2022 年 3 月 11 日
Just to clarify, by "rise time and fall time", do you mean adding an envelope to an existing signal so the amplitude rises from 0 to max over some period time at the beginning of the signal and falls from max to 0 over some period of time at the end of the signal?
BoWen Han
BoWen Han 2022 年 3 月 14 日
Hi sorry for late reply. Yes that is exactly what I mean and thanks for your advise for envelope !

サインインしてコメントする。

採用された回答

Scott MacKenzie
Scott MacKenzie 2022 年 3 月 14 日
編集済み: Scott MacKenzie 2022 年 3 月 14 日
Here's a simple approach that provides separate control for the rise or attack time (n1), the sustain time (n2), and the decay or fall time (n3):
f = 440; % Hz (cycles per second)
duration = 2; % seconds
sRate = 8192; % default
sInterval = 1/sRate;
% vector for values of t at each sample point
t = 0:sInterval:duration;
n = length(t);
% build the waveform vector
y = sin(2*pi * f * t);
% build envelope (tweak as desired)
n1 = 100; % attack
n2 = 200; % sustain
n3 = 500; % decay
n4 = n - (n1 + n2 + n3); % off
attack = linspace(0,1,n1);
sustain = ones(1,n2);
decay = linspace(1,0,n3);
off = zeros(1,n4);
envelope = [attack sustain decay off];
% apply envelope to signal
y = y .* envelope;
% play it
soundsc(y, sRate); % NOTE: sRate not needed if 8192 (default)
% plot the first few cycles of the waveform
plot(y(1:1000));
set(gca, 'ylim', [-1.5 1.5]);
title('Envelope Demonstration');
xlabel('Time'); ylabel('Amplitude');
  2 件のコメント
BoWen Han
BoWen Han 2022 年 3 月 15 日
Thank you ! That is really helpful. This inspire me a lot and thanks for your help.
Scott MacKenzie
Scott MacKenzie 2022 年 3 月 15 日
@BoWen Han you're welcome. Good luck.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by