비주얼 베이식에서 웨이브 정보 추출
[CODE type=vb]
Public Type wave_header
wavRIFFChunk As String * 4
wavSize As Long
wavWaveChunk As String * 4
wavFMTChunk As String * 4
wavFormatSize As Long
wavPCMFormatFlag As Integer
wavChannel As Integer
wavSampleRate As Long
wavSampleRatePerSec As Long
wavPerSecScale As Integer
wavBits As Integer
wavDataChunk As String * 4
wavDataSize As Long
End Type
Open txtFile1.Text For Binary As #1
Get #1, , openFile1
If openFile1.wavPCMFormatFlag <> 1 Then
MsgBox "표준 PCM 웨이브 파일이 아닙니다.", vbOKOnly + vbInformation, "확인"
Close #1
txtFile1.Text = ""
Exit Sub
End If
MCI.Command = "stop"
MCI.Command = "close"
tinfo = "RIFF Chunk : " & openFile1.wavRIFFChunk & vbCrLf & _
"Size : " & openFile1.wavSize & vbCrLf & _
"Wave Chunk : " & openFile1.wavWaveChunk & vbCrLf & _
"FMT Chunk : " & openFile1.wavFMTChunk & vbCrLf & _
"Format Size : " & openFile1.wavFormatSize & vbCrLf & _
"PCM Format Flag : " & openFile1.wavPCMFormatFlag & vbCrLf & _
"Channels : " & openFile1.wavChannel & vbCrLf & _
"Sample Rate : " & openFile1.wavSampleRate & vbCrLf & _
"Sample Rate/sec : " & openFile1.wavSampleRatePerSec & vbCrLf & _
"Per sec Scale : " & openFile1.wavPerSecScale & vbCrLf & _
"Bits per Sample : " & openFile1.wavBits & vbCrLf & _
"Data Chunk : " & openFile1.wavDataChunk & vbCrLf & _
"Data Size : " & openFile1.wavDataSize
lblInformation1.Caption = tinfo
zNumSample1 = openFile1.wavDataSize / (openFile1.wavChannel * (openFile1.wavBits / 8))
lblWating1.Visible = True
DoEvents
ReDim WaveData1(openFile1.wavChannel, zNumSample1)
'reading data
For i = 0 To zNumSample1 - 1
For j = 0 To openFile1.wavChannel - 1
If openFile1.wavBits = 8 Then
Get #1, , sdata8
WaveData1(j, i) = sdata8
Else
Get #1, , sdata16
WaveData1(j, i) = sdata16
End If
Next
Next
lblWating1.Visible = False
Close #1
[/CODE]
댓글 없음:
댓글 쓰기