Page 1 of 6

Irregular Sine Waves

Posted: Thu Oct 29, 2015 8:24 am
by tulamide
I wonder why there are adjustable square waves, where the center is moved around (like phase modulation of some sort)

Code: Select all

|  |  |
| |   |
|    ||


but no sine waves, adjustable in the same way? I can imagine this to be a rich sound if more than one oscillator is used.

Since time is constant in this scenario, I assume the gaps between two sample points vary according to some function, that is able to accept a varying factor. But I have no clue how to produce an oscillator from that.

Has anyone ever made something similar? Or is it just a stupid idea for reasons I don't see yet?

Re: Irregular Sine Waves

Posted: Thu Oct 29, 2015 9:12 am
by nix
It is quite easy with wavetables.
Just get the 2 sine halves 0-180, 180-360 and resample them in ratio as float arrays.
'resample float array' is the one.
(edit-you will need float array append to join the 2 halves together)

This is not modulatable though really sadly.

I'm curious to write osc algos. Sine is the only one I'm stuck on,
but it can be realised by low passing a triangle.

hmm, you've got me interested in trying this somehow- so it can be swept, too

Re: Irregular Sine Waves

Posted: Thu Oct 29, 2015 8:18 pm
by martinvicanek
The equivalent to pulse width modulation of a square wave would be a synchronous phase modulation of a sine wave so that the valleys and crests get stretched (horizontally) in opposite directions, respectively. You can do that by feeding a fraction of the oscillator output back to its phase input. More variety is possible with some quadrature trickery.

Have fun. ;)

Re: Irregular Sine Waves

Posted: Thu Oct 29, 2015 11:04 pm
by tulamide
What can I say? Awesome as always, Martin!
I can already hear, just as I expected, that the sound characteristic changes distinctly. That will give some new options. I don't really understand what you mean by "quadrature trickery", but if that is something that doesn't cost you too much time, would you mind giving an example of that, too?

Oh, and what would be a good name for it? Pulse Width Modulation, or PWM, is known to the people, but would Sine Width Modulation, or SWM, really address the functionality of this? It would be more like half-cycle width modulation, or something, right?

EDIT: Oops, just read your answer again. So, "synchronous phase modulation", or SPM, would be the matching name?

Re: Irregular Sine Waves

Posted: Fri Oct 30, 2015 12:44 am
by BobF
Hello gang,

Wow, now this is what I am talking about! Refferencing to "Crazy Ideas".
Cool tricks and tips stuff. Many thanks Martin, a very cool trick.

Later then, Bobf.....

Re: Irregular Sine Waves

Posted: Fri Oct 30, 2015 9:47 am
by Spogg
Guys!
I spent a couple of hours on this last night, also playing around with self-phase modulation (feedback) and also using a second synchronised oscillator for the modulation source with various waveforms. I got similar results to Martin but not what I understood tulamide was asking for.
Like nix I thought he was after something like zero-crossing modulation as per my very poor sketch below.

Martin's technique is found in the DX7 and my QX7 whereby feedback around 1 oscillator and env creates a wide range of harmonic variations. Maybe tulamide could clarify what he wanted...?

Cheers

Spogg

Re: Irregular Sine Waves

Posted: Fri Oct 30, 2015 10:53 am
by tulamide
Hey Spogg,

you are absolutely right. What you sketched is what I oringinally looked for. And I would love to see that realized. But I also have fun with Martin's demo. So, if my original thoughts can't be realized, at least some alternative is available.

My thoughts began with the simple imagination of a sine wave, whose "center point" is moved away from the center. I can replicate this behaviour with my spline class for Ruby. But I couldn't find a formula for this. (See attached fsm)

You can't just reduce/increase the radius of the two half-circles, since the whole line from the top of the first half to the bottom of the second half is influenced.

So, yes, you are right. That's what I wondered about.

Re: Irregular Sine Waves

Posted: Fri Oct 30, 2015 11:32 am
by nix
hmm-
you can't do it by decreasing the radius,
but it can be done by changing frequency.
If you could write a half cycle, the correct freq change would make the desired form.

Re: Irregular Sine Waves

Posted: Fri Oct 30, 2015 1:41 pm
by Spogg
One thing I tried last night was modulating the frequency (not phase) with a separate synchronised variable pulse width square wave oscillator.
I figured that by varying the mark/space ratio I could achieve the desired result. This kinda worked BUT the overall period changed with the m/s ratio. This is because the frequency control spent more/less time high than low as the m/s ratio deviated from 50/50. It might be possible to create some compensation for this but it would not be elegant.
Unless someone knows better...

I thought this was going to be easy when I read the OP but it ain't!

Cheers

Spogg

Re: Irregular Sine Waves

Posted: Fri Oct 30, 2015 2:22 pm
by KG_is_back
I've also tried different approach... instead of modulating frequency/phase, I distorted the ramp-osc which was then driven into a sin1(x) function. I've made 2 versions.
first one simply changed the straight ramp into two lines, intersecting at y=0.5 and x specified by mod. Problem was, the resulting oscillator was not smooth on zero crossings.
Second version, I've changed the ramp into exponential function that crosses [0,0] [mod,0.5] [1,1]. The resulting oscillator was smooth in the center, but the transition from one period to next was not smooth.
Lastly I tried to make it smooth on both zero crossings, but after about an hour I rage-quitted and destroyed versions 1 and 2 in the process... :shock: