/// <summary> /// Open MP3 file /// </summary> /// <returns>true if successful</returns> public bool OpenAudioFile(SupportedAudioFormat format) { try { WaveChannel32 inputStream; switch (format) { case SupportedAudioFormat.MP3: ArcaeaSpeedChanger.GlobalVariable.soundParseFormat = nowParseSoundFormat = SupportedAudioFormat.MP3; Mp3FileReader mp3File = new Mp3FileReader(soundFilePath); inputStream = new WaveChannel32(mp3File); break; case SupportedAudioFormat.OGG: ArcaeaSpeedChanger.GlobalVariable.soundParseFormat = nowParseSoundFormat = SupportedAudioFormat.OGG; VorbisWaveReader oggFile = new VorbisWaveReader(soundFilePath); inputStream = new WaveChannel32(oggFile); break; default: return(false); } inputStream.PadWithZeroes = false; // don't pad, otherwise the stream never ends streamProcessor = new WaveStreamProcessor(inputStream); //这个应该是被soundTouch处理过的wav waveOut = new WaveOut() //waveOut应该是用来播放的 { DesiredLatency = 100 }; waveOut.Init(streamProcessor); // inputStream); return(true); } catch (Exception) { // Error in opening file waveOut = null; //return false; throw; } }
private void OpenFileButton_Click(object sender, EventArgs e) { try { OpenFileDialog dialog = new OpenFileDialog { Filter = "arcaea谱面文件(*.aff;*.txt)|*.aff;*.txt" }; if (dialog.ShowDialog() == DialogResult.OK) { sheetUrlLabel.Text = dialog.FileName; this.sheetUrl = dialog.FileName; this.sheetName = dialog.SafeFileName; this.sheetDirectory = this.sheetUrl.Replace(sheetName, ""); if (soundCheckBox.Checked) { OpenFileDialog soundOpenDialog = new OpenFileDialog { Filter = "OGG音频文件(*.ogg)|*.ogg|MP3音频文件(*.mp3)|*.mp3" }; if (soundOpenDialog.ShowDialog() == DialogResult.OK) { switch (soundOpenDialog.FilterIndex) { case 1: nowParseSoundFormat = SupportedAudioFormat.OGG; break; case 2: nowParseSoundFormat = SupportedAudioFormat.MP3; break; } if (!File.Exists(@"SOX\sox.exe") && nowParseSoundFormat == SupportedAudioFormat.OGG) { ShowArcaeaDialog("OGG转换需要sox.exe支持, 请将SOX文件夹放在变速器同一个目录下!"); } else { sheetUrlLabel.Text += "\n" + soundOpenDialog.FileName; this.soundUrl = soundOpenDialog.FileName; this.soundName = soundOpenDialog.SafeFileName; this.soundDirectory = this.soundUrl.Replace(soundName, ""); } } else { this.soundUrl = null; } } } else { this.sheetUrl = null; } } catch (Exception) { AskAuthor(); throw; } }