Differenze tra le versioni di "Estrarre informazioni da un file MP3 con le funzioni esterne del API di Id3tag"

Da Gambas-it.org - Wikipedia.
(Creata pagina con 'Le risorse del API di '''''id3tag''''' consentono anche di ottenere informazioni (''Tag'') dai file audio formato mp3 richiamando l'attuale versione della libreria: ''libid3ta...')
 
Riga 1: Riga 1:
 
Le risorse del API di '''''id3tag''''' consentono anche di ottenere informazioni (''Tag'') dai file audio formato mp3 richiamando l'attuale versione della libreria: ''libid3tag.so.0.3.0''
 
Le risorse del API di '''''id3tag''''' consentono anche di ottenere informazioni (''Tag'') dai file audio formato mp3 richiamando l'attuale versione della libreria: ''libid3tag.so.0.3.0''
  
Potremo procedere con un codice simile al seguente:
+
 
 +
Poiché l'uso della libreria esterna ''libid3tag'' prevede il richiamo diretto ed indiretto di numerose ''Strutture'', ed al fine di poter [[Gestire_con_sicurezza_le_Strutture_esterne|gestire dette ''Strutture'' esterne in modo assolutamente <SPAN style="text-decoration:underline">sicuro</span>]], ci serviremo di un'apposita libreria esterna scritta in C, che realizzeremo ''ad hoc'' e che richiameremo all'interno del codice Gambas.
 +
 
 +
La libreria ''ad hoc'' per la gestione della ''Struttura'' utilizzata di ''id3tag'' sarà la seguente:
 +
#include "id3tag.h"
 +
 +
 +
<FONT color=Blue>''// Legge nei campi della Struttura utilizzata:''</font>
 +
int obt_frame_nfields(struct id3_frame *p) {
 +
 +
  return p->nfields;
 +
 +
}
 +
 +
int obt_frame_type(struct id3_frame *p) {
 +
 +
  return p->fields[1].type;
 +
 +
}
 +
 +
union id3_field * obt_frame_fields(struct id3_frame *p) {
 +
 +
  return &p->fields[1];
 +
 +
}
 +
Tale codice in linguaggio C in questo esempio sarà posto nella cartella ''Dati'' dell'applicativo Gambas, e andrà poi trasformato in una libreria condivisa ''.so'' , che - come già accennato - sarà richiamata nel codice Gambas.
 +
 
 +
Il codice Gambas, che prevede ad esempio l'esecuzione di un file audio ed il contemporaneo effetto della variazione del volume in diminuzione, potrà essere il seguente:
 +
'''Public''' Struct audio_file_tags
 +
  title As String
 +
  artist As String
 +
  album As String
 +
  anno As String
 +
  genere As String
 +
  comment As String
 +
  track As String
 +
  composer As String
 +
  orig_artist As String
 +
  copyright As String
 +
  url As String
 +
  encoded_b As String
 +
'''End''' Struct
 +
 +
'''Private''' aftag As Struct Audio_file_tags
 +
 +
'''Private''' genre_table As String[] = ["Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge",
 +
"Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno",
 +
"Industrial", "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop",
 +
"Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip",
 +
"Gospel", "Noise", "Alt. Rock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrum. Pop", "Instrum. Rock",
 +
"Ethnic", "Gothic", "Darkwave", "Techno-Indust.", "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock",
 +
"Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret",
 +
"New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka",
 +
"Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", "Swing", "Fusion", "Bebob",
 +
"Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progress. Rock", "Psychadel. Rock",
 +
"Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson",
 +
"Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire"]
 +
 +
 +
Library "libid3tag:0.3.0"
 +
 +
'''Private''' Const ID3_FIELD_TYPE_STRINGLIST As Byte = 6
 +
 +
'''Private''' Enum ID3_FILE_MODE_READONLY = 0, ID3_FILE_MODE_READWRITE
 +
 +
<FONT color=gray>' ''id3_file *id3_file_open(char const *, enum id3_file_mode)''</font>
 +
