예제 #1
0
파일: ASIO.cs 프로젝트: EraYaN/EV2020
        public ASIO(InstalledDriver instdriver, int[] InputChannels, int[] OutputChannels, int QueueDepth = DefaultQueueDepth)
        {
            System.Diagnostics.Debug.WriteLine("ASIO driver: {0}", instdriver);
            driver = AsioDriver.SelectDriver(instdriver);
            driver.BufferUpdate += new EventHandler(AsioDriver_BufferUpdate);

            System.Diagnostics.Debug.WriteLine("Version: {0}", driver.Version);
            System.Diagnostics.Debug.WriteLine("In: {0}; Out: {1}", driver.NumberInputChannels, driver.NumberOutputChannels);
            Init();
            foreach(int ch_ind in InputChannels){
                if (ch_ind < driver.NumberInputChannels && ch_ind >= 0)
                {
                    inputChannels.Add(driver.InputChannels[ch_ind]);
                    sampleBuffersIn.Add(new CircularBuffer<double>(QueueDepth, true));
                }
            }
            foreach (int ch_ind in OutputChannels)
            {
                if (ch_ind < driver.NumberOutputChannels && ch_ind >= 0)
                {
                    outputChannels.Add(driver.OutputChannels[ch_ind]);
                    sampleBuffersOut.Add(new CircularBuffer<double>(QueueDepth, true));
                }
            }
        }
예제 #2
0
        public Asio(InstalledDriver drv)
        {
            ProcessAudio = null;

            // make sure we have at least one ASIO driver installed
            if (AsioDriver.InstalledDrivers.Length == 0)
            {
                return;
            }

            // load and activate the desited driver
            driver = AsioDriver.SelectDriver(drv);

            // driver.ShowControlPanel();

            driver.CreateBuffers(false);

            // this is our buffer fill event we need to respond to
            driver.BufferUpdate += new EventHandler(AsioDriver_BufferUpdate);
        }
예제 #3
0
        public static void LoadDriver(InstalledDriver driver)
        {
            if (AudioCaptureSettings.LoadedDriver != null)
            {
                AudioCaptureSettings.LoadedDriver.Release();
            }

            // Load the driver, set the sample rate, and temporarily create buffers so we can enumerate the input channels
            try
            {
                AudioCaptureSettings.LoadedDriver = AsioDriver.SelectDriver(driver);
                AudioCaptureSettings.LoadedDriver.SetSampleRate(AudioCaptureSettings.SampleRate);
                AudioCaptureSettings.LoadedDriver.CreateBuffers(false, -1);
            }
            catch (ApplicationException)
            {
                throw new Exception("Could not initialize driver");
            }

            AudioCaptureSettings.LoadedDriver.DisposeBuffers();

            Raise_DriverLoaded(AudioCaptureSettings.LoadedDriver);
        }
예제 #4
0
 public LoadDriverCommandArgs(InstalledDriver driver, uint sampleRate)
 {
     _driver = driver;
     _sampleRate = sampleRate;
 }
예제 #5
0
        static ASIODriver SelectDriver(InstalledDriver _drvinf)
        {
            ASIODriver _drv = ASIODriver.GetASIODriverByGuid(new Guid(_drvinf.ClsId));

            return(_drv);
        }
예제 #6
0
파일: Localizer.cs 프로젝트: EraYaN/EV2020
 public bool InitializeDriver(InstalledDriver driver)
 {
     asio = new ASIO(driver, _inputChannels, _outputChannels, Convert.ToInt32(ASIO.Fs));
     Debug.WriteLine("Starting timer.");
     //TODO back to 250 ms
     timer = new System.Timers.Timer(sampleLength * 1000 * (matchedFilterEnabled && !matchedFilterToep ? 2 : 2)); // TEST: 8 times longer
     timer.Elapsed += timer_Elapsed;
     timer.Start();
     asio.IsInputEnabled = true;
     return true;
 }
        /// <summary>
        /// Check if the currently installed driver is a better match than the best driver we found in the updates source
        /// </summary>
        /// <param name="installedDriver">The installed driver</param>
        /// <param name="matchResult">The best driver match found in the updates source</param>
        /// <param name="hardwareIdList">The list of hardware ids for the device</param>
        /// <param name="computerHardwareIds">List of computer hardware ids</param>
        /// <returns>True if the installed driver is a better match, false otherwise</returns>
        private bool IsInstalledDriverBetterMatch(InstalledDriver installedDriver, DriverMatchResult matchResult, List <string> hardwareIdList, List <Guid> computerHardwareIds)
        {
            if (installedDriver.MatchingComputerHWID.HasValue)
            {
                if (!matchResult.MatchedComputerHardwareId.HasValue)
                {
                    // The installed driver matched a computer HW ID while the match result did not; the installed driver is better
                    return(false);
                }
                else
                {
                    // Both installed and matched driver matched a computer hardware id
                    // Compare them on how specific the match was
                    var installedDriverComputerMatchIndex = computerHardwareIds.IndexOf(installedDriver.MatchingComputerHWID.Value);
                    var matchedDriverComputerMatchIndex   = computerHardwareIds.IndexOf(matchResult.MatchedComputerHardwareId.Value);

                    if (installedDriverComputerMatchIndex == matchedDriverComputerMatchIndex)
                    {
                        // The installed and matched drivers matched on the same computer hardware id;
                        // Compare them based on feature score

                        // Get the installed driver's features score
                        // A driver rank is formatted as 0xSSGGTHHH, where the value of 0x00GG0000 is the feature score
                        var installedDriverFeatureScore = (byte)((installedDriver.DriverRank & 0x00FF0000) >> 24);

                        // If the match result does not have a feature score, consider the score to be 255
                        var matchResultEffectiveFeatureScore = matchResult.MatchedFeatureScore == null ? byte.MaxValue : matchResult.MatchedFeatureScore.Score;

                        if (installedDriverFeatureScore != matchResultEffectiveFeatureScore)
                        {
                            // The installed driver is a better match if the feature score is less that the match result feature score
                            return(installedDriverFeatureScore < matchResultEffectiveFeatureScore);
                        }
                    }
                    else
                    {
                        // Installed driver is better if it matched on a more specific computer hardware id (appears sooner in the list of computer hardware ids)
                        return(installedDriverComputerMatchIndex < matchedDriverComputerMatchIndex);
                    }
                }
            }
            else if (matchResult.MatchedComputerHardwareId.HasValue)
            {
                // The installed driver did not match a computer hardware id but the match result did match
                return(true);
            }

            // The installed and matched drivers have the same ranking so far; compare them by how specific is the hardware id match

            var installedDriverMatchIndex = hardwareIdList.IndexOf(installedDriver.MatchingID);
            var matchResultMatchIndex     = hardwareIdList.IndexOf(matchResult.MatchedHardwareId);

            if (installedDriverMatchIndex == matchResultMatchIndex)
            {
                // Both our driver match and the installed driver matched the same HWID. Figure out the best one by comparing versions
                if (matchResult.MatchedVersion.Date == installedDriver.DriverVerDate)
                {
                    return((ulong)installedDriver.DriverVerVersion > matchResult.MatchedVersion.Version);
                }
                else
                {
                    // The installed driver is better if it has a higher timestamp
                    return(installedDriver.DriverVerDate > matchResult.MatchedVersion.Date);
                }
            }
            else
            {
                // Installed driver is better if it matched on a more specific device hardware id (appears sooner in the list of device hardware ids)
                return(installedDriverMatchIndex < matchResultMatchIndex);
            }
        }