initial checkin

This commit is contained in:
chudov
2008-10-13 19:25:11 +00:00
parent 2e379c72e2
commit 36757fca7a
937 changed files with 184964 additions and 0 deletions

0
APEDotNet/APEDotNet.h Normal file
View File

422
APEDotNet/APEDotNet.vcproj Normal file
View File

@@ -0,0 +1,422 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="APEDotNet"
ProjectGUID="{9AE965C4-301E-4C01-B90F-297AF341ACC6}"
RootNamespace="APEDotNet"
Keyword="ManagedCProj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\MAC_SDK\Shared"
PreprocessorDefinitions="WIN32;_DEBUG"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
AssemblyDebug="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\MAC_SDK\Shared"
PreprocessorDefinitions="WIN32;_DEBUG"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
AssemblyDebug="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\MAC_SDK\Shared"
PreprocessorDefinitions="WIN32;NDEBUG"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\MAC_SDK\Shared"
PreprocessorDefinitions="WIN32;NDEBUG"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
AdditionalLibraryDirectories=""
GenerateDebugInformation="true"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
<AssemblyReference
RelativePath="System.dll"
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
/>
<AssemblyReference
RelativePath="System.Data.dll"
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
/>
<AssemblyReference
RelativePath="System.XML.dll"
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
/>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\APEDotNet.cpp"
>
</File>
<File
RelativePath=".\AssemblyInfo.cpp"
>
</File>
<File
RelativePath=".\Stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\APEDotNet.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\Stdafx.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\app.ico"
>
</File>
<File
RelativePath=".\app.rc"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,40 @@
#include "stdafx.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// 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:AssemblyTitleAttribute("APEDotNet")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("APEDotNet")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) Greg Chudov 2008")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];

31
APEDotNet/ReadMe.txt Normal file
View File

@@ -0,0 +1,31 @@
========================================================================
DYNAMIC LINK LIBRARY : APEDotNet Project Overview
========================================================================
AppWizard has created this APEDotNet DLL for you.
This file contains a summary of what you will find in each of the files that
make up your APEDotNet application.
APEDotNet.vcproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
APEDotNet.cpp
This is the main DLL source file.
APEDotNet.h
This file contains a class declaration.
AssemblyInfo.cpp
Contains custom attributes for modifying assembly metadata.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////

5
APEDotNet/Stdafx.cpp Normal file
View File

@@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// APEDotNet.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

7
APEDotNet/Stdafx.h Normal file
View File

@@ -0,0 +1,7 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once

233
APEDotNet/apedotnet.cpp Normal file
View File

@@ -0,0 +1,233 @@
// This is the main DLL file.
using namespace System;
using namespace System::Text;
using namespace System::Collections::Generic;
using namespace System::Collections::Specialized;
using namespace System::Runtime::InteropServices;
#ifndef _WAVEFORMATEX_
#define _WAVEFORMATEX_
#define BOOL int
#define TRUE 1
#define FALSE 0
#define HWND long
/*
* extended waveform format structure used for all non-PCM formats. this
* structure is common to all non-PCM formats.
*/
typedef struct tWAVEFORMATEX
{
Int16 wFormatTag; /* format type */
Int16 nChannels; /* number of channels (i.e. mono, stereo...) */
Int32 nSamplesPerSec; /* sample rate */
Int32 nAvgBytesPerSec; /* for buffer estimation */
Int16 nBlockAlign; /* block size of data */
Int16 wBitsPerSample; /* number of bits per sample of mono data */
Int16 cbSize; /* the count in bytes of the size of */
/* extra information (after cbSize) */
} WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX;
#endif /* _WAVEFORMATEX_ */
#include "All.h"
#include "MACLib.h"
#include "APETag.h"
namespace APEDotNet {
public ref class APEReader {
public:
APEReader(String^ path) {
IntPtr pathChars;
pAPEDecompress = NULL;
_sampleOffset = 0;
_samplesWaiting = false;
_path = NULL;
pBuffer = NULL;
int nRetVal = 0;
pathChars = Marshal::StringToHGlobalUni(path);
size_t pathLen = wcslen ((const wchar_t*)pathChars.ToPointer())+1;
_path = new wchar_t[pathLen];
memcpy ((void*) _path, (const wchar_t*)pathChars.ToPointer(), pathLen*sizeof(wchar_t));
Marshal::FreeHGlobal(pathChars);
pAPEDecompress = CreateIAPEDecompress (_path, &nRetVal);
if (!pAPEDecompress) {
throw gcnew Exception("Unable to open file.");
}
_sampleRate = pAPEDecompress->GetInfo (APE_INFO_SAMPLE_RATE, 0, 0);
_bitsPerSample = pAPEDecompress->GetInfo (APE_INFO_BITS_PER_SAMPLE, 0, 0);
_channelCount = pAPEDecompress->GetInfo (APE_INFO_CHANNELS, 0, 0);
// make a buffer to hold 16384 blocks of audio data
nBlockAlign = pAPEDecompress->GetInfo (APE_INFO_BLOCK_ALIGN, 0, 0);
pBuffer = new unsigned char [16384 * nBlockAlign];
// loop through the whole file
_sampleCount = pAPEDecompress->GetInfo (APE_DECOMPRESS_TOTAL_BLOCKS, 0, 0); // * ?
}
~APEReader ()
{
if (pBuffer) delete [] pBuffer;
if (_path) delete [] _path;
}
property Int32 BitsPerSample {
Int32 get() {
return _bitsPerSample;
}
}
property Int32 ChannelCount {
Int32 get() {
return _channelCount;
}
}
property Int32 SampleRate {
Int32 get() {
return _sampleRate;
}
}
property Int64 Length {
Int64 get() {
return _sampleCount;
}
}
property Int64 Position {
Int64 get() {
return _sampleOffset;
}
void set(Int64 offset) {
_sampleOffset = offset;
_samplesWaiting = false;
if (pAPEDecompress->Seek ((int) offset /*? */))
throw gcnew Exception("Unable to seek.");
}
}
property Int64 Remaining {
Int64 get() {
return _sampleCount - _sampleOffset;
}
}
void Close() {
if (pAPEDecompress) delete pAPEDecompress;
pAPEDecompress = NULL;
}
property NameValueCollection^ Tags {
NameValueCollection^ get () {
if (!_tags) GetTags ();
return _tags;
}
void set (NameValueCollection ^tags) {
_tags = tags;
}
}
Int32 Read([Out] array<Int32, 2>^% sampleBuffer) {
int sampleCount;
int nBlocksRetrieved;
if (pAPEDecompress->GetData ((char *) pBuffer, 16384, &nBlocksRetrieved))
throw gcnew Exception("An error occurred while decoding.");
sampleCount = nBlocksRetrieved;
array<Int32,2>^ _sampleBuffer = gcnew array<Int32,2> (nBlocksRetrieved, 2);
{
interior_ptr<Int32> pMyBuffer = &_sampleBuffer[0, 0];
unsigned short * pAPEBuffer = (unsigned short *) pBuffer;
unsigned short * pAPEBufferEnd = (unsigned short *) pBuffer + 2 * nBlocksRetrieved;
while (pAPEBuffer < pAPEBufferEnd) {
*(pMyBuffer++) = *(pAPEBuffer++);
*(pMyBuffer++) = *(pAPEBuffer++);
}
}
#if 0
for (int i = 0; i < nBlocksRetrieved; i++)
{
_sampleBuffer[i,0] = pBuffer[i*4] + (pBuffer[i*4+1] << 8);
_sampleBuffer[i,1] = pBuffer[i*4+2] + (pBuffer[i*4+3] << 8);
}
#endif
sampleBuffer = _sampleBuffer;
_sampleOffset += nBlocksRetrieved;
_samplesWaiting = false;
return sampleCount;
}
private:
IAPEDecompress * pAPEDecompress;
NameValueCollection^ _tags;
Int64 _sampleCount, _sampleOffset;
Int32 _bitsPerSample, _channelCount, _sampleRate;
int nBlockAlign;
bool _samplesWaiting;
unsigned char * pBuffer;
const wchar_t * _path;
void GetTags (void)
{
_tags = gcnew NameValueCollection();
CAPETag apeTag (_path, TRUE);
for (int i = 0; ; i++)
{
CAPETagField * field = apeTag.GetTagField (i);
if (!field)
break;
if (field->GetIsUTF8Text())
{
int valueSize = field->GetFieldValueSize();
while (valueSize && field->GetFieldValue()[valueSize-1]=='\0')
valueSize --;
const wchar_t * fieldName = field->GetFieldName ();
if (!wcsicmp (fieldName, L"YEAR"))
fieldName = L"DATE";
if (!wcsicmp (fieldName, L"TRACK"))
fieldName = L"TRACKNUMBER";
_tags->Add (gcnew String (fieldName),
gcnew String (field->GetFieldValue(), 0, valueSize, System::Text::Encoding::UTF8));
}
}
}
#if 0
APE__StreamDecoderWriteStatus WriteCallback(const APE__StreamDecoder *decoder,
const APE__Frame *frame, const APE__int32 * const buffer[], void *client_data)
{
if ((_sampleBuffer == nullptr) || (_sampleBuffer->GetLength(0) != sampleCount)) {
_sampleBuffer = gcnew array<Int32, 2>(sampleCount, _channelCount);
}
for (Int32 iChan = 0; iChan < _channelCount; iChan++) {
interior_ptr<Int32> pMyBuffer = &_sampleBuffer[0, iChan];
const APE__int32 *pAPEBuffer = buffer[iChan];
const APE__int32 *pAPEBufferEnd = pAPEBuffer + sampleCount;
while (pAPEBuffer < pAPEBufferEnd) {
*pMyBuffer = *pAPEBuffer;
pMyBuffer += _channelCount;
pAPEBuffer++;
}
}
}
#endif
};
}

BIN
APEDotNet/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

63
APEDotNet/app.rc Normal file
View File

@@ -0,0 +1,63 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon placed first or with lowest ID value becomes application icon
LANGUAGE 25, 1
#pragma code_page(1251)
1 ICON "app.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
"\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

3
APEDotNet/resource.h Normal file
View File

@@ -0,0 +1,3 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc

View File

@@ -0,0 +1,6 @@
// This is the main DLL file.
#include "stdafx.h"
#include "APETagsDotNet.h"

View File

@@ -0,0 +1,158 @@
// APETagsDotNet.h
#pragma once
using namespace System;
using namespace System::Runtime::InteropServices;
#include <string.h>
/*****************************************************************************************
The version of the APE tag
*****************************************************************************************/
#define CURRENT_APE_TAG_VERSION 2000
/*****************************************************************************************
Footer (and header) flags
*****************************************************************************************/
#define APE_TAG_FLAG_CONTAINS_HEADER (1 << 31)
#define APE_TAG_FLAG_CONTAINS_FOOTER (1 << 30)
#define APE_TAG_FLAG_IS_HEADER (1 << 29)
#define APE_TAG_FLAGS_DEFAULT (APE_TAG_FLAG_CONTAINS_FOOTER)
/*****************************************************************************************
Tag field flags
*****************************************************************************************/
#define TAG_FIELD_FLAG_READ_ONLY (1 << 0)
#define TAG_FIELD_FLAG_DATA_TYPE_MASK (6)
#define TAG_FIELD_FLAG_DATA_TYPE_TEXT_UTF8 (0 << 1)
#define TAG_FIELD_FLAG_DATA_TYPE_BINARY (1 << 1)
#define TAG_FIELD_FLAG_DATA_TYPE_EXTERNAL_INFO (2 << 1)
#define TAG_FIELD_FLAG_DATA_TYPE_RESERVED (3 << 1)
/*****************************************************************************************
The footer at the end of APE tagged files (can also optionally be at the front of the tag)
*****************************************************************************************/
#define APE_TAG_FOOTER_BYTES 32
namespace APETagsDotNet {
ref class APE_TAG_FOOTER
{
protected:
String^ m_cID; // should equal 'APETAGEX'
int m_nVersion; // equals CURRENT_APE_TAG_VERSION
int m_nSize; // the complete size of the tag, including this footer (excludes header)
int m_nFields; // the number of fields in the tag
int m_nFlags; // the tag flags
array<unsigned char>^ m_cReserved; // reserved for later use (must be zero)
public:
APE_TAG_FOOTER(int nFields, int nFieldBytes)
{
//TODO
//m_cID = gcnew array<unsigned char> (8);
//Marshal::Copy (m_cID, 0, (IntPtr) "APETAGEX", 8);
m_cID = gcnew String ("APETAGEX");
m_cReserved = gcnew array<unsigned char> (8);
//TODO
//memset(m_cReserved, 0, 8);
m_nFields = nFields;
m_nFlags = APE_TAG_FLAGS_DEFAULT;
m_nSize = nFieldBytes + APE_TAG_FOOTER_BYTES;
m_nVersion = CURRENT_APE_TAG_VERSION;
}
property Int32 TotalTagBytes { Int32 get() { return m_nSize + (HasHeader ? APE_TAG_FOOTER_BYTES : 0); } }
property Int32 FieldBytes { Int32 get() { return m_nSize - APE_TAG_FOOTER_BYTES; } }
property Int32 FieldsOffset { Int32 get() { return HasHeader ? APE_TAG_FOOTER_BYTES : 0; } }
property Int32 NumberFields { Int32 get() { return m_nFields; } }
property bool HasHeader { bool get() { return (m_nFlags & APE_TAG_FLAG_CONTAINS_HEADER) != 0; } }
property bool IsHeader { bool get() { return (m_nFlags & APE_TAG_FLAG_IS_HEADER) != 0; } }
property Int32 Version { Int32 get() { return m_nVersion; } }
bool GetIsValid (bool bAllowHeader)
{
//TODO
return //(strncmp(m_cID, "APETAGEX", 8) == 0) &&
(m_nVersion <= CURRENT_APE_TAG_VERSION) &&
(m_nFields <= 65536) &&
(FieldBytes <= (1024 * 1024 * 16)) &&
(bAllowHeader || !IsHeader);
}
};
public ref class APETagField
{
public:
// create a tag field (use nFieldBytes = -1 for null-terminated strings)
APETagField (String^ fieldName, array<unsigned char>^ fieldValue, int fieldFlags) {
_fieldName = fieldName;
_fieldValue = fieldValue;
_fieldFlags = fieldFlags;
}
// destructor
~APETagField() {
}
// gets the size of the entire field in bytes (name, value, and metadata)
int GetFieldSize()
{
return _fieldName->Length + 1 + _fieldValue->Length + 4 + 4;
}
// get the name of the field
property String^ FieldName {
String ^ get() { return _fieldName; }
}
// get the value of the field
property array<unsigned char>^ FieldValue {
array<unsigned char>^ get() { return _fieldValue; }
}
// output the entire field to a buffer (GetFieldSize() bytes)
int SaveField(char * pBuffer)
{
//TODO
//*((int *) pBuffer) = m_nFieldValueBytes;
//pBuffer += 4;
//*((int *) pBuffer) = m_nFieldFlags;
//pBuffer += 4;
//
//CSmartPtr<char> spFieldNameANSI((char *) GetANSIFromUTF16(m_spFieldNameUTF16), TRUE);
//strcpy(pBuffer, spFieldNameANSI);
//pBuffer += strlen(spFieldNameANSI) + 1;
//memcpy(pBuffer, m_spFieldValue, m_nFieldValueBytes);
return GetFieldSize();
}
// checks to see if the field is read-only
property bool IsReadOnly { bool get() { return (_fieldFlags & TAG_FIELD_FLAG_READ_ONLY) != 0; } }
property bool IsUTF8Text { bool get() { return (_fieldFlags & TAG_FIELD_FLAG_DATA_TYPE_MASK) == TAG_FIELD_FLAG_DATA_TYPE_TEXT_UTF8; } }
// set helpers (use with EXTREME caution)
property Int32 FieldFlags {
Int32 get() { return _fieldFlags; }
void set(Int32 fieldFlags) { _fieldFlags = fieldFlags; }
}
private:
String^ _fieldName;
array<unsigned char>^ _fieldValue;
int _fieldFlags;
int _fieldValueBytes;
};
public ref class APETagsDotNet
{
};
}

View File

@@ -0,0 +1,422 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="APETagsDotNet"
ProjectGUID="{A8662B81-5B09-487E-B8F6-28251A8C46AF}"
RootNamespace="APETagsDotNet"
Keyword="ManagedCProj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
AssemblyDebug="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
AssemblyDebug="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
<AssemblyReference
RelativePath="System.dll"
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
/>
<AssemblyReference
RelativePath="System.Data.dll"
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
/>
<AssemblyReference
RelativePath="System.XML.dll"
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
/>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\APETagsDotNet.cpp"
>
</File>
<File
RelativePath=".\AssemblyInfo.cpp"
>
</File>
<File
RelativePath=".\Stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\APETagsDotNet.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\Stdafx.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\app.ico"
>
</File>
<File
RelativePath=".\app.rc"
>
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,40 @@
#include "stdafx.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// 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:AssemblyTitleAttribute("APETagsDotNet")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("Microsoft")];
[assembly:AssemblyProductAttribute("APETagsDotNet")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) Microsoft 2008")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];

31
APETagsDotNet/ReadMe.txt Normal file
View File

@@ -0,0 +1,31 @@
========================================================================
DYNAMIC LINK LIBRARY : APETagsDotNet Project Overview
========================================================================
AppWizard has created this APETagsDotNet DLL for you.
This file contains a summary of what you will find in each of the files that
make up your APETagsDotNet application.
APETagsDotNet.vcproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
APETagsDotNet.cpp
This is the main DLL source file.
APETagsDotNet.h
This file contains a class declaration.
AssemblyInfo.cpp
Contains custom attributes for modifying assembly metadata.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////

5
APETagsDotNet/Stdafx.cpp Normal file
View File

@@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// APETagsDotNet.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

7
APETagsDotNet/Stdafx.h Normal file
View File

@@ -0,0 +1,7 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once

BIN
APETagsDotNet/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

63
APETagsDotNet/app.rc Normal file
View File

@@ -0,0 +1,63 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon placed first or with lowest ID value becomes application icon
LANGUAGE 25, 1
#pragma code_page(1251)
1 ICON "app.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
"\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

3
APETagsDotNet/resource.h Normal file
View File

@@ -0,0 +1,3 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc

874
CUETools/AudioReadWrite.cs Normal file
View File