'''Private''' Extern id3_file_open(fl As String, id3_file_mode As Byte) As Pointer
 +
 +
<FONT color=gray>' ''id3_tag *id3_file_tag(struct id3_file const *)''</font>
 +
'''Private''' Extern id3_file_tag(id3_file As Pointer) As Pointer
 +
 +
<FONT color=gray>' ''id3_frame *id3_tag_findframe(struct id3_tag const *, char const *, unsigned int)''</font>
 +
'''Private''' Extern id3_tag_findframe(id3_tag As Pointer, id$ As String, ui As Integer) As Pointer
 +
 +
<FONT color=gray>' ''id3_ucs4_t const *id3_field_getstrings(union id3_field const *, unsigned int)''</font>
 +
Private Extern id3_field_getstrings(unid3_field As Pointer, ui As Integer) As Pointer
 +
 +
<FONT color=gray>' ''id3_utf8_t *id3_ucs4_utf8duplicate(id3_ucs4_t const *)''</font>
 +
'''Private''' Extern id3_ucs4_utf8duplicate(id3_ucs4_t As Pointer) As Pointer
 +
 +
<FONT color=gray>' ''union id3_field *id3_frame_field(struct id3_frame const *, unsigned int)''</font>
 +
'''Private''' Extern id3_frame_field(strFrame As Pointer, ui As Integer) As Pointer
 +
 +
<FONT color=gray>' ''unsigned int id3_field_getnstrings(union id3_field const *)''</font>
 +
'''Private''' Extern id3_field_getnstrings(unid3_field As Pointer) As Integer
 +
 +
<FONT color=gray>' ''id3_latin1_t *id3_ucs4_latin1duplicate(id3_ucs4_t const *)''</font>
 +
'''Private''' Extern id3_ucs4_latin1duplicate(id3_ucs4_t As Pointer) As Pointer
 +
 +
<FONT color=gray>' ''int id3_file_close(struct id3_file *)''</font>
 +
'''Private''' Extern id3_file_close(id3_file As Pointer) As Integer
 +
 +
 +
Library "/tmp/libtag3"
 +
 +
'''Private''' Extern obt_frame_nfields(fr As Pointer) As Integer
 +
'''Private''' Extern obt_frame_type(fr As Pointer) As Integer
 +
'''Private''' Extern obt_frame_fields(fr As Pointer) As Pointer
 +
 +
 +
'''Public''' Sub Main()
 +
 +
  Dim id3_file, id3_tag As Pointer
 +
  Dim artista, titolo, album, anno As Pointer
 +
  Dim tracce, nomeFl, dur As Pointer
 +
  Dim genus As String
 +
 
 +
 +
<FONT color=gray>' ''Verifica se già è presente la libreria ad hoc''
 +
' ''per la gestione "sicura" delle Strutture di Sox:''</font>
 +
  If Exist("''/percorso/dell'apposita/libreria.so''") = False Then creaSo()
 +
 +
 
 +
  id3_file = id3_file_open("/home/ploppo/Scrivania/Via-Gra - Zhiva.mp3", ID3_FILE_MODE_READONLY)
 +
  If IsNull(id3_file) Then Error.Raise("Errore nel'apertura del file audio !")
 +
 
 +
  id3_tag = id3_file_tag(id3_file)
 +
 
 +
  With aftag
 +
    artista = obtArtista(id3_tag)
 +
    Print "Artista = "; String@(artista)
 +
    titolo = obtTitolo(id3_tag)
 +
    Print "Titolo = "; String@(titolo)
 +
    anno = obtAnno(id3_tag)
 +
    Print "Anno = "; String@(anno)
 +
    album = obtAlbum(id3_tag)
 +
    Print "Album = "; String@(album)
 +
    genus = String@(obtGenere(id3_tag))
 +
    If IsDigit(genus) Then genus = lista_generi.genre_table[Val(genus)]
 +
    Print "Genere = "; genus
 +
    tracce = obtTracce(id3_tag)
 +
    Print "Tracce = "; String@(tracce)
 +
    nomeFl = obtOrigFilename(id3_tag)
 +
    Print "Nome file originale = "; nomeFl
 +
    dur = obtLen(id3_tag)
 +
    Print "Durata sec. = "; nomeFl
 +
 +
  End With
 +
 
 +
 +
  id3_file_close(id3_file)
 +
 +
