vbAccelerator - Contents of code file: cWinAmpToWaveWriter.cls

This file is part of the download VB6 Winamp Plugin Client, which is described in the article Using WinAmp In Plugins From VB.

  MultiUse = -1  'True
Attribute VB_Name = "cConverterWaveWriter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private m_cWriter As cWavFileDataWriter
Private m_sFile As String
Private m_cConverter As cWinAmpAudioConverter

Public Event Progress(ByVal lPercentDone As Long, ByRef bCancel As Boolean)

Public Property Get Filename() As String
   Filename = m_sFile
End Property

Public Property Let Filename(ByVal sFile As String)
   m_sFile = sFile
End Property

Public Sub Decode(cConverter As cWinAmpAudioConverter)
Dim lRead As Long
Dim bCancel As Boolean
   If (cConverter.FileIsOpen) Then
      If (m_cWriter.OpenFile(m_sFile)) Then
            lRead = cConverter.ConvertChunk(1)
            If (lRead > 0) Then
               m_cWriter.WriteWavData cConverter.ReadBufferPtr(1), lRead
            End If
            RaiseEvent Progress(cConverter.Percent, bCancel)
         Loop While (lRead > 0) And Not (bCancel)
         If (bCancel) Then
            KillFileIfExists m_sFile
         End If
      End If
   End If
End Sub

Private Sub KillFileIfExists(ByVal sFile As String)
   On Error Resume Next
   Kill sFile
End Sub

Private Sub Class_Initialize()
   Set m_cWriter = New cWavFileDataWriter
End Sub

Private Sub Class_Terminate()
   Set m_cWriter = Nothing
End Sub