diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2025-12-10 17:49:22 -0500 |
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2025-12-10 17:49:22 -0500 |
| commit | 29f69b5b7831c846cea1f61a7de4920fafa97ede (patch) | |
| tree | a216cbcef9306ab5707752d8eec33f5a5a682744 /project/Core/Src/Project/song_info.c | |
| parent | 9db025199644833d70e729d03e6151f8cce58ed5 (diff) | |
| download | 340-repo-Sowgro-29f69b5b7831c846cea1f61a7de4920fafa97ede.tar.gz 340-repo-Sowgro-29f69b5b7831c846cea1f61a7de4920fafa97ede.tar.bz2 340-repo-Sowgro-29f69b5b7831c846cea1f61a7de4920fafa97ede.zip | |
push for laptop
Diffstat (limited to 'project/Core/Src/Project/song_info.c')
| -rw-r--r-- | project/Core/Src/Project/song_info.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/project/Core/Src/Project/song_info.c b/project/Core/Src/Project/song_info.c index 4a94954..2990da0 100644 --- a/project/Core/Src/Project/song_info.c +++ b/project/Core/Src/Project/song_info.c @@ -11,10 +11,11 @@ #include "song_info.h" #include "endian_converters.h" -song_info_t get_song_info(uint8_t *p_song) { - song_info_t ret = {0, 0, 0}; -// header_t *header = (header_t *) p_song; - p_song += sizeof(header_t) - 2; // move pointer past header +uint8_t get_song_info(uint8_t *p_song, song_info_t *ret) { + ret->copyright = 0; + ret->tempo = 0; + ret->title = 0; + p_song += 4; // move past MTrk label uint32_t MTrk_len = convert_to_uint32(p_song); // read in size of MTrk @@ -26,8 +27,8 @@ song_info_t get_song_info(uint8_t *p_song) { p_song += sizeof(uint16_t); uint8_t ev_len = *(uint8_t *) p_song; p_song += sizeof(ev_len); - ret.copyright = (char *) p_song; - ret.copyright[ev_len] = 0; + ret->copyright = (char *) p_song; + ret->copyright[ev_len] = 0; } // FF 03 - title @@ -35,19 +36,17 @@ song_info_t get_song_info(uint8_t *p_song) { p_song += sizeof(uint16_t); uint8_t ev_len = *(uint8_t *) p_song; p_song += sizeof(ev_len); - ret.title = (char *) p_song; - ret.title[ev_len] = 0; + ret->title = (char *) p_song; + ret->title[ev_len] = 0; } // FF 51 - tempo if (convert_to_uint16(p_song) == 0xFF51) { p_song += sizeof(uint16_t); p_song += sizeof(uint8_t); // skip length, always 03 - ret.tempo = convert_to_uint24(p_song); + ret->tempo = convert_to_uint24(p_song); } } - - - return ret; + return p_song; } |
