f2e-spec icon indicating copy to clipboard operation
f2e-spec copied to clipboard

Pitchdetector2 - further tuning

Open Tronic opened this issue 5 years ago • 51 comments

This is an experimental branch that does more than #540 which itself can better be compared with the master branch. The changes in this one seem to greatly reduce the number of extra tones detected and shown on practice screen. More testing is still needed.

If all is good, I expect to merge these changes back to pitchdetector, which maintains cleaner history (mesonbuild is merged to this so that I could hack it).

Tronic avatar Apr 19 '20 12:04 Tronic

Also... this is just a question/suggestion, since you're going elbow-deep into pitch processing, how do you think about adding a "Difficulty" setting like Ultrastar does? Is it easily doable?

Lord-Kamina avatar Apr 19 '20 17:04 Lord-Kamina

Scoring and thus difficulty settings would be handled in an entirely different part than the pitch detector (I gather that might be in player.cc but you'll need to look it up). The idea has been discussed before, and there is not much use for less strict scoring because Performous already gives gradually less score with less accuracy (it is not on/off like in singstar). Not having difficulty levels keeps scores comparable, too.

Tronic avatar Apr 19 '20 17:04 Tronic

Scoring and thus difficulty settings would be handled in an entirely different part than the pitch detector (I gather that might be in player.cc but you'll need to look it up). The idea has been discussed before, and there is not much use for less strict scoring because Performous already gives gradually less score with less accuracy (it is not on/off like in singstar). Not having difficulty levels keeps scores comparable, too.

I thought maybe it could go in here so long as it is using a less strict comparison of notes expected and sung (then again, perhaps that logic IS elsewhere)

Lord-Kamina avatar Apr 19 '20 17:04 Lord-Kamina

Analyzer only gives out detected frequencies in Hz, it doesn't know about notes.

Tronic avatar Apr 20 '20 07:04 Tronic

Analyzer only gives out detected frequencies in Hz, it doesn't know about notes.

Ah ok. So they get converted to notes/tones elsewhere?

Lord-Kamina avatar Apr 20 '20 11:04 Lord-Kamina

Now it works much better than the old one. Clear and uberprecise detection in practice, and seems to be working in singing too. During testing I got one segfault but couldn't determine if it was caused by this patch or not.

Tronic avatar Apr 20 '20 13:04 Tronic

@Lord-Kamina See Notes::powerFactor that's the essence of vocal scoring. MusicalScale for conversions between Hz and note numbers. Player::update for the main vocal grading loop.

Tronic avatar Apr 20 '20 15:04 Tronic

Now it works much better than the old one. Clear and uberprecise detection in practice, and seems to be working in singing too. During testing I got one segfault but couldn't determine if it was caused by this patch or not.

Cool. Maybe post a trace or dump if you have it to see of we can figure it out?

Lord-Kamina avatar Apr 20 '20 16:04 Lord-Kamina

I didn't get a dump and couldn't get it to crash again.

Tronic avatar Apr 20 '20 16:04 Tronic

Oh, well. Was it during singing or in practice mode or what?

Lord-Kamina avatar Apr 20 '20 17:04 Lord-Kamina

This is still a work in progress. I'm developing the algorithm in Python, and what you see here is a port to C++ (curiously, the Python version runs faster). There are further developments done and more planned, that I plan to add here once complete. Unfortunately I'm still stuck to testing mostly without real microphone input, so any feedback from your experiments is more than welcome.

Tronic avatar Apr 26 '20 11:04 Tronic

Converted to draft according to latest comment: "This is still a work in progress"

Baklap4 avatar Jul 04 '21 15:07 Baklap4

It might take a very long time until I can pick this up again. If you don't mind keeping around a draft, feel free to keep it here. Possibly some feedback of the other Pitchdetector PR inspires me to complete this work still this Summer.

Tronic avatar Jul 04 '21 18:07 Tronic

This is also available for testing. IMO this has clearly better performance than either master or pitchdetector1 but YMMV because the algorithm is largely redesigned.

If there is agreement that this algorithm works well, I suggest merging this instead of pitchdetector1. If further development on this is needed, then pitchdetector1 should probably be merged meanwhile.

Tronic avatar Sep 01 '21 00:09 Tronic

@Tronic this includes/is built on top of the changes from #540 right?

If that's the case @ooshlablu should test this instead and #540 can be closed

Baklap4 avatar Sep 01 '21 06:09 Baklap4

@Baklap4 Yes, this is intended to supersede the other PR. The new phase equation is included and levels are tuned in this as well. Also, if the other PR is merged, there will be a merge conflict with this, so in that regard it might be nice to close the other one and only merge this.

The problem is that this changes a lot more, while the other one was intended to be merged without much testing due to it being a very minimal change with little expected adverse effects. I suggest several developers do thorough testing in noisy and quiet environments and with different singers before merging this.

In particular, high-pitched (female) voice needs to be tested. And since whistling is supported as a new feature, one might try that as well (be sure not to blow on your mic but beside it).

Tronic avatar Sep 01 '21 08:09 Tronic

And since whistling is supported as a new feature

"Always look on the bright side of life - Monty python" is a great song for whistling ;)

Baklap4 avatar Sep 01 '21 08:09 Baklap4

I'll test #540 anyway since I already built the package and it seems like it's easier to test by myself.

I will do a test of this myself at some point today and see if i can get a proper group to fully test this PR over the weekend. Finding someone that can actually whistle to a song might be difficult tho :-)