@@ -0,0 +1,874 @@
using System;
using System.IO;
using FLACDotNet;
using WavPackDotNet;
using APEDotNet;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace JDP {
public interface IAudioSource {
uint Read(byte[] buff, uint sampleCount);
ulong Length { get; }
ulong Position { get; set; }
NameValueCollection Tags { get; set; }
ulong Remaining { get; }
void Close();
int BitsPerSample { get; }
int ChannelCount { get; }
int SampleRate { get; }
}
public interface IAudioDest {
void Write(byte[] buff, uint sampleCount);
void Close();
long FinalSampleCount { set; }
}
public static class AudioReadWrite {
public static IAudioSource GetAudioSource(string path) {
switch (Path.GetExtension(path).ToLower()) {
case ".wav":
return new WAVReader(path);
case ".flac":
return new FLACReader(path);
case ".wv":
return new WavPackReader(path);
case ".ape":
return new APEReader(path);
default:
throw new Exception("Unsupported audio type.");
}
}
public static IAudioDest GetAudioDest(string path, int bitsPerSample, int channelCount, int sampleRate, long finalSampleCount) {
IAudioDest dest;
switch (Path.GetExtension(path).ToLower()) {
case ".wav":
dest = new WAVWriter(path, bitsPerSample, channelCount, sampleRate); break;
case ".flac":
dest = new FLACWriter(path, bitsPerSample, channelCount, sampleRate); break;
case ".wv":
dest = new WavPackWriter(path, bitsPerSample, channelCount, sampleRate); break;
case ".dummy":
dest = new DummyWriter(path, bitsPerSample, channelCount, sampleRate); break;
default:
throw new Exception("Unsupported audio type.");
}
dest.FinalSampleCount = finalSampleCount;
return dest;
}
}
public class DummyWriter : IAudioDest {
public DummyWriter (string path, int bitsPerSample, int channelCount, int sampleRate) {
}
public void Close() {
}
public long FinalSampleCount {
set {
}
}
public void Write(byte[] buff, uint sampleCount) {
}
}
public class WAVReader : IAudioSource {
FileStream _fs;
BinaryReader _br;
ulong _dataOffset, _dataLen;
ulong _samplePos, _sampleLen;
int _bitsPerSample, _channelCount, _sampleRate, _blockAlign;
bool _largeFile;
public WAVReader(string path) {
_fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
_br = new BinaryReader(_fs);
ParseHeaders();
_sampleLen = _dataLen / (uint)_blockAlign;
Position = 0;
}
public void Close() {
_br.Close();
_br = null;
_fs = null;
}
private void ParseHeaders() {
const long maxFileSize = 0x7FFFFFFEL;
const uint fccRIFF = 0x46464952;
const uint fccWAVE = 0x45564157;
const uint fccFormat = 0x20746D66;
const uint fccData = 0x61746164;
uint lenRIFF;
long fileEnd;
bool foundFormat, foundData;
if (_br.ReadUInt32() != fccRIFF) {
throw new Exception("Not a valid RIFF file.");
}
lenRIFF = _br.ReadUInt32();
fileEnd = (long)lenRIFF + 8;
if (_br.ReadUInt32() != fccWAVE) {
throw new Exception("Not a valid WAVE file.");
}
_largeFile = false;
foundFormat = false;
foundData = false;
while (_fs.Position < fileEnd) {
uint ckID, ckSize, ckSizePadded;
long ckEnd;
ckID = _br.ReadUInt32();
ckSize = _br.ReadUInt32();
ckSizePadded = (ckSize + 1U) & ~1U;
ckEnd = _fs.Position + (long)ckSizePadded;
if (ckID == fccFormat) {
foundFormat = true;
if (_br.ReadUInt16() != 1) {
throw new Exception("WAVE must be PCM format.");
}
_channelCount = _br.ReadInt16();
_sampleRate = _br.ReadInt32();
_br.ReadInt32();
_blockAlign = _br.ReadInt16();
_bitsPerSample = _br.ReadInt16();
}
else if (ckID == fccData) {
foundData = true;
_dataOffset = (ulong) _fs.Position;
if (_fs.Length <= maxFileSize) {
_dataLen = ckSize;
}
else {
_largeFile = true;
_dataLen = ((ulong)_fs.Length) - _dataOffset;
}
}
if ((foundFormat & foundData) || _largeFile) {
break;
}
_fs.Seek(ckEnd, SeekOrigin.Begin);
}
if ((foundFormat & foundData) == false) {
throw new Exception("Format or data chunk not found.");
}
if (_channelCount <= 0) {
throw new Exception("Channel count is invalid.");
}
if (_sampleRate <= 0) {
throw new Exception("Sample rate is invalid.");
}
if (_blockAlign != (_channelCount * ((_bitsPerSample + 7) / 8))) {
throw new Exception("Block align is invalid.");
}
if ((_bitsPerSample <= 0) || (_bitsPerSample > 32)) {
throw new Exception("Bits per sample is invalid.");
}
}
public ulong Position {
get {
return _samplePos;
}
set {
ulong seekPos;
if (value > _sampleLen) {
_samplePos = _sampleLen;
}
else {
_samplePos = value;
}
seekPos = _dataOffset + (_samplePos * (uint)_blockAlign);
_fs.Seek((long) seekPos, SeekOrigin.Begin);
}
}
public ulong Length {
get {
return _sampleLen;
}
}
public ulong Remaining {
get {
return _sampleLen - _samplePos;
}
}
public int ChannelCount {
get {
return _channelCount;
}
}
public int SampleRate {
get {
return _sampleRate;
}
}
public int BitsPerSample {
get {
return _bitsPerSample;
}
}
public int BlockAlign {
get {
return _blockAlign;
}
}
public NameValueCollection Tags {
get {
return new NameValueCollection();
}
set {
}
}
public void GetTags(out List<string> names, out List<string> values)
{
names = new List<string>();
values = new List<string>();
}
public uint Read(byte[] buff, uint sampleCount) {
if (sampleCount > Remaining)
sampleCount = (uint) Remaining;
uint byteCount = sampleCount * (uint) _blockAlign;
if (sampleCount != 0) {
if (_fs.Read(buff, 0, (int) byteCount) != byteCount) {
throw new Exception("Incomplete file read.");
}
_samplePos += sampleCount;
}
return sampleCount;
}
}
public class WAVWriter : IAudioDest {
FileStream _fs;
BinaryWriter _bw;
int _bitsPerSample, _channelCount, _sampleRate, _blockAlign;
long _sampleLen;
public WAVWriter(string path, int bitsPerSample, int channelCount, int sampleRate) {
_bitsPerSample = bitsPerSample;
_channelCount = channelCount;
_sampleRate = sampleRate;
_blockAlign = _channelCount * ((_bitsPerSample + 7) / 8);
_fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read);
_bw = new BinaryWriter(_fs);
WriteHeaders();
}
private void WriteHeaders() {
const uint fccRIFF = 0x46464952;
const uint fccWAVE = 0x45564157;
const uint fccFormat = 0x20746D66;
const uint fccData = 0x61746164;
_bw.Write(fccRIFF);
_bw.Write((uint)0);
_bw.Write(fccWAVE);
_bw.Write(fccFormat);
_bw.Write((uint)16);
_bw.Write((ushort)1);
_bw.Write((ushort)_channelCount);
_bw.Write((uint)_sampleRate);
_bw.Write((uint)(_sampleRate * _blockAlign));
_bw.Write((ushort)_blockAlign);
_bw.Write((ushort)_bitsPerSample);
_bw.Write(fccData);
_bw.Write((uint)0);
}
public void Close() {
const long maxFileSize = 0x7FFFFFFEL;
long dataLen, dataLenPadded;
dataLen = _sampleLen * _blockAlign;
if ((dataLen & 1) == 1) {
_bw.Write((byte)0);
}
if ((dataLen + 44) > maxFileSize) {
dataLen = ((maxFileSize - 44) / _blockAlign) * _blockAlign;
}
dataLenPadded = ((dataLen & 1) == 1) ? (dataLen + 1) : dataLen;
_bw.Seek(4, SeekOrigin.Begin);
_bw.Write((uint)(dataLenPadded + 36));
_bw.Seek(40, SeekOrigin.Begin);
_bw.Write((uint)dataLen);
_bw.Close();
_bw = null;
_fs = null;
}
public long Position {
get {
return _sampleLen;
}
}
public long FinalSampleCount {
set {
}
}
public void Write(byte[] buff, uint sampleCount) {
if (sampleCount < 0) {
sampleCount = 0;
}
if (sampleCount != 0) {
_fs.Write(buff, 0, (int) sampleCount * _blockAlign);
_sampleLen += sampleCount;
}
}
}
class FLACReader : IAudioSource {
FLACDotNet.FLACReader _flacReader;
int[,] _sampleBuffer;
uint _bufferOffset, _bufferLength;
public FLACReader(string path) {
_flacReader = new FLACDotNet.FLACReader(path);
_bufferOffset = 0;
_bufferLength = 0;
}
public void Close() {
_flacReader.Close();
}
public NameValueCollection Tags
{
get { return _flacReader.Tags; }
set { _flacReader.Tags = value; }
}
public bool UpdateTags()
{
return _flacReader.UpdateTags();
}
public ulong Length {
get {
return (ulong) _flacReader.Length;
}
}
public ulong Remaining {
get {
return (ulong) _flacReader.Remaining + SamplesInBuffer;
}
}
public ulong Position {
get {
return (ulong) _flacReader.Position - SamplesInBuffer;
}
set {
_flacReader.Position = (long) value;
_bufferOffset = 0;
_bufferLength = 0;
}
}
private uint SamplesInBuffer {
get {
return (uint) (_bufferLength - _bufferOffset);
}
}
public int BitsPerSample {
get {
return _flacReader.BitsPerSample;
}
}
public int ChannelCount {
get {
return _flacReader.ChannelCount;
}
}
public int SampleRate {
get {
return _flacReader.SampleRate;
}
}
private unsafe void FLACSamplesToBytes_16(int[,] inSamples, uint inSampleOffset,
byte[] outSamples, uint outByteOffset, uint sampleCount, int channelCount)
{
uint loopCount = sampleCount * (uint) channelCount;
if ((inSamples.GetLength(0) - inSampleOffset < sampleCount) ||
(outSamples.Length - outByteOffset < loopCount * 2))
{
throw new IndexOutOfRangeException();
}
fixed (int* pInSamplesFixed = &inSamples[inSampleOffset, 0]) {
fixed (byte* pOutSamplesFixed = &outSamples[outByteOffset]) {
int* pInSamples = pInSamplesFixed;
short* pOutSamples = (short*)pOutSamplesFixed;
for (int i = 0; i < loopCount; i++) {
*(pOutSamples++) = (short)*(pInSamples++);
}
}
}
}
public uint Read(byte[] buff, uint sampleCount) {
if (_flacReader.BitsPerSample != 16) {
throw new Exception("Reading is only supported for 16 bit sample depth.");
}
int chanCount = _flacReader.ChannelCount;
uint copyCount;
uint buffOffset = 0;
uint samplesNeeded = sampleCount;
while (samplesNeeded != 0) {
if (SamplesInBuffer == 0) {
_bufferOffset = 0;
_bufferLength = (uint) _flacReader.Read(out _sampleBuffer);
}
copyCount = Math.Min(samplesNeeded, SamplesInBuffer);
FLACSamplesToBytes_16(_sampleBuffer, _bufferOffset, buff, buffOffset,
copyCount, chanCount);
samplesNeeded -= copyCount;
buffOffset += copyCount * (uint) chanCount * 2;
_bufferOffset += copyCount;
}
return sampleCount;
}
}
class FLACWriter : IAudioDest {
FLACDotNet.FLACWriter _flacWriter;
int[,] _sampleBuffer;
int _bitsPerSample;
int _channelCount;
int _sampleRate;
public FLACWriter(string path, int bitsPerSample, int channelCount, int sampleRate) {
if (bitsPerSample != 16) {
throw new Exception("Bits per sample must be 16.");
}
_bitsPerSample = bitsPerSample;
_channelCount = channelCount;
_sampleRate = sampleRate;
_flacWriter = new FLACDotNet.FLACWriter(path, bitsPerSample, channelCount, sampleRate);
}
public long FinalSampleCount {
get {
return _flacWriter.FinalSampleCount;
}
set {
_flacWriter.FinalSampleCount = value;
}
}
public int CompressionLevel {
get {
return _flacWriter.CompressionLevel;
}
set {
_flacWriter.CompressionLevel = value;
}
}
public bool Verify {
get {
return _flacWriter.Verify;
}
set {
_flacWriter.Verify = value;
}
}
public void SetTags(NameValueCollection tags)
{
_flacWriter.SetTags (tags);
}
public void Close() {
_flacWriter.Close();
}
private unsafe void BytesToFLACSamples_16(byte[] inSamples, int inByteOffset,
int[,] outSamples, int outSampleOffset, uint sampleCount, int channelCount)
{
uint loopCount = sampleCount * (uint) channelCount;
if ((inSamples.Length - inByteOffset < loopCount * 2) ||
(outSamples.GetLength(0) - outSampleOffset < sampleCount))
{
throw new IndexOutOfRangeException();
}
fixed (byte* pInSamplesFixed = &inSamples[inByteOffset]) {
fixed (int* pOutSamplesFixed = &outSamples[outSampleOffset, 0]) {
short* pInSamples = (short*)pInSamplesFixed;
int* pOutSamples = pOutSamplesFixed;
for (int i = 0; i < loopCount; i++) {
*(pOutSamples++) = (int)*(pInSamples++);
}
}
}
}
public void Write(byte[] buff, uint sampleCount) {
if ((_sampleBuffer == null) || (_sampleBuffer.GetLength(0) < sampleCount)) {
_sampleBuffer = new int[sampleCount, _channelCount];
}
BytesToFLACSamples_16(buff, 0, _sampleBuffer, 0, sampleCount, _channelCount);
_flacWriter.Write(_sampleBuffer, (int) sampleCount);
}
}
class APEReader : IAudioSource {
APEDotNet.APEReader _apeReader;
int[,] _sampleBuffer;
uint _bufferOffset, _bufferLength;
public APEReader(string path) {
_apeReader = new APEDotNet.APEReader(path);
_bufferOffset = 0;
_bufferLength = 0;
}
public void Close() {
_apeReader.Close();
}
public ulong Length {
get {
return (ulong) _apeReader.Length;
}
}
public ulong Remaining {
get {
return (ulong) _apeReader.Remaining + SamplesInBuffer;
}
}
public ulong Position {
get {
return (ulong) _apeReader.Position - SamplesInBuffer;
}
set {
_apeReader.Position = (long) value;
_bufferOffset = 0;
_bufferLength = 0;
}
}
private uint SamplesInBuffer {
get {
return (uint) (_bufferLength - _bufferOffset);
}
}
public int BitsPerSample {
get {
return _apeReader.BitsPerSample;
}
}
public int ChannelCount {
get {
return _apeReader.ChannelCount;
}
}
public int SampleRate {
get {
return _apeReader.SampleRate;
}
}
public NameValueCollection Tags
{
get { return _apeReader.Tags; }
set { _apeReader.Tags = value; }
}
private unsafe void APESamplesToBytes_16(int[,] inSamples, uint inSampleOffset,
byte[] outSamples, uint outByteOffset, uint sampleCount, int channelCount)
{
uint loopCount = sampleCount * (uint) channelCount;
if ((inSamples.GetLength(0) - inSampleOffset < sampleCount) ||
(outSamples.Length - outByteOffset < loopCount * 2))
{
throw new IndexOutOfRangeException();
}
fixed (int* pInSamplesFixed = &inSamples[inSampleOffset, 0]) {
fixed (byte* pOutSamplesFixed = &outSamples[outByteOffset]) {
int* pInSamples = pInSamplesFixed;
short* pOutSamples = (short*)pOutSamplesFixed;
for (int i = 0; i < loopCount; i++) {
*(pOutSamples++) = (short)*(pInSamples++);
}
}
}
}
public uint Read(byte[] buff, uint sampleCount) {
if (_apeReader.BitsPerSample != 16) {
throw new Exception("Reading is only supported for 16 bit sample depth.");
}
int chanCount = _apeReader.ChannelCount;
uint samplesNeeded, copyCount, buffOffset;
buffOffset = 0;
samplesNeeded = sampleCount;
while (samplesNeeded != 0) {
if (SamplesInBuffer == 0) {
_bufferOffset = 0;
_bufferLength = (uint) _apeReader.Read(out _sampleBuffer);
}
copyCount = Math.Min(samplesNeeded, SamplesInBuffer);
APESamplesToBytes_16(_sampleBuffer, _bufferOffset, buff, buffOffset,
copyCount, chanCount);
samplesNeeded -= copyCount;
buffOffset += copyCount * (uint) chanCount * 2;
_bufferOffset += copyCount;
}
return sampleCount;
}
}
class WavPackReader : IAudioSource {
WavPackDotNet.WavPackReader _wavPackReader;
public WavPackReader(string path) {
_wavPackReader = new WavPackDotNet.WavPackReader(path);
}
public void Close() {
_wavPackReader.Close();
}
public ulong Length {
get {
return (ulong) _wavPackReader.Length;
}
}
public ulong Remaining {
get {
return (ulong) _wavPackReader.Remaining;
}
}
public ulong Position {
get {
return (ulong) _wavPackReader.Position;
}
set {
_wavPackReader.Position = (int) value;
}
}
public int BitsPerSample {
get {
return _wavPackReader.BitsPerSample;
}
}
public int ChannelCount {
get {
return _wavPackReader.ChannelCount;
}
}
public int SampleRate {
get {
return _wavPackReader.SampleRate;
}
}
public NameValueCollection Tags
{
get { return _wavPackReader.Tags; }
set { _wavPackReader.Tags = value; }
}
private unsafe void WavPackSamplesToBytes_16(int[,] inSamples, uint inSampleOffset,
byte[] outSamples, uint outByteOffset, uint sampleCount, int channelCount)
{
uint loopCount = sampleCount * (uint) channelCount;
if ((inSamples.GetLength(0) - inSampleOffset < sampleCount) ||
(outSamples.Length - outByteOffset < loopCount * 2))
{
throw new IndexOutOfRangeException();
}
fixed (int* pInSamplesFixed = &inSamples[inSampleOffset, 0]) {
fixed (byte* pOutSamplesFixed = &outSamples[outByteOffset]) {
int* pInSamples = pInSamplesFixed;
short* pOutSamples = (short*)pOutSamplesFixed;
for (int i = 0; i < loopCount; i++) {
*(pOutSamples++) = (short)*(pInSamples++);
}
}
}
}
public uint Read(byte[] buff, uint sampleCount) {
if (_wavPackReader.BitsPerSample != 16) {
throw new Exception("Reading is only supported for 16 bit sample depth.");
}
int chanCount = _wavPackReader.ChannelCount;
int[,] sampleBuffer;
sampleBuffer = new int[sampleCount * 2, chanCount];
_wavPackReader.Read(sampleBuffer, (int) sampleCount);
WavPackSamplesToBytes_16(sampleBuffer, 0, buff, 0, sampleCount, chanCount);
return sampleCount;
}
}
class WavPackWriter : IAudioDest {
WavPackDotNet.WavPackWriter _wavPackWriter;
int[,] _sampleBuffer;
int _bitsPerSample;
int _channelCount;
int _sampleRate;
public WavPackWriter(string path, int bitsPerSample, int channelCount, int sampleRate) {
if (bitsPerSample != 16) {
throw new Exception("Bits per sample must be 16.");
}
_bitsPerSample = bitsPerSample;
_channelCount = channelCount;
_sampleRate = sampleRate;
_wavPackWriter = new WavPackDotNet.WavPackWriter(path, bitsPerSample, channelCount, sampleRate);
}
public long FinalSampleCount {
get {
return _wavPackWriter.FinalSampleCount;
}
set {
_wavPackWriter.FinalSampleCount = (int)value;
}
}
public int CompressionMode {
get {
return _wavPackWriter.CompressionMode;
}
set {
_wavPackWriter.CompressionMode = value;
}
}
public int ExtraMode {
get {
return _wavPackWriter.ExtraMode;
}
set {
_wavPackWriter.ExtraMode = value;
}
}
public void Close() {
_wavPackWriter.Close();
}
private unsafe void BytesToWavPackSamples_16(byte[] inSamples, int inByteOffset,
int[,] outSamples, int outSampleOffset, uint sampleCount, int channelCount)
{
uint loopCount = sampleCount * (uint) channelCount;
if ((inSamples.Length - inByteOffset < loopCount * 2) ||
(outSamples.GetLength(0) - outSampleOffset < sampleCount))
{
throw new IndexOutOfRangeException();
}
fixed (byte* pInSamplesFixed = &inSamples[inByteOffset]) {
fixed (int* pOutSamplesFixed = &outSamples[outSampleOffset, 0]) {
short* pInSamples = (short*)pInSamplesFixed;
int* pOutSamples = pOutSamplesFixed;
for (int i = 0; i < loopCount; i++) {
*(pOutSamples++) = (int)*(pInSamples++);
}
}
}
}
public void Write(byte[] buff, uint sampleCount) {
if ((_sampleBuffer == null) || (_sampleBuffer.GetLength(0) < sampleCount)) {
_sampleBuffer = new int[sampleCount, _channelCount];
}
BytesToWavPackSamples_16(buff, 0, _sampleBuffer, 0, sampleCount, _channelCount);
_wavPackWriter.Write(_sampleBuffer, (int) sampleCount);
}
}
}

176
CUETools/CUETools.csproj Normal file
View File

@@ -0,0 +1,176 @@
<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>{EF351583-A9CD-4530-92C3-20AC02136BC2}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>JDP</RootNamespace>
<AssemblyName>CUETools</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>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>AnyCPU</PlatformTarget>
</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>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\bin\win32\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>..\bin\win32\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>..\bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AudioReadWrite.cs" />
<Compile Include="frmBatch.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmBatch.Designer.cs">
<DependentUpon>frmBatch.cs</DependentUpon>
</Compile>
<Compile Include="frmFilenameCorrector.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmFilenameCorrector.Designer.cs">
<DependentUpon>frmFilenameCorrector.cs</DependentUpon>
</Compile>
<Compile Include="frmReport.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmReport.Designer.cs">
<DependentUpon>frmReport.cs</DependentUpon>
</Compile>
<Compile Include="frmSettings.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmSettings.Designer.cs">
<DependentUpon>frmSettings.cs</DependentUpon>
</Compile>
<Compile Include="Main.cs" />
<Compile Include="frmCUETools.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmCUETools.Designer.cs">
<DependentUpon>frmCUETools.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="frmBatch.resx">
<SubType>Designer</SubType>
<DependentUpon>frmBatch.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmCUETools.resx">
<SubType>Designer</SubType>
<DependentUpon>frmCUETools.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmFilenameCorrector.resx">
<SubType>Designer</SubType>
<DependentUpon>frmFilenameCorrector.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmReport.resx">
<SubType>Designer</SubType>
<DependentUpon>frmReport.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmSettings.resx">
<SubType>Designer</SubType>
<DependentUpon>frmSettings.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Settings.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\APEDotNet\APEDotNet.vcproj">
<Project>{9AE965C4-301E-4C01-B90F-297AF341ACC6}</Project>
<Name>APEDotNet</Name>
</ProjectReference>
<ProjectReference Include="..\FLACDotNet\FLACDotNet.vcproj">
<Project>{E70FA90A-7012-4A52-86B5-362B699D1540}</Project>
<Name>FLACDotNet</Name>
</ProjectReference>
<ProjectReference Include="..\WavPackDotNet\WavPackDotNet.vcproj">
<Project>{CC2E74B6-534A-43D8-9F16-AC03FE955000}</Project>
<Name>WavPackDotNet</Name>
</ProjectReference>
</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>

158
CUETools/CUETools.sln Normal file
View File

@@ -0,0 +1,158 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CUETools", "CUETools.csproj", "{EF351583-A9CD-4530-92C3-20AC02136BC2}"
ProjectSection(ProjectDependencies) = postProject
{9AE965C4-301E-4C01-B90F-297AF341ACC6} = {9AE965C4-301E-4C01-B90F-297AF341ACC6}
{E70FA90A-7012-4A52-86B5-362B699D1540} = {E70FA90A-7012-4A52-86B5-362B699D1540}
{CC2E74B6-534A-43D8-9F16-AC03FE955000} = {CC2E74B6-534A-43D8-9F16-AC03FE955000}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLACDotNet", "..\FLACDotNet\FLACDotNet.vcproj", "{E70FA90A-7012-4A52-86B5-362B699D1540}"
ProjectSection(ProjectDependencies) = postProject
{4CEFBC84-C215-11DB-8314-0800200C9A66} = {4CEFBC84-C215-11DB-8314-0800200C9A66}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APEDotNet", "..\APEDotNet\APEDotNet.vcproj", "{9AE965C4-301E-4C01-B90F-297AF341ACC6}"
ProjectSection(ProjectDependencies) = postProject
{0B9C97D4-61B8-4294-A1DF-BA90752A1779} = {0B9C97D4-61B8-4294-A1DF-BA90752A1779}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodecLibs", "CodecLibs", "{8B179853-B7D6-479C-B8B2-6CBCE835D040}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WavPackDotNet", "..\WavPackDotNet\WavPackDotNet.vcproj", "{CC2E74B6-534A-43D8-9F16-AC03FE955000}"
ProjectSection(ProjectDependencies) = postProject
{0B9C97D4-61B8-4294-A1DF-BA90752A1779} = {0B9C97D4-61B8-4294-A1DF-BA90752A1779}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MACLib", "..\MAC_SDK\Source\MACLib\MACLib.vcproj", "{0B9C97D4-61B8-4294-A1DF-BA90752A1779}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodecWrappers", "CodecWrappers", "{85F88959-C9E9-4989-ACB1-67BA9D1BEFE7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libFLAC_static", "..\flac\src\libFLAC\libFLAC_static.vcproj", "{4CEFBC84-C215-11DB-8314-0800200C9A66}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APETagsDotNet", "..\APETagsDotNet\APETagsDotNet.vcproj", "{A8662B81-5B09-487E-B8F6-28251A8C46AF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Debug|Win32.ActiveCfg = Debug|x86
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Debug|Win32.Build.0 = Debug|x86
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Debug|x64.ActiveCfg = Debug|x64
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Debug|x64.Build.0 = Debug|x64
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Debug|x86.ActiveCfg = Debug|x86
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Debug|x86.Build.0 = Debug|x86
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|Any CPU.Build.0 = Release|Any CPU
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|Win32.ActiveCfg = Release|x86
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|Win32.Build.0 = Release|x86
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|x64.ActiveCfg = Release|x64
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|x64.Build.0 = Release|x64
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|x86.ActiveCfg = Release|x86
{EF351583-A9CD-4530-92C3-20AC02136BC2}.Release|x86.Build.0 = Release|x86
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Any CPU.ActiveCfg = Debug|x64
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Win32.ActiveCfg = Debug|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Win32.Build.0 = Debug|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|x64.ActiveCfg = Debug|x64
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|x64.Build.0 = Debug|x64
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|x86.ActiveCfg = Debug|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|x86.Build.0 = Debug|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|Any CPU.ActiveCfg = Release|x64
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|Win32.ActiveCfg = Release|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|Win32.Build.0 = Release|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|x64.ActiveCfg = Release|x64
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|x64.Build.0 = Release|x64
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|x86.ActiveCfg = Release|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|x86.Build.0 = Release|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|Any CPU.ActiveCfg = Debug|x64
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|Win32.ActiveCfg = Debug|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|Win32.Build.0 = Debug|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|x64.ActiveCfg = Debug|x64
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|x64.Build.0 = Debug|x64
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|x86.ActiveCfg = Debug|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|x86.Build.0 = Debug|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|Any CPU.ActiveCfg = Release|x64
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|Win32.ActiveCfg = Release|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|Win32.Build.0 = Release|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|x64.ActiveCfg = Release|x64
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|x64.Build.0 = Release|x64
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|x86.ActiveCfg = Release|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|x86.Build.0 = Release|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|Any CPU.ActiveCfg = Debug|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|Win32.ActiveCfg = Debug|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|Win32.Build.0 = Debug|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|x64.ActiveCfg = Debug|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|x86.ActiveCfg = Debug|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Debug|x86.Build.0 = Debug|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|Any CPU.ActiveCfg = Release|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|Win32.ActiveCfg = Release|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|Win32.Build.0 = Release|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|x64.ActiveCfg = Release|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|x86.ActiveCfg = Release|Win32
{CC2E74B6-534A-43D8-9F16-AC03FE955000}.Release|x86.Build.0 = Release|Win32
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Debug|Any CPU.ActiveCfg = Debug|x64
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Debug|Win32.ActiveCfg = Debug|Win32
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Debug|Win32.Build.0 = Debug|Win32
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Debug|x64.ActiveCfg = Debug|x64
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Debug|x64.Build.0 = Debug|x64
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Debug|x86.ActiveCfg = Debug|Win32
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Debug|x86.Build.0 = Debug|Win32
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Release|Any CPU.ActiveCfg = Release|x64
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Release|Win32.ActiveCfg = Release|Win32
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Release|Win32.Build.0 = Release|Win32
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Release|x64.ActiveCfg = Release|x64
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Release|x64.Build.0 = Release|x64
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Release|x86.ActiveCfg = Release|Win32
{0B9C97D4-61B8-4294-A1DF-BA90752A1779}.Release|x86.Build.0 = Release|Win32
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|Any CPU.ActiveCfg = Debug|x64
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|Win32.ActiveCfg = Debug|Win32
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|Win32.Build.0 = Debug|Win32
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|x64.ActiveCfg = Debug|x64
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|x64.Build.0 = Debug|x64
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|x86.ActiveCfg = Debug|Win32
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Debug|x86.Build.0 = Debug|Win32
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|Any CPU.ActiveCfg = Release|x64
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|Win32.ActiveCfg = Release|Win32
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|Win32.Build.0 = Release|Win32
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|x64.ActiveCfg = Release|x64
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|x64.Build.0 = Release|x64
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|x86.ActiveCfg = Release|Win32
{4CEFBC84-C215-11DB-8314-0800200C9A66}.Release|x86.Build.0 = Release|Win32
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Debug|Any CPU.ActiveCfg = Debug|Win32
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Debug|Win32.ActiveCfg = Debug|Win32
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Debug|Win32.Build.0 = Debug|Win32
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Debug|x64.ActiveCfg = Debug|x64
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Debug|x64.Build.0 = Debug|x64
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Debug|x86.ActiveCfg = Debug|Win32
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Debug|x86.Build.0 = Debug|Win32
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Release|Any CPU.ActiveCfg = Release|Win32
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Release|Win32.ActiveCfg = Release|Win32
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Release|Win32.Build.0 = Release|Win32
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Release|x64.ActiveCfg = Release|x64
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Release|x64.Build.0 = Release|x64
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Release|x86.ActiveCfg = Release|Win32
{A8662B81-5B09-487E-B8F6-28251A8C46AF}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9AE965C4-301E-4C01-B90F-297AF341ACC6} = {85F88959-C9E9-4989-ACB1-67BA9D1BEFE7}
{CC2E74B6-534A-43D8-9F16-AC03FE955000} = {85F88959-C9E9-4989-ACB1-67BA9D1BEFE7}
{E70FA90A-7012-4A52-86B5-362B699D1540} = {85F88959-C9E9-4989-ACB1-67BA9D1BEFE7}
{A8662B81-5B09-487E-B8F6-28251A8C46AF} = {85F88959-C9E9-4989-ACB1-67BA9D1BEFE7}
{0B9C97D4-61B8-4294-A1DF-BA90752A1779} = {8B179853-B7D6-479C-B8B2-6CBCE835D040}
{4CEFBC84-C215-11DB-8314-0800200C9A66} = {8B179853-B7D6-479C-B8B2-6CBCE835D040}
EndGlobalSection
EndGlobal

340
CUETools/GPL.txt Normal file
View File

@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

2404
CUETools/Main.cs Normal file

File diff suppressed because it is too large Load Diff

27
CUETools/Program.cs Normal file
View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace JDP {
static class Program {
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args.Length == 2 && (args[0] == "/verify" || args[0] == "/convert" || args[0] == "/fix"))
{
frmBatch batch = new frmBatch();
batch.InputPath = args[1];
batch.AccurateRip = (args[0] != "/convert");
batch.AccurateOffset = (args[0] == "/fix");
Application.Run (batch);
return;
}
frmCUETools form = new frmCUETools();
if (args.Length == 1)
form.InputPath = args[0];
Application.Run(form);
}
}
}

