From 218f1b8f376ee055a29df0000f804be38d21915d Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Thu, 6 Jul 2017 17:37:02 +0300 Subject: [PATCH] Fix delay time playback --- .../NAudio.LICENSE.txt => COPYRIGHT | 33 +++++++++++++++++- .../at3plusdecoder.dll | Bin {Libraries => Dependencies}/vgmstream.dll | Bin LICENSE.txt => LICENSE | 0 Libraries/vgmstream.LICENSE.txt | 20 ----------- README.md | 29 ++++++++------- Source/AcbEditor/AcbEditor.csproj | 2 +- Source/AcbEditor/App.config | 2 +- Source/CsbBuilder/App.config | 2 +- Source/CsbBuilder/Audio/ExtendedWaveStream.cs | 28 +++++++++------ Source/CsbBuilder/CsbBuilder.csproj | 5 ++- Source/CsbEditor/App.config | 2 +- Source/CsbEditor/CsbEditor.csproj | 2 +- Source/SonicAudioCmd/App.config | 2 +- Source/SonicAudioCmd/SonicAudioCmd.csproj | 2 +- Source/SonicAudioLib/SonicAudioLib.csproj | 2 +- 16 files changed, 77 insertions(+), 54 deletions(-) rename Source/CsbBuilder/NAudio.LICENSE.txt => COPYRIGHT (68%) rename {Libraries => Dependencies}/at3plusdecoder.dll (100%) rename {Libraries => Dependencies}/vgmstream.dll (100%) rename LICENSE.txt => LICENSE (100%) delete mode 100644 Libraries/vgmstream.LICENSE.txt diff --git a/Source/CsbBuilder/NAudio.LICENSE.txt b/COPYRIGHT similarity index 68% rename from Source/CsbBuilder/NAudio.LICENSE.txt rename to COPYRIGHT index 622a544..2a51ee6 100644 --- a/Source/CsbBuilder/NAudio.LICENSE.txt +++ b/COPYRIGHT @@ -1,3 +1,9 @@ +Dependency Copyright Notices: + +====== +NAudio +====== + Microsoft Public License (Ms-PL) This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. @@ -28,4 +34,29 @@ A "contributor" is any person that distributes its contribution under this licen (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. -(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. \ No newline at end of file +(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. + +========= +vgmstream +========= + +Copyright (c) 2008-2010 Adam Gashlin, Fastelbja, Ronny Elfert + +Portions Copyright (c) 2004-2008, Marko Kreen +Portions Copyright 2001-2007 jagarl / Kazunori Ueno +Portions Copyright (c) 1998, Justin Frankel/Nullsoft Inc. +Portions Copyright (C) 2006 Nullsoft, Inc. +Portions Copyright (c) 2005-2007 Paul Hsieh +Portions Public Domain originating with Sun Microsystems + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Libraries/at3plusdecoder.dll b/Dependencies/at3plusdecoder.dll similarity index 100% rename from Libraries/at3plusdecoder.dll rename to Dependencies/at3plusdecoder.dll diff --git a/Libraries/vgmstream.dll b/Dependencies/vgmstream.dll similarity index 100% rename from Libraries/vgmstream.dll rename to Dependencies/vgmstream.dll diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/Libraries/vgmstream.LICENSE.txt b/Libraries/vgmstream.LICENSE.txt deleted file mode 100644 index 3603925..0000000 --- a/Libraries/vgmstream.LICENSE.txt +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2008-2010 Adam Gashlin, Fastelbja, Ronny Elfert - -Portions Copyright (c) 2004-2008, Marko Kreen -Portions Copyright 2001-2007 jagarl / Kazunori Ueno -Portions Copyright (c) 1998, Justin Frankel/Nullsoft Inc. -Portions Copyright (C) 2006 Nullsoft, Inc. -Portions Copyright (c) 2005-2007 Paul Hsieh -Portions Public Domain originating with Sun Microsystems - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index d38c19d..28bd1dd 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,29 @@ # Sonic Audio Tools -Sonic Audio Tools is a set of tools for editing the audio formats seen in Sonic the Hedgehog games. Currently, it's mostly focused on CRIWARE's audio formats, this means that these tools can be used to edit files from any game, as long as they are CSB, CPK, ACB or AWB. +Tools for editing CriMw / CriWare file formats. (CSB / CPK / ACB / AWB) ## Releases -[Here.](https://ci.appveyor.com/project/blueskythlikesclouds/sonicaudiotools/build/artifacts) +[On the AppVeyor page.](https://ci.appveyor.com/project/blueskythlikesclouds/sonicaudiotools/build/artifacts) +AppVeyor builds every commit automatically, so you can get the executables from the link above. +Stable builds are planned to be published [here.](https://github.com/blueskythlikesclouds/SonicAudioTools/releases) ## Building +If you still wish to build the solution yourself, this is what you should do: 1. Clone from [GitHub](https://github.com/blueskythlikesclouds/SonicAudioTools.git) `git clone https://github.com/blueskythlikesclouds/SonicAudioTools.git` 2. Open the solution in Visual Studio. (Visual Studio 2017 or later is required.) 3. Install the missing NuGet packages. 4. Build the solution. ## Projects -For more information about the projects, visit the [wiki](https://github.com/blueskythlikesclouds/SonicAudioTools/wiki) page. -### [SonicAudioLib](https://github.com/blueskythlikesclouds/SonicAudioTools/tree/master/Source/SonicAudioLib) -Core class library of the solution. Handles the IO work of the other projects. -### [AcbEditor](https://github.com/blueskythlikesclouds/SonicAudioTools/tree/master/Source/AcbEditor) -A tool to replace audio data in ACB files. Handles both ACBs and AWBs. Old ACB versions which had CPKs for storage are also supported. -### [CsbBuilder](https://github.com/blueskythlikesclouds/SonicAudioTools/tree/master/Source/CsbBuilder) -A fully functional CSB creator. It's currently able to load any CSB file as long as they contain ADX files. It also always builds in the latest CSB version, which appeared probably around 2010. -### [CsbEditor](https://github.com/blueskythlikesclouds/SonicAudioTools/tree/master/Source/CsbEditor) -A tool to replace audio data in CSB files. Handles both CSBs and CPKs. +To see more information about projects, visit the [wiki](https://github.com/blueskythlikesclouds/SonicAudioTools/wiki). +### [Sonic Audio Library](https://github.com/blueskythlikesclouds/SonicAudioTools/tree/master/Source/SonicAudioLib) +Main class library of the solution. Contains classes for IO and file formats. +### [ACB Editor](https://github.com/blueskythlikesclouds/SonicAudioTools/tree/master/Source/AcbEditor) +Audio data replacer for ACB / AWB files. Supports really old ACB files as well, which stored CPK files instead of currently used AWB files. Usage is explained in the program. +NOTE: It doesn't extract cue names so every audio will have its id on extracted file name. +### [CSB Builder](https://github.com/blueskythlikesclouds/SonicAudioTools/tree/master/Source/CsbBuilder) +CSB file importer/builder. Allows you to fully edit CSB files, preview your changes, add/remove cues, etc. +### [CSB Editor](https://github.com/blueskythlikesclouds/SonicAudioTools/tree/master/Source/CsbEditor) +Audio data replacer for CSB / CPK files. It works like ACB Editor and is a lot simpler than CSB Builder. ## License -See [LICENSE.txt](https://github.com/blueskythlikesclouds/SonicAudioTools/blob/master/LICENSE.txt) +Sonic Audio Tools uses the MIT license, meaning you're able to use and modify the code freely, as long as you include the copyright notice. +For more details, see [LICENSE](https://github.com/blueskythlikesclouds/SonicAudioTools/blob/master/LICENSE) diff --git a/Source/AcbEditor/AcbEditor.csproj b/Source/AcbEditor/AcbEditor.csproj index b152070..aa78d91 100644 --- a/Source/AcbEditor/AcbEditor.csproj +++ b/Source/AcbEditor/AcbEditor.csproj @@ -9,7 +9,7 @@ Properties AcbEditor AcbEditor - v4.6.1 + v4.5.2 512 true diff --git a/Source/AcbEditor/App.config b/Source/AcbEditor/App.config index ed71b0c..5c855f3 100644 --- a/Source/AcbEditor/App.config +++ b/Source/AcbEditor/App.config @@ -6,7 +6,7 @@ - + diff --git a/Source/CsbBuilder/App.config b/Source/CsbBuilder/App.config index bae5d6d..8227adb 100644 --- a/Source/CsbBuilder/App.config +++ b/Source/CsbBuilder/App.config @@ -1,6 +1,6 @@ - + diff --git a/Source/CsbBuilder/Audio/ExtendedWaveStream.cs b/Source/CsbBuilder/Audio/ExtendedWaveStream.cs index bcf9f88..a242eef 100644 --- a/Source/CsbBuilder/Audio/ExtendedWaveStream.cs +++ b/Source/CsbBuilder/Audio/ExtendedWaveStream.cs @@ -15,15 +15,13 @@ namespace CsbBuilder.Audio private double volume = 1; private double pitch = 0; - private long delayTime = 0; - private DateTime startTime; + private long delayBytes = 0; public override WaveFormat WaveFormat { get { WaveFormat waveFormat = streams[currentStreamIndex].WaveFormat; - return new WaveFormat(waveFormat.SampleRate + (int)(waveFormat.SampleRate * pitch), waveFormat.Channels); } } @@ -77,12 +75,16 @@ namespace CsbBuilder.Audio } } - public int DelayTime + public long DelayTime { set { - startTime = DateTime.Now; - delayTime = value * 10000; + delayBytes = (long)((value / 1000.0) * WaveFormat.AverageBytesPerSecond); + + if ((delayBytes % 2) != 0) + { + delayBytes++; + } } } @@ -90,14 +92,20 @@ namespace CsbBuilder.Audio public override int Read(byte[] buffer, int offset, int count) { - if (delayTime > 0) + if (delayBytes > 0) { - if ((DateTime.Now - startTime).Ticks < delayTime) + if (delayBytes - count < 0) { - return count; + offset += (int)delayBytes; + count -= (int)delayBytes; + delayBytes = 0; } - delayTime = 0; + else + { + delayBytes -= count; + return count; + } } int num = streams[currentStreamIndex].Read(buffer, 0, count); diff --git a/Source/CsbBuilder/CsbBuilder.csproj b/Source/CsbBuilder/CsbBuilder.csproj index 724701b..b546136 100644 --- a/Source/CsbBuilder/CsbBuilder.csproj +++ b/Source/CsbBuilder/CsbBuilder.csproj @@ -9,7 +9,7 @@ Properties CsbBuilder CsbBuilder - v4.6.1 + v4.5.2 512 true @@ -228,7 +228,6 @@ - @@ -236,7 +235,7 @@ - copy "$(SolutionDir)Libraries\*.dll" "$(TargetDir)" + copy "$(SolutionDir)Dependencies\*.dll" "$(TargetDir)"