Rockboxで歌詞表示

Rockboxでは音楽の再生にあわせて歌詞を表示できる.といっても通常の再生画面では表示されない.プラグインとしての機能であるが.
以下のパッチを当てる.

FS#7432 - sncviewer - a plugin for viewing synchronised lyrics on player screen

http://www.rockbox.org/tracker/task/7432

さて,いくつか気になる点があったので,パッチを当てた後,apps/plugins/sncviewer.cを手直し.

  • 日本語表示
    • 314行目あたり
  • タイムタグのフォーマット[mm:ss:xx]への対応
    • 1051行目あたり
  • あまり関係ないけど,下の余白*1
    • 697行目あたり
  • FS#5697 — bmp resize patch(http://www.rockbox.org/tracker/task/5697)の影響
    • 1行目あたり
    • 660行目あたり

以下,差分ファイル

--- ./apps/plugins/sncviewer.c	2007-07-21 14:56:21.328125000 +0900
+++ ./apps/plugins/sncviewer.c	2007-07-21 15:04:38.453125000 +0900
@@ -1,3 +1,4 @@
+#include "recorder/bmp.h"
 #include "plugin.h"
 PLUGIN_HEADER
 
@@ -314,11 +315,11 @@
   const unsigned char* artist=entry->artist;
   const unsigned char* title=entry->title;
   int height=sysfont_height;
-  if(artist!=NULL && title!=NULL && *artist < 0x80 && *title < 0x80)
+  if(artist!=NULL && title!=NULL)
     rb->snprintf(buf,BUFFERSIZE,"%s/%s",title,artist);  
   else //id3 != ascii -> display filename
     buffer=rb->strrchr(entry->path,'/')+1; 
-  if(*buffer < 0x80){
+  if(false){
     lcd_setfont(FONT_SYSFIXED);       
   } 
   else{ //id3 and filename not ascii -> show filename and use ui_font
@@ -660,7 +661,11 @@
     rb->strcpy(foundc,".bmp");
     
     bool read_bmp_file(char* const file){//return true if the bmp cannot be found
-      return (bmp_size=rb->read_bmp_file(file, &bm, size, FORMAT_ANY))<0;
+      return (bmp_size=rb->read_bmp_file(file, &bm, size, FORMAT_ANY, 
+                             LCD_WIDTH, LCD_HEIGHT,
+                             BMP_RESIZE_INCREASE | BMP_RESIZE_DECREASE
+
+      ))<0;
     }
     if(read_bmp_file(path)){  // path/<filename>.bmp 
       foundc=rb->strrchr(path,'/')+1;  
@@ -697,7 +702,7 @@
 
 void peak_meter(void){
   int y=scroll_y0;
-  const int max_height=LCD_HEIGHT-y-sysfont_height-3;
+  const int max_height=LCD_HEIGHT-y-sysfont_height-3-32;
   const int width=((LCD_WIDTH-bmp_width)/5)<<1;
   int left_peak,right_peak;
 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
@@ -1051,7 +1056,7 @@
     int mm,ss,ms=0;
     (*buffer)++; //skip [ 
     tt2int(buffer,&mm,':'); 
-    tt2int(buffer,&ss,'.') ? tt2int(buffer,&ms,']'): tt2int(buffer,&ss,']');  
+    (tt2int(buffer,&ss,'.') || tt2int(buffer,&ss,':')) ? tt2int(buffer,&ms,']'): tt2int(buffer,&ss,']');
     //+1 ensure that time is > 0
     *time=mm*60000+ss*1000+(ms<100 ? ms*10 : ms) +1; //wrong if ms=0xx !!!  
   }

*1:個人的な好み