'''End'''
 +
 +
 +
'''Private''' Function obtArtista(id3_tag As Pointer) As Pointer
 +
 
 +
  Dim nomeArtistaP As Pointer
 +
 
 +
    nomeArtistaP = obtFrameText(id3_tag, "TPE1")
 +
    If IsNull(nomeartistaP) Then nomeartistaP = obtFrameText(id3_tag, "TPE2")
 +
    If IsNull(nomeartistaP) Then nomeartistaP = obtFrameText(id3_tag, "TPE3")
 +
    If IsNull(nomeartistaP) Then nomeartistaP = obtFrameText(id3_tag, "TPE4")
 +
    If IsNull(nomeartistaP) Then nomeartistaP = obtFrameText(id3_tag, "TCOM")
 +
 +
    Return nomeArtistaP
 +
 
 +
'''End'''
 +
 +
'''Private''' Function obtTitolo(id3_tag As Pointer) As Pointer
 +
 
 +
  Dim titoloP As Pointer
 +
 
 +
    titoloP = obtFrameText(id3_tag, "TIT2")
 +
    Return titoloP
 +
 
 +
'''End'''
 +
 +
'''Private''' Function obtAlbum(id3_tag As Pointer) As Pointer
 +
 
 +
  Dim albumP As Pointer
 +
 
 +
    albumP = obtFrameText(id3_tag, "TALB")
 +
    Return albumP
 +
 
 +
'''End'''
 +
 +
'''Private''' Function obtAnno(id3_tag As Pointer) As Pointer
 +
 
 +
  Dim annoP As Pointer
 +
 
 +
    annoP = obtFrameText(id3_tag, "TYER")
 +
    If IsNull(annoP) Then annoP = obtFrameText(id3_tag, "TDRC")
 +
    Return annoP
 +
 
 +
'''End'''
 +
 +
'''Private''' Function obtGenere(id3_tag As Pointer) As Pointer
 +
 
 +
  Dim gnreP As Pointer
 +
 
 +
    gnreP = obtFrameText(id3_tag, "TCON")
 +
    Return gnreP
 +
 
 +
'''End'''
 +
 +
'''Private''' Function obtTracce(id3_tag As Pointer) As Pointer
 +
 
 +
  Dim tracceP As Pointer
 +
 
 +
    tracceP = obtFrameText(id3_tag, "TRCK")
 +
    Return tracceP
 +
'''End'''
 +
 +
'''Private''' Function obtOrigFilename(id3_tag As Pointer) As Pointer
 +
 
 +
  Dim nomP As Pointer
 +
 
 +
    nomP = obtFrameText(id3_tag, "TOFN")
 +
    Return nomP
 +
   
 +
'''End'''
 +
 +
'''Private''' Function obtLen(id3_tag As Pointer) As Integer
 +
 
 +
  Dim durI As Pointer
 +
 
 +
    durI = obtDurata(id3_tag, "TLEN")
 +
    Return durI
 +
   
 +
'''End'''
 +
 +
 +
'''Private''' Function obtFrameText(tag As Pointer, id As String) As Pointer
 +
 
 +
  Dim frame, field1 As Pointer
 +
  Dim ucs4, utf8 As Pointer
 +
 
 +
    frame = id3_tag_findframe(tag, id, 0)
 +
    If IsNull(frame) Then Return Null
 +
   
 +
    If obt_frame_nfields(frame) <> 2 Then Return Null
 +
   
 +
    If obt_frame_type(frame) <> ID3_FIELD_TYPE_STRINGLIST Then Return Null
 +
   
 +
    field1 = obt_frame_fields(frame)
 +
   
 +
    ucs4 = id3_field_getstrings(field1, 0)
 +
    If ucs4 = 0 Then Return Null
 +
   
 +
    utf8 = id3_ucs4_utf8duplicate(ucs4)
 +
 +
    Return utf8
 +
 +
