Author Topic: expression evaluator  (Read 2939 times)

Ingolf2

  • Guest
expression evaluator
« on: 27 Mar '03 - 13:08 »
Hi there,

I am working on a little expression evaluator, for doing graphs, but my main goal was to let the user fill in any formula to create new sound effects to apply to the sound realtime.

This code gets turned inside out and calculated 10000 times in 1400ms on my Intel P4 2.04Ghz.

My question: is this fast enough?

Code: [Select]
truncation = 10;
manipulation = 121;
hertz = 6;
noise = 300;

n = random(noise)/1000;
y = sin(x * hertz);
y = y^manipulation;
y = trunc(y * truncation)/truncation;
y = y + (n-(noise/2000));


It does this (10000 calculations) in 78ms:

Code: [Select]
y=sin(x);

I calculated (don't know exactly) that 50ms of stereo 16-bit data is 882 samples, so I tried the first formula on 882 samples, and it returned 125ms, which is too slow I guess??

Ingolf

  • Posts: 81
Re: expression evaluator
« Reply #1 on: 27 Mar '03 - 22:18 »
I narrowed it down to 0/15ms, so that would be enough I guess :)

CakeDeath

  • Guest
Re: expression evaluator
« Reply #2 on: 28 Mar '03 - 22:15 »
How did you speed it up?

Ingolf

  • Posts: 81
Re: expression evaluator
« Reply #3 on: 29 Mar '03 - 09:04 »
I removed as many string manipulations, string to float conversions, etc. as possible.