GithubHelp home page GithubHelp logo

issues with pitch detector about q HOT 10 CLOSED

cycfi avatar cycfi commented on August 20, 2024
issues with pitch detector

from q.

Comments (10)

TheTechnobear avatar TheTechnobear commented on August 20, 2024

just a thought? could the 'issue' be related to that fact that each test i do is harmonically related - one octave above the previous test?

from q.

TheTechnobear avatar TheTechnobear commented on August 20, 2024

hmm, ok, predict_frequency() seems more likely to give me the correct frequency

but still doesn't like high frequencies

PD setup: 220.000000  - 100.000000/10000.000000 hZ


test freq 220.000000
done test 0 0.000000 220.000000 : 219.982468
get_frequency 219.944809 predict_frequency 219.982468 ,  periodicity 0.997768

test freq 440.000000
done test 1 0.200000 440.000000 : 439.759125
get_frequency 219.982483 predict_frequency 439.759125 ,  periodicity 0.997768

test freq 880.000000
done test 2 0.400000 880.000000 : 879.877930
get_frequency 439.963989 predict_frequency 879.877930 ,  periodicity 0.997768

test freq 1760.000000
done test 3 0.600000 1760.000000 : 1760.579102
get_frequency 103.530266 predict_frequency 1760.579102 ,  periodicity 0.995536

test freq 3520.000000
done test 4 0.800000 3520.000000 : 0.000000
get_frequency 1760.166748 predict_frequency 1759.921997 ,  periodicity 0.995536

test freq 7040.000000
done test 5 1.000000 7040.000000 : 0.000000
get_frequency 0.000000 predict_frequency 7058.785156 ,  periodicity 0.995536

calibrated output : 0
tunedV [0] : 219.982468 
tunedV [1] : 439.759125 
tunedV [2] : 879.877930 
tunedV [3] : 1760.579102 
tunedV [4] : 0.000000 
tunedV [5] : 0.000000 

from q.

djowel avatar djowel commented on August 20, 2024

Could you post some audio test files I can try to run the PD on? I think your lowest to highest frequency (100-10000) is beyond the range of the PD. Normally, you don't want a range that high. Real instruments don't have that range after all. I think the limit is something like 5 octaves. I probably should give a warning or error in such a case.

from q.

TheTechnobear avatar TheTechnobear commented on August 20, 2024

I don't generate/read from files - they are sin waves created with algo (not hard ;) ).
anything that creates a pure sin wave would be the same.

whilst the limit is 10000, I'm actually only using between 220-7040hz, so 5 octaves.
but you can see its failing at 4.5hz, so thats 4 octaves.

also get_frequency() is even lower than that...

should I be using get_frequency()?
why is predict_frequency() giving more accurate results?

what's the limit? is this an implementation limitation (e.g. float/double accuracy , or number of samples per cycle?) or a theoretical limitation on the algo used for the FFT?

obviously, if this is not going to work, then I guess I should move on to find an FFT/PD thats more suited to this application?

btw: Im also finding, if I re-create a PitchDetector its crashing with a SIG fault.
e.g. I was creating a shared_ptr and would use it with one test for a small range of frequencies around testfreq , then for the next test id create another one with a new range... and this crashes....
(crash is during operator(sample) - somewhere in autocorrelator)

btw2: when you compile, there are warnings about the default copy ctor being used, due to member _pd with PitchDetector - not sure if these are related to SIG fault.

from q.

TheTechnobear avatar TheTechnobear commented on August 20, 2024

SEGV fault...

Thread 3 "bela-audio" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb61ea450 (LWP 835)]
0x00015ee8 in cycfi::q::period_detector::autocorrelate()::{lambda()#1}::operator()() const ()
(gdb) bt
#0  0x00015ee8 in cycfi::q::period_detector::autocorrelate()::{lambda()#1}::operator()() const ()
#1  0x00015938 in cycfi::q::period_detector::autocorrelate() ()
#2  0x000152d4 in cycfi::q::period_detector::operator()(float) ()
#3  0x00014bc0 in render ()
#4  0x000271f0 in PRU::loop(void*, void (*)(BelaContext*, void*), bool) ()
#5  0x00017dd0 in audioLoop(void*) ()
#6  0xb6fbe59a in cobalt_thread_trampoline () from /usr/xenomai/lib/libcobalt.so.2
#7  0xb6f815e8 in start_thread () from /lib/arm-linux-gnueabihf/libpthread.so.0
#8  0xb6b614fa in ?? () from /lib/arm-linux-gnueabihf/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

from q.

djowel avatar djowel commented on August 20, 2024

Can you record those into files, maybe using a DAW? There's no way I can test this unless you give me a way to reproduce exactly what you have. There may be other factors other than just synthesizing sine waves. I do test using generated sine waves already.

Oh and the min-limit..max-limit is the range. So your range is already way beyond the limits regardless if you are only testing a subset of the range. Anyway, there can be other factors, so I really need a way to recreate your setup and settings in a test.

(Edit: You can skip this if you instead give me an mcve. See comment below).

from q.

djowel avatar djowel commented on August 20, 2024

btw: Im also finding, if I re-create a PitchDetector its crashing with a SIG fault.

Again there is no way to know without reproducing your scenario. Can you at least post a minimal, complete and verifiable example (mcve) test code that I can run here? Minimal test code, meaning it is one cpp file with code, stripped down to its minimum that still exhibits the problem, that anyone can immediately run without any extra hardware or software dependencies other than the library itself and the std libraries.

https://stackoverflow.com/help/minimal-reproducible-example

So basically, you have two distinct problems 1) the PD pitch tracking 2) Creating a PD with a shared_ptr. Please post two MVCEs separately, don't bundle them into one.

from q.

djowel avatar djowel commented on August 20, 2024

Updates:

  • I did some more tests up to 10000_Hz and I am having good results. I'll push my newer tests as soon as I refine the tests clean them up.
  • The maximum capture range is 4 octaves, not 5 as I initially said. Do not violate that. For example, if the max frequency is 10000 Hz (highest_freq), the min frequency (lowest_freq) should be 625 Hz.
  • If you need capture range higher than that, then this PD is not for you. This PD is designed to detect typical instruments with smaller capture ranges. For example, the guitar, for which this PD is heavily tested with, has a capture range of only 2 octaves per string (i.e. 24 frets).

I'm very eager to see your MVCEs!

from q.

djowel avatar djowel commented on August 20, 2024

I'm still very eager to see your MVCEs, but in the meantime, I pushed some refinements for handling higher frequencies and wider ranges. See if that works for you. The requirement of <= 4 octaves capture range still holds and is now checked and an exception is thrown if the precondition is not met.

Commit: c818171

@TheTechnobear , please tell me if you are still going to pursue the requested MVCEs. If not, then I'll have to close this issue.

from q.

djowel avatar djowel commented on August 20, 2024

@TheTechnobear , please tell me if you are still going to pursue the requested MVCEs. If not, then I'll have to close this issue.

I guess not... But feel free to reopen in case you do.

from q.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.