|
|
(12 versioni intermedie di uno stesso utente non sono mostrate) |
Riga 1: |
Riga 1: |
− | Per rilevare in tempo reale la quantità di frame audio processati dalla scheda audio, si verificherà in continuazione il valore associato all'elemento "''hw_ptr''" nel file "''/proc/asound/card.../pcm...p/sub0/status''".
| + | #REDIRECT [[Conoscere_in_tempo_reale_la_quantità_di_frame_audio_processati_dalla_scheda_audio]] |
− | | |
− | In particolare il driver ALSA aggiorna "''hw_ptr''" dopo aver copiato un frame nel framework ALSA.
| |
− | | |
− | Mentre un qualunque programma sta eseguendo un file audio o Midi, è possibile lanciare il codice sottostante:
| |
− | '''Public''' Sub Main()
| |
− |
| |
− | Dim s, pr, dis As String
| |
− | Dim fl As File
| |
− | Dim i, hz, fr, mid As Integer
| |
− | Dim can, bla, bit As Short
| |
− |
| |
− | s = "<FONT Color=gray>''/percorso/del/file''</font>"
| |
− | Print "File audio: "; s
| |
− |
| |
− | fl = Open s For Read
| |
− | i = Lof(fl)
| |
− | Read #fl, mid
| |
− | If mid == 1684558925 Then
| |
− | Print "Dimensione: "; i; " byte"
| |
− | i = 2147483647
| |
− | can = 2
| |
− | hz = 44100
| |
− | bla = 4
| |
− | bit = 16
| |
− | Else
| |
− | i -= 44
| |
− | Print "Dati audio: "; i; " byte"
| |
− | Seek fl, InStr(fl.Load(s), "fmt ") + 9
| |
− | Read #fl, can
| |
− | Print "Canali: "; can
| |
− | Read #fl, hz
| |
− | Print "Frequenza: "; hz
| |
− | Seek #fl, 32
| |
− | Read #fl, bla
| |
− | i /= bla
| |
− | pr = CStr(i)
| |
− | Read #fl, bit
| |
− | Print "Risoluzione: "; bit; " bit"
| |
− | Endif
| |
− | fl.Close
| |
− |
| |
− | dis = DispositivoAttivo()
| |
− |
| |
− | Print
| |
− | Repeat
| |
− | s = File.Load("/proc/asound/card" & dis &/ "sub0/status")
| |
− | If s == "closed\n" Then Break
| |
− | fr = Val(Scan(s, "*hw_ptr*: *\n*")[2])
| |
− | Write "\r\e[0mFrame da processare: " & pr & " | Frame processati: \e[34m\e[1m" & CStr(fr) &
| |
− | "\e[0m | Tempo trascorso: \e[35m" & CStr(Date(0, 0, 0, 0, 0, 0, ((fr * 8 * bla) / (hz * can * bit)) * 1000))
| |
− | Until fr >= i
| |
− |
| |
− | '''End'''
| |
− |
| |
− |
| |
− | '''Private''' Function DispositivoAttivo() As String <FONT Color=gray>' ''Verifica quale dispositivo audio è attivo''</font>
| |
− |
| |
− | Dim b, c As Byte
| |
− | Dim s As String
| |
− |
| |
− | <FONT Color=gray>' ''Verifica se qualche dispositivo audio è presente nel sistema:''</font>
| |
− | If Dir("/proc/asound", "card*", gb.Directory).Count == 0 Then Error.Raise("Dispositivo audio assente !")
| |
− |
| |
− | Repeat
| |
− | For Each s In Dir("/proc/asound/card" & CStr(b), "pcm*p", gb.Directory)
| |
− | If File.Load("/proc/asound/card" & CStr(b) &/ s & "/sub0/status") Like "*RUNNING*" Then c = 1
| |
− | Next
| |
− | Inc b
| |
− | Until c == 1
| |
− |
| |
− | Return CStr(b - 1) &/ s
| |
− |
| |
− | '''End'''
| |
− | | |
− | | |
− | <FONT Color=red size=4><B>Pagina in costruzione !</b></font>
| |