hi Giawa, this is brilliant. I'll try to get this into NAudio for v1.7
thanks so much
Mark
hi Giawa, this is brilliant. I'll try to get this into NAudio for v1.7
thanks so much
Mark
I've committed the new class, although haven't had a chance to test it yet. Any chance you could do a quick code review for me. The change ishere.
many thanks for this contribution.
Mark
you need to remember to call Dispose your Mp3FileReader and your waveOutDevice before creating new ones
hello,
For a while, I try to play wma files or other formats of the same kind with a driver or ASIO CoreAPI and I am still facing the same error.
I even included a MediaFoundation procedure (similar to that published in the new version of NAudio, a lot of work, and congratulations to the author) but it's still the same problem.
I end up with this error ::
"NAudio.MediaFoundation.IMFSourceReader ..... This interface is not supported (Exception from HRESULT 0x80004002 (E_NOINTERFACE)
However, the procedure works with audio driver WavOut () standart (without Thread).
So if someone find the trick to read files type. "Wma" with ASIO or driverAudio CoreAPI
Mark: I know I've raised the issue .. (see http://naudio.codeplex.com/workitem/16370) but hey, a call for commonality from time to time :-)
Sincerely, manun
the issue here is almost certainly threading. You're creating and initialising the COM object on one thread and accessing it from another. That's why WaveOut works, while the other models which use background threads don't. You could try marking your app as being MTAThread instead of STAThread. Alternatively, you could create a wrapper around your IWaveProvider that doesn't perform any initialisation until the first call to Read comes in, which will be on the correct thread.
I've only just committed the IMFSourceReader yesterday and it's by no means finished. I need to add in some locking for positioning while you are playing and I will be trying it out with various threading options and models over the coming weeks.
Mark
read this thread if you are unfamiliar with MTAThread:
http://stackoverflow.com/questions/127188/could-you-explain-sta-and-mta
I wrote a small test program in vb.net 2012 , the program is to record "what you hear" using the new WasapiCapture class. Upon invoking the wasapi.startrecording function, I get a ComException from NAudio. I searched Microsoft KB but the exception number was not there
has anyone encountered something similar?
the code is as follows:
Imports naudio
Imports naudio.wave
Imports NAudio.CoreAudioApi
Public Class Form1
Dim WithEvents Wasapi As WasapiCapture
Dim Writer As WaveFileWriter
Dim WvFormat As WaveFormat
Dim mmdev As MMDeviceEnumerator
Dim audio As MMDevice
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
mmdev = New MMDeviceEnumerator
audio = mmdev.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia)
WvFormat = audio.AudioClient.MixFormat
Wasapi = New WasapiCapture(audio)
Wasapi.WaveFormat = WvFormat
Writer = New WaveFileWriter("E:\2.wav", WvFormat)
''
''
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Application.Exit()
End Sub
Private Sub Wasapi_DataAvailable(sender As Object, e As WaveInEventArgs) Handles Wasapi.DataAvailable
Writer.Write(e.Buffer, 0, e.BytesRecorded)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Wasapi IsNot Nothing Then
Wasapi.StartRecording()
End If
''''
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If Wasapi IsNot Nothing Then
Wasapi.Dispose()
Wasapi = Nothing
End If
''
If Writer IsNot Nothing Then
Writer.Flush()
Writer.Close()
End If
''
End Sub
Private Sub Wasapi_RecordingStopped(sender As Object, e As EventArgs) Handles Wasapi.RecordingStopped
'''''
If Writer IsNot Nothing Then Writer.Dispose()
''''
If Wasapi IsNot Nothing Then Wasapi.Dispose()
''''
End Sub
End Class