Differenze tra le versioni di "Convertire i formati audio mediante il Componente gb.media"

Da Gambas-it.org - Wikipedia.
 
(15 versioni intermedie di uno stesso utente non sono mostrate)
Riga 11: Riga 11:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, wprs, cnv, lam, snk As MediaControl
 
   Dim src, wprs, cnv, lam, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.wav''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.wav''</font>"
 
  appoggio = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 31: Riga 29:
 
   lam["bitrate"] = 192      <FONT Color=gray>' ''Imposta il valore del Bitrate "Costante".''</font>
 
   lam["bitrate"] = 192      <FONT Color=gray>' ''Imposta il valore del Bitrate "Costante".''</font>
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
    
 
    
 
  <FONT Color=gray>' ''Collega fra loro all'interno della pipeline gli oggetti MediaControl impostati:''</font>
 
  <FONT Color=gray>' ''Collega fra loro all'interno della pipeline gli oggetti MediaControl impostati:''</font>
Riga 51: Riga 49:
 
   Until bo
 
   Until bo
 
   
 
   
  Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
+
<FONT Color=darkgray>' ''E' necessario prevedere sia il Metodo ".Stop" che il Metodo ".Close" della Classe "MediaPipeline", per evitare di ottenere un file audio vuoto:''</font>
 
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 74: Riga 71:
 
  Public Sub Main()
 
  Public Sub Main()
 
    
 
    
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, wprs, cnv, vor, mux, snk As MediaControl
 
   Dim src, wprs, cnv, vor, mux, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.wav''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.wav''</font>"
