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

Math help

For general discussion related FlowStone

Math help

Postby adamszabo » Wed Sep 16, 2020 3:42 pm

Hey friends,

I have to revisit an old code with this nasty formula: 0.0001^( SampleRate / ( 10^(( x-1)*4.307) - 4.925e-005 )*600 ), and I have to rewrite this in stream form, which will use way too much CPU because there are too many powers and a division. Are there any math wizards that can help me rewrite this in a much simpler form? It doesnt matter if there are some errors, as long as its close to it. The only variable is the 'x' and a samplerate input.

Thank you!
Attachments
formula.fsm
(254.63 KiB) Downloaded 932 times
adamszabo
 
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Math help

Postby aronb » Wed Sep 16, 2020 6:22 pm

Hi,

I might be able to help... BUT I have a few questions:

1) What are you calculating? Might be a more efficient way...
2) Otherwise is it just that EXACT formula?
3) What tolerances do you need? How exact does what you are calculating have to be...

Thank you,

Aron
User avatar
aronb
 
Posts: 154
Joined: Sun Apr 17, 2011 3:08 am
Location: Florida, USA

Re: Math help

Postby juha_tp » Wed Sep 16, 2020 6:25 pm

Try Simplify[0.0001^( f / ( 10^(( x-1)*4.307) - 4.925e-005 )*600 )] at https://www.wolframalpha.com/
juha_tp
 
Posts: 60
Joined: Fri Nov 09, 2018 10:37 pm

Re: Math help

Postby MichaelBenjamin » Wed Sep 16, 2020 7:00 pm

.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 11:02 am, edited 1 time in total.
MichaelBenjamin
 
Posts: 275
Joined: Tue Jul 13, 2010 1:32 pm

Re: Math help

Postby juha_tp » Wed Sep 16, 2020 7:08 pm

What is the range for variable "x" ?
juha_tp
 
Posts: 60
Joined: Fri Nov 09, 2018 10:37 pm

Re: Math help

Postby adamszabo » Wed Sep 16, 2020 8:18 pm

Thanks guys. This is for a decay calculation on my envelope so it needs to be pretty accurate, but it depends on the formula on how much cpu I can save. The range for the x input is from 0-1 only.
adamszabo
 
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Math help

Postby martinvicanek » Wed Sep 16, 2020 8:36 pm

The formula that is implemented in the schematic should read

0.0001^{1/[600*SampleRate*(10^4.307*(x - 1) - 4.925e-5)]}

For x in the range between 0 and 1, a reasonable approximation for 44.1k is

1 - (0.9939 + 2914*x)/(1 + x*(3102 + x*4356980))

Relative error is less than 1%.
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: Math help

Postby adamszabo » Wed Sep 16, 2020 8:52 pm

Thanks Martin!

The sample rate variable must be dynamic however, as the synth will get the samerate from the DAW. I cannot set it as fixed. Any ideas what to do in that case?
adamszabo
 
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: Math help

Postby deraudrl » Wed Sep 16, 2020 9:50 pm

adamszabo wrote:Thanks Martin!

The sample rate variable must be dynamic however, as the synth will get the samerate from the DAW. I cannot set it as fixed. Any ideas what to do in that case?
Derive the constants in Martin's equation once when the sample rate changes, then use the simplified equation thereafter?

Or maybe just look them up from a table: I suspect the number of different values for sample rate that you need to be able to deal with is rather small.
I keep a pair of oven mitts next to my computer so I don't get a concussion from slapping my forehead while I'm reading the responses to my questions.
deraudrl
 
Posts: 239
Joined: Thu Nov 28, 2019 9:12 pm
Location: SoCal

Re: Math help

Postby martinvicanek » Thu Sep 17, 2020 8:25 am

Forget my previous post. If the quantity of interest is the decay factor per sample, you need much more accuracy. I can offer the attached implementation using fast powers.
Attachments
stream_formula.fsm
(121.88 KiB) Downloaded 933 times
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Next

Return to General

Who is online

Users browsing this forum: No registered users and 37 guests