vbAccelerator - Contents of code file: cCDTocEntry.cls

This file is part of the download VB6 CD Ripper, which is described in the article CD Ripping in VB Part 1.

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "cTocEntry"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

' ------------------------------------------------------------
' Name:   cTocEntry
' Author: Steve McMahon (steve@vbaccelerator.com)
' Date:   2004-05-06
' Description:
' Class describing a single entry in the Table of Contents
' (TOC) of a CD, intended for use with the wrapper around
' the CDRip.DLL API.
'
' See http://vbaccelerator.com/
' ------------------------------------------------------------

Public Enum ECDRipTOCEntryType
   CDROMDATAFLAG = &H4
   AUDIOTRKFLAG = &H10
End Enum

Private m_cdIndex As Long
Private m_startSector As Long
Private m_endSector As Long
Private m_trackNumber As Byte
Private m_eEntryType As ECDRipTOCEntryType
Private m_lOffset As Long

Friend Sub fInit( _
      ByVal lCDIndex As Long, _
      ByVal lStartSector As Long, _
      ByVal bFlag As Byte, _
      ByVal bTrackNumber As Byte, _
      ByVal lEndSector As Long _
   )
   m_cdIndex = lCDIndex
   m_startSector = lStartSector
   m_trackNumber = bTrackNumber
   m_eEntryType = bFlag
   m_endSector = lEndSector
End Sub

Public Property Get StartSector() As Long
   StartSector = m_startSector
End Property
Public Property Get EndSector() As Long
   EndSector = m_endSector
End Property

Public Property Get TrackNumber() As Byte
   TrackNumber = m_trackNumber
End Property

Public Property Get TOCEntryType() As ECDRipTOCEntryType
   TOCEntryType = m_eEntryType
End Property

Public Property Get Offset() As Long
   Offset = m_startSector + 150 ' 2s * 75 frames/second
End Property

Public Property Get SizeBytes() As Long
Dim lFrames As Long
   lFrames = m_endSector - m_startSector
   SizeBytes = ((lFrames * 4&) / 75&) * 44100
End Property

Public Property Get StartTimeMinutes() As Long
   StartTimeMinutes = Int(Offset / (75 * 60))
End Property
Public Property Get StartTimeSeconds() As Long
   StartTimeSeconds = (Int(Offset / 75)) Mod 60
End Property
Public Property Get StartTimeFrames() As Long
   StartTimeFrames = Offset Mod 75
End Property

Public Property Get FormattedStartTime() As String
   FormattedStartTime = FormattedTime(StartTimeMinutes, _
      StartTimeSeconds, StartTimeFrames)
End Property
Public Property Get FormattedLength() As String
   FormattedLength = FormattedTime(LengthMinutes, _
      LengthSeconds, LengthFrames)
End Property
Private Function FormattedTime(ByVal minutes As Long, ByVal seconds As Long,
 ByVal frames As Long) As String
   FormattedTime = Format(minutes, "##0") & ":" & _
      Format(seconds, "00") & "." & Format((frames * 60) / 75, "00")
End Function

Public Property Get LengthMinutes() As Long
   LengthMinutes = Int((m_endSector - m_startSector) / (75 * 60))
End Property
Public Property Get LengthSeconds() As Long
   LengthSeconds = (Int((m_endSector - m_startSector) / 75)) Mod 60
End Property
Public Property Get LengthFrames() As Long
   LengthFrames = (m_endSector - m_startSector) Mod 75
End Property

Friend Property Get fCDIndex() As Long
   fCDIndex = m_cdIndex
End Property