Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Vector Math

  1. #1
    Senior Member
    Join Date
    May 2019
    Location
    Brisbane, QLD
    Posts
    102

    Vector Math

    In reference to;

    https://arm-software.github.io/CMSIS...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...

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,874
    Quote Originally Posted by martianredskies View Post
    So pSrcB & pSrcA have to be array defined at compile with static numbers?
    No, it just means the function does not change the src.

  3. #3
    Senior Member
    Join Date
    May 2019
    Location
    Brisbane, QLD
    Posts
    102
    Quote Originally Posted by Frank B View Post
    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?

  4. #4
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    230
    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

  5. #5
    Senior Member
    Join Date
    May 2019
    Location
    Brisbane, QLD
    Posts
    102
    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?



    Quote Originally Posted by chipaudette View Post
    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

  6. #6
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    230
    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!

  7. #7
    Senior Member
    Join Date
    May 2019
    Location
    Brisbane, QLD
    Posts
    102
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •