diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29..0000000 diff --git a/Assets/Plugins/Lame-For-Unity.meta b/Assets/Plugins/Lame-For-Unity.meta new file mode 100644 index 0000000..4d3f86e --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9fdecf5167b152f419b5b53d1f150689 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Assets.meta b/Assets/Plugins/Lame-For-Unity/Assets.meta new file mode 100644 index 0000000..88e8bb2 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Assets.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0c3a72dd354f8cc4bb9d1daf86beb4ad +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/LICENSE b/Assets/Plugins/Lame-For-Unity/LICENSE new file mode 100644 index 0000000..e6901a7 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 wangzhen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Assets/Plugins/Lame-For-Unity/LICENSE.meta b/Assets/Plugins/Lame-For-Unity/LICENSE.meta new file mode 100644 index 0000000..80a6211 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/LICENSE.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b1e233138ad623f4a8fa1bd59018f4f4 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame.asmdef b/Assets/Plugins/Lame-For-Unity/Lame.asmdef new file mode 100644 index 0000000..d7619ec --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame.asmdef @@ -0,0 +1,3 @@ +{ + "name": "Lame" +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame.asmdef.meta b/Assets/Plugins/Lame-For-Unity/Lame.asmdef.meta new file mode 100644 index 0000000..7f7cb80 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a22e31da5d6009e499a237fb7d439ebc +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame.meta b/Assets/Plugins/Lame-For-Unity/Lame.meta new file mode 100644 index 0000000..cc68480 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3c50e02b0bbd99240bcdd496b6af62c4 +folderAsset: yes +timeCreated: 1493112996 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/ExtendUtility.cs b/Assets/Plugins/Lame-For-Unity/Lame/ExtendUtility.cs new file mode 100644 index 0000000..9396a4c --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/ExtendUtility.cs @@ -0,0 +1,16 @@ +using System.IO; + +public static class ExtendUtility +{ + // Only useful before .NET 4 + public static void CopyTo(this Stream input, Stream output) + { + byte[] buffer = new byte[16 * 1024]; // Fairly arbitrary size + int bytesRead; + + while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0) + { + output.Write(buffer, 0, bytesRead); + } + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/ExtendUtility.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/ExtendUtility.cs.meta new file mode 100644 index 0000000..a7eddb4 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/ExtendUtility.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fb12997fe1438df428b9bca708076dea +timeCreated: 1493119352 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/LibMp3Lame.cs b/Assets/Plugins/Lame-For-Unity/Lame/LibMp3Lame.cs new file mode 100644 index 0000000..041c583 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/LibMp3Lame.cs @@ -0,0 +1,1888 @@ +#region MIT license +// +// MIT license +// +// Copyright (c) 2013 Corey Murtagh +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#endregion +#region Attributions +// +// Contents of the LibMp3Lame.NativeMethods class and associated enumerations +// are directly based on the lame.h v1.190, available at: +// http://lame.cvs.sourceforge.net/viewvc/lame/lame/include/lame.h?revision=1.190&content-type=text%2Fplain +// +// Source lines and comments included where useful/possible. +// +#endregion +using System; +using System.Runtime.InteropServices; +using System.Text; +using AOT; + +namespace NAudio.Lame +{ + /// LAME encoding presets + public enum LAMEPreset : int + { + /*values from 8 to 320 should be reserved for abr bitrates*/ + /*for abr I'd suggest to directly use the targeted bitrate as a value*/ + + /// 8-kbit ABR + ABR_8 = 8, + /// 16-kbit ABR + ABR_16 = 16, + /// 32-kbit ABR + ABR_32 = 32, + /// 48-kbit ABR + ABR_48 = 48, + /// 64-kbit ABR + ABR_64 = 64, + /// 96-kbit ABR + ABR_96 = 96, + /// 128-kbit ABR + ABR_128 = 128, + /// 160-kbit ABR + ABR_160 = 160, + /// 256-kbit ABR + ABR_256 = 256, + /// 320-kbit ABR + ABR_320 = 320, + + /*Vx to match Lame and VBR_xx to match FhG*/ + /// VBR Quality 9 + V9 = 410, + /// FhG: VBR Q10 + VBR_10 = 410, + /// VBR Quality 8 + V8 = 420, + /// FhG: VBR Q20 + VBR_20 = 420, + /// VBR Quality 7 + V7 = 430, + /// FhG: VBR Q30 + VBR_30 = 430, + /// VBR Quality 6 + V6 = 440, + /// FhG: VBR Q40 + VBR_40 = 440, + /// VBR Quality 5 + V5 = 450, + /// FhG: VBR Q50 + VBR_50 = 450, + /// VBR Quality 4 + V4 = 460, + /// FhG: VBR Q60 + VBR_60 = 460, + /// VBR Quality 3 + V3 = 470, + /// FhG: VBR Q70 + VBR_70 = 470, + /// VBR Quality 2 + V2 = 480, + /// FhG: VBR Q80 + VBR_80 = 480, + /// VBR Quality 1 + V1 = 490, + /// FhG: VBR Q90 + VBR_90 = 490, + /// VBR Quality 0 + V0 = 500, + /// FhG: VBR Q100 + VBR_100 = 500, + + /*still there for compatibility*/ + /// R3Mix quality - + R3MIX = 1000, + /// Standard Quality + STANDARD = 1001, + /// Extreme Quality + EXTREME = 1002, + /// Insane Quality + INSANE = 1003, + /// Fast Standard Quality + STANDARD_FAST = 1004, + /// Fast Extreme Quality + EXTREME_FAST = 1005, + /// Medium Quality + MEDIUM = 1006, + /// Fast Medium Quality + MEDIUM_FAST = 1007 + } +} + +namespace NAudio.Lame.DLL +{ + /// MPEG channel mode + public enum MPEGMode : uint + { + /// Stereo + Stereo = 0, + /// Joint Stereo + // JointStereo = 1, + DualChannel = 2, + // LAME does not support this + /// Mono + Mono = 3, + /// Undefined + NotSet = 4 + } + + + /// Assembler optimizations + public enum ASMOptimizations : uint + { + /// Use MMX instructions + MMX = 1, + /// Use AMD 3DNow instructions + AMD_3DNow = 2, + /// Use SSE instructions + SSE = 3 + } + + /// + /// Variable BitRate Mode + /// + public enum VBRMode : uint + { + /// No VBR (Constant Bitrate) + Off = 0, + /// MT Algorithm (Mark Taylor). Now same as MTRH + MT, + /// RH Algorithm (Roger Hegemann) + RH, + /// ABR - Average Bitrate + ABR, + /// MTRH Algorithm (Mark Taylor & Roger Hegemann)( + MTRH, + /// Default algorithm: MTRH + Default = MTRH + } + + /// MPEG wrapper version + public enum MPEGVersion : int + { + /// MPEG 2 + MPEG2 = 0, + /// MPEG 1 + MPEG1 = 1, + /// MPEG 2.5 + MPEG2_5 = 2 + } + + /// LAME DLL version information + [StructLayout(LayoutKind.Sequential)] + public class LAMEVersion + { + /* generic LAME version */ + /// LAME library major version + public int major; + /// LAME library minor version + public int minor; + /// LAME library 'Alpha' version flag + [MarshalAs(UnmanagedType.Bool)] + public bool alpha; + /// LAME library 'Beta' version flag + [MarshalAs(UnmanagedType.Bool)] + public bool beta; + + /// Psychoacoustic code major version + public int psy_major; + /// Psychoacoustic code minor version + public int psy_minor; + /// Psychoacoustic code 'Alpha' version flag + [MarshalAs(UnmanagedType.Bool)] + public bool psy_alpha; + /// Psychoacoustic code 'Beta' version flag + [MarshalAs(UnmanagedType.Bool)] + public bool psy_beta; + + /* compile time features */ + // const char *features; /* Don't make assumptions about the contents! */ + private IntPtr features_ptr = IntPtr.Zero; + + /// Compile-time features string + public string features + { + get + { + if (features_ptr != IntPtr.Zero) + return Marshal.PtrToStringAuto(features_ptr); + return null; + } + } + } + + /// LAME interface class + public class LibMp3Lame : IDisposable + { + /// Constructor + public LibMp3Lame() + { + context = NativeMethods.lame_init(); + //InitReportFunctions(); + } + + /// Destructor + ~LibMp3Lame() + { + Dispose(true); + } + + /// Dispose of object + public void Dispose() + { + Dispose(false); + } + + /// Clean up object, closing LAME context if present + /// True if called from destructor, else false + protected virtual void Dispose(bool final) + { + if (context != IntPtr.Zero) + { + NativeMethods.lame_close(context); + context = IntPtr.Zero; + } + } + + #region LAME context handle + + private IntPtr context = IntPtr.Zero; + + #endregion + + #region DLL version data + + /// Lame Version + public static string LameVersion { get { return NativeMethods.get_lame_version(); } } + + /// Lame Short Version + public static string LameShortVersion { get { return NativeMethods.get_lame_short_version(); } } + + /// Lame Very Short Version + public static string LameVeryShortVersion { get { return NativeMethods.get_lame_very_short_version(); } } + + /// Lame Psychoacoustic Version + public static string LamePsychoacousticVersion { get { return NativeMethods.get_psy_version(); } } + + /// Lame URL + public static string LameURL { get { return NativeMethods.get_lame_url(); } } + + /// Lame library bit width - 32 or 64 bit + public static string LameOSBitness { get { return NativeMethods.get_lame_os_bitness(); } } + + /// Get LAME version information + /// LAME version structure + public static LAMEVersion GetLameVersion() + { + LAMEVersion ver = new LAMEVersion(); + NativeMethods.get_lame_version_numerical(ver); + return ver; + } + + #endregion + + #region Properties + + delegate int setFunc(IntPtr p, T val); + + // wrapper function to simplify calling lame_set_* entry points + void setter(setFunc f, T value, string name = null) + { + int res = f(context, value); + if (res != 0) + { + if (string.IsNullOrEmpty(name)) + name = f.Method.Name; + throw new Exception(string.Format("libmp3lame: {0}({1}) returned error code: {2}", name, value, res)); + } + } + + #region Input Stream Description + + /// Number of samples (optional) + public UInt64 NumSamples + { + get { return NativeMethods.lame_get_num_samples(context); } + set { setter(NativeMethods.lame_set_num_samples, value); } + } + + /// Input sample rate + public int InputSampleRate + { + get { return NativeMethods.lame_get_in_samplerate(context); } + set { setter(NativeMethods.lame_set_in_samplerate, value); } + } + + /// Number of channels + public int NumChannels + { + get { return NativeMethods.lame_get_num_channels(context); } + set { setter(NativeMethods.lame_set_num_channels, value); } + } + + /// Global amplification factor + public float Scale + { + get { return NativeMethods.lame_get_scale(context); } + set { setter(NativeMethods.lame_set_scale, value); } + } + + /// Left channel amplification + public float ScaleLeft + { + get { return NativeMethods.lame_get_scale_left(context); } + set { setter(NativeMethods.lame_set_scale_left, value); } + } + + /// Right channel amplification + public float ScaleRight + { + get { return NativeMethods.lame_get_scale_right(context); } + set { setter(NativeMethods.lame_set_scale_right, value); } + } + + /// Output sample rate + public int OutputSampleRate + { + get { return NativeMethods.lame_get_out_samplerate(context); } + set { setter(NativeMethods.lame_set_out_samplerate, value); } + } + + #endregion + + #region General Control Parameters + + /// Enable analysis + public bool Anaylysis + { + get { return NativeMethods.lame_get_analysis(context); } + set { setter(NativeMethods.lame_set_analysis, value); } + } + + /// Write VBR tag to MP3 file + public bool WriteVBRTag + { + get { return NativeMethods.lame_get_bWriteVbrTag(context) != 0; } + set { setter(NativeMethods.lame_set_bWriteVbrTag, value ? 1 : 0); } + } + + /// + public bool DecodeOnly + { + get { return NativeMethods.lame_get_decode_only(context) != 0; } + set { setter(NativeMethods.lame_set_decode_only, value ? 1 : 0); } + } + + /// Encoding quality + public int Quality + { + get { return NativeMethods.lame_get_quality(context); } + set { setter(NativeMethods.lame_set_quality, value); } + } + + /// Specify MPEG channel mode, or use best guess if false + public MPEGMode Mode + { + get { return NativeMethods.lame_get_mode(context); } + set { setter(NativeMethods.lame_set_mode, value); } + } + + /// Force M/S mode + public bool ForceMS + { + get { return NativeMethods.lame_get_force_ms(context); } + set { setter(NativeMethods.lame_set_force_ms, value); } + } + + /// Use free format + public bool UseFreeFormat + { + get { return NativeMethods.lame_get_free_format(context); } + set { setter(NativeMethods.lame_set_free_format, value); } + } + + /// Perform replay gain analysis + public bool FindReplayGain + { + get { return NativeMethods.lame_get_findReplayGain(context); } + set { setter(NativeMethods.lame_set_findReplayGain, value); } + } + + /// Decode on the fly. Search for the peak sample. If the ReplayGain analysis is enabled then perform the analysis on the decoded data stream. + public bool DecodeOnTheFly + { + get { return NativeMethods.lame_get_decode_on_the_fly(context); } + set { setter(NativeMethods.lame_set_decode_on_the_fly, value); } + } + + /// Counters for gapless encoding + public int NoGapTotal + { + get { return NativeMethods.lame_get_nogap_total(context); } + set { setter(NativeMethods.lame_set_nogap_total, value); } + } + + /// Counters for gapless encoding + public int NoGapCurrentIndex + { + get { return NativeMethods.lame_get_nogap_currentindex(context); } + set { setter(NativeMethods.lame_set_nogap_currentindex, value); } + } + + /// Output bitrate + public int BitRate + { + get { return NativeMethods.lame_get_brate(context); } + set { setter(NativeMethods.lame_set_brate, value); } + } + + /// Output compression ratio + public float CompressionRatio + { + get { return NativeMethods.lame_get_compression_ratio(context); } + set { setter(NativeMethods.lame_set_compression_ratio, value); } + } + + /// Set compression preset + public bool SetPreset(LAMEPreset preset) + { + int res = NativeMethods.lame_set_preset(context, preset); + return res == 0; + } + + /// Enable/Disable optimizations + public bool SetOptimization(ASMOptimizations opt, bool enabled) + { + int res = NativeMethods.lame_set_asm_optimizations(context, opt, enabled); + return res == 0; + } + + #endregion + + #region Frame parameters + + /// Set output Copyright flag + public bool Copyright + { + get { return NativeMethods.lame_get_copyright(context); } + set { setter(NativeMethods.lame_set_copyright, value); } + } + + /// Set output Original flag + public bool Original + { + get { return NativeMethods.lame_get_original(context); } + set { setter(NativeMethods.lame_set_original, value); } + } + + /// Set error protection. Uses 2 bytes from each frame for CRC checksum + public bool ErrorProtection + { + get { return NativeMethods.lame_get_error_protection(context); } + set { setter(NativeMethods.lame_set_error_protection, value); } + } + + /// MP3 'private extension' bit. Meaningless. + public bool Extension + { + get { return NativeMethods.lame_get_extension(context); } + set { setter(NativeMethods.lame_set_extension, value); } + } + + /// Enforce strict ISO compliance. + public bool StrictISO + { + get { return NativeMethods.lame_get_strict_ISO(context); } + set { setter(NativeMethods.lame_set_strict_ISO, value); } + } + + #endregion + + #region Quantization/Noise Shaping + + /// Disable the bit reservoir. + public bool DisableReservoir { get { return NativeMethods.lame_get_disable_reservoir(context); } set { setter(NativeMethods.lame_set_disable_reservoir, value); } } + + /// Set a different "best quantization" function + public int QuantComp { get { return NativeMethods.lame_get_quant_comp(context); } set { setter(NativeMethods.lame_set_quant_comp, value); } } + + /// Set a different "best quantization" function + public int QuantCompShort { get { return NativeMethods.lame_get_quant_comp_short(context); } set { setter(NativeMethods.lame_set_quant_comp_short, value); } } + + /// Set a different "best quantization" function + public int ExperimentalX { get { return NativeMethods.lame_get_experimentalX(context); } set { setter(NativeMethods.lame_set_experimentalX, value); } } + + /// Set a different "best quantization" function + public int ExperimentalY { get { return NativeMethods.lame_get_experimentalY(context); } set { setter(NativeMethods.lame_set_experimentalY, value); } } + + /// Set a different "best quantization" function + public int ExperimentalZ { get { return NativeMethods.lame_get_experimentalZ(context); } set { setter(NativeMethods.lame_set_experimentalZ, value); } } + + /// Set a different "best quantization" function + public int ExperimentalNSPsyTune { get { return NativeMethods.lame_get_exp_nspsytune(context); } set { setter(NativeMethods.lame_set_exp_nspsytune, value); } } + + /// Set a different "best quantization" function + public int MSFix { get { return NativeMethods.lame_get_msfix(context); } set { setter(NativeMethods.lame_set_msfix, value); } } + + #endregion + + #region VBR Control + + /// Set VBR mode + public VBRMode VBR { get { return NativeMethods.lame_get_VBR(context); } set { setter(NativeMethods.lame_set_VBR, value); } } + + /// VBR quality level. 0 = highest, 9 = lowest. + public int VBRQualityLevel { get { return NativeMethods.lame_get_VBR_q(context); } set { setter(NativeMethods.lame_set_VBR_q, value); } } + + /// VBR quality level. 0 = highest, 9 = lowest + public float VBRQuality { get { return NativeMethods.lame_get_VBR_quality(context); } set { setter(NativeMethods.lame_set_VBR_quality, value); } } + + /// ABR average bitrate + public int VBRMeanBitrateKbps { get { return NativeMethods.lame_get_VBR_mean_bitrate_kbps(context); } set { setter(NativeMethods.lame_set_VBR_mean_bitrate_kbps, value); } } + + /// ABR minimum bitrate + public int VBRMinBitrateKbps { get { return NativeMethods.lame_get_VBR_min_bitrate_kbps(context); } set { setter(NativeMethods.lame_set_VBR_min_bitrate_kbps, value); } } + + /// ABR maximum bitrate + public int VBRMaxBitrateKbps { get { return NativeMethods.lame_get_VBR_max_bitrate_kbps(context); } set { setter(NativeMethods.lame_set_VBR_max_bitrate_kbps, value); } } + + /// Strictly enforce minimum bitrate. Normall it will be violated for analog silence. + public bool VBRHardMin { get { return NativeMethods.lame_get_VBR_hard_min(context); } set { setter(NativeMethods.lame_set_VBR_hard_min, value); } } + + #endregion + + #region Filtering control + +#pragma warning disable 1591 + public int LowPassFreq { get { return NativeMethods.lame_get_lowpassfreq(context); } set { setter(NativeMethods.lame_set_lowpassfreq, value); } } + + public int LowPassWidth { get { return NativeMethods.lame_get_lowpasswidth(context); } set { setter(NativeMethods.lame_set_lowpasswidth, value); } } + + public int HighPassFreq { get { return NativeMethods.lame_get_highpassfreq(context); } set { setter(NativeMethods.lame_set_highpassfreq, value); } } + + public int HighPassWidth { get { return NativeMethods.lame_get_highpasswidth(context); } set { setter(NativeMethods.lame_set_highpasswidth, value); } } +#pragma warning restore 1591 + #endregion + + #region Internal state variables, read only + +#pragma warning disable 1591 + public MPEGVersion Version { get { return NativeMethods.lame_get_version(context); } } + + public int EncoderDelay { get { return NativeMethods.lame_get_encoder_delay(context); } } + + public int EncoderPadding { get { return NativeMethods.lame_get_encoder_padding(context); } } + + public int MFSamplesToEncode { get { return NativeMethods.lame_get_mf_samples_to_encode(context); } } + + public int MP3BufferSize { get { return NativeMethods.lame_get_size_mp3buffer(context); } } + + public int FrameNumber { get { return NativeMethods.lame_get_frameNum(context); } } + + public int TotalFrames { get { return NativeMethods.lame_get_totalframes(context); } } + + public int RadioGain { get { return NativeMethods.lame_get_RadioGain(context); } } + + public int AudiophileGain { get { return NativeMethods.lame_get_AudiophileGain(context); } } + + public float PeakSample { get { return NativeMethods.lame_get_PeakSample(context); } } + + public int NoClipGainChange { get { return NativeMethods.lame_get_noclipGainChange(context); } } + + public float NoClipScale { get { return NativeMethods.lame_get_noclipScale(context); } } +#pragma warning restore 1591 + #endregion + + #endregion + + #region Methods + + /// Initialize encoder with parameters + /// Success/fail + public bool InitParams() + { + if (context == IntPtr.Zero) + throw new InvalidOperationException("InitParams called without initializing context"); + int res = NativeMethods.lame_init_params(context); + return res == 0; + } + + /// Write 16-bit integer PCM samples to encoder + /// PCM sample data. Interleaved for stereo. + /// Number of valid samples. + /// Buffer to write encoded data to + /// Size of buffer. + /// True if mono, false if stereo. + /// Number of bytes of encoded data written to output buffer. + public int Write(short[] samples, int nSamples, byte[] output, int outputSize, bool mono) + { + int rc = -1; + if (mono) + rc = NativeMethods.lame_encode_buffer(context, samples, samples, nSamples, output, outputSize); + else + rc = NativeMethods.lame_encode_buffer_interleaved(context, samples, nSamples / 2, output, outputSize); + + return rc; + } + + // float + /// Write 32-bit floating point PCM samples to encoder + /// PCM sample data. Interleaved for stereo. + /// Number of valid samples. + /// Buffer to write encoded data to + /// Size of buffer. + /// True if mono, false if stereo. + /// Number of bytes of encoded data written to output buffer. + public int Write(float[] samples, int nSamples, byte[] output, int outputSize, bool mono) + { + int rc = -1; + if (mono) + rc = NativeMethods.lame_encode_buffer_ieee_float(context, samples, samples, nSamples, output, outputSize); + else + rc = NativeMethods.lame_encode_buffer_interleaved_ieee_float(context, samples, nSamples / 2, output, outputSize); + return rc; + } + + /// Flush encoder output + /// Buffer to write encoded data to + /// Size of buffer. + /// Number of bytes of encoded data written to output buffer. + public int Flush(byte[] output, int outputSize) + { + int res = NativeMethods.lame_encode_flush(context, output, outputSize); + return Math.Max(0, res); + } + + #endregion + + internal static class NativeMethods + { +#if UNITY_EDITOR + #if UNITY_EDITOR_OSX + const string libname = @"__Internal"; + #else + const string libname = @"libmp3lame.dll"; + #endif +#elif UNITY_IOS + const string libname = @"__Internal"; +#elif UNITY_ANDROID + const string libname = @"mp3lame"; +#else + const string libname = @"libmp3lame.dll"; +#endif + + // typedef void (*lame_report_function)(const char *format, va_list ap); + + #region Startup/Shutdown + + /* + * REQUIRED: + * initialize the encoder. sets default for all encoder parameters, + * returns NULL if some malloc()'s failed + * otherwise returns pointer to structure needed for all future + * API calls. + */ + // lame_global_flags * CDECL lame_init(void); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern IntPtr lame_init(); + + /* + * REQUIRED: + * final call to free all remaining buffers + */ + // int CDECL lame_close (lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_close(IntPtr context); + + #endregion + + #region LAME information + + /* + * OPTIONAL: + * get the version number, in a string. of the form: + * "3.63 (beta)" or just "3.63". + */ + // const char* CDECL get_lame_version ( void ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern string get_lame_version(); + // const char* CDECL get_lame_short_version ( void ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern string get_lame_short_version(); + // const char* CDECL get_lame_very_short_version ( void ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern string get_lame_very_short_version(); + // const char* CDECL get_psy_version ( void ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern string get_psy_version(); + // const char* CDECL get_lame_url ( void ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern string get_lame_url(); + // const char* CDECL get_lame_os_bitness ( void ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern string get_lame_os_bitness(); + + // void CDECL get_lame_version_numerical(lame_version_t *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern void get_lame_version_numerical([Out]LAMEVersion ver); + + #endregion + + #region Input Stream Description + + /* number of samples. default = 2^32-1 */ + // int CDECL lame_set_num_samples(lame_global_flags *, unsigned long); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_num_samples(IntPtr context, UInt64 num_samples); + // unsigned long CDECL lame_get_num_samples(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern UInt64 lame_get_num_samples(IntPtr context); + + /* input sample rate in Hz. default = 44100hz */ + // int CDECL lame_set_in_samplerate(lame_global_flags *, int); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_in_samplerate(IntPtr context, int value); + // int CDECL lame_get_in_samplerate(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_in_samplerate(IntPtr context); + + /* number of channels in input stream. default=2 */ + //int CDECL lame_set_num_channels(lame_global_flags *, int); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_num_channels(IntPtr context, int value); + //int CDECL lame_get_num_channels(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_num_channels(IntPtr context); + + /* + scale the input by this amount before encoding. default=1 + (not used by decoding routines) + */ + //int CDECL lame_set_scale(lame_global_flags *, float); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_scale(IntPtr context, float value); + //float CDECL lame_get_scale(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern float lame_get_scale(IntPtr context); + + /* + scale the channel 0 (left) input by this amount before encoding. default=1 + (not used by decoding routines) + */ + // int CDECL lame_set_scale_left(lame_global_flags *, float); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_scale_left(IntPtr context, float value); + // float CDECL lame_get_scale_left(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern float lame_get_scale_left(IntPtr context); + + /* + scale the channel 1 (right) input by this amount before encoding. default=1 + (not used by decoding routines) + */ + // int CDECL lame_set_scale_right(lame_global_flags *, float); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_scale_right(IntPtr context, float value); + // float CDECL lame_get_scale_right(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern float lame_get_scale_right(IntPtr context); + + /* + output sample rate in Hz. default = 0, which means LAME picks best value + based on the amount of compression. MPEG only allows: + MPEG1 32, 44.1, 48khz + MPEG2 16, 22.05, 24 + MPEG2.5 8, 11.025, 12 + (not used by decoding routines) + */ + // int CDECL lame_set_out_samplerate(lame_global_flags *, int); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_out_samplerate(IntPtr context, int value); + // int CDECL lame_get_out_samplerate(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_out_samplerate(IntPtr context); + + #endregion + + #region General control parameters + + /* 1=cause LAME to collect data for an MP3 frame analyzer. default=0 */ + // int CDECL lame_set_analysis(lame_global_flags *, int); + // int CDECL lame_get_analysis(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_analysis(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_analysis(IntPtr context); + + /* + 1 = write a Xing VBR header frame. + default = 1 + this variable must have been added by a Hungarian notation Windows programmer :-) + */ + // int CDECL lame_set_bWriteVbrTag(lame_global_flags *, int); + // int CDECL lame_get_bWriteVbrTag(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_bWriteVbrTag(IntPtr context, [MarshalAs(UnmanagedType.Bool)] int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_bWriteVbrTag(IntPtr context); + + /* 1=decode only. use lame/mpglib to convert mp3/ogg to wav. default=0 */ + // int CDECL lame_set_decode_only(lame_global_flags *, int); + // int CDECL lame_get_decode_only(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_decode_only(IntPtr context, [MarshalAs(UnmanagedType.Bool)] int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_decode_only(IntPtr context); + + /* + internal algorithm selection. True quality is determined by the bitrate + but this variable will effect quality by selecting expensive or cheap algorithms. + quality=0..9. 0=best (very slow). 9=worst. + recommended: 2 near-best quality, not too slow + 5 good quality, fast + 7 ok quality, really fast + */ + // int CDECL lame_set_quality(lame_global_flags *, int); + // int CDECL lame_get_quality(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_quality(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_quality(IntPtr context); + + /* + mode = 0,1,2,3 = stereo, jstereo, dual channel (not supported), mono + default: lame picks based on compression ration and input channels + */ + // int CDECL lame_set_mode(lame_global_flags *, MPEG_mode); + // MPEG_mode CDECL lame_get_mode(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_mode(IntPtr context, MPEGMode value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern MPEGMode lame_get_mode(IntPtr context); + + /* + force_ms. Force M/S for all frames. For testing only. + default = 0 (disabled) + */ + // int CDECL lame_set_force_ms(lame_global_flags *, int); + // int CDECL lame_get_force_ms(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_force_ms(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_force_ms(IntPtr context); + + /* use free_format? default = 0 (disabled) */ + // int CDECL lame_set_free_format(lame_global_flags *, int); + // int CDECL lame_get_free_format(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_free_format(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_free_format(IntPtr context); + + /* perform ReplayGain analysis? default = 0 (disabled) */ + // int CDECL lame_set_findReplayGain(lame_global_flags *, int); + // int CDECL lame_get_findReplayGain(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_findReplayGain(IntPtr context, [In, MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_findReplayGain(IntPtr context); + + /* decode on the fly. Search for the peak sample. If the ReplayGain + * analysis is enabled then perform the analysis on the decoded data + * stream. default = 0 (disabled) + * NOTE: if this option is set the build-in decoder should not be used */ + // int CDECL lame_set_decode_on_the_fly(lame_global_flags *, int); + // int CDECL lame_get_decode_on_the_fly(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_decode_on_the_fly(IntPtr context, [In, MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_decode_on_the_fly(IntPtr context); + + /* counters for gapless encoding */ + // int CDECL lame_set_nogap_total(lame_global_flags*, int); + // int CDECL lame_get_nogap_total(const lame_global_flags*); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_nogap_total(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_nogap_total(IntPtr context); + + // int CDECL lame_set_nogap_currentindex(lame_global_flags* , int); + // int CDECL lame_get_nogap_currentindex(const lame_global_flags*); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_nogap_currentindex(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_nogap_currentindex(IntPtr context); + + /* set one of brate compression ratio. default is compression ratio of 11. */ + // int CDECL lame_set_brate(lame_global_flags *, int); + // int CDECL lame_get_brate(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_brate(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_brate(IntPtr context); + + // int CDECL lame_set_compression_ratio(lame_global_flags *, float); + // float CDECL lame_get_compression_ratio(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_compression_ratio(IntPtr context, float value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern float lame_get_compression_ratio(IntPtr context); + + //int CDECL lame_set_preset( lame_global_flags* gfp, int ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_preset(IntPtr context, LAMEPreset value); + + //int CDECL lame_set_asm_optimizations( lame_global_flags* gfp, int, int ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_asm_optimizations(IntPtr context, ASMOptimizations opt, [MarshalAs(UnmanagedType.Bool)] bool val); + + #endregion + + #region Frame parameters + + /* mark as copyright. default=0 */ + // int CDECL lame_set_copyright(lame_global_flags *, int); + // int CDECL lame_get_copyright(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_copyright(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_copyright(IntPtr context); + + /* mark as original. default=1 */ + // int CDECL lame_set_original(lame_global_flags *, int); + // int CDECL lame_get_original(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_original(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_original(IntPtr context); + + /* error_protection. Use 2 bytes from each frame for CRC checksum. default=0 */ + // int CDECL lame_set_error_protection(lame_global_flags *, int); + // int CDECL lame_get_error_protection(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_error_protection(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_error_protection(IntPtr context); + + /* MP3 'private extension' bit Meaningless. default=0 */ + // int CDECL lame_set_extension(lame_global_flags *, int); + // int CDECL lame_get_extension(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_extension(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_extension(IntPtr context); + + /* enforce strict ISO compliance. default=0 */ + // int CDECL lame_set_strict_ISO(lame_global_flags *, int); + // int CDECL lame_get_strict_ISO(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_strict_ISO(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_strict_ISO(IntPtr context); + + #endregion + + #region Quantization/Noise Shaping + + /* disable the bit reservoir. For testing only. default=0 */ + // int CDECL lame_set_disable_reservoir(lame_global_flags *, int); + // int CDECL lame_get_disable_reservoir(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_disable_reservoir(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_disable_reservoir(IntPtr context); + + /* select a different "best quantization" function. default=0 */ + // int CDECL lame_set_quant_comp(lame_global_flags *, int); + // int CDECL lame_get_quant_comp(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_quant_comp(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_quant_comp(IntPtr context); + + // int CDECL lame_set_quant_comp_short(lame_global_flags *, int); + // int CDECL lame_get_quant_comp_short(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_quant_comp_short(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_quant_comp_short(IntPtr context); + + // int CDECL lame_set_experimentalX(lame_global_flags *, int); /* compatibility*/ + // int CDECL lame_get_experimentalX(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_experimentalX(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_experimentalX(IntPtr context); + + /* another experimental option. for testing only */ + // int CDECL lame_set_experimentalY(lame_global_flags *, int); + // int CDECL lame_get_experimentalY(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_experimentalY(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_experimentalY(IntPtr context); + + /* another experimental option. for testing only */ + // int CDECL lame_set_experimentalZ(lame_global_flags *, int); + // int CDECL lame_get_experimentalZ(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_experimentalZ(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_experimentalZ(IntPtr context); + + /* Naoki's psycho acoustic model. default=0 */ + // int CDECL lame_set_exp_nspsytune(lame_global_flags *, int); + // int CDECL lame_get_exp_nspsytune(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_exp_nspsytune(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_exp_nspsytune(IntPtr context); + + // void CDECL lame_set_msfix(lame_global_flags *, double); + // float CDECL lame_get_msfix(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_msfix(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_msfix(IntPtr context); + + #endregion + + #region VBR control + + /* Types of VBR. default = vbr_off = CBR */ + // int CDECL lame_set_VBR(lame_global_flags *, vbr_mode); + // vbr_mode CDECL lame_get_VBR(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_VBR(IntPtr context, VBRMode value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern VBRMode lame_get_VBR(IntPtr context); + + /* VBR quality level. 0=highest 9=lowest */ + // int CDECL lame_set_VBR_q(lame_global_flags *, int); + // int CDECL lame_get_VBR_q(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_VBR_q(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_VBR_q(IntPtr context); + + /* VBR quality level. 0=highest 9=lowest, Range [0,...,10[ */ + // int CDECL lame_set_VBR_quality(lame_global_flags *, float); + // float CDECL lame_get_VBR_quality(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_VBR_quality(IntPtr context, float value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern float lame_get_VBR_quality(IntPtr context); + + /* Ignored except for VBR=vbr_abr (ABR mode) */ + // int CDECL lame_set_VBR_mean_bitrate_kbps(lame_global_flags *, int); + // int CDECL lame_get_VBR_mean_bitrate_kbps(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_VBR_mean_bitrate_kbps(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_VBR_mean_bitrate_kbps(IntPtr context); + + // int CDECL lame_set_VBR_min_bitrate_kbps(lame_global_flags *, int); + // int CDECL lame_get_VBR_min_bitrate_kbps(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_VBR_min_bitrate_kbps(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_VBR_min_bitrate_kbps(IntPtr context); + + // int CDECL lame_set_VBR_max_bitrate_kbps(lame_global_flags *, int); + // int CDECL lame_get_VBR_max_bitrate_kbps(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_VBR_max_bitrate_kbps(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_VBR_max_bitrate_kbps(IntPtr context); + + /* + 1=strictly enforce VBR_min_bitrate. Normally it will be violated for + analog silence + */ + // int CDECL lame_set_VBR_hard_min(lame_global_flags *, int); + // int CDECL lame_get_VBR_hard_min(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_VBR_hard_min(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_VBR_hard_min(IntPtr context); + + #endregion + + #region Filtering control + + /* freq in Hz to apply lowpass. Default = 0 = lame chooses. -1 = disabled */ + // int CDECL lame_set_lowpassfreq(lame_global_flags *, int); + // int CDECL lame_get_lowpassfreq(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_lowpassfreq(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_lowpassfreq(IntPtr context); + + /* width of transition band, in Hz. Default = one polyphase filter band */ + // int CDECL lame_set_lowpasswidth(lame_global_flags *, int); + // int CDECL lame_get_lowpasswidth(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_lowpasswidth(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_lowpasswidth(IntPtr context); + + /* freq in Hz to apply highpass. Default = 0 = lame chooses. -1 = disabled */ + // int CDECL lame_set_highpassfreq(lame_global_flags *, int); + // int CDECL lame_get_highpassfreq(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_highpassfreq(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_highpassfreq(IntPtr context); + + /* width of transition band, in Hz. Default = one polyphase filter band */ + // int CDECL lame_set_highpasswidth(lame_global_flags *, int); + // int CDECL lame_get_highpasswidth(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_highpasswidth(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_highpasswidth(IntPtr context); + + #endregion + + #region Psychoacoustics and other advanced settings + + /* only use ATH for masking */ + // int CDECL lame_set_ATHonly(lame_global_flags *, int); + // int CDECL lame_get_ATHonly(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_ATHonly(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_ATHonly(IntPtr context); + + /* only use ATH for short blocks */ + // int CDECL lame_set_ATHshort(lame_global_flags *, int); + // int CDECL lame_get_ATHshort(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_ATHshort(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_ATHshort(IntPtr context); + + /* disable ATH */ + // int CDECL lame_set_noATH(lame_global_flags *, int); + // int CDECL lame_get_noATH(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_noATH(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_noATH(IntPtr context); + + /* select ATH formula */ + // int CDECL lame_set_ATHtype(lame_global_flags *, int); + // int CDECL lame_get_ATHtype(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_ATHtype(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_ATHtype(IntPtr context); + + /* lower ATH by this many db */ + // int CDECL lame_set_ATHlower(lame_global_flags *, float); + // float CDECL lame_get_ATHlower(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_ATHlower(IntPtr context, float value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern float lame_get_ATHlower(IntPtr context); + + /* select ATH adaptive adjustment type */ + // int CDECL lame_set_athaa_type( lame_global_flags *, int); + // int CDECL lame_get_athaa_type( const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_athaa_type(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_athaa_type(IntPtr context); + + /* adjust (in dB) the point below which adaptive ATH level adjustment occurs */ + // int CDECL lame_set_athaa_sensitivity( lame_global_flags *, float); + // float CDECL lame_get_athaa_sensitivity( const lame_global_flags* ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_athaa_sensitivity(IntPtr context, float value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern float lame_get_athaa_sensitivity(IntPtr context); + + /* + allow blocktypes to differ between channels? + default: 0 for jstereo, 1 for stereo + */ + // int CDECL lame_set_allow_diff_short(lame_global_flags *, int); + // int CDECL lame_get_allow_diff_short(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_allow_diff_short(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_allow_diff_short(IntPtr context); + + /* use temporal masking effect (default = 1) */ + // int CDECL lame_set_useTemporal(lame_global_flags *, int); + // int CDECL lame_get_useTemporal(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_useTemporal(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_useTemporal(IntPtr context); + + /* use temporal masking effect (default = 1) */ + // int CDECL lame_set_interChRatio(lame_global_flags *, float); + // float CDECL lame_get_interChRatio(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_interChRatio(IntPtr context, float value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern float lame_get_interChRatio(IntPtr context); + + /* disable short blocks */ + // int CDECL lame_set_no_short_blocks(lame_global_flags *, int); + // int CDECL lame_get_no_short_blocks(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_no_short_blocks(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_no_short_blocks(IntPtr context); + + /* force short blocks */ + // int CDECL lame_set_force_short_blocks(lame_global_flags *, int); + // int CDECL lame_get_force_short_blocks(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_force_short_blocks(IntPtr context, [MarshalAs(UnmanagedType.Bool)] bool value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool lame_get_force_short_blocks(IntPtr context); + + /* Input PCM is emphased PCM (for instance from one of the rarely + emphased CDs), it is STRONGLY not recommended to use this, because + psycho does not take it into account, and last but not least many decoders + ignore these bits */ + // int CDECL lame_set_emphasis(lame_global_flags *, int); + // int CDECL lame_get_emphasis(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_emphasis(IntPtr context, int value); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_emphasis(IntPtr context); + + #endregion + + #region Internal state variables, read only + + /* version 0=MPEG-2 1=MPEG-1 (2=MPEG-2.5) */ + // int CDECL lame_get_version(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern MPEGVersion lame_get_version(IntPtr context); + + /* encoder delay */ + // int CDECL lame_get_encoder_delay(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_encoder_delay(IntPtr context); + + /* + padding appended to the input to make sure decoder can fully decode + all input. Note that this value can only be calculated during the + call to lame_encoder_flush(). Before lame_encoder_flush() has + been called, the value of encoder_padding = 0. + */ + // int CDECL lame_get_encoder_padding(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_encoder_padding(IntPtr context); + + /* size of MPEG frame */ + // int CDECL lame_get_framesize(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_framesize(IntPtr context); + + /* number of PCM samples buffered, but not yet encoded to mp3 data. */ + // int CDECL lame_get_mf_samples_to_encode( const lame_global_flags* gfp ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_mf_samples_to_encode(IntPtr context); + + /* + size (bytes) of mp3 data buffered, but not yet encoded. + this is the number of bytes which would be output by a call to + lame_encode_flush_nogap. NOTE: lame_encode_flush() will return + more bytes than this because it will encode the reamining buffered + PCM samples before flushing the mp3 buffers. + */ + // int CDECL lame_get_size_mp3buffer( const lame_global_flags* gfp ); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_size_mp3buffer(IntPtr context); + + /* number of frames encoded so far */ + // int CDECL lame_get_frameNum(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_frameNum(IntPtr context); + + /* + lame's estimate of the total number of frames to be encoded + only valid if calling program set num_samples + */ + // int CDECL lame_get_totalframes(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_totalframes(IntPtr context); + + /* RadioGain value. Multiplied by 10 and rounded to the nearest. */ + // int CDECL lame_get_RadioGain(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_RadioGain(IntPtr context); + + /* AudiophileGain value. Multipled by 10 and rounded to the nearest. */ + // int CDECL lame_get_AudiophileGain(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_AudiophileGain(IntPtr context); + + /* the peak sample */ + // float CDECL lame_get_PeakSample(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern float lame_get_PeakSample(IntPtr context); + + /* Gain change required for preventing clipping. The value is correct only if + peak sample searching was enabled. If negative then the waveform + already does not clip. The value is multiplied by 10 and rounded up. */ + // int CDECL lame_get_noclipGainChange(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_get_noclipGainChange(IntPtr context); + + /* user-specified scale factor required for preventing clipping. Value is + correct only if peak sample searching was enabled and no user-specified + scaling was performed. If negative then either the waveform already does + not clip or the value cannot be determined */ + // float CDECL lame_get_noclipScale(const lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern float lame_get_noclipScale(IntPtr context); + + #endregion + + #region Processing + + /* + * REQUIRED: + * sets more internal configuration based on data provided above. + * returns -1 if something failed. + */ + // int CDECL lame_init_params(lame_global_flags *); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_init_params(IntPtr context); + + /* + * input pcm data, output (maybe) mp3 frames. + * This routine handles all buffering, resampling and filtering for you. + * + * return code number of bytes output in mp3buf. Can be 0 + * -1: mp3buf was too small + * -2: malloc() problem + * -3: lame_init_params() not called + * -4: psycho acoustic problems + * + * The required mp3buf_size can be computed from num_samples, + * samplerate and encoding rate, but here is a worst case estimate: + * + * mp3buf_size in bytes = 1.25*num_samples + 7200 + * + * I think a tighter bound could be: (mt, March 2000) + * MPEG1: + * num_samples*(bitrate/8)/samplerate + 4*1152*(bitrate/8)/samplerate + 512 + * MPEG2: + * num_samples*(bitrate/8)/samplerate + 4*576*(bitrate/8)/samplerate + 256 + * + * but test first if you use that! + * + * set mp3buf_size = 0 and LAME will not check if mp3buf_size is + * large enough. + * + * NOTE: + * if gfp->num_channels=2, but gfp->mode = 3 (mono), the L & R channels + * will be averaged into the L channel before encoding only the L channel + * This will overwrite the data in buffer_l[] and buffer_r[]. + * + */ + // int CDECL lame_encode_buffer ( + // lame_global_flags* gfp, /* global context handle */ + // const short int buffer_l [], /* PCM data for left channel */ + // const short int buffer_r [], /* PCM data for right channel */ + // const int nsamples, /* number of samples per channel */ + // unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + // const int mp3buf_size ); /* number of valid octets in this stream */ + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_buffer(IntPtr context, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I2)] + short[] buffer_l, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I2)] + short[] buffer_r, + int nSamples, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + /* + * as above, but input has L & R channel data interleaved. + * NOTE: + * num_samples = number of samples in the L (or R) + * channel, not the total number of samples in pcm[] + */ + // int CDECL lame_encode_buffer_interleaved( + // lame_global_flags* gfp, /* global context handlei */ + // short int pcm[], /* PCM data for left and right + // channel, interleaved */ + // int num_samples, /* number of samples per channel, _not_ number of samples in pcm[] */ + // unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + // int mp3buf_size ); /* number of valid octets in this stream */ + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_buffer_interleaved(IntPtr context, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I2)] + short[] pcm, + int num_samples, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + /* as lame_encode_buffer, but for 'float's. + * !! NOTE: !! data must still be scaled to be in the same range as + * short int, +/- 32768 + */ + // int CDECL lame_encode_buffer_float( + // lame_global_flags* gfp, /* global context handle */ + // const float pcm_l [], /* PCM data for left channel */ + // const float pcm_r [], /* PCM data for right channel */ + // const int nsamples, /* number of samples per channel */ + // unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + // const int mp3buf_size ); /* number of valid octets in this stream */ + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_buffer_float(IntPtr context, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.R4)] + float[] pcm_l, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.R4)] + float[] pcm_r, + int nSamples, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + /* as lame_encode_buffer, but for 'float's. + * !! NOTE: !! data must be scaled to +/- 1 full scale + */ + // int CDECL lame_encode_buffer_ieee_float( + // lame_t gfp, + // const float pcm_l [], /* PCM data for left channel */ + // const float pcm_r [], /* PCM data for right channel */ + // const int nsamples, + // unsigned char * mp3buf, + // const int mp3buf_size); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_buffer_ieee_float(IntPtr context, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.R4)] + float[] pcm_l, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.R4)] + float[] pcm_r, + int nSamples, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + // int CDECL lame_encode_buffer_interleaved_ieee_float( + // lame_t gfp, + // const float pcm[], /* PCM data for left and right channel, interleaved */ + // const int nsamples, + // unsigned char * mp3buf, + // const int mp3buf_size); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_buffer_interleaved_ieee_float(IntPtr context, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.R4)] + + float[] pcm, + int nSamples, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + /* as lame_encode_buffer, but for 'double's. + * !! NOTE: !! data must be scaled to +/- 1 full scale + */ + // int CDECL lame_encode_buffer_ieee_double( + // lame_t gfp, + // const double pcm_l [], /* PCM data for left channel */ + // const double pcm_r [], /* PCM data for right channel */ + // const int nsamples, + // unsigned char * mp3buf, + // const int mp3buf_size); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_buffer_ieee_double(IntPtr context, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.R8)] + double[] pcm_l, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.R8)] + double[] pcm_r, + int nSamples, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + // int CDECL lame_encode_buffer_interleaved_ieee_double( + // lame_t gfp, + // const double pcm[], /* PCM data for left and right channel, interleaved */ + // const int nsamples, + // unsigned char * mp3buf, + // const int mp3buf_size); + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_buffer_interleaved_ieee_double(IntPtr context, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.R8)] + double[] pcm, + int nSamples, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + /* as lame_encode_buffer, but for long's + * !! NOTE: !! data must still be scaled to be in the same range as + * short int, +/- 32768 + * + * This scaling was a mistake (doesn't allow one to exploit full + * precision of type 'long'. Use lame_encode_buffer_long2() instead. + * + */ + // int CDECL lame_encode_buffer_long( + // lame_global_flags* gfp, /* global context handle */ + // const long buffer_l [], /* PCM data for left channel */ + // const long buffer_r [], /* PCM data for right channel */ + // const int nsamples, /* number of samples per channel */ + // unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + // const int mp3buf_size ); /* number of valid octets in this stream */ + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_buffer_long(IntPtr context, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I8)] + long[] buffer_l, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I8)] + long[] buffer_r, + int nSamples, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + /* Same as lame_encode_buffer_long(), but with correct scaling. + * !! NOTE: !! data must still be scaled to be in the same range as + * type 'long'. Data should be in the range: +/- 2^(8*size(long)-1) + * + */ + // int CDECL lame_encode_buffer_long2( + // lame_global_flags* gfp, /* global context handle */ + // const long buffer_l [], /* PCM data for left channel */ + // const long buffer_r [], /* PCM data for right channel */ + // const int nsamples, /* number of samples per channel */ + // unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + // const int mp3buf_size ); /* number of valid octets in this stream */ + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_buffer_long2(IntPtr context, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I8)] + long[] buffer_l, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I8)] + long[] buffer_r, + int nSamples, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + /* as lame_encode_buffer, but for int's + * !! NOTE: !! input should be scaled to the maximum range of 'int' + * If int is 4 bytes, then the values should range from + * +/- 2147483648. + * + * This routine does not (and cannot, without loosing precision) use + * the same scaling as the rest of the lame_encode_buffer() routines. + * + */ + // int CDECL lame_encode_buffer_int( + // lame_global_flags* gfp, /* global context handle */ + // const int buffer_l [], /* PCM data for left channel */ + // const int buffer_r [], /* PCM data for right channel */ + // const int nsamples, /* number of samples per channel */ + // unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + // const int mp3buf_size ); /* number of valid octets in this stream */ + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_buffer_int(IntPtr context, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I4)] + int[] buffer_l, + [In]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I4)] + int[] buffer_r, + int nSamples, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + /* + * REQUIRED: + * lame_encode_flush will flush the intenal PCM buffers, padding with + * 0's to make sure the final frame is complete, and then flush + * the internal MP3 buffers, and thus may return a + * final few mp3 frames. 'mp3buf' should be at least 7200 bytes long + * to hold all possible emitted data. + * + * will also write id3v1 tags (if any) into the bitstream + * + * return code = number of bytes output to mp3buf. Can be 0 + */ + // int CDECL lame_encode_flush( + // lame_global_flags * gfp, /* global context handle */ + // unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + // int size); /* number of valid octets in this stream */ + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_flush(IntPtr context, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + /* + * OPTIONAL: + * lame_encode_flush_nogap will flush the internal mp3 buffers and pad + * the last frame with ancillary data so it is a complete mp3 frame. + * + * 'mp3buf' should be at least 7200 bytes long + * to hold all possible emitted data. + * + * After a call to this routine, the outputed mp3 data is complete, but + * you may continue to encode new PCM samples and write future mp3 data + * to a different file. The two mp3 files will play back with no gaps + * if they are concatenated together. + * + * This routine will NOT write id3v1 tags into the bitstream. + * + * return code = number of bytes output to mp3buf. Can be 0 + */ + // int CDECL lame_encode_flush_nogap( + // lame_global_flags * gfp, /* global context handle */ + // unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + // int size); /* number of valid octets in this stream */ + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_encode_flush_nogap(IntPtr context, + [In, Out]//[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)] + byte[] mp3buf, + int mp3buf_size + ); + + + /* + * OPTIONAL: + * Normally, this is called by lame_init_params(). It writes id3v2 and + * Xing headers into the front of the bitstream, and sets frame counters + * and bitrate histogram data to 0. You can also call this after + * lame_encode_flush_nogap(). + */ + //int CDECL lame_init_bitstream( + // lame_global_flags * gfp); /* global context handle */ + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_init_bitstream(IntPtr context); + + #endregion + + #region Reporting callbacks + + [UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true, CharSet = CharSet.Ansi)] + internal delegate void delReportFunction(string fmt, IntPtr args); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_errorf(IntPtr context, delReportFunction fn); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_debugf(IntPtr context, delReportFunction fn); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern int lame_set_msgf(IntPtr context, delReportFunction fn); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern void lame_print_config(IntPtr context); + + [DllImport(libname, CallingConvention = CallingConvention.Cdecl)] + internal static extern void lame_print_internals(IntPtr context); + + + #endregion + + + #region 'printf' support for reporting functions + + //[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ThrowOnUnmappableChar = true, BestFitMapping = false)] + //internal static extern int _vsnprintf_s( + // [In, Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder str, + // int sizeOfBuffer, + // int count, + // [In, MarshalAs(UnmanagedType.LPStr)] String format, + // [In] IntPtr va_args); + + //internal static string printf(string format, IntPtr va_args) + //{ + // StringBuilder sb = new StringBuilder(4096); + // int res = NativeMethods._vsnprintf_s(sb, sb.Capacity, sb.Capacity - 2, format.Replace("\t", "\xFF"), va_args); + // return sb.ToString().Replace("\xFF", "\t"); + //} + + #endregion + } + + ///// Print out LAME configuration to standard output, or to registered output function + //public void PrintConfig() + //{ + // NativeMethods.lame_print_config(context); + //} + + ///// Print out LAME internals to standard output, or to registered output function + //public void PrintInternals() + //{ + // NativeMethods.lame_print_internals(context); + //} + + #region Reporting function support + + // /// Delegate for receiving output messages + // /// Text to output + //public delegate void ReportFunction(string text); + + // private static ReportFunction rptError = null; + // private static ReportFunction rptDebug = null; + // private static ReportFunction rptMsg = null; + + // [MonoPInvokeCallback(typeof(ReportFunction))] + // private static void error_proxy(string format, IntPtr va_args) + // { + // string text = NativeMethods.printf(format, va_args); + // if (rptError != null) + // rptError(text); + // } + + // [MonoPInvokeCallback(typeof(ReportFunction))] + // private static void debug_proxy(string format, IntPtr va_args) + // { + // string text = NativeMethods.printf(format, va_args); + // if (rptDebug != null) + // rptDebug(text); + // } + + // [MonoPInvokeCallback(typeof(ReportFunction))] + // private static void msg_proxy(string format, IntPtr va_args) + // { + // string text = NativeMethods.printf(format, va_args); + // if (rptMsg != null) + // rptMsg(text); + // } + + // private void InitReportFunctions() + // { + // NativeMethods.lame_set_errorf(context, error_proxy); + // NativeMethods.lame_set_debugf(context, debug_proxy); + // NativeMethods.lame_set_msgf(context, msg_proxy); + // } + + // /// Set reporting function for error output from LAME library + // /// Reporting function + // public static void SetErrorFunc(ReportFunction fn) + // { + // rptError = fn; + // } + + // /// Set reporting function for debug output from LAME library + // /// Reporting function + // public static void SetDebugFunc(ReportFunction fn) + // { + // rptDebug = fn; + // } + + // /// Set reporting function for message output from LAME library + // /// Reporting function + // public static void SetMsgFunc(ReportFunction fn) + // { + // rptMsg = fn; + // } + + #endregion + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/LibMp3Lame.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/LibMp3Lame.cs.meta new file mode 100644 index 0000000..ca9c425 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/LibMp3Lame.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d66ded0e78d16b9488dfb0e9247211e7 +timeCreated: 1493208137 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/MP3FileWriter.cs b/Assets/Plugins/Lame-For-Unity/Lame/MP3FileWriter.cs new file mode 100644 index 0000000..07c071d --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/MP3FileWriter.cs @@ -0,0 +1,447 @@ +#region MIT license +// +// MIT license +// +// Copyright (c) 2013 Corey Murtagh +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +#endregion +using System; +using System.IO; +using System.Runtime.InteropServices; +using NAudio.Lame.DLL; +using NAudio.Wave.WZT; + +namespace NAudio.Lame +{ + /// MP3 encoding class, uses libmp3lame DLL to encode. + public class LameMP3FileWriter : Stream + { + /// Union class for fast buffer conversion + /// + /// + /// Because of the way arrays work in .NET, all of the arrays will have the same + /// length value. To prevent unaware code from trying to read/write from out of + /// bounds, allocation is done at the grain of the Least Common Multiple of the + /// sizes of the contained types. In this case the LCM is 8 bytes - the size of + /// a double or a long - which simplifies allocation. + /// + /// This means that when you ask for an array of 500 bytes you will actually get + /// an array of 63 doubles - 504 bytes total. Any code that uses the length of + /// the array will see only 63 bytes, shorts, etc. + /// + /// CodeAnalysis does not like this class, with good reason. It should never be + /// exposed beyond the scope of the MP3FileWriter. + /// + /// + // uncomment to suppress CodeAnalysis warnings for the ArrayUnion class: + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Portability", "CA1900:ValueTypeFieldsShouldBePortable", Justification = "This design breaks portability, but is never exposed outside the class. Tested on 32-bit and 64-bit.")] + [StructLayout(LayoutKind.Explicit)] + private class ArrayUnion + { + /// Size array in bytes + [FieldOffset(0)] + public readonly int nBytes; + + [FieldOffset(16)] + public readonly byte[] bytes; + + [FieldOffset(16)] + public readonly short[] shorts; + + [FieldOffset(16)] + public readonly int[] ints; + + [FieldOffset(16)] + public readonly long[] longs; + + [FieldOffset(16)] + public readonly float[] floats; + + [FieldOffset(16)] + public readonly double[] doubles; + + // True sizes of the various array types, calculated from number of bytes + + public int nShorts { get { return nBytes / 2; } } + public int nInts { get { return nBytes / 4; } } + public int nLongs { get { return nBytes / 8; } } + public int nFloats { get { return nBytes / 4; } } + public int nDoubles { get { return nBytes / 8; } } + + /// Initialize array to hold the requested number of bytes + /// Minimum byte count of array + /// + /// Since all arrays will have the same apparent count, allocation + /// is done on the array with the largest data type. This helps + /// to prevent out-of-bounds reads and writes by methods that do + /// not know about the union. + /// + public ArrayUnion(int reqBytes) + { + // Calculate smallest number of doubles required to store the + // requested byte count + int reqDoubles = (reqBytes + 7) / 8; + + this.doubles = new double[reqDoubles]; + this.nBytes = reqDoubles * 8; + } + }; + + #region Properties + // LAME library context + private LibMp3Lame _lame; + + // Format of input wave data + private readonly WaveFormat inputFormat; + + // Output stream to write encoded data to + private Stream outStream; + + // Flag to control whether we should dispose of output stream + private bool disposeOutput = false; + #endregion + + #region Structors + /// Create MP3FileWriter to write to a file on disk + /// Name of file to create + /// Input WaveFormat + /// LAME quality preset + public LameMP3FileWriter(string outFileName, WaveFormat format, LAMEPreset quality) + : this(File.Create(outFileName), format, quality) + { + this.disposeOutput = true; + } + + /// Create MP3FileWriter to write to supplied stream + /// Stream to write encoded data to + /// Input WaveFormat + /// LAME quality preset + public LameMP3FileWriter(Stream outStream, WaveFormat format, LAMEPreset quality) + : base() + { + // sanity check + if (outStream == null) + throw new ArgumentNullException("outStream"); + if (format == null) + throw new ArgumentNullException("format"); + + // check for unsupported wave formats + if (format.Channels != 1 && format.Channels != 2) + throw new ArgumentException(string.Format("Unsupported number of channels {0}", format.Channels), "format"); + if (format.Encoding != WaveFormatEncoding.Pcm && format.Encoding != WaveFormatEncoding.IeeeFloat) + throw new ArgumentException(string.Format("Unsupported encoding format {0}", format.Encoding.ToString()), "format"); + if (format.Encoding == WaveFormatEncoding.Pcm && format.BitsPerSample != 16) + throw new ArgumentException(string.Format("Unsupported PCM sample size {0}", format.BitsPerSample), "format"); + if (format.Encoding == WaveFormatEncoding.IeeeFloat && format.BitsPerSample != 32) + throw new ArgumentException(string.Format("Unsupported Float sample size {0}", format.BitsPerSample), "format"); + if (format.SampleRate < 8000 || format.SampleRate > 48000) + throw new ArgumentException(string.Format("Unsupported Sample Rate {0}", format.SampleRate), "format"); + + // select encoder function that matches data format + if (format.Encoding == WaveFormatEncoding.Pcm) + { + if (format.Channels == 1) + _encode = encode_pcm_16_mono; + else + _encode = encode_pcm_16_stereo; + } + else + { + if (format.Channels == 1) + _encode = encode_float_mono; + else + _encode = encode_float_stereo; + } + + // Set base properties + this.inputFormat = format; + this.outStream = outStream; + this.disposeOutput = false; + + // Allocate buffers based on sample rate + this.inBuffer = new ArrayUnion(format.AverageBytesPerSecond); + this.outBuffer = new byte[format.SampleRate * 5 / 4 + 7200]; + + // Initialize lame library + this._lame = new LibMp3Lame(); + + this._lame.InputSampleRate = format.SampleRate; + this._lame.NumChannels = format.Channels; + + this._lame.SetPreset(quality); + + this._lame.InitParams(); + } + + + /// Create MP3FileWriter to write to a file on disk + /// Name of file to create + /// Input WaveFormat + /// Output bit rate in kbps + public LameMP3FileWriter(string outFileName, WaveFormat format, int bitRate) + : this(File.Create(outFileName), format, bitRate) + { + this.disposeOutput = true; + } + + /// Create MP3FileWriter to write to supplied stream + /// Stream to write encoded data to + /// Input WaveFormat + /// Output bit rate in kbps + public LameMP3FileWriter(Stream outStream, WaveFormat format, int bitRate) + : base() + { + // sanity check + if (outStream == null) + throw new ArgumentNullException("outStream"); + if (format == null) + throw new ArgumentNullException("format"); + + // check for unsupported wave formats + if (format.Channels != 1 && format.Channels != 2) + throw new ArgumentException(string.Format("Unsupported number of channels {0}", format.Channels), "format"); + if (format.Encoding != WaveFormatEncoding.Pcm && format.Encoding != WaveFormatEncoding.IeeeFloat) + throw new ArgumentException(string.Format("Unsupported encoding format {0}", format.Encoding.ToString()), "format"); + if (format.Encoding == WaveFormatEncoding.Pcm && format.BitsPerSample != 16) + throw new ArgumentException(string.Format("Unsupported PCM sample size {0}", format.BitsPerSample), "format"); + if (format.Encoding == WaveFormatEncoding.IeeeFloat && format.BitsPerSample != 32) + throw new ArgumentException(string.Format("Unsupported Float sample size {0}", format.BitsPerSample), "format"); + if (format.SampleRate < 8000 || format.SampleRate > 48000) + throw new ArgumentException(string.Format("Unsupported Sample Rate {0}", format.SampleRate), "format"); + + // select encoder function that matches data format + if (format.Encoding == WaveFormatEncoding.Pcm) + { + if (format.Channels == 1) + _encode = encode_pcm_16_mono; + else + _encode = encode_pcm_16_stereo; + } + else + { + if (format.Channels == 1) + _encode = encode_float_mono; + else + _encode = encode_float_stereo; + } + + // Set base properties + this.inputFormat = format; + this.outStream = outStream; + this.disposeOutput = false; + + // Allocate buffers based on sample rate + this.inBuffer = new ArrayUnion(format.AverageBytesPerSecond); + this.outBuffer = new byte[format.SampleRate * 5 / 4 + 7200]; + + // Initialize lame library + this._lame = new LibMp3Lame(); + + this._lame.InputSampleRate = format.SampleRate; + this._lame.NumChannels = format.Channels; + + this._lame.BitRate = bitRate; + + this._lame.InitParams(); + } + + + // Close LAME instance and output stream on dispose + /// Dispose of object + /// True if called from destructor, false otherwise + protected override void Dispose(bool final) + { + if (_lame != null && outStream != null) + Flush(); + + if (_lame != null) + { + _lame.Dispose(); + _lame = null; + } + + if (outStream != null && disposeOutput) + { + outStream.Dispose(); + outStream = null; + } + + base.Dispose(final); + } + #endregion + + /// Get internal LAME library instance + /// LAME library instance + public LibMp3Lame GetLameInstance() + { + return _lame; + } + + #region Internal encoder operations + // Input buffer + private ArrayUnion inBuffer = null; + + /// Current write position in input buffer + private int inPosition; + + /// Output buffer, size determined by call to Lame.beInitStream + protected byte[] outBuffer; + + long InputByteCount = 0; + long OutputByteCount = 0; + + // encoder write functions, one for each supported input wave format + + private int encode_pcm_16_mono() + { + return _lame.Write(inBuffer.shorts, inPosition / 2, outBuffer, outBuffer.Length, true); + } + + private int encode_pcm_16_stereo() + { + return _lame.Write(inBuffer.shorts, inPosition / 2, outBuffer, outBuffer.Length, false); + } + + private int encode_float_mono() + { + return _lame.Write(inBuffer.floats, inPosition / 4, outBuffer, outBuffer.Length, true); + } + + private int encode_float_stereo() + { + return _lame.Write(inBuffer.floats, inPosition / 4, outBuffer, outBuffer.Length, false); + } + + // Selected encoding write function + delegate int delEncode(); + delEncode _encode = null; + + // Pass data to encoder + private void Encode() + { + // check if encoder closed + if (outStream == null || _lame == null) + throw new InvalidOperationException("Output Stream closed."); + + // If no data to encode, do nothing + if (inPosition < inputFormat.Channels * 2) + return; + + // send to encoder + int rc = _encode(); + + if (rc > 0) + { + outStream.Write(outBuffer, 0, rc); + OutputByteCount += rc; + } + + InputByteCount += inPosition; + inPosition = 0; + } + #endregion + + #region Stream implementation + /// Write-only stream. Always false. + public override bool CanRead { get { return false; } } + /// Non-seekable stream. Always false. + public override bool CanSeek { get { return false; } } + /// True when encoder can accept more data + public override bool CanWrite { get { return outStream != null && _lame != null; } } + + /// Dummy Position. Always 0. + public override long Position + { + get { return 0; } + set { throw new NotImplementedException(); } + } + + /// Dummy Length. Always 0. + public override long Length + { + get { return 0; } + } + + /// Add data to output buffer, sending to encoder when buffer full + /// Source buffer + /// Offset of data in buffer + /// Length of data + public override void Write(byte[] buffer, int offset, int count) + { + while (count > 0) + { + int blockSize = Math.Min(inBuffer.nBytes - inPosition, count); + Buffer.BlockCopy(buffer, offset, inBuffer.bytes, inPosition, blockSize); + + inPosition += blockSize; + count -= blockSize; + offset += blockSize; + + if (inPosition >= inBuffer.nBytes) + Encode(); + } + } + + /// Finalise compression, add final output to output stream and close encoder + public override void Flush() + { + // write remaining data + if (inPosition > 0) + Encode(); + + // finalize compression + int rc = _lame.Flush(outBuffer, outBuffer.Length); + if (rc > 0) + outStream.Write(outBuffer, 0, rc); + + // Cannot continue after flush, so clear output stream + if (disposeOutput) + outStream.Dispose(); + outStream = null; + } + + /// Reading not supported. Throws NotImplementedException. + /// + /// + /// + /// + public override int Read(byte[] buffer, int offset, int count) + { + throw new NotImplementedException(); + } + + /// Setting length not supported. Throws NotImplementedException. + /// Length value + public override void SetLength(long value) + { + throw new NotImplementedException(); + } + + /// Seeking not supported. Throws NotImplementedException. + /// Seek offset + /// Seek origin + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotImplementedException(); + } + #endregion + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/MP3FileWriter.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/MP3FileWriter.cs.meta new file mode 100644 index 0000000..a0da4fe --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/MP3FileWriter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fb5c882d3dd15214491ac8aaf1f5b608 +timeCreated: 1493208137 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio.meta new file mode 100644 index 0000000..906473f --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 23b199320e3e7df47a5ebee61346c2b0 +folderAsset: yes +timeCreated: 1493208131 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AdpcmWaveFormat.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AdpcmWaveFormat.cs new file mode 100644 index 0000000..124c14a --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AdpcmWaveFormat.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; + +namespace NAudio.Wave.WZT +{ + /// + /// Microsoft ADPCM + /// See http://icculus.org/SDL_sound/downloads/external_documentation/wavecomp.htm + /// + [StructLayout(LayoutKind.Sequential, Pack=2)] + public class AdpcmWaveFormat : WaveFormat + { + short samplesPerBlock; + short numCoeff; + // 7 pairs of coefficients + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] + short[] coefficients; + + /// + /// Empty constructor needed for marshalling from a pointer + /// + AdpcmWaveFormat() : this(8000,1) + { + } + + /// + /// Samples per block + /// + public int SamplesPerBlock + { + get { return samplesPerBlock; } + } + + /// + /// Number of coefficients + /// + public int NumCoefficients + { + get { return numCoeff; } + } + + /// + /// Coefficients + /// + public short[] Coefficients + { + get { return coefficients; } + } + + /// + /// Microsoft ADPCM + /// + /// Sample Rate + /// Channels + public AdpcmWaveFormat(int sampleRate, int channels) : + base(sampleRate,0,channels) + { + this.waveFormatTag = WaveFormatEncoding.Adpcm; + + // TODO: validate sampleRate, bitsPerSample + this.extraSize = 32; + switch(this.sampleRate) + { + case 8000: + case 11025: + blockAlign = 256; + break; + case 22050: + blockAlign = 512; + break; + case 44100: + default: + blockAlign = 1024; + break; + } + + this.bitsPerSample = 4; + this.samplesPerBlock = (short) ((((blockAlign - (7 * channels)) * 8) / (bitsPerSample * channels)) + 2); + this.averageBytesPerSecond = + ((this.SampleRate * blockAlign) / samplesPerBlock); + + // samplesPerBlock = blockAlign - (7 * channels)) * (2 / channels) + 2; + + + numCoeff = 7; + coefficients = new short[14] { + 256,0,512,-256,0,0,192,64,240,0,460,-208,392,-232 + }; + } + + /// + /// Serializes this wave format + /// + /// Binary writer + public override void Serialize(System.IO.BinaryWriter writer) + { + base.Serialize(writer); + writer.Write(samplesPerBlock); + writer.Write(numCoeff); + foreach (short coefficient in coefficients) + { + writer.Write(coefficient); + } + } + + /// + /// String Description of this WaveFormat + /// + public override string ToString() + { + return String.Format("Microsoft ADPCM {0} Hz {1} channels {2} bits per sample {3} samples per block", + this.SampleRate, this.channels, this.bitsPerSample, this.samplesPerBlock); + } + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AdpcmWaveFormat.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AdpcmWaveFormat.cs.meta new file mode 100644 index 0000000..204a167 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AdpcmWaveFormat.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 60f6eb670e8f81f4382cc6d1e8ac13fa +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AudioMediaSubtypes.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AudioMediaSubtypes.cs new file mode 100644 index 0000000..b8159ee --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AudioMediaSubtypes.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NAudio.Dmo.WZT +{ + class AudioMediaSubtypes + { + public static readonly Guid MEDIASUBTYPE_PCM = new Guid("00000001-0000-0010-8000-00AA00389B71"); // PCM audio. + public static readonly Guid MEDIASUBTYPE_PCMAudioObsolete = new Guid("e436eb8a-524f-11ce-9f53-0020af0ba770"); // Obsolete. Do not use. + public static readonly Guid MEDIASUBTYPE_MPEG1Packet = new Guid("e436eb80-524f-11ce-9f53-0020af0ba770"); // MPEG1 Audio packet. + public static readonly Guid MEDIASUBTYPE_MPEG1Payload = new Guid("e436eb81-524f-11ce-9f53-0020af0ba770"); // MPEG1 Audio Payload. + public static readonly Guid MEDIASUBTYPE_MPEG2_AUDIO = new Guid("e06d802b-db46-11cf-b4d1-00805f6cbbea"); // MPEG-2 audio data + public static readonly Guid MEDIASUBTYPE_DVD_LPCM_AUDIO = new Guid("e06d8032-db46-11cf-b4d1-00805f6cbbea"); // DVD audio data + public static readonly Guid MEDIASUBTYPE_DRM_Audio = new Guid("00000009-0000-0010-8000-00aa00389b71"); // Corresponds to WAVE_FORMAT_DRM. + public static readonly Guid MEDIASUBTYPE_IEEE_FLOAT = new Guid("00000003-0000-0010-8000-00aa00389b71"); // Corresponds to WAVE_FORMAT_IEEE_FLOAT + public static readonly Guid MEDIASUBTYPE_DOLBY_AC3 = new Guid("e06d802c-db46-11cf-b4d1-00805f6cbbea"); // Dolby data + public static readonly Guid MEDIASUBTYPE_DOLBY_AC3_SPDIF = new Guid("00000092-0000-0010-8000-00aa00389b71"); // Dolby AC3 over SPDIF. + public static readonly Guid MEDIASUBTYPE_RAW_SPORT = new Guid("00000240-0000-0010-8000-00aa00389b71"); // Equivalent to MEDIASUBTYPE_DOLBY_AC3_SPDIF. + public static readonly Guid MEDIASUBTYPE_SPDIF_TAG_241h = new Guid("00000241-0000-0010-8000-00aa00389b71"); // Equivalent to MEDIASUBTYPE_DOLBY_AC3_SPDIF. + //http://msdn.microsoft.com/en-us/library/dd757532%28VS.85%29.aspx + public static readonly Guid WMMEDIASUBTYPE_MP3 = new Guid("00000055-0000-0010-8000-00AA00389B71"); + // others? + public static readonly Guid MEDIASUBTYPE_WAVE = new Guid("e436eb8b-524f-11ce-9f53-0020af0ba770"); + public static readonly Guid MEDIASUBTYPE_AU = new Guid("e436eb8c-524f-11ce-9f53-0020af0ba770"); + public static readonly Guid MEDIASUBTYPE_AIFF = new Guid("e436eb8d-524f-11ce-9f53-0020af0ba770"); + + public static readonly Guid[] AudioSubTypes = new Guid[] + { + MEDIASUBTYPE_PCM, + MEDIASUBTYPE_PCMAudioObsolete, + MEDIASUBTYPE_MPEG1Packet, + MEDIASUBTYPE_MPEG1Payload, + MEDIASUBTYPE_MPEG2_AUDIO, + MEDIASUBTYPE_DVD_LPCM_AUDIO, + MEDIASUBTYPE_DRM_Audio, + MEDIASUBTYPE_IEEE_FLOAT, + MEDIASUBTYPE_DOLBY_AC3, + MEDIASUBTYPE_DOLBY_AC3_SPDIF, + MEDIASUBTYPE_RAW_SPORT, + MEDIASUBTYPE_SPDIF_TAG_241h, + WMMEDIASUBTYPE_MP3, + }; + + public static readonly string[] AudioSubTypeNames = new string[] + { + "PCM", + "PCM Obsolete", + "MPEG1Packet", + "MPEG1Payload", + "MPEG2_AUDIO", + "DVD_LPCM_AUDIO", + "DRM_Audio", + "IEEE_FLOAT", + "DOLBY_AC3", + "DOLBY_AC3_SPDIF", + "RAW_SPORT", + "SPDIF_TAG_241h", + "MP3" + }; + public static string GetAudioSubtypeName(Guid subType) + { + for (int index = 0; index < AudioSubTypes.Length; index++) + { + if (subType == AudioSubTypes[index]) + { + return AudioSubTypeNames[index]; + } + } + return subType.ToString(); + } + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AudioMediaSubtypes.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AudioMediaSubtypes.cs.meta new file mode 100644 index 0000000..19780f0 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/AudioMediaSubtypes.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0ee08990d14d50946a1ad3ad9c69e4d3 +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/Gsm610WaveFormat.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/Gsm610WaveFormat.cs new file mode 100644 index 0000000..0d58f90 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/Gsm610WaveFormat.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using System.IO; + +namespace NAudio.Wave.WZT +{ + /// + /// GSM 610 + /// + [StructLayout(LayoutKind.Sequential, Pack = 2)] + public class Gsm610WaveFormat : WaveFormat + { + private short samplesPerBlock; + + /// + /// Creates a GSM 610 WaveFormat + /// For now hardcoded to 13kbps + /// + public Gsm610WaveFormat() + { + this.waveFormatTag = WaveFormatEncoding.Gsm610; + this.channels = 1; + this.averageBytesPerSecond = 1625; + this.bitsPerSample = 0; // must be zero + this.blockAlign = 65; + this.sampleRate = 8000; + + this.extraSize = 2; + this.samplesPerBlock = 320; + } + + /// + /// Samples per block + /// + public short SamplesPerBlock { get { return this.samplesPerBlock; } } + + /// + /// Writes this structure to a BinaryWriter + /// + public override void Serialize(BinaryWriter writer) + { + base.Serialize(writer); + writer.Write(samplesPerBlock); + } + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/Gsm610WaveFormat.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/Gsm610WaveFormat.cs.meta new file mode 100644 index 0000000..87002c3 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/Gsm610WaveFormat.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c029ee315c0c6834e90f04f619338b3b +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/IWaveProvider.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/IWaveProvider.cs new file mode 100644 index 0000000..a44ccd8 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/IWaveProvider.cs @@ -0,0 +1,26 @@ +using System; +using NAudio.Lame; + +namespace NAudio.Wave.WZT +{ + /// + /// Generic interface for all WaveProviders. + /// + public interface IWaveProvider + { + /// + /// Gets the WaveFormat of this WaveProvider. + /// + /// The wave format. + WaveFormat WaveFormat { get; } + + /// + /// Fill the specified buffer with wave data. + /// + /// The buffer to fill of wave data. + /// Offset into buffer + /// The number of bytes to read + /// the number of bytes written to the buffer. + int Read(byte[] buffer, int offset, int count); + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/IWaveProvider.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/IWaveProvider.cs.meta new file mode 100644 index 0000000..e7ecddb --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/IWaveProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fbfb88f187675b0448dcf66ca372dc8f +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/RiffChunk.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/RiffChunk.cs new file mode 100644 index 0000000..ac45f8e --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/RiffChunk.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace NAudio.Wave.WZT +{ + /// + /// Holds information about a RIFF file chunk + /// + public class RiffChunk + { + int identifier; + int length; + long streamPosition; + + /// + /// Creates a RiffChunk object + /// + public RiffChunk(int identifier, int length, long streamPosition) + { + this.identifier = identifier; + this.length = length; + this.streamPosition = streamPosition; + } + + /// + /// The chunk identifier + /// + public int Identifier + { + get + { + return identifier; + } + } + + /// + /// The chunk identifier converted to a string + /// + public string IdentifierAsString + { + get + { + return ASCIIEncoding.ASCII.GetString(BitConverter.GetBytes(identifier)); + } + } + + /// + /// The chunk length + /// + public int Length + { + get + { + return length; + } + } + + /// + /// The stream position this chunk is located at + /// + public long StreamPosition + { + get + { + return streamPosition; + } + } + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/RiffChunk.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/RiffChunk.cs.meta new file mode 100644 index 0000000..83123f4 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/RiffChunk.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fe306abf31fdbe64481deb697a77ba52 +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFileReader.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFileReader.cs new file mode 100644 index 0000000..a6b4a7e --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFileReader.cs @@ -0,0 +1,322 @@ +using System; +using System.IO; +using System.Text; +using System.Collections.Generic; +using System.Diagnostics; + +namespace NAudio.Wave.WZT +{ + /// This class supports the reading of WAV files, + /// providing a repositionable WaveStream that returns the raw data + /// contained in the WAV file + /// + public class WaveFileReader : WaveStream + { + private WaveFormat waveFormat; + private Stream waveStream; + private bool ownInput; + private long dataPosition; + private int dataChunkLength; + private List chunks = new List(); + + /// Supports opening a WAV file + /// The WAV file format is a real mess, but we will only + /// support the basic WAV file format which actually covers the vast + /// majority of WAV files out there. For more WAV file format information + /// visit www.wotsit.org. If you have a WAV file that can't be read by + /// this class, email it to the NAudio project and we will probably + /// fix this reader to support it + /// + public WaveFileReader(String waveFile) : + this(File.OpenRead(waveFile)) + { + ownInput = true; + } + + /// + /// Creates a Wave File Reader based on an input stream + /// + /// The input stream containing a WAV file including header + public WaveFileReader(Stream inputStream) + { + this.waveStream = inputStream; + ReadWaveHeader(waveStream, out waveFormat, out dataPosition, out dataChunkLength, chunks); + Position = 0; + } + + /// + /// Reads the header part of a WAV file from a stream + /// + /// The stream, positioned at the start of audio data + /// The format found + /// The position of the data chunk + /// The length of the data chunk + /// Additional chunks found + public static void ReadWaveHeader(Stream stream, out WaveFormat format, out long dataChunkPosition, out int dataChunkLength, List chunks) + { + dataChunkPosition = -1; + format = null; + BinaryReader br = new BinaryReader(stream); + if (Encoding.ASCII.GetString(br.ReadBytes(4)) != "RIFF")//WaveInterop.mmioStringToFOURCC("RIFF", 0) + { + throw new FormatException("Not a WAVE file - no RIFF header"); + } + uint fileSize = br.ReadUInt32(); // read the file size (minus 8 bytes) + if (Encoding.ASCII.GetString(br.ReadBytes(4)) != "WAVE")//WaveInterop.mmioStringToFOURCC("WAVE", 0) + { + throw new FormatException("Not a WAVE file - no WAVE header"); + } + int dataChunkID = BitConverter.ToInt32(Encoding.UTF8.GetBytes("data"), 0); ;//WaveInterop.mmioStringToFOURCC("data", 0) + int formatChunkId = BitConverter.ToInt32(Encoding.UTF8.GetBytes("fmt "), 0); ;//WaveInterop.mmioStringToFOURCC("fmt ", 0) + dataChunkLength = 0; + + // sometimes a file has more data than is specified after the RIFF header + long stopPosition = Math.Min(fileSize + 8, stream.Length); + + // this -8 is so we can be sure that there are at least 8 bytes for a chunk id and length + while (stream.Position <= stopPosition - 8) + { + Int32 chunkIdentifier = br.ReadInt32(); + Int32 chunkLength = br.ReadInt32(); + if (chunkIdentifier == dataChunkID) + { + dataChunkPosition = stream.Position; + dataChunkLength = chunkLength; + stream.Position += chunkLength; + } + else if (chunkIdentifier == formatChunkId) + { + format = WaveFormat.FromFormatChunk(br, chunkLength); + } + else + { + // check for invalid chunk length + if (chunkLength < 0 || chunkLength > stream.Length - stream.Position) + { + Debug.Assert(false, String.Format("Invalid chunk length {0}, pos: {1}. length: {2}", + chunkLength, stream.Position, stream.Length)); + // an exception will be thrown further down if we haven't got a format and data chunk yet, + // otherwise we will tolerate this file despite it having corrupt data at the end + break; + } + if (chunks != null) + { + chunks.Add(new RiffChunk(chunkIdentifier, chunkLength, stream.Position)); + } + stream.Position += chunkLength; + } + } + + if (format == null) + { + throw new FormatException("Invalid WAV file - No fmt chunk found"); + } + if (dataChunkPosition == -1) + { + throw new FormatException("Invalid WAV file - No data chunk found"); + } + } + + /// + /// Gets a list of the additional chunks found in this file + /// + public List ExtraChunks + { + get + { + return chunks; + } + } + + /// + /// Gets the data for the specified chunk + /// + public byte[] GetChunkData(RiffChunk chunk) + { + long oldPosition = waveStream.Position; + waveStream.Position = chunk.StreamPosition; + byte[] data = new byte[chunk.Length]; + waveStream.Read(data, 0, data.Length); + waveStream.Position = oldPosition; + return data; + } + + /// + /// Cleans up the resources associated with this WaveFileReader + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + // Release managed resources. + if (waveStream != null) + { + // only dispose our source if we created it + if (ownInput) + { + waveStream.Close(); + } + waveStream = null; + } + } + else + { + System.Diagnostics.Debug.Assert(false, "WaveFileReader was not disposed"); + } + // Release unmanaged resources. + // Set large fields to null. + // Call Dispose on your base class. + base.Dispose(disposing); + } + + /// + /// + /// + public override WaveFormat WaveFormat + { + get + { + return waveFormat; + } + } + + /// + /// This is the length of audio data contained in this WAV file, in bytes + /// (i.e. the byte length of the data chunk, not the length of the WAV file itself) + /// + /// + public override long Length + { + get + { + return dataChunkLength; + } + } + + /// + /// Number of Samples (if possible to calculate) + /// This currently does not take into account number of channels, so + /// divide again by number of channels if you want the number of + /// audio 'frames' + /// + public long SampleCount + { + get + { + if (waveFormat.Encoding == WaveFormatEncoding.Pcm || + waveFormat.Encoding == WaveFormatEncoding.Extensible || + waveFormat.Encoding == WaveFormatEncoding.IeeeFloat) + { + return dataChunkLength / BlockAlign; + } + else + { + // n.b. if there is a fact chunk, you can use that to get the number of samples + throw new InvalidOperationException("Sample count is calculated only for the standard encodings"); + } + } + } + + /// + /// Position in the WAV data chunk. + /// + /// + public override long Position + { + get + { + return waveStream.Position - dataPosition; + } + set + { + lock (this) + { + value = Math.Min(value, Length); + // make sure we don't get out of sync + value -= (value % waveFormat.BlockAlign); + waveStream.Position = value + dataPosition; + } + } + } + + /// + /// Reads bytes from the Wave File + /// + /// + public override int Read(byte[] array, int offset, int count) + { + if (count % waveFormat.BlockAlign != 0) + { + throw new ArgumentException(String.Format("Must read complete blocks: requested {0}, block align is {1}", count, this.WaveFormat.BlockAlign)); + } + // sometimes there is more junk at the end of the file past the data chunk + if (Position + count > dataChunkLength) + { + count = dataChunkLength - (int)Position; + } + return waveStream.Read(array, offset, count); + } + + /// + /// Attempts to read a sample into a float. n.b. only applicable for uncompressed formats + /// Will normalise the value read into the range -1.0f to 1.0f if it comes from a PCM encoding + /// + /// False if the end of the WAV data chunk was reached + public bool TryReadFloat(out float sampleValue) + { + sampleValue = 0.0f; + // 16 bit PCM data + if (waveFormat.BitsPerSample == 16) + { + byte[] value = new byte[2]; + int read = Read(value, 0, 2); + if (read < 2) + return false; + sampleValue = (float)BitConverter.ToInt16(value, 0) / 32768f; + return true; + } + // 24 bit PCM data + else if (waveFormat.BitsPerSample == 24) + { + byte[] value = new byte[4]; + int read = Read(value, 0, 3); + if (read < 3) + return false; + if (value[2] > 0x7f) + { + value[3] = 0xff; + } + else + { + value[3] = 0x00; + } + sampleValue = (float)BitConverter.ToInt32(value, 0) / (float)(0x800000); + return true; + } + // 32 bit PCM data + if (waveFormat.BitsPerSample == 32 && waveFormat.Encoding == WaveFormatEncoding.Extensible) + { + byte[] value = new byte[4]; + int read = Read(value, 0, 4); + if (read < 4) + return false; + sampleValue = (float)BitConverter.ToInt32(value, 0) / ((float)(Int32.MaxValue) + 1f); + return true; + } + // IEEE float data + if (waveFormat.BitsPerSample == 32 && waveFormat.Encoding == WaveFormatEncoding.IeeeFloat) + { + byte[] value = new byte[4]; + int read = Read(value, 0, 4); + if (read < 4) + return false; + sampleValue = BitConverter.ToSingle(value, 0); + return true; + } + else + { + throw new ApplicationException("Only 16, 24 or 32 bit PCM or IEEE float audio data supported"); + } + } + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFileReader.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFileReader.cs.meta new file mode 100644 index 0000000..04d869d --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFileReader.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b8920394775cdb6438bd7656c5c68841 +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormat.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormat.cs new file mode 100644 index 0000000..46c5b1b --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormat.cs @@ -0,0 +1,389 @@ +using System; +using System.IO; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace NAudio.Wave.WZT +{ + /// + /// Represents a Wave file format + /// + [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=2)] + public class WaveFormat + { + /// format type + protected WaveFormatEncoding waveFormatTag; + /// number of channels + protected short channels; + /// sample rate + protected int sampleRate; + /// for buffer estimation + protected int averageBytesPerSecond; + /// block size of data + protected short blockAlign; + /// number of bits per sample of mono data + protected short bitsPerSample; + /// number of following bytes + protected short extraSize; + + /// + /// Creates a new PCM 44.1Khz stereo 16 bit format + /// + public WaveFormat() : this(44100,16,2) + { + + } + + /// + /// Creates a new 16 bit wave format with the specified sample + /// rate and channel count + /// + /// Sample Rate + /// Number of channels + public WaveFormat(int sampleRate, int channels) + : this(sampleRate, 16, channels) + { + } + + /// + /// Gets the size of a wave buffer equivalent to the latency in milliseconds. + /// + /// The milliseconds. + /// + public int ConvertLatencyToByteSize(int milliseconds) + { + int bytes = (int) ((AverageBytesPerSecond/1000.0)*milliseconds); + if ((bytes%BlockAlign) != 0) + { + // Return the upper BlockAligned + bytes = bytes + BlockAlign - (bytes % BlockAlign); + } + return bytes; + } + + /// + /// Creates a WaveFormat with custom members + /// + /// The encoding + /// Sample Rate + /// Number of channels + /// Average Bytes Per Second + /// Block Align + /// Bits Per Sample + /// + public static WaveFormat CreateCustomFormat(WaveFormatEncoding tag, int sampleRate, int channels, int averageBytesPerSecond, int blockAlign, int bitsPerSample) + { + WaveFormat waveFormat = new WaveFormat(); + waveFormat.waveFormatTag = tag; + waveFormat.channels = (short)channels; + waveFormat.sampleRate = sampleRate; + waveFormat.averageBytesPerSecond = averageBytesPerSecond; + waveFormat.blockAlign = (short)blockAlign; + waveFormat.bitsPerSample = (short)bitsPerSample; + waveFormat.extraSize = 0; + return waveFormat; + } + + /// + /// Creates an A-law wave format + /// + /// Sample Rate + /// Number of Channels + /// Wave Format + public static WaveFormat CreateALawFormat(int sampleRate, int channels) + { + return CreateCustomFormat(WaveFormatEncoding.ALaw, sampleRate, channels, sampleRate * channels, 1, 8); + } + + /// + /// Creates a Mu-law wave format + /// + /// Sample Rate + /// Number of Channels + /// Wave Format + public static WaveFormat CreateMuLawFormat(int sampleRate, int channels) + { + return CreateCustomFormat(WaveFormatEncoding.MuLaw, sampleRate, channels, sampleRate * channels, 1, 8); + } + + /// + /// Creates a new PCM format with the specified sample rate, bit depth and channels + /// + public WaveFormat(int rate, int bits, int channels) + { + if (channels < 1) + { + throw new ArgumentOutOfRangeException("Channels must be 1 or greater", "channels"); + } + // minimum 16 bytes, sometimes 18 for PCM + this.waveFormatTag = WaveFormatEncoding.Pcm; + this.channels = (short)channels; + this.sampleRate = rate; + this.bitsPerSample = (short)bits; + this.extraSize = 0; + + this.blockAlign = (short)(channels * (bits / 8)); + this.averageBytesPerSecond = this.sampleRate * this.blockAlign; + } + + /// + /// Creates a new 32 bit IEEE floating point wave format + /// + /// sample rate + /// number of channels + public static WaveFormat CreateIeeeFloatWaveFormat(int sampleRate, int channels) + { + WaveFormat wf = new WaveFormat(); + wf.waveFormatTag = WaveFormatEncoding.IeeeFloat; + wf.channels = (short)channels; + wf.bitsPerSample = 32; + wf.sampleRate = sampleRate; + wf.blockAlign = (short) (4*channels); + wf.averageBytesPerSecond = sampleRate * wf.blockAlign; + wf.extraSize = 0; + return wf; + } + + /// + /// Helper function to retrieve a WaveFormat structure from a pointer + /// + /// WaveFormat structure + /// + public static WaveFormat MarshalFromPtr(IntPtr pointer) + { + WaveFormat waveFormat = (WaveFormat)Marshal.PtrToStructure(pointer, typeof(WaveFormat)); + switch (waveFormat.Encoding) + { + case WaveFormatEncoding.Pcm: + // can't rely on extra size even being there for PCM so blank it to avoid reading + // corrupt data + waveFormat.extraSize = 0; + break; + case WaveFormatEncoding.Extensible: + waveFormat = (WaveFormatExtensible)Marshal.PtrToStructure(pointer, typeof(WaveFormatExtensible)); + break; + case WaveFormatEncoding.Adpcm: + waveFormat = (AdpcmWaveFormat)Marshal.PtrToStructure(pointer, typeof(AdpcmWaveFormat)); + break; + case WaveFormatEncoding.Gsm610: + waveFormat = (Gsm610WaveFormat)Marshal.PtrToStructure(pointer, typeof(Gsm610WaveFormat)); + break; + default: + if (waveFormat.ExtraSize > 0) + { + waveFormat = (WaveFormatExtraData)Marshal.PtrToStructure(pointer, typeof(WaveFormatExtraData)); + } + break; + } + return waveFormat; + } + + /// + /// Helper function to marshal WaveFormat to an IntPtr + /// + /// WaveFormat + /// IntPtr to WaveFormat structure (needs to be freed by callee) + public static IntPtr MarshalToPtr(WaveFormat format) + { + int formatSize = Marshal.SizeOf(format); + IntPtr formatPointer = Marshal.AllocHGlobal(formatSize); + Marshal.StructureToPtr(format, formatPointer, false); + return formatPointer; + } + + /// + /// Reads in a WaveFormat (with extra data) from a fmt chunk (chunk identifier and + /// length should already have been read) + /// + /// Binary reader + /// Format chunk length + /// A WaveFormatExtraData + public static WaveFormat FromFormatChunk(BinaryReader br, int formatChunkLength) + { + WaveFormatExtraData waveFormat = new WaveFormatExtraData(); + waveFormat.ReadWaveFormat(br, formatChunkLength); + waveFormat.ReadExtraData(br); + return waveFormat; + } + + private void ReadWaveFormat(BinaryReader br, int formatChunkLength) + { + if (formatChunkLength < 16) + throw new ApplicationException("Invalid WaveFormat Structure"); + this.waveFormatTag = (WaveFormatEncoding)br.ReadUInt16(); + this.channels = br.ReadInt16(); + this.sampleRate = br.ReadInt32(); + this.averageBytesPerSecond = br.ReadInt32(); + this.blockAlign = br.ReadInt16(); + this.bitsPerSample = br.ReadInt16(); + if (formatChunkLength > 16) + { + this.extraSize = br.ReadInt16(); + if (this.extraSize != formatChunkLength - 18) + { + Debug.WriteLine("Format chunk mismatch"); + this.extraSize = (short)(formatChunkLength - 18); + } + } + } + + /// + /// Reads a new WaveFormat object from a stream + /// + /// A binary reader that wraps the stream + public WaveFormat(BinaryReader br) + { + int formatChunkLength = br.ReadInt32(); + this.ReadWaveFormat(br, formatChunkLength); + } + + /// + /// Reports this WaveFormat as a string + /// + /// String describing the wave format + public override string ToString() + { + switch (this.waveFormatTag) + { + case WaveFormatEncoding.Pcm: + case WaveFormatEncoding.Extensible: + // extensible just has some extra bits after the PCM header + return String.Format("{0} bit PCM: {1}kHz {2} channels", + bitsPerSample, sampleRate / 1000, channels); + default: + return this.waveFormatTag.ToString(); + } + } + + /// + /// Compares with another WaveFormat object + /// + /// Object to compare to + /// True if the objects are the same + public override bool Equals(object obj) + { + WaveFormat other = obj as WaveFormat; + if(other != null) + { + return waveFormatTag == other.waveFormatTag && + channels == other.channels && + sampleRate == other.sampleRate && + averageBytesPerSecond == other.averageBytesPerSecond && + blockAlign == other.blockAlign && + bitsPerSample == other.bitsPerSample; + } + return false; + } + + /// + /// Provides a Hashcode for this WaveFormat + /// + /// A hashcode + public override int GetHashCode() + { + return (int) waveFormatTag ^ + (int) channels ^ + sampleRate ^ + averageBytesPerSecond ^ + (int) blockAlign ^ + (int) bitsPerSample; + } + + /// + /// Returns the encoding type used + /// + public WaveFormatEncoding Encoding + { + get + { + return waveFormatTag; + } + } + + /// + /// Writes this WaveFormat object to a stream + /// + /// the output stream + public virtual void Serialize(BinaryWriter writer) + { + writer.Write((int)(18 + extraSize)); // wave format length + writer.Write((short)Encoding); + writer.Write((short)Channels); + writer.Write((int)SampleRate); + writer.Write((int)AverageBytesPerSecond); + writer.Write((short)BlockAlign); + writer.Write((short)BitsPerSample); + writer.Write((short)extraSize); + } + + /// + /// Returns the number of channels (1=mono,2=stereo etc) + /// + public int Channels + { + get + { + return channels; + } + } + + /// + /// Returns the sample rate (samples per second) + /// + public int SampleRate + { + get + { + return sampleRate; + } + } + + /// + /// Returns the average number of bytes used per second + /// + public int AverageBytesPerSecond + { + get + { + return averageBytesPerSecond; + } + } + + /// + /// Returns the block alignment + /// + public virtual int BlockAlign + { + get + { + return blockAlign; + } + } + + /// + /// Returns the number of bits per sample (usually 16 or 32, sometimes 24 or 8) + /// Can be 0 for some codecs + /// + public int BitsPerSample + { + get + { + return bitsPerSample; + } + } + + /// + /// Returns the number of extra bytes used by this waveformat. Often 0, + /// except for compressed formats which store extra data after the WAVEFORMATEX header + /// + public int ExtraSize + { + get + { + return extraSize; + } + } + + + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormat.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormat.cs.meta new file mode 100644 index 0000000..942acc2 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormat.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f709c5c91c6ee1347bbdbfb71e25563d +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatEncoding.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatEncoding.cs new file mode 100644 index 0000000..0639e05 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatEncoding.cs @@ -0,0 +1,314 @@ +using System; + +namespace NAudio.Wave.WZT +{ + /// + /// Summary description for WaveFormatEncoding. + /// + public enum WaveFormatEncoding : ushort + { + /// WAVE_FORMAT_UNKNOWN, Microsoft Corporation + Unknown = 0x0000, + /// WAVE_FORMAT_PCM Microsoft Corporation + Pcm = 0x0001, + /// WAVE_FORMAT_ADPCM Microsoft Corporation + Adpcm = 0x0002, + /// WAVE_FORMAT_IEEE_FLOAT Microsoft Corporation + IeeeFloat = 0x0003, + /// WAVE_FORMAT_VSELP Compaq Computer Corp. + Vselp = 0x0004, + /// WAVE_FORMAT_IBM_CVSD IBM Corporation + IbmCvsd = 0x0005, + /// WAVE_FORMAT_ALAW Microsoft Corporation + ALaw = 0x0006, + /// WAVE_FORMAT_MULAW Microsoft Corporation + MuLaw = 0x0007, + /// WAVE_FORMAT_DTS Microsoft Corporation + Dts = 0x0008, + /// WAVE_FORMAT_DRM Microsoft Corporation + Drm = 0x0009, + /// WAVE_FORMAT_OKI_ADPCM OKI + OkiAdpcm = 0x0010, + /// WAVE_FORMAT_DVI_ADPCM Intel Corporation + DviAdpcm = 0x0011, + /// WAVE_FORMAT_IMA_ADPCM Intel Corporation + ImaAdpcm = DviAdpcm, + /// WAVE_FORMAT_MEDIASPACE_ADPCM Videologic + MediaspaceAdpcm = 0x0012, + /// WAVE_FORMAT_SIERRA_ADPCM Sierra Semiconductor Corp + SierraAdpcm = 0x0013, + /// WAVE_FORMAT_G723_ADPCM Antex Electronics Corporation + G723Adpcm = 0x0014, + /// WAVE_FORMAT_DIGISTD DSP Solutions, Inc. + DigiStd = 0x0015, + /// WAVE_FORMAT_DIGIFIX DSP Solutions, Inc. + DigiFix = 0x0016, + /// WAVE_FORMAT_DIALOGIC_OKI_ADPCM Dialogic Corporation + DialogicOkiAdpcm = 0x0017, + /// WAVE_FORMAT_MEDIAVISION_ADPCM Media Vision, Inc. + MediaVisionAdpcm = 0x0018, + /// WAVE_FORMAT_CU_CODEC Hewlett-Packard Company + CUCodec = 0x0019, + /// WAVE_FORMAT_YAMAHA_ADPCM Yamaha Corporation of America + YamahaAdpcm = 0x0020, + /// WAVE_FORMAT_SONARC Speech Compression + SonarC = 0x0021, + /// WAVE_FORMAT_DSPGROUP_TRUESPEECH DSP Group, Inc + DspGroupTrueSpeech = 0x0022, + /// WAVE_FORMAT_ECHOSC1 Echo Speech Corporation + EchoSpeechCorporation1 = 0x0023, + /// WAVE_FORMAT_AUDIOFILE_AF36, Virtual Music, Inc. + AudioFileAf36 = 0x0024, + /// WAVE_FORMAT_APTX Audio Processing Technology + Aptx = 0x0025, + /// WAVE_FORMAT_AUDIOFILE_AF10, Virtual Music, Inc. + AudioFileAf10 = 0x0026, + /// WAVE_FORMAT_PROSODY_1612, Aculab plc + Prosody1612 = 0x0027, + /// WAVE_FORMAT_LRC, Merging Technologies S.A. + Lrc = 0x0028, + /// WAVE_FORMAT_DOLBY_AC2, Dolby Laboratories + DolbyAc2 = 0x0030, + /// WAVE_FORMAT_GSM610, Microsoft Corporation + Gsm610 = 0x0031, + /// WAVE_FORMAT_MSNAUDIO, Microsoft Corporation + MsnAudio = 0x0032, + /// WAVE_FORMAT_ANTEX_ADPCME, Antex Electronics Corporation + AntexAdpcme = 0x0033, + /// WAVE_FORMAT_CONTROL_RES_VQLPC, Control Resources Limited + ControlResVqlpc = 0x0034, + /// WAVE_FORMAT_DIGIREAL, DSP Solutions, Inc. + DigiReal = 0x0035, + /// WAVE_FORMAT_DIGIADPCM, DSP Solutions, Inc. + DigiAdpcm = 0x0036, + /// WAVE_FORMAT_CONTROL_RES_CR10, Control Resources Limited + ControlResCr10 = 0x0037, + /// + 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 + /// + Mpeg = 0x0050, // WAVE_FORMAT_MPEG, Microsoft Corporation + /// + WAVE_FORMAT_RT24 = 0x0052, // InSoft, Inc. + /// + WAVE_FORMAT_PAC = 0x0053, // InSoft, Inc. + /// + MpegLayer3 = 0x0055, // WAVE_FORMAT_MPEGLAYER3, 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_GSM + Gsm = 0x00A1, + /// WAVE_FORMAT_G729 + G729 = 0x00A2, + /// WAVE_FORMAT_G723 + G723 = 0x00A3, + /// WAVE_FORMAT_ACELP + Acelp = 0x00A4, + /// + 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, Microsoft Corporation + /// + WAVE_FORMAT_WMAUDIO2 = 0x0161, + /// + /// WAVE_FORMAT_WMAUDIO3, Microsoft Corporation + /// + WAVE_FORMAT_WMAUDIO3 = 0x0162, + /// + 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_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_DVM = 0x2000, // FAST Multimedia AG + /// WAVE_FORMAT_EXTENSIBLE + Extensible = 0xFFFE, // Microsoft + /// + WAVE_FORMAT_DEVELOPMENT = 0xFFFF, + + // others - not from MS headers + /// WAVE_FORMAT_VORBIS1 "Og" Original stream compatible + Vorbis1 = 0x674f, + /// WAVE_FORMAT_VORBIS2 "Pg" Have independent header + Vorbis2 = 0x6750, + /// WAVE_FORMAT_VORBIS3 "Qg" Have no codebook header + Vorbis3 = 0x6751, + /// WAVE_FORMAT_VORBIS1P "og" Original stream compatible + Vorbis1P = 0x676f, + /// WAVE_FORMAT_VORBIS2P "pg" Have independent headere + Vorbis2P = 0x6770, + /// WAVE_FORMAT_VORBIS3P "qg" Have no codebook header + Vorbis3P = 0x6771, + + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatEncoding.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatEncoding.cs.meta new file mode 100644 index 0000000..13fa73a --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatEncoding.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 07c489cad6787a04eadcc0f7b39dfc3e +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtensible.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtensible.cs new file mode 100644 index 0000000..f3fb626 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtensible.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using NAudio.Dmo.WZT; + +namespace NAudio.Wave.WZT +{ + /// + /// WaveFormatExtensible + /// http://www.microsoft.com/whdc/device/audio/multichaud.mspx + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 2)] + public class WaveFormatExtensible : WaveFormat + { + short wValidBitsPerSample; // bits of precision, or is wSamplesPerBlock if wBitsPerSample==0 + int dwChannelMask; // which channels are present in stream + Guid subFormat; + + /// + /// Parameterless constructor for marshalling + /// + WaveFormatExtensible() + { + } + + /// + /// Creates a new WaveFormatExtensible for PCM or IEEE + /// + public WaveFormatExtensible(int rate, int bits, int channels) + : base(rate, bits, channels) + { + waveFormatTag = WaveFormatEncoding.Extensible; + extraSize = 22; + wValidBitsPerSample = (short) bits; + for (int n = 0; n < channels; n++) + { + dwChannelMask |= (1 << n); + } + if (bits == 32) + { + // KSDATAFORMAT_SUBTYPE_IEEE_FLOAT + subFormat = AudioMediaSubtypes.MEDIASUBTYPE_IEEE_FLOAT; // new Guid("00000003-0000-0010-8000-00aa00389b71"); + } + else + { + // KSDATAFORMAT_SUBTYPE_PCM + subFormat = AudioMediaSubtypes.MEDIASUBTYPE_PCM; // new Guid("00000001-0000-0010-8000-00aa00389b71"); + } + + } + + /// + /// SubFormat (may be one of AudioMediaSubtypes) + /// + public Guid SubFormat { get { return subFormat; } } + + /// + /// Serialize + /// + /// + public override void Serialize(System.IO.BinaryWriter writer) + { + base.Serialize(writer); + writer.Write(wValidBitsPerSample); + writer.Write(dwChannelMask); + byte[] guid = subFormat.ToByteArray(); + writer.Write(guid, 0, guid.Length); + } + + /// + /// String representation + /// + public override string ToString() + { + return String.Format("{0} wBitsPerSample:{1} dwChannelMask:{2} subFormat:{3} extraSize:{4}", + base.ToString(), + wValidBitsPerSample, + dwChannelMask, + subFormat, + extraSize); + } + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtensible.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtensible.cs.meta new file mode 100644 index 0000000..9677a9c --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtensible.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5d0e3542e85464541a0022c04d0da8b6 +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtraData.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtraData.cs new file mode 100644 index 0000000..f6de559 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtraData.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using System.IO; + +namespace NAudio.Wave.WZT +{ + /// + /// This class used for marshalling from unmanaged code + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 2)] + public class WaveFormatExtraData : WaveFormat + { + // try with 100 bytes for now, increase if necessary + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 100)] + private byte[] extraData = new byte[100]; + + /// + /// Allows the extra data to be read + /// + public byte[] ExtraData { get { return extraData; } } + + /// + /// parameterless constructor for marshalling + /// + internal WaveFormatExtraData() + { + } + + /// + /// Reads this structure from a BinaryReader + /// + public WaveFormatExtraData(BinaryReader reader) + : base(reader) + { + ReadExtraData(reader); + } + + internal void ReadExtraData(BinaryReader reader) + { + if (this.extraSize > 0) + { + reader.Read(extraData, 0, extraSize); + } + } + + /// + /// Writes this structure to a BinaryWriter + /// + public override void Serialize(BinaryWriter writer) + { + base.Serialize(writer); + if (extraSize > 0) + { + writer.Write(extraData, 0, extraSize); + } + } + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtraData.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtraData.cs.meta new file mode 100644 index 0000000..34b906e --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveFormatExtraData.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fad90a98c9bb79f4e86bf7f8e56d85b9 +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveStream.cs b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveStream.cs new file mode 100644 index 0000000..69365b7 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveStream.cs @@ -0,0 +1,143 @@ +// created on 27/12/2002 at 20:20 +using System; +using System.IO; +using NAudio.Lame; + +namespace NAudio.Wave.WZT +{ + /// + /// Base class for all WaveStream classes. Derives from stream. + /// + public abstract class WaveStream : Stream, IWaveProvider + { + /// + /// Retrieves the WaveFormat for this stream + /// + public abstract WaveFormat WaveFormat { get; } + + // base class includes long Position get; set + // base class includes long Length get + // base class includes Read + // base class includes Dispose + + /// + /// We can read from this stream + /// + public override bool CanRead { get { return true; } } + + /// + /// We can seek within this stream + /// + public override bool CanSeek { get { return true; } } + + /// + /// We can't write to this stream + /// + public override bool CanWrite { get { return false; } } + + /// + /// Flush does not need to do anything + /// See + /// + public override void Flush() { } + + /// + /// An alternative way of repositioning. + /// See + /// + public override long Seek(long offset, SeekOrigin origin) + { + if (origin == SeekOrigin.Begin) + Position = offset; + else if (origin == SeekOrigin.Current) + Position += offset; + else + Position = Length + offset; + return Position; + } + + /// + /// Sets the length of the WaveStream. Not Supported. + /// + /// + public override void SetLength(long length) + { + throw new NotSupportedException("Can't set length of a WaveFormatString"); + } + + /// + /// Writes to the WaveStream. Not Supported. + /// + public override void Write(byte[] buffer, int offset, int count) + { + throw new NotSupportedException("Can't write to a WaveFormatString"); + } + + /// + /// The block alignment for this wavestream. Do not modify the Position + /// to anything that is not a whole multiple of this value + /// + public virtual int BlockAlign + { + get + { + return WaveFormat.BlockAlign; + } + } + + /// + /// Moves forward or backwards the specified number of seconds in the stream + /// + /// Number of seconds to move, can be negative + public void Skip(int seconds) + { + lock (this) + { + long newPosition = Position + WaveFormat.AverageBytesPerSecond * seconds; + if (newPosition > Length) + Position = Length; + else if (newPosition < 0) + Position = 0; + else + Position = newPosition; + } + } + + /// + /// The current position in the stream in Time format + /// + public virtual TimeSpan CurrentTime + { + get + { + return TimeSpan.FromSeconds((double)Position / WaveFormat.AverageBytesPerSecond); + } + set + { + Position = (long) (value.TotalSeconds * WaveFormat.AverageBytesPerSecond); + } + } + + /// + /// Total length in real-time of the stream (may be an estimate for compressed files) + /// + public virtual TimeSpan TotalTime + { + get + { + + return TimeSpan.FromSeconds((double) Length / WaveFormat.AverageBytesPerSecond); + } + } + + /// + /// Whether the WaveStream has non-zero sample data at the current position for the + /// specified count + /// + /// Number of bytes to read + public virtual bool HasData(int count) + { + return Position < Length; + } + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveStream.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveStream.cs.meta new file mode 100644 index 0000000..cfc1e6e --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/NAudio/WaveStream.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1e3938bcd2820f546a28486ea4b7ba5d +timeCreated: 1493208131 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/Test.cs b/Assets/Plugins/Lame-For-Unity/Lame/Test.cs new file mode 100644 index 0000000..9ef4f7a --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/Test.cs @@ -0,0 +1,68 @@ +using UnityEngine; +using System.Collections; +using UnityEngine.UI; +using NAudio.Lame; +using NAudio.Wave.WZT; +using System.IO; + +public class Test : MonoBehaviour +{ + public InputField input; + public Button button; + + // Use this for initialization + IEnumerator Start() + { + string testWav = "testWav.wav"; + string testMp3 = "testMp3.mp3"; + WWW www = new WWW(GetFileStreamingAssetsPath(testWav)); + yield return www; + if (string.IsNullOrEmpty(www.error)) + { + string saveWavPath = Path.Combine(Application.persistentDataPath, testWav); + File.WriteAllBytes(saveWavPath, www.bytes); + button.onClick.AddListener(() => + { + string saveMp3Path = Path.Combine(Application.persistentDataPath, testMp3); + var bitRate = string.IsNullOrEmpty(input.text) ? LAMEPreset.ABR_128 : (LAMEPreset)int.Parse(input.text); + WaveToMP3(saveWavPath, saveMp3Path, bitRate); + StartCoroutine(PlayMp3(saveMp3Path)); + }); + } + } + + public virtual string GetFileStreamingAssetsPath(string path) + { + string filePath = null; +#if UNITY_EDITOR + filePath = string.Format("file://{0}/StreamingAssets/{1}", Application.dataPath, path); +#elif UNITY_ANDROID + filePath = string.Format("jar:file://{0}!/assets/{1}", Application.dataPath, path); +#else + filePath = string.Format("file://{0}/Raw/{1}", Application.dataPath, path); +#endif + return filePath; + } + + public static void WaveToMP3(string waveFileName, string mp3FileName, LAMEPreset bitRate = LAMEPreset.ABR_128) + { + using (var reader = new WaveFileReader(waveFileName)) + using (var writer = new LameMP3FileWriter(mp3FileName, reader.WaveFormat, bitRate)) + reader.CopyTo(writer); + } + + private IEnumerator PlayMp3(string path) + { + if (File.Exists(path)) + { + var www = new WWW("file:///" + path); + yield return www; + if (string.IsNullOrEmpty(www.error)) + { + var audioSource = GetComponent(); + audioSource.clip = www.GetAudioClip(); + audioSource.Play(); + } + } + } +} diff --git a/Assets/Plugins/Lame-For-Unity/Lame/Test.cs.meta b/Assets/Plugins/Lame-For-Unity/Lame/Test.cs.meta new file mode 100644 index 0000000..e5b4f59 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/Test.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 847526f57fb424a4b842d98ba15c6b65 +timeCreated: 1493116478 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Lame/Test.unity b/Assets/Plugins/Lame-For-Unity/Lame/Test.unity new file mode 100644 index 0000000..90205e3 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/Test.unity @@ -0,0 +1,988 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 10 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 1 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 0 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &273940 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 273941} + - component: {fileID: 273943} + - component: {fileID: 273942} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &273941 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 273940} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1249143627} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &273942 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 273940} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 50 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 5 + m_MaxSize: 53 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u8F6C\u6362" +--- !u!222 &273943 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 273940} + m_CullTransparentMesh: 0 +--- !u!1 &339270561 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 339270566} + - component: {fileID: 339270565} + - component: {fileID: 339270564} + - component: {fileID: 339270563} + - component: {fileID: 339270562} + m_Layer: 0 + m_Name: MainCamera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &339270562 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 339270561} + m_Enabled: 1 +--- !u!92 &339270563 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 339270561} + m_Enabled: 1 +--- !u!124 &339270564 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 339270561} + m_Enabled: 1 +--- !u!20 &339270565 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 339270561} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_GateFitMode: 2 + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &339270566 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 339270561} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 830.9337, y: 697.84076, z: -818} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &419645686 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 419645687} + - component: {fileID: 419645689} + - component: {fileID: 419645688} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &419645687 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 419645686} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 730594049} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &419645688 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 419645686} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 40 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 4 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: 128 +--- !u!222 &419645689 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 419645686} + m_CullTransparentMesh: 0 +--- !u!1 &638438787 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 638438788} + - component: {fileID: 638438790} + - component: {fileID: 638438789} + m_Layer: 5 + m_Name: Placeholder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &638438788 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 638438787} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 730594049} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -0.5} + m_SizeDelta: {x: -20, y: -13} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &638438789 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 638438787} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 40 + m_FontStyle: 2 + m_BestFit: 0 + m_MinSize: 4 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: "\u6BD4\u7279\u7387" +--- !u!222 &638438790 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 638438787} + m_CullTransparentMesh: 0 +--- !u!1 &701457615 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 701457618} + - component: {fileID: 701457617} + - component: {fileID: 701457616} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &701457616 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 701457615} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1077351063, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &701457617 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 701457615} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -619905303, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 5 +--- !u!4 &701457618 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 701457615} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &730594048 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 730594049} + - component: {fileID: 730594052} + - component: {fileID: 730594051} + - component: {fileID: 730594050} + m_Layer: 5 + m_Name: InputField + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &730594049 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 730594048} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 638438788} + - {fileID: 419645687} + m_Father: {fileID: 1816191059} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0.00028229, y: 104} + m_SizeDelta: {x: 200, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &730594050 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 730594048} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 575553740, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 730594051} + m_TextComponent: {fileID: 419645688} + m_Placeholder: {fileID: 638438789} + m_ContentType: 0 + m_InputType: 0 + m_AsteriskChar: 42 + m_KeyboardType: 0 + m_LineType: 0 + m_HideMobileInput: 0 + m_CharacterValidation: 0 + m_CharacterLimit: 0 + m_OnEndEdit: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.InputField+SubmitEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null + m_OnValueChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.InputField+OnChangeEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null + m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_CustomCaretColor: 0 + m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} + m_Text: 128 + m_CaretBlinkRate: 0.85 + m_CaretWidth: 1 + m_ReadOnly: 0 +--- !u!114 &730594051 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 730594048} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!222 &730594052 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 730594048} + m_CullTransparentMesh: 0 +--- !u!1 &1249143626 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1249143627} + - component: {fileID: 1249143630} + - component: {fileID: 1249143629} + - component: {fileID: 1249143628} + m_Layer: 5 + m_Name: Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1249143627 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1249143626} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 273941} + m_Father: {fileID: 1816191059} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 375, y: 70} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1249143628 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1249143626} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1249143629} + m_OnClick: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &1249143629 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1249143626} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!222 &1249143630 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1249143626} + m_CullTransparentMesh: 0 +--- !u!1 &1816191055 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1816191059} + - component: {fileID: 1816191058} + - component: {fileID: 1816191057} + - component: {fileID: 1816191056} + - component: {fileID: 1816191060} + - component: {fileID: 1816191061} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1816191056 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1816191055} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &1816191057 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1816191055} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 1920, y: 1080} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &1816191058 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1816191055} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 1 + m_Camera: {fileID: 339270565} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 25 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &1816191059 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1816191055} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 730594049} + - {fileID: 1249143627} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!114 &1816191060 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1816191055} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 847526f57fb424a4b842d98ba15c6b65, type: 3} + m_Name: + m_EditorClassIdentifier: + input: {fileID: 730594050} + button: {fileID: 1249143628} +--- !u!82 &1816191061 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1816191055} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 0} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 0 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 0 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 0 diff --git a/Assets/Plugins/Lame-For-Unity/Lame/Test.unity.meta b/Assets/Plugins/Lame-For-Unity/Lame/Test.unity.meta new file mode 100644 index 0000000..0a2c68b --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Lame/Test.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1cf6ec65b2df9324d9777836cb87ac2c +timeCreated: 1493116273 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins.meta b/Assets/Plugins/Lame-For-Unity/Plugins.meta new file mode 100644 index 0000000..ef3b99a --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d5140afce754bf342bc5713552754863 +folderAsset: yes +timeCreated: 1493113014 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android.meta b/Assets/Plugins/Lame-For-Unity/Plugins/Android.meta new file mode 100644 index 0000000..ddfe1aa --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/Android.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7721f3b7b022be04a85d4030fa6cfe98 +folderAsset: yes +timeCreated: 1493113029 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs.meta b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs.meta new file mode 100644 index 0000000..db7ff3d --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7a7d75e69fd032a46bd4687af202b1f8 +folderAsset: yes +timeCreated: 1493124849 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/arm64-v8a.meta b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/arm64-v8a.meta new file mode 100644 index 0000000..c89f53b --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/arm64-v8a.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 74d4cac7052b2094b9c8d9b697f02841 +folderAsset: yes +timeCreated: 1553864937 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/arm64-v8a/libmp3lame.so b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/arm64-v8a/libmp3lame.so new file mode 100644 index 0000000..6157d56 Binary files /dev/null and b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/arm64-v8a/libmp3lame.so differ diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/arm64-v8a/libmp3lame.so.meta b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/arm64-v8a/libmp3lame.so.meta new file mode 100644 index 0000000..4162ca8 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/arm64-v8a/libmp3lame.so.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 673a24e661c22644fbb16983267b8416 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Android: Android + second: + enabled: 1 + settings: + CPU: ARM64 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/armeabi-v7a.meta b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/armeabi-v7a.meta new file mode 100644 index 0000000..9d70bf6 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/armeabi-v7a.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: 323459e64325449409415ed5b6f9b7ec +folderAsset: yes +timeCreated: 1493114060 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 1 + settings: {} + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/armeabi-v7a/libmp3lame.so b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/armeabi-v7a/libmp3lame.so new file mode 100644 index 0000000..9814040 Binary files /dev/null and b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/armeabi-v7a/libmp3lame.so differ diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/armeabi-v7a/libmp3lame.so.meta b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/armeabi-v7a/libmp3lame.so.meta new file mode 100644 index 0000000..052ec31 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/armeabi-v7a/libmp3lame.so.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: c5079b7970e95bc4d93291b0eecd50ff +timeCreated: 1493114099 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: ARMv7 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/x86.meta b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/x86.meta new file mode 100644 index 0000000..899aeea --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/x86.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: e243f72b6359fca45924fbeed9941749 +folderAsset: yes +timeCreated: 1493114054 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 1 + settings: {} + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/x86/libmp3lame.so b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/x86/libmp3lame.so new file mode 100644 index 0000000..e663e4e Binary files /dev/null and b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/x86/libmp3lame.so differ diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/x86/libmp3lame.so.meta b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/x86/libmp3lame.so.meta new file mode 100644 index 0000000..f761239 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/Android/libs/x86/libmp3lame.so.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: ae5a1caf80162664ebb525a1b14d3e02 +timeCreated: 1493114116 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: x86 + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/iOS.meta b/Assets/Plugins/Lame-For-Unity/Plugins/iOS.meta new file mode 100644 index 0000000..d1e4e7e --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/iOS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 06bd442699761b84dbb59714adb87435 +folderAsset: yes +timeCreated: 1493113036 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/iOS/libmp3lame.a b/Assets/Plugins/Lame-For-Unity/Plugins/iOS/libmp3lame.a new file mode 100644 index 0000000..7615b47 Binary files /dev/null and b/Assets/Plugins/Lame-For-Unity/Plugins/iOS/libmp3lame.a differ diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/iOS/libmp3lame.a.meta b/Assets/Plugins/Lame-For-Unity/Plugins/iOS/libmp3lame.a.meta new file mode 100644 index 0000000..a58e6d3 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/iOS/libmp3lame.a.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: afb3065c6a5e940239f4645d1da9175a +timeCreated: 1493215407 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + iOS: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle.meta new file mode 100644 index 0000000..2d9fd6b --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 1dc07fa05074ac848ac0fd4a2a68ad56 +folderAsset: yes +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents.meta new file mode 100644 index 0000000..01da9f2 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 36e581751f68744caa08872f006b2680 +folderAsset: yes +timeCreated: 1515556075 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Headers.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Headers.meta new file mode 100644 index 0000000..58b277c --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Headers.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e2b82e11cd3904d18bbeb682e3359237 +folderAsset: yes +timeCreated: 1515556075 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Headers/lame.h b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Headers/lame.h new file mode 100644 index 0000000..5196690 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Headers/lame.h @@ -0,0 +1,1342 @@ +/* + * Interface to MP3 LAME encoding engine + * + * Copyright (c) 1999 Mark Taylor + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* $Id: lame.h,v 1.192 2017/08/31 14:14:46 robert Exp $ */ + +#ifndef LAME_LAME_H +#define LAME_LAME_H + +/* for size_t typedef */ +#include +/* for va_list typedef */ +#include +/* for FILE typedef, TODO: remove when removing lame_mp3_tags_fid */ +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +typedef void (*lame_report_function)(const char *format, va_list ap); + +#if defined(WIN32) || defined(_WIN32) +#undef CDECL +#define CDECL __cdecl +#else +#define CDECL +#endif + +#define DEPRECATED_OR_OBSOLETE_CODE_REMOVED 1 + +typedef enum vbr_mode_e { + vbr_off=0, + vbr_mt, /* obsolete, same as vbr_mtrh */ + vbr_rh, + vbr_abr, + vbr_mtrh, + vbr_max_indicator, /* Don't use this! It's used for sanity checks. */ + vbr_default=vbr_mtrh /* change this to change the default VBR mode of LAME */ +} vbr_mode; + + +/* MPEG modes */ +typedef enum MPEG_mode_e { + STEREO = 0, + JOINT_STEREO, + DUAL_CHANNEL, /* LAME doesn't supports this! */ + MONO, + NOT_SET, + MAX_INDICATOR /* Don't use this! It's used for sanity checks. */ +} MPEG_mode; + +/* Padding types */ +typedef enum Padding_type_e { + PAD_NO = 0, + PAD_ALL, + PAD_ADJUST, + PAD_MAX_INDICATOR /* Don't use this! It's used for sanity checks. */ +} Padding_type; + + + +/*presets*/ +typedef enum preset_mode_e { + /*values from 8 to 320 should be reserved for abr bitrates*/ + /*for abr I'd suggest to directly use the targeted bitrate as a value*/ + ABR_8 = 8, + ABR_320 = 320, + + V9 = 410, /*Vx to match Lame and VBR_xx to match FhG*/ + VBR_10 = 410, + V8 = 420, + VBR_20 = 420, + V7 = 430, + VBR_30 = 430, + V6 = 440, + VBR_40 = 440, + V5 = 450, + VBR_50 = 450, + V4 = 460, + VBR_60 = 460, + V3 = 470, + VBR_70 = 470, + V2 = 480, + VBR_80 = 480, + V1 = 490, + VBR_90 = 490, + V0 = 500, + VBR_100 = 500, + + + + /*still there for compatibility*/ + R3MIX = 1000, + STANDARD = 1001, + EXTREME = 1002, + INSANE = 1003, + STANDARD_FAST = 1004, + EXTREME_FAST = 1005, + MEDIUM = 1006, + MEDIUM_FAST = 1007 +} preset_mode; + + +/*asm optimizations*/ +typedef enum asm_optimizations_e { + MMX = 1, + AMD_3DNOW = 2, + SSE = 3 +} asm_optimizations; + + +/* psychoacoustic model */ +typedef enum Psy_model_e { + PSY_GPSYCHO = 1, + PSY_NSPSYTUNE = 2 +} Psy_model; + + +/* buffer considerations */ +typedef enum buffer_constraint_e { + MDB_DEFAULT=0, + MDB_STRICT_ISO=1, + MDB_MAXIMUM=2 +} buffer_constraint; + + +struct lame_global_struct; +typedef struct lame_global_struct lame_global_flags; +typedef lame_global_flags *lame_t; + + + + +/*********************************************************************** + * + * The LAME API + * These functions should be called, in this order, for each + * MP3 file to be encoded. See the file "API" for more documentation + * + ***********************************************************************/ + + +/* + * REQUIRED: + * initialize the encoder. sets default for all encoder parameters, + * returns NULL if some malloc()'s failed + * otherwise returns pointer to structure needed for all future + * API calls. + */ +lame_global_flags * CDECL lame_init(void); +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +/* obsolete version */ +int CDECL lame_init_old(lame_global_flags *); +#endif + +/* + * OPTIONAL: + * set as needed to override defaults + */ + +/******************************************************************** + * input stream description + ***********************************************************************/ +/* number of samples. default = 2^32-1 */ +int CDECL lame_set_num_samples(lame_global_flags *, unsigned long); +unsigned long CDECL lame_get_num_samples(const lame_global_flags *); + +/* input sample rate in Hz. default = 44100hz */ +int CDECL lame_set_in_samplerate(lame_global_flags *, int); +int CDECL lame_get_in_samplerate(const lame_global_flags *); + +/* number of channels in input stream. default=2 */ +int CDECL lame_set_num_channels(lame_global_flags *, int); +int CDECL lame_get_num_channels(const lame_global_flags *); + +/* + scale the input by this amount before encoding. default=1 + (not used by decoding routines) +*/ +int CDECL lame_set_scale(lame_global_flags *, float); +float CDECL lame_get_scale(const lame_global_flags *); + +/* + scale the channel 0 (left) input by this amount before encoding. default=1 + (not used by decoding routines) +*/ +int CDECL lame_set_scale_left(lame_global_flags *, float); +float CDECL lame_get_scale_left(const lame_global_flags *); + +/* + scale the channel 1 (right) input by this amount before encoding. default=1 + (not used by decoding routines) +*/ +int CDECL lame_set_scale_right(lame_global_flags *, float); +float CDECL lame_get_scale_right(const lame_global_flags *); + +/* + output sample rate in Hz. default = 0, which means LAME picks best value + based on the amount of compression. MPEG only allows: + MPEG1 32, 44.1, 48khz + MPEG2 16, 22.05, 24 + MPEG2.5 8, 11.025, 12 + (not used by decoding routines) +*/ +int CDECL lame_set_out_samplerate(lame_global_flags *, int); +int CDECL lame_get_out_samplerate(const lame_global_flags *); + + +/******************************************************************** + * general control parameters + ***********************************************************************/ +/* 1=cause LAME to collect data for an MP3 frame analyzer. default=0 */ +int CDECL lame_set_analysis(lame_global_flags *, int); +int CDECL lame_get_analysis(const lame_global_flags *); + +/* + 1 = write a Xing VBR header frame. + default = 1 + this variable must have been added by a Hungarian notation Windows programmer :-) +*/ +int CDECL lame_set_bWriteVbrTag(lame_global_flags *, int); +int CDECL lame_get_bWriteVbrTag(const lame_global_flags *); + +/* 1=decode only. use lame/mpglib to convert mp3/ogg to wav. default=0 */ +int CDECL lame_set_decode_only(lame_global_flags *, int); +int CDECL lame_get_decode_only(const lame_global_flags *); + +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +/* 1=encode a Vorbis .ogg file. default=0 */ +/* DEPRECATED */ +int CDECL lame_set_ogg(lame_global_flags *, int); +int CDECL lame_get_ogg(const lame_global_flags *); +#endif + +/* + internal algorithm selection. True quality is determined by the bitrate + but this variable will effect quality by selecting expensive or cheap algorithms. + quality=0..9. 0=best (very slow). 9=worst. + recommended: 2 near-best quality, not too slow + 5 good quality, fast + 7 ok quality, really fast +*/ +int CDECL lame_set_quality(lame_global_flags *, int); +int CDECL lame_get_quality(const lame_global_flags *); + +/* + mode = 0,1,2,3 = stereo, jstereo, dual channel (not supported), mono + default: lame picks based on compression ration and input channels +*/ +int CDECL lame_set_mode(lame_global_flags *, MPEG_mode); +MPEG_mode CDECL lame_get_mode(const lame_global_flags *); + +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +/* + mode_automs. Use a M/S mode with a switching threshold based on + compression ratio + DEPRECATED +*/ +int CDECL lame_set_mode_automs(lame_global_flags *, int); +int CDECL lame_get_mode_automs(const lame_global_flags *); +#endif + +/* + force_ms. Force M/S for all frames. For testing only. + default = 0 (disabled) +*/ +int CDECL lame_set_force_ms(lame_global_flags *, int); +int CDECL lame_get_force_ms(const lame_global_flags *); + +/* use free_format? default = 0 (disabled) */ +int CDECL lame_set_free_format(lame_global_flags *, int); +int CDECL lame_get_free_format(const lame_global_flags *); + +/* perform ReplayGain analysis? default = 0 (disabled) */ +int CDECL lame_set_findReplayGain(lame_global_flags *, int); +int CDECL lame_get_findReplayGain(const lame_global_flags *); + +/* decode on the fly. Search for the peak sample. If the ReplayGain + * analysis is enabled then perform the analysis on the decoded data + * stream. default = 0 (disabled) + * NOTE: if this option is set the build-in decoder should not be used */ +int CDECL lame_set_decode_on_the_fly(lame_global_flags *, int); +int CDECL lame_get_decode_on_the_fly(const lame_global_flags *); + +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +/* DEPRECATED: now does the same as lame_set_findReplayGain() + default = 0 (disabled) */ +int CDECL lame_set_ReplayGain_input(lame_global_flags *, int); +int CDECL lame_get_ReplayGain_input(const lame_global_flags *); + +/* DEPRECATED: now does the same as + lame_set_decode_on_the_fly() && lame_set_findReplayGain() + default = 0 (disabled) */ +int CDECL lame_set_ReplayGain_decode(lame_global_flags *, int); +int CDECL lame_get_ReplayGain_decode(const lame_global_flags *); + +/* DEPRECATED: now does the same as lame_set_decode_on_the_fly() + default = 0 (disabled) */ +int CDECL lame_set_findPeakSample(lame_global_flags *, int); +int CDECL lame_get_findPeakSample(const lame_global_flags *); +#endif + +/* counters for gapless encoding */ +int CDECL lame_set_nogap_total(lame_global_flags*, int); +int CDECL lame_get_nogap_total(const lame_global_flags*); + +int CDECL lame_set_nogap_currentindex(lame_global_flags* , int); +int CDECL lame_get_nogap_currentindex(const lame_global_flags*); + + +/* + * OPTIONAL: + * Set printf like error/debug/message reporting functions. + * The second argument has to be a pointer to a function which looks like + * void my_debugf(const char *format, va_list ap) + * { + * (void) vfprintf(stdout, format, ap); + * } + * If you use NULL as the value of the pointer in the set function, the + * lame buildin function will be used (prints to stderr). + * To quiet any output you have to replace the body of the example function + * with just "return;" and use it in the set function. + */ +int CDECL lame_set_errorf(lame_global_flags *, lame_report_function); +int CDECL lame_set_debugf(lame_global_flags *, lame_report_function); +int CDECL lame_set_msgf (lame_global_flags *, lame_report_function); + + + +/* set one of brate compression ratio. default is compression ratio of 11. */ +int CDECL lame_set_brate(lame_global_flags *, int); +int CDECL lame_get_brate(const lame_global_flags *); +int CDECL lame_set_compression_ratio(lame_global_flags *, float); +float CDECL lame_get_compression_ratio(const lame_global_flags *); + + +int CDECL lame_set_preset( lame_global_flags* gfp, int ); +int CDECL lame_set_asm_optimizations( lame_global_flags* gfp, int, int ); + + + +/******************************************************************** + * frame params + ***********************************************************************/ +/* mark as copyright. default=0 */ +int CDECL lame_set_copyright(lame_global_flags *, int); +int CDECL lame_get_copyright(const lame_global_flags *); + +/* mark as original. default=1 */ +int CDECL lame_set_original(lame_global_flags *, int); +int CDECL lame_get_original(const lame_global_flags *); + +/* error_protection. Use 2 bytes from each frame for CRC checksum. default=0 */ +int CDECL lame_set_error_protection(lame_global_flags *, int); +int CDECL lame_get_error_protection(const lame_global_flags *); + +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +/* padding_type. 0=pad no frames 1=pad all frames 2=adjust padding(default) */ +int CDECL lame_set_padding_type(lame_global_flags *, Padding_type); +Padding_type CDECL lame_get_padding_type(const lame_global_flags *); +#endif + +/* MP3 'private extension' bit Meaningless. default=0 */ +int CDECL lame_set_extension(lame_global_flags *, int); +int CDECL lame_get_extension(const lame_global_flags *); + +/* enforce strict ISO compliance. default=0 */ +int CDECL lame_set_strict_ISO(lame_global_flags *, int); +int CDECL lame_get_strict_ISO(const lame_global_flags *); + + +/******************************************************************** + * quantization/noise shaping + ***********************************************************************/ + +/* disable the bit reservoir. For testing only. default=0 */ +int CDECL lame_set_disable_reservoir(lame_global_flags *, int); +int CDECL lame_get_disable_reservoir(const lame_global_flags *); + +/* select a different "best quantization" function. default=0 */ +int CDECL lame_set_quant_comp(lame_global_flags *, int); +int CDECL lame_get_quant_comp(const lame_global_flags *); +int CDECL lame_set_quant_comp_short(lame_global_flags *, int); +int CDECL lame_get_quant_comp_short(const lame_global_flags *); + +int CDECL lame_set_experimentalX(lame_global_flags *, int); /* compatibility*/ +int CDECL lame_get_experimentalX(const lame_global_flags *); + +/* another experimental option. for testing only */ +int CDECL lame_set_experimentalY(lame_global_flags *, int); +int CDECL lame_get_experimentalY(const lame_global_flags *); + +/* another experimental option. for testing only */ +int CDECL lame_set_experimentalZ(lame_global_flags *, int); +int CDECL lame_get_experimentalZ(const lame_global_flags *); + +/* Naoki's psycho acoustic model. default=0 */ +int CDECL lame_set_exp_nspsytune(lame_global_flags *, int); +int CDECL lame_get_exp_nspsytune(const lame_global_flags *); + +void CDECL lame_set_msfix(lame_global_flags *, double); +float CDECL lame_get_msfix(const lame_global_flags *); + + +/******************************************************************** + * VBR control + ***********************************************************************/ +/* Types of VBR. default = vbr_off = CBR */ +int CDECL lame_set_VBR(lame_global_flags *, vbr_mode); +vbr_mode CDECL lame_get_VBR(const lame_global_flags *); + +/* VBR quality level. 0=highest 9=lowest */ +int CDECL lame_set_VBR_q(lame_global_flags *, int); +int CDECL lame_get_VBR_q(const lame_global_flags *); + +/* VBR quality level. 0=highest 9=lowest, Range [0,...,10[ */ +int CDECL lame_set_VBR_quality(lame_global_flags *, float); +float CDECL lame_get_VBR_quality(const lame_global_flags *); + +/* Ignored except for VBR=vbr_abr (ABR mode) */ +int CDECL lame_set_VBR_mean_bitrate_kbps(lame_global_flags *, int); +int CDECL lame_get_VBR_mean_bitrate_kbps(const lame_global_flags *); + +int CDECL lame_set_VBR_min_bitrate_kbps(lame_global_flags *, int); +int CDECL lame_get_VBR_min_bitrate_kbps(const lame_global_flags *); + +int CDECL lame_set_VBR_max_bitrate_kbps(lame_global_flags *, int); +int CDECL lame_get_VBR_max_bitrate_kbps(const lame_global_flags *); + +/* + 1=strictly enforce VBR_min_bitrate. Normally it will be violated for + analog silence +*/ +int CDECL lame_set_VBR_hard_min(lame_global_flags *, int); +int CDECL lame_get_VBR_hard_min(const lame_global_flags *); + +/* for preset */ +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +int CDECL lame_set_preset_expopts(lame_global_flags *, int); +#endif + +/******************************************************************** + * Filtering control + ***********************************************************************/ +/* freq in Hz to apply lowpass. Default = 0 = lame chooses. -1 = disabled */ +int CDECL lame_set_lowpassfreq(lame_global_flags *, int); +int CDECL lame_get_lowpassfreq(const lame_global_flags *); +/* width of transition band, in Hz. Default = one polyphase filter band */ +int CDECL lame_set_lowpasswidth(lame_global_flags *, int); +int CDECL lame_get_lowpasswidth(const lame_global_flags *); + +/* freq in Hz to apply highpass. Default = 0 = lame chooses. -1 = disabled */ +int CDECL lame_set_highpassfreq(lame_global_flags *, int); +int CDECL lame_get_highpassfreq(const lame_global_flags *); +/* width of transition band, in Hz. Default = one polyphase filter band */ +int CDECL lame_set_highpasswidth(lame_global_flags *, int); +int CDECL lame_get_highpasswidth(const lame_global_flags *); + + +/******************************************************************** + * psycho acoustics and other arguments which you should not change + * unless you know what you are doing + ***********************************************************************/ + +/* only use ATH for masking */ +int CDECL lame_set_ATHonly(lame_global_flags *, int); +int CDECL lame_get_ATHonly(const lame_global_flags *); + +/* only use ATH for short blocks */ +int CDECL lame_set_ATHshort(lame_global_flags *, int); +int CDECL lame_get_ATHshort(const lame_global_flags *); + +/* disable ATH */ +int CDECL lame_set_noATH(lame_global_flags *, int); +int CDECL lame_get_noATH(const lame_global_flags *); + +/* select ATH formula */ +int CDECL lame_set_ATHtype(lame_global_flags *, int); +int CDECL lame_get_ATHtype(const lame_global_flags *); + +/* lower ATH by this many db */ +int CDECL lame_set_ATHlower(lame_global_flags *, float); +float CDECL lame_get_ATHlower(const lame_global_flags *); + +/* select ATH adaptive adjustment type */ +int CDECL lame_set_athaa_type( lame_global_flags *, int); +int CDECL lame_get_athaa_type( const lame_global_flags *); + +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +/* select the loudness approximation used by the ATH adaptive auto-leveling */ +int CDECL lame_set_athaa_loudapprox( lame_global_flags *, int); +int CDECL lame_get_athaa_loudapprox( const lame_global_flags *); +#endif + +/* adjust (in dB) the point below which adaptive ATH level adjustment occurs */ +int CDECL lame_set_athaa_sensitivity( lame_global_flags *, float); +float CDECL lame_get_athaa_sensitivity( const lame_global_flags* ); + +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +/* OBSOLETE: predictability limit (ISO tonality formula) */ +int CDECL lame_set_cwlimit(lame_global_flags *, int); +int CDECL lame_get_cwlimit(const lame_global_flags *); +#endif + +/* + allow blocktypes to differ between channels? + default: 0 for jstereo, 1 for stereo +*/ +int CDECL lame_set_allow_diff_short(lame_global_flags *, int); +int CDECL lame_get_allow_diff_short(const lame_global_flags *); + +/* use temporal masking effect (default = 1) */ +int CDECL lame_set_useTemporal(lame_global_flags *, int); +int CDECL lame_get_useTemporal(const lame_global_flags *); + +/* use temporal masking effect (default = 1) */ +int CDECL lame_set_interChRatio(lame_global_flags *, float); +float CDECL lame_get_interChRatio(const lame_global_flags *); + +/* disable short blocks */ +int CDECL lame_set_no_short_blocks(lame_global_flags *, int); +int CDECL lame_get_no_short_blocks(const lame_global_flags *); + +/* force short blocks */ +int CDECL lame_set_force_short_blocks(lame_global_flags *, int); +int CDECL lame_get_force_short_blocks(const lame_global_flags *); + +/* Input PCM is emphased PCM (for instance from one of the rarely + emphased CDs), it is STRONGLY not recommended to use this, because + psycho does not take it into account, and last but not least many decoders + ignore these bits */ +int CDECL lame_set_emphasis(lame_global_flags *, int); +int CDECL lame_get_emphasis(const lame_global_flags *); + + + +/************************************************************************/ +/* internal variables, cannot be set... */ +/* provided because they may be of use to calling application */ +/************************************************************************/ +/* version 0=MPEG-2 1=MPEG-1 (2=MPEG-2.5) */ +int CDECL lame_get_version(const lame_global_flags *); + +/* encoder delay */ +int CDECL lame_get_encoder_delay(const lame_global_flags *); + +/* + padding appended to the input to make sure decoder can fully decode + all input. Note that this value can only be calculated during the + call to lame_encoder_flush(). Before lame_encoder_flush() has + been called, the value of encoder_padding = 0. +*/ +int CDECL lame_get_encoder_padding(const lame_global_flags *); + +/* size of MPEG frame */ +int CDECL lame_get_framesize(const lame_global_flags *); + +/* number of PCM samples buffered, but not yet encoded to mp3 data. */ +int CDECL lame_get_mf_samples_to_encode( const lame_global_flags* gfp ); + +/* + size (bytes) of mp3 data buffered, but not yet encoded. + this is the number of bytes which would be output by a call to + lame_encode_flush_nogap. NOTE: lame_encode_flush() will return + more bytes than this because it will encode the reamining buffered + PCM samples before flushing the mp3 buffers. +*/ +int CDECL lame_get_size_mp3buffer( const lame_global_flags* gfp ); + +/* number of frames encoded so far */ +int CDECL lame_get_frameNum(const lame_global_flags *); + +/* + lame's estimate of the total number of frames to be encoded + only valid if calling program set num_samples +*/ +int CDECL lame_get_totalframes(const lame_global_flags *); + +/* RadioGain value. Multiplied by 10 and rounded to the nearest. */ +int CDECL lame_get_RadioGain(const lame_global_flags *); + +/* AudiophileGain value. Multipled by 10 and rounded to the nearest. */ +int CDECL lame_get_AudiophileGain(const lame_global_flags *); + +/* the peak sample */ +float CDECL lame_get_PeakSample(const lame_global_flags *); + +/* Gain change required for preventing clipping. The value is correct only if + peak sample searching was enabled. If negative then the waveform + already does not clip. The value is multiplied by 10 and rounded up. */ +int CDECL lame_get_noclipGainChange(const lame_global_flags *); + +/* user-specified scale factor required for preventing clipping. Value is + correct only if peak sample searching was enabled and no user-specified + scaling was performed. If negative then either the waveform already does + not clip or the value cannot be determined */ +float CDECL lame_get_noclipScale(const lame_global_flags *); + +/* returns the limit of PCM samples, which one can pass in an encode call + under the constrain of a provided buffer of size buffer_size */ +int CDECL lame_get_maximum_number_of_samples(lame_t gfp, size_t buffer_size); + + + + +/* + * REQUIRED: + * sets more internal configuration based on data provided above. + * returns -1 if something failed. + */ +int CDECL lame_init_params(lame_global_flags *); + + +/* + * OPTIONAL: + * get the version number, in a string. of the form: + * "3.63 (beta)" or just "3.63". + */ +const char* CDECL get_lame_version ( void ); +const char* CDECL get_lame_short_version ( void ); +const char* CDECL get_lame_very_short_version ( void ); +const char* CDECL get_psy_version ( void ); +const char* CDECL get_lame_url ( void ); +const char* CDECL get_lame_os_bitness ( void ); + +/* + * OPTIONAL: + * get the version numbers in numerical form. + */ +typedef struct { + /* generic LAME version */ + int major; + int minor; + int alpha; /* 0 if not an alpha version */ + int beta; /* 0 if not a beta version */ + + /* version of the psy model */ + int psy_major; + int psy_minor; + int psy_alpha; /* 0 if not an alpha version */ + int psy_beta; /* 0 if not a beta version */ + + /* compile time features */ + const char *features; /* Don't make assumptions about the contents! */ +} lame_version_t; +void CDECL get_lame_version_numerical(lame_version_t *); + + +/* + * OPTIONAL: + * print internal lame configuration to message handler + */ +void CDECL lame_print_config(const lame_global_flags* gfp); + +void CDECL lame_print_internals( const lame_global_flags *gfp); + + +/* + * input pcm data, output (maybe) mp3 frames. + * This routine handles all buffering, resampling and filtering for you. + * + * return code number of bytes output in mp3buf. Can be 0 + * -1: mp3buf was too small + * -2: malloc() problem + * -3: lame_init_params() not called + * -4: psycho acoustic problems + * + * The required mp3buf_size can be computed from num_samples, + * samplerate and encoding rate, but here is a worst case estimate: + * + * mp3buf_size in bytes = 1.25*num_samples + 7200 + * + * I think a tighter bound could be: (mt, March 2000) + * MPEG1: + * num_samples*(bitrate/8)/samplerate + 4*1152*(bitrate/8)/samplerate + 512 + * MPEG2: + * num_samples*(bitrate/8)/samplerate + 4*576*(bitrate/8)/samplerate + 256 + * + * but test first if you use that! + * + * set mp3buf_size = 0 and LAME will not check if mp3buf_size is + * large enough. + * + * NOTE: + * if gfp->num_channels=2, but gfp->mode = 3 (mono), the L & R channels + * will be averaged into the L channel before encoding only the L channel + * This will overwrite the data in buffer_l[] and buffer_r[]. + * +*/ +int CDECL lame_encode_buffer ( + lame_global_flags* gfp, /* global context handle */ + const short int buffer_l [], /* PCM data for left channel */ + const short int buffer_r [], /* PCM data for right channel */ + const int nsamples, /* number of samples per channel */ + unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + const int mp3buf_size ); /* number of valid octets in this + stream */ + +/* + * as above, but input has L & R channel data interleaved. + * NOTE: + * num_samples = number of samples in the L (or R) + * channel, not the total number of samples in pcm[] + */ +int CDECL lame_encode_buffer_interleaved( + lame_global_flags* gfp, /* global context handlei */ + short int pcm[], /* PCM data for left and right + channel, interleaved */ + int num_samples, /* number of samples per channel, + _not_ number of samples in + pcm[] */ + unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + int mp3buf_size ); /* number of valid octets in this + stream */ + + +/* as lame_encode_buffer, but for 'float's. + * !! NOTE: !! data must still be scaled to be in the same range as + * short int, +/- 32768 + */ +int CDECL lame_encode_buffer_float( + lame_global_flags* gfp, /* global context handle */ + const float pcm_l [], /* PCM data for left channel */ + const float pcm_r [], /* PCM data for right channel */ + const int nsamples, /* number of samples per channel */ + unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + const int mp3buf_size ); /* number of valid octets in this + stream */ + +/* as lame_encode_buffer, but for 'float's. + * !! NOTE: !! data must be scaled to +/- 1 full scale + */ +int CDECL lame_encode_buffer_ieee_float( + lame_t gfp, + const float pcm_l [], /* PCM data for left channel */ + const float pcm_r [], /* PCM data for right channel */ + const int nsamples, + unsigned char * mp3buf, + const int mp3buf_size); +int CDECL lame_encode_buffer_interleaved_ieee_float( + lame_t gfp, + const float pcm[], /* PCM data for left and right + channel, interleaved */ + const int nsamples, + unsigned char * mp3buf, + const int mp3buf_size); + +/* as lame_encode_buffer, but for 'double's. + * !! NOTE: !! data must be scaled to +/- 1 full scale + */ +int CDECL lame_encode_buffer_ieee_double( + lame_t gfp, + const double pcm_l [], /* PCM data for left channel */ + const double pcm_r [], /* PCM data for right channel */ + const int nsamples, + unsigned char * mp3buf, + const int mp3buf_size); +int CDECL lame_encode_buffer_interleaved_ieee_double( + lame_t gfp, + const double pcm[], /* PCM data for left and right + channel, interleaved */ + const int nsamples, + unsigned char * mp3buf, + const int mp3buf_size); + +/* as lame_encode_buffer, but for long's + * !! NOTE: !! data must still be scaled to be in the same range as + * short int, +/- 32768 + * + * This scaling was a mistake (doesn't allow one to exploit full + * precision of type 'long'. Use lame_encode_buffer_long2() instead. + * + */ +int CDECL lame_encode_buffer_long( + lame_global_flags* gfp, /* global context handle */ + const long buffer_l [], /* PCM data for left channel */ + const long buffer_r [], /* PCM data for right channel */ + const int nsamples, /* number of samples per channel */ + unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + const int mp3buf_size ); /* number of valid octets in this + stream */ + +/* Same as lame_encode_buffer_long(), but with correct scaling. + * !! NOTE: !! data must still be scaled to be in the same range as + * type 'long'. Data should be in the range: +/- 2^(8*size(long)-1) + * + */ +int CDECL lame_encode_buffer_long2( + lame_global_flags* gfp, /* global context handle */ + const long buffer_l [], /* PCM data for left channel */ + const long buffer_r [], /* PCM data for right channel */ + const int nsamples, /* number of samples per channel */ + unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + const int mp3buf_size ); /* number of valid octets in this + stream */ + +/* as lame_encode_buffer, but for int's + * !! NOTE: !! input should be scaled to the maximum range of 'int' + * If int is 4 bytes, then the values should range from + * +/- 2147483648. + * + * This routine does not (and cannot, without loosing precision) use + * the same scaling as the rest of the lame_encode_buffer() routines. + * + */ +int CDECL lame_encode_buffer_int( + lame_global_flags* gfp, /* global context handle */ + const int buffer_l [], /* PCM data for left channel */ + const int buffer_r [], /* PCM data for right channel */ + const int nsamples, /* number of samples per channel */ + unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + const int mp3buf_size ); /* number of valid octets in this + stream */ + +/* + * as above, but for interleaved data. + * !! NOTE: !! data must still be scaled to be in the same range as + * type 'int32_t'. Data should be in the range: +/- 2^(8*size(int32_t)-1) + * NOTE: + * num_samples = number of samples in the L (or R) + * channel, not the total number of samples in pcm[] + */ +int +lame_encode_buffer_interleaved_int( + lame_t gfp, + const int pcm [], /* PCM data for left and right + channel, interleaved */ + const int nsamples, /* number of samples per channel, + _not_ number of samples in + pcm[] */ + unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + const int mp3buf_size ); /* number of valid octets in this + stream */ + + + +/* + * REQUIRED: + * lame_encode_flush will flush the intenal PCM buffers, padding with + * 0's to make sure the final frame is complete, and then flush + * the internal MP3 buffers, and thus may return a + * final few mp3 frames. 'mp3buf' should be at least 7200 bytes long + * to hold all possible emitted data. + * + * will also write id3v1 tags (if any) into the bitstream + * + * return code = number of bytes output to mp3buf. Can be 0 + */ +int CDECL lame_encode_flush( + lame_global_flags * gfp, /* global context handle */ + unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + int size); /* number of valid octets in this stream */ + +/* + * OPTIONAL: + * lame_encode_flush_nogap will flush the internal mp3 buffers and pad + * the last frame with ancillary data so it is a complete mp3 frame. + * + * 'mp3buf' should be at least 7200 bytes long + * to hold all possible emitted data. + * + * After a call to this routine, the outputed mp3 data is complete, but + * you may continue to encode new PCM samples and write future mp3 data + * to a different file. The two mp3 files will play back with no gaps + * if they are concatenated together. + * + * This routine will NOT write id3v1 tags into the bitstream. + * + * return code = number of bytes output to mp3buf. Can be 0 + */ +int CDECL lame_encode_flush_nogap( + lame_global_flags * gfp, /* global context handle */ + unsigned char* mp3buf, /* pointer to encoded MP3 stream */ + int size); /* number of valid octets in this stream */ + +/* + * OPTIONAL: + * Normally, this is called by lame_init_params(). It writes id3v2 and + * Xing headers into the front of the bitstream, and sets frame counters + * and bitrate histogram data to 0. You can also call this after + * lame_encode_flush_nogap(). + */ +int CDECL lame_init_bitstream( + lame_global_flags * gfp); /* global context handle */ + + + +/* + * OPTIONAL: some simple statistics + * a bitrate histogram to visualize the distribution of used frame sizes + * a stereo mode histogram to visualize the distribution of used stereo + * modes, useful in joint-stereo mode only + * 0: LR left-right encoded + * 1: LR-I left-right and intensity encoded (currently not supported) + * 2: MS mid-side encoded + * 3: MS-I mid-side and intensity encoded (currently not supported) + * + * attention: don't call them after lame_encode_finish + * suggested: lame_encode_flush -> lame_*_hist -> lame_close + */ + +void CDECL lame_bitrate_hist( + const lame_global_flags * gfp, + int bitrate_count[14] ); +void CDECL lame_bitrate_kbps( + const lame_global_flags * gfp, + int bitrate_kbps [14] ); +void CDECL lame_stereo_mode_hist( + const lame_global_flags * gfp, + int stereo_mode_count[4] ); + +void CDECL lame_bitrate_stereo_mode_hist ( + const lame_global_flags * gfp, + int bitrate_stmode_count[14][4] ); + +void CDECL lame_block_type_hist ( + const lame_global_flags * gfp, + int btype_count[6] ); + +void CDECL lame_bitrate_block_type_hist ( + const lame_global_flags * gfp, + int bitrate_btype_count[14][6] ); + +#if (DEPRECATED_OR_OBSOLETE_CODE_REMOVED && 0) +#else +/* + * OPTIONAL: + * lame_mp3_tags_fid will rewrite a Xing VBR tag to the mp3 file with file + * pointer fid. These calls perform forward and backwards seeks, so make + * sure fid is a real file. Make sure lame_encode_flush has been called, + * and all mp3 data has been written to the file before calling this + * function. + * NOTE: + * if VBR tags are turned off by the user, or turned off by LAME because + * the output is not a regular file, this call does nothing + * NOTE: + * LAME wants to read from the file to skip an optional ID3v2 tag, so + * make sure you opened the file for writing and reading. + * NOTE: + * You can call lame_get_lametag_frame instead, if you want to insert + * the lametag yourself. +*/ +void CDECL lame_mp3_tags_fid(lame_global_flags *, FILE* fid); +#endif + +/* + * OPTIONAL: + * lame_get_lametag_frame copies the final LAME-tag into 'buffer'. + * The function returns the number of bytes copied into buffer, or + * the required buffer size, if the provided buffer is too small. + * Function failed, if the return value is larger than 'size'! + * Make sure lame_encode flush has been called before calling this function. + * NOTE: + * if VBR tags are turned off by the user, or turned off by LAME, + * this call does nothing and returns 0. + * NOTE: + * LAME inserted an empty frame in the beginning of mp3 audio data, + * which you have to replace by the final LAME-tag frame after encoding. + * In case there is no ID3v2 tag, usually this frame will be the very first + * data in your mp3 file. If you put some other leading data into your + * file, you'll have to do some bookkeeping about where to write this buffer. + */ +size_t CDECL lame_get_lametag_frame( + const lame_global_flags *, unsigned char* buffer, size_t size); + +/* + * REQUIRED: + * final call to free all remaining buffers + */ +int CDECL lame_close (lame_global_flags *); + +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +/* + * OBSOLETE: + * lame_encode_finish combines lame_encode_flush() and lame_close() in + * one call. However, once this call is made, the statistics routines + * will no longer work because the data will have been cleared, and + * lame_mp3_tags_fid() cannot be called to add data to the VBR header + */ +int CDECL lame_encode_finish( + lame_global_flags* gfp, + unsigned char* mp3buf, + int size ); +#endif + + + + + + +/********************************************************************* + * + * decoding + * + * a simple interface to mpglib, part of mpg123, is also included if + * libmp3lame is compiled with HAVE_MPGLIB + * + *********************************************************************/ + +struct hip_global_struct; +typedef struct hip_global_struct hip_global_flags; +typedef hip_global_flags *hip_t; + + +typedef struct { + int header_parsed; /* 1 if header was parsed and following data was + computed */ + int stereo; /* number of channels */ + int samplerate; /* sample rate */ + int bitrate; /* bitrate */ + int mode; /* mp3 frame type */ + int mode_ext; /* mp3 frame type */ + int framesize; /* number of samples per mp3 frame */ + + /* this data is only computed if mpglib detects a Xing VBR header */ + unsigned long nsamp; /* number of samples in mp3 file. */ + int totalframes; /* total number of frames in mp3 file */ + + /* this data is not currently computed by the mpglib routines */ + int framenum; /* frames decoded counter */ +} mp3data_struct; + +/* required call to initialize decoder */ +hip_t CDECL hip_decode_init(void); + +/* cleanup call to exit decoder */ +int CDECL hip_decode_exit(hip_t gfp); + +/* HIP reporting functions */ +void CDECL hip_set_errorf(hip_t gfp, lame_report_function f); +void CDECL hip_set_debugf(hip_t gfp, lame_report_function f); +void CDECL hip_set_msgf (hip_t gfp, lame_report_function f); + +/********************************************************************* + * input 1 mp3 frame, output (maybe) pcm data. + * + * nout = hip_decode(hip, mp3buf,len,pcm_l,pcm_r); + * + * input: + * len : number of bytes of mp3 data in mp3buf + * mp3buf[len] : mp3 data to be decoded + * + * output: + * nout: -1 : decoding error + * 0 : need more data before we can complete the decode + * >0 : returned 'nout' samples worth of data in pcm_l,pcm_r + * pcm_l[nout] : left channel data + * pcm_r[nout] : right channel data + * + *********************************************************************/ +int CDECL hip_decode( hip_t gfp + , unsigned char * mp3buf + , size_t len + , short pcm_l[] + , short pcm_r[] + ); + +/* same as hip_decode, and also returns mp3 header data */ +int CDECL hip_decode_headers( hip_t gfp + , unsigned char* mp3buf + , size_t len + , short pcm_l[] + , short pcm_r[] + , mp3data_struct* mp3data + ); + +/* same as hip_decode, but returns at most one frame */ +int CDECL hip_decode1( hip_t gfp + , unsigned char* mp3buf + , size_t len + , short pcm_l[] + , short pcm_r[] + ); + +/* same as hip_decode1, but returns at most one frame and mp3 header data */ +int CDECL hip_decode1_headers( hip_t gfp + , unsigned char* mp3buf + , size_t len + , short pcm_l[] + , short pcm_r[] + , mp3data_struct* mp3data + ); + +/* same as hip_decode1_headers, but also returns enc_delay and enc_padding + from VBR Info tag, (-1 if no info tag was found) */ +int CDECL hip_decode1_headersB( hip_t gfp + , unsigned char* mp3buf + , size_t len + , short pcm_l[] + , short pcm_r[] + , mp3data_struct* mp3data + , int *enc_delay + , int *enc_padding + ); + + + +/* OBSOLETE: + * lame_decode... functions are there to keep old code working + * but it is strongly recommended to replace calls by hip_decode... + * function calls, see above. + */ +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +int CDECL lame_decode_init(void); +int CDECL lame_decode( + unsigned char * mp3buf, + int len, + short pcm_l[], + short pcm_r[] ); +int CDECL lame_decode_headers( + unsigned char* mp3buf, + int len, + short pcm_l[], + short pcm_r[], + mp3data_struct* mp3data ); +int CDECL lame_decode1( + unsigned char* mp3buf, + int len, + short pcm_l[], + short pcm_r[] ); +int CDECL lame_decode1_headers( + unsigned char* mp3buf, + int len, + short pcm_l[], + short pcm_r[], + mp3data_struct* mp3data ); +int CDECL lame_decode1_headersB( + unsigned char* mp3buf, + int len, + short pcm_l[], + short pcm_r[], + mp3data_struct* mp3data, + int *enc_delay, + int *enc_padding ); +int CDECL lame_decode_exit(void); + +#endif /* obsolete lame_decode API calls */ + + +/********************************************************************* + * + * id3tag stuff + * + *********************************************************************/ + +/* + * id3tag.h -- Interface to write ID3 version 1 and 2 tags. + * + * Copyright (C) 2000 Don Melton. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +/* utility to obtain alphabetically sorted list of genre names with numbers */ +void CDECL id3tag_genre_list( + void (*handler)(int, const char *, void *), + void* cookie); + +void CDECL id3tag_init (lame_t gfp); + +/* force addition of version 2 tag */ +void CDECL id3tag_add_v2 (lame_t gfp); + +/* add only a version 1 tag */ +void CDECL id3tag_v1_only (lame_t gfp); + +/* add only a version 2 tag */ +void CDECL id3tag_v2_only (lame_t gfp); + +/* pad version 1 tag with spaces instead of nulls */ +void CDECL id3tag_space_v1 (lame_t gfp); + +/* pad version 2 tag with extra 128 bytes */ +void CDECL id3tag_pad_v2 (lame_t gfp); + +/* pad version 2 tag with extra n bytes */ +void CDECL id3tag_set_pad (lame_t gfp, size_t n); + +void CDECL id3tag_set_title(lame_t gfp, const char* title); +void CDECL id3tag_set_artist(lame_t gfp, const char* artist); +void CDECL id3tag_set_album(lame_t gfp, const char* album); +void CDECL id3tag_set_year(lame_t gfp, const char* year); +void CDECL id3tag_set_comment(lame_t gfp, const char* comment); + +/* return -1 result if track number is out of ID3v1 range + and ignored for ID3v1 */ +int CDECL id3tag_set_track(lame_t gfp, const char* track); + +/* return non-zero result if genre name or number is invalid + result 0: OK + result -1: genre number out of range + result -2: no valid ID3v1 genre name, mapped to ID3v1 'Other' + but taken as-is for ID3v2 genre tag */ +int CDECL id3tag_set_genre(lame_t gfp, const char* genre); + +/* return non-zero result if field name is invalid */ +int CDECL id3tag_set_fieldvalue(lame_t gfp, const char* fieldvalue); + +/* return non-zero result if image type is invalid */ +int CDECL id3tag_set_albumart(lame_t gfp, const char* image, size_t size); + +/* lame_get_id3v1_tag copies ID3v1 tag into buffer. + * Function returns number of bytes copied into buffer, or number + * of bytes rquired if buffer 'size' is too small. + * Function fails, if returned value is larger than 'size'. + * NOTE: + * This functions does nothing, if user/LAME disabled ID3v1 tag. + */ +size_t CDECL lame_get_id3v1_tag(lame_t gfp, unsigned char* buffer, size_t size); + +/* lame_get_id3v2_tag copies ID3v2 tag into buffer. + * Function returns number of bytes copied into buffer, or number + * of bytes rquired if buffer 'size' is too small. + * Function fails, if returned value is larger than 'size'. + * NOTE: + * This functions does nothing, if user/LAME disabled ID3v2 tag. + */ +size_t CDECL lame_get_id3v2_tag(lame_t gfp, unsigned char* buffer, size_t size); + +/* normaly lame_init_param writes ID3v2 tags into the audio stream + * Call lame_set_write_id3tag_automatic(gfp, 0) before lame_init_param + * to turn off this behaviour and get ID3v2 tag with above function + * write it yourself into your file. + */ +void CDECL lame_set_write_id3tag_automatic(lame_global_flags * gfp, int); +int CDECL lame_get_write_id3tag_automatic(lame_global_flags const* gfp); + +/* experimental */ +int CDECL id3tag_set_textinfo_latin1(lame_t gfp, char const *id, char const *text); + +/* experimental */ +int CDECL id3tag_set_comment_latin1(lame_t gfp, char const *lang, char const *desc, char const *text); + +#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED +#else +/* experimental */ +int CDECL id3tag_set_textinfo_ucs2(lame_t gfp, char const *id, unsigned short const *text); + +/* experimental */ +int CDECL id3tag_set_comment_ucs2(lame_t gfp, char const *lang, + unsigned short const *desc, unsigned short const *text); + +/* experimental */ +int CDECL id3tag_set_fieldvalue_ucs2(lame_t gfp, const unsigned short *fieldvalue); +#endif + +/* experimental */ +int CDECL id3tag_set_fieldvalue_utf16(lame_t gfp, const unsigned short *fieldvalue); + +/* experimental */ +int CDECL id3tag_set_textinfo_utf16(lame_t gfp, char const *id, unsigned short const *text); + +/* experimental */ +int CDECL id3tag_set_comment_utf16(lame_t gfp, char const *lang, unsigned short const *desc, unsigned short const *text); + + +/*********************************************************************** +* +* list of valid bitrates [kbps] & sample frequencies [Hz]. +* first index: 0: MPEG-2 values (sample frequencies 16...24 kHz) +* 1: MPEG-1 values (sample frequencies 32...48 kHz) +* 2: MPEG-2.5 values (sample frequencies 8...12 kHz) +***********************************************************************/ + +extern const int bitrate_table [3][16]; +extern const int samplerate_table [3][ 4]; + +/* access functions for use in DLL, global vars are not exported */ +int CDECL lame_get_bitrate(int mpeg_version, int table_index); +int CDECL lame_get_samplerate(int mpeg_version, int table_index); + + +/* maximum size of albumart image (128KB), which affects LAME_MAXMP3BUFFER + as well since lame_encode_buffer() also returns ID3v2 tag data */ +#define LAME_MAXALBUMART (128 * 1024) + +/* maximum size of mp3buffer needed if you encode at most 1152 samples for + each call to lame_encode_buffer. see lame_encode_buffer() below + (LAME_MAXMP3BUFFER is now obsolete) */ +#define LAME_MAXMP3BUFFER (16384 + LAME_MAXALBUMART) + + +typedef enum { + LAME_OKAY = 0, + LAME_NOERROR = 0, + LAME_GENERICERROR = -1, + LAME_NOMEM = -10, + LAME_BADBITRATE = -11, + LAME_BADSAMPFREQ = -12, + LAME_INTERNALERROR = -13, + + FRONTEND_READERROR = -80, + FRONTEND_WRITEERROR = -81, + FRONTEND_FILETOOLARGE = -82 + +} lame_errorcodes_t; + +#if defined(__cplusplus) +} +#endif +#endif /* LAME_LAME_H */ + diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Headers/lame.h.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Headers/lame.h.meta new file mode 100644 index 0000000..584d15f --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Headers/lame.h.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b4158ebc6ac7542a7a46ba99ca25fb76 +timeCreated: 1515556075 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Info.plist b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Info.plist new file mode 100644 index 0000000..37e5319 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Info.plist @@ -0,0 +1,44 @@ + + + + + BuildMachineOSBuild + 17C88 + CFBundleDevelopmentRegion + English + CFBundleExecutable + lame + CFBundleIdentifier + com.sgkj.lame + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + lame + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 9C40b + DTPlatformVersion + GM + DTSDKBuild + 17C76 + DTSDKName + macosx10.13 + DTXcode + 0920 + DTXcodeBuild + 9C40b + NSHumanReadableCopyright + Copyright © 2018年 sbooth.org. All rights reserved. + + diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Info.plist.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Info.plist.meta new file mode 100644 index 0000000..8edafbe --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Info.plist.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e02e12a8b8ce44ed88c7f97dbe19f52d +timeCreated: 1515556075 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/MacOS.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/MacOS.meta new file mode 100644 index 0000000..6130d16 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/MacOS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 148816131111a406faab31c7be9fabe4 +folderAsset: yes +timeCreated: 1515556075 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/MacOS/lame b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/MacOS/lame new file mode 100644 index 0000000..7e7c6cb Binary files /dev/null and b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/MacOS/lame differ diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/MacOS/lame.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/MacOS/lame.meta new file mode 100644 index 0000000..f141829 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/MacOS/lame.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c6f4b4f07b65e4b17980462114b9692f +timeCreated: 1515556075 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Resources.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Resources.meta new file mode 100644 index 0000000..07c1ec1 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: aa84d78183b384a53a07b07b4dafbea1 +folderAsset: yes +timeCreated: 1515556075 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Resources/Info.plist b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Resources/Info.plist new file mode 100644 index 0000000..e4542da --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Resources/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSHumanReadableCopyright + Copyright © 2018年 sbooth.org. All rights reserved. + NSPrincipalClass + + + diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Resources/Info.plist.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Resources/Info.plist.meta new file mode 100644 index 0000000..93b4350 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/Resources/Info.plist.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 708471da8aa5a423f956944c2beb763d +timeCreated: 1515556075 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/_CodeSignature.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/_CodeSignature.meta new file mode 100644 index 0000000..5db544e --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/_CodeSignature.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 181b06a7a87514b57a6159da3f3b32a6 +folderAsset: yes +timeCreated: 1515556075 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/_CodeSignature/CodeResources b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/_CodeSignature/CodeResources new file mode 100644 index 0000000..5378ad7 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/_CodeSignature/CodeResources @@ -0,0 +1,135 @@ + + + + + files + + Resources/Info.plist + + j38r/HNoA/kD/xXvliRRgixkbOI= + + + files2 + + Headers/lame.h + + hash2 + + sw5NP1uyR7rSeBdY2QYE8pzETdW9ef7hMKrvfH0lvPA= + + + Resources/Info.plist + + hash2 + + F2Ui6HZEFXbz3Rp7jLzd84Ofeav7U9XNdqTNCKjfsNI= + + + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/_CodeSignature/CodeResources.meta b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/_CodeSignature/CodeResources.meta new file mode 100644 index 0000000..5d9ce25 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/lame.bundle/Contents/_CodeSignature/CodeResources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a86be2cc5c33e4a5d99be6d77972cf57 +timeCreated: 1515556075 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/x86.meta b/Assets/Plugins/Lame-For-Unity/Plugins/x86.meta new file mode 100644 index 0000000..94199b9 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/x86.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9a1747509dce2bc4ebd495f009e84ae3 +folderAsset: yes +timeCreated: 1493113894 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/x86/libmp3lame.dll b/Assets/Plugins/Lame-For-Unity/Plugins/x86/libmp3lame.dll new file mode 100644 index 0000000..719126b Binary files /dev/null and b/Assets/Plugins/Lame-For-Unity/Plugins/x86/libmp3lame.dll differ diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/x86/libmp3lame.dll.meta b/Assets/Plugins/Lame-For-Unity/Plugins/x86/libmp3lame.dll.meta new file mode 100644 index 0000000..6b6e758 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/x86/libmp3lame.dll.meta @@ -0,0 +1,63 @@ +fileFormatVersion: 2 +guid: b0552d860d69eb5439d4c01a1140675e +timeCreated: 1493114174 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: x86 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: None + LinuxUniversal: + enabled: 1 + settings: + CPU: x86 + OSXIntel: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: None + OSXUniversal: + enabled: 0 + settings: + CPU: x86 + Win: + enabled: 1 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: None + iOS: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/x86_64.meta b/Assets/Plugins/Lame-For-Unity/Plugins/x86_64.meta new file mode 100644 index 0000000..71aa9a3 --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/x86_64.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 41a0c2ada380a744eaba4e8bd5344129 +folderAsset: yes +timeCreated: 1493113901 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/x86_64/libmp3lame.dll b/Assets/Plugins/Lame-For-Unity/Plugins/x86_64/libmp3lame.dll new file mode 100644 index 0000000..20f23ed Binary files /dev/null and b/Assets/Plugins/Lame-For-Unity/Plugins/x86_64/libmp3lame.dll differ diff --git a/Assets/Plugins/Lame-For-Unity/Plugins/x86_64/libmp3lame.dll.meta b/Assets/Plugins/Lame-For-Unity/Plugins/x86_64/libmp3lame.dll.meta new file mode 100644 index 0000000..6a3357b --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/Plugins/x86_64/libmp3lame.dll.meta @@ -0,0 +1,63 @@ +fileFormatVersion: 2 +guid: 30533557537581e45903f7a00083735d +timeCreated: 1493114174 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 0 + settings: + CPU: x86_64 + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + iOS: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Lame-For-Unity/README.md b/Assets/Plugins/Lame-For-Unity/README.md new file mode 100644 index 0000000..4eb11ac --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/README.md @@ -0,0 +1,6 @@ +# Lame-For-Unity +适用于Unity3D 把声音Wav转换为MP3, 用于录音时压缩语音上传等功能 + +Windows&Mac&iOS&Android全平台支持 + +Unity3D项目中Test脚本中有详细的示例代码 diff --git a/Assets/Plugins/Lame-For-Unity/README.md.meta b/Assets/Plugins/Lame-For-Unity/README.md.meta new file mode 100644 index 0000000..d64d14d --- /dev/null +++ b/Assets/Plugins/Lame-For-Unity/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a59320b49fcb0404cb1dcb8b9e43adec +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/RenderPipeline/UMAUniversalRenderPipelineAsset_Renderer.asset b/Assets/Resources/RenderPipeline/UMAUniversalRenderPipelineAsset_Renderer.asset index eff006c..4468eac 100644 --- a/Assets/Resources/RenderPipeline/UMAUniversalRenderPipelineAsset_Renderer.asset +++ b/Assets/Resources/RenderPipeline/UMAUniversalRenderPipelineAsset_Renderer.asset @@ -85,6 +85,12 @@ MonoBehaviour: type: 3} dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92, type: 3} + terrainDetailLitPS: {fileID: 4800000, guid: f6783ab646d374f94b199774402a5144, + type: 3} + terrainDetailGrassPS: {fileID: 4800000, guid: e507fdfead5ca47e8b9a768b51c291a1, + type: 3} + terrainDetailGrassBillboardPS: {fileID: 4800000, guid: 29868e73b638e48ca99a19ea58c48d90, + type: 3} m_AssetVersion: 2 m_OpaqueLayerMask: serializedVersion: 2 diff --git a/Assets/Scenes/Version2.unity b/Assets/Scenes/Version2.unity index 778f02a..dbd7770 100644 --- a/Assets/Scenes/Version2.unity +++ b/Assets/Scenes/Version2.unity @@ -18766,7 +18766,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 283, y: -390} + m_AnchoredPosition: {x: 283, y: -902.18} m_SizeDelta: {x: 283, y: 600} m_Pivot: {x: 1, y: 0.5} --- !u!114 &548276325 @@ -27712,9 +27712,9 @@ RectTransform: - {fileID: 1871345305} m_Father: {fileID: 6878219667498913896} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 116.5, y: -152.01} m_SizeDelta: {x: 180, y: 20} m_Pivot: {x: 0.5, y: 1} --- !u!114 &800374507 @@ -30754,6 +30754,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 872918889} m_CullTransparentMesh: 1 +--- !u!1 &876795732 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 876795733} + - component: {fileID: 876795735} + - component: {fileID: 876795734} + m_Layer: 5 + m_Name: GameObject + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &876795733 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 876795732} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.4, y: 0.4, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 933000798} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0.000045776367, y: 0} + m_SizeDelta: {x: 120, y: 60} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &876795734 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 876795732} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 58 + m_FontStyle: 1 + m_BestFit: 0 + m_MinSize: 5 + m_MaxSize: 58 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 0 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 1 + m_LineSpacing: 1 + m_Text: Export +--- !u!222 &876795735 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 876795732} + m_CullTransparentMesh: 1 --- !u!1 &880905948 GameObject: m_ObjectHideFlags: 0 @@ -31667,11 +31746,11 @@ RectTransform: - {fileID: 1111938551} m_Father: {fileID: 1209823365} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0} - m_AnchorMax: {x: 0.5, y: 0} - m_AnchoredPosition: {x: 87.6, y: 22.499985} + m_AnchorMin: {x: 1, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -15, y: -103.00001} m_SizeDelta: {x: 80, y: 40} - m_Pivot: {x: 0.5, y: 0} + m_Pivot: {x: 1, y: 1} --- !u!114 &916764977 MonoBehaviour: m_ObjectHideFlags: 0 @@ -32327,6 +32406,139 @@ MonoBehaviour: m_OnValueChanged: m_PersistentCalls: m_Calls: [] +--- !u!1 &933000797 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 933000798} + - component: {fileID: 933000801} + - component: {fileID: 933000800} + - component: {fileID: 933000799} + m_Layer: 5 + m_Name: ExportButton + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &933000798 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 933000797} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 876795733} + m_Father: {fileID: 1209823365} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 15, y: -103} + m_SizeDelta: {x: 80, y: 40} + m_Pivot: {x: 0, y: 1} +--- !u!114 &933000799 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 933000797} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 933000800} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1209823368} + m_TargetAssemblyTypeName: UISettingsSound, umamusume + m_MethodName: ExportAudio + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &933000800 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 933000797} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 9a444f34ba8719a4083a94891d66b364, type: 3} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 4.2 +--- !u!222 &933000801 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 933000797} + m_CullTransparentMesh: 1 --- !u!1 &937514623 GameObject: m_ObjectHideFlags: 0 @@ -40564,12 +40776,13 @@ RectTransform: - {fileID: 2083721900} - {fileID: 2108171286} - {fileID: 916764976} + - {fileID: 933000798} m_Father: {fileID: 1704906816} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 283, y: -213.675} - m_SizeDelta: {x: 283, y: 157.35} + m_AnchoredPosition: {x: 283, y: -215} + m_SizeDelta: {x: 283, y: 160} m_Pivot: {x: 1, y: 0.5} --- !u!114 &1209823366 MonoBehaviour: @@ -51659,6 +51872,7 @@ MonoBehaviour: CurrentUMAContainer: {fileID: 0} CurrentOtherContainer: {fileID: 0} CurrentAudioSources: [] + CurrentLiveSoundAWBIndex: -1 OverrideController: {fileID: 22100000, guid: 130057757529b0f40a4fdc08bf0861ef, type: 2} FaceOverrideController: {fileID: 22100000, guid: 21f82840716293147bcb9f4bfb58cc99, type: 2} @@ -67917,11 +68131,11 @@ RectTransform: - {fileID: 851197071} m_Father: {fileID: 1209823365} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0.5} - m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 0, y: 4.3} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -0.000061035156, y: -51.699955} m_SizeDelta: {x: -16, y: 25} - m_Pivot: {x: 0.5, y: 0.5} + m_Pivot: {x: 0.5, y: 1} --- !u!114 &2083721901 MonoBehaviour: m_ObjectHideFlags: 0 @@ -69176,11 +69390,11 @@ RectTransform: m_Children: [] m_Father: {fileID: 1209823365} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: -36.6} + m_AnchorMin: {x: 0.5, y: 1} + m_AnchorMax: {x: 0.5, y: 1} + m_AnchoredPosition: {x: -0.000076293945, y: -82.59995} m_SizeDelta: {x: 45, y: 45} - m_Pivot: {x: 0.5, y: 0.5} + m_Pivot: {x: 0.5, y: 1} --- !u!114 &2108171287 MonoBehaviour: m_ObjectHideFlags: 0 @@ -71119,9 +71333,9 @@ RectTransform: - {fileID: 1460100588} m_Father: {fileID: 6878219667498913896} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 116.5, y: -304.02} m_SizeDelta: {x: 180, y: 20} m_Pivot: {x: 0.5, y: 1} --- !u!114 &6878219665895574065 @@ -71520,9 +71734,9 @@ RectTransform: - {fileID: 1838874680} m_Father: {fileID: 6878219667498913896} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 116.5, y: -50.67} m_SizeDelta: {x: 180, y: 20} m_Pivot: {x: 0.5, y: 1} --- !u!222 &6878219666121841222 @@ -73677,9 +73891,9 @@ RectTransform: - {fileID: 880905949} m_Father: {fileID: 6878219667498913896} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 116.5, y: -202.68} m_SizeDelta: {x: 180, y: 20} m_Pivot: {x: 0.5, y: 1} --- !u!114 &6878219666841734894 @@ -74323,9 +74537,9 @@ RectTransform: - {fileID: 681146706} m_Father: {fileID: 6878219667498913896} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 116.5, y: -101.34} m_SizeDelta: {x: 180, y: 20} m_Pivot: {x: 0.5, y: 1} --- !u!114 &6878219667203546886 @@ -75586,9 +75800,9 @@ RectTransform: - {fileID: 1650889916} m_Father: {fileID: 6878219667498913896} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 116.5, y: 0} m_SizeDelta: {x: 180, y: 20} m_Pivot: {x: 0.5, y: 1} --- !u!114 &6878219667749320559 @@ -75807,9 +76021,9 @@ RectTransform: - {fileID: 1685814398} m_Father: {fileID: 6878219667498913896} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 116.5, y: -253.34999} m_SizeDelta: {x: 180, y: 20} m_Pivot: {x: 0.5, y: 1} --- !u!1 &6878219667784581358 diff --git a/Assets/Scripts/Exporters/AudioExporter.cs b/Assets/Scripts/Exporters/AudioExporter.cs new file mode 100644 index 0000000..60c0286 --- /dev/null +++ b/Assets/Scripts/Exporters/AudioExporter.cs @@ -0,0 +1,51 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using NAudio.Lame; +using System.IO; +using System; +using UmaMusumeAudio; +using NAudio.Wave.SampleProviders; +using NAudio.Wave; + +public class AudioExporter +{ + + public static void ExportAudio(List a, string path, int index = -1) { + + var l = new List(); + if (index == -1) + { + foreach (var z in a) + { + var blah = z.ToSampleProvider(); + l.Add(blah); + } + } else + { + var blah = a[index].ToSampleProvider(); + l.Add(blah); + } + + + var wf = a[0].WaveFormat; + + var mixer = new MixingSampleProvider(l); + IWaveProvider sourceProvider = new SampleToWaveProvider16(mixer); + + + using (var writer = new LameMP3FileWriter(path, new NAudio.Wave.WZT.WaveFormat(wf.SampleRate, wf.Channels), 320)) + { + byte[] buffer = new byte[wf.AverageBytesPerSecond]; // Read about 1 second of audio at a time + int bytesRead; + + // Loop to read from the source IWaveProvider and write to the MP3 writer + // The Read method returns 0 when there's no more data + while ((bytesRead = sourceProvider.Read(buffer, 0, buffer.Length)) > 0) + { + writer.Write(buffer, 0, bytesRead); + } + } + } + +} diff --git a/Assets/Scripts/Exporters/AudioExporter.cs.meta b/Assets/Scripts/Exporters/AudioExporter.cs.meta new file mode 100644 index 0000000..580e94d --- /dev/null +++ b/Assets/Scripts/Exporters/AudioExporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 11c7c93c56144a444adc503635f6aff3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Settings/UISettingsSound.cs b/Assets/Scripts/Settings/UISettingsSound.cs index 2a592b5..78a1c04 100644 --- a/Assets/Scripts/Settings/UISettingsSound.cs +++ b/Assets/Scripts/Settings/UISettingsSound.cs @@ -1,4 +1,10 @@ +#if !UNITY_ANDROID || UNITY_EDITOR +using SFB; +#endif +using System.Collections.Generic; +using System.Linq; using TMPro; +using UmaMusumeAudio; using UnityEngine; using UnityEngine.UI; @@ -63,6 +69,31 @@ public class UISettingsSound : MonoBehaviour LyricsText.text = ""; } + public void ExportAudio() + { +#if !UNITY_ANDROID || UNITY_EDITOR + var LiveSources = Builder.CurrentLiveSoundAWB; + if (LiveSources.Count > 0) + { + var lists = new List(); + foreach (var source in LiveSources) { + var z = Builder.LoadAudioStreams(source); + foreach (var item in z) + { + lists.Add(item); + } + } + + var path = StandaloneFileBrowser.SaveFilePanel("Save Music MP3 File", Config.Instance.MainPath, $"{TitleText.text}", "mp3"); + if (!string.IsNullOrEmpty(path)) + { + AudioExporter.ExportAudio(lists, path, Builder.CurrentLiveSoundAWBIndex); + } + + } +#endif + } + public void AudioProgressChange(float val) { if (Builder.CurrentAudioSources.Count > 0) diff --git a/Assets/Scripts/UmaViewerBuilder.cs b/Assets/Scripts/UmaViewerBuilder.cs index 17cb39e..e89eec5 100644 --- a/Assets/Scripts/UmaViewerBuilder.cs +++ b/Assets/Scripts/UmaViewerBuilder.cs @@ -33,6 +33,10 @@ public class UmaViewerBuilder : MonoBehaviour public List CurrentAudioSources = new List(); public List CurrentLyrics = new List(); + // Used for keeping track for exports + public List CurrentLiveSoundAWB = new List(); + public int CurrentLiveSoundAWBIndex = -1; + public AnimatorOverrideController OverrideController; public AnimatorOverrideController FaceOverrideController; public AnimatorOverrideController CameraOverrideController; @@ -754,10 +758,13 @@ public class UmaViewerBuilder : MonoBehaviour //Use decrypt function public void LoadLiveSound(int songid, UmaDatabaseEntry SongAwb, bool needLyrics = true) { + CurrentLiveSoundAWBIndex = -1; // mix awb together + CurrentLiveSoundAWB.Clear(); //load character voice if (SongAwb != null) { PlaySound(SongAwb); + CurrentLiveSoundAWB.Add(SongAwb); } //load BG @@ -769,6 +776,7 @@ public class UmaViewerBuilder : MonoBehaviour if (BGclip.Count > 0) { AddAudioSource(BGclip[0]); + CurrentLiveSoundAWB.Add(BGawb); } } @@ -812,6 +820,13 @@ public class UmaViewerBuilder : MonoBehaviour } + public void SetLastAudio(UmaDatabaseEntry AudioAwb, int index) + { + CurrentLiveSoundAWB.Clear(); + CurrentLiveSoundAWB.Add(AudioAwb); + CurrentLiveSoundAWBIndex = index; + } + private void AddAudioSource(AudioClip clip, float volume = 1, bool loop = false) { AudioSource source; @@ -830,6 +845,27 @@ public class UmaViewerBuilder : MonoBehaviour source.Play(); } + + + public List LoadAudioStreams(UmaDatabaseEntry awb) + { + var streams = new List(); + string awbPath = awb.FilePath; + if (!File.Exists(awbPath)) return streams; + + FileStream awbFile = File.OpenRead(awbPath); + AwbReader awbReader = new AwbReader(awbFile); + + foreach (Wave wave in awbReader.Waves) + { + var stream = new UmaWaveStream(awbReader, wave.WaveId); + streams.Add(stream); + } + + + return streams; + } + public static List LoadAudio(UmaDatabaseEntry awb) { List clips = new List(); diff --git a/Assets/Scripts/UmaViewerUI.cs b/Assets/Scripts/UmaViewerUI.cs index 3f77c07..95b2a7f 100644 --- a/Assets/Scripts/UmaViewerUI.cs +++ b/Assets/Scripts/UmaViewerUI.cs @@ -798,6 +798,7 @@ public class UmaViewerUI : MonoBehaviour container.Button.onClick.AddListener(() => { HighlightChildImage(NormalSubSoundList.content, container); + Builder.SetLastAudio(awb, subSounds.IndexOf(sound)); Builder.PlaySound(awb, subSounds.IndexOf(sound)); }); } diff --git a/Assets/Scripts/umamusume.asmdef b/Assets/Scripts/umamusume.asmdef index d9adac0..b54c3bd 100644 --- a/Assets/Scripts/umamusume.asmdef +++ b/Assets/Scripts/umamusume.asmdef @@ -6,7 +6,8 @@ "GUID:d60799ab2a985554ea1a39cd38695018", "GUID:fd1d627189c561043911a07470238b9c", "GUID:145e2572884581c48a08acf566c1a1d6", - "GUID:86ee6720b4f4f604caf8a6add1fd3b06" + "GUID:86ee6720b4f4f604caf8a6add1fd3b06", + "GUID:a22e31da5d6009e499a237fb7d439ebc" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Packages/manifest.json b/Packages/manifest.json index e668887..c895faa 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,18 +1,18 @@ { "dependencies": { "com.unity.2d.sprite": "1.0.0", - "com.unity.ai.navigation": "1.1.5", + "com.unity.ai.navigation": "1.1.6", "com.unity.formats.fbx": "5.0.0", - "com.unity.ide.rider": "3.0.34", + "com.unity.ide.rider": "3.0.36", "com.unity.ide.visualstudio": "2.0.22", "com.unity.ide.vscode": "1.2.5", "com.unity.nuget.newtonsoft-json": "3.2.1", "com.unity.postprocessing": "3.4.0", "com.unity.recorder": "4.0.3", - "com.unity.render-pipelines.universal": "14.0.11", + "com.unity.render-pipelines.universal": "14.0.12", "com.unity.test-framework": "1.1.33", "com.unity.textmeshpro": "3.0.7", - "com.unity.timeline": "1.7.6", + "com.unity.timeline": "1.7.7", "com.unity.ugui": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 2c7e247..ef31fb4 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -14,7 +14,7 @@ "dependencies": {} }, "com.unity.ai.navigation": { - "version": "1.1.5", + "version": "1.1.6", "depth": 0, "source": "registry", "dependencies": { @@ -23,7 +23,7 @@ "url": "https://packages.unity.com" }, "com.unity.burst": { - "version": "1.8.18", + "version": "1.8.21", "depth": 1, "source": "registry", "dependencies": { @@ -44,13 +44,13 @@ "depth": 0, "source": "registry", "dependencies": { - "com.autodesk.fbx": "5.0.0", - "com.unity.timeline": "1.7.1" + "com.unity.timeline": "1.7.1", + "com.autodesk.fbx": "5.0.0" }, "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "3.0.34", + "version": "3.0.36", "depth": 0, "source": "registry", "dependencies": { @@ -107,7 +107,7 @@ "url": "https://packages.unity.com" }, "com.unity.render-pipelines.core": { - "version": "14.0.11", + "version": "14.0.12", "depth": 1, "source": "builtin", "dependencies": { @@ -118,14 +118,14 @@ } }, "com.unity.render-pipelines.universal": { - "version": "14.0.11", + "version": "14.0.12", "depth": 0, "source": "builtin", "dependencies": { "com.unity.mathematics": "1.2.1", "com.unity.burst": "1.8.9", - "com.unity.render-pipelines.core": "14.0.11", - "com.unity.shadergraph": "14.0.11", + "com.unity.render-pipelines.core": "14.0.12", + "com.unity.shadergraph": "14.0.12", "com.unity.render-pipelines.universal-config": "14.0.9" } }, @@ -145,11 +145,11 @@ "url": "https://packages.unity.com" }, "com.unity.shadergraph": { - "version": "14.0.11", + "version": "14.0.12", "depth": 1, "source": "builtin", "dependencies": { - "com.unity.render-pipelines.core": "14.0.11", + "com.unity.render-pipelines.core": "14.0.12", "com.unity.searcher": "4.9.2" } }, @@ -174,13 +174,13 @@ "url": "https://packages.unity.com" }, "com.unity.timeline": { - "version": "1.7.6", + "version": "1.7.7", "depth": 0, "source": "registry", "dependencies": { - "com.unity.modules.audio": "1.0.0", "com.unity.modules.director": "1.0.0", "com.unity.modules.animation": "1.0.0", + "com.unity.modules.audio": "1.0.0", "com.unity.modules.particlesystem": "1.0.0" }, "url": "https://packages.unity.com" diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index b8192b7..8396d84 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -77,6 +77,7 @@ PlayerSettings: androidMinimumWindowHeight: 300 androidFullscreenMode: 1 androidAutoRotationBehavior: 1 + androidPredictiveBackSupport: 1 defaultIsNativeResolution: 0 macRetinaSupport: 1 runInBackground: 1 @@ -140,7 +141,7 @@ PlayerSettings: loadStoreDebugModeEnabled: 0 visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 - bundleVersion: 2.1.27 + bundleVersion: 2.1.28 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 0b5f0d8..7a6f40b 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2022.3.56f1 -m_EditorVersionWithRevision: 2022.3.56f1 (dd0c98481d00) +m_EditorVersion: 2022.3.62f1 +m_EditorVersionWithRevision: 2022.3.62f1 (4af31df58517)