Exemplo n.º 1
0
        //TODO wrap WaveIn to allow DI
        public void Initialise(WaveFormat format, WaveIn driver)
        {
            if (driver == null)
            {
                throw new ArgumentNullException("driver", "Must specify a WaveIn device instance");
            }

            if (format == null)
            {
                throw new ArgumentNullException("format", "Must specify an audio format");
            }

            this.driver = driver;

            driver.DataAvailable += device_DataAvailable;

            var caps = WaveIn.GetCapabilities(driver.DeviceNumber);

            driver.WaveFormat = format;
            device = new WaveInDeviceData
            {
                Driver = driver,
                Name = caps.ProductName,
                Channels = caps.Channels,
                Buffers = new float[caps.Channels][]
            };

            Format = WaveFormat.CreateIeeeFloatWaveFormat(format.SampleRate, device.Channels);
            formatPerLine = WaveFormat.CreateIeeeFloatWaveFormat(format.SampleRate, 1);

            mapInputs(device.Channels);
        }
Exemplo n.º 2
0
        //TODO wrap WaveIn to allow DI
        public void Initialise(WaveFormat format, WaveIn driver)
        {
            if (driver == null)
            {
                throw new ArgumentNullException("driver", "Must specify a WaveIn device instance");
            }

            if (format == null)
            {
                throw new ArgumentNullException("format", "Must specify an audio format");
            }

            this.driver = driver;

            driver.DataAvailable += device_DataAvailable;

            var caps = WaveIn.GetCapabilities(driver.DeviceNumber);

            driver.WaveFormat = format;
            device            = new WaveInDeviceData
            {
                Driver   = driver,
                Name     = caps.ProductName,
                Channels = caps.Channels,
                Buffers  = new float[caps.Channels][]
            };

            Format        = WaveFormat.CreateIeeeFloatWaveFormat(format.SampleRate, device.Channels);
            formatPerLine = WaveFormat.CreateIeeeFloatWaveFormat(format.SampleRate, 1);

            mapInputs(device.Channels);
        }