Waveform formulae for signalscope

Discuss Lemur and share techniques.
Post Reply
dc_Sux
Newbie
Posts: 9
Joined: 07 Jan 2012 12:37

Waveform formulae for signalscope

Post by dc_Sux »

This is a purely cosmetic thing, but I was hoping to program different signalscopes to display sine, sawtooth, reverse sawtooth, triangle and square waves, depending on what was selected for my oscillators/LFOs etc.

Trigonometry isn't exactly my strong point. I can get it to display a scrolling sine wave using the formula:

x=time%1
y=0.5+sin(time)*0.5
timebase=10

Anyone got any clue how I can get it to display these other waveforms?

I'd also like to be able to change the frequency depending on the individual tuning of the oscillators.

Any help on how to do this would be greatly appreciated.
Phil999
Regular
Posts: 919
Joined: 11 Jan 2012 01:53

Re: Waveform formulae for signalscope

Post by Phil999 »

square wave: round(0.5+sin(time)*0,5)
sawtooth wave: time-floor(time)

but you don't see the vertical lines.


http://en.wikipedia.org/wiki/Sawtooth_wave
http://en.wikipedia.org/wiki/Square_wave
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro
analog604
Regular
Posts: 262
Joined: 29 Dec 2011 15:40
Location: north east, usa

Re: Waveform formulae for signalscope

Post by analog604 »

Trig is a struggle point for me, but I can read code.
So I adapted some cpp code to get a triangle waveform:
asin(sin(time%1*3.14159+(time%1/10000)))/1.568
anyone have a better way to get a Tri?

dc_Sux wrote:This is a purely cosmetic thing, but I was hoping to program different signalscopes to display sine, sawtooth, reverse sawtooth, triangle and square waves, depending on what was selected for my oscillators/LFOs etc.

Trigonometry isn't exactly my strong point. I can get it to display a scrolling sine wave using the formula:

x=time%1
y=0.5+sin(time)*0.5
timebase=10

Anyone got any clue how I can get it to display these other waveforms?

I'd also like to be able to change the frequency depending on the individual tuning of the oscillators.

Any help on how to do this would be greatly appreciated.
Dashboard gear control templates: User 112 Idx :: LModIt Lite :: SVG image converter for Lemur Canvas
st8_livecontrol
Newbie
Posts: 8
Joined: 04 Oct 2010 12:26

Re: Waveform formulae for signalscope

Post by st8_livecontrol »

Heres my more primitive triangle generator, where o is some multiple of time
val = o % 4 > 2 ? (2 - o %2)/2 : (o % 2)/2;

i initially went the trigonmetric route with the sine series (http://en.wikipedia.org/wiki/Triangle_wave), you need about 3-5 harmonics for a decent triangle wave but you still get a bit of oscillation near the peaks. The above code cuts down mathematical operations somewhat.
Post Reply