How to use frest.Sinestream to create a sine wave sound

조회 수: 3 (최근 30일)
Eason
Eason 2013년 2월 18일
I use the code below to create a 6 secs long sine wave which contain 0~2 sec was 200 Hz, 2~4 sec was 100 Hz, 4~6 sec was 300 Hz.
result=frest.Sinestream('Amplitude',0.5,...
'Frequency',[200 100 300],...
'SamplesPerPeriod',ceil([44100/200 44100/100 44100/300]),...
'FreqUnits','Hz',...
'RampPeriods',[0.02/(1/200),0.02/(1/100),0.02/(1/300)],...
'NumPeriods',[200*2-4 100*2-2 300*2-6]);
The sine wave's sampling rate must be 44100 Hz, so each period's sample was according to it's frequency.(ex:0~2 sec was 200 Hz, so per period was 44100/200 samples.), and Ramp was 20ms long, so 200 Hz was 4 ramp period (0.02/(1/200)). and NumPeriods was 2 secs long each frequency. ex: 200 Hz*2-4(ramp period).
After that, the result was a Undefined function or method 'lt' for input arguments of type 'frest.Sinestream'. So it couldn't use wavwrite function to write into a wav file.
I found
x=generateTimeseries(result);
and x was a double timeseries, which x.Data can wavwrite into a wav file. Then I got a sine wave sound which has dynamic frequency. But, it was 6.0045 sec long, I found that the 0~2sec was incorrect. I though is because it's 'SamplesPerPeriod' was 44100/200=220.5 was not int. and I ceil it. How can I fix this problem?
Thanks

채택된 답변

Arkadiy Turevskiy
Arkadiy Turevskiy 2013년 2월 19일
frest is part of Simulink Control Design. You need to have a license of this product to use frest. I ran your code and was able to get the signal you are trying to generate.
You can check the products on your license by typing
>>ver
HTH.
Arkadiy

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by