Skip to content

Commit

Permalink
fix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jhyume committed Mar 26, 2015
1 parent b7e71c5 commit fe8b7ee
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions bin/runall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
for file in ./cut_5s/*.wav ; do
# echo ${file}
./recog $file
done
7 changes: 4 additions & 3 deletions src/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ int ProcessBuildRes(const char *szResDir, const char *szResPath){
if (!(S_IFDIR &statbuf.st_mode)) // 判断下一级成员不是目录
{
strcpy(FileName, entry->d_name);
printf("%d: %s ",index , FileName); // 输出属性不是目录的成员
myhash.AddSongList(FileName);
char FilePath[80] = "";
strcat(FilePath, szResDir);
strcat(FilePath, FileName);
printf("%s\n",FilePath); // 输出属性不是目录的成员
/* printf("%s\n",FilePath); // 输出属性不是目录的成员 */
fingerprint.ExtractPair(FilePath, myhash, 0, (float)0.98, index, 0);
printf("%d: %s 建库成功.\n",index , FileName); // 输出属性不是目录的成员
fingerprint.UnInit();
index ++;
}
Expand All @@ -79,7 +79,8 @@ int
main( int argc, char **argv )
{
Initialize();
ProcessBuildRes("./samples/", "./database");
//ADD your own paths here!!!
ProcessBuildRes("YOUT_PATH_OF_MUSIC_FILES", "YOUR_PATH_OF_DATABASE_FILE");
unInitialize();
return 0;
}
3 changes: 2 additions & 1 deletion src/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ void THash::File2Hash(const char *filename){
fp = fopen(filename, "rb");
char *chp;
fread(&song_num, sizeof(size_t), 1, fp);
printf("Totally %zu songs.\n", song_num);
printf("------------\n");
printf("数据库中共有 %zu 首歌的特征数据.\n", song_num);
for (size_t i = 0; i<song_num; i++){
chp = song_list[i];
do{
Expand Down
10 changes: 6 additions & 4 deletions src/recog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ int ProcessSelelct(const char *szAudioPath, std::string &szResultString){
fingerprint.UnInit();
size_t offset;
size_t result = myhash.VoteResult(offset);
printf("The song is %s, the offset is %f s.\n", myhash.song_list[result], (float)(offset*(float)FRAME_HOP / 8000.0));
printf("识别结果:\n");
printf("歌名: %30s, 正在播放:第 %10f 秒.\n", myhash.song_list[result], (float)(offset*(float)FRAME_HOP / 8000.0));
printf("------------\n");
szResultString = myhash.song_list[result];

return 0;
}

Expand All @@ -64,8 +65,9 @@ main( int argc, char **argv )
printf("Wrong Usage, please use './recog filename'\n");
return 1;
}
Initialize("./database");
printf("Initialize done.\n");
//ADD your database path here!!!
Initialize("YOUR_DATABASE_PATH");
/* printf("读文件,重建数据库. done.\n"); */
/* printf("Audio path is :%s\n",argv[1]); */
ProcessSelelct(argv[1],resultString);
unInitialize();
Expand Down
1 change: 0 additions & 1 deletion src/wav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
TWav::TWav(const char *filename){
fp = fopen(filename, "rb");
assert(fp != NULL);

fread(wav_info.riff_id, 1, 4, fp);
wav_info.riff_id[4] = '\0';
fread(&wav_info.size0, 4, 1, fp);
Expand Down

0 comments on commit fe8b7ee

Please sign in to comment.