Example #1
0
 public static void WriteToConsole(object sender, VolArgs e)
 {
     Console.SetCursorPosition(0, wells[e.Position]);
     Console.Write(new String(' ', 10));
     Console.SetCursorPosition(0, wells[e.Position]);
     Console.Write("\r" + e.Message);
 }
Example #2
0
        void OnDataAvailable(object sender, WaveInEventArgs e)
        {
            byte[] buffer = e.Buffer;

            for (int index = 0; index < e.BytesRecorded; index += 2)
            {
                short sample = (short)((buffer[index + 1] << 8) |
                                       buffer[index + 0]);
                float sample32 = sample / 32768f;
                maxValue = Math.Max(maxValue, sample32);
                minValue = Math.Min(minValue, sample32);
                sampleCount++;
            }

            if (sampleCount > 100)
            {
                VolArgs va = new VolArgs(DisplayWriter.VolMeter(Math.Max(maxValue, Math.Abs(minValue))), position);
                sampleCount = 0;
                maxValue    = 0f;
                minValue    = 0f;

                displayVolume(this, va);
            }
        }