#include <SongDb.h>
公開方法(Public Methods) | |
TSongDb () | |
~TSongDb () | |
void | SetOption (int, char *language=NULL, int method=METHOD_LSDTW) |
bool | Read (TInputStream *, TInputStream *, bool _expand=true) |
從index檔和db檔讀取資料庫,如果已經讀取過了,則會附加在後面 | |
bool | Write (TOutputStream *, TOutputStream *) |
將所有歌曲資料寫入index檔和db檔 | |
bool | Write (TOutputStream *, TOutputStream *, int, int) |
將某些歌曲資料寫入index檔和db檔 | |
int | AddSong (TSongItem *) |
增加一首歌曲,只新增一個指標連結,並不會將歌曲複製一份 | |
void | DeleteSong (int) |
刪除一首歌曲 | |
void | DeleteSong (TSongItem *) |
刪除一首歌曲 | |
TSongItem * | GetSong (int) |
傳回某一首歌 | |
int | GetSongNumber (void) |
傳回資料庫中的歌曲數目 | |
void | Compare (int *, int) |
比對所有歌曲 | |
void | Compare (int *, int, int, int) |
比對所部份歌曲 | |
int | Compare (char *, char *, bool, bool *) |
找出某個欄位符合某個值的歌曲 | |
int | Compare (char *, int, int, bool *) |
找出某個欄位值符合某個長度的歌曲,若值當中有雙位元的字,會當成一個字 | |
TSongItem * | GetTopSong (int) |
傳回某一個名次的歌曲 | |
int | GetTopSongIndex (int) |
傳回某一個名次的歌曲索引 | |
void | StopCompare (void) |
停止比對 | |
int | GetCompareProgress (void) |
傳回比對進度,範圍從0到100 | |
保護方法(Protected Methods) | |
void | AllNoteToMid (void) |
將每首歌轉換成中介格式 | |
void | SortByScore (int, int) |
依分數排序歌曲 | |
保護屬性 | |
int | resampleRate |
int | compareMethod |
int | compareFrom |
char | compareLanguage [20] |
TSongItem ** | Song |
資料庫中的所有歌曲 | |
int | songNumber |
歌曲數目 | |
int | compareNum1 |
比對的歌曲數目之一 | |
int | compareNum2 |
比對的歌曲數目之二 | |
int | compareProgress1 |
int | compareProgress2 |
bool | expand |
bool | stopCompare |
比對是否被中斷 | |
int * | topSongIndex |
將歌曲依名次排序後的index |
TSongDb::TSongDb | ( | ) |
定義在 SongDb.cpp 檔案之第 135 行.
參考 COMPARE_FROM_ANYWHERE, compareProgress1, compareProgress2, resampleRate, SetOption(), Song, songNumber, 及 topSongIndex.
TSongDb::~TSongDb | ( | ) |
int TSongDb::AddSong | ( | TSongItem * | SongItem | ) |
增加一首歌曲,只新增一個指標連結,並不會將歌曲複製一份
SongItem | 為新增的歌 |
定義在 SongDb.cpp 檔案之第 290 行.
參考 Song, songNumber, 及 topSongIndex.
void TSongDb::AllNoteToMid | ( | void | ) | [protected] |
將每首歌轉換成中介格式
int TSongDb::Compare | ( | char * | fieldName, | |
int | size, | |||
int | operate, | |||
bool * | result | |||
) |
找出某個欄位值符合某個長度的歌曲,若值當中有雙位元的字,會當成一個字
fieldName | 為某一欄位的名稱 | |
size | 為期望值 | |
operate | 為-1, 0 或 1,代表小於、等於或大於 | |
result | 為傳出結果,true代表符合,false代表不符合 |
定義在 SongDb.cpp 檔案之第 808 行.
參考 Song, 及 songNumber.
int TSongDb::Compare | ( | char * | fieldName, | |
char * | value, | |||
bool | exactMatch, | |||
bool * | result | |||
) |
找出某個欄位符合某個值的歌曲
fieldName | 為某一欄位的名稱 | |
value | 為期望值 | |
exactMatch | 為字串是否要完全符合或部份符合 | |
result | 為傳出結果,true代表符合,false代表不符合 |
定義在 SongDb.cpp 檔案之第 756 行.
參考 TSongItem::Fields, Song, songNumber, strequal(), strnequal(), 及 TMyStringList::Values().
void TSongDb::Compare | ( | int * | waveMid, | |
int | waveSize, | |||
int | fromIndex, | |||
int | toIndex | |||
) |
比對所部份歌曲
第一階段用 linear scaling 的方法,第二階段用 dynamic time warping 的方法 根據method的設定不同而做不同的比對
waveMid | 為唱進來的中介格式 | |
waveSize | 為waveMid的長度 | |
fromIndex | 為比對的起始範圍 | |
toIndex | 為比對的結束範圍 |
定義在 SongDb.cpp 檔案之第 409 行.
參考 TSongItem::bestSegment, COMPARE_FROM_HEAD, COMPARE_FROM_REFRAIN, compareFrom, compareLanguage, compareMethod, compareNum1, compareNum2, compareProgress1, compareProgress2, CONSTA, CONSTB, dtw(), expand, TSongItem::Fields, TSongItem::FreeMid(), INFINITE_INT, insertArray(), INTEGER_SCALE, METHOD_DTW, METHOD_LINEAR_SCALING, METHOD_LSDTW, METHOD_NOTEBEGIN_DTW, TSongItem::mid, TSongItem::midRefrainIndex, TSongItem::midSize, min(), MIN_WARP_RATE, TSongItem::noteIndex, TSongItem::noteIndexSize, TSongItem::NoteToMid(), TSongItem::refrainIndexSize, resampleRate, TSongItem::score, shiftMid(), shiftMidToMeanZero(), Song, songNumber, SortByScore(), stopCompare, topSongIndex, TMyStringList::Values(), 及 WARP_NUM.
void TSongDb::Compare | ( | int * | waveMid, | |
int | waveSize | |||
) |
比對所有歌曲
waveMid | 為唱進來的中介格式 | |
waveSize | 為waveMid的長度 |
定義在 SongDb.cpp 檔案之第 386 行.
參考 songNumber.
被參考於 main().
void TSongDb::DeleteSong | ( | TSongItem * | SongItem | ) |
void TSongDb::DeleteSong | ( | int | index | ) |
刪除一首歌曲
index | 為刪除的歌的索引 |
定義在 SongDb.cpp 檔案之第 314 行.
參考 Song, songNumber, 及 topSongIndex.
被參考於 DeleteSong().
int TSongDb::GetCompareProgress | ( | void | ) |
傳回比對進度,範圍從0到100
定義在 SongDb.cpp 檔案之第 916 行.
參考 compareNum1, compareNum2, compareProgress1, 及 compareProgress2.
TSongItem * TSongDb::GetSong | ( | int | index | ) |
int TSongDb::GetSongNumber | ( | void | ) |
TSongItem * TSongDb::GetTopSong | ( | int | rank | ) |
傳回某一個名次的歌曲
rank | 為名次,範圍從0到比對的歌曲數-1,否則會傳回無法預期的topSongIndex |
定義在 SongDb.cpp 檔案之第 878 行.
參考 Song, 及 topSongIndex.
被參考於 main().
int TSongDb::GetTopSongIndex | ( | int | rank | ) |
傳回某一個名次的歌曲索引
rank | 為名次,範圍從0到比對的歌曲數-1,否則會傳回無法預期的topSongIndex |
定義在 SongDb.cpp 檔案之第 893 行.
參考 topSongIndex.
bool TSongDb::Read | ( | TInputStream * | IndexStream, | |
TInputStream * | DbStream, | |||
bool | _expand = true | |||
) |
從index檔和db檔讀取資料庫,如果已經讀取過了,則會附加在後面
cbmrmain.cpp呼叫時_expand是設false.
IndexStream | 為index檔 | |
DbStream | 為db檔 | |
_expand | 設定note是否展開成mid |
定義在 SongDb.cpp 檔案之第 185 行.
參考 TMyList::Add(), TMyList::count, expand, INTEGER_SCALE, TMyList::Items(), TSongItem::Read(), TDataInputStream::ReadLine(), resampleRate, TSongItem::SetProperty(), Song, songNumber, 及 topSongIndex.
被參考於 main().
void TSongDb::SetOption | ( | int | , | |
char * | language = NULL , |
|||
int | method = METHOD_LSDTW | |||
) |
void TSongDb::SortByScore | ( | int | sortNum, | |
int | topNum | |||
) | [protected] |
依分數排序歌曲
sortNum | 為要排序的歌曲數目 | |
topNum | 為只排序出前topNum名即可 |
定義在 SongDb.cpp 檔案之第 839 行.
參考 Song, 及 topSongIndex.
被參考於 Compare().
void TSongDb::StopCompare | ( | void | ) |
bool TSongDb::Write | ( | TOutputStream * | IndexStream, | |
TOutputStream * | DbStream, | |||
int | fromIndex, | |||
int | toIndex | |||
) |
將某些歌曲資料寫入index檔和db檔
IndexStream | 為index檔 | |
DbStream | 為db檔 | |
fromIndex | 代表從哪一首歌開始 | |
toIndex | 代表到哪一首歌為止 |
定義在 SongDb.cpp 檔案之第 265 行.
參考 Song, songNumber, 及 Write().
bool TSongDb::Write | ( | TOutputStream * | IndexStream, | |
TOutputStream * | DbStream | |||
) |
將所有歌曲資料寫入index檔和db檔
IndexStream | 為index檔 | |
DbStream | 為db檔 |
定義在 SongDb.cpp 檔案之第 244 行.
參考 songNumber.
被參考於 Write().
int TSongDb::compareFrom [protected] |
char TSongDb::compareLanguage[20] [protected] |
int TSongDb::compareMethod [protected] |
int TSongDb::compareNum1 [protected] |
int TSongDb::compareNum2 [protected] |
int TSongDb::compareProgress1 [protected] |
int TSongDb::compareProgress2 [protected] |
bool TSongDb::expand [protected] |
TSongItem** TSongDb::Song [protected] |
資料庫中的所有歌曲
被參考於 AddSong(), Compare(), DeleteSong(), GetSong(), GetTopSong(), Read(), SortByScore(), TSongDb(), Write(), 及 ~TSongDb().
int TSongDb::songNumber [protected] |
歌曲數目
被參考於 AddSong(), Compare(), DeleteSong(), GetSong(), GetSongNumber(), Read(), TSongDb(), Write(), 及 ~TSongDb().
bool TSongDb::stopCompare [protected] |
int* TSongDb::topSongIndex [protected] |
將歌曲依名次排序後的index
被參考於 AddSong(), Compare(), DeleteSong(), GetTopSong(), GetTopSongIndex(), Read(), SortByScore(), TSongDb(), 及 ~TSongDb().