'''End'''
 +
 +
 +
'''Private''' Function obtDurata(tag As Pointer, id As String) As Integer
 +
 
 +
  Dim frame, field, latin1 As Pointer
 +
  Dim nstrings As Integer
 +
  Dim tempus As Long
 +
 
 +
    frame = id3_tag_findframe(tag, id, 0)
 +
    If IsNull(frame) Then Return Null
 +
   
 +
    field = id3_frame_field(frame, 1)
 +
   
 +
    nstrings = id3_field_getnstrings(field)
 +
    If nstrings <= 0 Then Return -1
 +
   
 +
    latin1 = id3_ucs4_latin1duplicate(id3_field_getstrings(field, 0))
 +
    If IsNull(latin1) Then Return -1
 +
   
 +
<FONT color=gray>' ''Il frame 'lengh' contiene la durata dei dati audio''
 +
' ''espressa in millisecondi e rappresentata in una stringa numerica:''</font>
 +
    tempus = Long@(latin1)
 +
   
 +
    If tempus > 0 Then
 +
      Return CInt(tempus / 1000 + 0.5)
 +
    Else
 +
      Return -1
 +
    Endif
 +
 +
'''End'''
 +
 +
 +
<FONT color=gray>' ''Crea l'apposita libreria per la gestione sicura delle Strutture di "id3tag":''</font>
 +
'''Private''' Procedure creaSo()
 +
 +
  Shell "gcc -o ''/percorso/destinazione/dell'apposita/libreria.so'' " & Application.Path &/ "''codice.c'' -shared -fPIC" Wait
 +
 
 +
'''End'''
  
  
 
<FONT color=red><B>Pagina in costruzione
 
<FONT color=red><B>Pagina in costruzione

Versione delle 06:44, 14 feb 2014

Le risorse del API di id3tag consentono anche di ottenere informazioni (Tag) dai file audio formato mp3 richiamando l'attuale versione della libreria: libid3tag.so.0.3.0


Poiché l'uso della libreria esterna libid3tag prevede il richiamo diretto ed indiretto di numerose Strutture, ed al fine di poter gestire dette Strutture esterne in modo assolutamente sicuro, ci serviremo di un'apposita libreria esterna scritta in C, che realizzeremo ad hoc e che richiameremo all'interno del codice Gambas.

La libreria ad hoc per la gestione della Struttura utilizzata di id3tag sarà la seguente:

#include "id3tag.h"


// Legge nei campi della Struttura utilizzata:
int obt_frame_nfields(struct id3_frame *p) {

 return p->nfields;

}

int obt_frame_type(struct id3_frame *p) {

 return p->fields[1].type;

}

union id3_field * obt_frame_fields(struct id3_frame *p) {

 return &p->fields[1];

}

Tale codice in linguaggio C in questo esempio sarà posto nella cartella Dati dell'applicativo Gambas, e andrà poi trasformato in una libreria condivisa .so , che - come già accennato - sarà richiamata nel codice Gambas.

Il codice Gambas, che prevede ad esempio l'esecuzione di un file audio ed il contemporaneo effetto della variazione del volume in diminuzione, potrà essere il seguente:

Public Struct audio_file_tags
 title As String
 artist As String
 album As String
 anno As String
 genere As String
 comment As String
 track As String
 composer As String
 orig_artist As String
 copyright As String
 url As String
 encoded_b As String
End Struct

Private aftag As Struct Audio_file_tags

Private genre_table As String[] = ["Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge",
"Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno",
"Industrial", "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop",
"Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", "Acid", "House", "Game", "Sound Clip",
"Gospel", "Noise", "Alt. Rock", "Bass", "Soul", "Punk", "Space", "Meditative", "Instrum. Pop", "Instrum. Rock",
"Ethnic", "Gothic", "Darkwave", "Techno-Indust.", "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock",
"Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", "Native American", "Cabaret",
"New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka",
"Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", "Swing", "Fusion", "Bebob",
"Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progress. Rock", "Psychadel. Rock",
"Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson",
"Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire"]