View File

@@ -0,0 +1,33 @@
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("CUE Tools")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Copyright 2006-2007 Moitah")]
[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("8ce8b79b-411e-4989-982b-df51ae457e80")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.9.0.1")]
[assembly: AssemblyFileVersion("1.9.0.1")]

View File

@@ -0,0 +1,72 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1434
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace JDP.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JDP.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to Verify.
/// </summary>
internal static string Verify {
get {
return ResourceManager.GetString("Verify", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Verify" xml:space="preserve">
<value>Verify</value>
</data>
</root>

26
CUETools/Properties/Settings.Designer.cs generated Normal file
View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.832
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace JDP.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

74
CUETools/ReadMe.txt Normal file
View File

@@ -0,0 +1,74 @@
There is no installation, just unzip to a new folder in the "Program Files"
folder. The .NET Framework 2.0 (x86) is required. If you get a "could not
load file or assembly" error message for FLACDotNet or WavPackDotNet, make sure
the Visual C++ 2005 SP1 runtime files (x86) are installed.
As an alternative to the Browse button, the input path may be set by dragging
a .cue file onto the input path text box.
"Output Style" naming compared to Exact Audio Copy:
CUE Tools: Exact Audio Copy:
Single File Single WAV File
Gaps Appended Multiple WAV Files With Gaps (Noncompliant)
Gaps Prepended Multiple WAV Files With Corrected Gaps
Gaps Left Out Multiple WAV Files With Leftout Gaps
Audio filename formatting variables (case sensitive). The values are obtained
from the CUE sheet only (not from any tags within the input audio files):
%D - Album artist
%C - Album title
%N - Track number
%A - Track artist
%T - Track title
%F - Filename of the input CUE sheet without extension
A "special character" is anything other than a-z, A-Z, 0-9, space, or
underscore.
Custom output path formatting variables (case sensitive). The remove special
characters and replace spaces audio filename settings also apply to %D and %C
here:
%D - Album artist
%C - Album title
%F - Filename of the input CUE sheet without extension
%0 - Full directory of the input CUE sheet
%x (where x is an integer) - Part of the directory of the input CUE sheet.
For example if the input CUE sheet is located in C:\Stuff\CUEs, %1 = C:,
%2 = Stuff, %3 = CUEs. Negative numbers start from the end of the
directory, i.e. %-1 = CUEs, %-2 = Stuff, %-3 = E:.
%x:y (where x/y are integers) - Same as above but specifies a range.
"Write offset" is the same as "Write samples offset" in Exact Audio Copy. For
negative offsets, silence is added at the beginning and samples are removed
from the end. For positive offsets, samples are removed from the beginning and
silence is added at the end.
The "Preserve HTOA" (hidden track one audio) setting will cause an extra file
to be created when outputting a gaps appended CUE sheet if an index 0 for track
1 exists. If disabled, a PREGAP line will be written instead and the HTOA will
be discarded.
AccurateRip online database keeps CRCs of the ripped CDs. AccurateRip 'Verify'
option accesses this database to compare the CRCs and ensure you have the
exact copy. If the CD has been ripped with software, which doesn't handle
CD drive read offset, or with incorrectly specified read offset, CRCs won't
match, but the correct offset will be detected. AccurateRip 'Fix offset'
option is a two-pass operation, which computes that offset during
the first step, and applies it during the second step. If the output format
is FLAC, and 'Add tags with CRCs' option in advanced settings is checked,
the output flac file will contain ACCURATERIPCOUNT tag for each track,
which shows that the track was ripped from the CD correctly, and also
demonstrates how popular is this CD. You can set up foobar2000 to display
this nice statictics for each file.
The settings file is located in the "%AppData%\CUE Tools" folder. For example,
on Windows XP if your username is "John", the settings folder is likely
"C:\Documents and Settings\John\Application Data\CUE Tools".
Command line format: CUETools.exe [/verify] "filename"
When called with a file name as argument, opens the usual dialog
with this file name in the input box.
When called with /verify switch and a filename, starts automatic
AccurateRip verification, /convert stats conversion, and /fix
starts AccurateRip verification and convertion (with possible
offset correction).

92
CUETools/Settings.cs Normal file
View File

@@ -0,0 +1,92 @@
// ****************************************************************************
//
// CUE Tools
// Copyright (C) 2006-2007 Moitah (moitah@yahoo.com)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// ****************************************************************************
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace JDP {
static class SettingsShared {
public static string GetMyAppDataDir(string appName) {
string appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string myAppDataDir = Path.Combine(appDataDir, appName);
if (Directory.Exists(myAppDataDir) == false) {
Directory.CreateDirectory(myAppDataDir);
}
return myAppDataDir;
}
}
public class SettingsReader {
Dictionary<string, string> _settings;
public SettingsReader(string appName, string fileName) {
_settings = new Dictionary<string, string>();
string path = Path.Combine(SettingsShared.GetMyAppDataDir(appName), fileName);
if (!File.Exists(path)) {
return;
}
using (StreamReader sr = new StreamReader(path, Encoding.UTF8)) {
string line, name, val;
int pos;
while ((line = sr.ReadLine()) != null) {
pos = line.IndexOf('=');
if (pos != -1) {
name = line.Substring(0, pos);
val = line.Substring(pos + 1);
if (!_settings.ContainsKey(name)) {
_settings.Add(name, val);
}
}
}
}
}
public string Load(string name) {
return _settings.ContainsKey(name) ? _settings[name] : null;
}
}
public class SettingsWriter {
StreamWriter _sw;
public SettingsWriter(string appName, string fileName) {
string path = Path.Combine(SettingsShared.GetMyAppDataDir(appName), fileName);
_sw = new StreamWriter(path, false, Encoding.UTF8);
}
public void Save(string name, string value) {
_sw.WriteLine(name + "=" + value);
}
public void Close() {
_sw.Close();
}
}
}

3
CUETools/app.config Normal file
View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>

96
CUETools/frmBatch.Designer.cs generated Normal file
View File

@@ -0,0 +1,96 @@
namespace JDP
{
partial class frmBatch
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.progressBar2 = new System.Windows.Forms.ProgressBar();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(12, 12);
this.progressBar1.Margin = new System.Windows.Forms.Padding(10);
this.progressBar1.MinimumSize = new System.Drawing.Size(440, 20);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(533, 20);
this.progressBar1.TabIndex = 0;
//
// progressBar2
//
this.progressBar2.Location = new System.Drawing.Point(12, 38);
this.progressBar2.Margin = new System.Windows.Forms.Padding(10);
this.progressBar2.MinimumSize = new System.Drawing.Size(440, 20);
this.progressBar2.Name = "progressBar2";
this.progressBar2.Size = new System.Drawing.Size(533, 20);
this.progressBar2.TabIndex = 1;
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.SystemColors.Control;
this.textBox1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.textBox1.Location = new System.Drawing.Point(13, 71);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Size = new System.Drawing.Size(532, 180);
this.textBox1.TabIndex = 2;
//
// frmBatch
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(569, 341);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.progressBar2);
this.Controls.Add(this.progressBar1);
this.Cursor = System.Windows.Forms.Cursors.Default;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimumSize = new System.Drawing.Size(480, 60);
this.Name = "frmBatch";
this.Padding = new System.Windows.Forms.Padding(10);
this.Text = "Working...";
this.Load += new System.EventHandler(this.frmBatch_Load);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmBatch_FormClosing);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.ProgressBar progressBar2;
private System.Windows.Forms.TextBox textBox1;
}
}

243
CUETools/frmBatch.cs Normal file
View File

@@ -0,0 +1,243 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
namespace JDP
{
public partial class frmBatch : Form
{
public frmBatch()
{
InitializeComponent();
_config = new CUEConfig();
_cueStyle = CUEStyle.SingleFile;
_audioFormat = OutputAudioFormat.WAV;
_accurateRip = true;
_accurateOffset = false;
}
public string InputPath
{
get { return pathIn; }
set { pathIn = value; }
}
public bool AccurateRip
{
get { return _accurateRip; }
set { _accurateRip = value; }
}
public bool AccurateOffset
{
get { return _accurateOffset; }
set { _accurateOffset = value; }
}
Thread _workThread;
CUESheet _workClass;
CUEConfig _config;
CUEStyle _cueStyle;
OutputAudioFormat _audioFormat;
string pathIn;
string pathOut;
bool _accurateRip;
bool _accurateOffset;
DateTime _startedAt;
public void SetStatus(string status, uint percentTrack, double percentDisk)
{
this.BeginInvoke((MethodInvoker)delegate()
{
if (percentDisk == 0)
{
_startedAt = DateTime.Now;
}
else if (percentDisk > 0.02)
{
TimeSpan span = DateTime.Now - _startedAt;
TimeSpan eta = new TimeSpan ((long) (span.Ticks/percentDisk));
Text = String.Format("{0}, ETA {1}:{2:00}.", status, (int)eta.TotalMinutes, eta.Seconds);
} else
Text = status;
progressBar1.Value = (int)percentTrack;
progressBar2.Value = (int)(percentDisk*100);
});
}
private void WriteAudioFilesThread(object o)
{
CUESheet cueSheet = (CUESheet)o;
try
{
cueSheet.WriteAudioFiles(Path.GetDirectoryName(pathOut), _cueStyle, new SetStatus(this.SetStatus));
this.Invoke((MethodInvoker)delegate()
{
//if (_batchPaths.Count == 0)
{
//TimeSpan span = DateTime.Now - _startedAt;
Text = "Done.";
progressBar1.Value = 0;
progressBar2.Value = 0;
if (cueSheet.AccurateRip)
{
StringWriter sw = new StringWriter();
cueSheet.GenerateAccurateRipLog(sw);
textBox1.Text = sw.ToString();
sw.Close();
textBox1.Show();
}
}
});
}
catch (StopException)
{
////_batchPaths.Clear();
//this.Invoke((MethodInvoker)delegate()
//{
// MessageBox.Show("Conversion was stopped.", "Stopped", MessageBoxButtons.OK,
// MessageBoxIcon.Exclamation);
// Close();
//});
this.Invoke((MethodInvoker)delegate()
{
Text = "Aborted.";
progressBar1.Value = 0;
progressBar2.Value = 0;
});
}
catch (Exception ex)
{
this.Invoke((MethodInvoker)delegate()
{
//if (_batchPaths.Count == 0) SetupControls(false);
//if (!ShowErrorMessage(ex))
//{
// _batchPaths.Clear();
// SetupControls(false);
//}
Text = "Error: " + ex.Message;
});
}
//if (_batchPaths.Count != 0)
//{
// _batchPaths.RemoveAt(0);
// this.BeginInvoke((MethodInvoker)delegate()
// {
// if (_batchPaths.Count == 0)
// {
// SetupControls(false);
// ShowBatchDoneMessage();
// }
// else
// {
// StartConvert();
// }
// });
//}
}
public void StartConvert()
{
CUESheet cueSheet;
try
{
_startedAt = DateTime.Now;
_workThread = null;
//if (_batchPaths.Count != 0)
//{
// txtInputPath.Text = _batchPaths[0];
//}
if (!File.Exists(pathIn))
{
throw new Exception("Input CUE Sheet not found.");
}
bool outputAudio = _accurateOffset || !_accurateRip;
cueSheet = new CUESheet(pathIn, _config);
if (outputAudio)
{
bool pathFound = false;
for (int i = 0; i < 20; i++)
{
string outDir = Path.Combine(Path.GetDirectoryName (pathIn), "CUEToolsOutput" + (i > 0? String.Format("({0})",i) : ""));
if (!Directory.Exists(outDir))
{
Directory.CreateDirectory(outDir);
pathOut = Path.Combine(outDir, Path.GetFileNameWithoutExtension(pathIn) + ".cue");
pathFound = true;
break;
}
}
if (!pathFound)
{
Text = "Could not create a folder";
return;
}
} else
pathOut = pathIn;
cueSheet.GenerateFilenames(_audioFormat, pathOut);
if (outputAudio)
{
if (_cueStyle == CUEStyle.SingleFileWithCUE)
cueSheet.SingleFilename = Path.ChangeExtension(Path.GetFileName (pathOut), General.FormatExtension (_audioFormat));
}
cueSheet.UsePregapForFirstTrackInSingleFile = false;
cueSheet.AccurateRip = _accurateRip;
cueSheet.AccurateOffset = _accurateOffset;
_workThread = new Thread(WriteAudioFilesThread);
_workClass = cueSheet;
_workThread.Start(cueSheet);
}
catch (Exception ex)
{
Text = "Error: " + ex.Message;
//if (!ShowErrorMessage(ex))
//{
// _batchPaths.Clear();
//}
//Close();
}
}
private void frmBatch_Load(object sender, EventArgs e)
{
//_batchPaths = new List<string>();
textBox1.Hide();
SettingsReader sr = new SettingsReader("CUE Tools", "settings.txt");
string val;
_config.Load(sr);
try
{
val = sr.Load("CUEStyle");
_cueStyle = (val != null) ? (CUEStyle)Int32.Parse(val) : CUEStyle.SingleFile;
val = sr.Load("OutputAudioFormat");
_audioFormat = (val != null) ? (OutputAudioFormat)Int32.Parse(val) : OutputAudioFormat.WAV;
}
catch { };
StartConvert();
}
private void frmBatch_FormClosing(Object sender, FormClosingEventArgs e)
{
if ((_workThread != null) && (_workThread.IsAlive))
{
_workClass.Stop();
e.Cancel = true;
}
}
}
}

120
CUETools/frmBatch.resx Normal file
View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

497
CUETools/frmCUETools.Designer.cs generated Normal file
View File

@@ -0,0 +1,497 @@
namespace JDP {
partial class frmCUETools {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmCUETools));
this.btnConvert = new System.Windows.Forms.Button();
this.grpCUEPaths = new System.Windows.Forms.GroupBox();
this.btnBrowseOutput = new System.Windows.Forms.Button();
this.btnBrowseInput = new System.Windows.Forms.Button();
this.lblOutput = new System.Windows.Forms.Label();
this.lblInput = new System.Windows.Forms.Label();
this.txtOutputPath = new System.Windows.Forms.TextBox();
this.txtInputPath = new System.Windows.Forms.TextBox();
this.grpOutputStyle = new System.Windows.Forms.GroupBox();
this.rbEmbedCUE = new System.Windows.Forms.RadioButton();
this.rbGapsLeftOut = new System.Windows.Forms.RadioButton();
this.rbGapsPrepended = new System.Windows.Forms.RadioButton();
this.rbGapsAppended = new System.Windows.Forms.RadioButton();
this.rbSingleFile = new System.Windows.Forms.RadioButton();
this.btnAbout = new System.Windows.Forms.Button();
this.grpOutputPathGeneration = new System.Windows.Forms.GroupBox();
this.txtCustomFormat = new System.Windows.Forms.TextBox();
this.rbCustomFormat = new System.Windows.Forms.RadioButton();
this.txtCreateSubdirectory = new System.Windows.Forms.TextBox();
this.rbDontGenerate = new System.Windows.Forms.RadioButton();
this.rbCreateSubdirectory = new System.Windows.Forms.RadioButton();
this.rbAppendFilename = new System.Windows.Forms.RadioButton();
this.txtAppendFilename = new System.Windows.Forms.TextBox();
this.grpAudioOutput = new System.Windows.Forms.GroupBox();
this.rbNoAudio = new System.Windows.Forms.RadioButton();
this.rbWavPack = new System.Windows.Forms.RadioButton();
this.rbFLAC = new System.Windows.Forms.RadioButton();
this.rbWAV = new System.Windows.Forms.RadioButton();
this.btnBatch = new System.Windows.Forms.Button();
this.btnFilenameCorrector = new System.Windows.Forms.Button();
this.btnSettings = new System.Windows.Forms.Button();
this.grpAccurateRip = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.txtDataTrackLength = new System.Windows.Forms.MaskedTextBox();
this.rbArApplyOffset = new System.Windows.Forms.RadioButton();
this.rbArVerify = new System.Windows.Forms.RadioButton();
this.rbArNone = new System.Windows.Forms.RadioButton();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.toolStripProgressBar2 = new System.Windows.Forms.ToolStripProgressBar();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.btnCUECreator = new System.Windows.Forms.Button();
this.grpCUEPaths.SuspendLayout();
this.grpOutputStyle.SuspendLayout();
this.grpOutputPathGeneration.SuspendLayout();
this.grpAudioOutput.SuspendLayout();
this.grpAccurateRip.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
//
// btnConvert
//
resources.ApplyResources(this.btnConvert, "btnConvert");
this.btnConvert.Name = "btnConvert";
this.btnConvert.UseVisualStyleBackColor = true;
this.btnConvert.Click += new System.EventHandler(this.btnConvert_Click);
//
// grpCUEPaths
//
this.grpCUEPaths.Controls.Add(this.btnBrowseOutput);
this.grpCUEPaths.Controls.Add(this.btnBrowseInput);
this.grpCUEPaths.Controls.Add(this.lblOutput);
this.grpCUEPaths.Controls.Add(this.lblInput);
this.grpCUEPaths.Controls.Add(this.txtOutputPath);
this.grpCUEPaths.Controls.Add(this.txtInputPath);
resources.ApplyResources(this.grpCUEPaths, "grpCUEPaths");
this.grpCUEPaths.Name = "grpCUEPaths";
this.grpCUEPaths.TabStop = false;
//
// btnBrowseOutput
//
resources.ApplyResources(this.btnBrowseOutput, "btnBrowseOutput");
this.btnBrowseOutput.Name = "btnBrowseOutput";
this.btnBrowseOutput.UseVisualStyleBackColor = true;
this.btnBrowseOutput.Click += new System.EventHandler(this.btnBrowseOutput_Click);
//
// btnBrowseInput
//
resources.ApplyResources(this.btnBrowseInput, "btnBrowseInput");
this.btnBrowseInput.Name = "btnBrowseInput";
this.btnBrowseInput.UseVisualStyleBackColor = true;
this.btnBrowseInput.Click += new System.EventHandler(this.btnBrowseInput_Click);
//
// lblOutput
//
resources.ApplyResources(this.lblOutput, "lblOutput");
this.lblOutput.Name = "lblOutput";
//
// lblInput
//
resources.ApplyResources(this.lblInput, "lblInput");
this.lblInput.Name = "lblInput";
//
// txtOutputPath
//
this.txtOutputPath.AllowDrop = true;
resources.ApplyResources(this.txtOutputPath, "txtOutputPath");
this.txtOutputPath.Name = "txtOutputPath";
this.txtOutputPath.DragDrop += new System.Windows.Forms.DragEventHandler(this.PathTextBox_DragDrop);
this.txtOutputPath.DragEnter += new System.Windows.Forms.DragEventHandler(this.PathTextBox_DragEnter);
//
// txtInputPath
//
this.txtInputPath.AllowDrop = true;
resources.ApplyResources(this.txtInputPath, "txtInputPath");
this.txtInputPath.Name = "txtInputPath";
this.txtInputPath.TextChanged += new System.EventHandler(this.txtInputPath_TextChanged);
this.txtInputPath.DragDrop += new System.Windows.Forms.DragEventHandler(this.PathTextBox_DragDrop);
this.txtInputPath.DragEnter += new System.Windows.Forms.DragEventHandler(this.PathTextBox_DragEnter);
//
// grpOutputStyle
//
this.grpOutputStyle.Controls.Add(this.rbEmbedCUE);
this.grpOutputStyle.Controls.Add(this.rbGapsLeftOut);
this.grpOutputStyle.Controls.Add(this.rbGapsPrepended);
this.grpOutputStyle.Controls.Add(this.rbGapsAppended);
this.grpOutputStyle.Controls.Add(this.rbSingleFile);
resources.ApplyResources(this.grpOutputStyle, "grpOutputStyle");
this.grpOutputStyle.Name = "grpOutputStyle";
this.grpOutputStyle.TabStop = false;
//
// rbEmbedCUE
//
resources.ApplyResources(this.rbEmbedCUE, "rbEmbedCUE");
this.rbEmbedCUE.Name = "rbEmbedCUE";
this.rbEmbedCUE.TabStop = true;
this.toolTip1.SetToolTip(this.rbEmbedCUE, resources.GetString("rbEmbedCUE.ToolTip"));
this.rbEmbedCUE.UseVisualStyleBackColor = true;
this.rbEmbedCUE.CheckedChanged += new System.EventHandler(this.rbEmbedCUE_CheckedChanged);
//
// rbGapsLeftOut
//
resources.ApplyResources(this.rbGapsLeftOut, "rbGapsLeftOut");
this.rbGapsLeftOut.Name = "rbGapsLeftOut";
this.toolTip1.SetToolTip(this.rbGapsLeftOut, resources.GetString("rbGapsLeftOut.ToolTip"));
this.rbGapsLeftOut.UseVisualStyleBackColor = true;
//
// rbGapsPrepended
//
resources.ApplyResources(this.rbGapsPrepended, "rbGapsPrepended");
this.rbGapsPrepended.Name = "rbGapsPrepended";
this.toolTip1.SetToolTip(this.rbGapsPrepended, resources.GetString("rbGapsPrepended.ToolTip"));
this.rbGapsPrepended.UseVisualStyleBackColor = true;
//
// rbGapsAppended
//
resources.ApplyResources(this.rbGapsAppended, "rbGapsAppended");
this.rbGapsAppended.Name = "rbGapsAppended";
this.toolTip1.SetToolTip(this.rbGapsAppended, resources.GetString("rbGapsAppended.ToolTip"));
this.rbGapsAppended.UseVisualStyleBackColor = true;
//
// rbSingleFile
//
resources.ApplyResources(this.rbSingleFile, "rbSingleFile");
this.rbSingleFile.Checked = true;
this.rbSingleFile.Name = "rbSingleFile";
this.rbSingleFile.TabStop = true;
this.toolTip1.SetToolTip(this.rbSingleFile, resources.GetString("rbSingleFile.ToolTip"));
this.rbSingleFile.UseVisualStyleBackColor = true;
//
// btnAbout
//
resources.ApplyResources(this.btnAbout, "btnAbout");
this.btnAbout.Name = "btnAbout";
this.btnAbout.UseVisualStyleBackColor = true;
this.btnAbout.Click += new System.EventHandler(this.btnAbout_Click);
//
// grpOutputPathGeneration
//
this.grpOutputPathGeneration.Controls.Add(this.txtCustomFormat);
this.grpOutputPathGeneration.Controls.Add(this.rbCustomFormat);
this.grpOutputPathGeneration.Controls.Add(this.txtCreateSubdirectory);
this.grpOutputPathGeneration.Controls.Add(this.rbDontGenerate);
this.grpOutputPathGeneration.Controls.Add(this.rbCreateSubdirectory);
this.grpOutputPathGeneration.Controls.Add(this.rbAppendFilename);
this.grpOutputPathGeneration.Controls.Add(this.txtAppendFilename);
resources.ApplyResources(this.grpOutputPathGeneration, "grpOutputPathGeneration");
this.grpOutputPathGeneration.Name = "grpOutputPathGeneration";
this.grpOutputPathGeneration.TabStop = false;
//
// txtCustomFormat
//
resources.ApplyResources(this.txtCustomFormat, "txtCustomFormat");
this.txtCustomFormat.Name = "txtCustomFormat";
this.txtCustomFormat.TextChanged += new System.EventHandler(this.txtCustomFormat_TextChanged);
//
// rbCustomFormat
//
resources.ApplyResources(this.rbCustomFormat, "rbCustomFormat");
this.rbCustomFormat.Name = "rbCustomFormat";
this.rbCustomFormat.TabStop = true;
this.rbCustomFormat.UseVisualStyleBackColor = true;
this.rbCustomFormat.CheckedChanged += new System.EventHandler(this.rbCustomFormat_CheckedChanged);
//
// txtCreateSubdirectory
//
resources.ApplyResources(this.txtCreateSubdirectory, "txtCreateSubdirectory");
this.txtCreateSubdirectory.Name = "txtCreateSubdirectory";
this.txtCreateSubdirectory.TextChanged += new System.EventHandler(this.txtCreateSubdirectory_TextChanged);
//
// rbDontGenerate
//
resources.ApplyResources(this.rbDontGenerate, "rbDontGenerate");
this.rbDontGenerate.Name = "rbDontGenerate";
this.rbDontGenerate.UseVisualStyleBackColor = true;
//
// rbCreateSubdirectory
//
resources.ApplyResources(this.rbCreateSubdirectory, "rbCreateSubdirectory");
this.rbCreateSubdirectory.Checked = true;
this.rbCreateSubdirectory.Name = "rbCreateSubdirectory";
this.rbCreateSubdirectory.TabStop = true;
this.rbCreateSubdirectory.UseVisualStyleBackColor = true;
this.rbCreateSubdirectory.CheckedChanged += new System.EventHandler(this.rbCreateSubdirectory_CheckedChanged);
//
// rbAppendFilename
//
resources.ApplyResources(this.rbAppendFilename, "rbAppendFilename");
this.rbAppendFilename.Name = "rbAppendFilename";
this.rbAppendFilename.UseVisualStyleBackColor = true;
this.rbAppendFilename.CheckedChanged += new System.EventHandler(this.rbAppendFilename_CheckedChanged);
//
// txtAppendFilename
//
resources.ApplyResources(this.txtAppendFilename, "txtAppendFilename");
this.txtAppendFilename.Name = "txtAppendFilename";
this.txtAppendFilename.TextChanged += new System.EventHandler(this.txtAppendFilename_TextChanged);
//
// grpAudioOutput
//
this.grpAudioOutput.Controls.Add(this.rbNoAudio);
this.grpAudioOutput.Controls.Add(this.rbWavPack);
this.grpAudioOutput.Controls.Add(this.rbFLAC);
this.grpAudioOutput.Controls.Add(this.rbWAV);
resources.ApplyResources(this.grpAudioOutput, "grpAudioOutput");
this.grpAudioOutput.Name = "grpAudioOutput";
this.grpAudioOutput.TabStop = false;
//
// rbNoAudio
//
resources.ApplyResources(this.rbNoAudio, "rbNoAudio");
this.rbNoAudio.Name = "rbNoAudio";
this.toolTip1.SetToolTip(this.rbNoAudio, resources.GetString("rbNoAudio.ToolTip"));
this.rbNoAudio.UseVisualStyleBackColor = true;
this.rbNoAudio.CheckedChanged += new System.EventHandler(this.rbNoAudio_CheckedChanged);
//
// rbWavPack
//
resources.ApplyResources(this.rbWavPack, "rbWavPack");
this.rbWavPack.Name = "rbWavPack";
this.rbWavPack.UseVisualStyleBackColor = true;
this.rbWavPack.CheckedChanged += new System.EventHandler(this.rbWavPack_CheckedChanged);
//
// rbFLAC
//
resources.ApplyResources(this.rbFLAC, "rbFLAC");
this.rbFLAC.Name = "rbFLAC";
this.rbFLAC.UseVisualStyleBackColor = true;
this.rbFLAC.CheckedChanged += new System.EventHandler(this.rbFLAC_CheckedChanged);
//
// rbWAV
//
resources.ApplyResources(this.rbWAV, "rbWAV");
this.rbWAV.Checked = true;
this.rbWAV.Name = "rbWAV";
this.rbWAV.TabStop = true;
this.rbWAV.UseVisualStyleBackColor = true;
this.rbWAV.CheckedChanged += new System.EventHandler(this.rbWAV_CheckedChanged);
//
// btnBatch
//
resources.ApplyResources(this.btnBatch, "btnBatch");
this.btnBatch.Name = "btnBatch";
this.btnBatch.UseVisualStyleBackColor = true;
this.btnBatch.Click += new System.EventHandler(this.btnBatch_Click);
//
// btnFilenameCorrector
//
resources.ApplyResources(this.btnFilenameCorrector, "btnFilenameCorrector");
this.btnFilenameCorrector.Name = "btnFilenameCorrector";
this.btnFilenameCorrector.UseVisualStyleBackColor = true;
this.btnFilenameCorrector.Click += new System.EventHandler(this.btnFilenameCorrector_Click);
//
// btnSettings
//
resources.ApplyResources(this.btnSettings, "btnSettings");
this.btnSettings.Name = "btnSettings";
this.btnSettings.UseVisualStyleBackColor = true;
this.btnSettings.Click += new System.EventHandler(this.btnSettings_Click);
//
// grpAccurateRip
//
this.grpAccurateRip.Controls.Add(this.label1);
this.grpAccurateRip.Controls.Add(this.txtDataTrackLength);
this.grpAccurateRip.Controls.Add(this.rbArApplyOffset);
this.grpAccurateRip.Controls.Add(this.rbArVerify);
this.grpAccurateRip.Controls.Add(this.rbArNone);
resources.ApplyResources(this.grpAccurateRip, "grpAccurateRip");
this.grpAccurateRip.Name = "grpAccurateRip";
this.grpAccurateRip.TabStop = false;
//
// label1
//
resources.ApplyResources(this.label1, "label1");
this.label1.Name = "label1";
//
// txtDataTrackLength
//
this.txtDataTrackLength.Culture = new System.Globalization.CultureInfo("");
this.txtDataTrackLength.CutCopyMaskFormat = System.Windows.Forms.MaskFormat.IncludePromptAndLiterals;
this.txtDataTrackLength.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
resources.ApplyResources(this.txtDataTrackLength, "txtDataTrackLength");
this.txtDataTrackLength.Name = "txtDataTrackLength";
this.txtDataTrackLength.TextMaskFormat = System.Windows.Forms.MaskFormat.IncludePromptAndLiterals;
this.toolTip1.SetToolTip(this.txtDataTrackLength, resources.GetString("txtDataTrackLength.ToolTip"));
//
// rbArApplyOffset
//
resources.ApplyResources(this.rbArApplyOffset, "rbArApplyOffset");
this.rbArApplyOffset.Name = "rbArApplyOffset";
this.toolTip1.SetToolTip(this.rbArApplyOffset, resources.GetString("rbArApplyOffset.ToolTip"));
this.rbArApplyOffset.UseVisualStyleBackColor = true;
//
// rbArVerify
//
resources.ApplyResources(this.rbArVerify, "rbArVerify");
this.rbArVerify.Name = "rbArVerify";
this.toolTip1.SetToolTip(this.rbArVerify, resources.GetString("rbArVerify.ToolTip"));
this.rbArVerify.UseVisualStyleBackColor = true;
this.rbArVerify.CheckedChanged += new System.EventHandler(this.rbArVerify_CheckedChanged);
//
// rbArNone
//
resources.ApplyResources(this.rbArNone, "rbArNone");
this.rbArNone.Checked = true;
this.rbArNone.Name = "rbArNone";
this.rbArNone.TabStop = true;
this.toolTip1.SetToolTip(this.rbArNone, resources.GetString("rbArNone.ToolTip"));
this.rbArNone.UseVisualStyleBackColor = true;
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.toolStripProgressBar1,
this.toolStripProgressBar2});
resources.ApplyResources(this.statusStrip1, "statusStrip1");
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.SizingGrip = false;
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
resources.ApplyResources(this.toolStripStatusLabel1, "toolStripStatusLabel1");
this.toolStripStatusLabel1.Spring = true;
//
// toolStripProgressBar1
//
this.toolStripProgressBar1.AutoToolTip = true;
this.toolStripProgressBar1.Name = "toolStripProgressBar1";
resources.ApplyResources(this.toolStripProgressBar1, "toolStripProgressBar1");
this.toolStripProgressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
//
// toolStripProgressBar2
//
this.toolStripProgressBar2.AutoToolTip = true;
this.toolStripProgressBar2.Name = "toolStripProgressBar2";
resources.ApplyResources(this.toolStripProgressBar2, "toolStripProgressBar2");
this.toolStripProgressBar2.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
//
// toolTip1
//
this.toolTip1.AutoPopDelay = 15000;
this.toolTip1.InitialDelay = 500;
this.toolTip1.ReshowDelay = 100;
//
// btnCUECreator
//
resources.ApplyResources(this.btnCUECreator, "btnCUECreator");
this.btnCUECreator.Name = "btnCUECreator";
this.btnCUECreator.UseVisualStyleBackColor = true;
this.btnCUECreator.Click += new System.EventHandler(this.btnCUECreator_Click);
//
// frmCUETools
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnCUECreator);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.grpAccurateRip);
this.Controls.Add(this.btnSettings);
this.Controls.Add(this.btnFilenameCorrector);
this.Controls.Add(this.btnBatch);
this.Controls.Add(this.grpAudioOutput);
this.Controls.Add(this.grpOutputPathGeneration);
this.Controls.Add(this.btnAbout);
this.Controls.Add(this.grpOutputStyle);
this.Controls.Add(this.grpCUEPaths);
this.Controls.Add(this.btnConvert);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "frmCUETools";
this.Load += new System.EventHandler(this.frmCUETools_Load);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frmCUETools_FormClosed);
this.grpCUEPaths.ResumeLayout(false);
this.grpCUEPaths.PerformLayout();
this.grpOutputStyle.ResumeLayout(false);
this.grpOutputStyle.PerformLayout();
this.grpOutputPathGeneration.ResumeLayout(false);
this.grpOutputPathGeneration.PerformLayout();
this.grpAudioOutput.ResumeLayout(false);
this.grpAudioOutput.PerformLayout();
this.grpAccurateRip.ResumeLayout(false);
this.grpAccurateRip.PerformLayout();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnConvert;
private System.Windows.Forms.GroupBox grpCUEPaths;
private System.Windows.Forms.Button btnBrowseOutput;
private System.Windows.Forms.Button btnBrowseInput;
private System.Windows.Forms.Label lblOutput;
private System.Windows.Forms.Label lblInput;
private System.Windows.Forms.TextBox txtOutputPath;
private System.Windows.Forms.TextBox txtInputPath;
private System.Windows.Forms.GroupBox grpOutputStyle;
private System.Windows.Forms.Button btnAbout;
private System.Windows.Forms.RadioButton rbGapsLeftOut;
private System.Windows.Forms.RadioButton rbGapsPrepended;
private System.Windows.Forms.RadioButton rbGapsAppended;
private System.Windows.Forms.RadioButton rbSingleFile;
private System.Windows.Forms.GroupBox grpOutputPathGeneration;
private System.Windows.Forms.RadioButton rbDontGenerate;
private System.Windows.Forms.RadioButton rbCreateSubdirectory;
private System.Windows.Forms.RadioButton rbAppendFilename;
private System.Windows.Forms.TextBox txtAppendFilename;
private System.Windows.Forms.TextBox txtCreateSubdirectory;
private System.Windows.Forms.GroupBox grpAudioOutput;
private System.Windows.Forms.RadioButton rbFLAC;
private System.Windows.Forms.RadioButton rbWAV;
private System.Windows.Forms.RadioButton rbWavPack;
private System.Windows.Forms.RadioButton rbCustomFormat;
private System.Windows.Forms.TextBox txtCustomFormat;
private System.Windows.Forms.Button btnBatch;
private System.Windows.Forms.Button btnFilenameCorrector;
private System.Windows.Forms.Button btnSettings;
private System.Windows.Forms.RadioButton rbNoAudio;
private System.Windows.Forms.GroupBox grpAccurateRip;
private System.Windows.Forms.RadioButton rbArApplyOffset;
private System.Windows.Forms.RadioButton rbArVerify;
private System.Windows.Forms.RadioButton rbArNone;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar2;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.RadioButton rbEmbedCUE;
private System.Windows.Forms.Button btnCUECreator;
private System.Windows.Forms.MaskedTextBox txtDataTrackLength;
private System.Windows.Forms.Label label1;
}
}