ooshlablu avatar Sep 01 '21 11:09 ooshlablu

someone that can actually whistle to a song

It was surprisingly easy to hit the notes on Hard difficulty. The pitch wave looks different too.

Tronic avatar Sep 01 '21 11:09 Tronic

EDIT: Forgot to mention that I only tested on Ubuntu 20.04

For me, this is really choppy and appears to be not picking up the pitch compared to how #540 and current master is.

I tried with 2 different mics on Behringer USB interface, trying different volume levels, and a straight USB mic, and had results that look like this: Screenshot from 2021-09-01 20-51-45 Screenshot from 2021-09-01 20-51-50

I couldn't find where to tune in the settings, and the results are similar on all the difficulty levels, just thinner lines :)

If I had to pick between #540 and this, I would pick that to merge for now. Let me know what I can do to get you any info you need to help.

ooshlablu avatar Sep 02 '21 01:09 ooshlablu

The pitch waves show high frequency, suggesting that something other than your singing (base frequency) is being detected. Could you check in practice screen visually which notes appear? Also check your volume level, should be around -20 dB while singing. If much louder, it probably cannot work, and more silent should produce no notes.

If your CPU is really show or you are on a non-optimised debug build, there could also be performance issues. I think the new algorithm is heavier than the old one but still it runs fine on my 2015 Macbook Pro with four mics, so I doubt this would have effect on any modern PC.

Tronic avatar Sep 02 '21 08:09 Tronic

@Tronic I see what you are saying now. If I play with the output volume from Performous very low/off it seems more stable and less jumpy overall when singing along with a song. This does have major interference with the way I play tho, which is with a group rock-band style with 1 mic and guitar controllers, rowdy,and hence high volumes through high-powered, and very responsive speakers :-).

At the moment, I can't get this to work with any sort of outside noise. I've tried adjusting the USB mic volume in pulse audio, which I don't think has any effect since this uses SDL to interface devices directly (I could be wrong, but that's how it seems to me when messing with volumes), and I also have tried turning down the input gain from the mic through the Behringer interface. At very low gain through the Behringer, things do seem to smooth out, but there are "blanks" and other chops that are definitely the result of low sensitivity at such low volumes.

@Baklap4 I think for now #540 is the better candidate that does make a difference in terms of scoring and actual game play if this is something that should make it into a new release. I think we should mark the PRs appropriately.

ooshlablu avatar Sep 05 '21 03:09 ooshlablu

Alright so #540 within Release 1.2.0 and #541 in an upcoming release?

Baklap4 avatar Sep 06 '21 10:09 Baklap4

Yeah, I believe that should be the path for now

ooshlablu avatar Sep 07 '21 12:09 ooshlablu

@ooshlablu I think you need to adjust mic volume in alsamixer, switch to capture volumes on the physical device of the mic(s). If your device supports that.

Could you confirm which dB value you see in practice screen while singing? Does it ever reach the top (0 dB)?

Tronic avatar Sep 07 '21 20:09 Tronic

1.2.0 is released a month ago. This was expected to be merged after this. Can we get this PR up-to-date and test it? @ooshlablu

Baklap4 avatar Apr 25 '22 09:04 Baklap4

@Tronic if you could look at the conflicts, the packages will build and get attached to this PR now. I can install it and test it again and see how it looks now.

ooshlablu avatar Apr 25 '22 12:04 ooshlablu

Hmmh, that's some pretty nasty conflicts. I'll see if I can get this compiled and running with actual mics, to be able to merge with meaningful dB limits.

Tronic avatar Apr 25 '22 13:04 Tronic

As an update, I am missing some cables needed for my karaoke setup, and thus will only be able to test this with Macbook internal mic. I suggest others also do some testing and possibly fiddling with the values but I'll try to get to my tests in the coming days too.

Tronic avatar May 17 '22 14:05 Tronic

If there may be problems with the new pitch detection why not make it configurable?

twollgam avatar Jun 29 '22 17:06 twollgam