If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding premade modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
Sin Osc (for curiosity)
13 posts
• Page 1 of 2 • 1, 2
Sin Osc (for curiosity)
Here's a sin osc.
But it's more for curiosity.
I recommend to use the Martin Vicaneck sin osc that is a little faster.
Also my phase system would probably make little problem ??
(need at least a dezip if controlled manually)
Optionally, we could have a little 3x harmonic.
I tried to shut down the aliasing, but i'm not sure i found the perfect value.
I liked the concept to use less variables, only 2, to convert a triangle in a sin approximation.
But this take more calculation..
Here's the formula :
X is Trig (01) >
X1 = X*X
X2 = 1((1X)*(1X))
z = ( (X2X1)* X) + X1
zz = ( (zX)* 0.282425) + X
result = ( (X2X1)* zz) + X1
(I also find that a triangle derivative multiplied by the frequency, then again derivative * freq make almost a sin..
But this lead to DC problematic that are more hard to deal..)
But it's more for curiosity.
I recommend to use the Martin Vicaneck sin osc that is a little faster.
Also my phase system would probably make little problem ??
(need at least a dezip if controlled manually)
Optionally, we could have a little 3x harmonic.
I tried to shut down the aliasing, but i'm not sure i found the perfect value.
I liked the concept to use less variables, only 2, to convert a triangle in a sin approximation.
But this take more calculation..
Here's the formula :
X is Trig (01) >
X1 = X*X
X2 = 1((1X)*(1X))
z = ( (X2X1)* X) + X1
zz = ( (zX)* 0.282425) + X
result = ( (X2X1)* zz) + X1
(I also find that a triangle derivative multiplied by the frequency, then again derivative * freq make almost a sin..
But this lead to DC problematic that are more hard to deal..)
 Attachments

 Cos Osc.fsm
 (33.3 KiB) Downloaded 151 times
 Tepeix
 Posts: 193
 Joined: Sat Oct 16, 2021 3:11 pm
Re: Sin Osc (for curiosity)
interesting, however the sine wave you produce is unipolar (goes between 0 and 1), a normal sine should be bipolar (1 to 1)
 adamszabo
 Posts: 646
 Joined: Sun Jul 11, 2010 7:21 am
Re: Sin Osc (for curiosity)
Yes, in fact it's like a (sin1(x) / 2) +0.5
But it only work for input value from 0 to 1.)
But it only work for input value from 0 to 1.)
 Tepeix
 Posts: 193
 Joined: Sat Oct 16, 2021 3:11 pm
Re: Sin Osc (for curiosity)
I was wrong with the derivative idea..
Seeing a derivative of a derivative of a triangle, i was thinking it's close to a sin.
To fight the DC that make a derivative, i find the "triangle derivative".
That's a triangle osc that take as input another's triangle multiplied by a multiple of his frequency.
> when changing the frequency it will act badly and go out of sync.. Needing a reset.
But the real problem is that the harmonics are not completely shut down even with 3 derivarive..
When frequency output is higher than 440 hertz the aliasing become very horrible !
Maybe each triangle derivative will shut harmonic only if they are not aliasing...
Also, with some frequency, an imprecision will make the "triangle derivative" out of sync repeatably.
Very not a good way to make a sin or i miss something to fix all of this !)
Seeing a derivative of a derivative of a triangle, i was thinking it's close to a sin.
To fight the DC that make a derivative, i find the "triangle derivative".
That's a triangle osc that take as input another's triangle multiplied by a multiple of his frequency.
> when changing the frequency it will act badly and go out of sync.. Needing a reset.
But the real problem is that the harmonics are not completely shut down even with 3 derivarive..
When frequency output is higher than 440 hertz the aliasing become very horrible !
Maybe each triangle derivative will shut harmonic only if they are not aliasing...
Also, with some frequency, an imprecision will make the "triangle derivative" out of sync repeatably.
Very not a good way to make a sin or i miss something to fix all of this !)
 Attachments

 Derivative sin is bad.fsm
 (24.39 KiB) Downloaded 151 times
 Tepeix
 Posts: 193
 Joined: Sat Oct 16, 2021 3:11 pm