907
CUETools/frmCUETools.cs Normal file
View File

@@ -0,0 +1,907 @@
// ****************************************************************************
//
// CUE Tools
// Copyright (C) 2006-2007 Moitah (moitah@yahoo.com)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// ****************************************************************************
// ****************************************************************************
// Access to AccurateRip is regulated, see
// http://www.accuraterip.com/3rdparty-access.htm for details.
// ****************************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
namespace JDP {
public partial class frmCUETools : Form {
public frmCUETools() {
_config = new CUEConfig();
InitializeComponent();
}
private void btnBrowseInput_Click(object sender, EventArgs e) {
OpenFileDialog fileDlg = new OpenFileDialog();
DialogResult dlgRes;
fileDlg.Title = "Input CUE Sheet or FLAC image";
fileDlg.Filter = "CUE Sheets (*.cue)|*.cue|FLAC images (*.flac)|*.flac";
dlgRes = fileDlg.ShowDialog();
if (dlgRes == DialogResult.OK) {
txtInputPath.Text = fileDlg.FileName;
}
}
private void btnBrowseOutput_Click(object sender, EventArgs e) {
SaveFileDialog fileDlg = new SaveFileDialog();
DialogResult dlgRes;
fileDlg.Title = "Output CUE Sheet";
fileDlg.Filter = "CUE Sheets (*.cue)|*.cue";
dlgRes = fileDlg.ShowDialog();
if (dlgRes == DialogResult.OK) {
txtOutputPath.Text = fileDlg.FileName;
}
}
private void btnConvert_Click(object sender, EventArgs e) {
if ((_workThread != null) && (_workThread.IsAlive)) {
_workClass.Stop();
}
else {
if (!CheckWriteOffset()) return;
StartConvert();
}
}
private void btnBatch_Click(object sender, EventArgs e) {
if (rbDontGenerate.Checked) {
MessageBox.Show("Batch mode cannot be used with the output path set manually.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
FolderBrowserDialog folderDialog = new FolderBrowserDialog();
folderDialog.Description = "Select the folder containing the CUE sheets you want to convert. Subfolders will be included automatically.";
folderDialog.ShowNewFolderButton = false;
if (folderDialog.ShowDialog() == DialogResult.OK) {
if (!CheckWriteOffset()) return;
AddDirToBatch(folderDialog.SelectedPath);
StartConvert();
}
}
private void btnFilenameCorrector_Click(object sender, EventArgs e) {
if ((_fcForm == null) || _fcForm.IsDisposed) {
_fcForm = new frmFilenameCorrector();
CenterSubForm(_fcForm);
_fcForm.Show();
}
else {
_fcForm.Activate();
}
}
private void btnSettings_Click(object sender, EventArgs e) {
using (frmSettings settingsForm = new frmSettings()) {
settingsForm.WriteOffset = _writeOffset;
settingsForm.Config = _config;
CenterSubForm(settingsForm);
settingsForm.ShowDialog();
_writeOffset = settingsForm.WriteOffset;
_config = settingsForm.Config;
_config.BuildCharMap();
UpdateOutputPath();
}
}
private void btnAbout_Click(object sender, EventArgs e) {
using (frmReport reportForm = new frmReport())
{
StringWriter sw = new StringWriter();
sw.WriteLine("CUE Tools v1.9.2");
sw.WriteLine("Copyright 2006-2007 Moitah http://www.moitah.net/.");
sw.WriteLine("AccurateRip, Monkey's Audio (APE) input and FLAC embedded CUE sheet support added in 2008 by Greg Chudov, gchudov@gmail.com.");
sw.WriteLine("Thanks go out to Christopher Key and Whitehobbit for insight on AccurateRip functionality and to Mr Spoon for permission to use the database.");
sw.WriteLine("Monkey's Audio library by Matthew T. Ashland.");
reportForm.Message = sw.ToString();
sw.Close();
CenterSubForm(reportForm);
reportForm.Text = "About CUE Tools";
reportForm.ShowDialog(this);
}
}
private void PathTextBox_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop) && !((TextBox)sender).ReadOnly) {
e.Effect = DragDropEffects.Copy;
}
}
private void PathTextBox_DragDrop(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length == 1) {
((TextBox)sender).Text = files[0];
}
}
}
public string InputPath {
get {
return txtInputPath.Text;
}
set {
txtInputPath.Text = value;
}
}
private void txtInputPath_TextChanged(object sender, EventArgs e) {
UpdateOutputPath();
}
private void rbCreateSubdirectory_CheckedChanged(object sender, EventArgs e) {
UpdateOutputPath();
}
private void rbAppendFilename_CheckedChanged(object sender, EventArgs e) {
UpdateOutputPath();
}
private void rbCustomFormat_CheckedChanged(object sender, EventArgs e) {
UpdateOutputPath();
}
private void txtCreateSubdirectory_TextChanged(object sender, EventArgs e) {
UpdateOutputPath();
}
private void txtAppendFilename_TextChanged(object sender, EventArgs e) {
UpdateOutputPath();
}
private void txtCustomFormat_TextChanged(object sender, EventArgs e) {
UpdateOutputPath();
}
private void frmCUETools_Load(object sender, EventArgs e) {
_batchPaths = new List<string>();
LoadSettings();
SetupControls(false);
UpdateOutputPath();
updateOutputStyles();
}
private void frmCUETools_FormClosed(object sender, FormClosedEventArgs e) {
SaveSettings();
}
// ********************************************************************************
frmFilenameCorrector _fcForm;
List<string> _batchPaths;
bool _usePregapForFirstTrackInSingleFile;
int _writeOffset;
Thread _workThread;
CUESheet _workClass;
CUEConfig _config;
private void StartConvert() {
string pathIn, pathOut, outDir;
CUESheet cueSheet;
CUEStyle cueStyle;
try {
_workThread = null;
if (_batchPaths.Count != 0) {
txtInputPath.Text = _batchPaths[0];
}
pathIn = txtInputPath.Text;
cueStyle = SelectedCUEStyle;
bool outputAudio = !rbNoAudio.Checked && !rbArVerify.Checked;
bool outputCUE = (cueStyle != CUEStyle.SingleFileWithCUE) && !rbArVerify.Checked;
bool accurateRip = !rbArNone.Checked;
if (!File.Exists(pathIn)) {
throw new Exception("Input CUE Sheet not found.");
}
cueSheet = new CUESheet(pathIn, _config);
cueSheet.WriteOffset = _writeOffset;
UpdateOutputPath(cueSheet.Artist != "" ? cueSheet.Artist : "Unknown Artist", cueSheet.Title != "" ? cueSheet.Title : "Unknown Title");
pathOut = txtOutputPath.Text;
cueSheet.GenerateFilenames(SelectedOutputAudioFormat, pathOut);
outDir = Path.GetDirectoryName(pathOut);
if (cueStyle == CUEStyle.SingleFileWithCUE)
cueSheet.SingleFilename = Path.GetFileName (pathOut);
bool outputExists = false;
if (outputCUE)
outputExists = File.Exists(pathOut);
if (outputAudio) {
if (cueStyle == CUEStyle.SingleFile || cueStyle == CUEStyle.SingleFileWithCUE) {
outputExists |= File.Exists(Path.Combine(outDir, cueSheet.SingleFilename));
}
else {
if ((cueStyle == CUEStyle.GapsAppended) && _config.preserveHTOA) {
outputExists |= File.Exists(Path.Combine(outDir, cueSheet.HTOAFilename));
}
for (int i = 0; i < cueSheet.TrackCount; i++) {
outputExists |= File.Exists(Path.Combine(outDir, cueSheet.TrackFilenames[i]));
}
}
}
if (outputExists) {
DialogResult dlgRes = MessageBox.Show("One or more output file already exists, " +
"do you want to overwrite?", "Overwrite?", (_batchPaths.Count == 0) ?
MessageBoxButtons.YesNo : MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (dlgRes == DialogResult.Cancel) {
_batchPaths.Clear();
}
if (dlgRes != DialogResult.Yes) {
goto SkipConversion;
}
}
cueSheet.UsePregapForFirstTrackInSingleFile = _usePregapForFirstTrackInSingleFile && !outputAudio;
cueSheet.AccurateRip = accurateRip;
cueSheet.AccurateOffset = rbArApplyOffset.Checked;
cueSheet.DataTrackLength = txtDataTrackLength.Text;
if (outputAudio || accurateRip) {
object[] p = new object[3];
_workThread = new Thread(WriteAudioFilesThread);
_workClass = cueSheet;
p[0] = cueSheet;
p[1] = outDir;
p[2] = cueStyle;
SetupControls(true);
_workThread.Start(p);
}
else {
if (!Directory.Exists(outDir))
Directory.CreateDirectory(outDir);
if (outputCUE)
cueSheet.Write(pathOut, cueStyle);
ShowFinishedMessage(cueSheet.PaddedToFrame);
}
}
catch (Exception ex) {
if (!ShowErrorMessage(ex)) {
_batchPaths.Clear();
}
}
SkipConversion:
if ((_workThread == null) && (_batchPaths.Count != 0)) {
_batchPaths.RemoveAt(0);
if (_batchPaths.Count == 0) {
ShowBatchDoneMessage();
}
else {
StartConvert();
}
}
}
private void WriteAudioFilesThread(object o) {
object[] p = (object[])o;
CUESheet cueSheet = (CUESheet)p[0];
string outDir = (string)p[1];
CUEStyle cueStyle = (CUEStyle)p[2];
try {
cueSheet.WriteAudioFiles(outDir, cueStyle, new SetStatus(this.SetStatus));
this.Invoke((MethodInvoker)delegate() {
if (_batchPaths.Count == 0)
{
if (cueSheet.AccurateRip)
{
using (frmReport reportForm = new frmReport())
{
StringWriter sw = new StringWriter();
cueSheet.GenerateAccurateRipLog(sw);
reportForm.Message = sw.ToString();
sw.Close();
CenterSubForm(reportForm);
reportForm.ShowDialog(this);
}
}
else
ShowFinishedMessage(cueSheet.PaddedToFrame);
SetupControls(false);
}
});
}
catch (StopException) {
_batchPaths.Clear();
this.Invoke((MethodInvoker)delegate() {
SetupControls(false);
MessageBox.Show("Conversion was stopped.", "Stopped", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
});
}
catch (Exception ex) {
this.Invoke((MethodInvoker)delegate() {
if (_batchPaths.Count == 0) SetupControls(false);
if (!ShowErrorMessage(ex)) {
_batchPaths.Clear();
SetupControls(false);
}
});
}
if (_batchPaths.Count != 0) {
_batchPaths.RemoveAt(0);
this.BeginInvoke((MethodInvoker)delegate() {
if (_batchPaths.Count == 0) {
SetupControls(false);
ShowBatchDoneMessage();
}
else {
StartConvert();
}
});
}
}
public void SetStatus(string status, uint percentTrack, double percentDisk) {
this.BeginInvoke((MethodInvoker)delegate() {
toolStripStatusLabel1.Text = status;
toolStripProgressBar1.Value = (int)percentTrack;
toolStripProgressBar2.Value = (int)(percentDisk*100);
});
}
private void SetupControls(bool running) {
grpCUEPaths.Enabled = !running;
grpOutputPathGeneration.Enabled = !running;
grpAudioOutput.Enabled = !running && !rbArVerify.Checked;
grpAccurateRip.Enabled = !running;
grpOutputStyle.Enabled = !running && !rbArVerify.Checked;
txtDataTrackLength.Enabled = !running && !rbArNone.Checked;
btnAbout.Enabled = !running;
btnSettings.Enabled = !running;
btnFilenameCorrector.Enabled = !running;
btnCUECreator.Enabled = !running;
btnBatch.Enabled = !running;
btnConvert.Text = running ? "&Stop" : "&Convert";
toolStripStatusLabel1.Text = String.Empty;
toolStripProgressBar1.Value = 0;
toolStripProgressBar2.Value = 0;
}
private bool ShowErrorMessage(Exception ex) {
DialogResult dlgRes = MessageBox.Show(ex.Message, "Error", (_batchPaths.Count == 0) ?
MessageBoxButtons.OK : MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
return (dlgRes == DialogResult.OK);
}
private void ShowFinishedMessage(bool warnAboutPadding) {
if (_batchPaths.Count != 0) {
return;
}
if (warnAboutPadding) {
MessageBox.Show("One or more input file doesn't end on a CD frame boundary. " +
"The output has been padded where necessary to fix this. If your input " +
"files are from a CD source, this may indicate a problem with your files.",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
MessageBox.Show("Conversion was successful!", "Done", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
private void ShowBatchDoneMessage() {
MessageBox.Show("Batch conversion is complete!", "Done", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
private bool CheckWriteOffset() {
if ((_writeOffset == 0) || rbNoAudio.Checked || rbArVerify.Checked) {
return true;
}
DialogResult dlgRes = MessageBox.Show("Write offset setting is non-zero which " +
"will cause some samples to be discarded. You should only use this setting " +
"to make temporary files for burning. Are you sure you want to continue?",
"Write offset is enabled", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
return (dlgRes == DialogResult.Yes);
}
private void AddDirToBatch(string dir) {
string[] files = Directory.GetFiles(dir, "*.cue");
string[] subDirs = Directory.GetDirectories(dir);
_batchPaths.AddRange(files);
foreach (string subDir in subDirs) {
AddDirToBatch(subDir);
}
}
private void LoadSettings() {
SettingsReader sr = new SettingsReader("CUE Tools", "settings.txt");
string val;
val = sr.Load("OutputPathGeneration");
if (val != null) {
try {
SelectedOutputPathGeneration = (OutputPathGeneration)Int32.Parse(val);
}
catch { }
}
val = sr.Load("OutputSubdirectory");
if (val != null) {
txtCreateSubdirectory.Text = val;
}
val = sr.Load("OutputFilenameSuffix");
if (val != null) {
txtAppendFilename.Text = val;
}
val = sr.Load("OutputCustomFormat");
if (val != null) {
txtCustomFormat.Text = val;
}
val = sr.Load("OutputAudioFormat");
if (val != null) {
try {
SelectedOutputAudioFormat = (OutputAudioFormat)Int32.Parse(val);
}
catch { }
}
val = sr.Load("AccurateRipMode");
if (val != null) {
try {
SelectedAccurateRipMode = (AccurateRipMode)Int32.Parse(val);
}
catch { }
}
val = sr.Load("CUEStyle");
if (val != null) {
try {
SelectedCUEStyle = (CUEStyle)Int32.Parse(val);
}
catch { }
}
val = sr.Load("WriteOffset");
if (val != null) {
if (!Int32.TryParse(val, out _writeOffset)) _writeOffset = 0;
}
val = sr.Load("UsePregapForFirstTrackInSingleFile");
_usePregapForFirstTrackInSingleFile = (val != null) ? (val != "0") : false;
_config.Load(sr);
}
private void SaveSettings() {
SettingsWriter sw = new SettingsWriter("CUE Tools", "settings.txt");
sw.Save("OutputPathGeneration", ((int)SelectedOutputPathGeneration).ToString());
sw.Save("OutputSubdirectory", txtCreateSubdirectory.Text);
sw.Save("OutputFilenameSuffix", txtAppendFilename.Text);
sw.Save("OutputCustomFormat", txtCustomFormat.Text);
sw.Save("OutputAudioFormat", ((int)SelectedOutputAudioFormat).ToString());
sw.Save("AccurateRipMode", ((int)SelectedAccurateRipMode).ToString());
sw.Save("CUEStyle", ((int)SelectedCUEStyle).ToString());
sw.Save("WriteOffset", _writeOffset.ToString());
sw.Save("UsePregapForFirstTrackInSingleFile", _usePregapForFirstTrackInSingleFile ? "1" : "0");
_config.Save(sw);
sw.Close();
}
private void BuildOutputPathFindReplace(string inputPath, string format, List<string> find, List<string> replace) {
int i, j, first, last, maxFindLen;
string range;
string[] rangeSplit;
List<string> tmpFind = new List<string>();
List<string> tmpReplace = new List<string>();
i = 0;
last = 0;
while (i < format.Length) {
if (format[i++] == '%') {
j = i;
while (j < format.Length) {
char c = format[j];
if (((c < '0') || (c > '9')) && (c != '-') && (c != ':')) {
break;
}
j++;
}
range = format.Substring(i, j - i);
if (range.Length != 0) {
rangeSplit = range.Split(new char[] { ':' }, 2);
if (Int32.TryParse(rangeSplit[0], out first)) {
if (rangeSplit.Length == 1) {
last = first;
}
if ((rangeSplit.Length == 1) || Int32.TryParse(rangeSplit[1], out last)) {
tmpFind.Add("%" + range);
tmpReplace.Add(General.EmptyStringToNull(GetDirectoryElements(Path.GetDirectoryName(inputPath), first, last)));
}
}
}
i = j;
}
}
// Sort so that longest find strings are first, so when the replacing is done the
// longer strings are checked first. This avoids problems with overlapping find
// strings, for example if one of the strings is "%1" and another is "%1:3".
maxFindLen = 0;
for (i = 0; i < tmpFind.Count; i++) {
if (tmpFind[i].Length > maxFindLen) {
maxFindLen = tmpFind[i].Length;
}
}
for (j = maxFindLen; j >= 1; j--) {
for (i = 0; i < tmpFind.Count; i++) {
if (tmpFind[i].Length == j) {
find.Add(tmpFind[i]);
replace.Add(tmpReplace[i]);
}
}
}
find.Add("%F");
replace.Add(Path.GetFileNameWithoutExtension(inputPath));
}
private string GetDirectoryElements(string dir, int first, int last) {
string[] dirSplit = dir.Split(Path.DirectorySeparatorChar,
Path.AltDirectorySeparatorChar);
int count = dirSplit.Length;
if ((first == 0) && (last == 0)) {
first = 1;
last = count;
}
if (first < 0) first = (count + 1) + first;
if (last < 0) last = (count + 1) + last;
if ((first < 1) && (last < 1)) {
return String.Empty;
}
else if ((first > count) && (last > count)) {
return String.Empty;
}
else {
int i;
StringBuilder sb = new StringBuilder();
if (first < 1) first = 1;
if (first > count) first = count;
if (last < 1) last = 1;
if (last > count) last = count;
if (last >= first) {
for (i = first; i <= last; i++) {
sb.Append(dirSplit[i - 1]);
sb.Append(Path.DirectorySeparatorChar);
}
}
else {
for (i = first; i >= last; i--) {
sb.Append(dirSplit[i - 1]);
sb.Append(Path.DirectorySeparatorChar);
}
}
return sb.ToString(0, sb.Length - 1);
}
}
private CUEStyle SelectedCUEStyle {
get {
if (rbGapsAppended.Checked) return CUEStyle.GapsAppended;
if (rbGapsPrepended.Checked) return CUEStyle.GapsPrepended;
if (rbGapsLeftOut.Checked) return CUEStyle.GapsLeftOut;
if (rbEmbedCUE.Checked) return CUEStyle.SingleFileWithCUE;
return CUEStyle.SingleFile;
}
set {
switch (value) {
case CUEStyle.SingleFileWithCUE: rbEmbedCUE.Checked = true; break;
case CUEStyle.SingleFile: rbSingleFile.Checked = true; break;
case CUEStyle.GapsAppended: rbGapsAppended.Checked = true; break;
case CUEStyle.GapsPrepended: rbGapsPrepended.Checked = true; break;
case CUEStyle.GapsLeftOut: rbGapsLeftOut.Checked = true; break;
}
}
}
private OutputPathGeneration SelectedOutputPathGeneration {
get {
if (rbCreateSubdirectory.Checked) return OutputPathGeneration.CreateSubdirectory;
if (rbAppendFilename.Checked) return OutputPathGeneration.AppendFilename;
if (rbCustomFormat.Checked) return OutputPathGeneration.CustomFormat;
return OutputPathGeneration.Disabled;
}
set {
switch (value) {
case OutputPathGeneration.CreateSubdirectory: rbCreateSubdirectory.Checked = true; break;
case OutputPathGeneration.AppendFilename: rbAppendFilename.Checked = true; break;
case OutputPathGeneration.CustomFormat: rbCustomFormat.Checked = true; break;
case OutputPathGeneration.Disabled: rbDontGenerate.Checked = true; break;
}
}
}
private OutputAudioFormat SelectedOutputAudioFormat {
get {
if (rbFLAC.Checked) return OutputAudioFormat.FLAC;
if (rbWavPack.Checked) return OutputAudioFormat.WavPack;
if (rbNoAudio.Checked) return OutputAudioFormat.NoAudio;
return OutputAudioFormat.WAV;
}
set {
switch (value) {
case OutputAudioFormat.FLAC: rbFLAC.Checked = true; break;
case OutputAudioFormat.WavPack: rbWavPack.Checked = true; break;
case OutputAudioFormat.WAV: rbWAV.Checked = true; break;
case OutputAudioFormat.NoAudio: rbNoAudio.Checked = true; break;
}
}
}
private AccurateRipMode SelectedAccurateRipMode {
get {
if (rbArVerify.Checked) return AccurateRipMode.Verify;
if (rbArApplyOffset.Checked) return AccurateRipMode.Offset;
return AccurateRipMode.None;
}
set {
switch (value) {
case AccurateRipMode.Verify: rbArVerify.Checked = true; break;
case AccurateRipMode.Offset: rbArApplyOffset.Checked = true; break;
default: rbArNone.Checked = true; break;
}
}
}
private void CenterSubForm(Form form) {
int centerX, centerY, formX, formY;
Rectangle formRect, maxRect;
centerX = ((Left * 2) + Width ) / 2;
centerY = ((Top * 2) + Height) / 2;
formX = ((Left * 2) + Width - form.Width ) / 2;
formY = ((Top * 2) + Height - form.Height) / 2;
formRect = new Rectangle(formX, formY, form.Width, form.Height);
maxRect = Screen.GetWorkingArea(new Point(centerX, centerY));
if (formRect.Right > maxRect.Right) {
formRect.X -= formRect.Right - maxRect.Right;
}
if (formRect.Bottom > maxRect.Bottom) {
formRect.Y -= formRect.Bottom - maxRect.Bottom;
}
if (formRect.X < maxRect.X) {
formRect.X = maxRect.X;
}
if (formRect.Y < maxRect.Y) {
formRect.Y = maxRect.Y;
}
form.Location = formRect.Location;
}
private void UpdateOutputPath() {
UpdateOutputPath("Artist", "Album");
}
private void UpdateOutputPath(string artist, string album) {
/* if (rbArVerify.Checked)
{
txtOutputPath.Text = txtInputPath.Text;
txtOutputPath.ReadOnly = true;
btnBrowseOutput.Enabled = false;
}
else */ if (rbDontGenerate.Checked)
{
txtOutputPath.ReadOnly = false;
btnBrowseOutput.Enabled = true;
}
else
{
txtOutputPath.ReadOnly = true;
btnBrowseOutput.Enabled = false;
txtOutputPath.Text = GenerateOutputPath(artist, album);
}
}
private string GenerateOutputPath(string artist, string album) {
string pathIn, pathOut, dir, file, ext;
pathIn = txtInputPath.Text;
pathOut = String.Empty;
if ((pathIn.Length != 0) && File.Exists(pathIn)) {
dir = Path.GetDirectoryName(pathIn);
file = Path.GetFileNameWithoutExtension(pathIn);
ext = ".cue";
if (rbEmbedCUE.Checked)
ext = General.FormatExtension (SelectedOutputAudioFormat);
if (rbCreateSubdirectory.Checked) {
pathOut = Path.Combine(Path.Combine(dir, txtCreateSubdirectory.Text), file + ext);
}
else if (rbAppendFilename.Checked) {
pathOut = Path.Combine(dir, file + txtAppendFilename.Text + ext);
}
else if (rbCustomFormat.Checked) {
string format = txtCustomFormat.Text;
List<string> find = new List<string>();
List<string> replace = new List<string>();
bool rs = _config.replaceSpaces;
find.Add("%D");
find.Add("%C");
replace.Add(General.EmptyStringToNull(_config.CleanseString(rs ? artist.Replace(' ', '_') : artist)));
replace.Add(General.EmptyStringToNull(_config.CleanseString(rs ? album.Replace(' ', '_') : album)));
BuildOutputPathFindReplace(pathIn, format, find, replace);
pathOut = General.ReplaceMultiple(format, find, replace);
if (pathOut == null) pathOut = String.Empty;
pathOut = Path.ChangeExtension(pathOut, ext);
}
}
return pathOut;
}
private void updateOutputStyles()
{
rbEmbedCUE.Enabled = rbFLAC.Checked;
rbNoAudio.Enabled = rbWAV.Enabled = rbWavPack.Enabled = !rbEmbedCUE.Checked;
}
private void rbWAV_CheckedChanged(object sender, EventArgs e)
{
updateOutputStyles();
}
private void rbFLAC_CheckedChanged(object sender, EventArgs e)
{
updateOutputStyles();
}
private void rbWavPack_CheckedChanged(object sender, EventArgs e)
{
updateOutputStyles();
}
private void rbEmbedCUE_CheckedChanged(object sender, EventArgs e)
{
updateOutputStyles();
UpdateOutputPath();
}
private void rbNoAudio_CheckedChanged(object sender, EventArgs e)
{
updateOutputStyles();
UpdateOutputPath();
}
private void rbArVerify_CheckedChanged(object sender, EventArgs e)
{
UpdateOutputPath();
SetupControls (false);
}
private void CUECreator (string dir)
{
string[] cueFiles = Directory.GetFiles(dir, "*.cue");
if (cueFiles.Length == 0)
{
string[] audioExts = new string[] { "*.wav", "*.flac", "*.wv", "*.ape" };
for (int i = 0; i < audioExts.Length; i++)
{
string [] audioFiles = Directory.GetFiles(dir, audioExts[i]);
if (audioFiles.Length < 2)
continue;
Array.Sort (audioFiles);
string cueName = Path.GetFileName(dir) + ".cuetools" + audioExts[i].Substring(1) + ".cue";
cueName = Path.Combine(dir, cueName);
StreamWriter sw = new StreamWriter(cueName, false, CUESheet.Encoding);
sw.WriteLine(String.Format("REM COMMENT \"CUETools generated dummy CUE sheet\""));
for (int iFile = 0; iFile < audioFiles.Length; iFile++)
{
sw.WriteLine(String.Format("FILE \"{0}\" WAVE", Path.GetFileName (audioFiles[iFile])));
sw.WriteLine(String.Format(" TRACK {0:00} AUDIO", iFile+1));
sw.WriteLine(String.Format(" INDEX 01 00:00:00"));
}
sw.Close();
break;
}
}
string[] subDirs = Directory.GetDirectories(dir);
foreach (string subDir in subDirs)
{
CUECreator (subDir);
}
}
private void btnCUECreator_Click(object sender, EventArgs e)
{
FolderBrowserDialog folderDialog = new FolderBrowserDialog();
folderDialog.Description = "Select the folder containing the audio files without CUE sheets. Subfolders will be included automatically.";
folderDialog.ShowNewFolderButton = false;
if (folderDialog.ShowDialog() == DialogResult.OK)
{
try
{
CUECreator(folderDialog.SelectedPath);
}
catch (Exception ex)
{
ShowErrorMessage(ex);
}
}
}
}
enum OutputPathGeneration {
CreateSubdirectory,
AppendFilename,
CustomFormat,
Disabled
}
enum AccurateRipMode {
None,
Verify,
Offset
}
}

1488
CUETools/frmCUETools.resx Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,63 @@
namespace JDP {
partial class frmFilenameCorrector {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmFilenameCorrector));
this.lblDescription = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lblDescription
//
this.lblDescription.Location = new System.Drawing.Point(8, 8);
this.lblDescription.Name = "lblDescription";
this.lblDescription.Size = new System.Drawing.Size(272, 144);
this.lblDescription.TabIndex = 0;
this.lblDescription.Text = resources.GetString("lblDescription.Text");
this.lblDescription.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// frmFilenameCorrector
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(286, 159);
this.Controls.Add(this.lblDescription);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "frmFilenameCorrector";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Filename Corrector";
this.TopMost = true;
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.frmFilenameCorrector_DragDrop);
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.frmFilenameCorrector_DragEnter);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label lblDescription;
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
namespace JDP {
public partial class frmFilenameCorrector : Form {
private Thread _workThread;
public frmFilenameCorrector() {
InitializeComponent();
}
private void frmFilenameCorrector_DragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
e.Effect = DragDropEffects.Copy;
}
}
private void frmFilenameCorrector_DragDrop(object sender, DragEventArgs e) {
if ((_workThread != null) && (_workThread.IsAlive)) {
return;
}
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
_workThread = new Thread(new ParameterizedThreadStart(CorrectCUEThread));
_workThread.Start(e.Data.GetData(DataFormats.FileDrop));
}
}
private void CorrectCUEThread(object p) {
string[] paths = (string[])p;
bool oneSuccess = false;
bool cancel = false;
foreach (string path in paths) {
if (Path.GetExtension(path).ToLower() == ".cue") {
try {
string fixedCue = CUESheet.CorrectAudioFilenames(path, true);
using (StreamWriter sw = new StreamWriter(path, false, CUESheet.Encoding))
sw.Write (fixedCue);
oneSuccess = true;
}
catch (Exception ex) {
Invoke((MethodInvoker)delegate() {
cancel = (MessageBox.Show(this, path + Environment.NewLine +
Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OKCancel,
MessageBoxIcon.Error) == DialogResult.Cancel);
});
if (cancel) break;
}
}
}
if (oneSuccess) {
Invoke((MethodInvoker)delegate() {
MessageBox.Show(this, "Filename correction is complete!", "Done",
MessageBoxButtons.OK, MessageBoxIcon.Information);
});
}
}
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="lblDescription.Text" xml:space="preserve">
<value>Drop CUE sheets here to correct the audio filenames contained inside. The audio files must be located in the same folder as the CUE sheet. The number of audio files in that folder must match the number of files referenced by the CUE sheet. The audio files must be named such that when sorted they are in order by track number. To correct multiple CUE sheets at once, you can drop the search results for *.cue.</value>
</data>
</root>

79
CUETools/frmReport.Designer.cs generated Normal file
View File

@@ -0,0 +1,79 @@
namespace JDP
{
partial class frmReport
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button1.Location = new System.Drawing.Point(254, 322);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Close";
this.button1.UseVisualStyleBackColor = true;
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.SystemColors.Control;
this.textBox1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.textBox1.Location = new System.Drawing.Point(21, 16);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Size = new System.Drawing.Size(540, 287);
this.textBox1.TabIndex = 1;
//
// frmReport
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button1;
this.ClientSize = new System.Drawing.Size(582, 357);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.Name = "frmReport";
this.Text = "Status report";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
}
}

21
CUETools/frmReport.cs Normal file
View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace JDP
{
public partial class frmReport : Form
{
public frmReport()
{
InitializeComponent();
}
public string Message {
get { return textBox1.Text; }
set { textBox1.Text = value; }
}
}
}

120
CUETools/frmReport.resx Normal file
View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

687
CUETools/frmSettings.Designer.cs generated Normal file
View File

@@ -0,0 +1,687 @@
namespace JDP {
partial class frmSettings {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
System.Windows.Forms.Button btnCancel;
this.grpGeneral = new System.Windows.Forms.GroupBox();
this.numericWriteOffset = new System.Windows.Forms.NumericUpDown();
this.chkAutoCorrectFilenames = new System.Windows.Forms.CheckBox();
this.chkPreserveHTOA = new System.Windows.Forms.CheckBox();
this.lblWriteOffset = new System.Windows.Forms.Label();
this.grpFLAC = new System.Windows.Forms.GroupBox();
this.numericFLACCompressionLevel = new System.Windows.Forms.NumericUpDown();
this.lblFLACCompressionLevel = new System.Windows.Forms.Label();
this.chkFLACVerify = new System.Windows.Forms.CheckBox();
this.btnOK = new System.Windows.Forms.Button();
this.grpWavPack = new System.Windows.Forms.GroupBox();
this.chkWVExtraMode = new System.Windows.Forms.CheckBox();
this.rbWVVeryHigh = new System.Windows.Forms.RadioButton();
this.rbWVHigh = new System.Windows.Forms.RadioButton();
this.rbWVNormal = new System.Windows.Forms.RadioButton();
this.rbWVFast = new System.Windows.Forms.RadioButton();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.numFixWhenConfidence = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.numFixWhenPercent = new System.Windows.Forms.NumericUpDown();
this.chkArAddCRCs = new System.Windows.Forms.CheckBox();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.grpAudioFilenames = new System.Windows.Forms.GroupBox();
this.chkKeepOriginalFilenames = new System.Windows.Forms.CheckBox();
this.txtSpecialExceptions = new System.Windows.Forms.TextBox();
this.chkRemoveSpecial = new System.Windows.Forms.CheckBox();
this.chkReplaceSpaces = new System.Windows.Forms.CheckBox();
this.txtTrackFilenameFormat = new System.Windows.Forms.TextBox();
this.lblTrackFilenameFormat = new System.Windows.Forms.Label();
this.lblSingleFilenameFormat = new System.Windows.Forms.Label();
this.txtSingleFilenameFormat = new System.Windows.Forms.TextBox();
this.chkArSaveLog = new System.Windows.Forms.CheckBox();
this.chkArNoUnverifiedAudio = new System.Windows.Forms.CheckBox();
this.numWVExtraMode = new System.Windows.Forms.NumericUpDown();
this.numEncodeWhenConfidence = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.numEncodeWhenPercent = new System.Windows.Forms.NumericUpDown();
this.label4 = new System.Windows.Forms.Label();
this.chkArFixOffset = new System.Windows.Forms.CheckBox();
btnCancel = new System.Windows.Forms.Button();
this.grpGeneral.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericWriteOffset)).BeginInit();
this.grpFLAC.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericFLACCompressionLevel)).BeginInit();
this.grpWavPack.SuspendLayout();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numFixWhenConfidence)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numFixWhenPercent)).BeginInit();
this.grpAudioFilenames.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numWVExtraMode)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numEncodeWhenConfidence)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numEncodeWhenPercent)).BeginInit();
this.SuspendLayout();
//
// btnCancel
//
btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
btnCancel.Location = new System.Drawing.Point(267, 373);
btnCancel.Name = "btnCancel";
btnCancel.Size = new System.Drawing.Size(73, 23);
btnCancel.TabIndex = 5;
btnCancel.Text = "Cancel";
btnCancel.UseVisualStyleBackColor = true;
//
// grpGeneral
//
this.grpGeneral.Controls.Add(this.numericWriteOffset);
this.grpGeneral.Controls.Add(this.chkAutoCorrectFilenames);
this.grpGeneral.Controls.Add(this.chkPreserveHTOA);
this.grpGeneral.Controls.Add(this.lblWriteOffset);
this.grpGeneral.Location = new System.Drawing.Point(8, 4);
this.grpGeneral.Name = "grpGeneral";
this.grpGeneral.Size = new System.Drawing.Size(246, 128);
this.grpGeneral.TabIndex = 0;
this.grpGeneral.TabStop = false;
this.grpGeneral.Text = "General";
//
// numericWriteOffset
//
this.numericWriteOffset.Location = new System.Drawing.Point(133, 20);
this.numericWriteOffset.Maximum = new decimal(new int[] {
5000,
0,
0,
0});
this.numericWriteOffset.Minimum = new decimal(new int[] {
5000,
0,
0,
-2147483648});
this.numericWriteOffset.Name = "numericWriteOffset";
this.numericWriteOffset.Size = new System.Drawing.Size(62, 21);
this.numericWriteOffset.TabIndex = 5;
this.numericWriteOffset.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// chkAutoCorrectFilenames
//
this.chkAutoCorrectFilenames.Location = new System.Drawing.Point(12, 68);
this.chkAutoCorrectFilenames.Name = "chkAutoCorrectFilenames";
this.chkAutoCorrectFilenames.Size = new System.Drawing.Size(232, 36);
this.chkAutoCorrectFilenames.TabIndex = 3;
this.chkAutoCorrectFilenames.Text = "Preprocess with filename corrector if unable to locate audio files";
this.chkAutoCorrectFilenames.UseVisualStyleBackColor = true;
//
// chkPreserveHTOA
//
this.chkPreserveHTOA.AutoSize = true;
this.chkPreserveHTOA.Location = new System.Drawing.Point(12, 48);
this.chkPreserveHTOA.Name = "chkPreserveHTOA";
this.chkPreserveHTOA.Size = new System.Drawing.Size(229, 17);
this.chkPreserveHTOA.TabIndex = 2;
this.chkPreserveHTOA.Text = "Preserve HTOA for gaps appended output";
this.chkPreserveHTOA.UseVisualStyleBackColor = true;
//
// lblWriteOffset
//
this.lblWriteOffset.AutoSize = true;
this.lblWriteOffset.Location = new System.Drawing.Point(9, 23);
this.lblWriteOffset.Name = "lblWriteOffset";
this.lblWriteOffset.Size = new System.Drawing.Size(118, 13);
this.lblWriteOffset.TabIndex = 0;
this.lblWriteOffset.Text = "Write offset (samples):";
//
// grpFLAC
//
this.grpFLAC.Controls.Add(this.numericFLACCompressionLevel);
this.grpFLAC.Controls.Add(this.lblFLACCompressionLevel);
this.grpFLAC.Controls.Add(this.chkFLACVerify);
this.grpFLAC.Location = new System.Drawing.Point(267, 282);
this.grpFLAC.Name = "grpFLAC";
this.grpFLAC.Size = new System.Drawing.Size(259, 48);
this.grpFLAC.TabIndex = 1;
this.grpFLAC.TabStop = false;
this.grpFLAC.Text = "FLAC";
//
// numericFLACCompressionLevel
//
this.numericFLACCompressionLevel.Location = new System.Drawing.Point(213, 15);
this.numericFLACCompressionLevel.Maximum = new decimal(new int[] {
8,
0,
0,
0});
this.numericFLACCompressionLevel.Name = "numericFLACCompressionLevel";
this.numericFLACCompressionLevel.Size = new System.Drawing.Size(35, 21);
this.numericFLACCompressionLevel.TabIndex = 4;
this.numericFLACCompressionLevel.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.numericFLACCompressionLevel.Value = new decimal(new int[] {
5,
0,
0,
0});
//
// lblFLACCompressionLevel
//
this.lblFLACCompressionLevel.AutoSize = true;
this.lblFLACCompressionLevel.Location = new System.Drawing.Point(99, 17);
this.lblFLACCompressionLevel.Name = "lblFLACCompressionLevel";
this.lblFLACCompressionLevel.Size = new System.Drawing.Size(97, 13);
this.lblFLACCompressionLevel.TabIndex = 0;
this.lblFLACCompressionLevel.Text = "Compression level:";
//
// chkFLACVerify
//
this.chkFLACVerify.AutoSize = true;
this.chkFLACVerify.Location = new System.Drawing.Point(12, 16);
this.chkFLACVerify.Name = "chkFLACVerify";
this.chkFLACVerify.Size = new System.Drawing.Size(54, 17);
this.chkFLACVerify.TabIndex = 2;
this.chkFLACVerify.Text = "Verify";
this.chkFLACVerify.UseVisualStyleBackColor = true;
//
// btnOK
//
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnOK.Location = new System.Drawing.Point(185, 373);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(73, 23);
this.btnOK.TabIndex = 3;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// grpWavPack
//
this.grpWavPack.Controls.Add(this.numWVExtraMode);
this.grpWavPack.Controls.Add(this.chkWVExtraMode);
this.grpWavPack.Controls.Add(this.rbWVVeryHigh);
this.grpWavPack.Controls.Add(this.rbWVHigh);
this.grpWavPack.Controls.Add(this.rbWVNormal);
this.grpWavPack.Controls.Add(this.rbWVFast);
this.grpWavPack.Location = new System.Drawing.Point(267, 182);
this.grpWavPack.Name = "grpWavPack";
this.grpWavPack.Size = new System.Drawing.Size(259, 94);
this.grpWavPack.TabIndex = 2;
this.grpWavPack.TabStop = false;
this.grpWavPack.Text = "WavPack";
//
// chkWVExtraMode
//
this.chkWVExtraMode.AutoSize = true;
this.chkWVExtraMode.Location = new System.Drawing.Point(94, 20);
this.chkWVExtraMode.Name = "chkWVExtraMode";
this.chkWVExtraMode.Size = new System.Drawing.Size(112, 17);
this.chkWVExtraMode.TabIndex = 4;
this.chkWVExtraMode.Text = "Extra mode (1-6):";
this.chkWVExtraMode.UseVisualStyleBackColor = true;
this.chkWVExtraMode.CheckedChanged += new System.EventHandler(this.chkWVExtraMode_CheckedChanged);
//
// rbWVVeryHigh
//
this.rbWVVeryHigh.AutoSize = true;
this.rbWVVeryHigh.Location = new System.Drawing.Point(13, 70);
this.rbWVVeryHigh.Name = "rbWVVeryHigh";
this.rbWVVeryHigh.Size = new System.Drawing.Size(71, 17);
this.rbWVVeryHigh.TabIndex = 3;
this.rbWVVeryHigh.Text = "Very High";
this.rbWVVeryHigh.UseVisualStyleBackColor = true;
//
// rbWVHigh
//
this.rbWVHigh.AutoSize = true;
this.rbWVHigh.Location = new System.Drawing.Point(13, 53);
this.rbWVHigh.Name = "rbWVHigh";
this.rbWVHigh.Size = new System.Drawing.Size(46, 17);
this.rbWVHigh.TabIndex = 1;
this.rbWVHigh.Text = "High";
this.rbWVHigh.UseVisualStyleBackColor = true;
//
// rbWVNormal
//
this.rbWVNormal.AutoSize = true;
this.rbWVNormal.Checked = true;
this.rbWVNormal.Location = new System.Drawing.Point(13, 36);
this.rbWVNormal.Name = "rbWVNormal";
this.rbWVNormal.Size = new System.Drawing.Size(58, 17);
this.rbWVNormal.TabIndex = 2;
this.rbWVNormal.TabStop = true;
this.rbWVNormal.Text = "Normal";
this.rbWVNormal.UseVisualStyleBackColor = true;
//
// rbWVFast
//
this.rbWVFast.AutoSize = true;
this.rbWVFast.Location = new System.Drawing.Point(13, 19);
this.rbWVFast.Name = "rbWVFast";
this.rbWVFast.Size = new System.Drawing.Size(46, 17);
this.rbWVFast.TabIndex = 0;
this.rbWVFast.Text = "Fast";
this.rbWVFast.UseVisualStyleBackColor = true;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.chkArFixOffset);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.numEncodeWhenPercent);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.numEncodeWhenConfidence);
this.groupBox1.Controls.Add(this.chkArNoUnverifiedAudio);
this.groupBox1.Controls.Add(this.chkArSaveLog);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.numFixWhenConfidence);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.numFixWhenPercent);
this.groupBox1.Controls.Add(this.chkArAddCRCs);
this.groupBox1.Location = new System.Drawing.Point(267, 4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(259, 172);
this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "AccurateRip";
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(62, 146);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(101, 13);
this.label2.TabIndex = 5;
this.label2.Text = "with confidence >=";
//
// numFixWhenConfidence
//
this.numFixWhenConfidence.Location = new System.Drawing.Point(168, 144);
this.numFixWhenConfidence.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numFixWhenConfidence.Name = "numFixWhenConfidence";
this.numFixWhenConfidence.Size = new System.Drawing.Size(37, 21);
this.numFixWhenConfidence.TabIndex = 4;
this.numFixWhenConfidence.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(42, 125);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(121, 13);
this.label1.TabIndex = 3;
this.label1.Text = "% of verified tracks >=";
//
// numFixWhenPercent
//
this.numFixWhenPercent.Increment = new decimal(new int[] {
5,
0,
0,
0});
this.numFixWhenPercent.Location = new System.Drawing.Point(168, 123);
this.numFixWhenPercent.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numFixWhenPercent.Name = "numFixWhenPercent";
this.numFixWhenPercent.Size = new System.Drawing.Size(38, 21);
this.numFixWhenPercent.TabIndex = 2;
this.numFixWhenPercent.Value = new decimal(new int[] {
51,
0,
0,
0});
//
// chkArAddCRCs
//
this.chkArAddCRCs.AutoSize = true;
this.chkArAddCRCs.Checked = true;
this.chkArAddCRCs.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkArAddCRCs.Location = new System.Drawing.Point(12, 21);
this.chkArAddCRCs.Name = "chkArAddCRCs";
this.chkArAddCRCs.Size = new System.Drawing.Size(76, 17);
this.chkArAddCRCs.TabIndex = 1;
this.chkArAddCRCs.Text = "Write tags";
this.toolTip1.SetToolTip(this.chkArAddCRCs, "When using \"apply offset\" AccurateRip mode, also add ACCURATERIPCOUNT tag to flac" +
" files. You can set up foobar2000 to show this value, and see if your music was " +
"ripped correctly or how popular it is.");
this.chkArAddCRCs.UseVisualStyleBackColor = true;
//
// toolTip1
//
this.toolTip1.AutoPopDelay = 15000;
this.toolTip1.InitialDelay = 500;
this.toolTip1.ReshowDelay = 100;
//
// grpAudioFilenames
//
this.grpAudioFilenames.Controls.Add(this.chkKeepOriginalFilenames);
this.grpAudioFilenames.Controls.Add(this.txtSpecialExceptions);
this.grpAudioFilenames.Controls.Add(this.chkRemoveSpecial);
this.grpAudioFilenames.Controls.Add(this.chkReplaceSpaces);
this.grpAudioFilenames.Controls.Add(this.txtTrackFilenameFormat);
this.grpAudioFilenames.Controls.Add(this.lblTrackFilenameFormat);
this.grpAudioFilenames.Controls.Add(this.lblSingleFilenameFormat);
this.grpAudioFilenames.Controls.Add(this.txtSingleFilenameFormat);
this.grpAudioFilenames.Location = new System.Drawing.Point(12, 138);
this.grpAudioFilenames.Name = "grpAudioFilenames";
this.grpAudioFilenames.Size = new System.Drawing.Size(246, 192);
this.grpAudioFilenames.TabIndex = 6;
this.grpAudioFilenames.TabStop = false;
this.grpAudioFilenames.Text = "Audio Filenames";
//
// chkKeepOriginalFilenames
//
this.chkKeepOriginalFilenames.AutoSize = true;
this.chkKeepOriginalFilenames.Checked = true;
this.chkKeepOriginalFilenames.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkKeepOriginalFilenames.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.chkKeepOriginalFilenames.Location = new System.Drawing.Point(12, 20);
this.chkKeepOriginalFilenames.Name = "chkKeepOriginalFilenames";
this.chkKeepOriginalFilenames.Size = new System.Drawing.Size(135, 17);
this.chkKeepOriginalFilenames.TabIndex = 0;
this.chkKeepOriginalFilenames.Text = "Keep original filenames";
this.chkKeepOriginalFilenames.UseVisualStyleBackColor = true;
//
// txtSpecialExceptions
//
this.txtSpecialExceptions.Location = new System.Drawing.Point(92, 123);
this.txtSpecialExceptions.Name = "txtSpecialExceptions";
this.txtSpecialExceptions.Size = new System.Drawing.Size(136, 21);
this.txtSpecialExceptions.TabIndex = 6;
this.txtSpecialExceptions.Text = "-()";
//
// chkRemoveSpecial
//
this.chkRemoveSpecial.AutoSize = true;
this.chkRemoveSpecial.Checked = true;
this.chkRemoveSpecial.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkRemoveSpecial.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.chkRemoveSpecial.Location = new System.Drawing.Point(12, 100);
this.chkRemoveSpecial.Name = "chkRemoveSpecial";
this.chkRemoveSpecial.Size = new System.Drawing.Size(194, 17);
this.chkRemoveSpecial.TabIndex = 5;
this.chkRemoveSpecial.Text = "Remove special characters except:";
this.chkRemoveSpecial.UseVisualStyleBackColor = true;
//
// chkReplaceSpaces
//
this.chkReplaceSpaces.AutoSize = true;
this.chkReplaceSpaces.Checked = true;
this.chkReplaceSpaces.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkReplaceSpaces.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.chkReplaceSpaces.Location = new System.Drawing.Point(12, 150);
this.chkReplaceSpaces.Name = "chkReplaceSpaces";
this.chkReplaceSpaces.Size = new System.Drawing.Size(185, 17);
this.chkReplaceSpaces.TabIndex = 7;
this.chkReplaceSpaces.Text = "Replace spaces with underscores";
this.chkReplaceSpaces.UseVisualStyleBackColor = true;
//
// txtTrackFilenameFormat
//
this.txtTrackFilenameFormat.Location = new System.Drawing.Point(92, 72);
this.txtTrackFilenameFormat.Name = "txtTrackFilenameFormat";
this.txtTrackFilenameFormat.Size = new System.Drawing.Size(136, 21);
this.txtTrackFilenameFormat.TabIndex = 4;
this.txtTrackFilenameFormat.Text = "%N-%A-%T";
//
// lblTrackFilenameFormat
//
this.lblTrackFilenameFormat.AutoSize = true;
this.lblTrackFilenameFormat.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.lblTrackFilenameFormat.Location = new System.Drawing.Point(10, 76);
this.lblTrackFilenameFormat.Name = "lblTrackFilenameFormat";
this.lblTrackFilenameFormat.Size = new System.Drawing.Size(72, 13);
this.lblTrackFilenameFormat.TabIndex = 3;
this.lblTrackFilenameFormat.Text = "Track format:";
//
// lblSingleFilenameFormat
//
this.lblSingleFilenameFormat.AutoSize = true;
this.lblSingleFilenameFormat.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.lblSingleFilenameFormat.Location = new System.Drawing.Point(10, 48);
this.lblSingleFilenameFormat.Name = "lblSingleFilenameFormat";
this.lblSingleFilenameFormat.Size = new System.Drawing.Size(74, 13);
this.lblSingleFilenameFormat.TabIndex = 1;
this.lblSingleFilenameFormat.Text = "Single format:";
//
// txtSingleFilenameFormat
//
this.txtSingleFilenameFormat.Location = new System.Drawing.Point(92, 44);
this.txtSingleFilenameFormat.Name = "txtSingleFilenameFormat";
this.txtSingleFilenameFormat.Size = new System.Drawing.Size(136, 21);
this.txtSingleFilenameFormat.TabIndex = 2;
this.txtSingleFilenameFormat.Text = "%F";
//
// chkArSaveLog
//
this.chkArSaveLog.AutoSize = true;
this.chkArSaveLog.Checked = true;
this.chkArSaveLog.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkArSaveLog.Location = new System.Drawing.Point(94, 21);
this.chkArSaveLog.Name = "chkArSaveLog";
this.chkArSaveLog.Size = new System.Drawing.Size(69, 17);
this.chkArSaveLog.TabIndex = 6;
this.chkArSaveLog.Text = "Write log";
this.chkArSaveLog.UseVisualStyleBackColor = true;
//
// chkArNoUnverifiedAudio
//
this.chkArNoUnverifiedAudio.AutoSize = true;
this.chkArNoUnverifiedAudio.Checked = true;
this.chkArNoUnverifiedAudio.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkArNoUnverifiedAudio.Location = new System.Drawing.Point(12, 44);
this.chkArNoUnverifiedAudio.Name = "chkArNoUnverifiedAudio";
this.chkArNoUnverifiedAudio.Size = new System.Drawing.Size(93, 17);
this.chkArNoUnverifiedAudio.TabIndex = 7;
this.chkArNoUnverifiedAudio.Text = "Encode only if";
this.chkArNoUnverifiedAudio.UseVisualStyleBackColor = true;
this.chkArNoUnverifiedAudio.CheckedChanged += new System.EventHandler(this.chkArNoUnverifiedAudio_CheckedChanged);
//
// numWVExtraMode
//
this.numWVExtraMode.Location = new System.Drawing.Point(212, 19);
this.numWVExtraMode.Maximum = new decimal(new int[] {
6,
0,
0,
0});
this.numWVExtraMode.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numWVExtraMode.Name = "numWVExtraMode";
this.numWVExtraMode.Size = new System.Drawing.Size(29, 21);
this.numWVExtraMode.TabIndex = 5;
this.numWVExtraMode.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// numEncodeWhenConfidence
//
this.numEncodeWhenConfidence.Location = new System.Drawing.Point(168, 87);
this.numEncodeWhenConfidence.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numEncodeWhenConfidence.Name = "numEncodeWhenConfidence";
this.numEncodeWhenConfidence.Size = new System.Drawing.Size(38, 21);
this.numEncodeWhenConfidence.TabIndex = 8;
this.numEncodeWhenConfidence.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// label3
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(62, 89);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(101, 13);
this.label3.TabIndex = 9;
this.label3.Text = "with confidence >=";
//
// numEncodeWhenPercent
//
this.numEncodeWhenPercent.Increment = new decimal(new int[] {
5,
0,
0,
0});
this.numEncodeWhenPercent.Location = new System.Drawing.Point(168, 66);
this.numEncodeWhenPercent.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numEncodeWhenPercent.Name = "numEncodeWhenPercent";
this.numEncodeWhenPercent.Size = new System.Drawing.Size(38, 21);
this.numEncodeWhenPercent.TabIndex = 10;
this.numEncodeWhenPercent.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// label4
//
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(41, 68);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(121, 13);
this.label4.TabIndex = 11;
this.label4.Text = "% of verified tracks >=";
//
// chkArFixOffset
//
this.chkArFixOffset.AutoSize = true;
this.chkArFixOffset.Checked = true;
this.chkArFixOffset.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkArFixOffset.Location = new System.Drawing.Point(12, 105);
this.chkArFixOffset.Name = "chkArFixOffset";
this.chkArFixOffset.Size = new System.Drawing.Size(81, 17);
this.chkArFixOffset.TabIndex = 12;
this.chkArFixOffset.Text = "Fix offset if";
this.chkArFixOffset.UseVisualStyleBackColor = true;
this.chkArFixOffset.CheckedChanged += new System.EventHandler(this.chkArFixOffset_CheckedChanged);
//
// frmSettings
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = btnCancel;
this.ClientSize = new System.Drawing.Size(540, 430);
this.Controls.Add(this.grpAudioFilenames);
this.Controls.Add(btnCancel);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.grpWavPack);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.grpFLAC);
this.Controls.Add(this.grpGeneral);
this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "frmSettings";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Advanced Settings";
this.Load += new System.EventHandler(this.frmSettings_Load);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmSettings_FormClosing);
this.grpGeneral.ResumeLayout(false);
this.grpGeneral.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericWriteOffset)).EndInit();
this.grpFLAC.ResumeLayout(false);
this.grpFLAC.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericFLACCompressionLevel)).EndInit();
this.grpWavPack.ResumeLayout(false);
this.grpWavPack.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numFixWhenConfidence)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numFixWhenPercent)).EndInit();
this.grpAudioFilenames.ResumeLayout(false);
this.grpAudioFilenames.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numWVExtraMode)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numEncodeWhenConfidence)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numEncodeWhenPercent)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox grpGeneral;
private System.Windows.Forms.CheckBox chkPreserveHTOA;
private System.Windows.Forms.Label lblWriteOffset;
private System.Windows.Forms.GroupBox grpFLAC;
private System.Windows.Forms.Label lblFLACCompressionLevel;
private System.Windows.Forms.CheckBox chkFLACVerify;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.GroupBox grpWavPack;
private System.Windows.Forms.RadioButton rbWVVeryHigh;
private System.Windows.Forms.RadioButton rbWVHigh;
private System.Windows.Forms.RadioButton rbWVNormal;
private System.Windows.Forms.RadioButton rbWVFast;
private System.Windows.Forms.CheckBox chkWVExtraMode;
private System.Windows.Forms.CheckBox chkAutoCorrectFilenames;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox chkArAddCRCs;
private System.Windows.Forms.NumericUpDown numericFLACCompressionLevel;
private System.Windows.Forms.NumericUpDown numericWriteOffset;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.NumericUpDown numFixWhenPercent;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.NumericUpDown numFixWhenConfidence;
private System.Windows.Forms.GroupBox grpAudioFilenames;
private System.Windows.Forms.CheckBox chkKeepOriginalFilenames;
private System.Windows.Forms.TextBox txtSpecialExceptions;
private System.Windows.Forms.CheckBox chkRemoveSpecial;
private System.Windows.Forms.CheckBox chkReplaceSpaces;
private System.Windows.Forms.TextBox txtTrackFilenameFormat;
private System.Windows.Forms.Label lblTrackFilenameFormat;
private System.Windows.Forms.Label lblSingleFilenameFormat;
private System.Windows.Forms.TextBox txtSingleFilenameFormat;
private System.Windows.Forms.CheckBox chkArNoUnverifiedAudio;
private System.Windows.Forms.CheckBox chkArSaveLog;
private System.Windows.Forms.NumericUpDown numWVExtraMode;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.NumericUpDown numEncodeWhenConfidence;
private System.Windows.Forms.NumericUpDown numEncodeWhenPercent;
private System.Windows.Forms.CheckBox chkArFixOffset;
private System.Windows.Forms.Label label4;
}
}

