General
Waveform formulae for signalscope
Started by dc_Sux on .
Sign in or create an account to join the conversation.
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.
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.
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
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
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?
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.
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.
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.