ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • C# NAudio MicroPhone 볼륨 조절
    프로그래밍 언어/C# 2020. 8. 20. 21:07

    private void sourceStream_DataAvailable(object sender, NAudio.Wave.WaveInEventArgs e)

    {

        byte[] encoded = e.Buffer;

        if (reLen + encoded.Length < 70000)

        {

            if (recordingFirstSkip > 6)

            {

                encoded.CopyTo(recordingStream, reLen);

                int i;

               float multiplier = 12.0f; // 볼륨 Gain

               for (i = 0; i < encoded.Length; i = i + 2)

               {

                   Int16 sample = BitConverter.ToInt16(encoded, i);

                   sample = (Int16)(sample * multiplier);

                   byte[] sampleBytes = BitConverter.GetBytes(sample);

                   encoded[i] = sampleBytes[0];

                   encoded[i + 1] = sampleBytes[1];

                }

                encoded.CopyTo(recordingStream2, reLen);

                reLen += encoded.Length;

               }

              else

             {

                  encoded.CopyTo(recordingStream, reLen);

                  encoded.CopyTo(recordingStream2, reLen);

                  recordingFirstSkip++;

             }

        }

    }

     

     

     

     

    '프로그래밍 언어 > C#' 카테고리의 다른 글

    C# RGB 출력, YUV420 -> RGB로 출력  (0) 2020.09.01
    C# 이미지 그리기, 출력  (0) 2020.08.21
Designed by Tistory.