Pitch and onset detection from Cycfi

Status
Not open for further replies.

okvern

New member
Colleagues,

Joel de Guzman is doing amazing things with multichannel guitar pickups at cycfi.com. He's also written some great pitch and note onset detection code. He's looking for collaborators and/or interested parties:

https://www.cycfi.com/2021/10/keeping-it-open-rethinking-open-source-part-2/

If it's possible to run this on the Teensy, I think it would be a huge addition to the Audio Library. If you've got the chops--and the time--drop him a line!

Thanks,

Olav Kvern
 
The audio lib is open source on Github - he can contribute to it anytime. But why do you speak for him?
 
__builtin_popcount(for 32Bit) looks like this on Teensy:
Code:
    1c68:    0843          lsrs    r3, r0, #1
    1c6a:    f003 3355     and.w    r3, r3, #1431655765    ; 0x55555555
    1c6e:    1ac0          subs    r0, r0, r3
    1c70:    0883          lsrs    r3, r0, #2
    1c72:    f003 3333     and.w    r3, r3, #858993459    ; 0x33333333
    1c76:    f000 3033     and.w    r0, r0, #858993459    ; 0x33333333
    1c7a:    4418          add    r0, r3
    1c7c:    eb00 1010     add.w    r0, r0, r0, lsr #4
    1c80:    f000 300f     and.w    r0, r0, #252645135    ; 0xf0f0f0f
    1c84:    eb00 2000     add.w    r0, r0, r0, lsl #8
    1c88:    eb00 4000     add.w    r0, r0, r0, lsl #16
    1c8c:    0e00          lsrs    r0, r0, #24
    1c8e:    4770          bx    lr
Does not look that slow - 12 cycles (without taking T4's dual issue into account)

(Was the post just SPAM?)
 
Hi FrankB,

I'm not attempting to "speak for him"--I'm just passing along something that might be of interest to people here. I'm not sure what was wrong with that?

Also, he wasn't saying that __builtin_popcount is slow, he was observing that not all microcontrollers support it. [Edit] Yes, I guess he did say it was slow in straight C++, but I understood his main point was that it wouldn't work on all architectures.

Thanks,

Olav
 
As said, the lib is open source. Good contributions are always welcome.

And, as this is a commercial site, placing the link here is questionable.
 
Last edited:
As said, the lib is open source. Good contributions are always welcome.

And, as this is a commercial site, placing the link here is questionable.

Ah, I see. I was mostly thinking of his Open Source work (of which there's quite a lot). You're right, my apologies.
 
Ah, I see. I was mostly thinking of his Open Source work (of which there's quite a lot). You're right, my apologies.

There is no need to apologize here, FrankB didn't take the time to look into what is behind that short blog post.

Joel de Guzman has a novel, monophonic pitch detection algorithm called BACF implemented in his open source C++ Q library, which he was going to remove, but then changed his mind. okvern simply saw this as a potential opportunity to ask if anyone might be able to port it to the Teensy Audio Library. Of course Joel could port his algo to the Teensy Audio Library himself, but why on earth would he? It's already fully implemented, and deeply integrated in his own, arguably better audio library.

That bit in the blog post about "__builtin_popcount()" stems from a discussion I had with him a few months ago as I was trying to get his algorithm running on the Daisy Seed (STM32H7). Profiling an earlier POC version of the algo, and my own adaptation of that showed that getting the Hamming weight of the bitstream in the auto-correlation function, and specifically that GCC builtin to be the hot spot. While AMD64 has a single cycle POPCNT instruction, ARMv7 does not, and those 12 instructions suddenly become noticeable on a microcontroller in a critical loop.

After testing against the current implementation found in the Q library, I found it works fine on the STM32H7, given the signal is appropriately conditioned. This is because there are now significant optimizations to filter and reduce the number of candidate periods that even get auto-correlated, reducing the overall load.

@okvern - I have no intention of porting the algo to the Teensy Audio Library, or testing it on the Teensy. I do having it running on the Daisy, and I'm using it for a project I'm working on. If you're familiar with that platform and would like to know more, feel free to get in contact with me.
 
Last edited:
If this was really not meant as spam (paid consulting etc) I apologize of course.
It would be fine if he would contribute the algorithm to the Teensy audiolib.
 
Status
Not open for further replies.
Back
Top