109
CUETools/frmSettings.cs Normal file
View File

@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace JDP {
public partial class frmSettings : Form {
int _writeOffset;
CUEConfig _config;
public frmSettings() {
InitializeComponent();
}
private void frmSettings_Load(object sender, EventArgs e) {
numericWriteOffset.Value = _writeOffset;
chkPreserveHTOA.Checked = _config.preserveHTOA;
chkAutoCorrectFilenames.Checked = _config.autoCorrectFilenames;
numericFLACCompressionLevel.Value = _config.flacCompressionLevel;
numFixWhenConfidence.Value = _config.fixWhenConfidence;
numFixWhenPercent.Value = _config.fixWhenPercent;
numEncodeWhenConfidence.Value = _config.encodeWhenConfidence;
numEncodeWhenPercent.Value = _config.encodeWhenPercent;
chkFLACVerify.Checked = _config.flacVerify;
chkArAddCRCs.Checked = _config.writeCRC;
if (_config.wvCompressionMode == 0) rbWVFast.Checked = true;
if (_config.wvCompressionMode == 1) rbWVNormal.Checked = true;
if (_config.wvCompressionMode == 2) rbWVHigh.Checked = true;
if (_config.wvCompressionMode == 3) rbWVVeryHigh.Checked = true;
chkWVExtraMode.Checked = (_config.wvExtraMode != 0);
chkWVExtraMode_CheckedChanged(null, null);
if (_config.wvExtraMode != 0) numWVExtraMode.Value = _config.wvExtraMode;
chkKeepOriginalFilenames.Checked = _config.keepOriginalFilenames;
txtSingleFilenameFormat.Text = _config.singleFilenameFormat;
txtTrackFilenameFormat.Text = _config.trackFilenameFormat;
chkRemoveSpecial.Checked = _config.removeSpecial;
txtSpecialExceptions.Text = _config.specialExceptions;
chkReplaceSpaces.Checked = _config.replaceSpaces;
chkArSaveLog.Checked = _config.writeArLog;
chkArNoUnverifiedAudio.Checked = _config.noUnverifiedOutput;
chkArFixOffset.Checked = _config.fixOffset;
}
private void frmSettings_FormClosing(object sender, FormClosingEventArgs e) {
}
public int WriteOffset {
get { return _writeOffset; }
set { _writeOffset = value; }
}
public CUEConfig Config {
get { return _config; }
set { _config = value; }
}
private void chkWVExtraMode_CheckedChanged(object sender, EventArgs e) {
if (chkWVExtraMode.Checked) {
numWVExtraMode.Enabled = true;
}
else {
numWVExtraMode.Enabled = false;
}
}
private void btnOK_Click(object sender, EventArgs e)
{
_writeOffset = (int)numericWriteOffset.Value;
_config.preserveHTOA = chkPreserveHTOA.Checked;
_config.autoCorrectFilenames = chkAutoCorrectFilenames.Checked;
_config.flacCompressionLevel = (uint)numericFLACCompressionLevel.Value;
_config.fixWhenPercent = (uint)numFixWhenPercent.Value;
_config.fixWhenConfidence = (uint)numFixWhenConfidence.Value;
_config.encodeWhenPercent = (uint)numEncodeWhenPercent.Value;
_config.encodeWhenConfidence = (uint)numEncodeWhenConfidence.Value;
_config.flacVerify = chkFLACVerify.Checked;
_config.writeCRC = chkArAddCRCs.Checked;
if (rbWVFast.Checked) _config.wvCompressionMode = 0;
else if (rbWVHigh.Checked) _config.wvCompressionMode = 2;
else if (rbWVVeryHigh.Checked) _config.wvCompressionMode = 3;
else _config.wvCompressionMode = 1;
if (!chkWVExtraMode.Checked) _config.wvExtraMode = 0;
else _config.wvExtraMode = (int) numWVExtraMode.Value;
_config.keepOriginalFilenames = chkKeepOriginalFilenames.Checked;
_config.singleFilenameFormat = txtSingleFilenameFormat.Text;
_config.trackFilenameFormat = txtTrackFilenameFormat.Text;
_config.removeSpecial = chkRemoveSpecial.Checked;
_config.specialExceptions = txtSpecialExceptions.Text;
_config.replaceSpaces = chkReplaceSpaces.Checked;
_config.writeArLog = chkArSaveLog.Checked;
_config.noUnverifiedOutput = chkArNoUnverifiedAudio.Checked;
_config.fixOffset = chkArFixOffset.Checked;
}
private void chkArFixOffset_CheckedChanged(object sender, EventArgs e)
{
numFixWhenConfidence.Enabled = chkArFixOffset.Checked;
numFixWhenPercent.Enabled = chkArFixOffset.Checked;
}
private void chkArNoUnverifiedAudio_CheckedChanged(object sender, EventArgs e)
{
numEncodeWhenConfidence.Enabled = chkArNoUnverifiedAudio.Checked;
numEncodeWhenPercent.Enabled = chkArNoUnverifiedAudio.Checked;
}
}
}

