Support

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 pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

making triangle/ramp switch

For general discussion related FlowStone

making triangle/ramp switch

Postby tester » Mon Sep 16, 2013 3:00 pm

I can't find an easy way to do that.

I have flat-ramp generator (with phase offset) to drive something, and I'd like to add some quick switch to the code to flip from ramp to triangle.

One of my guesses is, that some sort of triangle formula could be added to the code, but this would produce double calculations or would involve additional selectors on stream routing. I'd like to avoid that.

Other of my guesses is, that there is some sort of threshold based formula, that would generate flat ramp or flat triangle (in 0-1 range), depending on flip, value that can be provided via separate input.

How to make it?
Attachments
convert.fsm
(27.46 KiB) Downloaded 865 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: making triangle/ramp switch

Postby tester » Mon Sep 16, 2013 3:37 pm

Hmm... Found and adapted something like this?
Attachments
triramp1.fsm
(27.43 KiB) Downloaded 891 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: making triangle/ramp switch

Postby trogluddite » Mon Sep 16, 2013 9:38 pm

Pretty cool - PWM for triangle waves!

If you're only ever switching in green, you could calculate 1/sw and 1/(1-sw) in a hop - should save a fair few CPU cycles replacing the divides for multiplys in the main equation.

Might also be worth restricting the range of sw by a tiny amount - there's a corner case at each end of the wave where 'zero divides zero' is possible - which would give an indeterminate answer (-1.#IND). If sw = 0, you will always get that on the first sample when ph has just initialised.
Depends what you're going to do with it, but that gives potential for a 'lock-up' situation if feeding into e.g. biquad filters etc. where the #INF can feed back on itself indefinitely. Probably rare that 'ph' would exactly be zero to 32bit precision, but it only needs to happen once in that kind of setup - needing an audio reset to recover!
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: making triangle/ramp switch

Postby tester » Mon Sep 16, 2013 9:58 pm

I borrowed this one from SM and cleaned up and slightly modified. The original idea there was to smoothly change/morph from ramp through traigne to saw.

As for hoping - generally this one will be modulated (ramp is needed to get full rotation, triangle is needed to get angle swing back and forth), so not sure which part / how could be hoped.

Yes, I noticed a glitch on initlalizing. By limiting you mean like 1e-36 instead of 0 for phase offset or something in code?
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: making triangle/ramp switch

Postby tester » Mon Sep 16, 2013 11:24 pm

Trog - you mean something like this?

Question: Ramp/triangle is feeding/modulating the rotation of local soundspace. Will not the sw limit produce audio glitch, at least from time to time?
Attachments
triramp2.fsm
(27.62 KiB) Downloaded 893 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: making triangle/ramp switch

Postby DjMmix » Thu Dec 19, 2013 8:45 pm

hi tester,

I took your algo in asm as impossible to understand the conditions of your code (it's not fault of trying to have)

if you could explain your algorithm simply I include in the DLL in C + + code directly thank you :)

and very interesting passage: p
DjMmix
 
Posts: 16
Joined: Wed Nov 09, 2011 8:02 am
Location: france

Re: making triangle/ramp switch

Postby Nubeat7 » Thu Dec 19, 2013 9:41 pm

i remember some further discussion about this code here:
viewtopic.php?f=2&t=1688&start=10

variables are renamed here, maybe its better to understand
here is the fixed schematic with different variablenames, hope this helps
triramp_fix.fsm
(29.49 KiB) Downloaded 903 times


if you re not familiar with FS DSP code, the & acts like "if - then"

so:
Code: Select all
ramp>=1&1

would mean "if ramp >= 1 then 1"
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: making triangle/ramp switch

Postby DjMmix » Thu Dec 19, 2013 10:59 pm

thank's nubeat :)

good explain
DjMmix
 
Posts: 16
Joined: Wed Nov 09, 2011 8:02 am
Location: france

Re: making triangle/ramp switch

Postby tester » Thu Dec 19, 2013 11:43 pm

Gosh... I don't remember the context! :mrgreen: :-) I only remember, that it is already implemented somewhere (modified or as it is - I don't remember) and probably works fine. Otherwise I would remember it among things to do.

But as I am going to revisit some projects soon (within few months), switching from 'clone' philosophy into 'multifunction/array' based - if there is something to find out - it will come out. Thanks for pointing.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet


Return to General

Who is online

Users browsing this forum: No registered users and 37 guests

cron