|
Imports System.IO
Imports System.Text
'Genre is a numeric field which may have one of the following values:
'0 'Blues' 20 'Alternative' 40 'AlternRock' 60 'Top 40'
'1 'Classic Rock' 21 'Ska' 41 'Bass' 61 'Christian Rap'
'2 'Country' 22 'Death Metal' 42 'Soul' 62 'Pop/Funk'
'3 'Dance' 23 'Pranks' 43 'Punk' 63 'Jungle'
'4 'Disco' 24 'Soundtrack' 44 'Space' 64 'Native American'
'5 'Funk' 25 'Euro-Techno' 45 'Meditative' 65 'Cabaret'
'6 'Grunge' 26 'Ambient' 46 'Instrumental Pop' 66 'New Wave'
'7 'Hip-Hop' 27 'Trip-Hop' 47 'Instrumental Rock' 67 'Psychadelic'
'8 'Jazz' 28 'Vocal' 48 'Ethnic' 68 'Rave'
'9 'Metal' 29 'Jazz+Funk' 49 'Gothic' 69 'Showtunes'
'10 'New Age' 30 'Fusion' 50 'Darkwave' 70 'Trailer'
'11 'Oldies' 31 'Trance' 51 'Techno-Industrial' 71 'Lo-Fi'
'12 'Other' 32 'Classical' 52 'Electronic' 72 'Tribal'
'13 'Pop' 33 'Instrumental' 53 'Pop-Folk' 73 'Acid Punk'
'14 'R&B' 34 'Acid' 54 'Eurodance' 74 'Acid Jazz'
'15 'Rap' 35 'House' 55 'Dream' 75 'Polka'
'16 'Reggae' 36 'Game' 56 'Southern Rock' 76 'Retro'
'17 'Rock' 37 'Sound Clip' 57 'Comedy' 77 'Musical'
'18 'Techno' 38 'Gospel' 58 'Cult' 78 'Rock & Roll'
'19 'Industrial' 39 'Noise' 59 'Gangsta' 79 'Hard Rock'
'WinAmp expanded this table with the next codes:
'80 'Folk' 92 'Progressive Rock' 104 'Chamber Music' 116 'Ballad'
'81 'Folk-Rock' 93 'Psychedelic Rock' 105 'Sonata' 117 'Poweer Ballad'
'82 'National Folk' 94 'Symphonic Rock' 106 'Symphony' 118 'Rhytmic Soul'
'83 'Swing' 95 'Slow Rock' 107 'Booty Brass' 119 'Freestyle'
'84 'Fast Fusion' 96 'Big Band' 108 'Primus' 120 'Duet'
'85 'Bebob' 97 'Chorus' 109 'Porn Groove' 121 'Punk Rock'
'86 'Latin' 98 'Easy Listening' 110 'Satire' 122 'Drum Solo'
'87 'Revival' 99 'Acoustic' 111 'Slow Jam' 123 'A Capela'
'88 'Celtic' 100 'Humour' 112 'Club' 124 'Euro-House'
'89 'Bluegrass' 101 'Speech' 113 'Tango' 125 'Dance Hall'
'90 'Avantgarde' 102 'Chanson' 114 'Samba'
'91 'Gothic Rock' 103 'Opera' 115 'Folklore'
'Any other value should be considered as 'Unknown'
' Genres
'ReEdited by: R.S.Percy a.k.a. ( Oilcan_Harry )
Public Class clsID3v1Reader
Public Enum Genres As Byte
Blues = 0
ClassicRock = 1
Country = 2
Dance = 3
Disco = 4
Funk = 5
Grunge = 6
HipHop = 7
Jazz = 8
Metal = 9
NewAge = 10
Oldies = 11
Other = 12
Pop = 13
RnB = 14
Rap = 15
Reggae = 16
Rock = 17
Techno = 18
Industrial = 19
Alternative = 20
Ska = 21
DeathMetal = 22
Pranks = 23
Soundtrack = 24
EuroTechno = 25
Ambient = 26
TripHop = 27
Vocal = 28
JazzFunk = 29
Fusion = 30
Trance = 31
Classical = 32
Instrumental = 33
Acid = 34
House = 35
Game = 36
SoundClip = 37
Gospel = 38
Noise = 39
AlternRock = 40
Bass = 41
Soul = 42
Punk = 43
Space = 44
Meditative = 45
InstrumentalPop = 46
InstrumentalRock = 47
Ethnic = 48
Gothic = 49
Darkwave = 50
TechnoIndustrial = 51
Electronic = 52
PopFolk = 53
Eurodance = 54
Dream = 55
SouthernRock = 56
Comedy = 57
Cult = 58
Gangsta = 59
Top40 = 60
ChristianRap = 61
PopFunk = 62
Jungle = 63
NativeAmerican = 64
Cabaret = 65
NewWave = 66
Psychadelic = 67
Rave = 68
Showtunes = 69
Trailer = 70
LoFi = 71
Tribal = 72
AcidPunk = 73
AcidJazz = 74
Polka = 75
Retro = 76
Musical = 77
RocknRoll = 78
HardRock = 79
Folk = 80
FolkRock = 81
NationalFolk = 82
Swing = 83
FastFusion = 84
Bebob = 85
Latin = 86
Revival = 87
Celtic = 88
Bluegrass = 89
Avantgarde = 90
GothicRock = 91
ProgressiveRock = 92
PsychedelicRock = 93
SymphonicRock = 94
SlowRock = 95
BigBand = 96
Chorus = 97
EasyListening = 98
Acoustic = 99
Humour = 100
Speech = 101
Chanson = 102
Opera = 103
ChamberMusic = 104
Sonata = 105
Symphony = 106
BootyBass = 107
Primus = 108
PornGroove = 109
Satire = 110
SlowJam = 111
Club = 112
Tango = 113
Samba = 114
Folklore = 115
Ballad = 116
PowerBallad = 117
RhythmicSoul = 118
Freestyle = 119
Duet = 120
PunkRock = 121
DrumSolo = 122
ACappella = 123
EuroHouse = 124
DanceHall = 125
Goa = 126
DrumBass = 127
ClubHouse = 128
Hardcore = 129
Terror = 130
Indie = 131
BritPop = 132
Negerpunk = 133
PolskPunk = 134
Beat = 135
ChristianGangsta = 136
HeavyMetal = 137
Black_etal = 138
Crossover = 139
ContemporaryChristian = 140
ChristianRock = 141
Merengue = 142
Salsa = 143
ThrashMetal = 144
Anime = 145
JPop = 146
SynthPop = 147
None = 255
End Enum
Private m_Artist As String
Private m_Comment As String
Private m_Genre As Genres
Private m_FileName As String
Private m_Recording As String
Private m_TrackSequence As Byte = 0
Private m_TrackTitle As String
Private m_Year As String
Public Property Artist() As String
Get
Return Me.m_Artist
End Get
Set(ByVal Value As String)
Me.m_Artist = Value
End Set
End Property
Public Property Comment() As String
Get
Return Me.m_Comment
End Get
Set(ByVal Value As String)
Me.m_Comment = Value
End Set
End Property
Public Property Genre() As Byte
Get
Return Me.m_Genre
End Get
Set(ByVal Value As Byte)
Me.m_Genre = Value
End Set
End Property
Public Property FileName() As String
Get
Return Me.m_FileName
End Get
Set(ByVal Value As String)
Me.m_FileName = Value
Me.Reset()
End Set
End Property
Public Property Recording() As String
Get
Return Me.m_Recording
End Get
Set(ByVal Value As String)
Me.m_Recording = Value
End Set
End Property
Public Property TrackSequence() As Byte
Get
Return Me.m_TrackSequence
End Get
Set(ByVal Value As Byte)
Me.m_TrackSequence = Value
End Set
End Property
Public Property TrackTitle() As String
Get
Return Me.m_TrackTitle
End Get
Set(ByVal Value As String)
Me.m_TrackTitle = Value
End Set
End Property
Public Property Year() As String
Get
Return Me.m_Year
End Get
Set(ByVal Value As String)
Me.m_Year = Value
End Set
End Property
Public Sub New()
' This is needed since there is a
' paramaterized constructor.
' This is so this class can be used
' for multiple files.
End Sub
Public Sub New(ByVal FileName As String)
Me.FileName = FileName
Parse()
End Sub
Public Sub Parse()
Dim fs As FileStream = Nothing
Dim ae As ASCIIEncoding
Dim buffer(127) As Byte
Dim tag As String
Dim hdr As String
'Lets get the tag info.
Try
fs = New FileStream(Me.FileName, FileMode.Open, FileAccess.Read)
ae = New ASCIIEncoding
fs.Seek(-128, SeekOrigin.End)
fs.Read(buffer, 0, 128)
tag = ae.GetString(buffer)
hdr = tag.Substring(0, 3)
If hdr = "TAG" Then
Me.TrackTitle = SubStringNull(tag, 3, 30)
Me.Artist = SubStringNull(tag, 33, 30)
Me.Recording = SubStringNull(tag, 63, 30)
Me.Year = SubStringNull(tag, 93, 4)
Me.Comment = SubStringNull(tag, 97, 30)
' If buffer(125) = 0 Then
Me.TrackSequence = buffer(126)
Me.Genre = buffer(127)
' End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, ex.Source, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
If Not fs Is Nothing Then
'Clean-Up
fs.Flush()
fs.Close()
End If
End Try
End Sub
Private Sub Reset()
Me.Artist = Nothing
Me.Comment = Nothing
Me.Genre = 255
Me.Recording = Nothing
Me.TrackSequence = 0
Me.TrackTitle = Nothing
Me.Year = Nothing
End Sub
Private Function SubStringNull(ByVal s As String, ByVal start As Integer, ByVal length As Integer) As String
Dim subS As String = s.Substring(start, length)
Return subS.TrimEnd(Convert.ToChar(0))
End Function
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am currently retired.
I have no degree but I have some programming experience
when I was in college(Cobol, Pascal).
My accomplishments thus far are;
Best VB.Net article for January(2009)
Best VB.Net article for July(2009)