Library "libid3tag:0.3.0"

Private Const ID3_FIELD_TYPE_STRINGLIST As Byte = 6

Private Enum ID3_FILE_MODE_READONLY = 0, ID3_FILE_MODE_READWRITE

' id3_file *id3_file_open(char const *, enum id3_file_mode)
Private Extern id3_file_open(fl As String, id3_file_mode As Byte) As Pointer

' id3_tag *id3_file_tag(struct id3_file const *)
Private Extern id3_file_tag(id3_file As Pointer) As Pointer

' id3_frame *id3_tag_findframe(struct id3_tag const *, char const *, unsigned int)
Private Extern id3_tag_findframe(id3_tag As Pointer, id$ As String, ui As Integer) As Pointer

' id3_ucs4_t const *id3_field_getstrings(union id3_field const *, unsigned int)
Private Extern id3_field_getstrings(unid3_field As Pointer, ui As Integer) As Pointer

' id3_utf8_t *id3_ucs4_utf8duplicate(id3_ucs4_t const *)
Private Extern id3_ucs4_utf8duplicate(id3_ucs4_t As Pointer) As Pointer

' union id3_field *id3_frame_field(struct id3_frame const *, unsigned int)
Private Extern id3_frame_field(strFrame As Pointer, ui As Integer) As Pointer

' unsigned int id3_field_getnstrings(union id3_field const *)
Private Extern id3_field_getnstrings(unid3_field As Pointer) As Integer

' id3_latin1_t *id3_ucs4_latin1duplicate(id3_ucs4_t const *)
Private Extern id3_ucs4_latin1duplicate(id3_ucs4_t As Pointer) As Pointer

' int id3_file_close(struct id3_file *)
Private Extern id3_file_close(id3_file As Pointer) As Integer


Library "/tmp/libtag3"

Private Extern obt_frame_nfields(fr As Pointer) As Integer
Private Extern obt_frame_type(fr As Pointer) As Integer
Private Extern obt_frame_fields(fr As Pointer) As Pointer


Public Sub Main()

 Dim id3_file, id3_tag As Pointer
 Dim artista, titolo, album, anno As Pointer
 Dim tracce, nomeFl, dur As Pointer
 Dim genus As String
 

' Verifica se già è presente la libreria ad hoc
' per la gestione "sicura" delle Strutture di Sox:
  If Exist("/percorso/dell'apposita/libreria.so") = False Then creaSo()

 
 id3_file = id3_file_open("/home/ploppo/Scrivania/Via-Gra - Zhiva.mp3", ID3_FILE_MODE_READONLY)
 If IsNull(id3_file) Then Error.Raise("Errore nel'apertura del file audio !")
 
 id3_tag = id3_file_tag(id3_file)
 
 With aftag
   artista = obtArtista(id3_tag)
   Print "Artista = "; String@(artista)
   titolo = obtTitolo(id3_tag)
   Print "Titolo = "; String@(titolo)
   anno = obtAnno(id3_tag)
   Print "Anno = "; String@(anno)
   album = obtAlbum(id3_tag)
   Print "Album = "; String@(album)
   genus = String@(obtGenere(id3_tag))
   If IsDigit(genus) Then genus = lista_generi.genre_table[Val(genus)]
   Print "Genere = "; genus
   tracce = obtTracce(id3_tag)
   Print "Tracce = "; String@(tracce)
   nomeFl = obtOrigFilename(id3_tag)
   Print "Nome file originale = "; nomeFl
   dur = obtLen(id3_tag)
   Print "Durata sec. = "; nomeFl

 End With
 

 id3_file_close(id3_file)

End


