Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool WaveCutOff(string filePath, int[] channelValues)
- {
- byte[] bytes = File.ReadAllBytes(filePath);
- int startOffset = DataOffset(bytes);
- int dataLength = (bytes.Length - startOffset);
- byte[] data = new byte[dataLength];
- int channel = 0;
- int segmentCount = 0;
- for(int i = 0; i < dataLength; i++)
- {
- if (segmentCount >= 2)
- {
- channel++;
- segmentCount = 0;
- }
- if (channel >= channelValues.Length)
- channel = 0;
- /* if (channel == 0)
- data[i] = 255;
- else
- data[i] = 0;*/
- data[i] = (byte)(Math.Abs(bytes[startOffset + i] - channelValues[channel]) % 255);
- segmentCount++;
- }
- FileStream fstream = new FileStream(filePath + ".mod.wav", FileMode.Create);
- BinaryWriter bpisac = new BinaryWriter(fstream);
- //write the header
- for (int i = 0; i < startOffset; i++)
- bpisac.Write(bytes[i]);
- //write the data
- for (int i = 0; i < data.Length; i++)
- bpisac.Write(data[i]);
- fstream.Close();
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement