I would like to reproduce the script: "Wavegen Piano Script" in R language
for learning purposes. The WaveForms script is on the Script => Example tab.
( It's a demonstration of how to use FM / AM ).
I studied the script and I can see the coefficients given in the arrays: rgFM and rgAM
in the "Custom" tab and I can export them to Clipboard.
In R, I created the carrier signal like this:
rate <- 44100 # the sampling rate
dur <- 5.333 # duration time in seconds
# Generate the carrier
signal_carrier <- sin( seq( 0, 1760*dur*2*pi, length=rate*dur ) )
This way I can produce the sinusoidal signal with 235186 points.
In R, I matched the size of rgAM and rgFM with the size of signal_carrier:
coef_am <- approx( rgAM, n=length(signal_carrier) )$y
coef_fm <- approx( rgFM, n=length(signal_carrier) )$y
But my question is how to produce the resulting signal, that is, how to apply these coefficients.
In my test, I simply multiplied both and made a graph.
The appearance of my graph is quite different from that generated by WaveForms
(when I temporarily disabled the FM option).
>--- PNG (bitmap) Graphic ---<
As I have not yet understood the application of the rgAM coefficients, I have not applied the rgFM.
(I also have doubts about this).
So I ask questions:
1) Is there a general formula for doing both modulations in this example?
2) In WaveForms, do I have any option to export the output signal that is generated?
I apologize for being such basic questions, but the goal is to learn.
I thank you immediately for the information and attention.
Thank you very much!
Cleber Borges
ps.: In R, I can test the signal directly to the speakers and compare the audios.
Question
Cleber Borges
I would like to reproduce the script: "Wavegen Piano Script" in R language
for learning purposes. The WaveForms script is on the Script => Example tab.
( It's a demonstration of how to use FM / AM ).
I studied the script and I can see the coefficients given in the arrays: rgFM and rgAM
in the "Custom" tab and I can export them to Clipboard.
In R, I created the carrier signal like this:
rate <- 44100 # the sampling rate
dur <- 5.333 # duration time in seconds
# Generate the carrier
signal_carrier <- sin( seq( 0, 1760*dur*2*pi, length=rate*dur ) )
This way I can produce the sinusoidal signal with 235186 points.
In R, I matched the size of rgAM and rgFM with the size of signal_carrier:
coef_am <- approx( rgAM, n=length(signal_carrier) )$y
coef_fm <- approx( rgFM, n=length(signal_carrier) )$y
But my question is how to produce the resulting signal, that is, how to apply these coefficients.
In my test, I simply multiplied both and made a graph.
output <- signal_carrier * coef_am
plot( output, t='l' )
The appearance of my graph is quite different from that generated by WaveForms
(when I temporarily disabled the FM option).
>--- PNG (bitmap) Graphic ---<
As I have not yet understood the application of the rgAM coefficients, I have not applied the rgFM.
(I also have doubts about this).
So I ask questions:
1) Is there a general formula for doing both modulations in this example?
2) In WaveForms, do I have any option to export the output signal that is generated?
I apologize for being such basic questions, but the goal is to learn.
I thank you immediately for the information and attention.
Thank you very much!
Cleber Borges
ps.: In R, I can test the signal directly to the speakers and compare the audios.
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now