diff --git a/BrawlLib.LoopSelection/BrawlLib.LoopSelection.csproj b/BrawlLib.LoopSelection/BrawlLib.LoopSelection.csproj deleted file mode 100644 index 1304a9f..0000000 --- a/BrawlLib.LoopSelection/BrawlLib.LoopSelection.csproj +++ /dev/null @@ -1,113 +0,0 @@ - - - - - Debug - x86 - {41C94979-CE5A-4582-888A-1BEE98DD43D3} - Library - Properties - BrawlLib.LoopSelection - BrawlLib.LoopSelection - v4.8 - 512 - - - - - true - full - false - bin\Debug\ - TRACE;DEBUG - prompt - 4 - true - AnyCPU - false - - - pdbonly - true - bin\Release\ - TRACE;BRAWLLIB_AUDIO - prompt - 4 - true - AnyCPU - false - - - true - bin\Debug\ - TRACE;DEBUG - true - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - false - - - bin\Release\ - TRACE;BRAWLLIB_AUDIO - true - true - pdbonly - AnyCPU - prompt - MinimumRecommendedRules.ruleset - false - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - Component - - - Form - - - - - - - BrstmConverterDialog.cs - - - - - - \ No newline at end of file diff --git a/BrawlLib.LoopSelection/Platform/Win32.DirectSound.cs b/BrawlLib.LoopSelection/Platform/Win32.DirectSound.cs deleted file mode 100644 index 01fa717..0000000 --- a/BrawlLib.LoopSelection/Platform/Win32.DirectSound.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace BrawlLib.LoopSelection -{ - internal static partial class Win32 - { - internal static unsafe partial class DirectSound - { - public delegate bool DSEnumCallback(Guid* lpGuid, sbyte* lpcstrDescription, sbyte* lpcstrModule, IntPtr lpContext); - - public static readonly Guid DefaultPlaybackGuid = new Guid("DEF00000-9C6D-47ED-AAF1-4DDA8F2B5C03"); - public static readonly Guid DefaultVoicePlaybackGuid = new Guid("DEF00002-9C6D-47ED-AAF1-4DDA8F2B5C03"); - - [DllImport("DSound.dll", PreserveSig = false)] - public static extern void GetDeviceID(ref Guid pGuidSrc, out Guid pGuidDest); - [DllImport("DSound.dll", PreserveSig = false)] - public static extern void DirectSoundEnumerate([MarshalAs(UnmanagedType.FunctionPtr)] DSEnumCallback lpDSEnumCallback, IntPtr lpContext); - [DllImport("DSound.dll", PreserveSig = false)] - public static extern void DirectSoundCreate8(Guid* lpcGuidDevice, out IDirectSound8 ppDS8, IntPtr pUnkOuter); - - #region Structs - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct DSCaps - { - public uint dwSize; - public DSCapsFlags dwFlags; - public uint dwMinSecondarySampleRate; - public uint dwMaxSecondarySampleRate; - public uint dwPrimaryBuffers; - public uint dwMaxHwMixingAllBuffers; - public uint dwMaxHwMixingStaticBuffers; - public uint dwMaxHwMixingStreamingBuffers; - public uint dwFreeHwMixingAllBuffers; - public uint dwFreeHwMixingStaticBuffers; - public uint dwFreeHwMixingStreamingBuffers; - public uint dwMaxHw3DAllBuffers; - public uint dwMaxHw3DStaticBuffers; - public uint dwMaxHw3DStreamingBuffers; - public uint dwFreeHw3DAllBuffers; - public uint dwFreeHw3DStaticBuffers; - public uint dwFreeHw3DStreamingBuffers; - public uint dwTotalHwMemBytes; - public uint dwFreeHwMemBytes; - public uint dwMaxContigFreeHwMemBytes; - public uint dwUnlockTransferRateHwBuffers; - public uint dwPlayCpuOverheadSwBuffers; - public uint dwReserved1; - public uint dwReserved2; - } - #endregion - - #region Enums - [Flags] - public enum DSCapsFlags : uint - { - PrimaryMono = 0x00000001, - PrimaryStereo = 0x00000002, - Primary8Bit = 0x00000004, - Primary16Bit = 0x00000008, - ContinuousRate = 0x00000010, - EmulDriver = 0x00000020, - Certified = 0x00000040, - SecondaryMono = 0x00000100, - SecondaryStereo = 0x00000200, - Secondary8Bit = 0x00000400, - Secondary16Bit = 0x00000800 - } - - public enum DSCooperativeLevel : uint - { - Normal = 0x00000001, - Priority = 0x00000002, - Exclusive = 0x00000003, - WritePrimary = 0x00000004 - } - - [Flags] - public enum DSSpeakerConfig : uint - { - DirectOut = 0x00000000, - Headphone = 0x00000001, - Mono = 0x00000002, - Quad = 0x00000003, - Stereo = 0x00000004, - Surround = 0x00000005, - Back5Point1 = 0x00000006, - Wide7Point1 = 0x00000007, - Surround7Point1 = 0x00000008, - Surround5Point1 = 0x00000009, - - StereoGeometryMin = 0x00050000, // 5 degrees - GeometryNarrow = 0x000A0000, // 10 degrees - GeometryWide = 0x00140000, // 20 degrees - GeometryMax = 0x00B40000 // 180 degrees - } - #endregion - - #region Interfaces - - [Guid("C50A7E93-F395-4834-9EF6-7FA99DE50966"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - public unsafe interface IDirectSound8 - { - void CreateSoundBuffer(ref DSBufferDesc pcDSBufferDesc, out IDirectSoundBuffer8 ppDSBuffer, IntPtr pUnkOuter); - void GetCaps(ref DSCaps pDSCaps); - void DuplicateSoundBuffer(IDirectSoundBuffer8 pDSBufferOriginal, out IDirectSoundBuffer8 ppDSBufferDuplicate); - void SetCooperativeLevel(IntPtr hwnd, DSCooperativeLevel dwLevel); - void Compact(); - void GetSpeakerConfig(out DSSpeakerConfig pdwSpeakerConfig); - void SetSpeakerConfig(DSSpeakerConfig dwSpeakerConfig); - void Initialize(ref Guid pcGuidDevice); - void VerifyCertification(out uint pdwCertified); - } - - #endregion - } - } -} diff --git a/BrawlLib.LoopSelection/Platform/Win32.DirectSoundBuffer.cs b/BrawlLib.LoopSelection/Platform/Win32.DirectSoundBuffer.cs deleted file mode 100644 index 8aee45c..0000000 --- a/BrawlLib.LoopSelection/Platform/Win32.DirectSoundBuffer.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System.Runtime.InteropServices; -using System; - -namespace BrawlLib.LoopSelection -{ - static partial class Win32 - { - internal static partial class DirectSound - { - #region Structs - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - internal unsafe struct DSBufferDesc - { - public const uint Size = 36; - - public uint dwSize; - public DSBufferCapsFlags dwFlags; - public uint dwBufferBytes; - public uint dwReserved; - public WaveFormatEx* lpwfxFormat; - public Guid guid3DAlgorithm; - - public DSBufferDesc(uint bufferSize, DSBufferCapsFlags bufferCaps) : this(bufferSize, bufferCaps, null, Guid.Empty) { } - public DSBufferDesc(uint bufferSize, DSBufferCapsFlags bufferCaps, WaveFormatEx* format, Guid algorithm) - { - dwSize = Size; - dwFlags = bufferCaps; - dwBufferBytes = bufferSize; - dwReserved = 0; - lpwfxFormat = format; - guid3DAlgorithm = algorithm; - } - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - internal struct DSBufferCaps - { - public const uint Size = 20; - - public uint dwSize; - public DSBufferCapsFlags dwFlags; - public uint dwBufferBytes; - public uint dwUnlockTransferRate; - public uint dwPlayCpuOverhead; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - internal struct DSEffectDesc - { - public uint dwSize; - public DSEffectDescFlags dwFlags; - public Guid guidDSFXClass; - public IntPtr dwReserved1; - public IntPtr dwReserved2; - } - [StructLayout(LayoutKind.Sequential, Pack = 1)] - internal struct DSBufferPositionNotify - { - public uint dwOffset; - public IntPtr hEventNotify; - } - - #endregion - - #region Flags - - [Flags] - internal enum DSBufferCapsFlags : uint - { - PrimaryBuffer = 0x00000001, - Static = 0x00000002, - LocHardware = 0x00000004, - LocSoftware = 0x00000008, - Ctrl3D = 0x00000010, - CtrlFrequency = 0x00000020, - CtrlPan = 0x00000040, - CtrlVolume = 0x00000080, - CtrlPositionNotify = 0x00000100, - CtrlFX = 0x00000200, - StickyFocus = 0x00004000, - GlobalFocus = 0x00008000, - GetCurrentPosition2 = 0x00010000, - Mute3dAtMaxDistance = 0x00020000, - LocDefer = 0x00040000, - TruePlayPosition = 0x00080000 - } - - [Flags] - internal enum DSBufferStatus : uint - { - Playing = 0x00000001, - BufferLost = 0x00000002, - Looping = 0x00000004, - LocHardware = 0x00000008, - LocSoftware = 0x00000010, - Terminated = 0x00000020 - } - - [Flags] - internal enum DSBufferPlayFlags : uint - { - None = 0, - Looping = 0x00000001, - LocHardware = 0x00000002, - LocSoftware = 0x00000004, - TerminateByTime = 0x00000008, - TerminateByDistance = 0x000000010, - TerminateByPriority = 0x000000020 - } - - [Flags] - internal enum DSLockFlags : uint - { - None = 0, - FromWriteCursor = 0x00000001, - EntireBuffer = 0x00000002 - } - - internal enum DSEffectDescFlags : uint - { - None = 0x0000000, - LocHardware = 0x00000001, - LocSoftware = 0x00000002 - } - - internal enum DSEffectResult : uint - { - Present = 0, - LocHardware = 1, - LocSoftware = 2, - Unallocated = 3, - Failed = 4, - Unknown = 5, - SendLoop = 6 - } - - #endregion - - #region COM Interfaces - [Guid("279AFA85-4981-11CE-A521-0020AF0BE560"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - internal unsafe interface IDirectSoundBuffer8 - { - void GetCaps(ref DSBufferCaps pDSBufferCaps); - void GetCurrentPosition(uint* pdwCurrentPlayCursor, uint* pdwCurrentWriteCursor); - void GetFormat(WaveFormatEx* pwfxFormat, uint dwSizeAllocated, uint* pdwSizeWritten); - void GetVolume(out int plVolume); - void GetPan(out int plPan); - void GetFrequency(out uint pdwFrequency); - void GetStatus(out DSBufferStatus pdwStatus); - void Initialize(IDirectSound8 pDirectSound, ref DSBufferDesc pcDSBufferDesc); - void Lock(uint dwOffset, uint dwBytes, out IntPtr ppvAudioPtr1, out uint pdwAudioBytes1, out IntPtr ppvAudioPtr2, out uint pdwAudioBytes2, DSLockFlags dwFlags); - void Play(uint dwReserved1, uint dwPriority, DSBufferPlayFlags dwFlags); - void SetCurrentPosition(uint dwNewPosition); - void SetFormat(WaveFormatEx* pcfxFormat); - void SetVolume(int lVolume); - void SetPan(int lPan); - void SetFrequency(uint dwFrequency); - void Stop(); - void Unlock(IntPtr pvAudioPtr1, uint dwAudioBytes1, IntPtr pvAudioPtr2, uint dwAudioBytes2); - void Restore(); - void SetFX(uint dwEffectsCount, [MarshalAs(UnmanagedType.LPArray)] DSEffectDesc[] pDSFXDesc, [MarshalAs(UnmanagedType.LPArray)] DSEffectResult[] pdwResultCodes); - void AcquireResources(DSBufferPlayFlags dwFlags, uint dwEffectsCount, [MarshalAs(UnmanagedType.LPArray)] DSEffectResult[] pdwResultCodes); - void GetObjectInPath(ref Guid rguidObject, uint dwIndex, ref Guid rguidInterface, out IntPtr ppObject); - } - - [Guid("B0210783-89CD-11D0-AF08-00A0C925CD16"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - internal unsafe interface IDirectSound8Notify - { - void SetNotificationPositions(uint dwPositionNotifies, [MarshalAs(UnmanagedType.LPArray)] DSBufferPositionNotify[] pcPositionNotifies); - } - #endregion - } - } -} diff --git a/BrawlLib.LoopSelection/Properties/AssemblyInfo.cs b/BrawlLib.LoopSelection/Properties/AssemblyInfo.cs deleted file mode 100644 index 2e29543..0000000 --- a/BrawlLib.LoopSelection/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -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("BrawlLib v0.24")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("BrawlLib")] -[assembly: AssemblyCopyright("Copyright © 2009 - 2017 Bryan Moulton, BlackJax96, libertyernie && Sammi Husky")] -[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("84b5ec46-630b-4225-beec-6082c28f85e6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.25.*")] -[assembly: AssemblyFileVersion("0.25.1.0")] diff --git a/BrawlLib.LoopSelection/Properties/Resources.Designer.cs b/BrawlLib.LoopSelection/Properties/Resources.Designer.cs deleted file mode 100644 index 625a69a..0000000 --- a/BrawlLib.LoopSelection/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace BrawlLib.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // 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", "4.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() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [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("BrawlLib.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/BrawlLib.LoopSelection/Properties/Resources.resources b/BrawlLib.LoopSelection/Properties/Resources.resources deleted file mode 100644 index 6c05a97..0000000 Binary files a/BrawlLib.LoopSelection/Properties/Resources.resources and /dev/null differ diff --git a/BrawlLib.LoopSelection/Properties/Resources.resx b/BrawlLib.LoopSelection/Properties/Resources.resx deleted file mode 100644 index 1af7de1..0000000 --- a/BrawlLib.LoopSelection/Properties/Resources.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/BrawlLib.LoopSelection/Properties/Settings.Designer.cs b/BrawlLib.LoopSelection/Properties/Settings.Designer.cs deleted file mode 100644 index 3e6a6cb..0000000 --- a/BrawlLib.LoopSelection/Properties/Settings.Designer.cs +++ /dev/null @@ -1,96 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.18034 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using BrawlLib.Modeling; -using BrawlLib.SSBB.ResourceNodes; -using System; -using System.Collections.Generic; -namespace BrawlLib.Properties -{ - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] - public 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; } } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public Collada.ImportOptions ColladaImportOptions - { - get - { - return ((Collada.ImportOptions)(this["ColladaImportOptions"])); - } - set - { - this["ColladaImportOptions"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("false")] - public bool HideMDL0Errors { - get { - return ((bool)(this["HideMDL0Errors"])); - } - set { - this["HideMDL0Errors"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public List Codes - { - get - { - return ((List)(this["Codes"])); - } - set - { - this["Codes"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("true")] - public bool SaveGCTWithInfo - { - get - { - return (bool)(this["SaveGCTWithInfo"]); - } - set - { - this["SaveGCTWithInfo"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("1")] - public double? AudioVolumePercent - { - get - { - return (double?)(this["AudioVolumePercent"]); - } - set - { - this["AudioVolumePercent"] = value; - } - } - } -} diff --git a/BrawlLib.LoopSelection/README.md b/BrawlLib.LoopSelection/README.md deleted file mode 100644 index 89226a3..0000000 --- a/BrawlLib.LoopSelection/README.md +++ /dev/null @@ -1,10 +0,0 @@ -BrawlLib.LoopSelection -====================== - -This library contains just the loop point selection dialog from [BrawlLib](https://github.com/libertyernie/brawltools) / [BrawlCrate](https://github.com/soopercool101/BrawlCrate). - -This program is provided as-is without any warranty, implied or otherwise. -By using this program, the end user agrees to take full responsibility -regarding its proper and lawful use. The authors/hosts/distributors cannot be -held responsible for any damage resulting in the use of this program, nor can -they be held accountable for the manner in which it is used. \ No newline at end of file diff --git a/BrawlLib.LoopSelection/System/Audio/AudioBuffer.cs b/BrawlLib.LoopSelection/System/Audio/AudioBuffer.cs deleted file mode 100644 index a039e90..0000000 --- a/BrawlLib.LoopSelection/System/Audio/AudioBuffer.cs +++ /dev/null @@ -1,178 +0,0 @@ -using System; - -namespace BrawlLib.LoopSelection -{ - public abstract class AudioBuffer : IDisposable - { - //Buffer will be valid for two seconds. The application MUST update/fill before then. - //This is plenty of time, as timer updates should occur every 10 - 100 ms. - internal const int DefaultBufferSpan = 2; - - internal AudioProvider _owner; - public AudioProvider Owner { get { return _owner; } } - - internal IAudioStream _source; - public IAudioStream Source { get { return _source; } } - - internal WaveFormatTag _format; - public WaveFormatTag Format { get { return _format; } } - - internal int _frequency; - public int Frequency { get { return _frequency; } } - - internal int _channels; - public int Channels { get { return _channels; } } - - internal int _bitsPerSample; - public int BitsPerSample { get { return _bitsPerSample; } } - - //Number of samples that can be stored inside the buffer. - internal int _sampleLength; - public int SampleLength { get { return _sampleLength; } } - - //Total byte length of the buffer. - internal int _dataLength; - public int DataLength { get { return _dataLength; } } - - //Number of bytes in each sample. (_bitsPerSample * _channels / 8) - internal int _blockAlign; - public int BlockAlign { get { return _blockAlign; } } - - //Byte offset within buffer in which to continue writing. - //Read-only. It is the responsibility of the application to update the audio data in a timely manner. - //As data is written, this is updated automatically. - internal int _writeOffset; - public int WriteOffset { get { return _writeOffset; } } - - //Byte offset within buffer in which reading is currently commencing. - //The application must call Update (or Fill) to update this value. - internal int _readOffset; - public int ReadOffset { get { return _readOffset; } } - - //Cumulative sample position in which to continue writing. - //This value is updated automatically when fill is called. - internal int _writeSample; - public int WriteSample { get { return _writeSample; } } - - //Cumulative sample position in which the buffer is currently reading. - //This value is updated as Update is called. - internal int _readSample; - public int ReadSample { get { return _readSample; } } - - //Sets whether the buffer manages looping. - //Use this with Source. - internal bool _loop = false; - public bool Loop { get { return _loop; } set { _loop = value; } } - - //internal bool _playing = false; - //public bool IsPlaying { get { return _playing; } } - - //Byte offset within buffer in which playback is commencing. - internal abstract int PlayCursor { get; set; } - - public abstract int Volume { get; set; } - public abstract int Pan { get; set; } - - ~AudioBuffer() { Dispose(); } - public virtual void Dispose() - { - if (_owner != null) - { - _owner._buffers.Remove(this); - _owner = null; - } - GC.SuppressFinalize(this); - } - - public abstract void Play(); - public abstract void Stop(); - public abstract BufferData Lock(int offset, int length); - public abstract void Unlock(BufferData data); - - //Should only be used while playback is stopped - public void Seek(int samplePos) - { - _readOffset = _writeOffset = PlayCursor; - _readSample = _writeSample = samplePos; - - if (_source != null) - _source.SamplePosition = samplePos; - } - public void Reset() - { - _readOffset = _writeOffset = PlayCursor; - } - - public virtual void Update() - { - //Get current sample offset. - int sampleOffset = PlayCursor / _blockAlign; - //Get current byte offset - int byteOffset = sampleOffset * _blockAlign; - //Get sample difference since last update, taking into account circular wrapping. - int sampleDifference = (((byteOffset < _readOffset) ? (byteOffset + _dataLength) : byteOffset) - _readOffset) / _blockAlign; - //Get byte difference - //int byteDifference = sampleDifference * _blockAlign; - - //If no change, why continue? - if (sampleDifference == 0) - return; - - //Set new read offset. - _readOffset = byteOffset; - - //Update looping - if (_source != null) - { - if ((_loop) && (_source.IsLooping)) - { - int start = _source.LoopStartSample; - int end = _source.LoopEndSample; - int newSample = _readSample + sampleDifference; - - if ((newSample >= end) && (_writeSample < _readSample)) - _readSample = start + ((newSample - start) % (end - start)); - else - _readSample = Math.Min(newSample, _source.Samples); - } - else - { - _readSample = Math.Min(_readSample + sampleDifference, _source.Samples); - //if (_readSample >= _source.Samples) - // Stop(); - } - } - else - _readSample += sampleDifference; - } - - public virtual void Fill() - { - //This only works if a source has been assigned! - if (_source == null) - return; - - //Update read position - Update(); - - //Get number of samples available for writing. - int sampleCount = (((_readOffset <= _writeOffset) ? (_readOffset + _dataLength) : _readOffset) - _writeOffset) / _blockAlign / 8; - - //Fill samples - Fill(_source, sampleCount, _loop); - } - public virtual void Fill(IAudioStream source, int samples, bool loop) - { - int byteCount = samples * _blockAlign; - - //Lock buffer and fill - BufferData data = Lock(_writeOffset, byteCount); - try { data.Fill(source, loop); } - finally { Unlock(data); } - - //Advance offsets - _writeOffset = (_writeOffset + byteCount) % _dataLength; - _writeSample = source.SamplePosition; - } - } -} diff --git a/BrawlLib.LoopSelection/System/Audio/AudioDevice.cs b/BrawlLib.LoopSelection/System/Audio/AudioDevice.cs deleted file mode 100644 index acb856e..0000000 --- a/BrawlLib.LoopSelection/System/Audio/AudioDevice.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; - -namespace BrawlLib.LoopSelection -{ - public abstract class AudioDevice - { - internal string _description, _driver; - - public string Description { get { return _description; } } - public string Driver { get { return _driver; } } - - public static AudioDevice[] PlaybackDevices - { - get - { - switch (Environment.OSVersion.Platform) { - case PlatformID.Win32NT: return wAudioDevice.PlaybackDevices; - } - return null; - } - } - - public static AudioDevice DefaultPlaybackDevice - { - get { - switch (Environment.OSVersion.Platform) { - case PlatformID.Win32NT: return wAudioDevice.DefaultPlaybackDevice; - } - return null; - } - } - - public static AudioDevice DefaultVoicePlaybackDevice - { - get { - switch (Environment.OSVersion.Platform) { - case PlatformID.Win32NT: return wAudioDevice.DefaultVoicePlaybackDevice; - } - return null; - } - } - } -} diff --git a/BrawlLib.LoopSelection/System/Audio/AudioProvider.cs b/BrawlLib.LoopSelection/System/Audio/AudioProvider.cs deleted file mode 100644 index 985efc8..0000000 --- a/BrawlLib.LoopSelection/System/Audio/AudioProvider.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Windows.Forms; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System; - -namespace BrawlLib.LoopSelection -{ - public abstract class AudioProvider : IDisposable - { - internal AudioDevice _device; - public AudioDevice Device { get { return _device; } } - - internal List _buffers = new List(); - public List Buffers { get { return _buffers; } } - - [Flags] - public enum AudioProviderType { - None = 0, - DirectSound = 1, - OpenAL = 2, - All = ~0 - }; - public static AudioProviderType AvailableTypes = AudioProviderType.All; - - public static AudioProvider Create(AudioDevice device) - { - if (AvailableTypes.HasFlag(AudioProviderType.DirectSound)) - { - switch (Environment.OSVersion.Platform) - { - case PlatformID.Win32NT: - if (IntPtr.Size <= 4) return new wAudioProvider(device); - break; - } - } - - return null; - } - - ~AudioProvider() { Dispose(); } - public virtual void Dispose() - { - foreach (AudioBuffer buffer in _buffers) - buffer.Dispose(); - _buffers.Clear(); - GC.SuppressFinalize(this); - } - - public abstract void Attach(Control owner); - - public abstract AudioBuffer CreateBuffer(IAudioStream target); - } -} diff --git a/BrawlLib.LoopSelection/System/Audio/BufferData.cs b/BrawlLib.LoopSelection/System/Audio/BufferData.cs deleted file mode 100644 index 35d7143..0000000 --- a/BrawlLib.LoopSelection/System/Audio/BufferData.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; - -namespace BrawlLib.LoopSelection -{ - public struct BufferData - { - internal int _sampleOffset; - public int SampleOffset { get { return _sampleOffset; } } - - internal int _sampleLength; - public int SampleLength { get { return _sampleLength; } } - - internal int _dataOffset; - public int DataOffset { get { return _dataOffset; } } - - internal int _dataLength; - public int DataLength { get { return _dataLength; } } - - internal IntPtr _part1Address; - public IntPtr Part1Address { get { return _part1Address; } } - internal int _part1Length; - public int Part1Length { get { return _part1Length; } } - internal int _part1Samples; - public int Part1Samples { get { return _part1Samples; } } - - internal IntPtr _part2Address; - public IntPtr Part2Address { get { return _part2Address; } } - internal int _part2Length; - public int Part2Length { get { return _part2Length; } } - internal int _part2Samples; - public int Part2Samples { get { return _part2Samples; } } - - public bool IsSplit { get { return _part2Length != 0; } } - - public void Fill(IAudioStream stream, bool loop) - { - int blockAlign = stream.BitsPerSample * stream.Channels / 8; - int samplePos = stream.SamplePosition; - int sampleCount = _sampleLength; - int samplesRead; - bool end = false; - - loop = loop && stream.IsLooping; - int lastSample = loop ? stream.LoopEndSample : stream.Samples; - - IntPtr blockAddr = _part1Address; - int blockRemaining = _part1Samples; - - while (sampleCount > 0) - { - //Get current block sample count - int blockSamples = Math.Min(blockRemaining, sampleCount); - - //Fill zeros - if (end) - Memory.Fill(blockAddr, (uint)(blockSamples * blockAlign), 0); - else - { - //Do we extend within last sample range? - if ((samplePos <= lastSample) && (lastSample < (samplePos + blockSamples))) - { - blockSamples = lastSample - samplePos; - end = true; - } - - samplesRead = stream.ReadSamples(blockAddr, blockSamples); - samplePos += samplesRead; - - if (samplesRead < blockSamples) - { - blockSamples = samplesRead; - end = true; - } - else if (loop && end) - { - stream.Wrap(); - if (samplePos == stream.SamplePosition) - { - samplePos = -1; - break; - } - samplePos = stream.SamplePosition; - end = false; - } - } - - blockAddr += blockSamples * blockAlign; - blockRemaining -= blockSamples; - - //Wrap to second buffer - if (blockRemaining <= 0) - { - blockAddr = _part2Address; - blockRemaining = _part2Samples; - } - - sampleCount -= blockSamples; - } - } - } -} diff --git a/BrawlLib.LoopSelection/System/Audio/IAudioStream.cs b/BrawlLib.LoopSelection/System/Audio/IAudioStream.cs deleted file mode 100644 index 02df77b..0000000 --- a/BrawlLib.LoopSelection/System/Audio/IAudioStream.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -namespace BrawlLib.LoopSelection -{ - public interface IAudioStream: IDisposable - { - WaveFormatTag Format { get; } - int BitsPerSample { get; } - int Samples { get; } - int Channels { get; } - int Frequency { get; } - bool IsLooping { get; set; } - int LoopStartSample { get; set; } - int LoopEndSample { get; set; } - int SamplePosition { get; set; } - - /// - /// Reads numSamples audio samples into the address specified by destAddr. - /// This method does not observe loop points and does not loop automatically. - /// - /// The address at which to start writing samples. - /// The maximum number of samples to read. - /// The actual number of samples read (per channel). - int ReadSamples(IntPtr destAddr, int numSamples); - - //Wraps the stream to the loop context. - //Must be used manually in order to track stream state. (Just good coding practice) - void Wrap(); - } -} diff --git a/BrawlLib.LoopSelection/System/Audio/WaveFormatEx.cs b/BrawlLib.LoopSelection/System/Audio/WaveFormatEx.cs deleted file mode 100644 index 35dd868..0000000 --- a/BrawlLib.LoopSelection/System/Audio/WaveFormatEx.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Runtime.InteropServices; - -namespace BrawlLib.LoopSelection -{ - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public unsafe struct WaveFormatEx - { - public WaveFormatTag wFormatTag; - public ushort nChannels; - public uint nSamplesPerSec; - public uint nAvgBytesPerSec; - public ushort nBlockAlign; - public ushort wBitsPerSample; - public ushort cbSize; - - public WaveFormatEx(WaveFormatTag format, int channels, int frequency, int bitsPerSample) - { - wFormatTag = format; - nChannels = (ushort)channels; - nSamplesPerSec = (uint)frequency; - nBlockAlign = (ushort)(bitsPerSample * channels / 8); - nAvgBytesPerSec = nBlockAlign * nSamplesPerSec; - wBitsPerSample = (ushort)bitsPerSample; - cbSize = 0; - } - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct WaveFormatExtensible - { - public WaveFormatEx Format; - public ushort wValidBitsPerSample; - public ushort wSamplesPerBlock; - public ushort wReserved; - public uint dwChannelMask; - public uint SubFormat; - } -} diff --git a/BrawlLib.LoopSelection/System/Audio/WaveFormatTag.cs b/BrawlLib.LoopSelection/System/Audio/WaveFormatTag.cs deleted file mode 100644 index de6e137..0000000 --- a/BrawlLib.LoopSelection/System/Audio/WaveFormatTag.cs +++ /dev/null @@ -1,154 +0,0 @@ -namespace BrawlLib.LoopSelection { - public enum WaveFormatTag : ushort - { - WAVE_FORMAT_UNKNOWN = 0x0000, /* Microsoft Corporation */ - WAVE_FORMAT_PCM = 0x0001, /* Microsoft Corporation */ - WAVE_FORMAT_ADPCM = 0x0002, /* Microsoft Corporation */ - WAVE_FORMAT_IEEE_FLOAT = 0x0003, /* Microsoft Corporation */ - WAVE_FORMAT_VSELP = 0x0004, /* Compaq Computer Corp. */ - WAVE_FORMAT_IBM_CVSD = 0x0005, /* IBM Corporation */ - WAVE_FORMAT_ALAW = 0x0006, /* Microsoft Corporation */ - WAVE_FORMAT_MULAW = 0x0007, /* Microsoft Corporation */ - WAVE_FORMAT_DTS = 0x0008, /* Microsoft Corporation */ - WAVE_FORMAT_DRM = 0x0009, /* Microsoft Corporation */ - WAVE_FORMAT_WMAVOICE9 = 0x000A, /* Microsoft Corporation */ - WAVE_FORMAT_WMAVOICE10 = 0x000B, /* Microsoft Corporation */ - WAVE_FORMAT_OKI_ADPCM = 0x0010, /* OKI */ - WAVE_FORMAT_DVI_ADPCM = 0x0011, /* Intel Corporation */ - WAVE_FORMAT_IMA_ADPCM = 0x0011, /* Intel Corporation */ - WAVE_FORMAT_MEDIASPACE_ADPCM = 0x0012, /* Videologic */ - WAVE_FORMAT_SIERRA_ADPCM = 0x0013, /* Sierra Semiconductor Corp */ - WAVE_FORMAT_DIGISTD = 0x0015, /* DSP Solutions, Inc. */ - WAVE_FORMAT_DIGIFIX = 0x0016, /* DSP Solutions, Inc. */ - WAVE_FORMAT_DIALOGIC_OKI_ADPCM = 0x0017, /* Dialogic Corporation */ - WAVE_FORMAT_MEDIAVISION_ADPCM = 0x0018, /* Media Vision, Inc. */ - WAVE_FORMAT_CU_CODEC = 0x0019, /* Hewlett-Packard Company */ - WAVE_FORMAT_YAMAHA_ADPCM = 0x0020, /* Yamaha Corporation of America */ - WAVE_FORMAT_SONARC = 0x0021, /* Speech Compression */ - WAVE_FORMAT_DSPGROUP_TRUESPEECH = 0x0022, /* DSP Group, Inc */ - WAVE_FORMAT_ECHOSC1 = 0x0023, /* Echo Speech Corporation */ - WAVE_FORMAT_AUDIOFILE_AF36 = 0x0024, /* Virtual Music, Inc. */ - WAVE_FORMAT_APTX = 0x0025, /* Audio Processing Technology */ - WAVE_FORMAT_AUDIOFILE_AF10 = 0x0026, /* Virtual Music, Inc. */ - WAVE_FORMAT_PROSODY_1612 = 0x0027, /* Aculab plc */ - WAVE_FORMAT_LRC = 0x0028, /* Merging Technologies S.A. */ - WAVE_FORMAT_DOLBY_AC2 = 0x0030, /* Dolby Laboratories */ - WAVE_FORMAT_GSM610 = 0x0031, /* Microsoft Corporation */ - WAVE_FORMAT_MSNAUDIO = 0x0032, /* Microsoft Corporation */ - WAVE_FORMAT_ANTEX_ADPCME = 0x0033, /* Antex Electronics Corporation */ - WAVE_FORMAT_CONTROL_RES_VQLPC = 0x0034, /* Control Resources Limited */ - WAVE_FORMAT_DIGIREAL = 0x0035, /* DSP Solutions, Inc. */ - WAVE_FORMAT_DIGIADPCM = 0x0036, /* DSP Solutions, Inc. */ - WAVE_FORMAT_CONTROL_RES_CR10 = 0x0037, /* Control Resources Limited */ - WAVE_FORMAT_NMS_VBXADPCM = 0x0038, /* Natural MicroSystems */ - WAVE_FORMAT_CS_IMAADPCM = 0x0039, /* Crystal Semiconductor IMA ADPCM */ - WAVE_FORMAT_ECHOSC3 = 0x003A, /* Echo Speech Corporation */ - WAVE_FORMAT_ROCKWELL_ADPCM = 0x003B, /* Rockwell International */ - WAVE_FORMAT_ROCKWELL_DIGITALK = 0x003C, /* Rockwell International */ - WAVE_FORMAT_XEBEC = 0x003D, /* Xebec Multimedia Solutions Limited */ - WAVE_FORMAT_G721_ADPCM = 0x0040, /* Antex Electronics Corporation */ - WAVE_FORMAT_G728_CELP = 0x0041, /* Antex Electronics Corporation */ - WAVE_FORMAT_MSG723 = 0x0042, /* Microsoft Corporation */ - WAVE_FORMAT_MPEG = 0x0050, /* Microsoft Corporation */ - WAVE_FORMAT_RT24 = 0x0052, /* InSoft, Inc. */ - WAVE_FORMAT_PAC = 0x0053, /* InSoft, Inc. */ - WAVE_FORMAT_MPEGLAYER3 = 0x0055, /* ISO/MPEG Layer3 Format Tag */ - WAVE_FORMAT_LUCENT_G723 = 0x0059, /* Lucent Technologies */ - WAVE_FORMAT_CIRRUS = 0x0060, /* Cirrus Logic */ - WAVE_FORMAT_ESPCM = 0x0061, /* ESS Technology */ - WAVE_FORMAT_VOXWARE = 0x0062, /* Voxware Inc */ - WAVE_FORMAT_CANOPUS_ATRAC = 0x0063, /* Canopus, co., Ltd. */ - WAVE_FORMAT_G726_ADPCM = 0x0064, /* APICOM */ - WAVE_FORMAT_G722_ADPCM = 0x0065, /* APICOM */ - WAVE_FORMAT_DSAT_DISPLAY = 0x0067, /* Microsoft Corporation */ - WAVE_FORMAT_VOXWARE_BYTE_ALIGNED = 0x0069, /* Voxware Inc */ - WAVE_FORMAT_VOXWARE_AC8 = 0x0070, /* Voxware Inc */ - WAVE_FORMAT_VOXWARE_AC10 = 0x0071, /* Voxware Inc */ - WAVE_FORMAT_VOXWARE_AC16 = 0x0072, /* Voxware Inc */ - WAVE_FORMAT_VOXWARE_AC20 = 0x0073, /* Voxware Inc */ - WAVE_FORMAT_VOXWARE_RT24 = 0x0074, /* Voxware Inc */ - WAVE_FORMAT_VOXWARE_RT29 = 0x0075, /* Voxware Inc */ - WAVE_FORMAT_VOXWARE_RT29HW = 0x0076, /* Voxware Inc */ - WAVE_FORMAT_VOXWARE_VR12 = 0x0077, /* Voxware Inc */ - WAVE_FORMAT_VOXWARE_VR18 = 0x0078, /* Voxware Inc */ - WAVE_FORMAT_VOXWARE_TQ40 = 0x0079, /* Voxware Inc */ - WAVE_FORMAT_SOFTSOUND = 0x0080, /* Softsound, Ltd. */ - WAVE_FORMAT_VOXWARE_TQ60 = 0x0081, /* Voxware Inc */ - WAVE_FORMAT_MSRT24 = 0x0082, /* Microsoft Corporation */ - WAVE_FORMAT_G729A = 0x0083, /* AT&T Labs, Inc. */ - WAVE_FORMAT_MVI_MVI2 = 0x0084, /* Motion Pixels */ - WAVE_FORMAT_DF_G726 = 0x0085, /* DataFusion Systems (Pty) (Ltd) */ - WAVE_FORMAT_DF_GSM610 = 0x0086, /* DataFusion Systems (Pty) (Ltd) */ - WAVE_FORMAT_ISIAUDIO = 0x0088, /* Iterated Systems, Inc. */ - WAVE_FORMAT_ONLIVE = 0x0089, /* OnLive! Technologies, Inc. */ - WAVE_FORMAT_SBC24 = 0x0091, /* Siemens Business Communications Sys */ - WAVE_FORMAT_DOLBY_AC3_SPDIF = 0x0092, /* Sonic Foundry */ - WAVE_FORMAT_MEDIASONIC_G723 = 0x0093, /* MediaSonic */ - WAVE_FORMAT_PROSODY_8KBPS = 0x0094, /* Aculab plc */ - WAVE_FORMAT_ZYXEL_ADPCM = 0x0097, /* ZyXEL Communications, Inc. */ - WAVE_FORMAT_PHILIPS_LPCBB = 0x0098, /* Philips Speech Processing */ - WAVE_FORMAT_PACKED = 0x0099, /* Studer Professional Audio AG */ - WAVE_FORMAT_MALDEN_PHONYTALK = 0x00A0, /* Malden Electronics Ltd. */ - WAVE_FORMAT_RHETOREX_ADPCM = 0x0100, /* Rhetorex Inc. */ - WAVE_FORMAT_IRAT = 0x0101, /* BeCubed Software Inc. */ - WAVE_FORMAT_VIVO_G723 = 0x0111, /* Vivo Software */ - WAVE_FORMAT_VIVO_SIREN = 0x0112, /* Vivo Software */ - WAVE_FORMAT_DIGITAL_G723 = 0x0123, /* Digital Equipment Corporation */ - WAVE_FORMAT_SANYO_LD_ADPCM = 0x0125, /* Sanyo Electric Co., Ltd. */ - WAVE_FORMAT_SIPROLAB_ACEPLNET = 0x0130, /* Sipro Lab Telecom Inc. */ - WAVE_FORMAT_SIPROLAB_ACELP4800 = 0x0131, /* Sipro Lab Telecom Inc. */ - WAVE_FORMAT_SIPROLAB_ACELP8V3 = 0x0132, /* Sipro Lab Telecom Inc. */ - WAVE_FORMAT_SIPROLAB_G729 = 0x0133, /* Sipro Lab Telecom Inc. */ - WAVE_FORMAT_SIPROLAB_G729A = 0x0134, /* Sipro Lab Telecom Inc. */ - WAVE_FORMAT_SIPROLAB_KELVIN = 0x0135, /* Sipro Lab Telecom Inc. */ - WAVE_FORMAT_G726ADPCM = 0x0140, /* Dictaphone Corporation */ - WAVE_FORMAT_QUALCOMM_PUREVOICE = 0x0150, /* Qualcomm, Inc. */ - WAVE_FORMAT_QUALCOMM_HALFRATE = 0x0151, /* Qualcomm, Inc. */ - WAVE_FORMAT_TUBGSM = 0x0155, /* Ring Zero Systems, Inc. */ - WAVE_FORMAT_MSAUDIO1 = 0x0160, /* Microsoft Corporation */ - WAVE_FORMAT_WMAUDIO2 = 0x0161, /* Microsoft Corporation */ - WAVE_FORMAT_WMAUDIO3 = 0x0162, /* Microsoft Corporation */ - WAVE_FORMAT_WMAUDIO_LOSSLESS = 0x0163, /* Microsoft Corporation */ - WAVE_FORMAT_WMASPDIF = 0x0164, /* Microsoft Corporation */ - WAVE_FORMAT_UNISYS_NAP_ADPCM = 0x0170, /* Unisys Corp. */ - WAVE_FORMAT_UNISYS_NAP_ULAW = 0x0171, /* Unisys Corp. */ - WAVE_FORMAT_UNISYS_NAP_ALAW = 0x0172, /* Unisys Corp. */ - WAVE_FORMAT_UNISYS_NAP_16K = 0x0173, /* Unisys Corp. */ - WAVE_FORMAT_CREATIVE_ADPCM = 0x0200, /* Creative Labs, Inc */ - WAVE_FORMAT_CREATIVE_FASTSPEECH8 = 0x0202, /* Creative Labs, Inc */ - WAVE_FORMAT_CREATIVE_FASTSPEECH10 = 0x0203, /* Creative Labs, Inc */ - WAVE_FORMAT_UHER_ADPCM = 0x0210, /* UHER informatic GmbH */ - WAVE_FORMAT_QUARTERDECK = 0x0220, /* Quarterdeck Corporation */ - WAVE_FORMAT_ILINK_VC = 0x0230, /* I-link Worldwide */ - WAVE_FORMAT_RAW_SPORT = 0x0240, /* Aureal Semiconductor */ - WAVE_FORMAT_ESST_AC3 = 0x0241, /* ESS Technology, Inc. */ - WAVE_FORMAT_GENERIC_PASSTHRU = 0x0249, - WAVE_FORMAT_IPI_HSX = 0x0250, /* Interactive Products, Inc. */ - WAVE_FORMAT_IPI_RPELP = 0x0251, /* Interactive Products, Inc. */ - WAVE_FORMAT_CS2 = 0x0260, /* Consistent Software */ - WAVE_FORMAT_SONY_SCX = 0x0270, /* Sony Corp. */ - WAVE_FORMAT_FM_TOWNS_SND = 0x0300, /* Fujitsu Corp. */ - WAVE_FORMAT_BTV_DIGITAL = 0x0400, /* Brooktree Corporation */ - WAVE_FORMAT_QDESIGN_MUSIC = 0x0450, /* QDesign Corporation */ - WAVE_FORMAT_VME_VMPCM = 0x0680, /* AT&T Labs, Inc. */ - WAVE_FORMAT_TPC = 0x0681, /* AT&T Labs, Inc. */ - WAVE_FORMAT_OLIGSM = 0x1000, /* Ing C. Olivetti & C., S.p.A. */ - WAVE_FORMAT_OLIADPCM = 0x1001, /* Ing C. Olivetti & C., S.p.A. */ - WAVE_FORMAT_OLICELP = 0x1002, /* Ing C. Olivetti & C., S.p.A. */ - WAVE_FORMAT_OLISBC = 0x1003, /* Ing C. Olivetti & C., S.p.A. */ - WAVE_FORMAT_OLIOPR = 0x1004, /* Ing C. Olivetti & C., S.p.A. */ - WAVE_FORMAT_LH_CODEC = 0x1100, /* Lernout & Hauspie */ - WAVE_FORMAT_NORRIS = 0x1400, /* Norris Communications, Inc. */ - WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS = 0x1500, /* AT&T Labs, Inc. */ - WAVE_FORMAT_MPEG_ADTS_AAC = 0x1600, /* Microsoft Corporation */ - WAVE_FORMAT_MPEG_RAW_AAC = 0x1601, /* Microsoft Corporation */ - WAVE_FORMAT_MPEG_LOAS = 0x1602, /* Microsoft Corporation (MPEG-4 Audio Transport Streams (LOAS/LATM) */ - WAVE_FORMAT_NOKIA_MPEG_ADTS_AAC = 0x1608, /* Microsoft Corporation */ - WAVE_FORMAT_NOKIA_MPEG_RAW_AAC = 0x1609, /* Microsoft Corporation */ - WAVE_FORMAT_VODAFONE_MPEG_ADTS_AAC = 0x160A, /* Microsoft Corporation */ - WAVE_FORMAT_VODAFONE_MPEG_RAW_AAC = 0x160B, /* Microsoft Corporation */ - WAVE_FORMAT_MPEG_HEAAC = 0x1610, /* Microsoft Corporation (MPEG-2 AAC or MPEG-4 HE-AAC v1/v2 streams with any payload (ADTS, ADIF, LOAS/LATM, RAW). Format block includes MP4 AudioSpecificConfig() -- see HEAACWAVEFORMAT below */ - WAVE_FORMAT_DVM = 0x2000, /* FAST Multimedia AG */ - WAVE_FORMAT_EXTENSIBLE = 0xFFFE /* Microsoft */ - }; -} diff --git a/BrawlLib.LoopSelection/System/Audio/wAudioBuffer.cs b/BrawlLib.LoopSelection/System/Audio/wAudioBuffer.cs deleted file mode 100644 index 78b65ea..0000000 --- a/BrawlLib.LoopSelection/System/Audio/wAudioBuffer.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using DS = BrawlLib.LoopSelection.Win32.DirectSound; - -namespace BrawlLib.LoopSelection -{ - unsafe class wAudioBuffer : AudioBuffer - { - wAudioProvider _parent; - DS.IDirectSoundBuffer8 _dsb8; - - internal override int PlayCursor - { - get { uint pos; _dsb8.GetCurrentPosition(&pos, null); return (int)pos; } - set { _dsb8.SetCurrentPosition((uint)value); } - } - public override int Volume - { - get { int vol; _dsb8.GetVolume(out vol); return vol; } - set { _dsb8.SetVolume(value); } - } - public override int Pan - { - get { int pan; _dsb8.GetPan(out pan); return pan; } - set { _dsb8.SetPan(value); } - } - - //internal wAudioBuffer(wAudioProvider parent, DS.IDirectSoundBuffer8 buffer) { _dsb8 = buffer; } - internal wAudioBuffer(wAudioProvider parent, ref DS.DSBufferDesc desc) - { - _parent = parent; - - if (desc.dwBufferBytes == 0) - return; - - _parent._ds8.CreateSoundBuffer(ref desc, out _dsb8, IntPtr.Zero); - - _format = desc.lpwfxFormat->wFormatTag; - _frequency = (int)desc.lpwfxFormat->nSamplesPerSec; - _channels = desc.lpwfxFormat->nChannels; - _bitsPerSample = desc.lpwfxFormat->wBitsPerSample; - _dataLength = (int)desc.dwBufferBytes; - _blockAlign = _bitsPerSample * _channels / 8; - _sampleLength = _dataLength / _blockAlign; - } - - public override void Dispose() - { - if (_dsb8 != null) - { - Marshal.FinalReleaseComObject(_dsb8); - _dsb8 = null; - } - base.Dispose(); - } - - public override BufferData Lock(int offset, int length) - { - BufferData data = new BufferData(); - uint len1, len2; - IntPtr addr1, addr2; - - offset = offset.Align(_blockAlign); - length = length.Align(_blockAlign); - - data._dataOffset = offset; - data._dataLength = length; - data._sampleOffset = offset / _blockAlign; - data._sampleLength = length / _blockAlign; - - if (length != 0) - { - _dsb8.Lock((uint)offset, (uint)length, out addr1, out len1, out addr2, out len2, 0); - - data._part1Address = addr1; - data._part1Length = (int)len1; - data._part1Samples = (int)len1 / _blockAlign; - - data._part2Address = addr2; - data._part2Length = (int)len2; - data._part2Samples = (int)len2 / _blockAlign; - } - - return data; - } - public override void Unlock(BufferData data) - { - _dsb8.Unlock(data._part1Address, (uint)data._part1Length, data._part2Address, (uint)data._part2Length); - } - - public override void Play() - { - try - { - _dsb8.Play(0, 0, DS.DSBufferPlayFlags.Looping); - } - catch { } - } - public override void Stop() - { - _dsb8.Stop(); - } - } -} diff --git a/BrawlLib.LoopSelection/System/Audio/wAudioDevice.cs b/BrawlLib.LoopSelection/System/Audio/wAudioDevice.cs deleted file mode 100644 index dcd9c45..0000000 --- a/BrawlLib.LoopSelection/System/Audio/wAudioDevice.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -namespace BrawlLib.LoopSelection -{ - unsafe class wAudioDevice : AudioDevice - { - internal Guid _guid; - - private wAudioDevice() { } - private wAudioDevice(Guid guid, string desc, string driver) - { - _guid = guid; - _description = desc; - _driver = driver; - } - - internal static AudioDevice[] PlaybackDevices - { - get - { - List list = new List(); - GCHandle handle = GCHandle.Alloc(list); - try { Win32.DirectSound.DirectSoundEnumerate(EnumCallback, (IntPtr)handle); } - finally { handle.Free(); } - return list.ToArray(); - } - } - internal static AudioDevice DefaultPlaybackDevice - { - get - { - Guid g1 = Win32.DirectSound.DefaultPlaybackGuid, g2; - Win32.DirectSound.GetDeviceID(ref g1, out g2); - wAudioDevice dev = new wAudioDevice() { _guid = g2 }; - - GCHandle handle = GCHandle.Alloc(dev); - try { Win32.DirectSound.DirectSoundEnumerate(EnumCallback, (IntPtr)handle); } - finally { handle.Free(); } - return dev; - } - } - public static AudioDevice DefaultVoicePlaybackDevice - { - get - { - Guid g1 = Win32.DirectSound.DefaultVoicePlaybackGuid, g2; - Win32.DirectSound.GetDeviceID(ref g1, out g2); - wAudioDevice dev = new wAudioDevice() { _guid = g2 }; - - GCHandle handle = GCHandle.Alloc(dev); - try { Win32.DirectSound.DirectSoundEnumerate(EnumCallback, (IntPtr)handle); } - finally { handle.Free(); } - return dev; - } - } - - private static bool EnumCallback(Guid* guid, sbyte* desc, sbyte* module, IntPtr context) - { - if (guid == null) - return true; - - object ctx = ((GCHandle)context).Target; - if (ctx is List) - { - ((List)ctx).Add(new wAudioDevice(*guid, new String(desc), new String(module))); - return true; - } - else if (ctx is wAudioDevice) - { - wAudioDevice dev = ctx as wAudioDevice; - if (*guid == dev._guid) - { - dev._description = new String(desc); - dev._driver = new String(module); - return false; - } - return true; - } - return false; - } - } -} diff --git a/BrawlLib.LoopSelection/System/Audio/wAudioProvider.cs b/BrawlLib.LoopSelection/System/Audio/wAudioProvider.cs deleted file mode 100644 index 73f3cfe..0000000 --- a/BrawlLib.LoopSelection/System/Audio/wAudioProvider.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System.Windows.Forms; -using System.Runtime.InteropServices; -using DS = BrawlLib.LoopSelection.Win32.DirectSound; -using System; - -namespace BrawlLib.LoopSelection -{ - unsafe class wAudioProvider : AudioProvider - { - internal Win32.DirectSound.IDirectSound8 _ds8; - - internal wAudioProvider(AudioDevice device) - { - _device = device == null ? wAudioDevice.DefaultPlaybackDevice : device; - - Guid guid = ((wAudioDevice)_device)._guid; - Win32.DirectSound.DirectSoundCreate8(&guid, out _ds8, IntPtr.Zero); - } - public override void Dispose() - { - base.Dispose(); - if (_ds8 != null) - { - Marshal.FinalReleaseComObject(_ds8); - _ds8 = null; - } - } - - public override void Attach(Control owner) - { - _ds8.SetCooperativeLevel(owner.Handle, Win32.DirectSound.DSCooperativeLevel.Normal); - } - - public override AudioBuffer CreateBuffer(IAudioStream target) - { - int size = AudioBuffer.DefaultBufferSpan * target.Frequency * target.Channels * target.BitsPerSample / 8; - - WaveFormatEx fmt = new WaveFormatEx(target.Format, target.Channels, target.Frequency, target.BitsPerSample); - - DS.DSBufferCapsFlags flags = DS.DSBufferCapsFlags.CtrlVolume | DS.DSBufferCapsFlags.LocDefer | DS.DSBufferCapsFlags.GlobalFocus | DS.DSBufferCapsFlags.GetCurrentPosition2; - DS.DSBufferDesc desc = new DS.DSBufferDesc((uint)size, flags, &fmt, Guid.Empty); - - return new wAudioBuffer(this, ref desc) { _source = target, _owner = this }; - } - - public override string ToString() - { - return "DirectSound 8"; - } - } -} diff --git a/BrawlLib.LoopSelection/System/Int32Extension.cs b/BrawlLib.LoopSelection/System/Int32Extension.cs deleted file mode 100644 index 16f5b95..0000000 --- a/BrawlLib.LoopSelection/System/Int32Extension.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace BrawlLib.LoopSelection -{ - public static class intExtension - { - public static unsafe int Reverse(this int value) - { - return ((value >> 24) & 0xFF) | (value << 24) | ((value >> 8) & 0xFF00) | ((value & 0xFF00) << 8); - } - public static int Align(this int value, int align) - { - if (align == 0) return value; - return (value + align - 1) / align * align; - } - public static int Clamp(this int value, int min, int max) - { - return value <= min ? min : value >= max ? max : value; - } - public static int ClampMin(this int value, int min) - { - return value <= min ? min : value; - } - public static int RoundDownToEven(this int value) - { - return value - (value % 2); - } - public static int RoundUpToEven(this int value) - { - return value + (value % 2); - } - } -} diff --git a/BrawlLib.LoopSelection/System/Memory.cs b/BrawlLib.LoopSelection/System/Memory.cs deleted file mode 100644 index 7c50188..0000000 --- a/BrawlLib.LoopSelection/System/Memory.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace BrawlLib.LoopSelection -{ - public unsafe static class Memory - { - public static unsafe void Move(IntPtr dst, IntPtr src, uint size) - { - byte* from = (byte*)src.ToPointer(); - byte* to = (byte*)dst.ToPointer(); - if (from < to) - for (uint i = size - 1; i >= 0; i--) - to[i] = from[i]; - else if (from > to) - for (uint i = 0; i < size; i++) - to[i] = from[i]; - } - - internal static unsafe void Fill(IntPtr dest, uint length, byte value) - { - byte* to = (byte*)dest.ToPointer(); - for (uint i = 0; i < length; i++) - to[i] = value; - } - } -} diff --git a/BrawlLib.LoopSelection/System/Windows/Controls/CustomTrackBar.cs b/BrawlLib.LoopSelection/System/Windows/Controls/CustomTrackBar.cs deleted file mode 100644 index 9408ef1..0000000 --- a/BrawlLib.LoopSelection/System/Windows/Controls/CustomTrackBar.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Windows.Forms; - -namespace BrawlLib.LoopSelection -{ - public class CustomTrackBar : TrackBar - { - private bool _isScrolling = false; - - public event EventHandler UserSeek; - - new public int Value - { - get { return base.Value; } - set { if (!_isScrolling) base.Value = value; } - } - - protected override void OnMouseDown(MouseEventArgs e) - { - base.OnMouseDown(e); - - if (_isScrolling || (e.Button != MouseButtons.Left)) - return; - - int x = 12, w = Width - 15; - int y = 4, h = 20; - - if ((e.X < x) || (e.X > w) || (e.Y < y) || (e.Y > h)) - return; - - float scale = ((float)e.X - x) / (w - x); - int pos = (int)(Maximum * scale); - - _isScrolling = true; - - if ((base.Value > (pos - 10)) && (base.Value < (pos + 10))) - return; - - base.Value = pos; - - //Send MouseDown message so we can capture the slider. - Message msg = new Message(); - msg.HWnd = this.Handle; - msg.Msg = 0x201; - msg.WParam = (IntPtr)1; - msg.LParam = (IntPtr)((e.Y & 0xFFFF) << 16 | (e.X & 0xFFFF)); - base.WndProc(ref msg); - } - - protected override void OnMouseUp(MouseEventArgs e) - { - if (e.Button != MouseButtons.Left) - return; - - if (_isScrolling) - { - _isScrolling = false; - if (UserSeek != null) - UserSeek(this, null); - } - } - } -} diff --git a/BrawlLib.LoopSelection/System/Windows/Forms/BrstmConverterDialog.cs b/BrawlLib.LoopSelection/System/Windows/Forms/BrstmConverterDialog.cs deleted file mode 100644 index 0ba84e6..0000000 --- a/BrawlLib.LoopSelection/System/Windows/Forms/BrstmConverterDialog.cs +++ /dev/null @@ -1,1017 +0,0 @@ -using System; -using System.ComponentModel; -using System.Windows.Forms; - -namespace BrawlLib.LoopSelection -{ - public class BrstmConverterDialog : Form - { - internal unsafe class InitialStreamWrapper : IAudioStream - { - public readonly IAudioStream BaseStream; - - public InitialStreamWrapper(IAudioStream baseStream) - { - BaseStream = baseStream ?? throw new ArgumentNullException(nameof(baseStream)); - - IsLooping = BaseStream.IsLooping; - LoopStartSample = BaseStream.LoopStartSample; - LoopEndSample = BaseStream.LoopEndSample; - } - - public WaveFormatTag Format => BaseStream.Format; - public int BitsPerSample => BaseStream.BitsPerSample; - public int Samples => BaseStream.Samples; - public int Channels => Math.Min(BaseStream.Channels, 2); - public int Frequency => BaseStream.Frequency; - - public bool IsLooping { get; set; } - public int LoopStartSample { get; set; } - public int LoopEndSample { get; set; } - - public int SamplePosition { - get { - return BaseStream.SamplePosition; - } - set { - BaseStream.SamplePosition = value; - } - } - - public int ReadSamples(IntPtr destAddr, int numSamples) { - if (BaseStream.Channels <= 2) { - return BaseStream.ReadSamples(destAddr, numSamples); - } else { - int r = 0; - short* out_ptr = (short*)destAddr; - short[] buffer = new short[BaseStream.Channels]; - fixed (short* buffer_ptr = buffer) { - while (r < numSamples) { - int q = BaseStream.ReadSamples((IntPtr)buffer_ptr, 1); - r += q; - *out_ptr++ = buffer[0]; - *out_ptr++ = buffer[1]; - if (q == 0) break; - } - } - return r; - } - } - - public void Wrap() { - SamplePosition = LoopStartSample; - } - - public void Dispose() { } - } - - #region Designer - - private Button btnOkay; - private Button btnCancel; - private TextBox txtPath; - private CustomTrackBar customTrackBar1; - private GroupBox groupBox1; - private Label lblText2; - private Label lblText1; - private Label lblPlayTime; - private Button btnPlay; - private Button btnRewind; - private Panel pnlInfo; - private Panel pnlEdit; - private Panel pnlLoop; - private Splitter spltEnd; - private Panel pnlLoopEnd; - private Splitter spltStart; - private Panel pnlLoopStart; - private Label lblStart; - private Label lblEnd; - private NumericUpDown numLoopEnd; - private NumericUpDown numLoopStart; - private GroupBox groupBox2; - private Panel panel3; - private Panel panel4; - private GroupBox grpLoop; - private CheckBox chkLoop; - private CheckBox chkLoopEnable; - private OpenFileDialog dlgOpen; - private Timer tmrUpdate; - private IContainer components; - private Label lblSamples; - private Label lblFrequency; - private Button btnEndSet; - private Button btnStartSet; - private Button btnLoopRW; - private Button btnFFwd; - private Button btnSeekEnd; - private GroupBox groupBox3; - private ComboBox ddlEncoding; - private Label label1; - private Button btnBrowse; - - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.btnOkay = new System.Windows.Forms.Button(); - this.btnCancel = new System.Windows.Forms.Button(); - this.txtPath = new System.Windows.Forms.TextBox(); - this.btnBrowse = new System.Windows.Forms.Button(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.lblSamples = new System.Windows.Forms.Label(); - this.lblFrequency = new System.Windows.Forms.Label(); - this.lblText2 = new System.Windows.Forms.Label(); - this.lblText1 = new System.Windows.Forms.Label(); - this.lblPlayTime = new System.Windows.Forms.Label(); - this.btnPlay = new System.Windows.Forms.Button(); - this.btnRewind = new System.Windows.Forms.Button(); - this.pnlInfo = new System.Windows.Forms.Panel(); - this.panel4 = new System.Windows.Forms.Panel(); - this.pnlEdit = new System.Windows.Forms.Panel(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.btnSeekEnd = new System.Windows.Forms.Button(); - this.btnLoopRW = new System.Windows.Forms.Button(); - this.btnFFwd = new System.Windows.Forms.Button(); - this.chkLoop = new System.Windows.Forms.CheckBox(); - this.pnlLoop = new System.Windows.Forms.Panel(); - this.spltEnd = new System.Windows.Forms.Splitter(); - this.pnlLoopEnd = new System.Windows.Forms.Panel(); - this.spltStart = new System.Windows.Forms.Splitter(); - this.pnlLoopStart = new System.Windows.Forms.Panel(); - this.grpLoop = new System.Windows.Forms.GroupBox(); - this.btnEndSet = new System.Windows.Forms.Button(); - this.btnStartSet = new System.Windows.Forms.Button(); - this.numLoopStart = new System.Windows.Forms.NumericUpDown(); - this.numLoopEnd = new System.Windows.Forms.NumericUpDown(); - this.lblEnd = new System.Windows.Forms.Label(); - this.lblStart = new System.Windows.Forms.Label(); - this.panel3 = new System.Windows.Forms.Panel(); - this.chkLoopEnable = new System.Windows.Forms.CheckBox(); - this.dlgOpen = new System.Windows.Forms.OpenFileDialog(); - this.tmrUpdate = new System.Windows.Forms.Timer(this.components); - this.customTrackBar1 = new BrawlLib.LoopSelection.CustomTrackBar(); - this.groupBox3 = new System.Windows.Forms.GroupBox(); - this.label1 = new System.Windows.Forms.Label(); - this.ddlEncoding = new System.Windows.Forms.ComboBox(); - this.groupBox1.SuspendLayout(); - this.pnlInfo.SuspendLayout(); - this.panel4.SuspendLayout(); - this.pnlEdit.SuspendLayout(); - this.groupBox2.SuspendLayout(); - this.pnlLoop.SuspendLayout(); - this.grpLoop.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numLoopStart)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numLoopEnd)).BeginInit(); - this.panel3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.customTrackBar1)).BeginInit(); - this.groupBox3.SuspendLayout(); - this.SuspendLayout(); - // - // btnOkay - // - this.btnOkay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnOkay.Enabled = false; - this.btnOkay.Location = new System.Drawing.Point(3, 3); - this.btnOkay.Name = "btnOkay"; - this.btnOkay.Size = new System.Drawing.Size(75, 23); - this.btnOkay.TabIndex = 0; - this.btnOkay.Text = "Okay"; - this.btnOkay.UseVisualStyleBackColor = true; - this.btnOkay.Click += new System.EventHandler(this.btnOkay_Click); - // - // btnCancel - // - this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnCancel.Location = new System.Drawing.Point(80, 3); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(75, 23); - this.btnCancel.TabIndex = 1; - this.btnCancel.Text = "Cancel"; - this.btnCancel.UseVisualStyleBackColor = true; - this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); - // - // txtPath - // - this.txtPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtPath.Location = new System.Drawing.Point(0, 0); - this.txtPath.Name = "txtPath"; - this.txtPath.ReadOnly = true; - this.txtPath.Size = new System.Drawing.Size(292, 20); - this.txtPath.TabIndex = 2; - // - // btnBrowse - // - this.btnBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnBrowse.Location = new System.Drawing.Point(297, 0); - this.btnBrowse.Name = "btnBrowse"; - this.btnBrowse.Size = new System.Drawing.Size(25, 20); - this.btnBrowse.TabIndex = 3; - this.btnBrowse.Text = "..."; - this.btnBrowse.UseVisualStyleBackColor = true; - this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.lblSamples); - this.groupBox1.Controls.Add(this.lblFrequency); - this.groupBox1.Controls.Add(this.lblText2); - this.groupBox1.Controls.Add(this.lblText1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 57); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(158, 96); - this.groupBox1.TabIndex = 5; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "File Info"; - // - // lblSamples - // - this.lblSamples.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblSamples.Location = new System.Drawing.Point(84, 36); - this.lblSamples.Name = "lblSamples"; - this.lblSamples.Size = new System.Drawing.Size(68, 20); - this.lblSamples.TabIndex = 3; - this.lblSamples.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // lblFrequency - // - this.lblFrequency.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblFrequency.Location = new System.Drawing.Point(84, 16); - this.lblFrequency.Name = "lblFrequency"; - this.lblFrequency.Size = new System.Drawing.Size(68, 20); - this.lblFrequency.TabIndex = 2; - this.lblFrequency.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // lblText2 - // - this.lblText2.Location = new System.Drawing.Point(6, 36); - this.lblText2.Name = "lblText2"; - this.lblText2.Size = new System.Drawing.Size(72, 20); - this.lblText2.TabIndex = 1; - this.lblText2.Text = "Samples :"; - this.lblText2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // lblText1 - // - this.lblText1.Location = new System.Drawing.Point(6, 16); - this.lblText1.Name = "lblText1"; - this.lblText1.Size = new System.Drawing.Size(72, 20); - this.lblText1.TabIndex = 0; - this.lblText1.Text = "Frequency :"; - this.lblText1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // lblPlayTime - // - this.lblPlayTime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblPlayTime.Location = new System.Drawing.Point(6, 63); - this.lblPlayTime.Name = "lblPlayTime"; - this.lblPlayTime.Size = new System.Drawing.Size(314, 20); - this.lblPlayTime.TabIndex = 6; - this.lblPlayTime.Text = "0 / 0"; - this.lblPlayTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnPlay - // - this.btnPlay.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.btnPlay.Location = new System.Drawing.Point(126, 86); - this.btnPlay.Name = "btnPlay"; - this.btnPlay.Size = new System.Drawing.Size(75, 20); - this.btnPlay.TabIndex = 7; - this.btnPlay.Text = "Play"; - this.btnPlay.UseVisualStyleBackColor = true; - this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click); - // - // btnRewind - // - this.btnRewind.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.btnRewind.Location = new System.Drawing.Point(72, 86); - this.btnRewind.Name = "btnRewind"; - this.btnRewind.Size = new System.Drawing.Size(26, 20); - this.btnRewind.TabIndex = 8; - this.btnRewind.Text = "|<"; - this.btnRewind.UseVisualStyleBackColor = true; - this.btnRewind.Click += new System.EventHandler(this.btnRewind_Click); - // - // pnlInfo - // - this.pnlInfo.Controls.Add(this.groupBox1); - this.pnlInfo.Controls.Add(this.groupBox3); - this.pnlInfo.Controls.Add(this.panel4); - this.pnlInfo.Dock = System.Windows.Forms.DockStyle.Right; - this.pnlInfo.Location = new System.Drawing.Point(326, 0); - this.pnlInfo.Name = "pnlInfo"; - this.pnlInfo.Size = new System.Drawing.Size(158, 182); - this.pnlInfo.TabIndex = 9; - // - // panel4 - // - this.panel4.Controls.Add(this.btnOkay); - this.panel4.Controls.Add(this.btnCancel); - this.panel4.Dock = System.Windows.Forms.DockStyle.Bottom; - this.panel4.Location = new System.Drawing.Point(0, 153); - this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(158, 29); - this.panel4.TabIndex = 6; - // - // pnlEdit - // - this.pnlEdit.Controls.Add(this.groupBox2); - this.pnlEdit.Controls.Add(this.grpLoop); - this.pnlEdit.Controls.Add(this.panel3); - this.pnlEdit.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlEdit.Location = new System.Drawing.Point(0, 0); - this.pnlEdit.Name = "pnlEdit"; - this.pnlEdit.Size = new System.Drawing.Size(326, 182); - this.pnlEdit.TabIndex = 10; - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.btnSeekEnd); - this.groupBox2.Controls.Add(this.btnLoopRW); - this.groupBox2.Controls.Add(this.btnFFwd); - this.groupBox2.Controls.Add(this.chkLoop); - this.groupBox2.Controls.Add(this.lblPlayTime); - this.groupBox2.Controls.Add(this.pnlLoop); - this.groupBox2.Controls.Add(this.btnRewind); - this.groupBox2.Controls.Add(this.btnPlay); - this.groupBox2.Controls.Add(this.customTrackBar1); - this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox2.Location = new System.Drawing.Point(0, 65); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(326, 117); - this.groupBox2.TabIndex = 13; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Playback"; - // - // btnSeekEnd - // - this.btnSeekEnd.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.btnSeekEnd.Location = new System.Drawing.Point(229, 86); - this.btnSeekEnd.Name = "btnSeekEnd"; - this.btnSeekEnd.Size = new System.Drawing.Size(26, 20); - this.btnSeekEnd.TabIndex = 13; - this.btnSeekEnd.Text = ">|"; - this.btnSeekEnd.UseVisualStyleBackColor = true; - this.btnSeekEnd.Click += new System.EventHandler(this.btnSeekEnd_Click); - // - // btnLoopRW - // - this.btnLoopRW.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.btnLoopRW.Enabled = false; - this.btnLoopRW.Location = new System.Drawing.Point(99, 86); - this.btnLoopRW.Name = "btnLoopRW"; - this.btnLoopRW.Size = new System.Drawing.Size(26, 20); - this.btnLoopRW.TabIndex = 12; - this.btnLoopRW.Text = "<"; - this.btnLoopRW.UseVisualStyleBackColor = true; - this.btnLoopRW.Click += new System.EventHandler(this.btnLoopRW_Click); - // - // btnFFwd - // - this.btnFFwd.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.btnFFwd.Enabled = false; - this.btnFFwd.Location = new System.Drawing.Point(202, 86); - this.btnFFwd.Name = "btnFFwd"; - this.btnFFwd.Size = new System.Drawing.Size(26, 20); - this.btnFFwd.TabIndex = 11; - this.btnFFwd.Text = ">"; - this.btnFFwd.UseVisualStyleBackColor = true; - this.btnFFwd.Click += new System.EventHandler(this.btnFFwd_Click); - // - // chkLoop - // - this.chkLoop.Enabled = false; - this.chkLoop.Location = new System.Drawing.Point(10, 86); - this.chkLoop.Name = "chkLoop"; - this.chkLoop.Size = new System.Drawing.Size(52, 20); - this.chkLoop.TabIndex = 10; - this.chkLoop.Text = "Loop"; - this.chkLoop.UseVisualStyleBackColor = true; - this.chkLoop.CheckedChanged += new System.EventHandler(this.chkLoop_CheckedChanged); - // - // pnlLoop - // - this.pnlLoop.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pnlLoop.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); - this.pnlLoop.Controls.Add(this.spltEnd); - this.pnlLoop.Controls.Add(this.pnlLoopEnd); - this.pnlLoop.Controls.Add(this.spltStart); - this.pnlLoop.Controls.Add(this.pnlLoopStart); - this.pnlLoop.Location = new System.Drawing.Point(18, 50); - this.pnlLoop.Name = "pnlLoop"; - this.pnlLoop.Size = new System.Drawing.Size(290, 12); - this.pnlLoop.TabIndex = 9; - this.pnlLoop.Visible = false; - // - // spltEnd - // - this.spltEnd.BackColor = System.Drawing.Color.Red; - this.spltEnd.Dock = System.Windows.Forms.DockStyle.Right; - this.spltEnd.Location = new System.Drawing.Point(287, 0); - this.spltEnd.MinExtra = 0; - this.spltEnd.MinSize = 0; - this.spltEnd.Name = "spltEnd"; - this.spltEnd.Size = new System.Drawing.Size(3, 12); - this.spltEnd.TabIndex = 3; - this.spltEnd.TabStop = false; - // - // pnlLoopEnd - // - this.pnlLoopEnd.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); - this.pnlLoopEnd.Dock = System.Windows.Forms.DockStyle.Right; - this.pnlLoopEnd.Location = new System.Drawing.Point(290, 0); - this.pnlLoopEnd.Name = "pnlLoopEnd"; - this.pnlLoopEnd.Size = new System.Drawing.Size(0, 12); - this.pnlLoopEnd.TabIndex = 2; - this.pnlLoopEnd.SizeChanged += new System.EventHandler(this.pnlLoopEnd_SizeChanged); - // - // spltStart - // - this.spltStart.BackColor = System.Drawing.Color.Yellow; - this.spltStart.Location = new System.Drawing.Point(0, 0); - this.spltStart.MinExtra = 0; - this.spltStart.MinSize = 0; - this.spltStart.Name = "spltStart"; - this.spltStart.Size = new System.Drawing.Size(3, 12); - this.spltStart.TabIndex = 0; - this.spltStart.TabStop = false; - // - // pnlLoopStart - // - this.pnlLoopStart.BackColor = System.Drawing.Color.YellowGreen; - this.pnlLoopStart.Dock = System.Windows.Forms.DockStyle.Left; - this.pnlLoopStart.Location = new System.Drawing.Point(0, 0); - this.pnlLoopStart.Name = "pnlLoopStart"; - this.pnlLoopStart.Size = new System.Drawing.Size(0, 12); - this.pnlLoopStart.TabIndex = 1; - this.pnlLoopStart.SizeChanged += new System.EventHandler(this.pnlLoopStart_SizeChanged); - // - // grpLoop - // - this.grpLoop.Controls.Add(this.btnEndSet); - this.grpLoop.Controls.Add(this.btnStartSet); - this.grpLoop.Controls.Add(this.numLoopStart); - this.grpLoop.Controls.Add(this.numLoopEnd); - this.grpLoop.Controls.Add(this.lblEnd); - this.grpLoop.Controls.Add(this.lblStart); - this.grpLoop.Dock = System.Windows.Forms.DockStyle.Top; - this.grpLoop.Enabled = false; - this.grpLoop.Location = new System.Drawing.Point(0, 20); - this.grpLoop.Name = "grpLoop"; - this.grpLoop.Size = new System.Drawing.Size(326, 45); - this.grpLoop.TabIndex = 15; - this.grpLoop.TabStop = false; - this.grpLoop.Text = "Loop"; - // - // btnEndSet - // - this.btnEndSet.Location = new System.Drawing.Point(289, 19); - this.btnEndSet.Name = "btnEndSet"; - this.btnEndSet.Size = new System.Drawing.Size(15, 20); - this.btnEndSet.TabIndex = 13; - this.btnEndSet.Text = "*"; - this.btnEndSet.UseVisualStyleBackColor = true; - this.btnEndSet.Click += new System.EventHandler(this.btnEndSet_Click); - // - // btnStartSet - // - this.btnStartSet.Location = new System.Drawing.Point(141, 19); - this.btnStartSet.Name = "btnStartSet"; - this.btnStartSet.Size = new System.Drawing.Size(15, 20); - this.btnStartSet.TabIndex = 4; - this.btnStartSet.Text = "*"; - this.btnStartSet.UseVisualStyleBackColor = true; - this.btnStartSet.Click += new System.EventHandler(this.btnStartSet_Click); - // - // numLoopStart - // - this.numLoopStart.Increment = new decimal(new int[] { - 14, - 0, - 0, - 0}); - this.numLoopStart.Location = new System.Drawing.Point(59, 19); - this.numLoopStart.Name = "numLoopStart"; - this.numLoopStart.Size = new System.Drawing.Size(81, 20); - this.numLoopStart.TabIndex = 10; - this.numLoopStart.ValueChanged += new System.EventHandler(this.numLoopStart_ValueChanged); - // - // numLoopEnd - // - this.numLoopEnd.Increment = new decimal(new int[] { - 14, - 0, - 0, - 0}); - this.numLoopEnd.Location = new System.Drawing.Point(207, 19); - this.numLoopEnd.Name = "numLoopEnd"; - this.numLoopEnd.Size = new System.Drawing.Size(81, 20); - this.numLoopEnd.TabIndex = 11; - this.numLoopEnd.ValueChanged += new System.EventHandler(this.numLoopEnd_ValueChanged); - // - // lblEnd - // - this.lblEnd.Location = new System.Drawing.Point(160, 19); - this.lblEnd.Name = "lblEnd"; - this.lblEnd.Size = new System.Drawing.Size(41, 20); - this.lblEnd.TabIndex = 2; - this.lblEnd.Text = "End:"; - this.lblEnd.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // lblStart - // - this.lblStart.Location = new System.Drawing.Point(13, 19); - this.lblStart.Name = "lblStart"; - this.lblStart.Size = new System.Drawing.Size(40, 20); - this.lblStart.TabIndex = 12; - this.lblStart.Text = "Start:"; - this.lblStart.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // panel3 - // - this.panel3.Controls.Add(this.txtPath); - this.panel3.Controls.Add(this.btnBrowse); - this.panel3.Dock = System.Windows.Forms.DockStyle.Top; - this.panel3.Location = new System.Drawing.Point(0, 0); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(326, 20); - this.panel3.TabIndex = 14; - // - // chkLoopEnable - // - this.chkLoopEnable.Location = new System.Drawing.Point(49, 18); - this.chkLoopEnable.Name = "chkLoopEnable"; - this.chkLoopEnable.Size = new System.Drawing.Size(64, 20); - this.chkLoopEnable.TabIndex = 13; - this.chkLoopEnable.Text = "Enable"; - this.chkLoopEnable.UseVisualStyleBackColor = true; - this.chkLoopEnable.CheckedChanged += new System.EventHandler(this.chkLoopEnable_CheckedChanged); - // - // tmrUpdate - // - this.tmrUpdate.Interval = 17; - this.tmrUpdate.Tick += new System.EventHandler(this.tmrUpdate_Tick); - // - // customTrackBar1 - // - this.customTrackBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.customTrackBar1.Location = new System.Drawing.Point(6, 19); - this.customTrackBar1.Name = "customTrackBar1"; - this.customTrackBar1.Size = new System.Drawing.Size(314, 45); - this.customTrackBar1.TabIndex = 4; - this.customTrackBar1.UserSeek += new System.EventHandler(this.customTrackBar1_UserSeek); - this.customTrackBar1.ValueChanged += new System.EventHandler(this.customTrackBar1_ValueChanged); - // - // groupBox3 - // - this.groupBox3.AutoSize = true; - this.groupBox3.Controls.Add(this.ddlEncoding); - this.groupBox3.Controls.Add(this.label1); - this.groupBox3.Dock = System.Windows.Forms.DockStyle.Top; - this.groupBox3.Location = new System.Drawing.Point(0, 0); - this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(158, 57); - this.groupBox3.TabIndex = 4; - this.groupBox3.TabStop = false; - this.groupBox3.Text = "Parameters"; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(6, 16); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(64, 20); - this.label1.TabIndex = 13; - this.label1.Text = "Encoding:"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // ddlEncoding - // - this.ddlEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.ddlEncoding.FormattingEnabled = true; - this.ddlEncoding.Location = new System.Drawing.Point(76, 17); - this.ddlEncoding.Name = "ddlEncoding"; - this.ddlEncoding.Size = new System.Drawing.Size(70, 21); - this.ddlEncoding.TabIndex = 14; - // - // BrstmConverterDialog - // - this.ClientSize = new System.Drawing.Size(484, 182); - this.Controls.Add(this.chkLoopEnable); - this.Controls.Add(this.pnlEdit); - this.Controls.Add(this.pnlInfo); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; - this.MaximizeBox = false; - this.MinimumSize = new System.Drawing.Size(500, 216); - this.Name = "BrstmConverterDialog"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.Text = "Brstm Import"; - this.groupBox1.ResumeLayout(false); - this.pnlInfo.ResumeLayout(false); - this.pnlInfo.PerformLayout(); - this.panel4.ResumeLayout(false); - this.pnlEdit.ResumeLayout(false); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); - this.pnlLoop.ResumeLayout(false); - this.grpLoop.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.numLoopStart)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numLoopEnd)).EndInit(); - this.panel3.ResumeLayout(false); - this.panel3.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.customTrackBar1)).EndInit(); - this.groupBox3.ResumeLayout(false); - this.ResumeLayout(false); - - } - -#endregion - - private string _audioSource; - [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public string AudioSource { get { return _audioSource; } set { _audioSource = value; } } - - private AudioProvider _provider; - private AudioBuffer _buffer; - - private readonly IAudioStream _initialStream; - private IAudioStream _sourceStream; - - private DateTime _sampleTime; - private bool _playing = false; - private bool _updating = false; - - public BrstmConverterDialog(IAudioStream audioStream) - { - _initialStream = audioStream; - this.Text = "Loop Point Definition"; - InitializeComponent(); - tmrUpdate.Interval = 1000 / 60; - MaximumSize = new System.Drawing.Size(int.MaxValue, 216); - } - - new public DialogResult ShowDialog(IWin32Window owner) - { - DialogResult = DialogResult.Cancel; - //try - //{ - return base.ShowDialog(owner); - //} - //catch (Exception x) - //{ - // DisposeProvider(); - // MessageBox.Show(x.ToString()); - // return DialogResult.Cancel; - //} - } - - protected override void OnShown(EventArgs e) - { - if (_provider == null) - { - _provider = AudioProvider.Create(null); - if (_provider != null) - _provider.Attach(this); - else - btnPlay.Enabled = false; - } - - if (_initialStream != null) - { - LoadAudio("Internal audio"); - btnBrowse.Visible = false; - } - else if (_audioSource == null) - { - if (!LoadAudio()) - { - Close(); - return; - } - } - else if (!LoadAudio(_audioSource)) - { - Close(); - return; - } - - base.OnShown(e); - } - protected override void OnClosed(EventArgs e) - { - DisposeProvider(); - base.OnClosed(e); - } - - private void DisposeProvider() - { - DisposeSource(); - if (_provider != null) - { - _provider.Dispose(); - _provider = null; - } - } - private void DisposeSource() - { - //Stop playback - Stop(); - - //Dispose buffer - if (_buffer != null) - { - _buffer.Dispose(); - _buffer = null; - } - - if (_initialStream != _sourceStream) - { - //Dispose stream - if (_sourceStream != null) - { - _sourceStream.Dispose(); - _sourceStream = null; - } - - chkLoopEnable.Checked = chkLoop.Checked = chkLoop.Enabled = false; - } - - btnOkay.Enabled = false; - } - - private bool LoadAudio() - { - if (dlgOpen.ShowDialog(this) != DialogResult.OK) - return false; - return LoadAudio(dlgOpen.FileName); - } - private bool LoadAudio(string path) - { - DisposeSource(); - - //Get audio stream - _sourceStream = new InitialStreamWrapper(_initialStream); - _audioSource = path; - - //Create buffer for stream - if (_provider != null) - { - _buffer = _provider.CreateBuffer(_sourceStream); - _buffer.Loop = chkLoop.Checked; - } - - //Set controls - _sampleTime = new DateTime((long)_sourceStream.Samples * 10000000 / _sourceStream.Frequency); - - txtPath.Text = _initialStream != null ? "Internal audio" : path; - lblFrequency.Text = String.Format("{0} Hz", _sourceStream.Frequency); - lblSamples.Text = String.Format("{0}", _sourceStream.Samples); - - customTrackBar1.Value = 0; - customTrackBar1.TickStyle = TickStyle.None; - customTrackBar1.Maximum = _sourceStream.Samples; - customTrackBar1.TickFrequency = _sourceStream.Samples / 8; - customTrackBar1.TickStyle = TickStyle.BottomRight; - - numLoopStart.Maximum = numLoopEnd.Maximum = _sourceStream.Samples; - if (!_sourceStream.IsLooping) { - numLoopStart.Value = 0; - numLoopEnd.Value = _sourceStream.Samples; - - pnlLoopStart.Width = 0; - pnlLoopEnd.Width = 0; - } else { - numLoopStart.Value = _sourceStream.LoopStartSample; - numLoopEnd.Value = _sourceStream.LoopEndSample; - } - - btnOkay.Enabled = true; - - if (_type == 0) - chkLoopEnable.Checked = true; - - if (_type != 0) - groupBox3.Visible = false; - - if (_initialStream != null) - groupBox3.Visible = false; - - UpdateTimeDisplay(); - - return true; - } - - private void UpdateTimeDisplay() - { - if (_sourceStream != null) - { - DateTime t = new DateTime((long)customTrackBar1.Value * 10000000 / _sourceStream.Frequency); - lblPlayTime.Text = String.Format("{0:mm:ss.ff} / {1:mm:ss.ff}", t, _sampleTime); - } - else - lblPlayTime.Text = ""; - } - - private void Play() - { - if (_playing || (_buffer == null)) - return; - - _playing = true; - - if (customTrackBar1.Value == _sourceStream.Samples) - customTrackBar1.Value = 0; - - _buffer.Seek(customTrackBar1.Value); - - tmrUpdate_Tick(null, null); - tmrUpdate.Start(); - - _buffer.Play(); - - btnPlay.Text = "Stop"; - } - - private void Stop() - { - if (!_playing) - return; - - _playing = false; - - tmrUpdate.Stop(); - - if (_buffer != null) - _buffer.Stop(); - - btnPlay.Text = "Play"; - } - - private void Seek(int sample) - { - customTrackBar1.Value = sample; - - //Only seek the buffer when playing. - if (_playing) - { - Stop(); - _buffer.Seek(sample); - Play(); - } - } - - private void btnPlay_Click(object sender, EventArgs e) - { - if (_playing) - Stop(); - else - Play(); - } - - private void tmrUpdate_Tick(object sender, EventArgs e) - { - if ((_playing) && (_buffer != null)) - { - _buffer.Fill(); - - customTrackBar1.Value = _buffer.ReadSample; - - if (_buffer.ReadSample >= _sourceStream.Samples) - Stop(); - } - } - - private void btnRewind_Click(object sender, EventArgs e) { Seek(0); } - private void customTrackBar1_ValueChanged(object sender, EventArgs e) { UpdateTimeDisplay(); } - private void customTrackBar1_UserSeek(object sender, EventArgs e) { Seek(customTrackBar1.Value); } - - private void pnlLoopStart_SizeChanged(object sender, EventArgs e) - { - if ((_sourceStream == null) || (_updating)) - return; - - //Get approximate sample number from start of audio. - float percent = (float)pnlLoopStart.Width / pnlLoop.Width; - - //Should we align to a chunk, or block? - int startSample = (int)(_sourceStream.Samples * percent); - - _updating = true; - numLoopStart.Value = startSample; - _updating = false; - } - - private void pnlLoopEnd_SizeChanged(object sender, EventArgs e) - { - if ((_sourceStream == null) || (_updating)) - return; - - //Get approximate sample number from start of audio. - float percent = 1.0f - ((float)pnlLoopEnd.Width / pnlLoop.Width); - - //End sample doesn't need to be aligned - int endSample = (int)(_sourceStream.Samples * percent); - - _updating = true; - numLoopEnd.Value = endSample; - _updating = false; - } - - private void btnCancel_Click(object sender, EventArgs e) { Close(); } - - public int Type { get { return _type; } set { _type = value; Text = String.Format("{0} Import", _type == 0 ? "Brstm" : "Wave"); } } - public int _type = 0; - - private void btnOkay_Click(object sender, EventArgs e) - { - Stop(); - - if (_sourceStream is InitialStreamWrapper w && w.BaseStream == _initialStream) - { - _initialStream.LoopStartSample = _sourceStream.LoopStartSample; - _initialStream.LoopEndSample = _sourceStream.LoopEndSample; - _initialStream.IsLooping = _sourceStream.IsLooping; - } - DialogResult = DialogResult.OK; - Close(); - } - - private void chkLoop_CheckedChanged(object sender, EventArgs e) - { - if (_buffer != null) - _buffer.Loop = chkLoop.Checked; - } - - private void chkLoopEnable_CheckedChanged(object sender, EventArgs e) - { - pnlLoop.Visible = grpLoop.Enabled = chkLoop.Enabled = btnFFwd.Enabled = btnLoopRW.Enabled = chkLoopEnable.Checked; - if (!chkLoopEnable.Checked) - chkLoop.Checked = false; - - if (_sourceStream != null) - { - if (chkLoopEnable.Checked) - { - _sourceStream.IsLooping = true; - _sourceStream.LoopStartSample = (int)numLoopStart.Value; - _sourceStream.LoopEndSample = (int)numLoopEnd.Value; - } - else - { - _sourceStream.IsLooping = false; - _sourceStream.LoopStartSample = 0; - _sourceStream.LoopEndSample = 0; - } - } - } - - private void numLoopStart_ValueChanged(object sender, EventArgs e) - { - if (_sourceStream == null) - return; - - if (!_updating) - { - float percent = (float)numLoopStart.Value / _sourceStream.Samples; - - _updating = true; - pnlLoopStart.Width = (int)(pnlLoop.Width * percent); - _updating = false; - } - - if (_sourceStream.IsLooping) - _sourceStream.LoopStartSample = (int)numLoopStart.Value; - } - - private void numLoopEnd_ValueChanged(object sender, EventArgs e) - { - if (_sourceStream == null) - return; - - if (!_updating) - { - float percent = 1.0f - ((float)numLoopEnd.Value / _sourceStream.Samples); - - _updating = true; - pnlLoopEnd.Width = (int)(pnlLoop.Width * percent); - _updating = false; - } - - if (_sourceStream.IsLooping) - _sourceStream.LoopEndSample = (int)numLoopEnd.Value; - } - - private void btnBrowse_Click(object sender, EventArgs e) { LoadAudio(); } - private void btnStartSet_Click(object sender, EventArgs e) { numLoopStart.Value = customTrackBar1.Value; } - private void btnEndSet_Click(object sender, EventArgs e) { numLoopEnd.Value = customTrackBar1.Value; } - private void btnLoopRW_Click(object sender, EventArgs e) { Seek((int)numLoopStart.Value); } - private void btnFFwd_Click(object sender, EventArgs e) { Seek((int)numLoopEnd.Value); } - private void btnSeekEnd_Click(object sender, EventArgs e) { Seek(customTrackBar1.Maximum); } - - } -} diff --git a/BrawlLib.LoopSelection/System/Windows/Forms/BrstmConverterDialog.resx b/BrawlLib.LoopSelection/System/Windows/Forms/BrstmConverterDialog.resx deleted file mode 100644 index 23b342e..0000000 --- a/BrawlLib.LoopSelection/System/Windows/Forms/BrstmConverterDialog.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 116, 17 - - \ No newline at end of file diff --git a/LoopingAudioConverter.sln b/LoopingAudioConverter.sln index d372ff7..12450ec 100644 --- a/LoopingAudioConverter.sln +++ b/LoopingAudioConverter.sln @@ -1,54 +1,30 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2010 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31911.196 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoopingAudioConverter", "LoopingAudioConverter\LoopingAudioConverter.csproj", "{DB459B2F-C6AC-46C6-8CEE-653090772F0D}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VorbisCommentSharp", "VorbisCommentSharp\VorbisCommentSharp.csproj", "{5BD4854F-481B-4AA6-B838-32C21B2B069F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BrawlLib.LoopSelection", "BrawlLib.LoopSelection\BrawlLib.LoopSelection.csproj", "{41C94979-CE5A-4582-888A-1BEE98DD43D3}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSFContainerLib", "MSFContainerLib\MSFContainerLib.csproj", "{31BD3716-2D0B-49E4-A0E8-2C4E0ADD93F5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DB459B2F-C6AC-46C6-8CEE-653090772F0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DB459B2F-C6AC-46C6-8CEE-653090772F0D}.Debug|Any CPU.Build.0 = Debug|Any CPU {DB459B2F-C6AC-46C6-8CEE-653090772F0D}.Debug|x86.ActiveCfg = Debug|x86 {DB459B2F-C6AC-46C6-8CEE-653090772F0D}.Debug|x86.Build.0 = Debug|x86 - {DB459B2F-C6AC-46C6-8CEE-653090772F0D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DB459B2F-C6AC-46C6-8CEE-653090772F0D}.Release|Any CPU.Build.0 = Release|Any CPU {DB459B2F-C6AC-46C6-8CEE-653090772F0D}.Release|x86.ActiveCfg = Release|x86 {DB459B2F-C6AC-46C6-8CEE-653090772F0D}.Release|x86.Build.0 = Release|x86 - {5BD4854F-481B-4AA6-B838-32C21B2B069F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5BD4854F-481B-4AA6-B838-32C21B2B069F}.Debug|Any CPU.Build.0 = Debug|Any CPU {5BD4854F-481B-4AA6-B838-32C21B2B069F}.Debug|x86.ActiveCfg = Debug|Any CPU {5BD4854F-481B-4AA6-B838-32C21B2B069F}.Debug|x86.Build.0 = Debug|Any CPU - {5BD4854F-481B-4AA6-B838-32C21B2B069F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5BD4854F-481B-4AA6-B838-32C21B2B069F}.Release|Any CPU.Build.0 = Release|Any CPU {5BD4854F-481B-4AA6-B838-32C21B2B069F}.Release|x86.ActiveCfg = Release|Any CPU {5BD4854F-481B-4AA6-B838-32C21B2B069F}.Release|x86.Build.0 = Release|Any CPU - {41C94979-CE5A-4582-888A-1BEE98DD43D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {41C94979-CE5A-4582-888A-1BEE98DD43D3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {41C94979-CE5A-4582-888A-1BEE98DD43D3}.Debug|x86.ActiveCfg = Debug|x86 - {41C94979-CE5A-4582-888A-1BEE98DD43D3}.Debug|x86.Build.0 = Debug|x86 - {41C94979-CE5A-4582-888A-1BEE98DD43D3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {41C94979-CE5A-4582-888A-1BEE98DD43D3}.Release|Any CPU.Build.0 = Release|Any CPU - {41C94979-CE5A-4582-888A-1BEE98DD43D3}.Release|x86.ActiveCfg = Release|x86 - {41C94979-CE5A-4582-888A-1BEE98DD43D3}.Release|x86.Build.0 = Release|x86 - {31BD3716-2D0B-49E4-A0E8-2C4E0ADD93F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {31BD3716-2D0B-49E4-A0E8-2C4E0ADD93F5}.Debug|Any CPU.Build.0 = Debug|Any CPU {31BD3716-2D0B-49E4-A0E8-2C4E0ADD93F5}.Debug|x86.ActiveCfg = Debug|Any CPU {31BD3716-2D0B-49E4-A0E8-2C4E0ADD93F5}.Debug|x86.Build.0 = Debug|Any CPU - {31BD3716-2D0B-49E4-A0E8-2C4E0ADD93F5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {31BD3716-2D0B-49E4-A0E8-2C4E0ADD93F5}.Release|Any CPU.Build.0 = Release|Any CPU {31BD3716-2D0B-49E4-A0E8-2C4E0ADD93F5}.Release|x86.ActiveCfg = Release|Any CPU {31BD3716-2D0B-49E4-A0E8-2C4E0ADD93F5}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection diff --git a/LoopingAudioConverter/About.html b/LoopingAudioConverter/About.html index 14652bf..a9c7474 100644 --- a/LoopingAudioConverter/About.html +++ b/LoopingAudioConverter/About.html @@ -1,4 +1,4 @@ - + @@ -6,7 +6,7 @@ -

Looping Audio Converter 2.4

+

Looping Audio Converter 2.5

This application acts as a frontend to other programs and libraries, and allows conversion between a variety of looping audio formats.
@@ -16,181 +16,177 @@

Looping Audio Converter 2.4

- + - - + - + - - + - - + - - - - - - + - - + - - + - - - - + - - + - - + - - + - - + - + - - + - - - + - + - + - + - - - - + - - + - - + + + + + + + - +
File extensionFile extension Container(s) Decoder Supports looping
.wav
+
.wav
.lwav
WAVERIFF WAVE LoopingAudioConverter
.bfstm.bfstm BFSTMVGAudio
.bcstm.bcstm BCSTMVGAudio
.brstm.brstm BRSTMVGAudio
.brwav
+
.brwav
.rwav
BRWAVVGAudio
.bcwav
+
.bcwav
.cwav
BCWAVVGAudio
.bfwav.bfwav BFWAVVGAudio
.bcstp.bcstp BCSTPVGAudio
.bfstp.bfstp BFSTPVGAudio
.dsp
+
.dsp
.mdsp
DSP (Nintendo)VGAudio
.idsp.idsp Interleaved DSP (Nintendo)VGAudio
.hps.hps HPS (HAL)VGAudio
.adx.adx CRI ADXVGAudio
.hca.hca CRI HCAVGAudio
.mp3.mp3 MP3 MP3Sharp
.aac.aac AACfaad
.m4a.m4a MP4faad
.vgm
+
.vgm
.vgz
VGM VGMPlay
.pcm.pcm MSU-1 LoopingAudioConverter
.msf.msf MSF (PlayStation 3) – PCM MSFContainerLib
.msf.msf MSF (PlayStation 3) – MP3 MSFContainerLib + MP3Sharp
.msf.msf MSF (PlayStation 3) – Othervgmstream
.ogg
+
.ogg
.logg
Oggvgmstream
.flac.flac FLACvgmstream
.*.* Miscellaneousvgmstream
.*.*
+
Miscellaneous
+
ffmpeg
+

+
.* Miscellaneous SoX
+
@@ -198,7 +194,7 @@

Looping Audio Converter 2.4

- + @@ -206,92 +202,117 @@

Looping Audio Converter 2.4

- - + - - + - + - - + - + - - - + - - - + - - + - - + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - - - + - + @@ -299,17 +320,17 @@

Looping Audio Converter 2.4

- + - - + - + @@ -336,7 +357,11 @@

Looping Audio Converter 2.4

  • Only files ending with: This option will remove any file not ending with the given extension from the list when you click Filter. Useful after you use the "add folder" button to - add all files in a folder, recursively.
    + add all files in a folder, recursively.
  • +
  • Input directory: Used in conjunction with the "Add + Folder" workflow; allows Looping Audio Converter to more + accurately mirror the structure of subdirectories under the + original input directory.
  • Output directory
    • @@ -376,13 +401,13 @@

      Looping Audio Converter 2.4

      non-looping (including VGM, BRSTM, etc.) or lack loop information (MP3, usually WAV) will result in a non-looping output. -
    • Ask: The audio import dialog from BrawlBox will be +
    • Ask: The audio import dialog from BrawlCrate will be shown for each input file without loop information after decoding so you can specify your own loop point.
    • Ask for all files: The audio import dialog from - BrawlBox will be shown for all input files. For looping files, - the loop point will be pre-populated.
      + BrawlCrate will be shown for all input files. For looping + files, the loop point will be pre-populated.
  • Channel export options
  • @@ -436,6 +461,9 @@

    Looping Audio Converter 2.4

    allows Looping Audio Converter to skip re-encoding audio in certain circumstances:
      +
    • + A BrawlLib B*STM output format is used and the input format is also B*STM +
    • A VGAudio output format is used and VGAudio also supports the input format
    • @@ -453,7 +481,7 @@

      Looping Audio Converter 2.4

      operation. The default value (recommended) is the number of logical processor cores in your PC.
    • Load Options and Save Options: These buttons - allow you to load and save the options listed above to a .ini + allow you to load and save the options listed above to an .xml file. If there is a file in the current directory named LoopingAudioConverter.xml when the program starts, it will try to load options from this file automatically.
    • diff --git a/LoopingAudioConverter/Exporters/BrawlLibRSTMExporter.cs b/LoopingAudioConverter/Exporters/BrawlLibRSTMExporter.cs new file mode 100644 index 0000000..c769de6 --- /dev/null +++ b/LoopingAudioConverter/Exporters/BrawlLibRSTMExporter.cs @@ -0,0 +1,83 @@ +using BrawlLib.Internal.IO; +using BrawlLib.Internal.Windows.Forms; +using BrawlLib.SSBB.Types.Audio; +using BrawlLib.Wii.Audio; +using System; +using System.IO; +using System.Threading.Tasks; + +namespace LoopingAudioConverter { + public class BrawlLibRSTMExporter : IAudioExporter { + public enum Container { RSTM, CSTM, FSTM } + + public class SilentProgressTracker : IProgressTracker { + public float MinValue { get; set; } + public float MaxValue { get; set; } + public float CurrentValue { get; set; } + public bool Cancelled { get; set; } + + public void Begin(float min, float max, float current) { } + + public void Cancel() => throw new NotImplementedException(); + + public void Finish() { } + + public void Update(float value) { } + } + + private readonly WaveEncoding _waveEncoding; + private readonly Container _container; + + public BrawlLibRSTMExporter(WaveEncoding waveEncoding, Container container) { + _waveEncoding = waveEncoding; + _container = container; + } + + private unsafe byte[] Encode(PCM16Audio lwav) { + using (var ms = new MemoryStream()) { + var wrapper = new PCM16LoopWrapper(lwav); + + using (var fileMap = RSTMConverter.Encode(wrapper, new SilentProgressTracker(), _waveEncoding)) + using (var inputStream = new UnmanagedMemoryStream((byte*)fileMap.Address.address, fileMap.Length)) { + inputStream.CopyTo(ms); + } + + return ms.ToArray(); + } + } + + private byte[] Read(PCM16Audio lwav) { + string orig_path = lwav.OriginalPath?.ToLowerInvariant() ?? ""; + if (orig_path.EndsWith(".brstm")) { + return File.ReadAllBytes(orig_path); + } else if (orig_path.EndsWith(".bcstm")) { + return CSTMConverter.ToRSTM(File.ReadAllBytes(orig_path)); + } else if (orig_path.EndsWith(".bfstm")) { + return FSTMConverter.ToRSTM(File.ReadAllBytes(orig_path)); + } else { + return Encode(lwav); + } + } + + public void WriteFile(PCM16Audio lwav, string output_dir, string original_filename_no_ext) { + byte[] data = Read(lwav); + string ext = ".brstm"; + if (_container == Container.CSTM) { + data = CSTMConverter.FromRSTM(data); + ext = ".bcstm"; + } + if (_container == Container.FSTM) { + data = FSTMConverter.FromRSTM(data); + ext = ".bfstm"; + } + File.WriteAllBytes( + Path.Combine(output_dir, original_filename_no_ext + ext), + data); + } + + async Task IAudioExporter.WriteFileAsync(PCM16Audio lwav, string output_dir, string original_filename_no_ext) { + await Task.Yield(); + await Task.Run(() => WriteFile(lwav, output_dir, original_filename_no_ext)); + } + } +} diff --git a/LoopingAudioConverter/Exporters/BrawlLibRWAVExporter.cs b/LoopingAudioConverter/Exporters/BrawlLibRWAVExporter.cs new file mode 100644 index 0000000..02fffd3 --- /dev/null +++ b/LoopingAudioConverter/Exporters/BrawlLibRWAVExporter.cs @@ -0,0 +1,22 @@ +using BrawlLib.Wii.Audio; +using System.IO; +using System.Threading.Tasks; + +namespace LoopingAudioConverter { + public class BrawlLibRWAVExporter : IAudioExporter { + public unsafe void WriteFile(PCM16Audio lwav, string output_dir, string original_filename_no_ext) { + string outputPath = Path.Combine(output_dir, original_filename_no_ext + ".brwav"); + var wrapper = new PCM16LoopWrapper(lwav); + + using (var fileMap = RWAVConverter.Encode(wrapper, null)) + using (var inputStream = new UnmanagedMemoryStream((byte*)fileMap.Address.address, fileMap.Length)) + using (var outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write)) { + inputStream.CopyTo(outputStream); + } + } + + Task IAudioExporter.WriteFileAsync(PCM16Audio lwav, string output_dir, string original_filename_no_ext) { + return Task.Run(() => WriteFile(lwav, output_dir, original_filename_no_ext)); + } + } +} diff --git a/LoopingAudioConverter/Exporters/MP3Exporter.cs b/LoopingAudioConverter/Exporters/MP3Exporter.cs index 6af550e..16cc74e 100644 --- a/LoopingAudioConverter/Exporters/MP3Exporter.cs +++ b/LoopingAudioConverter/Exporters/MP3Exporter.cs @@ -1,4 +1,6 @@ -using RunProcessAsTask; +using MSFContainerLib; +using RunProcessAsTask; +using System; using System.Diagnostics; using System.IO; using System.Threading.Tasks; @@ -19,6 +21,15 @@ public async Task WriteFileAsync(PCM16Audio lwav, string output_dir, string orig throw new AudioExporterException("Invalid character (\") found in output filename"); } + if (Path.GetExtension(lwav.OriginalPath ?? "").Equals(".msf", StringComparison.InvariantCultureIgnoreCase)) { + byte[] data = File.ReadAllBytes(lwav.OriginalPath); + IPcmAudioSource msf = MSF.Parse(data); + if (msf is MSF_MP3 mp3) { + File.WriteAllBytes(outPath, mp3.Body); + return; + } + } + string infile = TempFiles.Create("wav"); File.WriteAllBytes(infile, lwav.Export()); diff --git a/LoopingAudioConverter/Interfaces.cs b/LoopingAudioConverter/Interfaces.cs index ceaa92e..e09fa3c 100644 --- a/LoopingAudioConverter/Interfaces.cs +++ b/LoopingAudioConverter/Interfaces.cs @@ -21,6 +21,7 @@ public interface IRenderingAudioImporter : IAudioImporter { } public interface IEffectEngine { + string GetImporterName(); PCM16Audio ApplyEffects(PCM16Audio lwav, int channels = int.MaxValue, decimal db = 0, decimal amplitude = 1, int rate = int.MaxValue, decimal pitch_semitones = 0, decimal tempo_ratio = 1); Task WriteFileAsync(PCM16Audio lwav, string output_filename, string encodingParameters); } diff --git a/LoopingAudioConverter/LoopingAudioConverter.csproj b/LoopingAudioConverter/LoopingAudioConverter.csproj index 887ea77..157f88a 100644 --- a/LoopingAudioConverter/LoopingAudioConverter.csproj +++ b/LoopingAudioConverter/LoopingAudioConverter.csproj @@ -40,30 +40,17 @@ - - true - bin\Debug\ - DEBUG;TRACE - true - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - - - bin\Release\ - TRACE - true - true - pdbonly - AnyCPU - prompt - MinimumRecommendedRules.ruleset - + + False + ..\lib\BrawlLib.dll + ..\packages\MP3Sharp.1.0.5\lib\netstandard2.0\MP3Sharp.dll + + ..\lib\OpenTK.dll + ..\packages\RunProcessAsTask.1.2.4\lib\net45\RunProcessAsTask.dll @@ -82,6 +69,8 @@ + + @@ -187,10 +176,6 @@ - - {41c94979-ce5a-4582-888a-1bee98dd43d3} - BrawlLib.LoopSelection - {31bd3716-2d0b-49e4-a0e8-2c4e0add93f5} MSFContainerLib diff --git a/LoopingAudioConverter/Options.cs b/LoopingAudioConverter/Options.cs index a34d470..3718c38 100644 --- a/LoopingAudioConverter/Options.cs +++ b/LoopingAudioConverter/Options.cs @@ -1,11 +1,7 @@ -using LoopingAudioConverter.VGAudioOptions; -using System; +using BrawlLib.SSBB.Types.Audio; +using LoopingAudioConverter.VGAudioOptions; using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; using System.Xml.Serialization; -using VGAudio.Containers.NintendoWare; namespace LoopingAudioConverter { public enum ExporterType { @@ -17,6 +13,11 @@ public enum ExporterType { HPS, HCA, ADX, + BrawlLib_BRSTM_ADPCM, + BrawlLib_BRSTM_PCM16, + BrawlLib_BCSTM, + BrawlLib_BFSTM, + BrawlLib_BRWAV, MSF_PCM16LE, MSF_PCM16BE, MSU1, @@ -66,6 +67,7 @@ public class Options { public AdxOptions AdxOptions { get; set; } public HcaOptions HcaOptions { get; set; } public BxstmOptions BxstmOptions { get; set; } + public WaveEncoding? WaveEncoding { get; set; } public UnknownLoopBehavior UnknownLoopBehavior { get; set; } public bool ExportWholeSong { get; set; } public string WholeSongSuffix { get; set; } diff --git a/LoopingAudioConverter/OptionsForm.Designer.cs b/LoopingAudioConverter/OptionsForm.Designer.cs index 7f4ffd0..30fa30f 100644 --- a/LoopingAudioConverter/OptionsForm.Designer.cs +++ b/LoopingAudioConverter/OptionsForm.Designer.cs @@ -762,8 +762,6 @@ private void InitializeComponent() { // chkShortCircuit // this.chkShortCircuit.AutoSize = true; - this.chkShortCircuit.Checked = true; - this.chkShortCircuit.CheckState = System.Windows.Forms.CheckState.Checked; this.chkShortCircuit.Location = new System.Drawing.Point(233, 192); this.chkShortCircuit.Name = "chkShortCircuit"; this.chkShortCircuit.Size = new System.Drawing.Size(259, 17); diff --git a/LoopingAudioConverter/OptionsForm.cs b/LoopingAudioConverter/OptionsForm.cs index ab2c510..6f34275 100644 --- a/LoopingAudioConverter/OptionsForm.cs +++ b/LoopingAudioConverter/OptionsForm.cs @@ -1,4 +1,5 @@ -using LoopingAudioConverter.VGAudioOptions; +using BrawlLib.SSBB.Types.Audio; +using LoopingAudioConverter.VGAudioOptions; using System; using System.Collections.Generic; using System.ComponentModel; @@ -43,6 +44,8 @@ public string private AdxOptions adxOptions = new AdxOptions(); private BxstmOptions bxstmOptions = new BxstmOptions(); + private WaveEncoding waveEncoding = 0; + public IEnumerable RunningTasks { get { return runningTasks; @@ -57,27 +60,38 @@ public OptionsForm() { hcaOptions = new HcaOptions(); adxOptions = new AdxOptions(); + string effectEngineName = Program.BuildImporters() + .OfType() + .Select(x => x.GetImporterName()) + .DefaultIfEmpty("???") + .First(); + var exporters = new[] { - new NVPair(ExporterType.BRSTM, "BRSTM"), - new NVPair(ExporterType.BCSTM, "BCSTM"), - new NVPair(ExporterType.BFSTM, "BFSTM"), - new NVPair(ExporterType.DSP, "DSP (Nintendo)"), - new NVPair(ExporterType.IDSP, "IDSP (Nintendo)"), - new NVPair(ExporterType.HPS, "HPS (HAL)"), - new NVPair(ExporterType.ADX, "CRI ADX"), - new NVPair(ExporterType.HCA, "CRI HCA"), + new NVPair(ExporterType.BRSTM, "[VGAudio] BRSTM"), + new NVPair(ExporterType.BCSTM, "[VGAudio] BCSTM"), + new NVPair(ExporterType.BFSTM, "[VGAudio] BFSTM"), + new NVPair(ExporterType.DSP, "[VGAudio] DSP (Nintendo)"), + new NVPair(ExporterType.IDSP, "[VGAudio] IDSP (Nintendo)"), + new NVPair(ExporterType.HPS, "[VGAudio] HPS (HAL)"), + new NVPair(ExporterType.ADX, "[VGAudio] CRI ADX"), + new NVPair(ExporterType.HCA, "[VGAudio] CRI HCA"), + new NVPair(ExporterType.BrawlLib_BRSTM_ADPCM, "[BrawlLib] BRSTM (ADPCM)"), + new NVPair(ExporterType.BrawlLib_BRSTM_PCM16, "[BrawlLib] BRSTM (PCM16)"), + new NVPair(ExporterType.BrawlLib_BCSTM, "[BrawlLib] BCSTM (ADPCM)"), + new NVPair(ExporterType.BrawlLib_BFSTM, "[BrawlLib] BFSTM (ADPCM)"), + new NVPair(ExporterType.BrawlLib_BRWAV, "[BrawlLib] BRWAV (ADPCM)"), new NVPair(ExporterType.MSF_PCM16BE, "MSF (PCM16, big-endian)"), new NVPair(ExporterType.MSF_PCM16LE, "MSF (PCM16, little-endian)"), new NVPair(ExporterType.MSU1, "MSU-1"), new NVPair(ExporterType.WAV, "WAV"), - new NVPair(ExporterType.FLAC, "FLAC"), - new NVPair(ExporterType.FFmpeg_MP3, "MP3"), - new NVPair(ExporterType.MP3, "MP3 [LAME]"), - new NVPair(ExporterType.FFmpeg_AAC_M4A, "AAC (.m4a)"), - new NVPair(ExporterType.AAC_M4A, "AAC (.m4a) [qaac]"), - new NVPair(ExporterType.FFmpeg_AAC_ADTS, "AAC (ADTS .aac)"), - new NVPair(ExporterType.AAC_ADTS, "AAC (ADTS .aac) [qaac]"), - new NVPair(ExporterType.OggVorbis, "Vorbis (.ogg)"), + new NVPair(ExporterType.FLAC, $"[{effectEngineName}] FLAC"), + new NVPair(ExporterType.FFmpeg_MP3, $"[{effectEngineName}] MP3"), + new NVPair(ExporterType.FFmpeg_AAC_M4A, $"[{effectEngineName}] AAC (.m4a)"), + new NVPair(ExporterType.FFmpeg_AAC_ADTS, $"[{effectEngineName}] AAC (ADTS .aac)"), + new NVPair(ExporterType.OggVorbis, $"[{effectEngineName}] Vorbis (.ogg)"), + new NVPair(ExporterType.MP3, "[LAME] MP3"), + new NVPair(ExporterType.AAC_M4A, "[qaac] AAC (.m4a)"), + new NVPair(ExporterType.AAC_ADTS, "[qaac] AAC (ADTS .aac)"), }; comboBox1.DataSource = exporters; if (comboBox1.SelectedIndex < 0) comboBox1.SelectedIndex = 0; @@ -172,6 +186,7 @@ public void LoadOptions(string filename) { hcaOptions = o.HcaOptions ?? new HcaOptions(); adxOptions = o.AdxOptions ?? new AdxOptions(); bxstmOptions = o.BxstmOptions ?? new BxstmOptions(); + waveEncoding = o.WaveEncoding ?? WaveEncoding.ADPCM; ddlUnknownLoopBehavior.SelectedValue = o.UnknownLoopBehavior; chk0End.Checked = o.ExportWholeSong; txt0EndFilenamePattern.Text = o.WholeSongSuffix; @@ -215,6 +230,7 @@ public Options GetOptions() { HcaOptions = hcaOptions, AdxOptions = adxOptions, BxstmOptions = bxstmOptions, + WaveEncoding = waveEncoding, UnknownLoopBehavior = (UnknownLoopBehavior)ddlUnknownLoopBehavior.SelectedValue, ExportWholeSong = chk0End.Checked, WholeSongSuffix = txt0EndFilenamePattern.Text, diff --git a/LoopingAudioConverter/PCM16LoopWrapper.cs b/LoopingAudioConverter/PCM16LoopWrapper.cs index 137d322..f799ab1 100644 --- a/LoopingAudioConverter/PCM16LoopWrapper.cs +++ b/LoopingAudioConverter/PCM16LoopWrapper.cs @@ -1,4 +1,5 @@ -using BrawlLib.LoopSelection; +using BrawlLib.Internal; +using BrawlLib.Internal.Audio; using System; using System.Runtime.InteropServices; @@ -7,8 +8,8 @@ namespace LoopingAudioConverter { /// A wrapper for PCM16Audio to conform to BrawlLib's IAudioStream interface. /// IAudioStream maintains a "current position" in the audio stream, while PCM16Audio does not, so this class handles SamplePosition, Wrap, and ReadSamples. /// - class PCM16LoopWrapper : IAudioStream { - private PCM16Audio lwav; + public class PCM16LoopWrapper : IAudioStream { + private readonly PCM16Audio lwav; public PCM16LoopWrapper(PCM16Audio lwav) { this.lwav = lwav; @@ -56,6 +57,8 @@ public int ReadSamples(IntPtr destAddr, int numSamples) { return numSamples; } + unsafe int IAudioStream.ReadSamples(VoidPtr destAddr, int numSamples) => ReadSamples(destAddr, numSamples); + public int SamplePosition { get; set; } public int Samples => lwav.Samples.Length / lwav.Channels; diff --git a/LoopingAudioConverter/Program.cs b/LoopingAudioConverter/Program.cs index 933495a..b606283 100644 --- a/LoopingAudioConverter/Program.cs +++ b/LoopingAudioConverter/Program.cs @@ -1,4 +1,5 @@ -using BrawlLib.LoopSelection; +using BrawlLib.Internal.Windows.Forms; +using BrawlLib.SSBB.Types.Audio; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -50,6 +51,24 @@ static void Main(string[] args) { } } + public static IEnumerable BuildImporters() { + yield return new WAVImporter(); + yield return new VGAudioImporter(); + yield return new MP3Importer(); + if (ConfigurationManager.AppSettings["faad_path"] is string faad_path) + yield return new MP4Importer(faad_path); + if (ConfigurationManager.AppSettings["vgmplay_path"] is string vgmplay_path) + yield return new VGMImporter(vgmplay_path); + yield return new MSU1(); + yield return new MSFImporter(); + if (ConfigurationManager.AppSettings["vgmstream_path"] is string vgmstream_path) + yield return new VGMStreamImporter(vgmstream_path); + if (ConfigurationManager.AppSettings["ffmpeg_path"] is string ffmpeg_path) + yield return new FFmpeg(ffmpeg_path); + if (ConfigurationManager.AppSettings["sox_path"] is string sox_path) + yield return new SoX(sox_path); + } + /// /// Runs a batch conversion process. /// @@ -60,25 +79,7 @@ public static async Task RunAsync(Options o, bool showEndDialog = true, IWin32Wi "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } - IEnumerable buildImporters() { - yield return new WAVImporter(); - yield return new VGAudioImporter(); - yield return new MP3Importer(); - if (ConfigurationManager.AppSettings["faad_path"] is string faad_path) - yield return new MP4Importer(faad_path); - if (ConfigurationManager.AppSettings["vgmplay_path"] is string vgmplay_path) - yield return new VGMImporter(vgmplay_path); - yield return new MSU1(); - yield return new MSFImporter(); - if (ConfigurationManager.AppSettings["vgmstream_path"] is string vgmstream_path) - yield return new VGMStreamImporter(vgmstream_path); - if (ConfigurationManager.AppSettings["ffmpeg_path"] is string ffmpeg_path) - yield return new FFmpeg(ffmpeg_path); - if (ConfigurationManager.AppSettings["sox_path"] is string sox_path) - yield return new SoX(sox_path); - } - - List importers = buildImporters().ToList(); + List importers = BuildImporters().ToList(); IEffectEngine effectEngine = importers.OfType().FirstOrDefault() ?? throw new AudioImporterException("Could not find either ffmpeg or SoX - please specify ffmpeg_path or sox_path in .config file"); @@ -100,6 +101,16 @@ IAudioExporter getExporter() { return new HCAExporter(o.HcaOptions?.Configuration); case ExporterType.ADX: return new ADXExporter(o.AdxOptions?.Configuration); + case ExporterType.BrawlLib_BRSTM_ADPCM: + return new BrawlLibRSTMExporter(WaveEncoding.ADPCM, BrawlLibRSTMExporter.Container.RSTM); + case ExporterType.BrawlLib_BRSTM_PCM16: + return new BrawlLibRSTMExporter(WaveEncoding.PCM16, BrawlLibRSTMExporter.Container.RSTM); + case ExporterType.BrawlLib_BCSTM: + return new BrawlLibRSTMExporter(WaveEncoding.ADPCM, BrawlLibRSTMExporter.Container.CSTM); + case ExporterType.BrawlLib_BFSTM: + return new BrawlLibRSTMExporter(WaveEncoding.ADPCM, BrawlLibRSTMExporter.Container.FSTM); + case ExporterType.BrawlLib_BRWAV: + return new BrawlLibRWAVExporter(); case ExporterType.MSF_PCM16BE: return new MSFPCM16Exporter(big_endian: true); case ExporterType.MSF_PCM16LE: diff --git a/LoopingAudioConverter/Properties/AssemblyInfo.cs b/LoopingAudioConverter/Properties/AssemblyInfo.cs index ed3e469..8fbcb7c 100644 --- a/LoopingAudioConverter/Properties/AssemblyInfo.cs +++ b/LoopingAudioConverter/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LoopingAudioConverter")] -[assembly: AssemblyCopyright("Copyright © 2020 libertyernie")] +[assembly: AssemblyCopyright("Copyright © 2021 libertyernie")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.4.0.0")] -[assembly: AssemblyFileVersion("2.4.0.0")] +[assembly: AssemblyVersion("2.5.0.0")] +[assembly: AssemblyFileVersion("2.5.0.0")] diff --git a/lib/BrawlLib.dll b/lib/BrawlLib.dll new file mode 100644 index 0000000..28c5811 Binary files /dev/null and b/lib/BrawlLib.dll differ diff --git a/lib/OpenTK.dll b/lib/OpenTK.dll new file mode 100644 index 0000000..afff0dd Binary files /dev/null and b/lib/OpenTK.dll differ diff --git a/lib/OpenTK.dll.config b/lib/OpenTK.dll.config new file mode 100644 index 0000000..2d48c0e --- /dev/null +++ b/lib/OpenTK.dll.config @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file
    File extensionFile extension Container(s) Codec(s) Encoder
    .wav
    +
    .wav
    .lwav
    WAVERIFF WAVE 16-bit PCM (little endian) LoopingAudioConverter
    .bfstm
    +
    .bfstm
    .bcstm
    .brstm
    BFSTM
    BCSTM
    BRSTM
    ADPCM (Nintendo)
    - 16-bit PCM (big endian)
    - 16-bit PCM (little endian)
    + 16-bit PCM
    8-bit PCM
    VGAudioVGAudio
    .dsp.dsp DSP (Nintendo)ADPCM (Nintendo)VGAudioADPCM (Nintendo)
    .idsp.idsp DSP (Nintendo) (interleaved)ADPCM (Nintendo)VGAudio
    .hps.hps HPS (HAL)ADPCM (Nintendo)VGAudio
    .adx.adx CRI ADXVGAudio
    .hca.hca CRI HCAVGAudio
    .mp3.brstm
    +
    BRSTM
    +
    ADPCM (Nintendo)
    + 16-bit PCM (big endian)
    +
    BrawlLib
    +
    .bcstm
    +
    BCSTM
    +
    ADPCM (Nintendo)
    .bfstm
    +
    BFSTM
    +
    .brwav
    +
    BRWAV
    +
    .mp3 MP3 lame
    .aac.aac AACAACqaacAACqaac
    .m4a.m4a MP4AACqaac
    .pcm.pcm MSU-1 16-bit PCM (little endian) LoopingAudioConverter
    .msf.msf MSF (PlayStation 3) 16-bit PCM (big endian)
    16-bit PCM (little endian)
    .ogg.ogg Ogg VorbisSoX + ffmpeg or SoX + VorbisCommentSharp
    .flac.flac FLACSoXffmpeg or SoX