mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
splitting the library into more intuitive modules
This commit is contained in:
310
CUETools.CDImage/CDImage.cs
Normal file
310
CUETools.CDImage/CDImage.cs
Normal file
@@ -0,0 +1,310 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CUETools.CDImage
|
||||
{
|
||||
public class CDTrackIndex
|
||||
{
|
||||
public CDTrackIndex(uint index, uint start)
|
||||
{
|
||||
_start = start;
|
||||
_index = index;
|
||||
_length = 0;
|
||||
}
|
||||
|
||||
public CDTrackIndex(uint index, uint start, uint length)
|
||||
{
|
||||
_length = length;
|
||||
_start = start;
|
||||
_index = index;
|
||||
}
|
||||
|
||||
public uint Start
|
||||
{
|
||||
get
|
||||
{
|
||||
return _start;
|
||||
}
|
||||
set
|
||||
{
|
||||
_start = value;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return _length;
|
||||
}
|
||||
set
|
||||
{
|
||||
_length = value;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Index
|
||||
{
|
||||
get
|
||||
{
|
||||
return _index;
|
||||
}
|
||||
}
|
||||
|
||||
public string MSF
|
||||
{
|
||||
get
|
||||
{
|
||||
return CDImageLayout.TimeToString(_start);
|
||||
}
|
||||
}
|
||||
|
||||
uint _start, _length, _index;
|
||||
}
|
||||
|
||||
public class CDTrack
|
||||
{
|
||||
public CDTrack(uint number, uint start, uint length, bool isAudio)
|
||||
{
|
||||
_number = number;
|
||||
_start = start;
|
||||
_length = length;
|
||||
_isAudio = isAudio;
|
||||
_indexes = new List<CDTrackIndex>();
|
||||
_indexes.Add(new CDTrackIndex(0, start, 0));
|
||||
}
|
||||
|
||||
public uint Start
|
||||
{
|
||||
get
|
||||
{
|
||||
return _start;
|
||||
}
|
||||
set
|
||||
{
|
||||
_start = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string StartMSF
|
||||
{
|
||||
get
|
||||
{
|
||||
return CDImageLayout.TimeToString(_start);
|
||||
}
|
||||
}
|
||||
|
||||
public uint Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return _length;
|
||||
}
|
||||
set
|
||||
{
|
||||
_length = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string LengthMSF
|
||||
{
|
||||
get
|
||||
{
|
||||
return CDImageLayout.TimeToString(_length);
|
||||
}
|
||||
}
|
||||
|
||||
public string ISRC
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isrc;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isrc = value;
|
||||
}
|
||||
}
|
||||
|
||||
public uint End
|
||||
{
|
||||
get
|
||||
{
|
||||
return _start + _length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public string EndMSF
|
||||
{
|
||||
get
|
||||
{
|
||||
return CDImageLayout.TimeToString(End);
|
||||
}
|
||||
}
|
||||
|
||||
public uint Number
|
||||
{
|
||||
get
|
||||
{
|
||||
return _number;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Pregap
|
||||
{
|
||||
get
|
||||
{
|
||||
return _indexes[0].Length;
|
||||
}
|
||||
}
|
||||
|
||||
public CDTrackIndex this[int key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _indexes[key];
|
||||
}
|
||||
}
|
||||
|
||||
public uint LastIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return (uint) _indexes.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAudio
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isAudio;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddIndex(CDTrackIndex index)
|
||||
{
|
||||
if (index.Index == 0)
|
||||
_indexes[0] = index;
|
||||
else
|
||||
_indexes.Add(index);
|
||||
}
|
||||
|
||||
IList<CDTrackIndex> _indexes;
|
||||
string _isrc;
|
||||
bool _isAudio;
|
||||
uint _start;
|
||||
uint _length;
|
||||
uint _number;
|
||||
}
|
||||
|
||||
public class CDImageLayout
|
||||
{
|
||||
public CDImageLayout(uint length)
|
||||
{
|
||||
_tracks = new List<CDTrack>();
|
||||
_length = length;
|
||||
}
|
||||
|
||||
public uint Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return _length;
|
||||
}
|
||||
set
|
||||
{
|
||||
_length = value;
|
||||
}
|
||||
}
|
||||
|
||||
public CDTrack this[int key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _tracks[key - 1];
|
||||
}
|
||||
}
|
||||
|
||||
public int TrackCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _tracks.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Pregap
|
||||
{
|
||||
get
|
||||
{
|
||||
return _tracks[0].Pregap;
|
||||
}
|
||||
}
|
||||
|
||||
public uint AudioTracks
|
||||
{
|
||||
get
|
||||
{
|
||||
return _audioTracks;
|
||||
}
|
||||
}
|
||||
|
||||
public String Catalog
|
||||
{
|
||||
get
|
||||
{
|
||||
return _catalog;
|
||||
}
|
||||
set
|
||||
{
|
||||
_catalog = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddTrack(CDTrack track)
|
||||
{
|
||||
_tracks.Add(track);
|
||||
if (track.IsAudio)
|
||||
_audioTracks++;
|
||||
}
|
||||
|
||||
public static int TimeFromString(string s)
|
||||
{
|
||||
string[] n = s.Split(':');
|
||||
if (n.Length != 3)
|
||||
{
|
||||
throw new Exception("Invalid timestamp.");
|
||||
}
|
||||
int min, sec, frame;
|
||||
|
||||
min = Int32.Parse(n[0]);
|
||||
sec = Int32.Parse(n[1]);
|
||||
frame = Int32.Parse(n[2]);
|
||||
|
||||
return frame + (sec * 75) + (min * 60 * 75);
|
||||
}
|
||||
|
||||
public static string TimeToString(uint t)
|
||||
{
|
||||
uint min, sec, frame;
|
||||
|
||||
frame = t % 75;
|
||||
t /= 75;
|
||||
sec = t % 60;
|
||||
t /= 60;
|
||||
min = t;
|
||||
|
||||
return String.Format("{0:00}:{1:00}:{2:00}", min, sec, frame);
|
||||
}
|
||||
|
||||
public string _cddbId;
|
||||
public string _ArId;
|
||||
|
||||
uint _length;
|
||||
string _catalog;
|
||||
IList<CDTrack> _tracks;
|
||||
uint _audioTracks;
|
||||
}
|
||||
}
|
||||
91
CUETools.CDImage/CUETools.CDImage.csproj
Normal file
91
CUETools.CDImage/CUETools.CDImage.csproj
Normal file
@@ -0,0 +1,91 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{1DD41038-D885-46C5-8DDE-E0B82F066584}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CUETools.CDImage</RootNamespace>
|
||||
<AssemblyName>CUETools.CDImage</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\bin\win32\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisRuleAssemblies>C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>..\bin\win32\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisRuleAssemblies>C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisRuleAssemblies>C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<OutputPath>..\bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisRuleAssemblies>C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CDImage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
35
CUETools.CDImage/Properties/AssemblyInfo.cs
Normal file
35
CUETools.CDImage/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("CUETools.CDImage")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("CUETools.CDImage")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("3db8bfa6-d3ba-4875-b02f-ef81119eab98")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Reference in New Issue
Block a user