曲の演奏時間の合計を調べる。
PC、プログラム
天気:晴れ
MP3CDを作って一枚のCD-RWに大量の音楽を押し込んで数時間鳴らしっぱなしにしています、深夜、日中を問わず。
まあ、BGMですから音質云々はこの際あまり気にしません、圧縮音源ですから、とは言えBose Wavemusic System IIIで鳴らすとそんな音源だとは思えないほどいい音で鳴ってくれるのです。
そこで総演奏時間がどのくらいになるのかを簡単に計算できないかと作ったのが以下のマクロです。
Sub 曲の長さを調べる()
Dim nObj As Variant
Dim nSH As Variant
Dim nDir As Variant
Dim nItem As Variant
Dim nH As Long
Dim nTgt As String
Dim nHTotal As Variant
With Application
.ScreenUpdating = False
nItem = Application.GetOpenFilename(FileFilter:="MP3ファイル,*.mp3", MultiSelect:=True)
If Not IsArray(nItem) Then Exit Sub
Set nObj = CreateObject("Scripting.FileSystemObject")
Set nSH = CreateObject("Shell.Application")
Set nDir = nSH.Namespace(nObj.GetFile(nItem(1)).ParentFolder.Path)
With nDir
nHTotal = 0
For nH = 1 To UBound(nItem)
nTgt = nObj.GetFile(nItem(nH)).Name
Cells(nH, 1) = .GetDetailsOf(.ParseName(nTgt), 0)
Cells(nH, 2) = .GetDetailsOf(.ParseName(nTgt), 27)
nHTotal = nHTotal + Cells(nH, 2)
Next nH
End With
Cells(1).EntireColumn.AutoFit
Set nDir = Nothing
Set nSH = Nothing
Set nObj = Nothing
Cells(nH, 2) = Format(nHTotal, "hh:mm:ss")
Cells(nH, 1).Activate
.ScreenUpdating = True
End With
End Sub
でもここに来てあることに気が付きました、MP3CDを作るにあたって演奏時間はどうでもいいことに。
肝心なのはファイルサイズの総合計でした、なんだか力抜けてしまいました、でもせっかく作ったんだから公開します。
あ、ちなみにファイルサイズの合計は実測で「702MB」までOKでしたが700MBまでにしておいたほうがいいでしょう、仮に超えてしまっても「できない」って怒られるだけですけど。
MP3CDを作って一枚のCD-RWに大量の音楽を押し込んで数時間鳴らしっぱなしにしています、深夜、日中を問わず。
まあ、BGMですから音質云々はこの際あまり気にしません、圧縮音源ですから、とは言えBose Wavemusic System IIIで鳴らすとそんな音源だとは思えないほどいい音で鳴ってくれるのです。
そこで総演奏時間がどのくらいになるのかを簡単に計算できないかと作ったのが以下のマクロです。
Sub 曲の長さを調べる()
Dim nObj As Variant
Dim nSH As Variant
Dim nDir As Variant
Dim nItem As Variant
Dim nH As Long
Dim nTgt As String
Dim nHTotal As Variant
With Application
.ScreenUpdating = False
nItem = Application.GetOpenFilename(FileFilter:="MP3ファイル,*.mp3", MultiSelect:=True)
If Not IsArray(nItem) Then Exit Sub
Set nObj = CreateObject("Scripting.FileSystemObject")
Set nSH = CreateObject("Shell.Application")
Set nDir = nSH.Namespace(nObj.GetFile(nItem(1)).ParentFolder.Path)
With nDir
nHTotal = 0
For nH = 1 To UBound(nItem)
nTgt = nObj.GetFile(nItem(nH)).Name
Cells(nH, 1) = .GetDetailsOf(.ParseName(nTgt), 0)
Cells(nH, 2) = .GetDetailsOf(.ParseName(nTgt), 27)
nHTotal = nHTotal + Cells(nH, 2)
Next nH
End With
Cells(1).EntireColumn.AutoFit
Set nDir = Nothing
Set nSH = Nothing
Set nObj = Nothing
Cells(nH, 2) = Format(nHTotal, "hh:mm:ss")
Cells(nH, 1).Activate
.ScreenUpdating = True
End With
End Sub
でもここに来てあることに気が付きました、MP3CDを作るにあたって演奏時間はどうでもいいことに。
肝心なのはファイルサイズの総合計でした、なんだか力抜けてしまいました、でもせっかく作ったんだから公開します。
あ、ちなみにファイルサイズの合計は実測で「702MB」までOKでしたが700MBまでにしておいたほうがいいでしょう、仮に超えてしまっても「できない」って怒られるだけですけど。