歌词解析: 整理文件夹, 更新优化 Makefile
This commit is contained in:
parent
d69cf117d5
commit
a9ce625d3a
|
@ -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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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)/time_delay.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)
|
|
@ -5,6 +5,14 @@
|
|||
#include <stdlib.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); // 打开歌词文件
|
||||
long get_lrc_size(FILE *fp); // 获取歌词文件大小
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
int main()
|
||||
{
|
||||
// 定义歌曲和歌词文件路径
|
||||
const char *song_path = "../songs/简单爱.mp3";
|
||||
const char *lrc_path = "../lrc/简单爱.lrc";
|
||||
const char *song_path = "./songs/简单爱.mp3";
|
||||
const char *lrc_path = "./lrcs/简单爱.lrc";
|
||||
|
||||
FILE *fp = open_lrc_file(lrc_path); // 打开歌词文件
|
||||
if (NULL == fp)
|
||||
|
|
Loading…
Reference in New Issue