Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public byte[] CalculateNewSound() {
- ReadWavFile rwf = new ReadWavFile(pathWavFile);
- byteArray = rwf.ReadWave();
- return byteArray;
- }
- public void CalculateNewSoundshort() {
- using (FileStream fs = new FileStream(pathWavFile, FileMode.Open, FileAccess.Read)) {
- using (BinaryReader br = new BinaryReader(fs)) {
- shortArray = new short[fs.Length / 2];
- for (int i = 0; i < fs.Length / 2; i++) {
- shortArray[i] = br.ReadInt16();
- }
- }
- }
- }
- public short[] Bit16Sound() {
- int bytesPerSecond = (bitsPerSample * sampleRate * channel) / 16;
- int actualByte = bytesPerSecond * delay;
- CalculateNewSoundshort();
- Int32 tempValue;
- int dataStart = zoekData();
- int start16 = dataStart / 2;
- for (int i = start16; i < shortArray.Length; i++)
- {
- if (i - start16 >= actualByte)
- {
- tempValue = (Int32)(((Int32)shortArray[i] + (Int32)shortArray[i - actualByte]) * (1.0 - demping));
- if (tempValue > 32767)
- {
- tempValue = 32767;
- }
- else if (tempValue < -32768)
- {
- tempValue = -32768;
- }
- shortArray[i] = (short)tempValue;
- }
- }
- return shortArray;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement