Implemented sound export

This commit is contained in:
Daniel Brunner
2017-02-14 21:29:49 +01:00
parent 44c1fdb033
commit cf1dbf5855
6 changed files with 269 additions and 0 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

22
RCTExtractor.sln Normal file
View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RCTExtractor", "RCTExtractor\RCTExtractor.csproj", "{85DC5D8A-E279-496E-B58C-A863A8AF94F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{85DC5D8A-E279-496E-B58C-A863A8AF94F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85DC5D8A-E279-496E-B58C-A863A8AF94F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85DC5D8A-E279-496E-B58C-A863A8AF94F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85DC5D8A-E279-496E-B58C-A863A8AF94F5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

6
RCTExtractor/App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

82
RCTExtractor/Program.cs Normal file
View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace RCTExtractor
{
class Program
{
static void Main(string[] args)
{
if (Directory.Exists("sounds"))
Directory.Delete("sounds", true);
Directory.CreateDirectory("sounds");
using (var fs = File.OpenRead(@"D:\SteamLibrary\steamapps\common\RollerCoaster Tycoon Deluxe\Data\Css1.dat"))
using (var br = new BinaryReader(fs))
{
var positions = new uint[br.ReadUInt32()];
Console.WriteLine("{0} sounds", positions.Length);
for (int i = 0; i < positions.Length; i++)
{
positions[i] = br.ReadUInt32();
Console.WriteLine("sound {0} at offset {1} {2}", i, positions[i], i > 0 ? "+" + (positions[i] - positions[i - 1]) : "");
}
var names = new string[] { "lift 1", "straight running", "lift 2", "scream 1",
"click 1", "click 2", "place item", "scream 2", "scream 3", "scream 4",
"scream 5", "scream 6", "lift 3", "cash sound", "crash", "laying out water",
"water 1", "water 2", "train whistle", "train chugging", "water splash",
"hammering", "ride launch 1", "ride launch 2", "cough 1", "cough 2",
"cough 3", "cough 4", "rain 1", "thunder 1", "thunder 2", "rain 2", "rain 3",
"tink 1", "tink 2", "scream 7", "toilet flush", "click 3", "quack",
"message sound", "dialog box sound", "person 1", "person 2", "person 3",
"clapping", "haunted house 1", "haunted house 2", "haunted house 3" };
for (int i = 0; i < positions.Length; i++)
{
fs.Position = positions[i];
var size = br.ReadUInt32();
var wFormatTag = br.ReadUInt16();
var wChannels = br.ReadUInt16();
var dwSamplesPerSec = br.ReadUInt32();
var dwAvgBytesPerSec = br.ReadUInt32();
var wBlockAlign = br.ReadUInt16();
var wBitsPerSample = br.ReadUInt16();
Console.WriteLine("Exporting sound {0} (size: {1})", i, size);
Console.WriteLine(" wFormatTag {0}", wFormatTag);
Console.WriteLine(" wChannels {0}", wChannels);
Console.WriteLine(" dwSamplesPerSec {0}", dwSamplesPerSec);
Console.WriteLine(" dwAvgBytesPerSec {0}", dwAvgBytesPerSec);
Console.WriteLine(" wBlockAlign {0}", wBlockAlign);
Console.WriteLine(" wBitsPerSample {0}", wBitsPerSample);
using (var sfs = File.OpenWrite(Path.Combine("sounds", names[i] + ".wav")))
using (var bw = new BinaryWriter(sfs))
{
bw.Write(new byte[] { (byte)'R', (byte)'I', (byte)'F', (byte)'F' });
bw.Write(4 + 4 + 4 + 4 + 4 + size);
bw.Write(new byte[] { (byte)'W', (byte)'A', (byte)'V', (byte)'E' });
bw.Write(new byte[] { (byte)'f', (byte)'m', (byte)'t', (byte)' ' });
bw.Write((uint)(2 + 2 + 4 + 4 + 2 + 2));
bw.Write(wFormatTag);
bw.Write(wChannels);
bw.Write(dwSamplesPerSec);
bw.Write(dwAvgBytesPerSec);
bw.Write(wBlockAlign);
bw.Write(wBitsPerSample);
bw.Write(new byte[] { (byte)'d', (byte)'a', (byte)'t', (byte)'a' });
bw.Write(size - 2 - 2 - 4 - 4 - 2 - 2);
bw.Write(br.ReadBytes((int)(size - 2 - 2 - 4 - 4 - 2 - 2)));
}
}
}
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("RCTExtractor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RCTExtractor")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("85dc5d8a-e279-496e-b58c-a863a8af94f5")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{85DC5D8A-E279-496E-B58C-A863A8AF94F5}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RCTExtractor</RootNamespace>
<AssemblyName>RCTExtractor</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\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>