Differenze tra le versioni di "Estrarre informazioni da un file OggVorbis con le funzioni esterne del API di Vorbisfile"
Da Gambas-it.org - Wikipedia.
(4 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 1: | Riga 1: | ||
La libreria di '''VorbisFile''' consente di estrarre informazioni di carattere generale da un file audio OggVorbis. | La libreria di '''VorbisFile''' consente di estrarre informazioni di carattere generale da un file audio OggVorbis. | ||
− | E' necessario avere installata nel sistema e richiamare nel programma Gambas la libreria | + | E' necessario avere installata nel sistema e richiamare nel programma Gambas la libreria condivisa: "''libvorbisfile.so.3.3.8'' ". |
− | |||
Vediamo di seguito un esempio pratico: | Vediamo di seguito un esempio pratico: | ||
− | Library "libvorbisfile" | + | Library "libvorbisfile:3.3.8" |
Public Struct vorbis_comment | Public Struct vorbis_comment | ||
Riga 174: | Riga 173: | ||
− | + | Public Sub Main() | |
Dim ogg As String | Dim ogg As String | ||
Riga 181: | Riga 180: | ||
Dim comm As Vorbis_comment | Dim comm As Vorbis_comment | ||
Dim av As Integer | Dim av As Integer | ||
− | + | ||
− | ogg = "<FONT color= | + | ogg = "<FONT color=darkgreen>''/percorso/del/file.ogg''</font>" |
− | + | ||
if ov_fopen(ogg, ovf) < 0 Then Error.Raise("Impossibile aprire il file: " & ogg & " !") | if ov_fopen(ogg, ovf) < 0 Then Error.Raise("Impossibile aprire il file: " & ogg & " !") | ||
− | + | ||
Print "\nFile audio ogg: "; ogg | Print "\nFile audio ogg: "; ogg | ||
With info = ov_info(ovf, 0) | With info = ov_info(ovf, 0) | ||
Riga 192: | Riga 191: | ||
Print "Bitrate nominale: "; .bitrate_nominal \ 1000; " Kbps" | Print "Bitrate nominale: "; .bitrate_nominal \ 1000; " Kbps" | ||
End With | End With | ||
− | Print " | + | Print "Dati compressi: "; ov_raw_total(ovf, -1); " byte" |
− | Print " | + | Print "Dati pcm: "; ov_pcm_total(ovf, -1); " byte" |
+ | Print "Dimensione totale: "; Len(File.Load(ogg)); " byte" | ||
Print "Numero seriale: "; ov_serialnumber(ovf, -1) | Print "Numero seriale: "; ov_serialnumber(ovf, -1) | ||
− | Print "\nDurata: "; | + | Print "\nDurata: "; Time(0, 0, 0, ov_time_total(ovf, -1) * 1000) |
With comm = ov_comment(ovf, 0) | With comm = ov_comment(ovf, 0) | ||
Riga 206: | Riga 206: | ||
Endif | Endif | ||
End With | End With | ||
− | + | ||
ov_clear(ovf) | ov_clear(ovf) | ||
− | + | ||
− | + | End | |
− | |||
=Riferimenti= | =Riferimenti= | ||
− | [1] | + | [1] http://www.xiph.org/vorbis/doc/vorbisfile/index.html |
Versione attuale delle 05:54, 14 gen 2024
La libreria di VorbisFile consente di estrarre informazioni di carattere generale da un file audio OggVorbis.
E' necessario avere installata nel sistema e richiamare nel programma Gambas la libreria condivisa: "libvorbisfile.so.3.3.8 ".
Vediamo di seguito un esempio pratico:
Library "libvorbisfile:3.3.8" Public Struct vorbis_comment user_comments As Pointer comment_lengths As Pointer comments As Integer vendor As Pointer End Struct Public Struct ogg_sync_state data As Pointer storage As Integer fill As Integer returned As Integer unisynced As Integer headerbytes As Integer bodybytes As Integer End Struct Public Struct ogg_stream_state body_data As Pointer body_storage As Long body_fill As Long body_returned As Long lacing_vals As Pointer granule_vals As Pointer lacing_storage As Long lacing_fill As Long lacing_packet As Long lacing_returned As Long header[282] As Byte header_fill As Integer e_o_s As Integer b_o_s As Integer serialno As Long pageno As Long packetno As Long granulepos As Long End Struct Public Struct vorbis_dsp_state analysisp As Integer vi As Pointer pcm As Pointer pcmret As Pointer pcm_storage As Integer pcm_current As Integer pcm_returned As Integer preextrapolate As Integer eofflag As Integer lW As Long W As Long nW As Long centerW As Long granulepos As Long sequence As Long glue_bits As Long time_bits As Long floor_bits As Long res_bits As Long End Struct Public Struct oggpack_buffer endbyte As Long endbit As Integer buffer As Pointer ptr As Pointer storage As Long End Struct Public Struct vorbis_block pcm As Pointer opb As Struct Oggpack_buffer lW As Long W As Long nW As Long pcmend As Integer mode As Integer eofflag As Integer granulepos As Long sequence As Long vd As Pointer localstore As Pointer localtop As Long localalloc As Long totaluse As Long reap As Pointer glue_bits As Long time_bits As Long floor_bits As Long res_bits As Long internal As Pointer End Struct Public Struct ov_callbacks fread As Pointer _ov_header_fseek_wrap As Pointer void As Pointer ftell As Pointer End Struct Public Struct OggVorbis_File datasource As Pointer seekable As Integer offset As Long end_ As Long oy As Struct Ogg_sync_state links As Integer offsets As Pointer dataoffsets As Pointer serialnos As Pointer pcmlengths As Pointer vi As Pointer vc As Pointer pcm_offset As Long ready_state As Integer current_serialno As Long current_link As Integer bittrack As Float samptrack As Float os As Struct Ogg_stream_state vd As Struct Vorbis_dsp_state vb As Struct Vorbis_block callbacks As Struct Ov_callbacks End Struct Public Struct vorbis_info version As Integer channels As Integer rate As Long bitrate_upper As Long bitrate_nominal As Long bitrate_lower As Long bitrate_window As Long End Struct ' int ov_fopen(const char *path,OggVorbis_File *vf) ' Opens and initialize an OggVorbis_File structure. Private Extern ov_fopen(path As String, vf As OggVorbis_File) As Integer ' vorbis_info *ov_info(OggVorbis_File *vf,int link) ' Returns the vorbis_info struct for the specified bitstream. Private Extern ov_info(vf As OggVorbis_File, olink As Integer) As Vorbis_info ' ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i) ' Returns the total (compressed) bytes. Private Extern ov_raw_total(vf As OggVorbis_File, i As Integer) As Long ' ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i) ' Returns the total pcm samples. Private Extern ov_pcm_total(vf As OggVorbis_File, i As Integer) As Long ' double ov_time_total(OggVorbis_File *vf,int i) ' Returns the total time in seconds of the physical bitstream or a specified logical bitstream. Private Extern ov_time_total(vf As OggVorbis_File, i As Integer) As Float ' vorbis_comment *ov_comment(OggVorbis_File *vf,int link) ' Returns a pointer to the vorbis_comment struct for the specified bitstream. Private Extern ov_comment(vf As OggVorbis_File, olink As Integer) As Vorbis_comment ' long ov_serialnumber(OggVorbis_File *vf,int i) ' Returns the serialnumber of the specified logical bitstream link number within the overall physical bitstream. Private Extern ov_serialnumber(vf As OggVorbis_File, i As Integer) As Long ' int ov_clear(OggVorbis_File *vf) ' Clears the decoder's buffers. Private Extern ov_clear(vf As OggVorbis_File) As Integer Public Sub Main() Dim ogg As String Dim ovf As New OggVorbis_File Dim info As Vorbis_info Dim comm As Vorbis_comment Dim av As Integer ogg = "/percorso/del/file.ogg" if ov_fopen(ogg, ovf) < 0 Then Error.Raise("Impossibile aprire il file: " & ogg & " !") Print "\nFile audio ogg: "; ogg With info = ov_info(ovf, 0) Print "\nNumero canali: "; .channels Print "Frequenza campinamento: "; .rate; " hertz" Print "Bitrate nominale: "; .bitrate_nominal \ 1000; " Kbps" End With Print "Dati compressi: "; ov_raw_total(ovf, -1); " byte" Print "Dati pcm: "; ov_pcm_total(ovf, -1); " byte" Print "Dimensione totale: "; Len(File.Load(ogg)); " byte" Print "Numero seriale: "; ov_serialnumber(ovf, -1) Print "\nDurata: "; Time(0, 0, 0, ov_time_total(ovf, -1) * 1000) With comm = ov_comment(ovf, 0) If .comments > 0 Then Print "\nVendor: "; String@(.vendor) Print "\nCommenti:" For av = 0 To .comments - 1 Print String@(Pointer@(comm.user_comments + (8 * av))) Next Endif End With ov_clear(ovf) End