using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using Microsoft.DirectX.DirectSound; using System.Media; using WaveRecorder; using System.Windows; namespace SpellingBee { public partial class AddQuizForm : Form { //Sound devices //Sound reference http://aaronamberman.com/tutorials/csaudio.php private SoundCapture sndCapt; private SoundDevices sndDevice; private Playback playBack; private bool isRecording = false; } private void setSound() { //int sampling = 96000; //short bitSample = 16; //short chnls = 2; try { //Set and reset devices sndDevice = new SoundDevices(this); sndCapt = new SoundCapture(96000); sndCapt.OnWavComplete += new SoundCapture.Complete(sndCapt_OnWavComplete); //sndCapt = new SoundCapture(SoundCapture._96000_HZ, SoundCapture._16_Bit, SoundCapture._STEREO); } catch (Exception ex) { MessageBox.Show(String.Concat(ex.StackTrace, ex.Message)); if (ex.InnerException != null) { MessageBox.Show("Sound could not be set at setSound()" + Environment.NewLine + String.Concat(ex.InnerException.StackTrace, ex.InnerException.Message)); } } }
public SoundCapture(int samplingRate) { if (samplingRate < 11025) samplingRate = 11025; else if (samplingRate > 11025 && samplingRate < 22050) samplingRate = 22050; else if (samplingRate > 22050 && samplingRate < 44100) samplingRate = 44100; else if (samplingRate > 44100 && samplingRate < 96000) samplingRate = 96000; else if (samplingRate > 96000) samplingRate = 96000; wvFrmt = new WaveFormat(); wvFrmt.SamplesPerSecond = samplingRate; if (samplingRate <= 22050) wvFrmt.BitsPerSample = 8; else if (samplingRate >= 44100) wvFrmt.BitsPerSample = 16; if (samplingRate <= 22050) wvFrmt.Channels = 1; else if (samplingRate >= 44100) wvFrmt.Channels = 2; wvFrmt.FormatTag = WaveFormatTag.Pcm; wvFrmt.BlockAlign = (short)(wvFrmt.Channels * (wvFrmt.BitsPerSample / 8)); wvFrmt.AverageBytesPerSecond = wvFrmt.SamplesPerSecond * wvFrmt.BlockAlign; cpturBffrDesc = new CaptureBufferDescription(); cpturBffrDesc.BufferBytes = wvFrmt.AverageBytesPerSecond; cpturBffrDesc.ControlEffects = false; cpturBffrDesc.Format = wvFrmt; cpturBffrDesc.WaveMapped = true; cptur = new Capture(); cptrBffr = new CaptureBuffer(cpturBffrDesc, cptur);//This is where the 2nd part of the error is listed rawSoundData = new List<byte[]>(); SetCaptureNotifications();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)