DSPRelated.com
Forums

Efficiency of Midi->Freq and back

Started by MatthewA March 25, 2019
I'm writing something with a lot of conversions between midi and frequency in a timing tight situation and I'm wondering about efficiency.  (in C)  

What are the community's experiences with this?  Would a 1 or 10 cent interpolated lookup table be more efficient?  Is there a way to make the log less expensive?  Does caching and comparing the last input and output help?  

Thanks for any insight.

-Matthew Aidekman
On Mon, 25 Mar 2019 06:37:11 -0700 (PDT), MatthewA
<matthewaudio@gmail.com> wrote:

>I'm writing something with a lot of conversions between midi and frequency in a timing tight situation and I'm wondering about efficiency. (in C) > >What are the community's experiences with this? Would a 1 or 10 cent interpolated lookup table be more efficient? Is there a way to make the log less expensive? Does caching and comparing the last input and output help? > >Thanks for any insight. > >-Matthew Aidekman
"Efficiency" is highly project and application specific. For example, what your efficiency metrics are might not be the same as someone else's efficiency metrics. Is speed most important to you? Energy consumption? Memory use? Device cost? Development time? Development cost? You haven't specified an efficiency metric, so interpret any answers you get accordingly.
MatthewA wrote:
> I'm writing something with a lot of conversions between midi and > frequency in a timing tight situation and I'm wondering about > efficiency. (in C) >
So you mean mapping frequency in Hz onto note numbers and vice versa? Pitch detect probably takes several orders of magnitude more computation. I'm thinking it was like 40ish msec on a nice beefy Win7 3.02GHz dual processor i5.
> What are the community's experiences with this? Would a 1 or 10 cent > interpolated lookup table be more efficient?
I don't know. Code it up and measure it. Matching floating point numbers in a table lookup is pretty fiddly.
> Is there a way to make > the log less expensive?
Probably not.
> Does caching and comparing the last input > and output help? >
Depends on the data flow.
> Thanks for any insight. > > -Matthew Aidekman >
-- Les Cargill