This project has moved and is read-only. For the latest updates, please go here.

Can't make spectrum to work - VB 2010

Feb 4, 2013 at 8:00 AM
I'm following the AudioPlaybackPanel.cs code and convert it to VB 2010 but just can't make the Spectrum to work. I mean, the PreVolumeMeter never fires

I can play, pause, stop, move the position with a slider, read the position.. just can't make the Spectrum to work

Ths is the code I use:
Dim waveOutDevice As IWavePlayer
Dim mp3Reader As Mp3FileReader
Dim inputStream As WaveChannel32
Dim WithEvents waveChannel As SampleChannel

Dim archivo As String

' ----------

waveOutDevice = New WaveOut()
mp3Reader = New Mp3FileReader(archivo)
inputStream = New WaveChannel32(mp3Reader)

waveChannel = New SampleChannel(mp3Reader, True)


' the event

Private Sub waveChannel_PreVolumeMeter(ByVal sender As Object, ByVal e As NAudio.Wave.SampleProviders.StreamVolumeEventArgs) Handles waveChannel.PreVolumeMeter
End Sub
Feb 4, 2013 at 11:03 AM
you are not using the SampleChannel at all. You are playing from the WaveChannel32. You need to pick one or the other.
Feb 4, 2013 at 4:20 PM
Edited Feb 4, 2013 at 4:21 PM
Thanks, works now..

This line


changes to

waveOutDevice.Init(New SampleToWaveProvider(waveChannel))

and this is gone

inputStream = New WaveChannel32(mp3Reader)
Feb 5, 2013 at 4:38 AM
Ok, the issue was solved but now I want to create the wave..

I read that I need to read until the end but didn't understand. I check the codes, even the WPF one, but still. I'm working with VB 2010 and maybe I can't understand exactly
mp3Reader = New Mp3FileReader(archivo)
waveChannel = New SampleChannel(mp3Reader, True)

Dim frame As Mp3Frame
Dim x As Integer = 1

While x < 50 ' just 50 for test
     frame = mp3Reader.ReadNextFrame()

     WaveformPainter1.AddMax( ???? )

      x = x + 1
End While