Skip to content

Commit

Permalink
Ensure the temporary writer buffer is allocated
Browse files Browse the repository at this point in the history
sorry!!!
  • Loading branch information
ascpixi committed Jul 7, 2022
1 parent 47b8313 commit 941309e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions source/Cosmos.System2/Audio/IO/AudioBufferWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,18 @@ public AudioBufferWriter(AudioBuffer target, SampleFormat writeFormat)
if(target.Format.BitDepth == writeFormat.BitDepth && target.Format.Signed == writeFormat.Signed)
{
mode = OperationMode.ChannelCopy;
} else
}
else
{
shouldMakeSigned = !writeFormat.Signed && target.Format.Signed; // whether we should make the samples in 'src' signed
shouldChangeSign = shouldMakeSigned || (!target.Format.Signed && writeFormat.Signed); // whether we should change the sign of the samples

buffer = new byte[
Math.Max(writeFormat.ChannelSize, target.Format.ChannelSize) * Math.Max(writeFormat.Channels, target.Format.Channels)
];

mode = OperationMode.Convert;
}
}

buffer = new byte[
Math.Max(writeFormat.ChannelSize, target.Format.ChannelSize) * Math.Max(writeFormat.Channels, target.Format.Channels)
];
}
}

Expand Down

0 comments on commit 941309e

Please sign in to comment.