Re: Sin Osc (for curiosity)
Here's another "sin".. But it fail to shut down completely harmonics..
(I might be obsessed by sin approximation osc !)
We make a ramp that go from 0 to 1.
And a square from 1 to 1, each time the ramp reset, the square switch.
Now it's "easy" to interpolate the square and almost make a sin like this:
C1 = 1( (1ramp)*(1ramp))
C2 = 1(ramp*ramp)
Result = square * C1 * C2.
But it take 4 multiply and a lot of instruction..
also it's not a prefect sin..
(I might be obsessed by sin approximation osc !)
We make a ramp that go from 0 to 1.
And a square from 1 to 1, each time the ramp reset, the square switch.
Now it's "easy" to interpolate the square and almost make a sin like this:
C1 = 1( (1ramp)*(1ramp))
C2 = 1(ramp*ramp)
Result = square * C1 * C2.
But it take 4 multiply and a lot of instruction..
also it's not a prefect sin..
 Attachments

 interpolation sin.fsm
 (34.17 KiB) Downloaded 146 times
 Tepeix
 Posts: 193
 Joined: Sat Oct 16, 2021 3:11 pm
Re: Sin Osc (for curiosity)
Interesting stuff!
In the old days of solid state analogue electronics the approach was to take a triangle wave, which was fairly easy to make, and process it with a bipolar nonlinear transfer, often made using the nonlinear range of forward conductance of diodes. This would be below about 0.7 volts for silicon and about 0.3 volts for germanium. This method also often appears in guitar distortion pedals and guitarists seem to argue about whether germanium or silicon diodes sound “better”. Go figure!
I’ve simulated this in the schematic using the tan(h)x module by Martin. In the analogue version there would usually be a trimmer to get the waveform with the fewest harmonics and in the oscillators I made back then I tuned it by ear, as you can with this version. Of course in the digital world aliasing can be heard at higher frequencies, even with the bandlimited triangle osc by Martin. Oversampling should reduce that.
In even older gear like a Rhodes piano, the valvebased low frequency oscillator for tremolo was made using a filtered square wave passed through a similar nonlinear transfer function to give a “rounded” clickfree waveform. This method was used because a valvebased low frequency sine wave osc was virtually impossible to make.
You did want a history lesson I hope!
In the old days of solid state analogue electronics the approach was to take a triangle wave, which was fairly easy to make, and process it with a bipolar nonlinear transfer, often made using the nonlinear range of forward conductance of diodes. This would be below about 0.7 volts for silicon and about 0.3 volts for germanium. This method also often appears in guitar distortion pedals and guitarists seem to argue about whether germanium or silicon diodes sound “better”. Go figure!
I’ve simulated this in the schematic using the tan(h)x module by Martin. In the analogue version there would usually be a trimmer to get the waveform with the fewest harmonics and in the oscillators I made back then I tuned it by ear, as you can with this version. Of course in the digital world aliasing can be heard at higher frequencies, even with the bandlimited triangle osc by Martin. Oversampling should reduce that.
In even older gear like a Rhodes piano, the valvebased low frequency oscillator for tremolo was made using a filtered square wave passed through a similar nonlinear transfer function to give a “rounded” clickfree waveform. This method was used because a valvebased low frequency sine wave osc was virtually impossible to make.
You did want a history lesson I hope!
 Attachments

 Triangle to sin .fsm
 3.06
 (195.05 KiB) Downloaded 162 times

Spogg  Posts: 3055
 Joined: Thu Nov 20, 2014 4:24 pm
 Location: Birmingham, England
Re: Sin Osc (for curiosity)
Thanks very interesting !
I was just trying to find some info on analog osc.
But i was not understanding anything and now it's very better !)
I need someday to go back to the basic of electricity, if i want to understand the articles on this subject.
I was just trying to find some info on analog osc.
But i was not understanding anything and now it's very better !)
I need someday to go back to the basic of electricity, if i want to understand the articles on this subject.
 Tepeix
 Posts: 193
 Joined: Sat Oct 16, 2021 3:11 pm
