#include <SongItem.h>
公開方法(Public Methods) | |
TSongItem () | |
~TSongItem () | |
void | SetProperty (char *) |
功能:設定並讀取stat和noteSize等資訊 | |
bool | Read (TInputStream *, int) |
從index檔讀取欄位,TSongDbLoad會呼叫此函式 | |
void | Write (TOutputStream *, TOutputStream *) |
將這首歌寫進index和db檔,TSongDbSave會呼叫此函式 | |
void | NoteToMid (int, int) |
將note轉換成中介格式 | |
void | FreeMid (void) |
將中介格式釋放掉,為了節省記憶體 | |
void | FreeRefrain (void) |
將複歌索引釋放掉 | |
void | Ready (int) |
當note遭修改時,必須呼叫此函式,否則無法哼唱搜尋 | |
公開屬性 | |
TMyStringList * | Fields |
index檔中所有的文字欄位 | |
int | start |
在db檔中的開始位置 | |
unsigned char * | note |
從db檔中讀進來的資料 | |
int | noteSize |
在db檔中的資料長度 | |
int * | mid |
從note轉換過來的中介格式 | |
int | midSize |
中介格式的長度 | |
float | score |
分數 | |
int * | noteIndex |
每個音符起點在mid中的索引 | |
int | noteIndexSize |
noteIndex陣列長度 | |
int | bestSegment |
第一階段比對後,記下最有可能是使用者唱的片段,用來做第二階段的比對 | |
int * | refrainIndex |
複歌起點在note中的索引 | |
int | refrainIndexSize |
複歌起點的個數 | |
int * | midRefrainIndex |
複歌起點在mid中的索引 |
定義在 SongItem.h 檔案之第 15 行.
TSongItem::TSongItem | ( | ) |
定義在 SongItem.cpp 檔案之第 14 行.
參考 Fields, mid, midRefrainIndex, midSize, note, noteIndex, noteIndexSize, noteSize, refrainIndex, refrainIndexSize, score, 及 start.
TSongItem::~TSongItem | ( | ) |
void TSongItem::FreeMid | ( | void | ) |
void TSongItem::FreeRefrain | ( | void | ) |
將複歌索引釋放掉
定義在 SongItem.cpp 檔案之第 260 行.
參考 midRefrainIndex, refrainIndex, 及 refrainIndexSize.
被參考於 ~TSongItem().
void TSongItem::NoteToMid | ( | int | resampleRate, | |
int | scale | |||
) |
將note轉換成中介格式
note中的時間單位是1/64秒,轉換後的單位是resampleRate/64秒 resampleRate目前設為4,所以是1/16秒
resampleRate | 目前設為4 | |
scale | 放大倍率,目前scale=INTEGER_SCALE=10,因為用整數代替浮點數而乘上的倍數 |
定義在 SongItem.cpp 檔案之第 202 行.
參考 mid, midSize, note, noteIndex, 及 noteIndexSize.
被參考於 TSongDb::Compare().
bool TSongItem::Read | ( | TInputStream * | DbStream, | |
int | resampleRate | |||
) |
從index檔讀取欄位,TSongDbLoad會呼叫此函式
從db檔中讀取資料,放進note欄位 note中的時間單位是1/64秒,轉換後的單位是resampleRate/64秒 resampleRate目前設為4,所以是1/16秒,以[音高音長音高音長...]排列, 一首歌完結後寫入0xFF
DbStream | 為db檔 | |
resampleRate | 目前設為4 |
定義在 SongItem.cpp 檔案之第 129 行.
參考 note, noteSize, TInputStream::Read(), TInputStream::Reads(), Ready(), TInputStream::Reset(), TInputStream::Skip(), 及 start.
被參考於 TSongDb::Read().
void TSongItem::Ready | ( | int | ) |
當note遭修改時,必須呼叫此函式,否則無法哼唱搜尋
定義在 SongItem.cpp 檔案之第 275 行.
參考 midRefrainIndex, midSize, note, noteIndexSize, noteSize, refrainIndex, refrainIndexSize, 及 SEGMENT_SIZE.
被參考於 Read().
void TSongItem::SetProperty | ( | char * | line | ) |
功能:設定並讀取stat和noteSize等資訊
對txt檔案裡的每一行做處理,一行即為一首歌的各個資訊,如: midiName=天涯.mid songName=天涯 singer=任賢齊 language=Chinese start=0 size=424 每個欄位之間用tab做分隔
line | line為index檔中的一行字串 |
定義在 SongItem.cpp 檔案之第 52 行.
參考 TMyStringList::Add(), Fields, noteSize, refrainIndex, refrainIndexSize, 及 start.
被參考於 TSongDb::Read().
void TSongItem::Write | ( | TOutputStream * | IndexStream, | |
TOutputStream * | DbStream | |||
) |
將這首歌寫進index和db檔,TSongDbSave會呼叫此函式
將一首歌寫進index和db檔
IndexStream | 為index檔 | |
DbStream | 為db檔 |
定義在 SongItem.cpp 檔案之第 158 行.
參考 TMyList::count, Fields, note, noteSize, refrainIndex, refrainIndexSize, TOutputStream::Size(), start, TMyStringList::Strings(), TOutputStream::Write(), 及 TOutputStream::Writes().
index檔中所有的文字欄位
定義在 SongItem.h 檔案之第 18 行.
被參考於 TSongDb::Compare(), main(), SetProperty(), TSongItem(), Write(), 及 ~TSongItem().
int* TSongItem::mid |
從note轉換過來的中介格式
定義在 SongItem.h 檔案之第 22 行.
被參考於 TSongDb::Compare(), FreeMid(), NoteToMid(), 及 TSongItem().
複歌起點在mid中的索引
定義在 SongItem.h 檔案之第 30 行.
被參考於 TSongDb::Compare(), FreeRefrain(), Ready(), 及 TSongItem().
unsigned char* TSongItem::note |
從db檔中讀進來的資料
定義在 SongItem.h 檔案之第 20 行.
被參考於 NoteToMid(), Read(), Ready(), TSongItem(), Write(), 及 ~TSongItem().
int* TSongItem::noteIndex |
每個音符起點在mid中的索引
定義在 SongItem.h 檔案之第 25 行.
被參考於 TSongDb::Compare(), FreeMid(), NoteToMid(), 及 TSongItem().
noteIndex陣列長度
定義在 SongItem.h 檔案之第 26 行.
被參考於 TSongDb::Compare(), NoteToMid(), Ready(), 及 TSongItem().
複歌起點在note中的索引
定義在 SongItem.h 檔案之第 28 行.
被參考於 FreeRefrain(), Ready(), SetProperty(), TSongItem(), 及 Write().
複歌起點的個數
定義在 SongItem.h 檔案之第 29 行.
被參考於 TSongDb::Compare(), FreeRefrain(), Ready(), SetProperty(), TSongItem(), 及 Write().
float TSongItem::score |
int TSongItem::start |