Added .mp3 export (#92)

* Update to larger bitrate

* Add support for sub-voice export

---------

Co-authored-by: katboi01 <59540382+katboi01@users.noreply.github.com>
This commit is contained in:
Evans Jahja
2025-07-20 14:18:58 +09:00
committed by GitHub
parent d48aa4488e
commit 956bbdb6d2
92 changed files with 7741 additions and 57 deletions
@@ -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);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fb12997fe1438df428b9bca708076dea
timeCreated: 1493119352
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d66ded0e78d16b9488dfb0e9247211e7
timeCreated: 1493208137
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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
{
/// <summary>MP3 encoding class, uses libmp3lame DLL to encode.</summary>
public class LameMP3FileWriter : Stream
{
/// <summary>Union class for fast buffer conversion</summary>
/// <remarks>
/// <para>
/// 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.
/// </para><para>
/// 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.
/// </para><para>
/// CodeAnalysis does not like this class, with good reason. It should never be
/// exposed beyond the scope of the MP3FileWriter.
/// </para>
/// </remarks>
// 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
{
/// <summary>Size array in bytes</summary>
[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; } }
/// <summary>Initialize array to hold the requested number of bytes</summary>
/// <param name="reqBytes">Minimum byte count of array</param>
/// <remarks>
/// 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.
/// </remarks>
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
/// <summary>Create MP3FileWriter to write to a file on disk</summary>
/// <param name="outFileName">Name of file to create</param>
/// <param name="format">Input WaveFormat</param>
/// <param name="quality">LAME quality preset</param>
public LameMP3FileWriter(string outFileName, WaveFormat format, LAMEPreset quality)
: this(File.Create(outFileName), format, quality)
{
this.disposeOutput = true;
}
/// <summary>Create MP3FileWriter to write to supplied stream</summary>
/// <param name="outStream">Stream to write encoded data to</param>
/// <param name="format">Input WaveFormat</param>
/// <param name="quality">LAME quality preset</param>
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();
}
/// <summary>Create MP3FileWriter to write to a file on disk</summary>
/// <param name="outFileName">Name of file to create</param>
/// <param name="format">Input WaveFormat</param>
/// <param name="bitRate">Output bit rate in kbps</param>
public LameMP3FileWriter(string outFileName, WaveFormat format, int bitRate)
: this(File.Create(outFileName), format, bitRate)
{
this.disposeOutput = true;
}
/// <summary>Create MP3FileWriter to write to supplied stream</summary>
/// <param name="outStream">Stream to write encoded data to</param>
/// <param name="format">Input WaveFormat</param>
/// <param name="bitRate">Output bit rate in kbps</param>
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
/// <summary>Dispose of object</summary>
/// <param name="final">True if called from destructor, false otherwise</param>
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
/// <summary>Get internal LAME library instance</summary>
/// <returns>LAME library instance</returns>
public LibMp3Lame GetLameInstance()
{
return _lame;
}
#region Internal encoder operations
// Input buffer
private ArrayUnion inBuffer = null;
/// <summary>Current write position in input buffer</summary>
private int inPosition;
/// <summary>Output buffer, size determined by call to Lame.beInitStream</summary>
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
/// <summary>Write-only stream. Always false.</summary>
public override bool CanRead { get { return false; } }
/// <summary>Non-seekable stream. Always false.</summary>
public override bool CanSeek { get { return false; } }
/// <summary>True when encoder can accept more data</summary>
public override bool CanWrite { get { return outStream != null && _lame != null; } }
/// <summary>Dummy Position. Always 0.</summary>
public override long Position
{
get { return 0; }
set { throw new NotImplementedException(); }
}
/// <summary>Dummy Length. Always 0.</summary>
public override long Length
{
get { return 0; }
}
/// <summary>Add data to output buffer, sending to encoder when buffer full</summary>
/// <param name="buffer">Source buffer</param>
/// <param name="offset">Offset of data in buffer</param>
/// <param name="count">Length of data</param>
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();
}
}
/// <summary>Finalise compression, add final output to output stream and close encoder</summary>
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;
}
/// <summary>Reading not supported. Throws NotImplementedException.</summary>
/// <param name="buffer"></param>
/// <param name="offset"></param>
/// <param name="count"></param>
/// <returns></returns>
public override int Read(byte[] buffer, int offset, int count)
{
throw new NotImplementedException();
}
/// <summary>Setting length not supported. Throws NotImplementedException.</summary>
/// <param name="value">Length value</param>
public override void SetLength(long value)
{
throw new NotImplementedException();
}
/// <summary>Seeking not supported. Throws NotImplementedException.</summary>
/// <param name="offset">Seek offset</param>
/// <param name="origin">Seek origin</param>
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotImplementedException();
}
#endregion
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fb5c882d3dd15214491ac8aaf1f5b608
timeCreated: 1493208137
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 23b199320e3e7df47a5ebee61346c2b0
folderAsset: yes
timeCreated: 1493208131
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.Wave.WZT
{
/// <summary>
/// Microsoft ADPCM
/// See http://icculus.org/SDL_sound/downloads/external_documentation/wavecomp.htm
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack=2)]
public class AdpcmWaveFormat : WaveFormat
{
short samplesPerBlock;
short numCoeff;
// 7 pairs of coefficients
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)]
short[] coefficients;
/// <summary>
/// Empty constructor needed for marshalling from a pointer
/// </summary>
AdpcmWaveFormat() : this(8000,1)
{
}
/// <summary>
/// Samples per block
/// </summary>
public int SamplesPerBlock
{
get { return samplesPerBlock; }
}
/// <summary>
/// Number of coefficients
/// </summary>
public int NumCoefficients
{
get { return numCoeff; }
}
/// <summary>
/// Coefficients
/// </summary>
public short[] Coefficients
{
get { return coefficients; }
}
/// <summary>
/// Microsoft ADPCM
/// </summary>
/// <param name="sampleRate">Sample Rate</param>
/// <param name="channels">Channels</param>
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
};
}
/// <summary>
/// Serializes this wave format
/// </summary>
/// <param name="writer">Binary writer</param>
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);
}
}
/// <summary>
/// String Description of this WaveFormat
/// </summary>
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);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 60f6eb670e8f81f4382cc6d1e8ac13fa
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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();
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0ee08990d14d50946a1ad3ad9c69e4d3
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
namespace NAudio.Wave.WZT
{
/// <summary>
/// GSM 610
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 2)]
public class Gsm610WaveFormat : WaveFormat
{
private short samplesPerBlock;
/// <summary>
/// Creates a GSM 610 WaveFormat
/// For now hardcoded to 13kbps
/// </summary>
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;
}
/// <summary>
/// Samples per block
/// </summary>
public short SamplesPerBlock { get { return this.samplesPerBlock; } }
/// <summary>
/// Writes this structure to a BinaryWriter
/// </summary>
public override void Serialize(BinaryWriter writer)
{
base.Serialize(writer);
writer.Write(samplesPerBlock);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c029ee315c0c6834e90f04f619338b3b
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,26 @@
using System;
using NAudio.Lame;
namespace NAudio.Wave.WZT
{
/// <summary>
/// Generic interface for all WaveProviders.
/// </summary>
public interface IWaveProvider
{
/// <summary>
/// Gets the WaveFormat of this WaveProvider.
/// </summary>
/// <value>The wave format.</value>
WaveFormat WaveFormat { get; }
/// <summary>
/// Fill the specified buffer with wave data.
/// </summary>
/// <param name="buffer">The buffer to fill of wave data.</param>
/// <param name="offset">Offset into buffer</param>
/// <param name="count">The number of bytes to read</param>
/// <returns>the number of bytes written to the buffer.</returns>
int Read(byte[] buffer, int offset, int count);
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fbfb88f187675b0448dcf66ca372dc8f
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace NAudio.Wave.WZT
{
/// <summary>
/// Holds information about a RIFF file chunk
/// </summary>
public class RiffChunk
{
int identifier;
int length;
long streamPosition;
/// <summary>
/// Creates a RiffChunk object
/// </summary>
public RiffChunk(int identifier, int length, long streamPosition)
{
this.identifier = identifier;
this.length = length;
this.streamPosition = streamPosition;
}
/// <summary>
/// The chunk identifier
/// </summary>
public int Identifier
{
get
{
return identifier;
}
}
/// <summary>
/// The chunk identifier converted to a string
/// </summary>
public string IdentifierAsString
{
get
{
return ASCIIEncoding.ASCII.GetString(BitConverter.GetBytes(identifier));
}
}
/// <summary>
/// The chunk length
/// </summary>
public int Length
{
get
{
return length;
}
}
/// <summary>
/// The stream position this chunk is located at
/// </summary>
public long StreamPosition
{
get
{
return streamPosition;
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fe306abf31fdbe64481deb697a77ba52
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,322 @@
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
namespace NAudio.Wave.WZT
{
/// <summary>This class supports the reading of WAV files,
/// providing a repositionable WaveStream that returns the raw data
/// contained in the WAV file
/// </summary>
public class WaveFileReader : WaveStream
{
private WaveFormat waveFormat;
private Stream waveStream;
private bool ownInput;
private long dataPosition;
private int dataChunkLength;
private List<RiffChunk> chunks = new List<RiffChunk>();
/// <summary>Supports opening a WAV file</summary>
/// <remarks>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
/// </remarks>
public WaveFileReader(String waveFile) :
this(File.OpenRead(waveFile))
{
ownInput = true;
}
/// <summary>
/// Creates a Wave File Reader based on an input stream
/// </summary>
/// <param name="inputStream">The input stream containing a WAV file including header</param>
public WaveFileReader(Stream inputStream)
{
this.waveStream = inputStream;
ReadWaveHeader(waveStream, out waveFormat, out dataPosition, out dataChunkLength, chunks);
Position = 0;
}
/// <summary>
/// Reads the header part of a WAV file from a stream
/// </summary>
/// <param name="stream">The stream, positioned at the start of audio data</param>
/// <param name="format">The format found</param>
/// <param name="dataChunkPosition">The position of the data chunk</param>
/// <param name="dataChunkLength">The length of the data chunk</param>
/// <param name="chunks">Additional chunks found</param>
public static void ReadWaveHeader(Stream stream, out WaveFormat format, out long dataChunkPosition, out int dataChunkLength, List<RiffChunk> 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");
}
}
/// <summary>
/// Gets a list of the additional chunks found in this file
/// </summary>
public List<RiffChunk> ExtraChunks
{
get
{
return chunks;
}
}
/// <summary>
/// Gets the data for the specified chunk
/// </summary>
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;
}
/// <summary>
/// Cleans up the resources associated with this WaveFileReader
/// </summary>
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);
}
/// <summary>
/// <see cref="WaveStream.WaveFormat"/>
/// </summary>
public override WaveFormat WaveFormat
{
get
{
return waveFormat;
}
}
/// <summary>
/// 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)
/// <see cref="WaveStream.WaveFormat"/>
/// </summary>
public override long Length
{
get
{
return dataChunkLength;
}
}
/// <summary>
/// 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'
/// </summary>
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");
}
}
}
/// <summary>
/// Position in the WAV data chunk.
/// <see cref="Stream.Position"/>
/// </summary>
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;
}
}
}
/// <summary>
/// Reads bytes from the Wave File
/// <see cref="Stream.Read"/>
/// </summary>
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);
}
/// <summary>
/// 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
/// </summary>
/// <returns>False if the end of the WAV data chunk was reached</returns>
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");
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b8920394775cdb6438bd7656c5c68841
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,389 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace NAudio.Wave.WZT
{
/// <summary>
/// Represents a Wave file format
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi, Pack=2)]
public class WaveFormat
{
/// <summary>format type</summary>
protected WaveFormatEncoding waveFormatTag;
/// <summary>number of channels</summary>
protected short channels;
/// <summary>sample rate</summary>
protected int sampleRate;
/// <summary>for buffer estimation</summary>
protected int averageBytesPerSecond;
/// <summary>block size of data</summary>
protected short blockAlign;
/// <summary>number of bits per sample of mono data</summary>
protected short bitsPerSample;
/// <summary>number of following bytes</summary>
protected short extraSize;
/// <summary>
/// Creates a new PCM 44.1Khz stereo 16 bit format
/// </summary>
public WaveFormat() : this(44100,16,2)
{
}
/// <summary>
/// Creates a new 16 bit wave format with the specified sample
/// rate and channel count
/// </summary>
/// <param name="sampleRate">Sample Rate</param>
/// <param name="channels">Number of channels</param>
public WaveFormat(int sampleRate, int channels)
: this(sampleRate, 16, channels)
{
}
/// <summary>
/// Gets the size of a wave buffer equivalent to the latency in milliseconds.
/// </summary>
/// <param name="milliseconds">The milliseconds.</param>
/// <returns></returns>
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;
}
/// <summary>
/// Creates a WaveFormat with custom members
/// </summary>
/// <param name="tag">The encoding</param>
/// <param name="sampleRate">Sample Rate</param>
/// <param name="channels">Number of channels</param>
/// <param name="averageBytesPerSecond">Average Bytes Per Second</param>
/// <param name="blockAlign">Block Align</param>
/// <param name="bitsPerSample">Bits Per Sample</param>
/// <returns></returns>
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;
}
/// <summary>
/// Creates an A-law wave format
/// </summary>
/// <param name="sampleRate">Sample Rate</param>
/// <param name="channels">Number of Channels</param>
/// <returns>Wave Format</returns>
public static WaveFormat CreateALawFormat(int sampleRate, int channels)
{
return CreateCustomFormat(WaveFormatEncoding.ALaw, sampleRate, channels, sampleRate * channels, 1, 8);
}
/// <summary>
/// Creates a Mu-law wave format
/// </summary>
/// <param name="sampleRate">Sample Rate</param>
/// <param name="channels">Number of Channels</param>
/// <returns>Wave Format</returns>
public static WaveFormat CreateMuLawFormat(int sampleRate, int channels)
{
return CreateCustomFormat(WaveFormatEncoding.MuLaw, sampleRate, channels, sampleRate * channels, 1, 8);
}
/// <summary>
/// Creates a new PCM format with the specified sample rate, bit depth and channels
/// </summary>
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;
}
/// <summary>
/// Creates a new 32 bit IEEE floating point wave format
/// </summary>
/// <param name="sampleRate">sample rate</param>
/// <param name="channels">number of channels</param>
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;
}
/// <summary>
/// Helper function to retrieve a WaveFormat structure from a pointer
/// </summary>
/// <param name="pointer">WaveFormat structure</param>
/// <returns></returns>
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;
}
/// <summary>
/// Helper function to marshal WaveFormat to an IntPtr
/// </summary>
/// <param name="format">WaveFormat</param>
/// <returns>IntPtr to WaveFormat structure (needs to be freed by callee)</returns>
public static IntPtr MarshalToPtr(WaveFormat format)
{
int formatSize = Marshal.SizeOf(format);
IntPtr formatPointer = Marshal.AllocHGlobal(formatSize);
Marshal.StructureToPtr(format, formatPointer, false);
return formatPointer;
}
/// <summary>
/// Reads in a WaveFormat (with extra data) from a fmt chunk (chunk identifier and
/// length should already have been read)
/// </summary>
/// <param name="br">Binary reader</param>
/// <param name="formatChunkLength">Format chunk length</param>
/// <returns>A WaveFormatExtraData</returns>
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);
}
}
}
/// <summary>
/// Reads a new WaveFormat object from a stream
/// </summary>
/// <param name="br">A binary reader that wraps the stream</param>
public WaveFormat(BinaryReader br)
{
int formatChunkLength = br.ReadInt32();
this.ReadWaveFormat(br, formatChunkLength);
}
/// <summary>
/// Reports this WaveFormat as a string
/// </summary>
/// <returns>String describing the wave format</returns>
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();
}
}
/// <summary>
/// Compares with another WaveFormat object
/// </summary>
/// <param name="obj">Object to compare to</param>
/// <returns>True if the objects are the same</returns>
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;
}
/// <summary>
/// Provides a Hashcode for this WaveFormat
/// </summary>
/// <returns>A hashcode</returns>
public override int GetHashCode()
{
return (int) waveFormatTag ^
(int) channels ^
sampleRate ^
averageBytesPerSecond ^
(int) blockAlign ^
(int) bitsPerSample;
}
/// <summary>
/// Returns the encoding type used
/// </summary>
public WaveFormatEncoding Encoding
{
get
{
return waveFormatTag;
}
}
/// <summary>
/// Writes this WaveFormat object to a stream
/// </summary>
/// <param name="writer">the output stream</param>
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);
}
/// <summary>
/// Returns the number of channels (1=mono,2=stereo etc)
/// </summary>
public int Channels
{
get
{
return channels;
}
}
/// <summary>
/// Returns the sample rate (samples per second)
/// </summary>
public int SampleRate
{
get
{
return sampleRate;
}
}
/// <summary>
/// Returns the average number of bytes used per second
/// </summary>
public int AverageBytesPerSecond
{
get
{
return averageBytesPerSecond;
}
}
/// <summary>
/// Returns the block alignment
/// </summary>
public virtual int BlockAlign
{
get
{
return blockAlign;
}
}
/// <summary>
/// Returns the number of bits per sample (usually 16 or 32, sometimes 24 or 8)
/// Can be 0 for some codecs
/// </summary>
public int BitsPerSample
{
get
{
return bitsPerSample;
}
}
/// <summary>
/// Returns the number of extra bytes used by this waveformat. Often 0,
/// except for compressed formats which store extra data after the WAVEFORMATEX header
/// </summary>
public int ExtraSize
{
get
{
return extraSize;
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f709c5c91c6ee1347bbdbfb71e25563d
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,314 @@
using System;
namespace NAudio.Wave.WZT
{
/// <summary>
/// Summary description for WaveFormatEncoding.
/// </summary>
public enum WaveFormatEncoding : ushort
{
/// <summary>WAVE_FORMAT_UNKNOWN, Microsoft Corporation</summary>
Unknown = 0x0000,
/// <summary>WAVE_FORMAT_PCM Microsoft Corporation</summary>
Pcm = 0x0001,
/// <summary>WAVE_FORMAT_ADPCM Microsoft Corporation</summary>
Adpcm = 0x0002,
/// <summary>WAVE_FORMAT_IEEE_FLOAT Microsoft Corporation</summary>
IeeeFloat = 0x0003,
/// <summary>WAVE_FORMAT_VSELP Compaq Computer Corp.</summary>
Vselp = 0x0004,
/// <summary>WAVE_FORMAT_IBM_CVSD IBM Corporation</summary>
IbmCvsd = 0x0005,
/// <summary>WAVE_FORMAT_ALAW Microsoft Corporation</summary>
ALaw = 0x0006,
/// <summary>WAVE_FORMAT_MULAW Microsoft Corporation</summary>
MuLaw = 0x0007,
/// <summary>WAVE_FORMAT_DTS Microsoft Corporation</summary>
Dts = 0x0008,
/// <summary>WAVE_FORMAT_DRM Microsoft Corporation</summary>
Drm = 0x0009,
/// <summary>WAVE_FORMAT_OKI_ADPCM OKI</summary>
OkiAdpcm = 0x0010,
/// <summary>WAVE_FORMAT_DVI_ADPCM Intel Corporation</summary>
DviAdpcm = 0x0011,
/// <summary>WAVE_FORMAT_IMA_ADPCM Intel Corporation</summary>
ImaAdpcm = DviAdpcm,
/// <summary>WAVE_FORMAT_MEDIASPACE_ADPCM Videologic</summary>
MediaspaceAdpcm = 0x0012,
/// <summary>WAVE_FORMAT_SIERRA_ADPCM Sierra Semiconductor Corp </summary>
SierraAdpcm = 0x0013,
/// <summary>WAVE_FORMAT_G723_ADPCM Antex Electronics Corporation </summary>
G723Adpcm = 0x0014,
/// <summary>WAVE_FORMAT_DIGISTD DSP Solutions, Inc.</summary>
DigiStd = 0x0015,
/// <summary>WAVE_FORMAT_DIGIFIX DSP Solutions, Inc.</summary>
DigiFix = 0x0016,
/// <summary>WAVE_FORMAT_DIALOGIC_OKI_ADPCM Dialogic Corporation</summary>
DialogicOkiAdpcm = 0x0017,
/// <summary>WAVE_FORMAT_MEDIAVISION_ADPCM Media Vision, Inc.</summary>
MediaVisionAdpcm = 0x0018,
/// <summary>WAVE_FORMAT_CU_CODEC Hewlett-Packard Company </summary>
CUCodec = 0x0019,
/// <summary>WAVE_FORMAT_YAMAHA_ADPCM Yamaha Corporation of America</summary>
YamahaAdpcm = 0x0020,
/// <summary>WAVE_FORMAT_SONARC Speech Compression</summary>
SonarC = 0x0021,
/// <summary>WAVE_FORMAT_DSPGROUP_TRUESPEECH DSP Group, Inc </summary>
DspGroupTrueSpeech = 0x0022,
/// <summary>WAVE_FORMAT_ECHOSC1 Echo Speech Corporation</summary>
EchoSpeechCorporation1 = 0x0023,
/// <summary>WAVE_FORMAT_AUDIOFILE_AF36, Virtual Music, Inc.</summary>
AudioFileAf36 = 0x0024,
/// <summary>WAVE_FORMAT_APTX Audio Processing Technology</summary>
Aptx = 0x0025,
/// <summary>WAVE_FORMAT_AUDIOFILE_AF10, Virtual Music, Inc.</summary>
AudioFileAf10 = 0x0026,
/// <summary>WAVE_FORMAT_PROSODY_1612, Aculab plc</summary>
Prosody1612 = 0x0027,
/// <summary>WAVE_FORMAT_LRC, Merging Technologies S.A. </summary>
Lrc = 0x0028,
/// <summary>WAVE_FORMAT_DOLBY_AC2, Dolby Laboratories</summary>
DolbyAc2 = 0x0030,
/// <summary>WAVE_FORMAT_GSM610, Microsoft Corporation</summary>
Gsm610 = 0x0031,
/// <summary>WAVE_FORMAT_MSNAUDIO, Microsoft Corporation</summary>
MsnAudio = 0x0032,
/// <summary>WAVE_FORMAT_ANTEX_ADPCME, Antex Electronics Corporation</summary>
AntexAdpcme = 0x0033,
/// <summary>WAVE_FORMAT_CONTROL_RES_VQLPC, Control Resources Limited </summary>
ControlResVqlpc = 0x0034,
/// <summary>WAVE_FORMAT_DIGIREAL, DSP Solutions, Inc. </summary>
DigiReal = 0x0035,
/// <summary>WAVE_FORMAT_DIGIADPCM, DSP Solutions, Inc.</summary>
DigiAdpcm = 0x0036,
/// <summary>WAVE_FORMAT_CONTROL_RES_CR10, Control Resources Limited</summary>
ControlResCr10 = 0x0037,
/// <summary></summary>
WAVE_FORMAT_NMS_VBXADPCM = 0x0038, // Natural MicroSystems
/// <summary></summary>
WAVE_FORMAT_CS_IMAADPCM = 0x0039, // Crystal Semiconductor IMA ADPCM
/// <summary></summary>
WAVE_FORMAT_ECHOSC3 = 0x003A, // Echo Speech Corporation
/// <summary></summary>
WAVE_FORMAT_ROCKWELL_ADPCM = 0x003B, // Rockwell International
/// <summary></summary>
WAVE_FORMAT_ROCKWELL_DIGITALK = 0x003C, // Rockwell International
/// <summary></summary>
WAVE_FORMAT_XEBEC = 0x003D, // Xebec Multimedia Solutions Limited
/// <summary></summary>
WAVE_FORMAT_G721_ADPCM = 0x0040, // Antex Electronics Corporation
/// <summary></summary>
WAVE_FORMAT_G728_CELP = 0x0041, // Antex Electronics Corporation
/// <summary></summary>
WAVE_FORMAT_MSG723 = 0x0042, // Microsoft Corporation
/// <summary></summary>
Mpeg = 0x0050, // WAVE_FORMAT_MPEG, Microsoft Corporation
/// <summary></summary>
WAVE_FORMAT_RT24 = 0x0052, // InSoft, Inc.
/// <summary></summary>
WAVE_FORMAT_PAC = 0x0053, // InSoft, Inc.
/// <summary></summary>
MpegLayer3 = 0x0055, // WAVE_FORMAT_MPEGLAYER3, ISO/MPEG Layer3 Format Tag
/// <summary></summary>
WAVE_FORMAT_LUCENT_G723 = 0x0059, // Lucent Technologies
/// <summary></summary>
WAVE_FORMAT_CIRRUS = 0x0060, // Cirrus Logic
/// <summary></summary>
WAVE_FORMAT_ESPCM = 0x0061, // ESS Technology
/// <summary></summary>
WAVE_FORMAT_VOXWARE = 0x0062, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_CANOPUS_ATRAC = 0x0063, // Canopus, co., Ltd.
/// <summary></summary>
WAVE_FORMAT_G726_ADPCM = 0x0064, // APICOM
/// <summary></summary>
WAVE_FORMAT_G722_ADPCM = 0x0065, // APICOM
/// <summary></summary>
WAVE_FORMAT_DSAT_DISPLAY = 0x0067, // Microsoft Corporation
/// <summary></summary>
WAVE_FORMAT_VOXWARE_BYTE_ALIGNED = 0x0069, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_VOXWARE_AC8 = 0x0070, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_VOXWARE_AC10 = 0x0071, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_VOXWARE_AC16 = 0x0072, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_VOXWARE_AC20 = 0x0073, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_VOXWARE_RT24 = 0x0074, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_VOXWARE_RT29 = 0x0075, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_VOXWARE_RT29HW = 0x0076, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_VOXWARE_VR12 = 0x0077, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_VOXWARE_VR18 = 0x0078, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_VOXWARE_TQ40 = 0x0079, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_SOFTSOUND = 0x0080, // Softsound, Ltd.
/// <summary></summary>
WAVE_FORMAT_VOXWARE_TQ60 = 0x0081, // Voxware Inc
/// <summary></summary>
WAVE_FORMAT_MSRT24 = 0x0082, // Microsoft Corporation
/// <summary></summary>
WAVE_FORMAT_G729A = 0x0083, // AT&T Labs, Inc.
/// <summary></summary>
WAVE_FORMAT_MVI_MVI2 = 0x0084, // Motion Pixels
/// <summary></summary>
WAVE_FORMAT_DF_G726 = 0x0085, // DataFusion Systems (Pty) (Ltd)
/// <summary></summary>
WAVE_FORMAT_DF_GSM610 = 0x0086, // DataFusion Systems (Pty) (Ltd)
/// <summary></summary>
WAVE_FORMAT_ISIAUDIO = 0x0088, // Iterated Systems, Inc.
/// <summary></summary>
WAVE_FORMAT_ONLIVE = 0x0089, // OnLive! Technologies, Inc.
/// <summary></summary>
WAVE_FORMAT_SBC24 = 0x0091, // Siemens Business Communications Sys
/// <summary></summary>
WAVE_FORMAT_DOLBY_AC3_SPDIF = 0x0092, // Sonic Foundry
/// <summary></summary>
WAVE_FORMAT_MEDIASONIC_G723 = 0x0093, // MediaSonic
/// <summary></summary>
WAVE_FORMAT_PROSODY_8KBPS = 0x0094, // Aculab plc
/// <summary></summary>
WAVE_FORMAT_ZYXEL_ADPCM = 0x0097, // ZyXEL Communications, Inc.
/// <summary></summary>
WAVE_FORMAT_PHILIPS_LPCBB = 0x0098, // Philips Speech Processing
/// <summary></summary>
WAVE_FORMAT_PACKED = 0x0099, // Studer Professional Audio AG
/// <summary></summary>
WAVE_FORMAT_MALDEN_PHONYTALK = 0x00A0, // Malden Electronics Ltd.
/// <summary>WAVE_FORMAT_GSM</summary>
Gsm = 0x00A1,
/// <summary>WAVE_FORMAT_G729</summary>
G729 = 0x00A2,
/// <summary>WAVE_FORMAT_G723</summary>
G723 = 0x00A3,
/// <summary>WAVE_FORMAT_ACELP</summary>
Acelp = 0x00A4,
/// <summary></summary>
WAVE_FORMAT_RHETOREX_ADPCM = 0x0100, // Rhetorex Inc.
/// <summary></summary>
WAVE_FORMAT_IRAT = 0x0101, // BeCubed Software Inc.
/// <summary></summary>
WAVE_FORMAT_VIVO_G723 = 0x0111, // Vivo Software
/// <summary></summary>
WAVE_FORMAT_VIVO_SIREN = 0x0112, // Vivo Software
/// <summary></summary>
WAVE_FORMAT_DIGITAL_G723 = 0x0123, // Digital Equipment Corporation
/// <summary></summary>
WAVE_FORMAT_SANYO_LD_ADPCM = 0x0125, // Sanyo Electric Co., Ltd.
/// <summary></summary>
WAVE_FORMAT_SIPROLAB_ACEPLNET = 0x0130, // Sipro Lab Telecom Inc.
/// <summary></summary>
WAVE_FORMAT_SIPROLAB_ACELP4800 = 0x0131, // Sipro Lab Telecom Inc.
/// <summary></summary>
WAVE_FORMAT_SIPROLAB_ACELP8V3 = 0x0132, // Sipro Lab Telecom Inc.
/// <summary></summary>
WAVE_FORMAT_SIPROLAB_G729 = 0x0133, // Sipro Lab Telecom Inc.
/// <summary></summary>
WAVE_FORMAT_SIPROLAB_G729A = 0x0134, // Sipro Lab Telecom Inc.
/// <summary></summary>
WAVE_FORMAT_SIPROLAB_KELVIN = 0x0135, // Sipro Lab Telecom Inc.
/// <summary></summary>
WAVE_FORMAT_G726ADPCM = 0x0140, // Dictaphone Corporation
/// <summary></summary>
WAVE_FORMAT_QUALCOMM_PUREVOICE = 0x0150, // Qualcomm, Inc.
/// <summary></summary>
WAVE_FORMAT_QUALCOMM_HALFRATE = 0x0151, // Qualcomm, Inc.
/// <summary></summary>
WAVE_FORMAT_TUBGSM = 0x0155, // Ring Zero Systems, Inc.
/// <summary></summary>
WAVE_FORMAT_MSAUDIO1 = 0x0160, // Microsoft Corporation
/// <summary>
/// WAVE_FORMAT_WMAUDIO2, Microsoft Corporation
/// </summary>
WAVE_FORMAT_WMAUDIO2 = 0x0161,
/// <summary>
/// WAVE_FORMAT_WMAUDIO3, Microsoft Corporation
/// </summary>
WAVE_FORMAT_WMAUDIO3 = 0x0162,
/// <summary></summary>
WAVE_FORMAT_UNISYS_NAP_ADPCM = 0x0170, // Unisys Corp.
/// <summary></summary>
WAVE_FORMAT_UNISYS_NAP_ULAW = 0x0171, // Unisys Corp.
/// <summary></summary>
WAVE_FORMAT_UNISYS_NAP_ALAW = 0x0172, // Unisys Corp.
/// <summary></summary>
WAVE_FORMAT_UNISYS_NAP_16K = 0x0173, // Unisys Corp.
/// <summary></summary>
WAVE_FORMAT_CREATIVE_ADPCM = 0x0200, // Creative Labs, Inc
/// <summary></summary>
WAVE_FORMAT_CREATIVE_FASTSPEECH8 = 0x0202, // Creative Labs, Inc
/// <summary></summary>
WAVE_FORMAT_CREATIVE_FASTSPEECH10 = 0x0203, // Creative Labs, Inc
/// <summary></summary>
WAVE_FORMAT_UHER_ADPCM = 0x0210, // UHER informatic GmbH
/// <summary></summary>
WAVE_FORMAT_QUARTERDECK = 0x0220, // Quarterdeck Corporation
/// <summary></summary>
WAVE_FORMAT_ILINK_VC = 0x0230, // I-link Worldwide
/// <summary></summary>
WAVE_FORMAT_RAW_SPORT = 0x0240, // Aureal Semiconductor
/// <summary></summary>
WAVE_FORMAT_ESST_AC3 = 0x0241, // ESS Technology, Inc.
/// <summary></summary>
WAVE_FORMAT_IPI_HSX = 0x0250, // Interactive Products, Inc.
/// <summary></summary>
WAVE_FORMAT_IPI_RPELP = 0x0251, // Interactive Products, Inc.
/// <summary></summary>
WAVE_FORMAT_CS2 = 0x0260, // Consistent Software
/// <summary></summary>
WAVE_FORMAT_SONY_SCX = 0x0270, // Sony Corp.
/// <summary></summary>
WAVE_FORMAT_FM_TOWNS_SND = 0x0300, // Fujitsu Corp.
/// <summary></summary>
WAVE_FORMAT_BTV_DIGITAL = 0x0400, // Brooktree Corporation
/// <summary></summary>
WAVE_FORMAT_QDESIGN_MUSIC = 0x0450, // QDesign Corporation
/// <summary></summary>
WAVE_FORMAT_VME_VMPCM = 0x0680, // AT&T Labs, Inc.
/// <summary></summary>
WAVE_FORMAT_TPC = 0x0681, // AT&T Labs, Inc.
/// <summary></summary>
WAVE_FORMAT_OLIGSM = 0x1000, // Ing C. Olivetti & C., S.p.A.
/// <summary></summary>
WAVE_FORMAT_OLIADPCM = 0x1001, // Ing C. Olivetti & C., S.p.A.
/// <summary></summary>
WAVE_FORMAT_OLICELP = 0x1002, // Ing C. Olivetti & C., S.p.A.
/// <summary></summary>
WAVE_FORMAT_OLISBC = 0x1003, // Ing C. Olivetti & C., S.p.A.
/// <summary></summary>
WAVE_FORMAT_OLIOPR = 0x1004, // Ing C. Olivetti & C., S.p.A.
/// <summary></summary>
WAVE_FORMAT_LH_CODEC = 0x1100, // Lernout & Hauspie
/// <summary></summary>
WAVE_FORMAT_NORRIS = 0x1400, // Norris Communications, Inc.
/// <summary></summary>
WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS = 0x1500, // AT&T Labs, Inc.
/// <summary></summary>
WAVE_FORMAT_DVM = 0x2000, // FAST Multimedia AG
/// <summary>WAVE_FORMAT_EXTENSIBLE</summary>
Extensible = 0xFFFE, // Microsoft
/// <summary></summary>
WAVE_FORMAT_DEVELOPMENT = 0xFFFF,
// others - not from MS headers
/// <summary>WAVE_FORMAT_VORBIS1 "Og" Original stream compatible</summary>
Vorbis1 = 0x674f,
/// <summary>WAVE_FORMAT_VORBIS2 "Pg" Have independent header</summary>
Vorbis2 = 0x6750,
/// <summary>WAVE_FORMAT_VORBIS3 "Qg" Have no codebook header</summary>
Vorbis3 = 0x6751,
/// <summary>WAVE_FORMAT_VORBIS1P "og" Original stream compatible</summary>
Vorbis1P = 0x676f,
/// <summary>WAVE_FORMAT_VORBIS2P "pg" Have independent headere</summary>
Vorbis2P = 0x6770,
/// <summary>WAVE_FORMAT_VORBIS3P "qg" Have no codebook header</summary>
Vorbis3P = 0x6771,
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 07c489cad6787a04eadcc0f7b39dfc3e
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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
{
/// <summary>
/// WaveFormatExtensible
/// http://www.microsoft.com/whdc/device/audio/multichaud.mspx
/// </summary>
[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;
/// <summary>
/// Parameterless constructor for marshalling
/// </summary>
WaveFormatExtensible()
{
}
/// <summary>
/// Creates a new WaveFormatExtensible for PCM or IEEE
/// </summary>
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");
}
}
/// <summary>
/// SubFormat (may be one of AudioMediaSubtypes)
/// </summary>
public Guid SubFormat { get { return subFormat; } }
/// <summary>
/// Serialize
/// </summary>
/// <param name="writer"></param>
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);
}
/// <summary>
/// String representation
/// </summary>
public override string ToString()
{
return String.Format("{0} wBitsPerSample:{1} dwChannelMask:{2} subFormat:{3} extraSize:{4}",
base.ToString(),
wValidBitsPerSample,
dwChannelMask,
subFormat,
extraSize);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5d0e3542e85464541a0022c04d0da8b6
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
namespace NAudio.Wave.WZT
{
/// <summary>
/// This class used for marshalling from unmanaged code
/// </summary>
[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];
/// <summary>
/// Allows the extra data to be read
/// </summary>
public byte[] ExtraData { get { return extraData; } }
/// <summary>
/// parameterless constructor for marshalling
/// </summary>
internal WaveFormatExtraData()
{
}
/// <summary>
/// Reads this structure from a BinaryReader
/// </summary>
public WaveFormatExtraData(BinaryReader reader)
: base(reader)
{
ReadExtraData(reader);
}
internal void ReadExtraData(BinaryReader reader)
{
if (this.extraSize > 0)
{
reader.Read(extraData, 0, extraSize);
}
}
/// <summary>
/// Writes this structure to a BinaryWriter
/// </summary>
public override void Serialize(BinaryWriter writer)
{
base.Serialize(writer);
if (extraSize > 0)
{
writer.Write(extraData, 0, extraSize);
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fad90a98c9bb79f4e86bf7f8e56d85b9
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,143 @@
// created on 27/12/2002 at 20:20
using System;
using System.IO;
using NAudio.Lame;
namespace NAudio.Wave.WZT
{
/// <summary>
/// Base class for all WaveStream classes. Derives from stream.
/// </summary>
public abstract class WaveStream : Stream, IWaveProvider
{
/// <summary>
/// Retrieves the WaveFormat for this stream
/// </summary>
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
/// <summary>
/// We can read from this stream
/// </summary>
public override bool CanRead { get { return true; } }
/// <summary>
/// We can seek within this stream
/// </summary>
public override bool CanSeek { get { return true; } }
/// <summary>
/// We can't write to this stream
/// </summary>
public override bool CanWrite { get { return false; } }
/// <summary>
/// Flush does not need to do anything
/// See <see cref="Stream.Flush"/>
/// </summary>
public override void Flush() { }
/// <summary>
/// An alternative way of repositioning.
/// See <see cref="Stream.Seek"/>
/// </summary>
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;
}
/// <summary>
/// Sets the length of the WaveStream. Not Supported.
/// </summary>
/// <param name="length"></param>
public override void SetLength(long length)
{
throw new NotSupportedException("Can't set length of a WaveFormatString");
}
/// <summary>
/// Writes to the WaveStream. Not Supported.
/// </summary>
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotSupportedException("Can't write to a WaveFormatString");
}
/// <summary>
/// The block alignment for this wavestream. Do not modify the Position
/// to anything that is not a whole multiple of this value
/// </summary>
public virtual int BlockAlign
{
get
{
return WaveFormat.BlockAlign;
}
}
/// <summary>
/// Moves forward or backwards the specified number of seconds in the stream
/// </summary>
/// <param name="seconds">Number of seconds to move, can be negative</param>
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;
}
}
/// <summary>
/// The current position in the stream in Time format
/// </summary>
public virtual TimeSpan CurrentTime
{
get
{
return TimeSpan.FromSeconds((double)Position / WaveFormat.AverageBytesPerSecond);
}
set
{
Position = (long) (value.TotalSeconds * WaveFormat.AverageBytesPerSecond);
}
}
/// <summary>
/// Total length in real-time of the stream (may be an estimate for compressed files)
/// </summary>
public virtual TimeSpan TotalTime
{
get
{
return TimeSpan.FromSeconds((double) Length / WaveFormat.AverageBytesPerSecond);
}
}
/// <summary>
/// Whether the WaveStream has non-zero sample data at the current position for the
/// specified count
/// </summary>
/// <param name="count">Number of bytes to read</param>
public virtual bool HasData(int count)
{
return Position < Length;
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1e3938bcd2820f546a28486ea4b7ba5d
timeCreated: 1493208131
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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>();
audioSource.clip = www.GetAudioClip();
audioSource.Play();
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 847526f57fb424a4b842d98ba15c6b65
timeCreated: 1493116478
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1cf6ec65b2df9324d9777836cb87ac2c
timeCreated: 1493116273
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant: