Std::valarray for audio processing


#1

I just came across this from a Quora post

    std::valarray<int> data = {0,1,2,3,4,5,6,7,8,9};  
    data *= 2; // now holds 0 2 4 6 8 10 12 14 16 18 
    data[data > 10] = -1; // now holds 0 2 4 6 8 10 -1 -1 -1 -1 

Seems like it would be handy for processing buffers of audio data, anyone using it? Posting here for future reference :slight_smile:


#2

Interesting stuff…Recently started using libarmadillo for matrix/linear algebra operations in some real-time audio classification as like lots of numerical libraries it uses expression templates to avoid creating temporaries which means a lot of the routines and operators can be used on a high-priority thread.

Would be interested at looking into std::valarray a little further though in case it could act as a quick replacement for things of a smaller scope/scale.

Cool.


#3

Maybe a bit overkill but I’m a big fan of eigen.