Exemplo n.º 1
0
 public extern static bool Init(int device,
                                int freq,
                                int chans,
                                WasapiInitFlags flags,
                                float buffer         = 0,
                                float period         = 0,
                                WasapiProcedure proc = null,
                                IntPtr User          = default(IntPtr));
Exemplo n.º 2
0
 public static extern bool Init(int Device,
                                int Frequency             = 0,
                                int Channels              = 0,
                                WasapiInitFlags Flags     = WasapiInitFlags.Shared,
                                float Buffer              = 0,
                                float Period              = 0,
                                WasapiProcedure Procedure = null,
                                IntPtr User = default(IntPtr));
Exemplo n.º 3
0
        public Analyzer()
        {
            _timer.Interval = TimeSpan.FromMilliseconds(1000 / 120f);
            _timer.Tick    += TimerUpdateEventHandler;

            // ReSharper disable once RedundantDelegateCreation
            _wasapiProcedure = new WasapiProcedure(Process); // capture to avoid freeing by GC
            _initialized     = false;
            Init();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create a new instance of <see cref="LoopbackProvider"/>.
        /// </summary>
        /// <param name="Device"><see cref="WasapiLoopbackDevice"/> to use.</param>
        /// <param name="IncludeSilence">Whether to record silence?... default = true</param>
        public LoopbackProvider(WasapiLoopbackDevice Device, bool IncludeSilence = true)
        {
            _deviceIndex = Device.DeviceIndex;
            _proc        = Procedure;

            if (IncludeSilence)
            {
                _silencePlayer = new Silence(PlaybackDevice.Devices.First(Dev => Dev.Info.Driver == Device.Info.ID));
            }

            BassWasapi.Init(_deviceIndex, Procedure: _proc);
            BassWasapi.CurrentDevice = Device.DeviceIndex;

            var info = BassWasapi.Info;

            WaveFormat = WaveFormat.CreateIeeeFloatWaveFormat(info.Frequency, info.Channels);
        }
Exemplo n.º 5
0
        public void WasapiInit()
        {
            int i;

            do
            {
                i = new Random().Next(BassWasapi.DeviceCount);
            }while (!BassWasapi.GetDeviceInfo(i).IsEnabled);

            if (BassWasapi.GetDeviceInfo(i).IsInitialized)
            {
                BassWasapi.CurrentDevice = i;
                BassWasapi.Free();
            }

            var proc = new WasapiProcedure((b, c, u) => c);

            Assert.IsTrue(BassWasapi.Init(i, 44100, 2, WasapiInitFlags.Shared, 0, 0, proc), "Cannot Init a random WASAPI device - {0}", Bass.LastError);

            Assert.IsTrue(BassWasapi.Free(), "Cannot free initialized WASAPI device - {0}", Bass.LastError);
        }
Exemplo n.º 6
0
 protected WasapiDevice()
 {
     proc = new WasapiProcedure(OnProc);
 }