ADSR envelope: Digital synthesizer

49 ビュー (過去 30 日間)
Erdal Yegenaga
Erdal Yegenaga 2020 年 11 月 1 日
コメント済み: Erdal Yegenaga 2020 年 11 月 5 日
clear ;
close all;
fs=8500;
t=0:0.000117:3;
note_do= sin(2*pi*261.6*t);
note_re= sin(2*pi*293.7*t);
note_mi= sin(2*pi*329.6*t);
note_fa= sin(2*pi*349.2*t);
note_sol= sin(2*pi*392*t);
note_la= sin(2*pi*440*t);
note_si= sin(2*pi*493.9*t);
note_do1= sin(2*pi*523.5*t);
y=note_do;
A = linspace(0, 0.9, (length(y)*0.10)); %rise 35% of signal
D = linspace(0.9, 0.7,(length(y)*0.05)); %drop of 5% of signal
S = linspace(0.7, 0.7,(length(y)*0.40)); %delay of 40% of signal
R = linspace(0.7, 0,(length(y)*0.20)); %drop of 25% of signal
ADSR = [A D S R] ;
x = zeros(size(y));
x(1:length(ADSR)) = ADSR;
tone=y.* x;
sound(tone,fs);
I wrote this codes it successfully run but i want to assign notes to keys to each musical notes for my digital synthesizer project. Like in computer keyboard if user press A key its plays note_do etc. Can you help me this part i am new to matlab?

回答 (1 件)

Maadhav Akula
Maadhav Akula 2020 年 11 月 4 日
Hi,
I believe you want to play note_do when user clicks on key A on their computer keyboard, in that case you can utilize the callback functions to capture the key pressed data from the user and write conditional statements using if-else statements or switch cases in your callback as per your requirements.
Have a look at this answer:
Hope this helps!
  1 件のコメント
Erdal Yegenaga
Erdal Yegenaga 2020 年 11 月 5 日
Thank you for answer!

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

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by