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

Da Gambas-it.org - Wikipedia.
Riga 74: Riga 74:
 
  Public Sub Main()
 
  Public Sub Main()
 
    
 
    
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo 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
Riga 80: Riga 80:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.wav''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.wav''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 92: Riga 92:
 
   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"] = temporaneo
 
    
 
    
 
   src.LinkTo(wprs)
 
   src.LinkTo(wprs)
Riga 111: Riga 111:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
   pl.Stop
 
   pl.Stop
 
   pl.Close
 
   pl.Close
Riga 133: Riga 133:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, wav, cnv, faac, snk As MediaControl
 
   Dim src, wav, cnv, faac, snk As MediaControl
Riga 140: Riga 140:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.wav''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.wav''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 152: Riga 152:
 
   flt = New MediaFilter(pl, "audio/mpeg,stream-format=adts,channels=2,rate=44100")
 
   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"] = temporaneo
 
    
 
    
 
   src.LinkTo(wav)
 
   src.LinkTo(wav)
Riga 172: Riga 172:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".aac"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".aac"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 195: Riga 195:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo 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
Riga 201: Riga 201:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 213: Riga 213:
 
   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"] = temporaneo
 
    
 
    
 
   src.LinkTo(map)
 
   src.LinkTo(map)
Riga 232: Riga 232:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 255: Riga 255:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo 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 261:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 272: Riga 272:
 
   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"] = temporaneo
 
    
 
    
 
   src.LinkTo(map)
 
   src.LinkTo(map)
Riga 290: Riga 290:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 314: Riga 314:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, par, dcd, snk As MediaControl
 
   Dim src, par, dcd, snk As MediaControl
Riga 321: Riga 321:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.mp3''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 332: Riga 332:
 
   fil = New MediaFilter(pl, "<FONT Color=#B22222>audio/x-raw, format=S16LE, rate=44100, channels=2, endianness=1234, width=16, depth=16</font>")
 
   fil = 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"] = temporaneo
 
   
 
   
 
   src.LinkTo(par)
 
   src.LinkTo(par)
Riga 350: Riga 350:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".raw"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".raw"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 375: Riga 375:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo 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
Riga 381: Riga 381:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.ogg''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.ogg''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 396: Riga 396:
 
   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"] = temporaneo
 
   
 
   
 
   src.LinkTo(ogg)
 
   src.LinkTo(ogg)
Riga 413: Riga 413:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 438: Riga 438:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, raw, wav, snk As MediaControl
 
   Dim src, raw, wav, snk As MediaControl
Riga 444: Riga 444:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 458: Riga 458:
 
   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"] = temporaneo
 
   
 
   
 
   src.LinkTo(raw)
 
   src.LinkTo(raw)
Riga 472: Riga 472:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 497: Riga 497:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo As String
 
   Dim pl As MediaPipeline
 
   Dim pl As MediaPipeline
 
   Dim src, raw, lam, snk As MediaControl
 
   Dim src, raw, lam, snk As MediaControl
Riga 503: Riga 503:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 520: Riga 520:
 
   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"] = temporaneo
 
   
 
   
 
   src.LinkTo(raw)
 
   src.LinkTo(raw)
Riga 537: Riga 537:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 560: Riga 560:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo 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
Riga 566: Riga 566:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/raw''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 582: Riga 582:
 
   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"] = temporaneo
 
   
 
   
 
   src.LinkTo(raw)
 
   src.LinkTo(raw)
Riga 601: Riga 601:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 624: Riga 624:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo 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
Riga 630: Riga 630:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 640: Riga 640:
 
   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"] = temporaneo
 
   
 
   
 
   src.LinkTo(flp)
 
   src.LinkTo(flp)
Riga 658: Riga 658:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 683: Riga 683:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo 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
Riga 689: Riga 689:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 702: Riga 702:
 
   lam["bitrate"] = 192
 
   lam["bitrate"] = 192
 
   snk = New MediaControl(pl, "filesink")
 
   snk = New MediaControl(pl, "filesink")
   snk["location"] = appoggio
