Exemplo n.º 1
0
        private void PlaySingleAudioShot()
        {
            Snapshot snapshot       = ThreadControlCenter.Main.ActiveSnapshot;
            int      bytesPerSecond = 48000;
            double   duration       = 0.5;
            double   frame          = duration / bytesPerSecond;
            int      steps          = Convert.ToInt32(bytesPerSecond * duration);

            short[] amplitudes = new short[steps];
            double  start      = ThreadControlCenter.Main.SecondsSinceStart;

            Parallel.For(0, steps, i =>
            {
                float amplitude = snapshot.GetAmplitude(i * frame + start, 0);
                if (amplitude >= 1)
                {
                    amplitudes[i] = 32760;
                }
                else if (amplitude < -1)
                {
                    amplitudes[i] = 0;
                }
                else
                {
                    amplitudes[i] = Convert.ToInt16(amplitude * 32760);
                }
            });
            SoundWave.Play(amplitudes);
        }
Exemplo n.º 2
0
 public EyeWebShape(double tone, double toneWidth = 1, float powerBase = 1.8f, float centerSubstract = 0.5f)
 {
     coordinates    = new EyeWebCoordinate[4];
     coordinates[0] = new EyeWebCoordinate(tone, powerBase, centerSubstract);
     coordinates[1] = new EyeWebCoordinate(tone + toneWidth, powerBase, centerSubstract);
     coordinates[2] = new EyeWebCoordinate(tone + 12 + toneWidth, powerBase, centerSubstract);
     coordinates[3] = new EyeWebCoordinate(tone + 12, powerBase, centerSubstract);
     this.tone      = tone;
     soundWave      = new SoundWave(tone);
 }