Skip to content

Commit ee5ab21

Browse files
authored
Merge pull request #127 from MrCSharp22/feature/support-ETCO-frames
Feature/support etco frames
2 parents bdbae35 + 8417f76 commit ee5ab21

File tree

10 files changed

+723
-81
lines changed

10 files changed

+723
-81
lines changed

src/TagLib/Id3v2/EventTimeCode.cs

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using TagLib.Id3v2;
3+
4+
namespace TagLib.Id3v2
5+
{
6+
public class EventTimeCode : ICloneable
7+
{
8+
#region Private Properties
9+
10+
private EventType typeOfEvent;
11+
12+
private int time;
13+
14+
#endregion
15+
16+
#region Public Properties
17+
18+
public EventType TypeOfEvent
19+
{
20+
get { return typeOfEvent; }
21+
set { typeOfEvent = value; }
22+
}
23+
24+
public int Time
25+
{
26+
get { return time; }
27+
set { time = value; }
28+
}
29+
30+
#endregion
31+
32+
#region Public Constructors
33+
34+
public EventTimeCode(EventType typeOfEvent,
35+
int time)
36+
{
37+
this.typeOfEvent = typeOfEvent;
38+
this.time = time;
39+
}
40+
41+
#endregion
42+
43+
#region Static Methods
44+
45+
public static EventTimeCode CreateEmpty()
46+
{
47+
return new EventTimeCode(EventType.Padding, 0);
48+
}
49+
50+
#endregion
51+
52+
#region ICloneable
53+
54+
public object Clone()
55+
{
56+
return new EventTimeCode(typeOfEvent, time);
57+
}
58+
59+
#endregion
60+
}
61+
}

src/TagLib/Id3v2/EventType.cs

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
namespace TagLib.Id3v2
2+
{
3+
/// <summary>
4+
/// Specifies the event type used by a <see
5+
/// cref="EventTimeCode" /> and <see cref="EventTimeCodesFrame"/>.
6+
/// </summary>
7+
public enum EventType
8+
{
9+
/// <summary>
10+
/// The padding - no meaning
11+
/// </summary>
12+
Padding = 0x00,
13+
14+
/// <summary>
15+
/// The end of initial silence
16+
/// </summary>
17+
EndOfInitialSilence = 0x01,
18+
19+
/// <summary>
20+
/// The intro start
21+
/// </summary>
22+
IntroStart = 0x02,
23+
24+
/// <summary>
25+
/// The main part start
26+
/// </summary>
27+
MainPartStart = 0x03,
28+
29+
/// <summary>
30+
/// The outro start
31+
/// </summary>
32+
OutroStart = 0x04,
33+
34+
/// <summary>
35+
/// The outro end
36+
/// </summary>
37+
OutroEnd = 0x05,
38+
39+
/// <summary>
40+
/// The verse start
41+
/// </summary>
42+
VerseStart = 0x06,
43+
44+
/// <summary>
45+
/// The refrain start
46+
/// </summary>
47+
RefrainStart = 0x07,
48+
49+
/// <summary>
50+
/// The interlude start
51+
/// </summary>
52+
InterludeStart = 0x08,
53+
54+
/// <summary>
55+
/// The theme start
56+
/// </summary>
57+
ThemeStart = 0x09,
58+
59+
/// <summary>
60+
/// The variation start
61+
/// </summary>
62+
VariationStart = 0x0A,
63+
64+
/// <summary>
65+
/// The key change
66+
/// </summary>
67+
KeyChange = 0x0B,
68+
69+
/// <summary>
70+
/// The time change
71+
/// </summary>
72+
TimeChange = 0x0C,
73+
74+
/// <summary>
75+
/// momentary unwanted noise (Snap, Crackle & Pop)
76+
/// </summary>
77+
MomentaryUnwantedNoise = 0x0D,
78+
79+
/// <summary>
80+
/// The sustained noise
81+
/// </summary>
82+
SustainedNoise = 0x0E,
83+
84+
/// <summary>
85+
/// The sustained noise end
86+
/// </summary>
87+
SustainedNoiseEnd = 0x0F,
88+
89+
/// <summary>
90+
/// The intro end
91+
/// </summary>
92+
IntroEnd = 0x10,
93+
94+
/// <summary>
95+
/// The main part end
96+
/// </summary>
97+
MainPartEnd = 0x11,
98+
99+
/// <summary>
100+
/// The verse end
101+
/// </summary>
102+
VerseEnd = 0x12,
103+
104+
/// <summary>
105+
/// The refrain end
106+
/// </summary>
107+
RefrainEnd = 0x13,
108+
109+
/// <summary>
110+
/// The theme end
111+
/// </summary>
112+
ThemeEnd = 0x14,
113+
114+
/// <summary>
115+
/// Profanity starts
116+
/// </summary>
117+
Profanity = 0x15,
118+
119+
/// <summary>
120+
/// The profanity end
121+
/// </summary>
122+
ProfanityEnd = 0x16,
123+
124+
/// <summary>
125+
/// The audio end
126+
/// </summary>
127+
AudioEnd = 0xFD,
128+
129+
/// <summary>
130+
/// The audio file end
131+
/// </summary>
132+
AudioFileEnd = 0xFE,
133+
}
134+
}

src/TagLib/Id3v2/FrameFactory.cs

+5
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ public static Frame CreateFrame (ByteVector data, File file,
295295
return new UrlLinkFrame(data, position,
296296
header, version);
297297

298+
// Event timing codes (frames 4.6)
299+
if (header.FrameId == FrameType.ETCO)
300+
return new EventTimeCodesFrame(data, position, header,
301+
version);
302+
298303
return new UnknownFrame (data, position, header,
299304
version);
300305
}

src/TagLib/Id3v2/FrameTypes.cs

+1
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,6 @@ internal static class FrameType {
9696
public static readonly ReadOnlyByteVector WPAY = "WPAY";
9797
public static readonly ReadOnlyByteVector WPUB = "WPUB";
9898
public static readonly ReadOnlyByteVector WXXX = "WXXX";
99+
public static readonly ReadOnlyByteVector ETCO = "ETCO";
99100
}
100101
}

0 commit comments

Comments
 (0)