Figured out a way to un-interleave the sound-data in place with one pass, with a simple algorithm. The principle is the see where a byte is supposed to go, save the value at the location, write into location, Repeat from where you are at now.
I was a little surprised that this concept wasn't brought up on the stream.
(Horrible C/pseudo code by someone who has never written any C, also untested)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 | uint32 PointAt = 1;
int32 GetValueNext = SampleData[PointAt];
for(uint32 SampleIndex = 1;
SampleIndex < Result.SampleCount - 1;
++SampleIndex)
{
int32 GetValue = GetValueNext;
uint32 WasPoint = PointAt;
PointAt = RoundUpStub(PointAt/2); // Round up, also a stub
if(IsOddThisReallyIsAStub(WasPoint)) // Check if value is an odd number
{
PointAt = PointAt+Result.SampleCount/2-1;
GetValueNext = SampleData[PointAt];
SampleData[PointAt] = GetValue;
}
else
{
GetValueNext = SampleData[PointAt];
SampleData[PointAt] = GetValue;
}
}
|