forked from len0rd/rockbox
pitch_detector: add the key transposition feature which makes the plugin better usable with/for transposing instruments (FS#11752 by Robert Horn)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29052 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
37feed5287
commit
53db95417d
2 changed files with 45 additions and 4 deletions
|
|
@ -294,8 +294,19 @@ static struct tuner_settings
|
||||||
int freq_A; /* Index of the frequency of A */
|
int freq_A; /* Index of the frequency of A */
|
||||||
bool use_sharps;
|
bool use_sharps;
|
||||||
bool display_hz;
|
bool display_hz;
|
||||||
|
int key_transposition; /* Which note to display as 'C'. */
|
||||||
|
/* 0=C, 1=D-flat, 2=D, ..., 11=B. This is useful if you */
|
||||||
|
/* use a transposing instrument. In that case, this */
|
||||||
|
/* setting tells which 'real' note is played by the */
|
||||||
|
/* instrument if you play a written 'C'. Thus, this */
|
||||||
|
/* setting is the number of semitones from the real 'C' */
|
||||||
|
/* up to the 'instrument key'. */
|
||||||
} settings;
|
} settings;
|
||||||
|
|
||||||
|
/* By default, the real 'C' is displayed as 'C' */
|
||||||
|
#define DEFAULT_KEY_TRANSPOSITION 0
|
||||||
|
|
||||||
|
|
||||||
/*=================================================================*/
|
/*=================================================================*/
|
||||||
/* Settings loading and saving(adapted from the clock plugin) */
|
/* Settings loading and saving(adapted from the clock plugin) */
|
||||||
/*=================================================================*/
|
/*=================================================================*/
|
||||||
|
|
@ -326,6 +337,7 @@ static void tuner_settings_reset(void)
|
||||||
.freq_A = DEFAULT_FREQ_A,
|
.freq_A = DEFAULT_FREQ_A,
|
||||||
.use_sharps = true,
|
.use_sharps = true,
|
||||||
.display_hz = false,
|
.display_hz = false,
|
||||||
|
.key_transposition = DEFAULT_KEY_TRANSPOSITION,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -406,6 +418,22 @@ static const struct opt_items accidental_text[] =
|
||||||
{ "Sharp", -1 },
|
{ "Sharp", -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct opt_items transpose_text[] =
|
||||||
|
{
|
||||||
|
{ "C (Concert Pitch)", -1 },
|
||||||
|
{ "D-flat", -1 },
|
||||||
|
{ "D", -1 },
|
||||||
|
{ "E-flat", -1 },
|
||||||
|
{ "E", -1 },
|
||||||
|
{ "F", -1 },
|
||||||
|
{ "G-flat", -1 },
|
||||||
|
{ "G", -1 },
|
||||||
|
{ "A-flat", -1 },
|
||||||
|
{ "A", -1 },
|
||||||
|
{ "B-flat", -1 },
|
||||||
|
{ "B", -1 },
|
||||||
|
};
|
||||||
|
|
||||||
static void set_min_freq(int new_freq)
|
static void set_min_freq(int new_freq)
|
||||||
{
|
{
|
||||||
settings.sample_size = freq2period(new_freq) * 4;
|
settings.sample_size = freq2period(new_freq) * 4;
|
||||||
|
|
@ -442,6 +470,7 @@ static bool main_menu(void)
|
||||||
"Lowest Frequency",
|
"Lowest Frequency",
|
||||||
"Algorithm Pickiness",
|
"Algorithm Pickiness",
|
||||||
"Accidentals",
|
"Accidentals",
|
||||||
|
"Key Transposition",
|
||||||
"Display Frequency (Hz)",
|
"Display Frequency (Hz)",
|
||||||
"Frequency of A (Hz)",
|
"Frequency of A (Hz)",
|
||||||
"Reset Settings",
|
"Reset Settings",
|
||||||
|
|
@ -484,10 +513,15 @@ static bool main_menu(void)
|
||||||
BOOL, accidental_text, 2, NULL);
|
BOOL, accidental_text, 2, NULL);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
|
rb->set_option("Key Transposition",
|
||||||
|
&settings.key_transposition,
|
||||||
|
INT, transpose_text, 12, NULL);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
rb->set_bool("Display Frequency (Hz)",
|
rb->set_bool("Display Frequency (Hz)",
|
||||||
&settings.display_hz);
|
&settings.display_hz);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 8:
|
||||||
freq_val = freq_A[settings.freq_A].frequency;
|
freq_val = freq_A[settings.freq_A].frequency;
|
||||||
rb->set_int("Frequency of A (Hz)",
|
rb->set_int("Frequency of A (Hz)",
|
||||||
"Hz", UNIT_INT, &freq_val, NULL,
|
"Hz", UNIT_INT, &freq_val, NULL,
|
||||||
|
|
@ -495,13 +529,13 @@ static bool main_menu(void)
|
||||||
NULL);
|
NULL);
|
||||||
settings.freq_A = freq_val - freq_A[0].frequency;
|
settings.freq_A = freq_val - freq_A[0].frequency;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 9:
|
||||||
reset = false;
|
reset = false;
|
||||||
rb->set_bool("Reset Tuner Settings?", &reset);
|
rb->set_bool("Reset Tuner Settings?", &reset);
|
||||||
if (reset)
|
if (reset)
|
||||||
tuner_settings_reset();
|
tuner_settings_reset();
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 10:
|
||||||
exit_tuner = true;
|
exit_tuner = true;
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -703,7 +737,13 @@ static void display_frequency (fixed freq)
|
||||||
draw_bar(ldf); /* The red bar */
|
draw_bar(ldf); /* The red bar */
|
||||||
if(fp_round(freq) != 0)
|
if(fp_round(freq) != 0)
|
||||||
{
|
{
|
||||||
draw_note(notes[note].name);
|
/* Raise the displayed pitch an octave minus key_transposition */
|
||||||
|
/* semitones, effectively lowering it. Note that the pitch */
|
||||||
|
/* displayed alongside the frequency is unaffected. */
|
||||||
|
int transposition = 12 - settings.key_transposition;
|
||||||
|
|
||||||
|
draw_note(notes[(note + transposition) % 12].name);
|
||||||
|
|
||||||
if(settings.display_hz)
|
if(settings.display_hz)
|
||||||
{
|
{
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_DEPTH > 1
|
||||||
|
|
|
||||||
|
|
@ -579,6 +579,7 @@ Thomas Jarosch
|
||||||
Will Sowerbutts
|
Will Sowerbutts
|
||||||
Łukasz Stelmach
|
Łukasz Stelmach
|
||||||
Gabriel Maia
|
Gabriel Maia
|
||||||
|
Robert Horn
|
||||||
|
|
||||||
The libmad team
|
The libmad team
|
||||||
The wavpack team
|
The wavpack team
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue