private void ChangeState(AsioStatus newState) { Console.WriteLine("AsioWrap.ChangeState() {0} ==> {1}", state, newState); if (state == newState) { return; } switch (state) { case AsioStatus.PreInit: System.Diagnostics.Debug.Assert( newState == AsioStatus.DriverNotLoaded); break; case AsioStatus.DriverNotLoaded: System.Diagnostics.Debug.Assert( newState == AsioStatus.DriverLoaded || newState == AsioStatus.PreInit); break; case AsioStatus.DriverLoaded: System.Diagnostics.Debug.Assert( newState == AsioStatus.DriverNotLoaded || newState == AsioStatus.SampleRateSet); break; case AsioStatus.SampleRateSet: System.Diagnostics.Debug.Assert( newState == AsioStatus.DriverLoaded || newState == AsioStatus.Prepared); break; case AsioStatus.Prepared: System.Diagnostics.Debug.Assert( newState == AsioStatus.SampleRateSet || newState == AsioStatus.Running || newState == AsioStatus.DriverLoaded); break; case AsioStatus.Running: System.Diagnostics.Debug.Assert( newState == AsioStatus.Prepared); break; default: System.Diagnostics.Debug.Assert(false); break; } state = newState; }
private void radioButtonOutFile_Checked(object sender, RoutedEventArgs e) { if (m_asioStatus != AsioStatus.NotReady) { asio.Unsetup(); m_asioStatus = AsioStatus.NotReady; } if (0 <= m_selectedAsioDeviceIdx) { asio.DriverUnload(); m_selectedAsioDeviceIdx = -1; } m_outputMode = OutputMode.WavFile; UpdateUIStatus(); }
private void listBoxAsioDevices_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listBoxAsioDevices.SelectedIndex != m_selectedAsioDeviceIdx) { if (m_asioStatus == AsioStatus.Ready) { asio.Unsetup(); m_asioStatus = AsioStatus.NotReady; } if (0 <= m_selectedAsioDeviceIdx) { asio.DriverUnload(); m_selectedAsioDeviceIdx = -1; } m_selectedAsioDeviceIdx = listBoxAsioDevices.SelectedIndex; bool bRv = asio.DriverLoad(m_selectedAsioDeviceIdx); if (!bRv) { MessageBox.Show(string.Format("エラー: ASIOドライバー{0}のロードに失敗", asio.DriverNameGet(m_selectedAsioDeviceIdx))); return; } int sampleRate = System.Convert.ToInt32(((ListBoxItem)listBoxSampleFreq.SelectedItem).Content); int rv = asio.Setup(sampleRate); if (rv != 0) { MessageBox.Show(string.Format("エラー: サンプルレートの設定に失敗 {0}\n AsioError {1}", sampleRate, rv)); return; } m_asioStatus = AsioStatus.Ready; { int nCh = asio.OutputChannelsNumGet(); if (nCh <= 0) { MessageBox.Show("エラー: 出力チャンネル情報取得に失敗"); return; } listBoxAsioChannels.Items.Clear(); for (int i = 0; i < nCh; ++i) { ListBoxItem item = new ListBoxItem(); item.Content = asio.OutputChannelNameGet(i); listBoxAsioChannels.Items.Add(item); } listBoxAsioChannels.SelectedIndex = 0; } { int nCS = asio.ClockSourceNumGet(); if (nCS <= 0) { MessageBox.Show("エラー: クロックソース情報取得に失敗"); return; } listBoxAsioClockSource.Items.Clear(); for (int i = 0; i < nCS; ++i) { ListBoxItem item = new ListBoxItem(); item.Content = asio.ClockSourceNameGet(i); listBoxAsioClockSource.Items.Add(item); } listBoxAsioClockSource.SelectedIndex = 0; } } }