Re: Sin Osc (for curiosity)
Tepeix wrote:...I was just trying to find some info on analog osc...
...I need someday to go back to the basic of electricity, if i want to understand the articles on this subject...
It’s interesting to me that I came from the analogue world to DSP and found it hard at first, but younger folk start off with DSP then get interested in analogue processes and find that tricky to understand.
You might be interested to look inside my Quilcom ASS (Analogue Sounding Synthesiser):
viewtopic.php?f=3&t=8705&hilit=quilcom+ass

Spogg  Posts: 3055
 Joined: Thu Nov 20, 2014 4:24 pm
 Location: Birmingham, England
Re: Sin Osc (for curiosity)
I will be very interested to see inside this !!)
Here's another sin osc.
I'm surprise it works not so bad.
But they are limitations..
It's not adapted to sample rate and the input is not in hertz.
(Might be possible to upgrade in this way..)
Also it only go to 600 hz. (Might also be possible to upgrade but might be probably limited)
also it's only mono due to the filter design.
So it's a very naive form.
Taking the MV superfast random noise we feed a bandpass filter.
A feedback loop refeed the bandpass; this one need to be clipped to avoid hard rise in volume.
And we got a sin without harmonic.. But i'm not sure how it will do transition of volume or note.
Here's another sin osc.
I'm surprise it works not so bad.
But they are limitations..
It's not adapted to sample rate and the input is not in hertz.
(Might be possible to upgrade in this way..)
Also it only go to 600 hz. (Might also be possible to upgrade but might be probably limited)
also it's only mono due to the filter design.
So it's a very naive form.
Taking the MV superfast random noise we feed a bandpass filter.
A feedback loop refeed the bandpass; this one need to be clipped to avoid hard rise in volume.
And we got a sin without harmonic.. But i'm not sure how it will do transition of volume or note.
 Attachments

 Sin RandFeedBandpass.fsm
 (61.59 KiB) Downloaded 153 times
 Tepeix
 Posts: 193
 Joined: Sat Oct 16, 2021 3:11 pm
Re: Sin Osc (for curiosity)
Another sin !)
I like those research of sin.. So many possibility, so many strange math, geometry..
Maybe this one could be good for cpu, have to test it more..
Taking a triangle from 0.5 to 0.5. x
We do f1= (x+x)  (abs(x)*(x+x)).
This is a faster way to do like 1((1x)*(1x)) and it works also for negative value.
Then we do f2 = f1*(abs(f1))
We now have to multiply f2 by a parameter and simply add to f1.
(note that the output volume is greater than 1 to 1. also the input might be *0.5)
Depending of the parameter we could have a sin with almost no harmonics.
But the 3X harmonic stay so at approximately 7000hz aliasing will be audible.
Finally the parameter do not so bad at 0.5.
So another optimization is to do f1+f1+f2. Avoiding a multiplication.
But the aliasing will come a little faster.
I like those research of sin.. So many possibility, so many strange math, geometry..
Maybe this one could be good for cpu, have to test it more..
Taking a triangle from 0.5 to 0.5. x
We do f1= (x+x)  (abs(x)*(x+x)).
This is a faster way to do like 1((1x)*(1x)) and it works also for negative value.
Then we do f2 = f1*(abs(f1))
We now have to multiply f2 by a parameter and simply add to f1.
(note that the output volume is greater than 1 to 1. also the input might be *0.5)
Depending of the parameter we could have a sin with almost no harmonics.
But the 3X harmonic stay so at approximately 7000hz aliasing will be audible.
Finally the parameter do not so bad at 0.5.
So another optimization is to do f1+f1+f2. Avoiding a multiplication.
But the aliasing will come a little faster.
 Attachments

 fast sin.fsm
 (53.61 KiB) Downloaded 153 times
 Tepeix
 Posts: 193
 Joined: Sat Oct 16, 2021 3:11 pm
13 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 6 guests