public AsioSampleProvider(string driverName, int sampleRate = 44100, int numChannels = 2) { this.sampleRate = sampleRate; this.numChannels = numChannels; //For now assuming ASIO in is PCM 16 (H6 input is PCM 16bit and not planning to use another interface) //In future may need some sort of data conversion this.WaveFormat = new WaveFormat(sampleRate, numChannels); waveProvider = new BufferedWaveProvider(this.WaveFormat); sampleProvider = waveProvider.ToSampleProvider(); try { asio = new AsioOut(driverName); asio.InitRecordAndPlayback(null, numChannels, sampleRate); asio.AudioAvailable += OnAudioAvailable; asio.Play(); Debug.Log(string.Format("Asio Playing: {0}", asio.PlaybackState)); } catch (System.ArgumentException e) { Debug.Log(string.Format("Invalid ASIO Driver Name: {0}", e)); } catch (System.Exception e) { Debug.Log(string.Format("Unknown ASIO Error: {0}", e)); } }
private void Start() { // allow change device if (asioOut != null && (asioOut.DriverName != comboBoxAsioDevice.Text || asioOut.ChannelOffset != GetUserSpecifiedChannelOffset())) { asioOut.AudioAvailable -= OnAsioOutAudioAvailable; asioOut.Dispose(); asioOut = null; } int recordChannelCount = GetUserSpecifiedChannelCount(); // create device if necessary if (asioOut == null) { asioOut = new AsioOut(comboBoxAsioDevice.Text); asioOut.InputChannelOffset = GetUserSpecifiedChannelOffset(); asioOut.InitRecordAndPlayback(null, recordChannelCount, 44100); asioOut.AudioAvailable += OnAsioOutAudioAvailable; } fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".wav"); writer = new WaveFileWriter(fileName, new WaveFormat(44100, recordChannelCount)); asioOut.Play(); timer1.Enabled = true; SetButtonStates(); }
public ViewModel(int rows, int cols) { Maze = new Maze(rows, cols); _generators = new List <IMazeGenerator>() { new DepthFirstSearchGenerator(Maze), new BinaryTreeGenerator(Maze), new KruskalsRandomizedGenerator(Maze), new SidewinderGenerator(Maze), new HuntAndKillGenerator(Maze), new PrimsRandomizedGenerator(Maze), new EllersGenerator(Maze), }; _asio = new AsioOut("Focusrite USB ASIO"); _asio.Init(_sineWaveProvider); //waveOut = new WaveOut(); //waveOut.Init(_sineWaveProvider); GenerateCommand = new RelayCommand(o => { _sineWaveProvider.Frequency = 0; _asio.Play(); //waveOut.Play(); RunGenerator(); }); }
static Audio() { var asioDrivers = AsioOut.GetDriverNames(); if (asioDrivers.Length == 0) { Console.WriteLine("please install http://www.asio4all.org/"); Console.WriteLine("press any key to exit"); Console.ReadKey(); Environment.Exit(0); } asioOut = new AsioOut(asioDrivers[0]); mixer = new MixingWaveProvider32(); hit = new WaveChannel32(new AudioFileReader("hitsound.wav")) { Volume = 0.2f, }; miss = new WaveChannel32(new AudioFileReader("miss.wav")) { Volume = 0.2f, }; var err = new SignalGenerator() { Type = SignalGeneratorType.SawTooth, Gain = 0.2, }.Take(TimeSpan.FromSeconds(0.1d)).ToWaveProvider(); mixer.AddInputStream(hit); mixer.AddInputStream(miss); asioOut.Init(mixer); asioOut.Play(); }
public void PlayAudio() { if (_device == null) { return; } _device.Play(); }
public void Start() { if (!initialised) { initialise(); } driver.Play(); }
public MainWindow() { String[] drivernames = AsioOut.GetDriverNames(); ASIODriver = new AsioOut(drivernames[0]); buffer = new BufferedWaveProvider(new WaveFormat()); ASIODriver.AudioAvailable += new EventHandler <AsioAudioAvailableEventArgs>(ASIODriver_AudioAvailable); ASIODriver.InitRecordAndPlayback(buffer, 2, 44100); ASIODriver.Play(); }
private void InitAudio() { synthEngine = new SynthEngine(48000, 32) { Amplitude = 0.5f }; audioOutput = new AsioOut(); audioOutput.Init(synthEngine); audioOutput.Play(); }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { FOutput.SliceCount = SpreadMax; if (FDriverIn.IsChanged) { CreateAsio(); if (FPlayIn[0]) { FAsioOut.Play(); } } if (FShowPanelIn[0]) { FAsioOut.ShowControlPanel(); } if (FWave != FWaveIn[0]) { FWave = FWaveIn[0]; CreateAsio(); if (FPlayIn[0]) { FAsioOut.Play(); } } if (FPlayIn.IsChanged) { if (FPlayIn[0]) { FAsioOut.Play(); } else { FAsioOut.Stop(); } } }
public AudioPlaybackEngine(int driverSelection, int sampleRate = 44100, int channelCount = 2) { this.sampleRate = sampleRate; midiTools = new MIDITools(); outputDevice = new AsioOut(AsioOut.GetDriverNames()[driverSelection]); mixer = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, channelCount)); mixer.ReadFully = true; saver = new SavingSampleProvider(mixer, "test.wav"); InitialiseActiveNotes(128); outputDevice.Init(saver); outputDevice.Play(); }
public void StartRecord(Action <float[], Complex[]> action) { if (_asioOut != null) { return; } _action = action; _cancellationTokenSource = new CancellationTokenSource(); _asioOut = PrepareAsioOut(); _asioOut.AudioAvailable += delegate(object o, AsioAudioAvailableEventArgs args) { _dataFromAsioCollection.Add(args.GetAsInterleavedSamples(), _cancellationTokenSource.Token); }; _recordTask = Task.Run(ProcessAudioData, _cancellationTokenSource.Token) .ContinueWith(t => { t.Exception?.Handle(e => true); }, TaskContinuationOptions.OnlyOnCanceled); ; _asioOut.Play(); }
private void OnButtonBeginClick(object sender, RoutedEventArgs e) { if (!running) { running = true; asioOut = new AsioOut((string)comboAsioDevices.SelectedItem); int inputChannels = asioOut.DriverInputChannelCount; // that's all my soundcard has :( int outputChannels = Math.Min(asioOut.DriverOutputChannelCount, 4); // support up to 4 inputPatcher = new AsioInputPatcher(44100, inputChannels, outputChannels); int ignored = 0; // yuck, really need to improve my API asioOut.InitRecordAndPlayback(new SampleToWaveProvider(inputPatcher), inputChannels, ignored); asioOut.AudioAvailable += OnAsioOutAudioAvailable; SetSliders(); asioOut.Play(); buttonBegin.Content = "Stop"; } else { Stop(); } }
private Mixer() { try { mixer.ReadFully = true; mixer.MixerInputEnded += OnInputEnded; VSP = new VolumeSampleProvider(mixer); VSP.Volume = baseVolume; PSP = new PanningSampleProvider(VSP); PSP.Pan = basePan; // waveOut = new WaveOutEvent(); // waveOut = new DirectSoundOut(40); waveOut = new NAudio.Wave.AsioOut("ASIO4ALL v2"); //waveOut = new AsioOut(); waveOut.Init(PSP); waveOut.Play(); } catch (Exception e) { throw e; } }
public static void Main(string[] args) { var names = AsioOut.GetDriverNames(); var asioDriverName = names[0]; Console.WriteLine("Selected ASIO driver: {0}", asioDriverName); var asioOut = new AsioOut(asioDriverName); //var inputChannels = asioOut.DriverInputChannelCount; asioOut.InputChannelOffset = 0; asioOut.InitRecordAndPlayback(null, 1, SampleRate); asioOut.AudioAvailable += OnAsioOutAudioAvailable; var soundProcessTask = Task.Run(ProcessAudioData, CancellationTokenSource.Token) .ContinueWith(t => { t.Exception?.Handle(e => true); Console.WriteLine("You have canceled the Sound Process task"); }, TaskContinuationOptions.OnlyOnCanceled); var playerTask = Task.Run(PlayAlarm, CancellationTokenSource.Token) .ContinueWith(t => { t.Exception?.Handle(e => true); Console.WriteLine("You have canceled the PlayAlarm task"); }, TaskContinuationOptions.OnlyOnCanceled); ; asioOut.Play(); // start recording Console.WriteLine("Press ENTER to exit"); Console.ReadLine(); asioOut.Stop(); CancellationTokenSource.Cancel(); Task.WaitAll(soundProcessTask, playerTask); }
public async IAsyncEnumerable <Sample[]> EnumerateSamplesAsync(InputOption option, [EnumeratorCancellation] CancellationToken token = default) { if (string.IsNullOrEmpty(option.OptionName)) { throw new ConfigurationNeededException(); } using var asio = new AsioOut(option.OptionName); option.SamplingFrequency = 44100; var wavprov = new BufferedWaveProvider(new WaveFormat(option.SamplingFrequency, 1)); values = new float[samplesBatchSize]; asio.AudioAvailable += HandleBuffer; //asio.InitRecordAndPlayback(wavprov, 1, 44100); asio.InitRecordAndPlayback(null, 1, option.SamplingFrequency); asio.Play(); while (await sampleQueue.OutputAvailableAsync(token)) { var samples = await sampleQueue.TakeAsync(token); yield return(samples); } asio.AudioAvailable -= HandleBuffer; }
private void Play() { // allow change device if (asioOut != null && (asioOut.DriverName != comboBoxAsioDevice.Text || asioOut.ChannelOffset != GetUserSpecifiedChannelOffset())) { asioOut.Dispose(); asioOut = null; } // create device if necessary if (asioOut == null) { asioOut = new AsioOut(comboBoxAsioDevice.Text); asioOut.ChannelOffset = GetUserSpecifiedChannelOffset(); asioOut.Init(reader); } reader.Position = 0; asioOut.Play(); timer1.Enabled = true; SetButtonStates(); }
public static void Play() { waveOut.Play(); }
static void Main(string[] args) { var sampleRate = 48000; var bitDepth = 24; var byteDepth = bitDepth / 8; var devices = AsioOut.GetDriverNames(); // 使用するデバイスを決定する Console.WriteLine("# Input Device"); var srcIndex = SelectDeviceIndex(devices); Console.WriteLine("# Output Device"); var dstIndex = SelectDeviceIndex(devices); // デバイスのルーティング設定 // TEST: srcのMASTER OUT L, RをdstのLRに当てることにする var routingChannels = new int[] { 12, 13 }; // srcのチャンネル番号を並べて書く // あとはよしなに using (var src = new AsioOut(devices[srcIndex])) using (var dst = new AsioOut(devices[dstIndex])) { // ルーティングテーブルがイマイチの場合に補完する var routingChannelDiff = dst.DriverOutputChannelCount - routingChannels.Length; if (routingChannelDiff > 0) { Console.WriteLine($"Warning: RoutingChannel added {routingChannelDiff} empty channles"); routingChannels = routingChannels.Concat(Enumerable.Repeat(-1, routingChannelDiff)).ToArray(); } else if (routingChannelDiff < 0) { Console.WriteLine($"Warning: RoutingChannel resize {routingChannelDiff}"); routingChannels = routingChannels.Take(dst.DriverOutputChannelCount).ToArray(); } Console.WriteLine($"RoutingChannels: [{string.Join(",", routingChannels)}]"); // Output Setting var bufferProvider = new BufferedWaveProvider(new WaveFormat(sampleRate, bitDepth, dst.DriverOutputChannelCount)); dst.Init(bufferProvider); dst.Play(); // Input Setting float[] srcBuffer = null; byte[] dstBuffer = null; src.AudioAvailable += (sx, ex) => { if (srcBuffer == null) { srcBuffer = new float[ex.SamplesPerBuffer * src.DriverInputChannelCount]; // 1ch[0:511], 2ch[512:... nch dstBuffer = new byte[ex.SamplesPerBuffer * dst.DriverOutputChannelCount * byteDepth]; Console.WriteLine("# Source"); Console.WriteLine($"\tDriverName: {src.DriverName}"); Console.WriteLine($"\tDriverInputChannelCount: {src.DriverInputChannelCount}"); Console.WriteLine($"\tDriverOutputChannelCount: {src.DriverOutputChannelCount}"); Console.WriteLine($"\tSamplePerBuffer: {ex.SamplesPerBuffer}"); Console.WriteLine($"\tAsioSampleType: {ex.AsioSampleType}"); Console.WriteLine($"\tsrcBufferSize: {srcBuffer.Length}"); Console.WriteLine("# Destination"); Console.WriteLine($"\tDriverName: {dst.DriverName}"); Console.WriteLine($"\tDriverInputChannelCount: {dst.DriverInputChannelCount}"); Console.WriteLine($"\tDriverOutputChannelCount: {dst.DriverOutputChannelCount}"); Console.WriteLine($"\tdstBufferSize: {dstBuffer.Length}"); } ex.GetAsInterleavedSamples(srcBuffer); // データの書き込み src -> dst for (int dataPtr = 0; dataPtr < ex.SamplesPerBuffer; ++dataPtr) { for (int ch = 0; ch < routingChannels.Length; ++ch) { // src 1sampleのデータをbyteDepthに分割して書き込む UInt32 raw; if (routingChannels[ch] == -1) { raw = 0; } else { var srcPtr = dataPtr + (routingChannels[ch] * ex.SamplesPerBuffer); Int32 sample = (Int32)(srcBuffer[srcPtr] * Int32.MaxValue); raw = (UInt32)sample; } var dstPtr = ((dataPtr * routingChannels.Length) + ch) * byteDepth; for (int byteOffset = 0; byteOffset < byteDepth; ++byteOffset) { dstBuffer[dstPtr + byteOffset] = (byte)((raw >> (8 * (3 - byteOffset))) & 0xff); } } } bufferProvider.AddSamples(dstBuffer, 0, dstBuffer.Length); }; src.InitRecordAndPlayback(null, src.DriverInputChannelCount, sampleRate); src.Play(); Console.ReadKey(); } }
public static void Start(Setting setting) { NAudioWrap.setting = setting; if (waveOut != null) { waveOut.Dispose(); } waveOut = null; if (wasapiOut != null) { wasapiOut.Dispose(); } wasapiOut = null; if (dsOut != null) { dsOut.Dispose(); } dsOut = null; if (asioOut != null) { asioOut.Dispose(); } asioOut = null; if (nullOut != null) { nullOut.Dispose(); } nullOut = null; try { switch (setting.outputDevice.DeviceType) { case 0: waveOut = new WaveOutEvent(); waveOut.DeviceNumber = 0; waveOut.DesiredLatency = setting.outputDevice.Latency; for (int i = 0; i < WaveOut.DeviceCount; i++) { if (setting.outputDevice.WaveOutDeviceName == WaveOut.GetCapabilities(i).ProductName) { waveOut.DeviceNumber = i; break; } } waveOut.PlaybackStopped += DeviceOut_PlaybackStopped; waveOut.Init(waveProvider); waveOut.Play(); break; case 1: System.Guid g = System.Guid.Empty; foreach (DirectSoundDeviceInfo d in DirectSoundOut.Devices) { if (setting.outputDevice.DirectSoundDeviceName == d.Description) { g = d.Guid; break; } } if (g == System.Guid.Empty) { dsOut = new DirectSoundOut(setting.outputDevice.Latency); } else { dsOut = new DirectSoundOut(g, setting.outputDevice.Latency); } dsOut.PlaybackStopped += DeviceOut_PlaybackStopped; dsOut.Init(waveProvider); dsOut.Play(); break; case 2: MMDevice dev = null; var enumerator = new MMDeviceEnumerator(); var endPoints = enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active); foreach (var endPoint in endPoints) { if (setting.outputDevice.WasapiDeviceName == string.Format("{0} ({1})", endPoint.FriendlyName, endPoint.DeviceFriendlyName)) { dev = endPoint; break; } } if (dev == null) { wasapiOut = new WasapiOut(setting.outputDevice.WasapiShareMode ? AudioClientShareMode.Shared : AudioClientShareMode.Exclusive, setting.outputDevice.Latency); } else { wasapiOut = new WasapiOut(dev, setting.outputDevice.WasapiShareMode ? AudioClientShareMode.Shared : AudioClientShareMode.Exclusive, false, setting.outputDevice.Latency); } wasapiOut.PlaybackStopped += DeviceOut_PlaybackStopped; wasapiOut.Init(waveProvider); wasapiOut.Play(); break; case 3: if (AsioOut.isSupported()) { int i = 0; foreach (string s in AsioOut.GetDriverNames()) { if (setting.outputDevice.AsioDeviceName == s) { break; } i++; } int retry = 1; do { try { asioOut = new AsioOut(i); } catch { asioOut = null; Thread.Sleep(1000); retry--; } } while (asioOut == null && retry > 0); asioOut.PlaybackStopped += DeviceOut_PlaybackStopped; asioOut.Init(waveProvider); asioOut.Play(); } break; case 5: nullOut = new NullOut(true); nullOut.PlaybackStopped += DeviceOut_PlaybackStopped; nullOut.Init(waveProvider); nullOut.Play(); break; } } catch (Exception ex) { log.ForcedWrite(ex); waveOut = new WaveOutEvent(); waveOut.PlaybackStopped += DeviceOut_PlaybackStopped; waveOut.Init(waveProvider); waveOut.DeviceNumber = 0; waveOut.Play(); } }
const int EXTRARECORDINGTIME = 10;// Extra recording time in seconds. Make sure we dont miss anything. private void processAudioFile() { goBtn.IsEnabled = false; asioDevice.IsEnabled = false; bool fail = true; OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Select w64 file to process"; if (ofd.ShowDialog() == true) { SaveFileDialog sfd = new SaveFileDialog(); string suffix = ""; sfd.FileName = ofd.FileName + ".ASIOLFLA" + suffix + ".w64"; if (sfd.ShowDialog() == true) { SuperWAV inputAudio = new SuperWAV(ofd.FileName); SuperWAV.WavInfo inInfo = inputAudio.getWavInfo(); if (inInfo.channelCount != 2) { MessageBox.Show("Only files with a channel count of 2 supported."); } else { fail = false; // Allocate an output file. SuperWAV outputAudio = new SuperWAV(sfd.FileName, SuperWAV.WavFormat.WAVE64, inInfo.sampleRate, 2, inInfo.audioFormat, inInfo.bitsPerSample); ConcurrentQueue <float[]> sampleBuffer = new ConcurrentQueue <float[]>(); float[] tmp; bool processingActive = true; UInt64 outputFileOffset = 0; // Do actual processing. AsioOut asioOut = new AsioOut(selectedAsioDevice); SuperWAVProvider sampleProvider = new SuperWAVProvider(inputAudio); IWaveProvider waveProvider = new SampleToWaveProvider(sampleProvider); asioOut.InitRecordAndPlayback(waveProvider, 2, (int)inInfo.sampleRate); asioOut.AudioAvailable += (object sender, AsioAudioAvailableEventArgs e) => { sampleBuffer.Enqueue(e.GetAsInterleavedSamples()); }; _ = Task.Run(() => { Task writerTask = Task.Run(() => { float[] tmp2; while (processingActive) { while (sampleBuffer.Count > 0) { if (!processingActive) { break; } if (sampleBuffer.TryDequeue(out tmp2)) { outputAudio.writeFloatArrayFast(tmp2, outputFileOffset); outputFileOffset += (ulong)tmp2.Length / 2; } } System.Threading.Thread.Sleep(10); // Just make sure we don't eat up all CPU with constant checks of the queue, pointless } }); // Progress updates Task progressTask = Task.Run(() => { while (processingActive) { double progress = (double)sampleProvider.InputOffset / (inputAudio.DataLengthInTicks + inInfo.sampleRate * EXTRARECORDINGTIME); Dispatcher.Invoke(() => { progressBar.Value = progress * 100.0; }); if (progress > 1.0) { processingActive = false; asioOut.Stop(); } System.Threading.Thread.Sleep(100); } }); writerTask.Wait(); progressTask.Wait(); Dispatcher.Invoke(() => { goBtn.IsEnabled = true; asioDevice.IsEnabled = true; }); }); asioOut.Play(); // start recording } } } if (fail) { goBtn.IsEnabled = true; asioDevice.IsEnabled = true; } }
/// <summary> /// 再生する /// </summary> /// <param name="deviceID">再生デバイスID</param> /// <param name="waveFile">wavファイル</param> /// <param name="isDelete">再生後に削除する</param> /// <param name="volume">ボリューム</param> public static void Play( string deviceID, string waveFile, bool isDelete, int volume) { var sw = Stopwatch.StartNew(); var volumeAsFloat = ((float)volume / 100f); try { IWavePlayer player = null; IWaveProvider provider = null; switch (TTSYukkuriConfig.Default.Player) { case WavePlayers.WaveOut: player = new WaveOut() { DeviceNumber = int.Parse(deviceID), DesiredLatency = PlayerLatencyWaveOut, }; break; case WavePlayers.DirectSound: player = new DirectSoundOut( Guid.Parse(deviceID), PlayerLatencyDirectSoundOut); break; case WavePlayers.WASAPI: player = new WasapiOut( deviceEnumrator.GetDevice(deviceID), AudioClientShareMode.Shared, false, PlayerLatencyWasapiOut); break; case WavePlayers.ASIO: player = new AsioOut(deviceID); break; } if (player == null) { return; } provider = new AudioFileReader(waveFile) { Volume = volumeAsFloat }; player.Init(provider); player.PlaybackStopped += (s, e) => { player.Dispose(); var file = provider as IDisposable; if (file != null) { file.Dispose(); } if (isDelete) { File.Delete(waveFile); } }; // 再生する player.Play(); } catch (Exception ex) { ActGlobals.oFormActMain.WriteExceptionLog( ex, "サウンドの再生で例外が発生しました。"); } finally { sw.Stop(); Debug.WriteLine( "PlaySound ({0}) -> {1:N0} ticks", TTSYukkuriConfig.Default.Player, sw.ElapsedTicks); } }
public void StartRecording() { _asioOut?.InitRecordAndPlayback(null, _waveFormat.Channels, _waveFormat.SampleRate); _asioOut?.Play(); }
private void StartStopSineWave() { if (asioOut == null) { button1.Content = "Stop Sound"; Console.WriteLine("User Selected Channels: " + selectedChannels); WaveOutCapabilities outdeviceInfo = WaveOut.GetCapabilities(0); waveOutChannels = outdeviceInfo.Channels; asioOut = new AsioOut(0); int waveOutDevices = WaveOut.DeviceCount; for (int i = 0; i < waveOutDevices; i++) { outdeviceInfo = WaveOut.GetCapabilities(i); Console.WriteLine("Device {0}: {1}, {2} channels", i, outdeviceInfo.ProductName, outdeviceInfo.Channels); } List <IWaveProvider> inputs = new List <IWaveProvider>(); frequencies = new List <int>(); centerbins = new List <int>(); for (int c = 0; c < selectedChannels; c++) { if (c != (selectedChannels - 1)) { inputs.Add(new SineWaveProvider32(0, 0.25f, 44100, 1)); frequencies.Add(0); centerbins.Add((int)Math.Round((0) / 10.768)); } else { inputs.Add(new SineWaveProvider32(600, 0.25f, 44100, 1)); frequencies.Add(300); centerbins.Add((int)Math.Round((600) / 10.768)); } } var splitter = new MultiplexingWaveProvider(inputs, selectedChannels); try { asioOut.Init(splitter); asioOut.Play(); } catch (System.ArgumentException) { Console.WriteLine("Invalid audio channel count. Please select a lower number of audio channels"); } //waveOut = new WaveOut(); //waveOut.Init(sineWaveProvider); //waveOut.Init(splitter); Console.WriteLine("Number of Channels: " + asioOut.NumberOfOutputChannels); Console.WriteLine("Playback Latency: " + asioOut.PlaybackLatency); } else { asioOut.Stop(); asioOut.Dispose(); asioOut = null; button1.Content = "Start Sound"; frequencies.Clear(); centerbins.Clear(); //Foutstream.Clear(); } }
protected override SinkSourceMode driverConnect() { if (selectedDriver <= 0) { return(SinkSourceMode.Offline); } owner.logText(String.Format("Opening ASIO Device {0}", driverNames[selectedDriver])); try { waveDev = new AsioOut(driverNames[selectedDriver]); waveDev.ChannelOffset = 0; waveDev.InputChannelOffset = 0; if ((waveDev.DriverInputChannelCount == 0) && (waveDev.DriverOutputChannelCount == 0)) { throw new Exception(String.Format("ASIO Driver {0} proveides no Input or output channels", driverNames[selectedDriver])); } RTIO[] ins = new RTIO[min(waveDev.DriverInputChannelCount, maxChannels)]; RTIO[] outs = new RTIO[min(waveDev.DriverOutputChannelCount, maxChannels)]; if ((waveDev.DriverInputChannelCount > 0) && (maxChannels > 0)) { ins[0] = ioI1; } if ((waveDev.DriverInputChannelCount > 1) && (maxChannels > 1)) { ins[1] = ioI2; } if ((waveDev.DriverInputChannelCount > 2) && (maxChannels > 2)) { ins[2] = ioI3; } if ((waveDev.DriverInputChannelCount > 3) && (maxChannels > 3)) { ins[3] = ioI4; } if ((waveDev.DriverInputChannelCount > 4) && (maxChannels > 4)) { ins[4] = ioI5; } if ((waveDev.DriverInputChannelCount > 5) && (maxChannels > 5)) { ins[5] = ioI6; } if ((waveDev.DriverInputChannelCount > 6) && (maxChannels > 6)) { ins[6] = ioI7; } if ((waveDev.DriverInputChannelCount > 7) && (maxChannels > 7)) { ins[7] = ioI8; } if ((waveDev.DriverOutputChannelCount > 0) && (maxChannels > 0)) { outs[0] = ioO1; } if ((waveDev.DriverOutputChannelCount > 1) && (maxChannels > 1)) { outs[1] = ioO2; } if ((waveDev.DriverOutputChannelCount > 2) && (maxChannels > 2)) { outs[2] = ioO3; } if ((waveDev.DriverOutputChannelCount > 3) && (maxChannels > 3)) { outs[3] = ioO4; } if ((waveDev.DriverOutputChannelCount > 4) && (maxChannels > 4)) { outs[4] = ioO5; } if ((waveDev.DriverOutputChannelCount > 5) && (maxChannels > 5)) { outs[5] = ioO6; } if ((waveDev.DriverOutputChannelCount > 6) && (maxChannels > 6)) { outs[6] = ioO7; } if ((waveDev.DriverOutputChannelCount > 7) && (maxChannels > 7)) { outs[7] = ioO8; } setChannels(outs, ins); if (waveProvider == null) { waveProvider = new NAudioShortWaveProvider(this); } waveProvider.SetWaveFormat(owner.sampleRate, toDriverChannels); if (fromDriverChannels == 0) { waveDev.InitRecordAndPlayback(waveProvider, 0, owner.sampleRate); } else if (toDriverChannels == 0) { waveDev.InitRecordAndPlayback(null, fromDriverChannels, owner.sampleRate); } else { waveDev.InitRecordAndPlayback(waveProvider, fromDriverChannels, owner.sampleRate); } if (fromDriverChannels > 0) { waveDev.AudioAvailable += ASIO_AudioAvailable; } waveDev.Play(); if (fromDriverChannels == 0) { processingType = ProcessingType.SynchronousSource; } else { processingType = ProcessingType.SynchronousSink; } owner.logText(String.Format("ASIO Device {0} open", driverNames[selectedDriver])); return(SinkSourceMode.Online); } catch (Exception e) { owner.showLogWin(); owner.logText(e.Message); return(SinkSourceMode.Error); } }
public void Start() { asioOut.Play(); }