1
0
Fork 0
forked from len0rd/rockbox

Metronome patch by Martin Scarratt: BPM entry acceleration and proper stopping of playback on iriver

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8348 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2006-01-14 02:39:30 +00:00
parent bae4e2acdd
commit c7c9069ed4

View file

@ -99,6 +99,8 @@ static int tap_count = 0;
static int tap_time = 0; static int tap_time = 0;
static int tap_timeout = 0; static int tap_timeout = 0;
int bpm_step_counter = 0;
void led(bool on) void led(bool on)
{ {
#if CONFIG_CPU == SH7034 #if CONFIG_CPU == SH7034
@ -189,7 +191,7 @@ void play_tock(void){
#else #else
#define MET_IS_PLAYING rb->pcm_is_playing() #define MET_IS_PLAYING rb->pcm_is_playing()
#define MET_PLAY_STOP rb->pcm_play_stop() #define MET_PLAY_STOP rb->audio_stop()
static signed short sound[] = { static signed short sound[] = {
1, -1, 1, -1, 0, 0, 0, 1, -1, 0, 0, 1, -1, 1, -1, 0, 0, 0, 1, -1, 0, 0,
@ -829,6 +831,24 @@ void change_volume(int delta){
} }
} }
/*function to accelerate bpm change*/
void change_bpm(int direction){
if((bpm_step_counter < 20)
|| (bpm > 389)
|| (bpm < 10))
bpm = bpm + direction;
else if (bpm_step_counter < 60)
bpm = bpm + direction * 2;
else
bpm = bpm + direction * 9;
if (bpm > 400) bpm = 400;
if (bpm < 1) bpm = 1;
calc_period();
draw_display();
bpm_step_counter++;
}
void timer_callback(void) void timer_callback(void)
{ {
if(minitick >= period){ if(minitick >= period){
@ -892,8 +912,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
rb = api; rb = api;
if (MET_IS_PLAYING) if (MET_IS_PLAYING)
MET_PLAY_STOP; // stop audio ISR MET_PLAY_STOP; // stop audio IS
#if CONFIG_CODEC != SWCODEC #if CONFIG_CODEC != SWCODEC
rb->bitswap(sound, sizeof(sound)); rb->bitswap(sound, sizeof(sound));
#else #else
@ -1005,31 +1025,15 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
break; break;
case BUTTON_LEFT: case BUTTON_LEFT:
if (bpm > 1) bpm_step_counter = 0;
bpm--;
calc_period();
draw_display();
break;
case BUTTON_LEFT | BUTTON_REPEAT: case BUTTON_LEFT | BUTTON_REPEAT:
if (bpm > 10) change_bpm(-1);
bpm=bpm-10;
calc_period();
draw_display();
break; break;
case BUTTON_RIGHT: case BUTTON_RIGHT:
if(bpm < 400) bpm_step_counter = 0;
bpm++;
calc_period();
draw_display();
break;
case BUTTON_RIGHT | BUTTON_REPEAT: case BUTTON_RIGHT | BUTTON_REPEAT:
if (bpm < 400) change_bpm(1);
bpm=bpm+10;
calc_period();
draw_display();
break; break;
#if CONFIG_KEYPAD != ONDIO_PAD #if CONFIG_KEYPAD != ONDIO_PAD