KFR: C++ DSP framework, FFT, FIR, biquad, sample rate conversion

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Chang-soo Kim wrote:Hi,
Hello, I just included your Framework but got loads of errors on OS X in cometa.hpp and min_max.hpp:

Image

Any ideas what I'm doing wrong/ what the issue is?

Would love to try out some of kfr as it looks very nice

Dave

Post

Hi Dave,

Judging by the screenshot,
somewhere in your project the following macros are defined:

Code: Select all

#define min(x, y) (((x) < (y)) ? (x) : (y))
#define max(x, y) (((x) > (y)) ? (x) : (y))
This prevents any functions named min and max from being defined anywhere after these macros.

To work around this, place

Code: Select all

#undef min
#undef max
before including kfr headers
or completely remove these macros (and replace by functions) cause they can break
any library that use min and max names or std::min/std::max functions.

Post

Namespaces would avoid these clashes.

Post

Namespaces can isolate functions but not macroses.
C preprocessor that replaces min and max knows nothing about C++ namespaces.

Post

You're right. Though I would just use namespaced functions, but that's irrelavent here, really. I actually overlooked the fact you were discussing macros somehow.

Post

Chang-soo Kim wrote:Namespaces can isolate functions but not macroses.
C preprocessor that replaces min and max knows nothing about C++ namespaces.
Since some headers like to define those, I've personally learned to always use (std::max)(a,b) which breaks macro-expansion so you never need to worry about it anymore.

Post

KFR 1.1.0 has been released.

New features:
1. Zero latency biquad filter
2. Documentation has been written for many functions
3. Access to the internal state of expressions and their operands
4. Ability to replace arguments in existing expressions
5. phasor function to easily setup oscillators
6. expression_adjacent: call a binary function on the adjacent elements of the input expression
7. Virtual base classes for the user-defined expressions
8. dspplot python library: New parameter div_by_N

Post

Chang-soo Kim wrote:KFR 1.1.0 has been released.

New features:
......
5. phasor function to easily setup oscillators
Hi, sorry for the stupid question but I'm trying to generate a unipolar trivial sawtooth using kfr version 1.1.0 and having some difficulty. I'd expect the following LOC to give me the output, a double, using kfr::phasor

Code: Select all

kfr::fbase phasor_203 = kfr::phasor(calculatedFrequency, 44100);
but I get an error:

Image

How would I get the output of the Phasor?

Also, I'd expect a Phasor to have a reset method but I guess this is handled internally by reduce.hpp, line 85?:

Code: Select all

void reset() { counter = 0; }

Post

The compiler warns you that no conversion from object type (expression_function<...>) to double.
It's because your code tries to get output by calling phasor function,
but phaser function returns object, not double value (fbase is an alias for double where it's native type).

Example of the proper usage of the phasor:

Code: Select all

auto ph = phasor(441.0, 44100.0);
univector<double, 2000> saw440hz_1 = sawtoothnorm(ph); // start from phase=0
univector<double, 2000> saw440hz_2 = sawtoothnorm(ph + 0.5); // start from phase=180deg
Note that phasor generates values in the range [0..1), so use oscillator functions whose names ends with 'norm'.

Reset method isn't needed because phasor resets every time it's used in an expression.

I'm always ready to answer any questions, but if a question requires detailed explanation, it would be better to move our conversation to
gitter:
https://gitter.im/kfrlib/kfr

Image

Post

Chang-soo Kim wrote: I'm always ready to answer any questions, but if a question requires detailed explanation, it would be better to move our conversation to
gitter:
https://gitter.im/kfrlib/kfr
Agreed. I'll ask there next time.

Thanks Chang-soo for the explanation. Can't wait to try out more of the KFR stuff....

Dave :D

Post

Liking the speed of updates. Is it possible to create biquads of variable section lengths at runtime rather than compile time? Might be a good idea to create a forum on KVR for questions ;-)

Post

keithwood wrote:Liking the speed of updates.
The speed at which the updates are released highly depends on how the framework helps developers to use and extend it.
The KFR code is well-structured, many utility functions have been written, so adding new features is usually a not-so-hard process.
In the same manner, using the KFR framework, a developer can improve not only the speed of execution but also the speed of development of an application or an audio plugin.
keithwood wrote:Is it possible to create biquads of variable section lengths at runtime rather than compile time?
Here is example of variable length biquad filter.
Download (or pull from repo) latest version of KFR and compile this code:
https://kfrlib.com/blog/biquad_variable_length-cpp/

In the above example, the cswitch function is used to pass a runtime value (filter length) in template parameter list.
Here is a detailed explanation of the cswitch function from the KFR:
https://isocpp.org/blog/2016/08/how-cpp ... d-examples

Post

KFR 1.2.0 has been released.

New features and notable changes:

1. Real-to-complex and complex-to-real FFT
2. FFT plan caching
3. Cross-correlation and auto-correlation
4. Initial support for GCC and other compilers
5. Compile times have been reduced by 10 times in Debug mode
6. New function to partition expression for parallel execution
7. Faster implementations for many functions
8. Various small improvements and fixes

Post Reply

Return to “DSP and Plugin Development”