Vector Math

Status
Not open for further replies.

martianredskies

Well-known member
In reference to;

https://arm-software.github.io/CMSIS_5/DSP/html/group__groupMath.html

I'm trying to understand where vector math has usage given that it expects constants for the A/B array? Consider the vector float multiply;


Code:
void arm_mult_f32	(	const float32_t * 	pSrcA,
const float32_t * 	pSrcB,
float32_t * 	pDst,
uint32_t 	blockSize 
)

So pSrcB & pSrcA have to be array defined at compile with static numbers? In the most basic way, how could one take advantage of
vector math like this for processing audio? like theoretically...
 
No, it just means the function does not change the src.

Ok, that makes more sense. So if you were building an 8 channel mono mixer that did 8 multiplications, this could be done using the vector multiply? pSrcA could be an array of 8 values representing one sample of incoming audio, pSrcB could be multiplication values for each sample & pDst would be the results of each multiplcation? Does it matter how many samples are each array? 2/4/8/16 float32_t?
 
IMO, you should always first write your code yourself without using the CMSIS libraries. Only when you get it working should you introduce the CMSIS functions so as to (maybe) accelerate things.

If you're inexperienced with the CMSIS style, you're always going to be questioning if you're using them right. If you have your own implementation first, even if it is an inefficient implementation, you'll have something to compare to, which let you confirm that you're using the CMSIS functions correctly.

I've been there...I know...the CMSIS docs are not for newbies. So just implement your mixer in your own code first. 4/6/8 channels isn't really that complicated. You'll find it much easier to do it yourself than working through their docs. Then, once it's working, you can focus on the narrower task of fitting their functions to your known-working code. That'll be much easier, much less frustrating, and much more effective for learning this new skill.

Signed: your friend, a recent CMSIS newb himself, Chip
 
This is good advice, though just given the ambitiousness of the audio project I'm undertaking, i think I'm going to have to use every trick in the book to get the most out of a T3.6... either that or start offloading some things onto external hardware chips, which is not a bad idea Vs complicated coding tricks.

I've already designed the hardware interface and now I'm building the engine, every refinement means i can do a little more with the same design. Are the vector functions even available in the version that is packaged with teensyduino?



IMO, you should always first write your code yourself without using the CMSIS libraries. Only when you get it working should you introduce the CMSIS functions so as to (maybe) accelerate things.

If you're inexperienced with the CMSIS style, you're always going to be questioning if you're using them right. If you have your own implementation first, even if it is an inefficient implementation, you'll have something to compare to, which let you confirm that you're using the CMSIS functions correctly.

I've been there...I know...the CMSIS docs are not for newbies. So just implement your mixer in your own code first. 4/6/8 channels isn't really that complicated. You'll find it much easier to do it yourself than working through their docs. Then, once it's working, you can focus on the narrower task of fitting their functions to your known-working code. That'll be much easier, much less frustrating, and much more effective for learning this new skill.

Signed: your friend, a recent CMSIS newb himself, Chip
 
Yes they are part of teensyduino. Just add to the top of your code

#include <arm_math.h>

As for learning how to use them, you don't have to prototype your use of vector math operations in your full system. I fact, you should not do it in your full system. You should do your trials in a super quick and simple program.

Write a very simple dumb "hello world" program that runs on the Teensy. you just need the teensy, no other hardware. Create a couple arrays of numbers. Fill the arrays with whatever values you want. Then, write a super basic function that multiplies them together (or whatever). Be as inefficient as you want. Just be simple so that you have confidence that you get the answer that you're expecting. Print the results over the Serial Monitor. Confirm you're getting what you expect.

Only then do you substitute one of the CMSIS functions for your hombrewed function. Print the results to the serial monitor. Does it match what you got with your code?

If so, you win! Now you know how to use the CMSIS function and you can deploy if with confidence into your full system.

If it does not give the same answer, try using it in a diff way. Or, you're using the wrong CMSIS function for the operation that yoj think that you want. Or, post your simple code here and ask questions.

Always test unfamiliar things in a short dumb simple program! Save yourself headaches!
 
I will take that advice. In the meantime I'm converting all my single variables into array groups, that should make it easier to integrate any possible vector math down the road conceptually. Thanks for your input.
 
Status
Not open for further replies.
Back
Top