Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
Eason
Eason le 18 Fév 2013
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

Réponse acceptée

Arkadiy Turevskiy
Arkadiy Turevskiy le 19 Fév 2013
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

Plus de réponses (0)

Catégories

En savoir plus sur Audio Processing Algorithm Design dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by