129
CUETools/frmSettings.resx Normal file
View File

@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="btnCancel.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -0,0 +1,40 @@
C:\Work\bin\x64\Release\CUETools.exe.config
C:\Work\bin\x64\Release\CUETools.exe
C:\Work\bin\x64\Release\CUETools.pdb
C:\Work\CUETools\obj\x64\Release\ResolveAssemblyReference.cache
C:\Work\CUETools\obj\x64\Release\JDP.frmBatch.resources
C:\Work\CUETools\obj\x64\Release\JDP.frmCUETools.resources
C:\Work\CUETools\obj\x64\Release\JDP.frmFilenameCorrector.resources
C:\Work\CUETools\obj\x64\Release\JDP.frmReport.resources
C:\Work\CUETools\obj\x64\Release\JDP.frmSettings.resources
C:\Work\CUETools\obj\x64\Release\JDP.Properties.Resources.resources
C:\Work\CUETools\obj\x64\Release\CUETools.csproj.GenerateResource.Cache
C:\Work\CUETools\obj\x64\Release\CUETools.exe
C:\Work\CUETools\obj\x64\Release\CUETools.pdb
C:\Work\bin\win32\Release\CUETools.exe.config
C:\Work\CUETools\obj\x86\Release\ResolveAssemblyReference.cache
C:\Work\CUETools\obj\x86\Release\JDP.frmBatch.resources
C:\Work\CUETools\obj\x86\Release\JDP.frmCUETools.resources
C:\Work\CUETools\obj\x86\Release\JDP.frmFilenameCorrector.resources
C:\Work\CUETools\obj\x86\Release\JDP.frmReport.resources
C:\Work\CUETools\obj\x86\Release\JDP.frmSettings.resources
C:\Work\CUETools\obj\x86\Release\JDP.Properties.Resources.resources
C:\Work\CUETools\obj\x86\Release\CUETools.csproj.GenerateResource.Cache
C:\Work\bin\win32\Release\CUETools.exe
C:\Work\bin\win32\Release\CUETools.pdb
C:\Work\CUETools\obj\x86\Release\CUETools.exe
C:\Work\CUETools\obj\x86\Release\CUETools.pdb
C:\Work\bin\win32\Debug\CUETools.exe.config
C:\Work\bin\x64\Debug\CUETools.exe.config
C:\Work\CUETools\obj\x86\Debug\ResolveAssemblyReference.cache
C:\Work\CUETools\obj\x86\Debug\JDP.frmBatch.resources
C:\Work\CUETools\obj\x86\Debug\JDP.frmCUETools.resources
C:\Work\CUETools\obj\x86\Debug\JDP.frmFilenameCorrector.resources
C:\Work\CUETools\obj\x86\Debug\JDP.frmReport.resources
C:\Work\CUETools\obj\x86\Debug\JDP.frmSettings.resources
C:\Work\CUETools\obj\x86\Debug\JDP.Properties.Resources.resources
C:\Work\CUETools\obj\x86\Debug\CUETools.csproj.GenerateResource.Cache
C:\Work\bin\win32\Debug\CUETools.exe
C:\Work\bin\win32\Debug\CUETools.pdb
C:\Work\CUETools\obj\x86\Debug\CUETools.exe
C:\Work\CUETools\obj\x86\Debug\CUETools.pdb

