Better pitch handling.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6503 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8f1ace7525
commit
b9ebe6af0a
3 changed files with 32 additions and 31 deletions
|
@ -389,7 +389,7 @@ int charging_screen(void)
|
|||
int pitch_screen(void)
|
||||
{
|
||||
int button;
|
||||
static int pitch = 1000;
|
||||
int pitch = sound_get_pitch();
|
||||
bool exit = false;
|
||||
bool used = false;
|
||||
|
||||
|
@ -436,9 +436,8 @@ int pitch_screen(void)
|
|||
case BUTTON_ON | BUTTON_UP:
|
||||
case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT:
|
||||
used = true;
|
||||
pitch++;
|
||||
if ( pitch > 2000 )
|
||||
pitch = 2000;
|
||||
if ( pitch < 2000 )
|
||||
pitch++;
|
||||
sound_set_pitch(pitch);
|
||||
break;
|
||||
|
||||
|
@ -446,9 +445,8 @@ int pitch_screen(void)
|
|||
case BUTTON_ON | BUTTON_DOWN:
|
||||
case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT:
|
||||
used = true;
|
||||
pitch--;
|
||||
if ( pitch < 500 )
|
||||
pitch = 500;
|
||||
if ( pitch > 500 )
|
||||
pitch--;
|
||||
sound_set_pitch(pitch);
|
||||
break;
|
||||
|
||||
|
@ -468,33 +466,21 @@ int pitch_screen(void)
|
|||
break;
|
||||
|
||||
case BUTTON_ON | BUTTON_RIGHT:
|
||||
case BUTTON_LEFT | BUTTON_REL:
|
||||
if ( pitch < 2000 ) {
|
||||
pitch += 20;
|
||||
sound_set_pitch(pitch);
|
||||
}
|
||||
break;
|
||||
|
||||
case BUTTON_RIGHT | BUTTON_REL:
|
||||
if ( pitch > 500 ) {
|
||||
pitch -= 20;
|
||||
sound_set_pitch(pitch);
|
||||
}
|
||||
break;
|
||||
|
||||
case BUTTON_ON | BUTTON_LEFT:
|
||||
case BUTTON_RIGHT | BUTTON_REL:
|
||||
if ( pitch > 500 ) {
|
||||
pitch -= 20;
|
||||
sound_set_pitch(pitch);
|
||||
}
|
||||
break;
|
||||
|
||||
case BUTTON_LEFT | BUTTON_REL:
|
||||
if ( pitch < 2000 ) {
|
||||
pitch += 20;
|
||||
sound_set_pitch(pitch);
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef SIMULATOR
|
||||
case BUTTON_ON:
|
||||
#else
|
||||
|
|
|
@ -55,7 +55,8 @@ const char *sound_unit(int setting);
|
|||
int sound_numdecimals(int setting);
|
||||
int sound_steps(int setting);
|
||||
#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) || defined(SIMULATOR)
|
||||
void sound_set_pitch(int percent);
|
||||
void sound_set_pitch(int permille);
|
||||
int sound_get_pitch(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -602,27 +602,41 @@ int sound_val2phys(int setting, int value)
|
|||
|
||||
The pitch value is in tenths of percent.
|
||||
*/
|
||||
static int last_pitch = 1000;
|
||||
|
||||
void sound_set_pitch(int pitch)
|
||||
{
|
||||
unsigned long val;
|
||||
|
||||
/* invert pitch value */
|
||||
pitch = 1000000/pitch;
|
||||
|
||||
/* Calculate the new (bogus) frequency */
|
||||
val = 18432*pitch/1000;
|
||||
if (pitch != last_pitch)
|
||||
{
|
||||
/* Calculate the new (bogus) frequency */
|
||||
val = 18432 * 1000 / pitch;
|
||||
|
||||
mas_writemem(MAS_BANK_D0, MAS_D0_OFREQ_CONTROL, &val, 1);
|
||||
mas_writemem(MAS_BANK_D0, MAS_D0_OFREQ_CONTROL, &val, 1);
|
||||
|
||||
/* We must tell the MAS that the frequency has changed.
|
||||
This will unfortunately cause a short silence. */
|
||||
mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
|
||||
/* We must tell the MAS that the frequency has changed.
|
||||
* This will unfortunately cause a short silence. */
|
||||
mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
|
||||
|
||||
last_pitch = pitch;
|
||||
}
|
||||
}
|
||||
|
||||
int sound_get_pitch(void)
|
||||
{
|
||||
return last_pitch;
|
||||
}
|
||||
#elif defined SIMULATOR
|
||||
void sound_set_pitch(int pitch)
|
||||
{
|
||||
(void)pitch;
|
||||
}
|
||||
|
||||
int sound_get_pitch(void)
|
||||
{
|
||||
return 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_HWCODEC == MASNONE
|
||||
|
|
Loading…
Reference in a new issue