Hi there,
I'm a newby, and so I need your help. It's more like a big help I'm looking for.
I have searched for a way to do this:
- open a *.wav file
- start reading the sub-chunk containing the wave data
- generate some data using this chunk
- play that chunk
- print a graphic using GDI+
- go to next chunk
- etc..
it's, ofcourse, a wave form graphics application.
I am using the wavefile class (I have found many alternatives), and I have these problems:
- I don't know where exactly is stored the "current"(at some point) data chunk;
- how can I read what's in the buffer containing this chunk from another .dll (a class witch a function that processes this data)
- I know that there are 2 buffers when playing: the one containing the chunk that is played (at some point), and another one with the next chunk. WHICH one is the first, and which is the other
I hope I will finf some answers from you, and the code I've used to open the WAV file is (it' not developed by me...):
Private
Sub Open(ByVal filename As String) ' Make sure the file exists If (Not File.Exists(filename)) Then Throw New FileNotFoundException("The media file could not be found.", filename) ' Open the input fileInput = mmioOpen(filename, IntPtr.Zero, MMIO_READ)
If (Input.Equals(IntPtr.Zero)) Then Throw New MediaException("An error occurs while opening the media file.") ' make sure this is a wave file Dim mmi As New MMCKINFO()mmi.fccType = mmioStringToFOURCC(
"WAVE", 0) If (mmioDescend(Input, mmi, IntPtr.Zero, MMIO_FINDRIFF) <> MMSYSERR_NOERROR) ThenClose()
Throw New MediaException("The media file is invalid.") End If ' get format infommi =
New MMCKINFO()mmi.ckid = mmioStringToFOURCC(
"fmt", 0) If (mmioDescend(Input, mmi, IntPtr.Zero, MMIO_FINDCHUNK) <> MMSYSERR_NOERROR) ThenClose()
Throw New MediaException("The format chunk could not be found.") End Ifm_Format =
New WAVEFORMAT() If (mmioRead(Input, m_Format, Marshal.SizeOf(m_Format)) = -1) ThenClose()
Throw New MediaException("An error occurs while reading from the media file.") End IfmmioAscend(Input, mmi, 0)
' find the data subchunkmmi.ckid = mmioStringToFOURCC(
"data", 0) If (mmioDescend(Input, mmi, IntPtr.Zero, MMIO_FINDCHUNK) <> MMSYSERR_NOERROR) ThenClose()
Throw New MediaException("The data chunk could not be found.") End Ifm_DataOffset = mmioSeek(Input, 0, SEEK_CUR)
' Get the length of the audiom_AudioLength = mmi.ckSize
' Allocate audio buffersm_BufferSize =
CType(m_Format.nSamplesPerSec * m_Format.nBlockAlign * m_Format.nChannels * BUFFER_SECONDS, Integer)m_BufferSize = m_BufferSize - (m_BufferSize
Mod m_Format.nBlockAlign) ReDim m_Buffer(m_Buffers - 1) ReDim m_Header(m_Buffers - 1) Dim i As Integer For i = 0 To m_Buffer.Length - 1m_Buffer(i) = Marshal.AllocHGlobal(m_BufferSize)
Next End Sub
Thank you !

reading wav files, extract the sub-chunk with data, play wav
betamark
xLogicTalentedx
OK, it's done!