This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#8768 - Instrument tuner plugin
Attached to Project:
Rockbox
Opened by Lechner Michael (smoking_gnu) - Thursday, 20 March 2008, 20:40 GMT+2
Opened by Lechner Michael (smoking_gnu) - Thursday, 20 March 2008, 20:40 GMT+2
|
DetailsThis plugin is an instrument tuner.
Currently, there's no real GUI, it just prints the note you're playing again and again until you press power. Here's the c file: |
This task depends upon
Should be more readable now; no functional changes.
Furthermore, it uses quite a lot of floating point arithmetics, which we aren't too fond of. But I think we can let that pass, since it's only a plugin.
Good work!
Identifiers
-----
We do not want mixed case identifiers.
Variables and function names should be all lower case.
Struct and enum names should be all lower case.
Preprocessor symbols and enum constants should be all upper case.
Another nitpick from CONTRIBUTING though,
"Keep lines below 80 columns length."
schmittTriggered=0;
:-)
Well, I added a little bar that shows how 'wrong' your pitch is.
I also corrected that guideline violation, and if I find another one, I'll simply give up ;)
If the played note is loud enough, the tuner is now quite usable.
I'd be very grateful if someone actually tried my plugin and tell me any bugs/suggestions...
Could anyone else with an player with a built-in mic try this for me?
The sample buffer should be 32-bit aligned BTW.
32-bit aligned would be a signed int, right?
Also, the reason for the plugin not working on sansas has to do with the fact that they cannot record with a 44,1K sample rate - I'm working on it.
print_int_xy(0,160,(int) *rb->rec_freq_sampr);
print_int_xy(0,200,(int) SAMPLE_RATE);
and both are reported as 22050 on the sansa e280 not 88200 as mentioned in the comments?
Does the actual tuning work too? Does the GUI display correctly on the sansa's screen?
@MikeS: The sample buffer is now 32-bit aligned -> int32_t.
The GUI does display correctly - and looks good
The GUI does display correctly - and looks good
If recording works, it should display "callback" every second or so. If not, recording does not work at all.
tc is always 0 hence freq is 0
If I exit pitch and go to recording, the mic is not responsive. If I then exit
recording and restart it, the mic responds.
This suggests something in the code is preventing the mc responding to input
There are some plugins that use recording, but they just use some functions and do not explain what they do exactly...
I know for sure that I'm doing several things wrong, but nobody actually helps me fixing those problems.
So until I get some more information, I'm afraid I can't help you.
It seems to be working on most targets, and I don't own a sansa to "reverse engineer" the recording api.
Thanks for testing it nevertheless!
rb->sound_set(SOUND_MIC_GAIN, 39);
rb->audio_set_recording_gain(39,39, AUDIO_GAIN_MIC);
Im not convinced that the sound_set()ine is actually doing anything. I think the gain
is being set by the audio_set_recording_gain()
recording now works although the pitch indication jumps around a bit. maybe some averaging would help.
I can't work on the plugin right now because cygwin doesn't work anymore and I can't get the toolchain installed on AndLinux.
The 'jumpiness' of the tuner is due to the fact that the Schmitt trigger algorithm only works reliably when the tone is quite loud.
So if you play a loud note, it shouldn't jump so much. I intend to fix that when I can compile again.
Detection doesn't work too well using built-in microphone though;
[either that or my guitar is way off-tune ;-) ]
I have removed rb->sound_set(SOUND_MIC_GAIN, 39);
gain is set at 39 instead of 100 as per as3514.c
rb->audio_set_recording_gain(39,39, AUDIO_GAIN_MIC);
I added some code in display_freq() that prevents the red bar set at -32 cents when freq=0 (no signal)
if ((int)freq == 0) /* prevents red bar at -32 cents when freq= 0*/
{ ldf = 0;
}