+
    
   appoggio = Temp
 
 
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
 
    
 
    
Riga 92: Riga 87:
 
   mux = New MediaControl(pl, "<FONT Color=#B22222>oggmux</font>")
 
   mux = New MediaControl(pl, "<FONT Color=#B22222>oggmux</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
    
 
    
 
   src.LinkTo(wprs)
 
   src.LinkTo(wprs)
Riga 111: Riga 106:
 
   Until bo
 
   Until bo
 
   
 
   
  Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 120: Riga 114:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 133: Riga 127:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
   Dim src, wav, cnv, faac, snk As MediaControl
+
   Dim src, wav, cnv, aac, snk As MediaControl
 
   Dim flt As MediaFilter
 
   Dim flt As MediaFilter
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.wav''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.wav''</font>"
 
  appoggio = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 149: Riga 141:
 
   wav = New MediaControl(pl, "wavparse")
 
   wav = New MediaControl(pl, "wavparse")
 
   cnv = New MediaControl(pl, "audioconvert")
 
   cnv = New MediaControl(pl, "audioconvert")
   faac = New MediaControl(pl, "faac")
+
   aac = New MediaControl(pl, "faac")   <FONT Color=gray>' ''oppure anche "'''voaacenc'''"''</font>
   flt = New MediaFilter(pl, "audio/mpeg,stream-format=adts")
+
   flt = New MediaFilter(pl, "audio/mpeg,stream-format=adts,channels=2,rate=44100")
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".aac"
 
    
 
    
 
   src.LinkTo(wav)
 
   src.LinkTo(wav)
 
   wav.LinkTo(cnv)
 
   wav.LinkTo(cnv)
   cnv.LinkTo(faac)
+
   cnv.LinkTo(aac)
   faac.LinkTo(flt)
+
   aac.LinkTo(flt)
 
   flt.LinkTo(snk)
 
   flt.LinkTo(snk)
 
   
 
   
Riga 171: Riga 163:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
 
  Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".aac"
 
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 182: Riga 172:
 
   
 
   
 
   
 
   
  Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 195: Riga 185:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, map, mad, vor, mux, snk As MediaControl
 
   Dim src, map, mad, vor, mux, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
  appoggio = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 207: Riga 195:
 
   src = New MediaControl(pl, "filesrc")
 
   src = New MediaControl(pl, "filesrc")
 
   src["location"] = fileaudio
 
   src["location"] = fileaudio
 
+
 
   map = New MediaControl(pl, "<FONT Color=#B22222>mpegaudioparse</font>")
 
   map = New MediaControl(pl, "<FONT Color=#B22222>mpegaudioparse</font>")
 
   mad = New MediaControl(pl, "<FONT Color=#B22222>mpg123audiodec</font>")
 
   mad = New MediaControl(pl, "<FONT Color=#B22222>mpg123audiodec</font>")
Riga 213: Riga 201:
 
   mux = New MediaControl(pl, "<FONT Color=#B22222>oggmux</font>")
 
   mux = New MediaControl(pl, "<FONT Color=#B22222>oggmux</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
+
 
   src.LinkTo(map)
 
   src.LinkTo(map)
 
   map.LinkTo(mad)
 
   map.LinkTo(mad)
Riga 222: Riga 210:
 
    
 
    
 
   pl.Play()
 
   pl.Play()
 
+
 
   While pl.Duration < 1
 
   While pl.Duration < 1
 
     Wait 0.01
 
     Wait 0.01
Riga 231: Riga 219:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
 
  Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 242: Riga 228:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 255: Riga 241:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, map, mad, wav, snk As MediaControl
 
   Dim src, map, mad, wav, snk As MediaControl
Riga 261: Riga 247:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
   
 
   
   appoggio = Temp
+
   pl = New MediaPipeline As "PLine"
 
   
 
   
  pl = New MediaPipeline As "PLine"
 
 
 
 
   src = New MediaControl(pl, "filesrc")
 
   src = New MediaControl(pl, "filesrc")
 
   src["location"] = fileaudio
 
   src["location"] = fileaudio
 
+
 
   map = New MediaControl(pl, "<FONT Color=#B22222>mpegaudioparse</font>")
 
   map = New MediaControl(pl, "<FONT Color=#B22222>mpegaudioparse</font>")
 
   mad = New MediaControl(pl, "<FONT Color=#B22222>mpg123audiodec</font>")
 
   mad = New MediaControl(pl, "<FONT Color=#B22222>mpg123audiodec</font>")
 
   wav = New MediaControl(pl, "<FONT Color=#B22222>wavenc</font>")
 
   wav = New MediaControl(pl, "<FONT Color=#B22222>wavenc</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
+
 
   src.LinkTo(map)
 
   src.LinkTo(map)
 
   map.LinkTo(mad)
 
   map.LinkTo(mad)
 
   mad.LinkTo(wav)
 
   mad.LinkTo(wav)
 
   wav.LinkTo(snk)
 
   wav.LinkTo(snk)
 
+
 
   pl.Play()
 
   pl.Play()
 
   
 
   
Riga 290: Riga 274:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
+
   pl.Stop
 +
  pl.Close
 +
 +
  Print "\n\e[0mConversione terminata !"
 +
 +
End
 +
 +
 +
Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 +
 +
  bo = True
 +
 +
End
 +
 
 +
 
 +
===Conversione audio dal formato MP3 al formato AAC===
 +
Private bo As Boolean
 +
 +
 +
Public Sub Main()
 +
 +
  Dim fileaudio As String
 +
  Dim pl As MediaPipeline
 +
  Dim src, map, mad, aac, snk As MediaControl
 +
  Dim flt As MediaFilter
 +
 +
  fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 +
 +
  pl = New MediaPipeline As "PLine"
 +
 +
  src = New MediaControl(pl, "filesrc")
 +
  src["location"] = fileaudio
 +
  map = New MediaControl(pl, "<FONT Color=#B22222>mpegaudioparse</font>")
 +
  mad = New MediaControl(pl, "<FONT Color=#B22222>mpg123audiodec</font>")
 +
  aac = New MediaControl(pl, "faac")  <FONT Color=gray>' ''oppure anche "'''voaacenc'''"''</font>
 +
  flt = New MediaFilter(pl, "audio/mpeg,stream-format=adts,channels=2,rate=44100")
 +
  snk = New MediaControl(pl, "filesink")
 +
  snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".aac"
 +
 
 +
  src.LinkTo(map)
 +
  map.LinkTo(mad)
 +
  mad.LinkTo(aac)
 +
  aac.LinkTo(flt)
 +
  flt.LinkTo(snk)
 +
 +
  pl.Play()
 +
 +
  While pl.Duration < 1
 +
    Wait 0.01
 +
  Wend
 +
  Print "Durata del file wav: "; Time(0, 0, 0, pl.Duration * 1000)
 +
 +
  Repeat
 +
    Write "\r\e[0mTempo trascorso:    \e[31m" & Time(0, 0, 0, pl.Position * 1000)
 +
    Wait 0.01
 +
  Until bo
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 300: Riga 339:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 314: Riga 353:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, par, dcd, snk As MediaControl
 
   Dim src, par, dcd, snk As MediaControl
   Dim fil As MediaFilter
+
   Dim flt As MediaFilter
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
  appoggio = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 327: Riga 364:
 
   src = New MediaControl(pl, "filesrc")
 
   src = New MediaControl(pl, "filesrc")
 
   src["location"] = fileaudio
 
   src["location"] = fileaudio
 
+
 
   par = New MediaControl(pl, "<FONT Color=#B22222>mpegaudioparse</font>")
 
   par = New MediaControl(pl, "<FONT Color=#B22222>mpegaudioparse</font>")
 
   dcd = New MediaControl(pl, "<FONT Color=#B22222>mpg123audiodec</font>")
 
   dcd = New MediaControl(pl, "<FONT Color=#B22222>mpg123audiodec</font>")
   fil = New MediaFilter(pl, "<FONT Color=#B22222>audio/x-raw, format=S16LE, rate=44100, channels=2, endianness=1234, width=16, depth=16</font>")
+
   flt = New MediaFilter(pl, "<FONT Color=#B22222>audio/x-raw, format=S16LE, rate=44100, channels=2, endianness=1234, width=16, depth=16</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".raw"
 
   
 
   
 
   src.LinkTo(par)
 
   src.LinkTo(par)
 
   par.LinkTo(dcd)
 
   par.LinkTo(dcd)
   dcd.LinkTo(fil)
+
   dcd.LinkTo(flt)
   fil.LinkTo(snk)
+
   flt.LinkTo(snk)
 
   
 
   
 
   pl.Play()
 
   pl.Play()
Riga 349: Riga 386:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
+
    
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".raw"
 
 
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 360: Riga 395:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 375: Riga 410:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, ogg, vor, cnv, lam, snk As MediaControl
 
   Dim src, ogg, vor, cnv, lam, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.ogg''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.ogg''</font>"
+
    
   appoggio = Temp
 
 
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
 
   
 
   
Riga 396: Riga 429:
 
   lam["bitrate"] = 192      ' Imposta il valore del Bitrate "Costante".
 
   lam["bitrate"] = 192      ' Imposta il valore del Bitrate "Costante".
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
   
 
   
 
   src.LinkTo(ogg)
 
   src.LinkTo(ogg)
Riga 413: Riga 446:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
+
   pl.Stop
 +
  pl.Close
 +
 +
  Print "\n\e[0mConversione terminata !"
 +
 +
End
 +
 +
 +
Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 +
 +
  bo = True
 +
 +
End
 +
 
 +
 
 +
===Conversione audio dal formato OGG-Vorbis al formato AAC===
 +
Private bo As Boolean
 +
 +
 +
Public Sub Main()
 +
 +
  Dim fileaudio As String
 +
  Dim pl As MediaPipeline
 +
  Dim src, ogg, vor, con, aac, snk As MediaControl
 +
  Dim flt As MediaFilter
 +
 +
  fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.ogg''</font>"
 +
 
 +
  pl = New MediaPipeline As "PLine"
 +
 +
  src = New MediaControl(pl, "filesrc")
 +
  src["location"] = fileaudio
 +
  ogg = New MediaControl(pl, "oggdemux")
 +
  vor = New MediaControl(pl, "vorbisdec")
 +
  con = New MediaControl(pl, "audioconvert")
 +
  aac = New MediaControl(pl, "faac")  <FONT Color=gray>' ''oppure anche "'''voaacenc'''"''</font>
 +
  flt = New MediaFilter(pl, "audio/mpeg,stream-format=adts,channels=2,rate=44100")
 +
  snk = New MediaControl(pl, "filesink")
 +
  snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".acc"
 +
 +
  src.LinkTo(ogg)
 +
  ogg.LinkLaterTo(vor)
 +
  vor.LinkTo(con)
 +
  con.LinkTo(aac)
 +
  aac.LinkTo(flt)
 +
  flt.LinkTo(snk)
 +
 +
  pl.Play()
 +
 +
  Print "Durata del file ogg: "; Time(0, 0, 0, pl.Duration * 1000)
 +
 +
  Repeat
 +
    Write "\r\e[0mTempo trascorso:    \e[31m" & Time(0, 0, 0, pl.Position * 1000)
 +
    Wait 0.01
 +
  Until bo
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 423: Riga 510:
 
   
 
   
 
   
 
   
  Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 438: Riga 525:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, raw, wav, snk As MediaControl
 
   Dim src, raw, wav, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
+
    
   appoggio = Temp
 
 
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
 
   
 
   
Riga 458: Riga 543:
 
   wav = New MediaControl(pl, "wavenc")
 
   wav = New MediaControl(pl, "wavenc")
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
   
 
   
 
   src.LinkTo(raw)
 
   src.LinkTo(raw)
Riga 466: Riga 551:
 
   pl.Play()
 
   pl.Play()
 
   
 
   
   Print "Durata del file wav finale: "; Time(0, 0, 0, pl.Duration * 1000)
+
   Print "Durata del file raw: "; Time(0, 0, 0, pl.Duration * 1000)
 
   Repeat
 
   Repeat
 
     Write "\r\e[0mTempo trascorso:    \e[31m" & Time(0, 0, 0, pl.Position * 1000)
 
     Write "\r\e[0mTempo trascorso:    \e[31m" & Time(0, 0, 0, pl.Position * 1000)
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
 
  Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 482: Riga 565:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 490: Riga 573:
  
 
===Conversione audio dal formato RAW al formato MP3===
 
===Conversione audio dal formato RAW al formato MP3===
 +
Private Const GST_AUDIO_FORMAT_S16LE As Integer = 4
 
  Private Const QUALITY As String = "quality"
 
  Private Const QUALITY As String = "quality"
 
  Private Const BITRATE As String = "bitrate"
 
  Private Const BITRATE As String = "bitrate"
Riga 497: Riga 581:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, raw, lam, snk As MediaControl
 
   Dim src, raw, lam, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
  appoggio = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 520: Riga 602:
 
   lam["bitrate"] = 192      <FONT Color=gray>' ''Imposta il valore del Bitrate "Costante"''</font>
 
   lam["bitrate"] = 192      <FONT Color=gray>' ''Imposta il valore del Bitrate "Costante"''</font>
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
   
 
   
 
   src.LinkTo(raw)
 
   src.LinkTo(raw)
Riga 531: Riga 613:
 
     Wait 0.01
 
     Wait 0.01
 
   Wend
 
   Wend
   Print "Durata del file mp3 finale: "; Time(0, 0, 0, pl.Duration * 1000)
+
   Print "Durata del file raw: "; Time(0, 0, 0, pl.Duration * 1000)
 
   Repeat
 
   Repeat
 
     Write "\r\e[0mTempo trascorso:    \e[31m" & Time(0, 0, 0, pl.Position * 1000)
 
     Write "\r\e[0mTempo trascorso:    \e[31m" & Time(0, 0, 0, pl.Position * 1000)
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
 
  Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 547: Riga 627:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 555: Riga 635:
  
 
===Conversione audio dal formato RAW al formato OGG-Vorbis===
 
===Conversione audio dal formato RAW al formato OGG-Vorbis===
 +
Private Const GST_AUDIO_FORMAT_S16LE As Integer = 4
 
  Private bo As Boolean
 
  Private bo As Boolean
 
   
 
   
Riga 560: Riga 641:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, raw, cnv, vor, mux, snk As MediaControl
 
   Dim src, raw, cnv, vor, mux, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
  appoggio = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 582: Riga 661:
 
   mux = New MediaControl(pl, "oggmux")
 
   mux = New MediaControl(pl, "oggmux")
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
   
 
   
 
   src.LinkTo(raw)
 
   src.LinkTo(raw)
Riga 595: Riga 674:
 
     Wait 0.01
 
     Wait 0.01
 
   Wend
 
   Wend
   Print "Durata del file ogg finale: "; Time(0, 0, 0, pl.Duration * 1000)
+
   Print "Durata del file raw: "; Time(0, 0, 0, pl.Duration * 1000)
 
   Repeat
 
   Repeat
 
     Write "\r\e[0mTempo trascorso:    \e[31m" & Time(0, 0, 0, pl.Position * 1000)
 
     Write "\r\e[0mTempo trascorso:    \e[31m" & Time(0, 0, 0, pl.Position * 1000)
Riga 601: Riga 680:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
+
   pl.Stop
 +
  pl.Close
 
   
 
   
 +
  Print "\n\e[0mConversione terminata !"
 +
 +
End
 +
 +
 +
Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 +
 +
  bo = True
 +
 +
End
 +
 +
 +
===Conversione audio dal formato RAW al formato AAC===
 +
Private Const GST_AUDIO_FORMAT_S16LE As Integer = 4
 +
Private bo As Boolean
 +
 +
 +
Public Sub Main()
 +
 +
  Dim fileaudio As String
 +
  Dim pl As MediaPipeline
 +
  Dim src, raw, aac, snk As MediaControl
 +
  Dim flt As MediaFilter
 +
 +
  fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 +
 +
  pl = New MediaPipeline As "PLine"
 +
 +
  src = New MediaControl(pl, "filesrc")
 +
  src["location"] = fileaudio
 +
 
 +
  raw = New MediaControl(pl, "rawaudioparse")
 +
  raw["interleaved"] = True
 +
  raw["num-channels"] = 2
 +
  raw["pcm-format"] = GST_AUDIO_FORMAT_S16LE
 +
  raw["sample-rate"] = 44100
 +
  aac = New MediaControl(pl, "faac")  <FONT Color=gray>' ''oppure anche "'''voaacenc'''"''</font>
 +
  flt = New MediaFilter(pl, "audio/mpeg,stream-format=adts,channels=2,rate=44100")
 +
  snk = New MediaControl(pl, "filesink")
 +
  snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".aac"
 +
 +
  src.LinkTo(raw)
 +
  raw.LinkTo(aac)
 +
  aac.LinkTo(flt)
 +
  flt.LinkTo(snk)
 +
 +
  pl.Play()
 +
 +
  Print "Durata del file raw: "; Time(0, 0, 0, pl.Duration * 1000)
 +
  Repeat
 +
    Write "\r\e[0mTempo trascorso:    \e[31m" & Time(0, 0, 0, pl.Position * 1000)
 +
    Wait 0.01
 +
  Until bo
 +
 
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 611: Riga 745:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 624: Riga 758:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, flp, fld, wav, snk As MediaControl
 
   Dim src, flp, fld, wav, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
+
    
   appoggio = Temp
 
 
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
 
   
 
   
Riga 640: Riga 772:
 
   wav = New MediaControl(pl, "wavenc")
 
   wav = New MediaControl(pl, "wavenc")
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
   
 
   
 
   src.LinkTo(flp)
 
   src.LinkTo(flp)
Riga 657: Riga 789:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
+
    
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
 
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 668: Riga 798:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 683: Riga 813:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, flp, fld, lam, snk As MediaControl
 
   Dim src, flp, fld, lam, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
  appoggio = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 702: Riga 830:
 
   lam["bitrate"] = 192
 
   lam["bitrate"] = 192
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
   
 
   
 
   src.LinkTo(flp)
 
   src.LinkTo(flp)
Riga 719: Riga 847:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
 
  Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 730: Riga 856:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 743: Riga 869:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, flp, fld, cnv, vor, mux, snk As MediaControl
 
   Dim src, flp, fld, cnv, vor, mux, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
  appoggio = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 761: Riga 885:
 
   mux = New MediaControl(pl, "oggmux")
 
   mux = New MediaControl(pl, "oggmux")
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
   
 
   
 
   src.LinkTo(flp)
 
   src.LinkTo(flp)
Riga 780: Riga 904:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
+
    
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
 
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 791: Riga 913:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 804: Riga 926:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, temporaneo As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, aac, wav, snk As MediaControl
 
   Dim src, aac, wav, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aac''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aac''</font>"
 
  temporaneo = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 816: Riga 936:
 
   src = New MediaControl(pl, "filesrc")
 
   src = New MediaControl(pl, "filesrc")
 
   src["location"] = fileaudio
 
   src["location"] = fileaudio
   aac = New MediaControl(pl, "faad")
+
   aac = New MediaControl(pl, "faad")   <FONT Color=gray>' ''oppure anche "'''voaacenc'''"''</font>
 
   wav = New MediaControl(pl, "wavenc")
 
   wav = New MediaControl(pl, "wavenc")
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = temporaneo
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
   
 
   
   src.LinkTo(flp)
+
   src.LinkTo(aac)
   flp.LinkTo(fld)
+
   aac.LinkTo(wav)
  fld.LinkTo(wav)
 
 
   wav.LinkTo(snk)
 
   wav.LinkTo(snk)
 
   
 
   
Riga 836: Riga 955:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
+
    
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
 
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 847: Riga 964:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 862: Riga 979:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, temporaneo As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, aac, lam, snk As MediaControl
 
   Dim src, aac, lam, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aac''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aac''</font>"
 
  temporaneo = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 874: Riga 989:
 
   src = New MediaControl(pl, "filesrc")
 
   src = New MediaControl(pl, "filesrc")
 
   src["location"] = fileaudio
 
   src["location"] = fileaudio
   aac = New MediaControl(pl, "faad")
+
   aac = New MediaControl(pl, "faad")   <FONT Color=gray>' ''oppure anche "'''voaacenc'''"''</font>
 
   lam = New MediaControl(pl, "lamemp3enc")
 
   lam = New MediaControl(pl, "lamemp3enc")
 
   lam["target"] = BITRATE
 
   lam["target"] = BITRATE
Riga 880: Riga 995:
 
   lam["bitrate"] = 192
 
   lam["bitrate"] = 192
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = temporaneo
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
   
 
   
 
   src.LinkTo(aac)
 
   src.LinkTo(aac)
Riga 896: Riga 1 011:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
+
    
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
 
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 907: Riga 1 020:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 920: Riga 1 033:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, temporaneo As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, aac, cnv, vor, mux, snk As MediaControl
 
   Dim src, aac, cnv, vor, mux, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aac''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aac''</font>"
 
  temporaneo = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 932: Riga 1 043:
 
   src = New MediaControl(pl, "filesrc")
 
   src = New MediaControl(pl, "filesrc")
 
   src["location"] = fileaudio
 
   src["location"] = fileaudio
   aac = New MediaControl(pl, "faad")
+
   aac = New MediaControl(pl, "faad")   <FONT Color=gray>' ''oppure anche "'''voaacenc'''"''</font>
 
   cnv = New MediaControl(pl, "audioconvert")
 
   cnv = New MediaControl(pl, "audioconvert")
 
   vor = New MediaControl(pl, "vorbisenc")
 
   vor = New MediaControl(pl, "vorbisenc")
 
   mux = New MediaControl(pl, "oggmux")
 
   mux = New MediaControl(pl, "oggmux")
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = temporaneo
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
   
 
   
 
   src.LinkTo(aac)
 
   src.LinkTo(aac)
Riga 955: Riga 1 066:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
 +
 
 +
  pl.Stop
 +
  pl.Close
 
   
 
   
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
+
   Print "\n\e[0mConversione terminata !"
 +
 +
End
 +
 +
 +
Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 +
 +
  bo = True
 +
 +
End
 +
 
 +
 
 +
===Conversione audio dal formato AAC al formato RAW===
 +
Private bo As Boolean
 +
 +
 +
Public Sub Main()
 +
 +
  Dim fileaudio As String
 +
  Dim pl As MediaPipeline
 +
  Dim src, aac, snk As MediaControl
 +
  Dim flt As MediaFilter
 +
 +
  fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aac''</font>"
 +
 +
  pl = New MediaPipeline As "PLine"
 +
 +
  src = New MediaControl(pl, "filesrc")
 +
  src["location"] = fileaudio
 +
  aac = New MediaControl(pl, "faad")  <FONT Color=gray>' ''oppure anche "'''voaacenc'''"''</font>
 +
  flt = New MediaFilter(pl, "audio/x-raw, format=S16LE, rate=44100, channels=2, endianness=1234, width=16, depth=16")
 +
  snk = New MediaControl(pl, "filesink")
 +
  snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".raw"
 +
 +
  src.LinkTo(aac)
 +
  aac.LinkTo(flt)
 +
  flt.LinkTo(snk)
 +
 +
  pl.Play()
 +
 +
  While pl.Duration < 1
 +
    Wait 0.01
 +
  Wend
 +
  Print "Durata del file aac: "; Time(0, 0, 0, pl.Duration * 1000)
 +
  Repeat
 +
    Write "\r\e[0mTempo trascorso:    \e[31m" & Time(0, 0, 0, pl.Position * 1000)
 +
    Wait 0.01
 +
  Until bo
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 966: Riga 1 127:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 979: Riga 1 140:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, temporaneo As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, aif, cnv, wav, snk As MediaControl
 
   Dim src, aif, cnv, wav, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aiff''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aiff''</font>"
 
  temporaneo = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 995: Riga 1 154:
 
   wav = New MediaControl(pl, "wavenc")
 
   wav = New MediaControl(pl, "wavenc")
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = temporaneo
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
   
 
   
 
   src.LinkTo(aif)
 
   src.LinkTo(aif)
Riga 1 012: Riga 1 171:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
+
    
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
 
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 1 023: Riga 1 180:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 1 038: Riga 1 195:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, temporaneo As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, aif, cnv, lam, snk As MediaControl
 
   Dim src, aif, cnv, lam, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aiff''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aiff''</font>"
 
  temporaneo = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 1 057: Riga 1 212:
 
   lam["bitrate"] = 192
 
   lam["bitrate"] = 192
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = temporaneo
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
   
 
   
 
   src.LinkTo(aif)
 
   src.LinkTo(aif)
Riga 1 074: Riga 1 229:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
+
    
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
 
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 1 085: Riga 1 238:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 1 098: Riga 1 251:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, temporaneo As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, aif, cnv, vor, mux, snk As MediaControl
 
   Dim src, aif, cnv, vor, mux, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aiff''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/aiff''</font>"
+
    
   temporaneo = Temp
 
 
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
 
   
 
   
Riga 1 115: Riga 1 266:
 
   mux = New MediaControl(pl, "oggmux")
 
   mux = New MediaControl(pl, "oggmux")
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = temporaneo
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
   
 
   
 
   src.LinkTo(aif)
 
   src.LinkTo(aif)
Riga 1 133: Riga 1 284:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
 
  Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 1 144: Riga 1 293:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 1 160: Riga 1 309:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, dcb, con, flt, wav, snk As MediaControl
 
   Dim src, dcb, con, flt, wav, snk As MediaControl
 
   
 
   
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.ogg''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.ogg''</font>"
 
  appoggio = Temp
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 1 178: Riga 1 325:
 
   wav = New MediaControl(pl, "<FONT Color=#B22222>wavenc</font>")
 
   wav = New MediaControl(pl, "<FONT Color=#B22222>wavenc</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
 
   snk = New MediaControl(pl, "<FONT Color=#B22222>filesink</font>")
   snk["location"] = appoggio
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
    
 
    
 
   src.LinkTo(dcb)
 
   src.LinkTo(dcb)
 
   dcb.LinkLaterTo(con)
 
   dcb.LinkLaterTo(con)
   con.LinkTo(fil)
+
   con.LinkTo(flt)
   fil.LinkTo(wav)
+
   flt.LinkTo(wav)
 
   wav.LinkTo(snk)
 
   wav.LinkTo(snk)
 
   
 
   
Riga 1 193: Riga 1 340:
 
     Wait 0.01
 
     Wait 0.01
 
   Until bo
 
   Until bo
 
  Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 1 204: Riga 1 349:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
Riga 1 217: Riga 1 362:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
 +
  Dim fileaudio As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, dcb, con, res, flt, wav, snk As MediaControl
 
   Dim src, dcb, con, res, flt, wav, snk As MediaControl
  Dim temporaneo, fileaudio As String
+
 
+
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
  temporaneo = Temp
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/audio/da/covertire''</font>"
 
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 1 234: Riga 1 378:
 
   wav = New MediaFilter(pl, "wavenc")
 
   wav = New MediaFilter(pl, "wavenc")
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = temporaneo
+
   snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 +
 
   src.LinkTo(dcb)
 
   src.LinkTo(dcb)
 
   dcb.LinkLaterTo(con)
 
   dcb.LinkLaterTo(con)
Riga 1 253: Riga 1 398:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
+
   pl.Stop
 
 
   pl.Close
 
   pl.Close
 
   
 
   
Riga 1 262: Riga 1 406:
 
   
 
   
 
   
 
   
  Public Sub PLine_End()
+
  Public Sub PLine_End() <FONT Color=gray>' ''Questo Evento viene sollevato, quando la conversione è terminata''</font>
 
   
 
   
 
   bo = True
 
   bo = True
 
   
 
   
 
  End
 
  End

Versione attuale delle 17:43, 17 gen 2024

Utilizzando i plugin di GStreamer con le Classi MediaControl e MediaPipeline del Componente gb.media, è possibile effettuare diverse conversioni di file audio da un formato ad un altro.

Mostriamo di seguito qualche esempio pratico.

Conversione audio dal formato WAV al formato MP3

Private Const QUALITY As String = "quality"
Private Const BITRATE As String = "bitrate"
Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, wprs, cnv, lam, snk As MediaControl

 fileaudio = "/percorso/del/file.wav"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio

 wprs = New MediaControl(pl, "wavparse")
 cnv = New MediaControl(pl, "audioconvert")
 lam = New MediaControl(pl, "lamemp3enc")
 lam["target"] = BITRATE    ' Imposta il Bitrate.
 lam["cbr"] = True          ' Imposta il Bitrate "Costante".
 lam["bitrate"] = 192       ' Imposta il valore del Bitrate "Costante".
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
' Collega fra loro all'interno della pipeline gli oggetti MediaControl impostati:
 src.LinkTo(wprs)
 wprs.LinkTo(cnv)
 cnv.LinkTo(lam)
 lam.LinkTo(snk)

 pl.Play()
 
 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file wav: "; Time(0, 0, 0, pl.Duration * 1000)

 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

' E' necessario prevedere sia il Metodo ".Stop" che il Metodo ".Close" della Classe "MediaPipeline", per evitare di ottenere un file audio vuoto:
 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato WAV al formato OGG

Private bo As Boolean


Public Sub Main()
 
 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, wprs, cnv, vor, mux, snk As MediaControl

 fileaudio = "/percorso/del/file.wav"
 
 pl = New MediaPipeline As "PLine"
  
 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 
 wprs = New MediaControl(pl, "wavparse")
 cnv = New MediaControl(pl, "audioconvert")
 vor = New MediaControl(pl, "vorbisenc")
 mux = New MediaControl(pl, "oggmux")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
 src.LinkTo(wprs)
 wprs.LinkTo(cnv)
 cnv.LinkTo(vor)
 vor.LinkTo(mux)
 mux.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file wav: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato WAV al formato AAC

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, wav, cnv, aac, snk As MediaControl
 Dim flt As MediaFilter

 fileaudio = "/percorso/del/file.wav"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio

 wav = New MediaControl(pl, "wavparse")
 cnv = New MediaControl(pl, "audioconvert")
 aac = New MediaControl(pl, "faac")   ' oppure anche "voaacenc"
 flt = New MediaFilter(pl, "audio/mpeg,stream-format=adts,channels=2,rate=44100")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".aac"
 
 src.LinkTo(wav)
 wav.LinkTo(cnv)
 cnv.LinkTo(aac)
 aac.LinkTo(flt)
 flt.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file wav: "; Time(0, 0, 0, pl.Duration * 1000)

 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato MP3 al formato OGG

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, map, mad, vor, mux, snk As MediaControl

 fileaudio = "/percorso/del/file.mp3"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio

 map = New MediaControl(pl, "mpegaudioparse")
 mad = New MediaControl(pl, "mpg123audiodec")
 vor = New MediaControl(pl, "vorbisenc")
 mux = New MediaControl(pl, "oggmux")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"

 src.LinkTo(map)
 map.LinkTo(mad)
 mad.LinkTo(vor)
 vor.LinkTo(mux)
 mux.LinkTo(snk)
 
 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file mp3: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato MP3 al formato WAV

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, map, mad, wav, snk As MediaControl

 fileaudio = "/percorso/del/file.mp3"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio

 map = New MediaControl(pl, "mpegaudioparse")
 mad = New MediaControl(pl, "mpg123audiodec")
 wav = New MediaControl(pl, "wavenc")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 src.LinkTo(map)
 map.LinkTo(mad)
 mad.LinkTo(wav)
 wav.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file mp3: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato MP3 al formato AAC

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, map, mad, aac, snk As MediaControl
 Dim flt As MediaFilter

 fileaudio = "/percorso/del/file.mp3"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 map = New MediaControl(pl, "mpegaudioparse")
 mad = New MediaControl(pl, "mpg123audiodec")
 aac = New MediaControl(pl, "faac")   ' oppure anche "voaacenc"
 flt = New MediaFilter(pl, "audio/mpeg,stream-format=adts,channels=2,rate=44100")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".aac"
 
 src.LinkTo(map)
 map.LinkTo(mad)
 mad.LinkTo(aac)
 aac.LinkTo(flt)
 flt.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file wav: "; Time(0, 0, 0, pl.Duration * 1000)

 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato MP3 al formato RAW

Con il seguente codice si otterranno da un file MP3 i dati audio grezzi nel formato: frequenza di campionamento = 44100, risoluzione = 16 bit, canali = 2.

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, par, dcd, snk As MediaControl
 Dim flt As MediaFilter

 fileaudio = "/percorso/del/file.mp3"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio

 par = New MediaControl(pl, "mpegaudioparse")
 dcd = New MediaControl(pl, "mpg123audiodec")
 flt = New MediaFilter(pl, "audio/x-raw, format=S16LE, rate=44100, channels=2, endianness=1234, width=16, depth=16")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".raw"

 src.LinkTo(par)
 par.LinkTo(dcd)
 dcd.LinkTo(flt)
 flt.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file mp3: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo
 
 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True
  
End


Conversione audio dal formato OGG-Vorbis al formato MP3

Private Const QUALITY As String = "quality"
Private Const BITRATE As String = "bitrate"
Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, ogg, vor, cnv, lam, snk As MediaControl

 fileaudio = "/percorso/del/file.ogg"
 
 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio

 ogg = New MediaControl(pl, "oggdemux")
 vor = New MediaControl(pl, "vorbisdec")
 cnv = New MediaControl(pl, "audioconvert")
 lam = New MediaControl(pl, "lamemp3enc")
 lam["target"] = BITRATE    ' Imposta il Bitrate.
 lam["cbr"] = True          ' Imposta il Bitrate "Costante".
 lam["bitrate"] = 192       ' Imposta il valore del Bitrate "Costante".
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 src.LinkTo(ogg)
 ogg.LinkLaterTo(vor)
 vor.LinkTo(cnv)
 cnv.LinkTo(lam)
 lam.LinkTo(snk)

 pl.Play()

 Print "Durata del file ogg: "; Time(0, 0, 0, pl.Duration * 1000)

 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato OGG-Vorbis al formato AAC

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, ogg, vor, con, aac, snk As MediaControl
 Dim flt As MediaFilter

 fileaudio = "/percorso/del/file.ogg"
 
 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 ogg = New MediaControl(pl, "oggdemux")
 vor = New MediaControl(pl, "vorbisdec")
 con = New MediaControl(pl, "audioconvert")
 aac = New MediaControl(pl, "faac")   ' oppure anche "voaacenc"
 flt = New MediaFilter(pl, "audio/mpeg,stream-format=adts,channels=2,rate=44100")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".acc"

 src.LinkTo(ogg)
 ogg.LinkLaterTo(vor)
 vor.LinkTo(con)
 con.LinkTo(aac)
 aac.LinkTo(flt)
 flt.LinkTo(snk)

 pl.Play()

 Print "Durata del file ogg: "; Time(0, 0, 0, pl.Duration * 1000)

 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato RAW al formato WAV

Il seguente codice prevede che i dati del file audio RAW abbiano le seguenti caratteristiche: frequenza di campionamento = 44100; numero di canali = 2; modalità interleaved e formato-pcm = S16LE.

Private Const GST_AUDIO_FORMAT_S16LE As Integer = 4
Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, raw, wav, snk As MediaControl

 fileaudio = "/percorso/del/file/raw"
 
 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 
 raw = New MediaControl(pl, "rawaudioparse")
 raw["interleaved"] = True
 raw["num-channels"] = 2
 raw["pcm-format"] = GST_AUDIO_FORMAT_S16LE
 raw["sample-rate"] = 44100
 wav = New MediaControl(pl, "wavenc")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 src.LinkTo(raw)
 raw.LinkTo(wav)
 wav.LinkTo(snk)

 pl.Play()

 Print "Durata del file raw: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato RAW al formato MP3

Private Const GST_AUDIO_FORMAT_S16LE As Integer = 4
Private Const QUALITY As String = "quality"
Private Const BITRATE As String = "bitrate"
Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, raw, lam, snk As MediaControl

 fileaudio = "/percorso/del/file/raw"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 
 raw = New MediaControl(pl, "rawaudioparse")
 raw["interleaved"] = True
 raw["num-channels"] = 2
 raw["pcm-format"] = GST_AUDIO_FORMAT_S16LE
 raw["sample-rate"] = 44100
 lam = New MediaControl(pl, "lamemp3enc")
 lam["target"] = BITRATE    ' Imposta il Bitrate
 lam["cbr"] = True          ' Imposta il Bitrate "Costante"
 lam["bitrate"] = 192       ' Imposta il valore del Bitrate "Costante"
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 src.LinkTo(raw)
 raw.LinkTo(lam)
 lam.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file raw: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato RAW al formato OGG-Vorbis

Private Const GST_AUDIO_FORMAT_S16LE As Integer = 4
Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, raw, cnv, vor, mux, snk As MediaControl

 fileaudio = "/percorso/del/file/raw"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 
 raw = New MediaControl(pl, "rawaudioparse")
 raw["interleaved"] = True
 raw["num-channels"] = 2
 raw["pcm-format"] = GST_AUDIO_FORMAT_S16LE
 raw["sample-rate"] = 44100
 cnv = New MediaControl(pl, "audioconvert")
 vor = New MediaControl(pl, "vorbisenc")
 mux = New MediaControl(pl, "oggmux")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"

 src.LinkTo(raw)
 raw.LinkTo(cnv)
 cnv.LinkTo(vor)
 vor.LinkTo(mux)
 mux.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file raw: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato RAW al formato AAC

Private Const GST_AUDIO_FORMAT_S16LE As Integer = 4
Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, raw, aac, snk As MediaControl
 Dim flt As MediaFilter

 fileaudio = "/percorso/del/file/raw"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 
 raw = New MediaControl(pl, "rawaudioparse")
 raw["interleaved"] = True
 raw["num-channels"] = 2
 raw["pcm-format"] = GST_AUDIO_FORMAT_S16LE
 raw["sample-rate"] = 44100
 aac = New MediaControl(pl, "faac")   ' oppure anche "voaacenc"
 flt = New MediaFilter(pl, "audio/mpeg,stream-format=adts,channels=2,rate=44100")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".aac"

 src.LinkTo(raw)
 raw.LinkTo(aac)
 aac.LinkTo(flt)
 flt.LinkTo(snk)

 pl.Play()

 Print "Durata del file raw: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo
 
 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato FLAC al formato WAV

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, flp, fld, wav, snk As MediaControl

 fileaudio = "/percorso/del/file/flac"
 
 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 flp = New MediaControl(pl, "flacparse")
 fld = New MediaControl(pl, "flacdec")
 wav = New MediaControl(pl, "wavenc")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 src.LinkTo(flp)
 flp.LinkTo(fld)
 fld.LinkTo(wav)
 wav.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file Flac: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo
 
 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato FLAC al formato MP3

Private Const QUALITY As String = "quality"
Private Const BITRATE As String = "bitrate"
Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, flp, fld, lam, snk As MediaControl

 fileaudio = "/percorso/del/file/flac"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 flp = New MediaControl(pl, "flacparse")
 fld = New MediaControl(pl, "flacdec")
 lam = New MediaControl(pl, "lamemp3enc")
 lam["target"] = BITRATE
 lam["cbr"] = True
 lam["bitrate"] = 192
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 src.LinkTo(flp)
 flp.LinkTo(fld)
 fld.LinkTo(lam)
 lam.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file Flac: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato FLAC al formato OGG-Vorbis

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, flp, fld, cnv, vor, mux, snk As MediaControl

 fileaudio = "/percorso/del/file/flac"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 flp = New MediaControl(pl, "flacparse")
 fld = New MediaControl(pl, "flacdec")
 cnv = New MediaControl(pl, "audioconvert")
 vor = New MediaControl(pl, "vorbisenc")
 mux = New MediaControl(pl, "oggmux")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"

 src.LinkTo(flp)
 flp.LinkTo(fld)
 fld.LinkTo(cnv)
 cnv.LinkTo(vor)
 vor.LinkTo(mux)
 mux.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file flac: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo
 
 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato AAC al formato WAV

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, aac, wav, snk As MediaControl

 fileaudio = "/percorso/del/file/aac"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 aac = New MediaControl(pl, "faad")   ' oppure anche "voaacenc"
 wav = New MediaControl(pl, "wavenc")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 src.LinkTo(aac)
 aac.LinkTo(wav)
 wav.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file aac: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo
 
 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato AAC al formato MP3

Private Const QUALITY As String = "quality"
Private Const BITRATE As String = "bitrate"
Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, aac, lam, snk As MediaControl

 fileaudio = "/percorso/del/file/aac"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 aac = New MediaControl(pl, "faad")   ' oppure anche "voaacenc"
 lam = New MediaControl(pl, "lamemp3enc")
 lam["target"] = BITRATE
 lam["cbr"] = True
 lam["bitrate"] = 192
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 src.LinkTo(aac)
 aac.LinkTo(lam)
 lam.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file Acc: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo
 
 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato AAC al formato OGG-Vorbis

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, aac, cnv, vor, mux, snk As MediaControl

 fileaudio = "/percorso/del/file/aac"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 aac = New MediaControl(pl, "faad")   ' oppure anche "voaacenc"
 cnv = New MediaControl(pl, "audioconvert")
 vor = New MediaControl(pl, "vorbisenc")
 mux = New MediaControl(pl, "oggmux")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"

 src.LinkTo(aac)
 aac.LinkTo(cnv)
 cnv.LinkTo(vor)
 vor.LinkTo(mux)
 mux.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file aac: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo
 
 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato AAC al formato RAW

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, aac, snk As MediaControl
 Dim flt As MediaFilter

 fileaudio = "/percorso/del/file/aac"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 aac = New MediaControl(pl, "faad")   ' oppure anche "voaacenc"
 flt = New MediaFilter(pl, "audio/x-raw, format=S16LE, rate=44100, channels=2, endianness=1234, width=16, depth=16")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".raw"

 src.LinkTo(aac)
 aac.LinkTo(flt)
 flt.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file aac: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato AIFF al formato WAV

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, aif, cnv, wav, snk As MediaControl

 fileaudio = "/percorso/del/file/aiff"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 aif = New MediaControl(pl, "aiffparse")
 cnv = New MediaControl(pl, "audioconvert")
 wav = New MediaControl(pl, "wavenc")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 src.LinkTo(aif)
 aif.LinkTo(cnv)
 cnv.LinkTo(wav)
 wav.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file aiff: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo
 
 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato AIFF al formato MP3

Private Const QUALITY As String = "quality"
Private Const BITRATE As String = "bitrate"
Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, aif, cnv, lam, snk As MediaControl

 fileaudio = "/percorso/del/file/aiff"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 aac = New MediaControl(pl, "aiffparse")
 cnv = New MediaControl(pl, "audioconvert")
 lam = New MediaControl(pl, "lamemp3enc")
 lam["target"] = BITRATE
 lam["cbr"] = True
 lam["bitrate"] = 192
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 src.LinkTo(aif)
 aif.LinkTo(cnv)
 cnv.LinkTo(lam)
 lam.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file aiff: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo
 
 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio dal formato AIFF al formato OGG-Vorbis

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, aif, cnv, vor, mux, snk As MediaControl

 fileaudio = "/percorso/del/file/aiff"
 
 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 aac = New MediaControl(pl, "aiffparse")
 cnv = New MediaControl(pl, "audioconvert")
 vor = New MediaControl(pl, "vorbisenc")
 mux = New MediaControl(pl, "oggmux")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".ogg"

 src.LinkTo(aif)
 aif.LinkTo(cnv)
 cnv.LinkTo(vor)
 vor.LinkTo(mux)
 mux.LinkTo(snk)

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file aiff: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End


Conversione audio con il plugin "decodebin"

Usando il plugin "decodebin" è possibile convertire qualsiasi formato audio in un altro desiderato.
Mostriamo un esempio, nel quale sarà convertito un file audio "OGG" in un file audio "WAV", avente il seguente formato: frequenza di campionamento = 44100, risoluzione = 16 bit, canali = 2.

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, dcb, con, flt, wav, snk As MediaControl

 fileaudio = "/percorso/del/file.ogg"

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio

 dcb = New MediaControl(pl, "decodebin")
 con = New MediaControl(pl, "audioconvert")
 flt = New MediaFilter(pl, "audio/x-raw, format=S16LE, rate=44100, channels=2, depth=16")
 wav = New MediaControl(pl, "wavenc")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
 src.LinkTo(dcb)
 dcb.LinkLaterTo(con)
 con.LinkTo(flt)
 flt.LinkTo(wav)
 wav.LinkTo(snk)

 pl.Play()

 Print "Durata del file ogg: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
   Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True
  
End

Se si vuole convertire in un file avente caratteristiche (frequenza di campionamento, numero dei canali, risoluzione in bit) dei propri campioni audio diverse da quelle del file originario, da convertire, allora si dovranno usare l'elemento "audioresample" e la Classe MediaFilter.

Mostriamo un esempio pratico, nel quale si convertirà un file MP3 in un file WAV avente frequenza di campionamento uguale a 22050 hertz e risoluzione a 8 bit:

Private bo As Boolean


Public Sub Main()

 Dim fileaudio As String
 Dim pl As MediaPipeline
 Dim src, dcb, con, res, flt, wav, snk As MediaControl

 fileaudio = "/percorso/del/file.mp3"

 pl = New MediaPipeline As "PLine"
  
 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 dcb = New MediaControl(pl, "decodebin")
 con = New MediaControl(pl, "audioconvert")
 res = New MediaControl(pl, "audioresample") ' Consente di modificare le caratteristiche del file audio
 flt = New MediaFilter(pl, "audio/x-raw,rate=22050,format=U8")
 wav = New MediaFilter(pl, "wavenc")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 src.LinkTo(dcb)
 dcb.LinkLaterTo(con)
 con.LinkTo(res)
 res.LinkTo(flt)
 flt.LinkTo(wav)
 wav.LinkTo(snk)
 
 pl.play

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file mp3: "; Time(0, 0, 0, pl.Duration * 1000)
 Repeat
 Write "\r\e[0mTempo trascorso:     \e[31m" & Time(0, 0, 0, pl.Position * 1000)
   Wait 0.01
 Until bo

 pl.Stop
 pl.Close

 Print "\n\e[0mConversione terminata !"

End


Public Sub PLine_End() ' Questo Evento viene sollevato, quando la conversione è terminata

 bo = True

End