ADSR envelope: Digital synthesizer

조회 수: 67 (최근 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!

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by