Compare commits

...

2 Commits

18 changed files with 115 additions and 39 deletions

31
lyric_analysis/Makefile Normal file
View File

@ -0,0 +1,31 @@
# 定义路径变量
SRC_DIR = srcs
OBJ_DIR = objs
BIN_DIR = ./
# 定义编译器
CC = gcc
# 定义目标文件
TARGET = $(BIN_DIR)/debug
# 定义源文件
SRCS = $(wildcard $(SRC_DIR)/*.c)
# OBJS = $(OBJ_DIR)/lrc.o $(OBJ_DIR)/console.o $(OBJ_DIR)/start_mplayer.o $(OBJ_DIR)/time_delay.o $(OBJ_DIR)/main.o
OBJS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRCS))
# 编译规则
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) -c $< -o $@
# 链接规则
$(TARGET): $(OBJS)
$(CC) $^ -o $@
# 默认构建目标
all: $(TARGET)
# 清理规则
clean:
rm -rf $(OBJ_DIR)/*.o $(TARGET)
# 伪目标
.PHONY: all clean

Binary file not shown.

View File

View File

@ -0,0 +1,30 @@
[ti:简单爱]
[ar:周杰伦]
[al:范特西]
[by:大脸猫]
[00:04.41]周杰伦 Chow, Jay Jou
[00:10.56]简单爱(台视Star blue蓝星主题曲)
[00:18.48]词:徐若瑄 曲:周杰伦
[00:26.44]说不上为什么 我变得很主动
[00:31.37]若爱上一个人 什么都会值得去做
[02:04.94][00:36.09]我想大声宣布 对你依依不舍
[02:09.97][00:41.26]连隔壁邻居都猜到我现在的感受
[02:14.94][00:46.17]河边的风 在吹着头发 飘动
[02:19.80][00:51.25]牵着你的手 一阵莫名感动
[02:24.61][00:55.86]我想带你 回我的外婆家
[02:28.32][00:59.79]一起看着日落 一直到我们都睡着
[03:34.64][02:34.71][01:05.83]我想就这样牵着你的手不放开
[03:39.68][02:39.34][01:10.71]爱能不能够永远单纯没有悲哀
[03:44.27][02:43.90][01:15.44]我想 带你骑单车
[03:46.74][02:46.60][01:18.05]我想 和你看棒球
[03:49.77][02:49.58][01:20.71]想这样没担忧
[03:51.61][02:51.59][01:22.69]唱着歌 一直走☆
[03:54.38][02:54.35][01:25.57]我想就这样牵着你的手不放开
[03:59.19][02:59.01][01:30.41]爱可不可以简简单单没有伤害
[04:03.77][03:03.73][01:35.04]你 靠着我的肩膀
[04:06.33][03:06.26][01:37.49]你 在我胸口睡着
[04:09.13][03:09.34][01:40.57]像这样的生活
[04:11.36][03:11.26][01:42.66]我爱你 你爱我★
[03:13.76][01:44.97]想~~~ 简!简!单!单! 爱~~~
[03:23.61][01:54.30]想~~~ 简!简!单!单! 爱~~~

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

0
lyric_analysis/songs/简单爱.mp3 Executable file → Normal file
View File

View File

@ -1,19 +0,0 @@
# SRC_DIR := ./srcs
OBJ_DIR := ../objs
BIN_DIR := ../bin
CC = gcc
TARGET = $(BIN_DIR)/main
# SRC = $(SRC_DIR)/lrc.c $(SRC_DIR)/console.c $(SRC_DIR)/start_mplayer.c $(SRC_DIR)/main.c
OBJ = $(OBJ_DIR)/lrc.o $(OBJ_DIR)/console.o $(OBJ_DIR)/start_mplayer.o $(OBJ_DIR)/main.o
# $(OBJ_DIR)/%.o: %.c
# $(CC) -c $< -o $@
$(OBJ_DIR)/%.o: %.c
$(CC) -c $< -o $@
$(TARGET): $(OBJ)
$(CC) $^ -o $@
clean:
rm -rf $(OBJ_DIR)/*.o $(TARGET)

0
lyric_analysis/srcs/console.c Executable file → Normal file
View File

0
lyric_analysis/srcs/includes/console.h Executable file → Normal file
View File

View File

@ -5,6 +5,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
typedef struct lrc
{
int time; // 歌词时间点
char lrc_buf[200]; // 歌词内容
int lrc_cur_num; // 当前歌词行数, 用于标记当前歌词(第几句歌词 从1开始)
struct lrc *next; // 指向下一行歌词(指向链表下一个节点)
} LRC;
FILE *open_lrc_file(const char *lrc_path); // 打开歌词文件 FILE *open_lrc_file(const char *lrc_path); // 打开歌词文件
long get_lrc_size(FILE *fp); // 获取歌词文件大小 long get_lrc_size(FILE *fp); // 获取歌词文件大小

0
lyric_analysis/srcs/includes/start_mplayer.h Executable file → Normal file
View File

View File

@ -0,0 +1,7 @@
#ifndef __TIME_DELAY_H__
#define __TIME_DELAY_H__
// 自封装延时函数
void time_delay(int sec);
#endif

View File

@ -1,12 +1,13 @@
#include "./includes/lrc.h" #include "./includes/lrc.h"
#include "./includes/console.h" #include "./includes/console.h"
#include "./includes/start_mplayer.h" #include "./includes/start_mplayer.h"
#include "includes/time_delay.h"
int main() int main()
{ {
// 定义歌曲和歌词文件路径 // 定义歌曲和歌词文件路径
const char *song_path = "../songs/简单爱.mp3"; const char *song_path = "./songs/简单爱.mp3";
const char *lrc_path = "../lrc/简单爱.lrc"; const char *lrc_path = "./lrcs/简单爱.lrc";
FILE *fp = open_lrc_file(lrc_path); // 打开歌词文件 FILE *fp = open_lrc_file(lrc_path); // 打开歌词文件
if (NULL == fp) if (NULL == fp)
@ -27,5 +28,26 @@ int main()
return -1; // 为歌词数据分配内存失败,退出程序 return -1; // 为歌词数据分配内存失败,退出程序
} }
// 读入歌词内容
fread(lrc_mem_data, lrc_size, 1, fp); // 读入歌词数据
// printf("%s", lrc_mem_data);
// FILE *fwx = fopen("../lrc/简单爱copy.lrc", "w");
// fwrite(lrc_mem_data, lrc_size, 1, fwx);
// 逐行解析歌词
char *line = strtok(lrc_mem_data, "\r\n"); // 逐行解析歌词
int i = 1;
while (line != NULL)
{
time_delay(2);
printf("%d.\t%s\n", i++, line);
line = strtok(NULL, "\r\n");
}
// FILE *fwx = fopen("../lrc/简单爱copy.lrc", "wb");
// fwrite(lrc_mem_data, lrc_size, 1, fwx);
// 释放内存,关闭文件
free(lrc_mem_data); // 释放歌词数据内存
fclose(fp); // 关闭歌词文件
return 0; return 0;
} }

0
lyric_analysis/srcs/start_mplayer.c Executable file → Normal file
View File

23
lyric_analysis/srcs/time_delay.c Executable file → Normal file
View File

@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include "includes/time_delay.h"
void time_delay(int sec) void time_delay(int sec)
{ {
int s_time, e_time; int s_time, e_time;
@ -11,16 +12,12 @@ void time_delay(int sec)
break; break;
} }
} }
int main(int argc, char *argv[]) // int main(int argc, char *argv[])
{ // {
while(1) // while(1)
{ // {
printf("hello world\n"); // printf("hello world\n");
time_delay(3); // time_delay(3);
} // }
return 0; // return 0;
} // }