00001 #ifndef _SONGDB_H_
00002 #define _SONGDB_H_
00003
00004 #include "SongItem.h"
00005 #include "InputStream.h"
00006 #include "OutputStream.h"
00007 #define INTEGER_SCALE 10 //因為用整數代替浮點數而乘上的倍數
00008
00009 enum {METHOD_LINEAR_SCALING, METHOD_DTW, METHOD_LSDTW, METHOD_NOTEBEGIN_DTW};
00010 enum {COMPARE_FROM_HEAD, COMPARE_FROM_ANYWHERE, COMPARE_FROM_REFRAIN};
00014 class TSongDb
00015 {
00016 protected:
00017 int resampleRate, compareMethod, compareFrom;
00018 char compareLanguage[20];
00019 TSongItem **Song;
00020 int songNumber;
00021 int compareNum1;
00022 int compareNum2;
00023 int compareProgress1;
00024 int compareProgress2;
00025 bool expand, stopCompare;
00026 int *topSongIndex;
00027
00028 void AllNoteToMid(void);
00029 void SortByScore(int, int);
00030 public:
00031 TSongDb();
00032 ~TSongDb();
00033 void SetOption(int, char *language = NULL, int method = METHOD_LSDTW);
00034 bool Read(TInputStream *, TInputStream *, bool _expand = true);
00035 bool Write(TOutputStream *, TOutputStream *);
00036 bool Write(TOutputStream *, TOutputStream *, int, int);
00037 int AddSong(TSongItem *);
00038 void DeleteSong(int);
00039 void DeleteSong(TSongItem *);
00040 TSongItem *GetSong(int);
00041 int GetSongNumber(void);
00042 void Compare(int *, int);
00043 void Compare(int *, int, int, int);
00044 int Compare(char *, char *, bool, bool *);
00045 int Compare(char *, int, int, bool *);
00046 TSongItem *GetTopSong(int);
00047 int GetTopSongIndex(int);
00048 void StopCompare(void);
00049 int GetCompareProgress(void);
00050 };
00051
00052 #endif
00053