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

Thread: Pitch and onset detection from Cycfi

  1. #1
    Junior Member
    Join Date
    Oct 2021
    Posts
    4

    Pitch and onset detection from Cycfi

    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/keepin...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

  2. #2
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,409
    The audio lib is open source on Github - he can contribute to it anytime. But why do you speak for him?

  3. #3
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,409
    __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?)

  4. #4
    Junior Member
    Join Date
    Oct 2021
    Posts
    4
    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

  5. #5
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,409
    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 by Frank B; 10-22-2021 at 10:21 AM.

  6. #6
    Junior Member
    Join Date
    Oct 2021
    Posts
    4
    Quote Originally Posted by Frank B View Post
    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.

  7. #7
    Quote Originally Posted by okvern View Post
    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 by recursinging; 10-22-2021 at 08:07 PM. Reason: Remove code formatting

  8. #8
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    9,409
    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.

  9. #9
    Junior Member
    Join Date
    Oct 2021
    Posts
    4
    It wasn't spam, but I appreciate your concerns about posting links to commercial sites.

Posting Permissions

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