View File

View File

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

79
CUETools/tmp.cs Normal file
View File

@@ -0,0 +1,79 @@
uint bestTracksMatch = 0;
int bestWorstConfidence = 0;
int bestOffset = 0;
int bestDisk = -1;
for (int di = 0; di < (int)accDisks.Count; di++)
{
for (int offset = -_arOffsetRange; offset <= _arOffsetRange; offset++)
{
uint tracksMatch = 0;
int worstConfidence = -1;
for (int iTrack = 0; iTrack < TrackCount; iTrack++)
if (_tracks[iTrack].OffsetedCRC[_arOffsetRange - offset] == accDisks[di].tracks[iTrack].CRC)
{
tracksMatch++;
//confidence += accDisks[di].tracks[iTrack].count;
if (accDisks[di].tracks[iTrack].CRC != 0)
if (worstConfidence == -1 || worstConfidence > accDisks[di].tracks[iTrack].count)
worstConfidence = (int) accDisks[di].tracks[iTrack].count;
//if (_config.fixWhenConfidence)
//tracksMatchWithConfidence++;
}
if (tracksMatch > bestTracksMatch
|| (tracksMatch == bestTracksMatch && worstConfidence > bestWorstConfidence)
|| (tracksMatch == bestTracksMatch && worstConfidence == bestWorstConfidence && Math.Abs(offset) < Math.Abs(bestOffset))
)
{
bestTracksMatch = tracksMatch;
bestWorstConfidence = worstConfidence;
bestOffset = offset;
bestDisk = di;
}
}
}
if (bestWorstConfidence > _config.fixWhenConfidence &&
(bestTracksMatch == TrackCount ||
(TrackCount > 2 && bestTracksMatch * 100 > TrackCount * _config.fixWhenPercent)))
_writeOffset = bestOffset;
else
if (bestTracksMatch != TrackCount && _config.noUnverifiedOutput)
SkipOutput = true;
int s1 = (int) Math.Min(count, Math.Max(0, 450 * 588 - _arOffsetRange - (int)currentOffset));
int s2 = (int) Math.Min(count, Math.Max(0, 451 * 588 + _arOffsetRange - (int)currentOffset));
if ( s1 < s2 )
fixed (uint* FrameCRCs = _tracks[iTrack].OffsetedFrame450CRC)
for (int sj = s1; sj < s2; sj++)
{
int magicFrameOffsetBase = (int)currentOffset + sj - 450 * 588 + 1;
for (int oi = -_arOffsetRange; oi <= _arOffsetRange; oi++)
{
int magicFrameOffset = magicFrameOffsetBase + oi;
if (magicFrameOffset > 0 && magicFrameOffset <= 588)
FrameCRCs[_arOffsetRange - oi] += (uint)(samples[sj] * magicFrameOffset);
}
}
int magicFrameOffset = (int)currentOffset + sj - 450 * 588 + 1;
int firstOffset = Math.Max(-_arOffsetRange, 1 - magicFrameOffset);
int lastOffset = Math.Min(_arOffsetRange, 588 - magicFrameOffset);
for (int oi = firstOffset; oi <= lastOffset; oi++)
FrameCRCs[_arOffsetRange - oi] += (uint)(samples[sj] * (magicFrameOffset + oi));

View File

@@ -0,0 +1,39 @@
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// 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:AssemblyTitleAttribute("FLACDotNet")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("")];
[assembly:AssemblyProductAttribute("")];
[assembly:AssemblyCopyrightAttribute("Copyright 2006-2007 Moitah")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.5.0.0")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];

36
FLACDotNet/FLACDotNet.sln Normal file
View File

@@ -0,0 +1,36 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLACDotNet", "FLACDotNet.vcproj", "{E70FA90A-7012-4A52-86B5-362B699D1540}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APEDotNet", "..\APEDotNet\APEDotNet.vcproj", "{9AE965C4-301E-4C01-B90F-297AF341ACC6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Win32.ActiveCfg = Debug|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|Win32.Build.0 = Debug|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|x64.ActiveCfg = Debug|x64
{E70FA90A-7012-4A52-86B5-362B699D1540}.Debug|x64.Build.0 = Debug|x64
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|Win32.ActiveCfg = Release|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|Win32.Build.0 = Release|Win32
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|x64.ActiveCfg = Release|x64
{E70FA90A-7012-4A52-86B5-362B699D1540}.Release|x64.Build.0 = Release|x64
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|Win32.ActiveCfg = Debug|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|Win32.Build.0 = Debug|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|x64.ActiveCfg = Debug|x64
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Debug|x64.Build.0 = Debug|x64
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|Win32.ActiveCfg = Release|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|Win32.Build.0 = Release|Win32
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|x64.ActiveCfg = Release|x64
{9AE965C4-301E-4C01-B90F-297AF341ACC6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,414 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="FLACDotNet"
ProjectGUID="{E70FA90A-7012-4A52-86B5-362B699D1540}"
RootNamespace="FLACDotNet"
Keyword="ManagedCProj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../flac/include"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
AssemblyDebug="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../flac/include"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
AssemblyDebug="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../flac/include"
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../flac/include"
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
<AssemblyReference
RelativePath="System.dll"
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
/>
<AssemblyReference
RelativePath="System.Data.dll"
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
/>
<AssemblyReference
RelativePath="System.XML.dll"
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
/>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\AssemblyInfo.cpp"
>
</File>
<File
RelativePath=".\FLACDotNet.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\resource.h"
>
</File>
<Filter
Name="FLAC"
>
<File
RelativePath=".\FLAC\all.h"
>
</File>
<File
RelativePath=".\FLAC\assert.h"
>
</File>
<File
RelativePath=".\FLAC\callback.h"
>
</File>
<File
RelativePath=".\FLAC\export.h"
>
</File>
<File
RelativePath=".\FLAC\format.h"
>
</File>
<File
RelativePath=".\FLAC\metadata.h"
>
</File>
<File
RelativePath=".\FLAC\ordinals.h"
>
</File>
<File
RelativePath=".\FLAC\stream_decoder.h"
>
</File>
<File
RelativePath=".\FLAC\stream_encoder.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\app.ico"
>
</File>
<File
RelativePath=".\app.rc"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

BIN
FLACDotNet/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

63
FLACDotNet/app.rc Normal file
View File

@@ -0,0 +1,63 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon placed first or with lowest ID value becomes application icon
LANGUAGE 9, 1
#pragma code_page(1252)
1 ICON "app.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
"\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

610
FLACDotNet/cuesheet.c Normal file
View File

@@ -0,0 +1,610 @@
/* grabbag - Convenience lib for various routines common to several tools
* Copyright (C) 2002,2003,2004,2005,2006,2007 Josh Coalson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include "FLAC/assert.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
unsigned grabbag__cuesheet_msf_to_frame(unsigned minutes, unsigned seconds, unsigned frames)
{
return ((minutes * 60) + seconds) * 75 + frames;
}
void grabbag__cuesheet_frame_to_msf(unsigned frame, unsigned *minutes, unsigned *seconds, unsigned *frames)
{
*frames = frame % 75;
frame /= 75;
*seconds = frame % 60;
frame /= 60;
*minutes = frame;
}
/* since we only care about values >= 0 or error, returns < 0 for any illegal string, else value */
static int local__parse_int_(const char *s)
{
int ret = 0;
char c;
if(*s == '\0')
return -1;
while('\0' != (c = *s++))
if(c >= '0' && c <= '9')
ret = ret * 10 + (c - '0');
else
return -1;
return ret;
}
/* since we only care about values >= 0 or error, returns < 0 for any illegal string, else value */
static FLAC__int64 local__parse_int64_(const char *s)
{
FLAC__int64 ret = 0;
char c;
if(*s == '\0')
return -1;
while('\0' != (c = *s++))
if(c >= '0' && c <= '9')
ret = ret * 10 + (c - '0');
else
return -1;
return ret;
}
/* accept '[0-9]+:[0-9][0-9]?:[0-9][0-9]?', but max second of 59 and max frame of 74, e.g. 0:0:0, 123:45:67
* return sample number or <0 for error
*/
static FLAC__int64 local__parse_msf_(const char *s)
{
FLAC__int64 ret, field;
char c;
c = *s++;
if(c >= '0' && c <= '9')
field = (c - '0');
else
return -1;
while(':' != (c = *s++)) {
if(c >= '0' && c <= '9')
field = field * 10 + (c - '0');
else
return -1;
}
ret = field * 60 * 44100;
c = *s++;
if(c >= '0' && c <= '9')
field = (c - '0');
else
return -1;
if(':' != (c = *s++)) {
if(c >= '0' && c <= '9') {
field = field * 10 + (c - '0');
c = *s++;
if(c != ':')
return -1;
}
else
return -1;
}
if(field >= 60)
return -1;
ret += field * 44100;
c = *s++;
if(c >= '0' && c <= '9')
field = (c - '0');
else
return -1;
if('\0' != (c = *s++)) {
if(c >= '0' && c <= '9') {
field = field * 10 + (c - '0');
c = *s++;
}
else
return -1;
}
if(c != '\0')
return -1;
if(field >= 75)
return -1;
ret += field * (44100 / 75);
return ret;
}
static char *local__get_field_(char **s, FLAC__bool allow_quotes)
{
FLAC__bool has_quote = false;
char *p;
FLAC__ASSERT(0 != s);
if(0 == *s)
return 0;
/* skip leading whitespace */
while(**s && 0 != strchr(" \t\r\n", **s))
(*s)++;
if(**s == 0) {
*s = 0;
return 0;
}
if(allow_quotes && (**s == '"')) {
has_quote = true;
(*s)++;
if(**s == 0) {
*s = 0;
return 0;
}
}
p = *s;
if(has_quote) {
*s = strchr(*s, '\"');
/* if there is no matching end quote, it's an error */
if(0 == *s)
p = *s = 0;
else {
**s = '\0';
(*s)++;
}
}
else {
while(**s && 0 == strchr(" \t\r\n", **s))
(*s)++;
if(**s) {
**s = '\0';
(*s)++;
}
else
*s = 0;
}
return p;
}
static FLAC__bool local__cuesheet_parse_(FILE *file, const char **error_message, unsigned *last_line_read, FLAC__StreamMetadata *cuesheet, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset)
{
#if defined _MSC_VER || defined __MINGW32__ || defined __EMX__
#define FLAC__STRCASECMP stricmp
#else
#define FLAC__STRCASECMP strcasecmp
#endif
char buffer[4096], *line, *field;
unsigned forced_leadout_track_num = 0;
FLAC__uint64 forced_leadout_track_offset = 0;
int in_track_num = -1, in_index_num = -1;
FLAC__bool disc_has_catalog = false, track_has_flags = false, track_has_isrc = false, has_forced_leadout = false;
FLAC__StreamMetadata_CueSheet *cs = &cuesheet->data.cue_sheet;
cs->lead_in = is_cdda? 2 * 44100 /* The default lead-in size for CD-DA */ : 0;
cs->is_cd = is_cdda;
while(0 != fgets(buffer, sizeof(buffer), file)) {
(*last_line_read)++;
line = buffer;
{
size_t linelen = strlen(line);
if((linelen == sizeof(buffer)-1) && line[linelen-1] != '\n') {
*error_message = "line too long";
return false;
}
}
if(0 != (field = local__get_field_(&line, /*allow_quotes=*/false))) {
if(0 == FLAC__STRCASECMP(field, "CATALOG")) {
if(disc_has_catalog) {
*error_message = "found multiple CATALOG commands";
return false;
}
if(0 == (field = local__get_field_(&line, /*allow_quotes=*/true))) {
*error_message = "CATALOG is missing catalog number";
return false;
}
if(strlen(field) >= sizeof(cs->media_catalog_number)) {
*error_message = "CATALOG number is too long";
return false;
}
if(is_cdda && (strlen(field) != 13 || strspn(field, "0123456789") != 13)) {
*error_message = "CD-DA CATALOG number must be 13 decimal digits";
return false;
}
strcpy(cs->media_catalog_number, field);
disc_has_catalog = true;
}
else if(0 == FLAC__STRCASECMP(field, "FLAGS")) {
if(track_has_flags) {
*error_message = "found multiple FLAGS commands";
return false;
}
if(in_track_num < 0 || in_index_num >= 0) {
*error_message = "FLAGS command must come after TRACK but before INDEX";
return false;
}
while(0 != (field = local__get_field_(&line, /*allow_quotes=*/false))) {
if(0 == FLAC__STRCASECMP(field, "PRE"))
cs->tracks[cs->num_tracks-1].pre_emphasis = 1;
}
track_has_flags = true;
}
else if(0 == FLAC__STRCASECMP(field, "INDEX")) {
FLAC__int64 xx;
FLAC__StreamMetadata_CueSheet_Track *track = &cs->tracks[cs->num_tracks-1];
if(in_track_num < 0) {
*error_message = "found INDEX before any TRACK";
return false;
}
if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) {
*error_message = "INDEX is missing index number";
return false;
}
in_index_num = local__parse_int_(field);
if(in_index_num < 0) {
*error_message = "INDEX has invalid index number";
return false;
}
FLAC__ASSERT(cs->num_tracks > 0);
if(track->num_indices == 0) {
/* it's the first index point of the track */
if(in_index_num > 1) {
*error_message = "first INDEX number of a TRACK must be 0 or 1";
return false;
}
}
else {
if(in_index_num != track->indices[track->num_indices-1].number + 1) {
*error_message = "INDEX numbers must be sequential";
return false;
}
}
if(is_cdda && in_index_num > 99) {
*error_message = "CD-DA INDEX number must be between 0 and 99, inclusive";
return false;
}
/*@@@ search for duplicate track number? */
if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) {
*error_message = "INDEX is missing an offset after the index number";
return false;
}
xx = local__parse_msf_(field);
if(xx < 0) {
if(is_cdda) {
*error_message = "illegal INDEX offset (not of the form MM:SS:FF)";
return false;
}
xx = local__parse_int64_(field);
if(xx < 0) {
*error_message = "illegal INDEX offset";
return false;
}
}
if(is_cdda && cs->num_tracks == 1 && cs->tracks[0].num_indices == 0 && xx != 0) {
*error_message = "first INDEX of first TRACK must have an offset of 00:00:00";
return false;
}
if(is_cdda && track->num_indices > 0 && (FLAC__uint64)xx <= track->indices[track->num_indices-1].offset) {
*error_message = "CD-DA INDEX offsets must increase in time";
return false;
}
/* fill in track offset if it's the first index of the track */
if(track->num_indices == 0)
track->offset = (FLAC__uint64)xx;
if(is_cdda && cs->num_tracks > 1) {
const FLAC__StreamMetadata_CueSheet_Track *prev = &cs->tracks[cs->num_tracks-2];
if((FLAC__uint64)xx <= prev->offset + prev->indices[prev->num_indices-1].offset) {
*error_message = "CD-DA INDEX offsets must increase in time";
return false;
}
}
if(!FLAC__metadata_object_cuesheet_track_insert_blank_index(cuesheet, cs->num_tracks-1, track->num_indices)) {
*error_message = "memory allocation error";
return false;
}
track->indices[track->num_indices-1].offset = (FLAC__uint64)xx - track->offset;
track->indices[track->num_indices-1].number = in_index_num;
}
else if(0 == FLAC__STRCASECMP(field, "ISRC")) {
char *l, *r;
if(track_has_isrc) {
*error_message = "found multiple ISRC commands";
return false;
}
if(in_track_num < 0 || in_index_num >= 0) {
*error_message = "ISRC command must come after TRACK but before INDEX";
return false;
}
if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) {
*error_message = "ISRC is missing ISRC number";
return false;
}
/* strip out dashes */
for(l = r = field; *r; r++) {
if(*r != '-')
*l++ = *r;
}
*l = '\0';
if(strlen(field) != 12 || strspn(field, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") < 5 || strspn(field+5, "1234567890") != 7) {
*error_message = "invalid ISRC number";
return false;
}
strcpy(cs->tracks[cs->num_tracks-1].isrc, field);
track_has_isrc = true;
}
else if(0 == FLAC__STRCASECMP(field, "TRACK")) {
if(cs->num_tracks > 0) {
const FLAC__StreamMetadata_CueSheet_Track *prev = &cs->tracks[cs->num_tracks-1];
if(
prev->num_indices == 0 ||
(
is_cdda &&
(
(prev->num_indices == 1 && prev->indices[0].number != 1) ||
(prev->num_indices == 2 && prev->indices[0].number != 1 && prev->indices[1].number != 1)
)
)
) {
*error_message = is_cdda?
"previous TRACK must specify at least one INDEX 01" :
"previous TRACK must specify at least one INDEX";
return false;
}
}
if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) {
*error_message = "TRACK is missing track number";
return false;
}
in_track_num = local__parse_int_(field);
if(in_track_num < 0) {
*error_message = "TRACK has invalid track number";
return false;
}
if(in_track_num == 0) {
*error_message = "TRACK number must be greater than 0";
return false;
}
if(is_cdda) {
if(in_track_num > 99) {
*error_message = "CD-DA TRACK number must be between 1 and 99, inclusive";
return false;
}
}
else {
if(in_track_num == 255) {
*error_message = "TRACK number 255 is reserved for the lead-out";
return false;
}
else if(in_track_num > 255) {
*error_message = "TRACK number must be between 1 and 254, inclusive";
return false;
}
}
if(is_cdda && cs->num_tracks > 0 && in_track_num != cs->tracks[cs->num_tracks-1].number + 1) {
*error_message = "CD-DA TRACK numbers must be sequential";
return false;
}
/*@@@ search for duplicate track number? */
if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) {
*error_message = "TRACK is missing a track type after the track number";
return false;
}
if(!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, cs->num_tracks)) {
*error_message = "memory allocation error";
return false;
}
cs->tracks[cs->num_tracks-1].number = in_track_num;
cs->tracks[cs->num_tracks-1].type = (0 == FLAC__STRCASECMP(field, "AUDIO"))? 0 : 1; /*@@@ should we be more strict with the value here? */
in_index_num = -1;
track_has_flags = false;
track_has_isrc = false;
}
else if(0 == FLAC__STRCASECMP(field, "REM")) {
if(0 != (field = local__get_field_(&line, /*allow_quotes=*/false))) {
if(0 == strcmp(field, "FLAC__lead-in")) {
FLAC__int64 xx;
if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) {
*error_message = "FLAC__lead-in is missing offset";
return false;
}
xx = local__parse_int64_(field);
if(xx < 0) {
*error_message = "illegal FLAC__lead-in offset";
return false;
}
if(is_cdda && xx % 588 != 0) {
*error_message = "illegal CD-DA FLAC__lead-in offset, must be even multiple of 588 samples";
return false;
}
cs->lead_in = (FLAC__uint64)xx;
}
else if(0 == strcmp(field, "FLAC__lead-out")) {
int track_num;
FLAC__int64 offset;
if(has_forced_leadout) {
*error_message = "multiple FLAC__lead-out commands";
return false;
}
if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) {
*error_message = "FLAC__lead-out is missing track number";
return false;
}
track_num = local__parse_int_(field);
if(track_num < 0) {
*error_message = "illegal FLAC__lead-out track number";
return false;
}
forced_leadout_track_num = (unsigned)track_num;
/*@@@ search for duplicate track number? */
if(0 == (field = local__get_field_(&line, /*allow_quotes=*/false))) {
*error_message = "FLAC__lead-out is missing offset";
return false;
}
offset = local__parse_int64_(field);
if(offset < 0) {
*error_message = "illegal FLAC__lead-out offset";
return false;
}
forced_leadout_track_offset = (FLAC__uint64)offset;
if(forced_leadout_track_offset != lead_out_offset) {
*error_message = "FLAC__lead-out offset does not match end-of-stream offset";
return false;
}
has_forced_leadout = true;
}
}
}
}
}
if(cs->num_tracks == 0) {
*error_message = "there must be at least one TRACK command";
return false;
}
else {
const FLAC__StreamMetadata_CueSheet_Track *prev = &cs->tracks[cs->num_tracks-1];
if(
prev->num_indices == 0 ||
(
is_cdda &&
(
(prev->num_indices == 1 && prev->indices[0].number != 1) ||
(prev->num_indices == 2 && prev->indices[0].number != 1 && prev->indices[1].number != 1)
)
)
) {
*error_message = is_cdda?
"previous TRACK must specify at least one INDEX 01" :
"previous TRACK must specify at least one INDEX";
return false;
}
}
if(!has_forced_leadout) {
forced_leadout_track_num = is_cdda? 170 : 255;
forced_leadout_track_offset = lead_out_offset;
}
if(!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, cs->num_tracks)) {
*error_message = "memory allocation error";
return false;
}
cs->tracks[cs->num_tracks-1].number = forced_leadout_track_num;
cs->tracks[cs->num_tracks-1].offset = forced_leadout_track_offset;
if(!feof(file)) {
*error_message = "read error";
return false;
}
return true;
#undef FLAC__STRCASECMP
}
FLAC__StreamMetadata *grabbag__cuesheet_parse(FILE *file, const char **error_message, unsigned *last_line_read, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset)
{
FLAC__StreamMetadata *cuesheet;
FLAC__ASSERT(0 != file);
FLAC__ASSERT(0 != error_message);
FLAC__ASSERT(0 != last_line_read);
*last_line_read = 0;
cuesheet = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET);
if(0 == cuesheet) {
*error_message = "memory allocation error";
return 0;
}
if(!local__cuesheet_parse_(file, error_message, last_line_read, cuesheet, is_cdda, lead_out_offset)) {
FLAC__metadata_object_delete(cuesheet);
return 0;
}
return cuesheet;
}
void grabbag__cuesheet_emit(FILE *file, const FLAC__StreamMetadata *cuesheet, const char *file_reference)
{
const FLAC__StreamMetadata_CueSheet *cs;
unsigned track_num, index_num;
FLAC__ASSERT(0 != file);
FLAC__ASSERT(0 != cuesheet);
FLAC__ASSERT(cuesheet->type == FLAC__METADATA_TYPE_CUESHEET);
cs = &cuesheet->data.cue_sheet;
if(*(cs->media_catalog_number))
fprintf(file, "CATALOG %s\n", cs->media_catalog_number);
fprintf(file, "FILE %s\n", file_reference);
for(track_num = 0; track_num < cs->num_tracks-1; track_num++) {
const FLAC__StreamMetadata_CueSheet_Track *track = cs->tracks + track_num;
fprintf(file, " TRACK %02u %s\n", (unsigned)track->number, track->type == 0? "AUDIO" : "DATA");
if(track->pre_emphasis)
fprintf(file, " FLAGS PRE\n");
if(*(track->isrc))
fprintf(file, " ISRC %s\n", track->isrc);
for(index_num = 0; index_num < track->num_indices; index_num++) {
const FLAC__StreamMetadata_CueSheet_Index *index = track->indices + index_num;
fprintf(file, " INDEX %02u ", (unsigned)index->number);
if(cs->is_cd) {
const unsigned logical_frame = (unsigned)((track->offset + index->offset) / (44100 / 75));
unsigned m, s, f;
grabbag__cuesheet_frame_to_msf(logical_frame, &m, &s, &f);
fprintf(file, "%02u:%02u:%02u\n", m, s, f);
}
else
#ifdef _MSC_VER
fprintf(file, "%I64u\n", track->offset + index->offset);
#else
fprintf(file, "%llu\n", (unsigned long long)(track->offset + index->offset));
#endif
}
}
#ifdef _MSC_VER
fprintf(file, "REM FLAC__lead-in %I64u\n", cs->lead_in);
fprintf(file, "REM FLAC__lead-out %u %I64u\n", (unsigned)cs->tracks[track_num].number, cs->tracks[track_num].offset);
#else
fprintf(file, "REM FLAC__lead-in %llu\n", (unsigned long long)cs->lead_in);
fprintf(file, "REM FLAC__lead-out %u %llu\n", (unsigned)cs->tracks[track_num].number, (unsigned long long)cs->tracks[track_num].offset);
#endif
}

