예제 #1
0
        public static void Detect(int device)
        {
            if (IsInitialized)
            {
                throw new InvalidOperationException("Device is already initialized.");
            }

            IsInitialized = true;

            Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detecting ASIO device.");

            try
            {
                BassAsioUtils.OK(BassAsio.Init(device, AsioInitFlags.Thread));
                BassAsioUtils.OK(BassAsioHandler.Init());
                var info = default(AsioChannelInfo);
                BassAsioUtils.OK(BassAsio.ChannelGetInfo(false, PRIMARY_CHANNEL, out info));
                Info = new BassAsioDeviceInfo(
                    BassAsio.CurrentDevice,
                    Convert.ToInt32(BassAsio.Rate),
                    BassAsio.Info.Inputs,
                    BassAsio.Info.Outputs,
                    GetSupportedRates(),
                    info.Format
                    );
                Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detected ASIO device: {0} => Inputs => {1}, Outputs = {2}, Rate = {3}, Format = {4}", BassAsio.CurrentDevice, Info.Inputs, Info.Outputs, Info.Rate, Enum.GetName(typeof(AsioSampleFormat), Info.Format));
                Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detected ASIO device: {0} => Rates => {1}", BassAsio.CurrentDevice, string.Join(", ", Info.SupportedRates));
            }
            finally
            {
                Free();
            }
        }
예제 #2
0
        public static void Init(int device)
        {
            if (device == BassAsioStreamOutputConfiguration.ASIO_NO_DEVICE)
            {
                throw new InvalidOperationException("A valid device must be provided.");
            }
            LogManager.Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Initializing BASS ASIO.");
            BassAsioUtils.OK(BassAsio.Init(device, AsioInitFlags.Thread));
            BassAsioUtils.OK(BassAsioHandler.Init());
            IsInitialized = true;
            var info = default(AsioChannelInfo);

            BassAsioUtils.OK(BassAsio.ChannelGetInfo(false, PRIMARY_CHANNEL, out info));
            Device          = device;
            Devices[device] = new BassAsioDeviceInfo(
                info.Name,
                Convert.ToInt32(BassAsio.Rate),
                BassAsio.Info.Inputs,
                BassAsio.Info.Outputs,
                GetSupportedRates(),
                info.Format
                );
            LogManager.Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detected ASIO device: {0} => Name => {1}, Inputs => {2}, Outputs = {3}, Rate = {4}, Format = {5}", Device, Info.Name, Info.Inputs, Info.Outputs, Info.Rate, Enum.GetName(typeof(AsioSampleFormat), Info.Format));
            LogManager.Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detected ASIO device: {0} => Rates => {1}", Device, string.Join(", ", Info.SupportedRates));
        }