Like it too
Then made Windows version.
I doubt what to do for histogram, then I guess ascii is universal.
It accepts optional parameter for number of bins (default 32), unlike binwidth in Axon's version.
Path to executables should be set according user preferance.
Example:
C:\>cscript flachist.vbs "10 - Hysteria.flac"
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
10 - Hysteria.flac
0: 36>
36: 73>
73: 110>
110: 147>
147: 183>
183: 220>
220: 257>
257: 294>
294: 330>
330: 367>
367: 404>
404: 441> *
441: 478> *
478: 514> *
514: 551> *
551: 588> *
588: 625> *
625: 661> **
661: 698> ***
698: 735> *****
735: 772> **********
772: 808> *************
808: 845> **************
845: 882> ***************************
882: 919> *************************************
919: 956> *******************************************************
956: 992> *************************************************************
992:1029> ********************************************************************
1029:1066> *********************************************************
1066:1103> ************************
1103:1139> ****
1139:1176>
flachist.vbs
' Path to executables
flac = "C:\Program Files\foobar2000\tools\flac.exe"
metaflac = "C:\Program Files\foobar2000\tools\metaflac.exe"
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
If WScript.Arguments.Count And fso.FileExists(WScript.Arguments(0)) Then
flacArgs = " -asc "
metaflacArgs = " --show-min-blocksize --show-max-blocksize --show-min-framesize" &_
" --show-max-framesize --show-channels --show-bps --show-sample-rate "
q = Chr(34) : flac = q & flac & q : metaflac = q & metaflac & q
Set cmd = WshShell.exec(metaflac & metaflacArgs & q & WScript.Arguments(0) & q)
info = Split(cmd.StdOut.ReadAll(), vbCrLf)
If info(0) <> info(1) Then
WScript.Echo "ERROR: min/max blocksizes differ: " & info(0) & "<>" & info(1)
WScript.Quit
Else
blocksize = info(0) : origminframe = info(2) : rate = info(6)
End If
' Write bits info data to csv file
Set csv = fso.CreateTextFile(WScript.Arguments(0) & ".csv")
Set cmd = WshShell.exec(flac & flacArgs & q & WScript.Arguments(0) & q)
Do While cmd.StdOut.AtEndOfStream <> True
readline = cmd.StdOut.ReadLine
If InStr(readline, "blocksize=" & blocksize) Then
bits = Split(Split(readline, vbTab)(2), "=")(1)
If Int(bits) <> origminframe*8 Then csv.WriteLine(bits)
End If
Loop
' Read csv
Set csv = fso.OpenTextFile(WScript.Arguments(0) & ".csv")
lines = Split(csv.ReadAll(), vbCrLf)
max = 0 : bins = 32
If WScript.Arguments.Count > 1 Then bins = CInt(WScript.Arguments(1))
For Each line In lines
If line <> "" Then If Int(line) > max Then max = Int(line)
Next
' Print ascii histogram
bin = Array() : ReDim bin(bins)
maxbin = 0
For Each line In lines
If line <> "" Then idx = Fix(bins*Int(line)/(max+1)) : bin(idx) = bin(idx) + 1
If bin(idx) > maxbin Then maxbin = bin(idx)
Next
WScript.Echo WScript.Arguments(0) & vbCrLf
m = max*rate/bins/blocksize/1000
For i=0 To bins-1
WScript.Echo Right(" " & Int(i*m), 4) & ":" &_
Right(" " & Int((i+1)*m), 4) & "> " &_
String(Int(bin(i)*68/maxbin), "*")
Next
Else
WScript.Echo "Usage: cscript flachist.vbs flac-file-path [bins]"
End If