Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WavUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public static byte[] FromAudioClip (AudioClip audioClip, out string filepath, bo
//Debug.AssertFormat (bitDepth == 16, "Only converting 16 bit is currently supported. The audio clip data is {0} bit.", bitDepth);

// total file size = 44 bytes for header format and audioClip.samples * factor due to float to Int16 / sbyte conversion
int fileSize = audioClip.samples * BlockSize_16Bit + headerSize; // BlockSize (bitDepth)
int fileSize = audioClip.samples * BlockSize_16Bit * audioClip.channels + headerSize; // BlockSize (bitDepth)

// chunk descriptor (riff)
WriteFileHeader (ref stream, fileSize);
Expand Down Expand Up @@ -304,7 +304,7 @@ private static int WriteFileData (ref MemoryStream stream, AudioClip audioClip,
byte[] id = Encoding.ASCII.GetBytes ("data");
count += WriteBytesToMemoryStream (ref stream, id, "DATA_ID");

int subchunk2Size = Convert.ToInt32 (audioClip.samples * BlockSize_16Bit); // BlockSize (bitDepth)
int subchunk2Size = Convert.ToInt32 (audioClip.samples * BlockSize_16Bit * audioClip.channels); // BlockSize (bitDepth)
count += WriteBytesToMemoryStream (ref stream, BitConverter.GetBytes (subchunk2Size), "SAMPLES");

// Validate header
Expand Down