+
   snk["location"] = temporaneo
 
   
 
   
 
   src.LinkTo(flp)
 
   src.LinkTo(flp)
Riga 720: Riga 720:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 743: Riga 743:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo 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
Riga 749: Riga 749:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file/flac''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 761: Riga 761:
 
   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"] = temporaneo
 
   
 
   
 
   src.LinkTo(flp)
 
   src.LinkTo(flp)
Riga 781: Riga 781:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 
   
 
   
 
   pl.Stop
 
   pl.Stop
Riga 1 160: Riga 1 160:
 
  Public Sub Main()
 
  Public Sub Main()
 
   
 
   
   Dim fileaudio, appoggio As String
+
   Dim fileaudio, temporaneo 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
Riga 1 166: Riga 1 166:
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.ogg''</font>"
 
   fileaudio = "<FONT Color=darkgreen>''/percorso/del/file.ogg''</font>"
 
   
 
   
   appoggio = Temp
+
   temporaneo = Temp
 
   
 
   
 
   pl = New MediaPipeline As "PLine"
 
   pl = New MediaPipeline As "PLine"
Riga 1 178: Riga 1 178:
 
   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"] = temporaneo
 
    
 
    
 
   src.LinkTo(dcb)
 
   src.LinkTo(dcb)
Riga 1 194: Riga 1 194:
 
   Until bo
 
   Until bo
 
   
 
   
   Copy appoggio To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
+
   Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"
 
   
 
   
 
   pl.Stop
 
   pl.Stop

Versione delle 09:07, 13 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, temporaneo As String
 Dim pl As MediaPipeline
 Dim src, wprs, cnv, lam, snk As MediaControl

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

 temporaneo = Temp

 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"] = temporaneo
 
' 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 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, temporaneo As String
 Dim pl As MediaPipeline
 Dim src, wprs, cnv, vor, mux, snk As MediaControl

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

 temporaneo = Temp

 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"] = temporaneo
 
 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"
 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End


Conversione audio dal formato WAV al formato AAC

Private bo As Boolean


Public Sub Main()

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

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

 temporaneo = Temp

 pl = New MediaPipeline As "PLine"

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

 wav = New MediaControl(pl, "wavparse")
 cnv = New MediaControl(pl, "audioconvert")
 faac = 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"] = temporaneo
 
 src.LinkTo(wav)
 wav.LinkTo(cnv)
 cnv.LinkTo(faac)
 faac.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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".aac"

 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, temporaneo As String
 Dim pl As MediaPipeline
 Dim src, map, mad, vor, mux, snk As MediaControl

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

 temporaneo = Temp

 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"] = temporaneo
 
 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End


Conversione audio dal formato MP3 al formato WAV

Private bo As Boolean


Public Sub Main()

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

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

 temporaneo = Temp

 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"] = temporaneo
 
 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 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, temporaneo As String
 Dim pl As MediaPipeline
 Dim src, par, dcd, snk As MediaControl
 Dim fil As MediaFilter

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

 temporaneo = Temp

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 
 par = New MediaControl(pl, "mpegaudioparse")
 dcd = New MediaControl(pl, "mpg123audiodec")
 fil = 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"] = temporaneo

 src.LinkTo(par)
 par.LinkTo(dcd)
 dcd.LinkTo(fil)
 fil.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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".raw"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 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, temporaneo As String
 Dim pl As MediaPipeline
 Dim src, ogg, vor, cnv, lam, snk As MediaControl

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

 temporaneo = Temp

 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"] = temporaneo

 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 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, temporaneo As String
 Dim pl As MediaPipeline
 Dim src, raw, wav, snk As MediaControl

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

 temporaneo = Temp

 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"] = temporaneo

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

 pl.Play()

 Print "Durata del file wav finale: "; 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End