Private Function obtArtista(id3_tag As Pointer) As Pointer
 
 Dim nomeArtistaP As Pointer
 
   nomeArtistaP = obtFrameText(id3_tag, "TPE1")
   If IsNull(nomeartistaP) Then nomeartistaP = obtFrameText(id3_tag, "TPE2")
   If IsNull(nomeartistaP) Then nomeartistaP = obtFrameText(id3_tag, "TPE3")
   If IsNull(nomeartistaP) Then nomeartistaP = obtFrameText(id3_tag, "TPE4")
   If IsNull(nomeartistaP) Then nomeartistaP = obtFrameText(id3_tag, "TCOM")

   Return nomeArtistaP
 
End

Private Function obtTitolo(id3_tag As Pointer) As Pointer
 
 Dim titoloP As Pointer
 
   titoloP = obtFrameText(id3_tag, "TIT2")
   Return titoloP
 
End

Private Function obtAlbum(id3_tag As Pointer) As Pointer
 
 Dim albumP As Pointer
 
   albumP = obtFrameText(id3_tag, "TALB")
   Return albumP
 
End

Private Function obtAnno(id3_tag As Pointer) As Pointer
 
 Dim annoP As Pointer
 
   annoP = obtFrameText(id3_tag, "TYER")
   If IsNull(annoP) Then annoP = obtFrameText(id3_tag, "TDRC")
   Return annoP
 
End

Private Function obtGenere(id3_tag As Pointer) As Pointer
 
 Dim gnreP As Pointer
 
   gnreP = obtFrameText(id3_tag, "TCON")
   Return gnreP
 
End

Private Function obtTracce(id3_tag As Pointer) As Pointer
 
 Dim tracceP As Pointer
 
   tracceP = obtFrameText(id3_tag, "TRCK")
   Return tracceP
End

Private Function obtOrigFilename(id3_tag As Pointer) As Pointer
 
 Dim nomP As Pointer
 
   nomP = obtFrameText(id3_tag, "TOFN")
   Return nomP
   
End

Private Function obtLen(id3_tag As Pointer) As Integer
 
 Dim durI As Pointer
 
   durI = obtDurata(id3_tag, "TLEN")
   Return durI
   
End


Private Function obtFrameText(tag As Pointer, id As String) As Pointer
 
 Dim frame, field1 As Pointer
 Dim ucs4, utf8 As Pointer
 
   frame = id3_tag_findframe(tag, id, 0)
   If IsNull(frame) Then Return Null
   
   If obt_frame_nfields(frame) <> 2 Then Return Null
   
   If obt_frame_type(frame) <> ID3_FIELD_TYPE_STRINGLIST Then Return Null
   
   field1 = obt_frame_fields(frame)
   
   ucs4 = id3_field_getstrings(field1, 0)
   If ucs4 = 0 Then Return Null
   
   utf8 = id3_ucs4_utf8duplicate(ucs4)

   Return utf8

End


Private Function obtDurata(tag As Pointer, id As String) As Integer
 
 Dim frame, field, latin1 As Pointer
 Dim nstrings As Integer
 Dim tempus As Long
 
   frame = id3_tag_findframe(tag, id, 0)
   If IsNull(frame) Then Return Null
   
   field = id3_frame_field(frame, 1)
   
   nstrings = id3_field_getnstrings(field)
   If nstrings <= 0 Then Return -1
   
   latin1 = id3_ucs4_latin1duplicate(id3_field_getstrings(field, 0))
   If IsNull(latin1) Then Return -1
   
' Il frame 'lengh' contiene la durata dei dati audio
' espressa in millisecondi e rappresentata in una stringa numerica:
   tempus = Long@(latin1)
   
   If tempus > 0 Then
     Return CInt(tempus / 1000 + 0.5)
   Else
     Return -1
   Endif

End


' Crea l'apposita libreria per la gestione sicura delle Strutture di "id3tag":
Private Procedure creaSo()

  Shell "gcc -o /percorso/destinazione/dell'apposita/libreria.so " & Application.Path &/ "codice.c -shared -fPIC" Wait
 
End


Pagina in costruzione