1 #ifndef GMEREADER_H 2 #define GMEREADER_H 3 4 #include <QtCore> 5 #include "tagreadermessages.pb.h" 6 7 class QFileInfo; 8 class QByteArray; 9 10 namespace GME { 11 bool IsSupportedFormat(const QFileInfo& file_info); 12 void ReadFile(const QFileInfo& file_info, 13 pb::tagreader::SongMetadata* song_info); 14 15 namespace SPC { 16 /* SPC SPEC: 17 * http://vspcplay.raphnet.net/spc_file_format.txt 18 */ 19 const int HAS_ID6_OFFSET = 0x23; 20 const int SONG_TITLE_OFFSET = 0x2E; 21 const int GAME_TITLE_OFFSET = 0x4E; 22 const int DUMPER_OFFSET = 0x6E; 23 const int COMMENTS_OFFSET = 0x7E; 24 /*It seems that intro length and fade length are inconsistent from 25 *file to file. It should be looked into within the GME source code 26 *to see how GStreamer gets its values for playback length.*/ 27 const int INTRO_LENGTH_OFFSET = 0xA9; 28 const int INTRO_LENGTH_SIZE = 3; 29 const int FADE_LENGTH_OFFSET = 0xAC; 30 const int FADE_LENGTH_SIZE = 4; 31 const int ARTIST_OFFSET = 0xB1; 32 const int XID6_OFFSET = (0x101C0 + 64); 33 34 const int NANO_PER_MS = 1000000; 35 36 enum xID6_STATUS { 37 ON = 0x26, 38 OFF = 0x27, 39 }; 40 41 enum xID6_ID { SongName = 0x01, GameName = 0x02, ArtistName = 0x03 }; 42 43 enum xID6_TYPE { Length = 0x0, String = 0x1, Integer = 0x4 }; 44 45 void Read(const QFileInfo& file_info, pb::tagreader::SongMetadata* song_info); 46 qint16 GetNextMemAddressAlign32bit(qint16 input); 47 quint64 ConvertSPCStringToNum(const QByteArray& arr); 48 } // namespace SPC 49 50 namespace VGM { 51 /* VGM SPEC: 52 * http://www.smspower.org/uploads/Music/vgmspec170.txt?sid=17c810c54633b6dd4982f92f718361c1 53 * GD3 TAG SPEC: 54 * http://www.smspower.org/uploads/Music/gd3spec100.txt */ 55 const int GD3_TAG_PTR = 0x14; 56 const int SAMPLE_COUNT = 0x18; 57 const int LOOP_SAMPLE_COUNT = 0x20; 58 const int SAMPLE_TIMEBASE = 44100; 59 const int GST_GME_LOOP_TIME_MS = 8000; 60 61 void Read(const QFileInfo& file_info, pb::tagreader::SongMetadata* song_info); 62 /* Takes in two QByteArrays, expected to be 4 bytes long. Desired length 63 * is returned via output parameter out_length. Returns false on error. */ 64 bool GetPlaybackLength(const QByteArray& sample_count_bytes, 65 const QByteArray& loop_count_bytes, quint64& out_length); 66 67 } // namespace VGM 68 69 } // namespace GME 70 71 #endif 72