Estrarre i TAG da un file SPC con le funzioni esterne del API di Libspctag
La libreria Libspctg1 consente di estrarre i Tag dai file .spc .
Un file audio SPC700 (o SPC) è un file musicale per videogioco, comprensivo di punteggi e dati musicali dalla RAM, utilizzati dal chip audio SPC700 sul Super Nintendo Entertainment System ( SNES ) o Super Famicom. Questi dati audio sono solitamente ottenuti da un emulatore di console e non dal sistema stesso. Le capacità del SPC700 DSP del sistema audio SNES consentono sintesi musicali di campioni (analogo al MOD o a formati musicali IT), che permettono di riprodurre dati audio di dimensioni non superiori a 64 kilobyte.
Per fruire delle risorse della libreria libspctag1 è necessario utilizzare la libreria (nella sua attuale versione): libspctag.so.1.0.2
Di seguito mostreremo un semplice codice per estrarre i Tag presenti in un file audio .spc:
Library "libspctag:1.0.2" ' int spctag_init( FILE *file ) ' Read tags from file. Private Extern spctag_init(fl As Pointer) As Integer ' char* spctag_get_songtitle() ' Return the song title. Private Extern spctag_get_songtitle() As String ' char* spctag_get_gametitle() ' Return the game title. Private Extern spctag_get_gametitle() As String ' char* spctag_get_dumpername() ' Return the dumper name. Private Extern spctag_get_dumpername() As String ' char* spctag_get_comments() ' Return comments. Private Extern spctag_get_comments() As String ' char* spctag_get_dumpdate() ' Return the dump date. Private Extern spctag_get_dumpdate() As String ' char* spctag_get_length() ' Return the number of seconds to play song before fading out. Private Extern spctag_get_length() As String ' char* spctag_get_fadelength() ' Return the length of fade in milliseconds Private Extern spctag_get_fadelength() As String ' char* spctag_get_artist() ' Return the artist name. Private Extern spctag_get_artist() As String ' char* spctag_get_defaultchannels() ' Return channel states. Default channel disables (0 = enable, 1 = disable). Private Extern spctag_get_defaultchannels() As String ' char* spctag_get_emulator() ' Return the name of the emulator used to dump: 0 = unknown, 1 = ZSNES, 2 = Snes9x Private Extern spctag_get_emulator() As String Library "libc:6" ' FILE *fopen(const char *path, const char *mode) ' La funzione fopen() apre il file path associandolo ad uno stream. Private Extern fopen(path As String, mode As String) As Pointer ' int fclose(FILE *stream) ' fclose() - chiude uno stream Private Extern fclose(stP As Pointer) As Integer Public Sub Main() Dim spc_file As Pointer Dim percorsoFile As String = "/percorso/del/file.spc" Dim err As Integer ' Apre il file: spc_file = fopen(percorsoFile, "r+b") If IsNull(spc_file) Then Error.Raise("Impossibile aprire il file " & percorsoFile & " !") err = spctag_init(spc_file) If err < 0 Then Error.Raise("Impossibile leggere i Tag dal file !") ' Mostra un paio di dati generali del file .spc caricato: Print "File caricato: "; percorsoFile Print "Dimensione: "; Stat(percorsoFile).Size; " byte" ' Estrae i Tag del file .spc caricato: Print "\n--- Lettura dei TAG ---\n" Print "Titolo del brano: "; spctag_get_songtitle() Print "Titolo del gioco: "; spctag_get_gametitle() Print "Nome dello scaricatore del file : "; spctag_get_dumpername() Print "Commenti: "; spctag_get_comments() Print "Data dello scarico: "; spctag_get_dumpdate() Print "Durata: "; spctag_get_length(); " secondi" Print "Durata della dissolvenza: "; spctag_get_fadelength(); " millisecondi" Print "Artista: "; spctag_get_artist() Print "Stato predefinito dei Canali: "; spctag_get_defaultchannels() Print "Emulatore: "; spctag_get_emulator() ' Va in chiusura: fclose(spc_file) End