How do i get the sound of a cosine signal

조회 수: 16 (최근 30일)
Deniz Bozdogan
Deniz Bozdogan 2021년 6월 12일
편집: Scott MacKenzie 2021년 6월 12일
I am trying to get the sound of a signal with different phases where its frequency is a frequency of a musical note. f=493.88. My code is below.
t=[0:0.2:20];
xc1=cos(2*pi*493.88*t);
xc12=cos(2*pi*493.88*t+pi/4);
xc13=cos(2*pi*493.88*t+pi/2);
xc14=cos(2*pi*493.88*t+pi);
soundsc(xc1, 1000)
When i try to run the sound i just get a tapping sound for 1 milisecond and then it stops. How do get the sound of the signal? Thank you in advance.

채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 6월 12일
You've only got 100 sample points and the sampling rate is too low. Try this...
t=[0:0.2:2000];
xc1=cos(2*pi*493.88*t);
soundsc(xc1, 8000)
  댓글 수: 4
Scott MacKenzie
Scott MacKenzie 2021년 6월 12일
편집: Scott MacKenzie 2021년 6월 12일
I'm not sure what you mean by "the sound would be the same for all signals right?". If the signals you are referring to are xc1, xc12, xc13, and xc14, then yes, the sound will be the same. The waveforms in these vectors are identical except you've added a bit of a phase shift (e.g., "+pi/2"). The phase shift does not affect the sound.
Deniz Bozdogan
Deniz Bozdogan 2021년 6월 12일
That's what i was asking for thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 6월 12일
Scott is right on.
For what it's worth, I'm attaching my demo for making a warbling, decaying chirp sound:

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by