How to generate a song on Matlab?

49 ビュー (過去 30 日間)
Richa Chaturvedi
Richa Chaturvedi 2016 年 12 月 19 日
回答済み: Micah Audrey 2024 年 1 月 26 日
I have to make a song on Matlab and then set up sine waves that correspond to the notes on the scale. The notes are CFDGCEAmCFGC. can someone help me with this?

採用された回答

David Barry
David Barry 2016 年 12 月 19 日
Here's an example to get you started. 5 seconds of middle C.
fs = 1e4; % sampling frequency
t = 1:1/fs:5; % time signal
freq = 261.6; % note frequency in Hz (middle C)
y = sin(2*pi*freq*t); % create sine wave
player = audioplayer(y, fs); % create audio player object
play(player); % play the sound
  1 件のコメント
Richa Chaturvedi
Richa Chaturvedi 2016 年 12 月 20 日
clear,clc; t = [0:.000125:.5]
G = sin(2*pi*392*t); A = sin(2*pi*400*t); F = sin(2*pi*370*t);
B = sin(2*pi*493.9*t); C = sin(2*pi*261.6*t);
line1 = [G,G,A,G,F,A,A,B,A,G,B,B,C,B,A]; song = [line1]; sound(song); I have written this code. But I'm unable to figure it out the time factor for each note. How can we find out the time for each note to play.

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

その他の回答 (2 件)

zeeshan ali
zeeshan ali 2020 年 3 月 1 日
fs = 1e4; % sampling frequency
t = 1:1/fs:5; % time signal
freq = 261.6; % note frequency in Hz (middle C)
y = sin(2*pi*freq*t); % create sine wave
player = audioplayer(y, fs); % create audio player object
play(player); % play the sound

Micah Audrey
Micah Audrey 2024 年 1 月 26 日
CAN SOMEONE REPLICATE THE SONG KISS THE RAIN USING MATLAB PLS

カテゴリ

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