547
FLACDotNet/flacdotnet.cpp Normal file
View File

@@ -0,0 +1,547 @@
// ****************************************************************************
//
// Copyright (c) 2006-2007 Moitah (moitah@yahoo.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the author nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using namespace System;
using namespace System::Text;
using namespace System::Collections::Generic;
using namespace System::Collections::Specialized;
using namespace System::Runtime::InteropServices;
#include "FLAC\all.h"
#include <string>
struct FLAC__Metadata_Iterator
{
int dummy;
};
struct FLAC__Metadata_Chain
{
int dummy;
};
namespace FLACDotNet {
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
public delegate FLAC__StreamDecoderWriteStatus DecoderWriteDelegate(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
public delegate void DecoderMetadataDelegate(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
public delegate void DecoderErrorDelegate(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
public ref class FLACReader {
public:
FLACReader(String^ path) {
IntPtr pathChars;
FILE *hFile;
_tags = gcnew NameValueCollection();
_writeDel = gcnew DecoderWriteDelegate(this, &FLACReader::WriteCallback);
_metadataDel = gcnew DecoderMetadataDelegate(this, &FLACReader::MetadataCallback);
_errorDel = gcnew DecoderErrorDelegate(this, &FLACReader::ErrorCallback);
_decoderActive = false;
_sampleOffset = 0;
_samplesWaiting = false;
_sampleBuffer = nullptr;
_path = path;
pathChars = Marshal::StringToHGlobalUni(_path);
hFile = _wfopen ((const wchar_t*)pathChars.ToPointer(), L"rb");
Marshal::FreeHGlobal(pathChars);
if (!hFile) {
throw gcnew Exception("Unable to open file.");
}
_decoder = FLAC__stream_decoder_new();
if (!FLAC__stream_decoder_set_metadata_respond (_decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT))
throw gcnew Exception("Unable to setup the decoder.");
if (FLAC__stream_decoder_init_FILE(_decoder, hFile,
(FLAC__StreamDecoderWriteCallback)Marshal::GetFunctionPointerForDelegate(_writeDel).ToPointer(),
(FLAC__StreamDecoderMetadataCallback)Marshal::GetFunctionPointerForDelegate(_metadataDel).ToPointer(),
(FLAC__StreamDecoderErrorCallback)Marshal::GetFunctionPointerForDelegate(_errorDel).ToPointer(),
NULL) != FLAC__STREAM_DECODER_INIT_STATUS_OK)
{
throw gcnew Exception("Unable to initialize the decoder.");
}
_decoderActive = true;
if (!FLAC__stream_decoder_process_until_end_of_metadata(_decoder)) {
throw gcnew Exception("Unable to retrieve metadata.");
}
}
~FLACReader ()
{
Close ();
}
property Int32 BitsPerSample {
Int32 get() {
return _bitsPerSample;
}
}
property Int32 ChannelCount {
Int32 get() {
return _channelCount;
}
}
property Int32 SampleRate {
Int32 get() {
return _sampleRate;
}
}
property Int64 Length {
Int64 get() {
return _sampleCount;
}
}
property Int64 Position {
Int64 get() {
return _sampleOffset;
}
void set(Int64 offset) {
_sampleOffset = offset;
_samplesWaiting = false;
if (!FLAC__stream_decoder_seek_absolute(_decoder, offset)) {
throw gcnew Exception("Unable to seek.");
}
}
}
property NameValueCollection^ Tags {
NameValueCollection^ get () {
return _tags;
}
void set (NameValueCollection ^tags) {
_tags = tags;
}
}
bool UpdateTags ()
{
Close ();
FLAC__Metadata_Chain* chain = FLAC__metadata_chain_new ();
if (!chain) return false;
IntPtr pathChars = Marshal::StringToHGlobalAnsi(_path);
int res = FLAC__metadata_chain_read (chain, (const char*)pathChars.ToPointer());
Marshal::FreeHGlobal(pathChars);
if (!res) {
FLAC__metadata_chain_delete (chain);
return false;
}
FLAC__Metadata_Iterator* i = FLAC__metadata_iterator_new ();
FLAC__metadata_iterator_init (i, chain);
do {
FLAC__StreamMetadata* metadata = FLAC__metadata_iterator_get_block (i);
if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
FLAC__metadata_iterator_delete_block (i, false);
} while (FLAC__metadata_iterator_next (i));
FLAC__StreamMetadata * vorbiscomment = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
for (int tagno = 0; tagno <_tags->Count; tagno++)
{
String ^ tag_name = _tags->GetKey(tagno);
int tag_len = tag_name->Length;
char * tag = new char [tag_len + 1];
IntPtr nameChars = Marshal::StringToHGlobalAnsi(tag_name);
memcpy (tag, (const char*)nameChars.ToPointer(), tag_len);
Marshal::FreeHGlobal(nameChars);
tag[tag_len] = 0;
array<String^>^ tag_values = _tags->GetValues(tagno);
for (int valno = 0; valno < tag_values->Length; valno++)
{
UTF8Encoding^ enc = gcnew UTF8Encoding();
array<Byte>^ value_array = enc->GetBytes (tag_values[valno]);
int value_len = value_array->Length;
char * value = new char [value_len + 1];
Marshal::Copy (value_array, 0, (IntPtr) value, value_len);
value[value_len] = 0;
FLAC__StreamMetadata_VorbisComment_Entry entry;
/* create and entry and append it */
if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, tag, value)) {
throw gcnew Exception("Unable to add tags, must be valid utf8.");
}
if(!FLAC__metadata_object_vorbiscomment_append_comment(vorbiscomment, entry, /*copy=*/false)) {
throw gcnew Exception("Unable to add tags.");
}
delete [] value;
}
delete [] tag;
}
FLAC__metadata_iterator_insert_block_after (i, vorbiscomment);
FLAC__metadata_iterator_delete (i);
FLAC__metadata_chain_sort_padding (chain);
res = FLAC__metadata_chain_write (chain, true, false);
FLAC__metadata_chain_delete (chain);
return 0 != res;
}
property Int64 Remaining {
Int64 get() {
return _sampleCount - _sampleOffset;
}
}
void Close() {
if (!_decoderActive) return;
FLAC__stream_decoder_finish(_decoder);
FLAC__stream_decoder_delete(_decoder);
_decoderActive = false;
}
Int32 Read([Out] array<Int32, 2>^% sampleBuffer) {
int sampleCount;
while (!_samplesWaiting) {
if (!FLAC__stream_decoder_process_single(_decoder)) {
throw gcnew Exception("An error occurred while decoding.");
}
}
sampleCount = _sampleBuffer->GetLength(0);
sampleBuffer = _sampleBuffer;
_sampleOffset += sampleCount;
_samplesWaiting = false;
return sampleCount;
}
private:
DecoderWriteDelegate^ _writeDel;
DecoderMetadataDelegate^ _metadataDel;
DecoderErrorDelegate^ _errorDel;
FLAC__StreamDecoder *_decoder;
Int64 _sampleCount, _sampleOffset;
Int32 _bitsPerSample, _channelCount, _sampleRate;
array<Int32, 2>^ _sampleBuffer;
bool _samplesWaiting;
NameValueCollection^ _tags;
String^ _path;
bool _decoderActive;
FLAC__StreamDecoderWriteStatus WriteCallback(const FLAC__StreamDecoder *decoder,
const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
{
Int32 sampleCount = frame->header.blocksize;
if (_samplesWaiting) {
throw gcnew Exception("Received unrequested samples.");
}
if ((frame->header.bits_per_sample != _bitsPerSample) ||
(frame->header.channels != _channelCount) ||
(frame->header.sample_rate != _sampleRate))
{
throw gcnew Exception("Format changes within a file are not allowed.");
}
if ((_sampleBuffer == nullptr) || (_sampleBuffer->GetLength(0) != sampleCount)) {
_sampleBuffer = gcnew array<Int32, 2>(sampleCount, _channelCount);
}
for (Int32 iChan = 0; iChan < _channelCount; iChan++) {
interior_ptr<Int32> pMyBuffer = &_sampleBuffer[0, iChan];
const FLAC__int32 *pFLACBuffer = buffer[iChan];
const FLAC__int32 *pFLACBufferEnd = pFLACBuffer + sampleCount;
while (pFLACBuffer < pFLACBufferEnd) {
*pMyBuffer = *pFLACBuffer;
pMyBuffer += _channelCount;
pFLACBuffer++;
}
}
_samplesWaiting = true;
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
void MetadataCallback(const FLAC__StreamDecoder *decoder,
const FLAC__StreamMetadata *metadata, void *client_data)
{
if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO)
{
_bitsPerSample = metadata->data.stream_info.bits_per_sample;
_channelCount = metadata->data.stream_info.channels;
_sampleRate = metadata->data.stream_info.sample_rate;
_sampleCount = metadata->data.stream_info.total_samples;
}
if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
{
for (unsigned tagno = 0; tagno < metadata->data.vorbis_comment.num_comments; tagno ++)
{
char * field_name, * field_value;
if(!FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(metadata->data.vorbis_comment.comments[tagno], &field_name, &field_value))
throw gcnew Exception("Unable to parse vorbis comment.");
String^ name = Marshal::PtrToStringAnsi ((IntPtr) field_name);
free (field_name);
array<Byte>^ bvalue = gcnew array<Byte>((int) strlen (field_value));
Marshal::Copy ((IntPtr) field_value, bvalue, 0, (int) strlen (field_value));
free (field_value);
UTF8Encoding^ enc = gcnew UTF8Encoding();
String ^value = enc->GetString (bvalue);
_tags->Add (name, value);
}
}
}
void ErrorCallback(const FLAC__StreamDecoder *decoder,
FLAC__StreamDecoderErrorStatus status, void *client_data)
{
switch (status) {
case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
throw gcnew Exception("Synchronization was lost.");
case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER:
throw gcnew Exception("Encountered a corrupted frame header.");
case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH:
throw gcnew Exception("Frame CRC mismatch.");
default:
throw gcnew Exception("An unknown error has occurred.");
}
}
};
public ref class FLACWriter {
public:
FLACWriter(String^ path, Int32 bitsPerSample, Int32 channelCount, Int32 sampleRate) {
_initialized = false;
_path = path;
_finalSampleCount = 0;
_samplesWritten = 0;
_bitsPerSample = bitsPerSample;
_channelCount = channelCount;
_sampleRate = sampleRate;
_compressionLevel = 5;
_paddingLength = 8192;
_verify = false;
_tags = gcnew NameValueCollection();
_encoder = FLAC__stream_encoder_new();
FLAC__stream_encoder_set_bits_per_sample(_encoder, bitsPerSample);
FLAC__stream_encoder_set_channels(_encoder, channelCount);
FLAC__stream_encoder_set_sample_rate(_encoder, sampleRate);
}
void Close() {
FLAC__stream_encoder_finish(_encoder);
for (int i = 0; i < _metadataCount; i++) {
FLAC__metadata_object_delete(_metadataList[i]);
}
delete[] _metadataList;
_metadataList = 0;
_metadataCount = 0;
FLAC__stream_encoder_delete(_encoder);
if ((_finalSampleCount != 0) && (_samplesWritten != _finalSampleCount)) {
throw gcnew Exception("Samples written differs from the expected sample count.");
}
_tags->Clear ();
}
property Int64 FinalSampleCount {
Int64 get() {
return _finalSampleCount;
}
void set(Int64 value) {
if (value < 0) {
throw gcnew Exception("Invalid final sample count.");
}
if (_initialized) {
throw gcnew Exception("Final sample count cannot be changed after encoding begins.");
}
_finalSampleCount = value;
}
}
property Int32 CompressionLevel {
Int32 get() {
return _compressionLevel;
}
void set(Int32 value) {
if ((value < 0) || (value > 8)) {
throw gcnew Exception("Invalid compression level.");
}
_compressionLevel = value;
}
}
property Boolean Verify {
Boolean get() {
return _verify;
}
void set(Boolean value) {
_verify = value;
}
}
property Int32 PaddingLength {
Int32 get() {
return _paddingLength;
}
void set(Int32 value) {
if (value < 0) {
throw gcnew Exception("Invalid padding length.");
}
_paddingLength = value;
}
}
void SetTags (NameValueCollection^ tags) {
_tags = tags;
}
void Write(array<Int32, 2>^ sampleBuffer, Int32 sampleCount) {
if (!_initialized) Initialize();
pin_ptr<Int32> pSampleBuffer = &sampleBuffer[0, 0];
if (!FLAC__stream_encoder_process_interleaved(_encoder,
(const FLAC__int32*)pSampleBuffer, sampleCount))
{
throw gcnew Exception("An error occurred while encoding.");
}
_samplesWritten += sampleCount;
}
private:
FLAC__StreamEncoder *_encoder;
bool _initialized;
String^ _path;
Int64 _finalSampleCount, _samplesWritten;
Int32 _bitsPerSample, _channelCount, _sampleRate;
Int32 _compressionLevel;
Int32 _paddingLength;
Boolean _verify;
FLAC__StreamMetadata **_metadataList;
int _metadataCount;
NameValueCollection^ _tags;
void Initialize() {
FLAC__StreamMetadata *padding, *seektable, *vorbiscomment;
IntPtr pathChars;
FILE *hFile;
_metadataList = new FLAC__StreamMetadata*[8];
_metadataCount = 0;
if (_finalSampleCount != 0) {
seektable = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE);
FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(
seektable, _sampleRate * 10, _finalSampleCount);
FLAC__metadata_object_seektable_template_sort(seektable, true);
_metadataList[_metadataCount++] = seektable;
}
vorbiscomment = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
for (int tagno = 0; tagno < _tags->Count; tagno++)
{
String ^ tag_name = _tags->GetKey(tagno);
int tag_len = tag_name->Length;
char * tag = new char [tag_len + 1];
IntPtr nameChars = Marshal::StringToHGlobalAnsi(tag_name);
memcpy (tag, (const char*)nameChars.ToPointer(), tag_len);
Marshal::FreeHGlobal(nameChars);
tag[tag_len] = 0;
array<String^>^ tag_values = _tags->GetValues(tagno);
for (int valno = 0; valno < tag_values->Length; valno++)
{
UTF8Encoding^ enc = gcnew UTF8Encoding();
array<Byte>^ value_array = enc->GetBytes (tag_values[valno]);
int value_len = value_array->Length;
char * value = new char [value_len + 1];
Marshal::Copy (value_array, 0, (IntPtr) value, value_len);
value[value_len] = 0;
FLAC__StreamMetadata_VorbisComment_Entry entry;
/* create and entry and append it */
if(!FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, tag, value)) {
throw gcnew Exception("Unable to add tags, must be valid utf8.");
}
if(!FLAC__metadata_object_vorbiscomment_append_comment(vorbiscomment, entry, /*copy=*/false)) {
throw gcnew Exception("Unable to add tags.");
}
delete [] value;
}
delete [] tag;
}
_metadataList[_metadataCount++] = vorbiscomment;
if (_paddingLength != 0) {
padding = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING);
padding->length = _paddingLength;
_metadataList[_metadataCount++] = padding;
}
FLAC__stream_encoder_set_metadata(_encoder, _metadataList, _metadataCount);
FLAC__stream_encoder_set_verify(_encoder, _verify);
if (_finalSampleCount != 0) {
FLAC__stream_encoder_set_total_samples_estimate(_encoder, _finalSampleCount);
}
FLAC__stream_encoder_set_compression_level(_encoder, _compressionLevel);
pathChars = Marshal::StringToHGlobalUni(_path);
hFile = _wfopen((const wchar_t*)pathChars.ToPointer(), L"w+b");
Marshal::FreeHGlobal(pathChars);
if (FLAC__stream_encoder_init_FILE(_encoder, hFile, NULL, NULL) !=
FLAC__STREAM_ENCODER_INIT_STATUS_OK)
{
throw gcnew Exception("Unable to initialize the encoder.");
}
_initialized = true;
}
};
}

3
FLACDotNet/resource.h Normal file
View File

@@ -0,0 +1,3 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc

Some files were not shown because too many files have changed in this diff Show More