Wednesday, June 27, 2007

 

frequency modulation converted from matlab to scilab

This is converted by hand from matlab to scilab. and I could probily do a awk or python script to search and replace a couple of things to make the conversion easier... Then you can take a second pass with scipad... looks like after that you are on your own looking up commands to see what they are...

The second part of this would be to read a text file to get frequency, duration, and give it a code so that the editor will know what it is (without knowing what it is but to treat it different from csound) I was also looking at rlab it appears there is an rlab+ that has music functions but only works on unix or linix or whatever.

sf = 22050; //% sample frequency (Hz)
d = 1.0; //% duration (s)
n = sf * d; //% number of samples

//% set carrier
cf = 1000; //% carrier frequency (Hz)
c = (1:n) / sf; //% carrier data preparation
c = 2 * %pi * cf * c;

//% set modulator
mf = 5; //% modulator frequency (Hz)
mi = 0.5; //% modulator index
m = (1:n) / sf; //% modulator data preparation
m = mi * cos(2 * %pi * mf * m); //% sinusoidal modulation

//% frequency modulation
s = sin(c + m); //% frequency modulation

//% sound presentation
sound(s, sf); //% sound presentation
//pause(d + 0.5); //% wating for sound end

Labels: , , , ,


Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?