Jump to content
  • 0

Learning how to make and reproduce the "AM / FM" example do AD2 / Script


Cleber Borges

Question

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 ---<

image.png.978c0b0d613e048130b49c36f291fbcf.png

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

  • 0

Thank you for the informations
I have no problem with R. That's why I use it.

I don't understand this diagram in SDK Ref Man.
I don't know what calculations this diagram represents.
By general formula I want to say the numerical way of making these modulations.

Is there an online version (links) of this manual?

I tried with those notes and got the coefficients shown in the graph.

const test = "CCCBBB ||||||";
play (test);

But the combination of the coefficients with the carrier is still a mystery.

thanks

Cleber Borges

image.png.b33d54221f91aaaaff78b87bb62d6898.png

##########################################################

> res$rgAM
 [1]  1.0000000  1.0000000  1.0000000  1.0000000  1.0000000  1.0000000  0.8000000  0.6200000  0.4580000
[10]  0.3122000  0.1809800  0.0628820 -0.0434062 -0.1390656 -0.2251590 -0.3026431 -0.3723788 -0.4351409
[19] -0.4916268 -0.5424642 -0.5882177 -0.6293960 -0.6664564 -0.6998107 -0.7298297 -0.7568467 -0.7811620
[28] -0.8030458 -0.8227412 -0.8404671 -0.8564204 -0.8707784
>
> res$rgFM
 [1] -0.7026982 -0.7026982 -0.7026982 -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690
[10] -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690
[19] -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690
[28] -0.4387690 -0.4387690 -0.4387690 -0.4387690 -0.4387690

##########################################################

 

Edited by Cleber Borges
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...