Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1.  public void CalculateNewSoundshort() {
  2.             using (FileStream fs = new FileStream(pathWavFile, FileMode.Open, FileAccess.Read)) {
  3.                 using (BinaryReader br = new BinaryReader(fs)) {
  4.  
  5.                     shortArray = new short[fs.Length / 2];
  6.  
  7.                     for (int i = 0; i < fs.Length / 2; i++) {
  8.                         shortArray[i] = br.ReadInt16();
  9.                     }
  10.                 }
  11.             }
  12.         }
  13.  
  14.         public short[] Bit16Sound() {
  15.             int bytesPerSecond = (bitsPerSample * sampleRate * channel) / 16;
  16.             int actualByte = bytesPerSecond * delay;
  17.  
  18.             CalculateNewSoundshort();
  19.  
  20.             Int32 tempValue;
  21.  
  22.             int dataStart = zoekData();
  23.             int start16 = dataStart / 2;
  24.  
  25.             for (int i = start16; i < shortArray.Length; i++)
  26.             {
  27.                 if (i - start16 >= actualByte)
  28.                 {
  29.                     tempValue = (Int32)(((Int32)shortArray[i] + (Int32)shortArray[i - actualByte]) * (1.0 - demping));
  30.                     if (tempValue > 32767)
  31.                     {
  32.                         tempValue = 32767;
  33.                     }
  34.                     else if (tempValue < -32768)
  35.                     {
  36.                         tempValue = -32768;
  37.                     }
  38.                     shortArray[i] = (short)tempValue;
  39.                 }
  40.             }
  41.  
  42.             return shortArray;
  43.  
  44.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement