Page 1 of 2
sin1(x) > 1 ?
Posted: Mon Sep 22, 2014 12:49 pm
by jotb
Hello,
studid question:
I run a 500Hz sine wave into the dsp module. If i process sin1(x), where x is the input, the output is > 1. how is that possible?

Re: sin1(x) > 1 ?
Posted: Mon Sep 22, 2014 12:54 pm
by tester
Scaling something somewhere?
Re: sin1(x) > 1 ?
Posted: Mon Sep 22, 2014 1:10 pm
by jotb
for now, I just do:
y=sin1(x);
y is streamout
Re: sin1(x) > 1 ?
Posted: Mon Sep 22, 2014 2:40 pm
by tester
Extract that part and post it.
Re: sin1(x) > 1 ?
Posted: Mon Sep 22, 2014 5:01 pm
by jotb
hmm. strange. I just build that and now the problem is gone.
but now I have another one:
I am trying to rebuild a matlab code in the code module. But I think the sin1(x) is different than the sin(x) in matlab. How do I "convert" that? I how do I get Pi in code module?
I think that is my problem:
http://www.synthmaker.co.uk/forum/viewt ... in1#p72502And more embarrassing: how do I get the values of the variables in code module? e.g. streamin x ?
Re: sin1(x) > 1 ?
Posted: Mon Sep 22, 2014 6:34 pm
by KG_is_back
jotb wrote:hmm. strange. I just build that and now the problem is gone.
but now I have another one:
I am trying to rebuild a matlab code in the code module. But I think the sin1(x) is different than the sin(x) in matlab. How do I "convert" that? I how do I get Pi in code module?
I think that is my problem:
http://www.synthmaker.co.uk/forum/viewt ... in1#p72502And more embarrassing: how do I get the values of the variables in code module? e.g. streamin x ?
sin1(x) is normalized to 0-1 range where 0 is 0radians and 1 stands for 2pi radians.
sin(x)=sin1(x/2pi) or other way around sin(2pi*x)=sin1(x)
To get pi into code module simply declare it as variable:
simply google for more precise pi value, 9 decimal places are just enough. You can initialize variables to any numeric value. If you don't specify the value, code component simply assumes zero "float a;" is the same like "float a=0;"
For the inputs/outputs in code module use:
Warning! never change the values of the input variables within the code, or you might get unexpected results in the rest of the schematic. You may use output variables just like normal variables. after all code is finished, the last value will be send out.
Code: Select all
streamin x;
streamout y;
x=123; //NEVER DO THIS!!!!
y=1;
y=2;
y=3+y;
//the code will output y=5 on stream output connector
Re: sin1(x) > 1 ?
Posted: Mon Sep 22, 2014 8:21 pm
by jotb
Thank you!
sin1(x)/(2*pi) seems to work

I always looked for something like math.pi
I just don`t get the stream output to do what I want...
Re: sin1(x) > 1 ?
Posted: Tue Sep 23, 2014 12:12 pm
by jotb
It still seems not right. I have too much "gain" and the phase seems wrong too.
the original function is:
y=sin(x)+(abs(sin(x)))^8-z
I have added the schematic. And a picture of how the sinewave should look like.
Re: sin1(x) > 1 ?
Posted: Tue Sep 23, 2014 9:07 pm
by KG_is_back
te provided image definitely doesn't show the graph of function you've written. check that with this plotter, It will output the same kind of wave like your schematic:
http://rechneronline.de/function-graphs/ and input "sin(sin(x))+(abs(sin(sin(x))))^8-0.01" (the inner sinuses are there to simulate a sine wave input)
You will see that your schematic shows the same graph as this function. Basically you've made perfectly the function you've written above within the code component.
It is possible that the user used different input wave, but unlikely. There must be something more in the paper that they've done with the signal, because the function and graph definitely doesn't match if input was sine.
Re: sin1(x) > 1 ?
Posted: Wed Sep 24, 2014 9:46 am
by jotb
thank you. very good link!
I have found something in the matlab code:
there is a point before ^
sin(x)+(abs(sin(x))).^8-z
i found out that is something like element by element calculation. but where is a matrix or so ??