Conversione audio dal formato RAW al formato MP3

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


Public Sub Main()

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

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

 temporaneo = Temp

 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"] = temporaneo

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

 pl.Play()

 While pl.Duration < 1
   Wait 0.01
 Wend
 Print "Durata del file mp3 finale: "; 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End


Conversione audio dal formato RAW al formato OGG-Vorbis

Private bo As Boolean


Public Sub Main()

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

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

 temporaneo = Temp

 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"] = temporaneo

 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 ogg finale: "; 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End


Conversione audio dal formato FLAC al formato WAV

Private bo As Boolean


Public Sub Main()

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

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

 temporaneo = Temp

 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"] = temporaneo

 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 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, temporaneo As String
 Dim pl As MediaPipeline
 Dim src, flp, fld, lam, snk As MediaControl

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

 temporaneo = Temp

 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"] = temporaneo

 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End


Conversione audio dal formato FLAC al formato OGG-Vorbis

Private bo As Boolean


Public Sub Main()

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

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

 temporaneo = Temp

 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"] = temporaneo

 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End


Conversione audio dal formato AAC al formato WAV

Private bo As Boolean


Public Sub Main()

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

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

 temporaneo = Temp

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 aac = New MediaControl(pl, "faad")
 wav = New MediaControl(pl, "wavenc")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = temporaneo

 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 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 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, temporaneo As String
 Dim pl As MediaPipeline
 Dim src, aac, lam, snk As MediaControl

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

 temporaneo = Temp

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 aac = New MediaControl(pl, "faad")
 lam = New MediaControl(pl, "lamemp3enc")
 lam["target"] = BITRATE
 lam["cbr"] = True
 lam["bitrate"] = 192
 snk = New MediaControl(pl, "filesink")
 snk["location"] = temporaneo

 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End


Conversione audio dal formato AAC al formato OGG-Vorbis

Private bo As Boolean


Public Sub Main()

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

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

 temporaneo = Temp

 pl = New MediaPipeline As "PLine"

 src = New MediaControl(pl, "filesrc")
 src["location"] = fileaudio
 aac = New MediaControl(pl, "faad")
 cnv = New MediaControl(pl, "audioconvert")
 vor = New MediaControl(pl, "vorbisenc")
 mux = New MediaControl(pl, "oggmux")
 snk = New MediaControl(pl, "filesink")
 snk["location"] = temporaneo

 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End


Conversione audio dal formato AIFF al formato WAV

Private bo As Boolean


Public Sub Main()

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

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

 temporaneo = Temp

 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"] = temporaneo

 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 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, temporaneo As String
 Dim pl As MediaPipeline
 Dim src, aif, cnv, lam, snk As MediaControl

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

 temporaneo = Temp

 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"] = temporaneo

 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".mp3"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End


Conversione audio dal formato AIFF al formato OGG-Vorbis

Private bo As Boolean


Public Sub Main()

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

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

 temporaneo = Temp

 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"] = temporaneo

 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".ogg"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 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, temporaneo As String
 Dim pl As MediaPipeline
 Dim src, dcb, con, flt, wav, snk As MediaControl

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

 temporaneo = Temp

 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"] = temporaneo
 
 src.LinkTo(dcb)
 dcb.LinkLaterTo(con)
 con.LinkTo(fil)
 fil.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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 pl.Stop
 pl.Close

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

End


Public Sub PLine_End()

 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 pl As MediaPipeline
 Dim src, dcb, con, res, flt, wav, snk As MediaControl
 Dim temporaneo, fileaudio As String
 
 temporaneo = Temp
 fileaudio = "/percorso/del/file/audio/da/covertire"

 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"] = temporaneo
 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

 Copy temporaneo To "/tmp" &/ File.BaseName(fileaudio) & ".wav"

 pl.Close

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

End


Public Sub PLine_End()

 bo = True

End