/// <summary> /// Handles the exception. Throws an exception based on the error. /// </summary> /// <param name="error">The error to check.</param> /// <param name="methodName">Method name</param> private void handleException(ASIOError error, String methodName) { if (error != ASIOError.ASE_OK && error != ASIOError.ASE_SUCCESS) { ASIOException asioException = new ASIOException(String.Format("Error code [{0}] while calling ASIO method <{1}>, {2}", ASIOException.getErrorName(error), methodName, this.getErrorMessage())); asioException.Error = error; throw asioException; } }
/// <summary> /// Builds the capabilities internally. /// </summary> private void BuildCapabilities() { capability = new AsioDriverCapability(); capability.DriverName = driver.getDriverName(); // Get nb Input/Output channels driver.getChannels(out capability.NbInputChannels, out capability.NbOutputChannels); capability.InputChannelInfos = new ASIOChannelInfo[capability.NbInputChannels]; capability.OutputChannelInfos = new ASIOChannelInfo[capability.NbOutputChannels]; // Get ChannelInfo for Inputs for (int i = 0; i < capability.NbInputChannels; i++) { capability.InputChannelInfos[i] = driver.getChannelInfo(i, true); } // Get ChannelInfo for Output for (int i = 0; i < capability.NbOutputChannels; i++) { capability.OutputChannelInfos[i] = driver.getChannelInfo(i, false); } // Get the current SampleRate capability.SampleRate = driver.getSampleRate(); var error = driver.GetLatencies(out capability.InputLatency, out capability.OutputLatency); // focusrite scarlett 2i4 returns ASE_NotPresent here if (error != ASIOError.ASE_OK && error != ASIOError.ASE_NotPresent) { var ex = new ASIOException("ASIOgetLatencies"); ex.Error = error; throw ex; } // Get BufferSize driver.getBufferSize(out capability.BufferMinSize, out capability.BufferMaxSize, out capability.BufferPreferredSize, out capability.BufferGranularity); }