oc 歌詞解析

2021-07-04 08:45:08 字數 3303 閱讀 6263

歌詞file:

[ti:傳奇]

[ar:王菲]

[00:03.50]傳奇

[00:19.10]作詞:劉兵 作曲:李健

[00:20.60]演唱:王菲

[00:26.60]

[04:40.75][02:39.90][00:36.25]只是因為在人群中多看了你一眼

[04:49.00]

[02:47.44][00:43.69]再也沒能忘掉你容顏

[02:54.83][00:51.24]夢想著偶然能有一天再相見

[03:02.32][00:58.75]從此我開始孤單思念

[03:08.15][01:04.30]

[03:09.35][01:05.50]想你時你在天邊

[03:16.90][01:13.13]想你時你在眼前

[03:24.42][01:20.92]想你時你在腦海

[03:31.85][01:28.44]想你時你在心田

[03:38.67][01:35.05]

[04:09.96][03:39.87][01:36.25]寧願相信我們前世有約

[04:16.37][03:46.38][01:42.47]今生的愛情故事 不會再改變

[04:24.82][03:54.83][01:51.18]寧願用這一生等你發現

[04:31.38][04:01.40][01:57.43]我一直在你身旁 從未走遠

[04:39.55][04:09.00][02:07.85]

首先分析一下這個歌詞,每句歌詞對應好幾個時間,每個時間不只是一秒的時間,而是一段時間。你有什麼思路呢?分割分割再分割,然後用字典鍵值對,根據時間輸出歌詞,額,這個方法是不是談麻煩了。

【**】

#import

@inte***ce lrceach : nsobject

@prooerty float seconds;

@property nsstring * lrceach;

@end

#import "lrceach.h"

@implementation lrceach

@end

#import

@inte***ce lrcmassage :nsobject

@property nsstring * ar;

@property nsstring * ti;

@property nsstring * al;

@property nsstring * by;

@property float offset;

@end

#import "lrcmassage.h"

@implementation lrcmassage

-(nsstring *)description

@end

@class lrcmassage;

@inte***ce lrcmanager : nsobject

@property (readonly) lrcmassage *message;

-(id)initwithfile:(nsstring *)path;

-(nsstring *)lrcintime:(float)time;

+(void)test;

@end

#import "lrcmanager.h"

#import "lrceach.h"

#import "lrcmassage.h"

//@inte***ce psblrcmanager () //

//@end

//匿名類別中宣告的成員變數和方法,不對外公開,只能被當前類的成員方法呼叫。

@implementation lrcmanager

- (id)initwithfile:(nsstring *)path

return self; }

//歌詞其實就是乙個lrc檔案,裡面存放了所有的歌詞 //

//類似於

//[ti:傳奇]

//[ar:王菲] //

//[00:03.50]傳奇

//[00:19.10]作詞:劉兵 作曲:李健

//[00:20.60]演唱:王菲

//[00:26.60]

//[04:40.75][02:39.90][00:36.25]只是因為在人群中多看了你一眼

//[04:49.00]

//解析相關路徑的檔案,將歌詞儲存到資料模型中,再將資料模型儲存到陣列中

- (void)paserlrcfile:(nsstring *)path

//讀取檔案,返回檔案內容

- (nsstring *)readfile:(nsstring *)path

//解析歌詞內容

- (void)paserlrcfilecontents:(nsstring *)contents

//判斷這一行是否以@"[0"開頭

if ([content hasprefix:@"[0"] == yes) else if([content hasprefix:@"["] == yes)  }

}//解析一句歌詞,存入資料模型

- (void)paserlrceach:(nsstring *)lrceach

} }

//解析曲目的資訊

- (void)paserlrcmessage:(nsstring *)message

else if([messagearray[1] isequaltostring:@"ti"])else if([messagearray[1] isequaltostring:@"al"])else if([messagearray[1] isequaltostring:@"by"])else if([messagearray[1] isequaltostring:@"offset"]) }

//給乙個時間字串,返回對應的秒數

- (float)sencondsfortime:(nsstring *)time

//陣列排序

- (void)sortarray

}  }

} - (nsstring *)lrcintime:(float)time

} return nil; }

#define path @"/users/pansongbiao/downloads/qfile-4.txt"

+ (void)test

}@end

#import

#import "lrcmanager.h"

int main(int argc, const char * argv)

return 0; }

krc歌詞檔案解析

做卡拉ok專案時,逐字歌詞同步需要很多高精度的lrc檔案,目前國內有2大家 擁有專利的kugou和沒有專利的qq 二者各推出了一種逐字同步歌詞檔案 krc和qrc。krc有加密處理,直接開啟的話只能看到亂碼。krc.h ioskrcdecoder created by zeng songgen on...

unity 解析歌詞文字

上面方法是使用陣列 下面是使用list 獲取lrc 檔案的,獲取到後 就可以用上面的隨便一種進行分割 根據時間對資料排列 public string sortlyricarrayandtimearray string lyrica float timea out float timearray ti...

用 python 解析歌詞

2.解析歌詞 musiclrc 00 03.50 傳奇 00 19.10 作詞 劉兵 作曲 李健 00 20.60 演唱 王菲 00 26.60 04 40.75 02 39.90 00 36.25 只是因為在人群中多看了你一眼 04 49.00 02 47.44 00 43.69 再也沒能忘掉你容...