public void ProcessBlockFromFile(int[] samplesIn) { if (WriteCallback == null) { throw new ArgumentNullException("WriteCallback", "Public Field WriteCallback must be set prior to using this method"); } if (BitPermutationIndicesRemaining == 0) { BitPermutationIndices.Clear(); } foreach (int sample in samplesIn) { if (BitPermutationIndicesRemaining <= 0) { AudioByteDataBitAssociation toAdd = new AudioByteDataBitAssociation(sample, 0); toAdd.Modified = true; AudioByteAssociations.AddLast(toAdd); } else { int generatedIndex = Rng.Next(BitPermutationIndicesRemaining); var assoc = new AudioByteDataBitAssociation(sample, BitPermutationIndices[generatedIndex]); AudioByteAssociations.AddLast(assoc); HashedAssociations[assoc.BitPosition] = assoc; IndicesUsed++; int temp = BitPermutationIndices[generatedIndex]; BitPermutationIndices[generatedIndex] = BitPermutationIndices[BitPermutationIndicesRemaining]; BitPermutationIndices[BitPermutationIndicesRemaining] = temp; } ProcessedSamples++; } ReadInNecessaryData(); WriteModifiedAssociations(WriteCallback); }
private void AudioFileWriteCallback(int[] samplesIn) { if (BitPermutationIndicesRemaining == 0) { BitPermutationIndices.Clear(); return; } foreach (int sample in samplesIn) { if (BitPermutationIndices.Count - IndicesUsed == 0) { continue; } int generatedIndex = Rng.Next(BitPermutationIndicesRemaining); int bitPosition = BitPermutationIndices[generatedIndex]; IndicesUsed++; int temp = BitPermutationIndices[generatedIndex]; BitPermutationIndices[generatedIndex] = BitPermutationIndices[BitPermutationIndicesRemaining]; BitPermutationIndices[BitPermutationIndicesRemaining] = temp; HashedAssociations[bitPosition] = new DataFileByteBitAssociation(bitPosition, ExtractLSB(sample)); } CheckAssociationsForConsecutivity(); }