public SoundPlayer(string filePath, float volume, bool isLoop, SoundType soudType) { if (!File.Exists(filePath)) { this.filePath = filePath; this.volume = volume; this.isLoop = isLoop; this.soundType = soudType; sourceType = SourceType.File; return; } if (soundType == SoundType.BGM) { lock (soundPlayersLock) { foreach (var sp in soundPlayers) { if ((sp.soundType == SoundType.BGM) && (sp.filePath == filePath) && (sp.status == Status.Play)) { // 同じファイルであれば、と切らずそのまま継続する return; } } } } if (coreThread == null) { //rundamIDManager = new Random.RundamIDManager("Sound_", 16); coreThread = new EasyLoopThread(Core, null); } this.filePath = filePath; this.volume = volume; this.isLoop = isLoop; this.soundType = soudType; sourceType = SourceType.File; _PlayCore(); if (soundType == SoundType.BGM) { lock (soundPlayersLock) { foreach (var sp in soundPlayers) { if (sp.soundType == SoundType.BGM) { // Todo : 停止しているだけで、Disposeしてない~ sp.Stop(); } } } } lock (soundPlayersLock) { soundPlayers.Add(this); } }
private void Form1_Load(object sender, EventArgs e) { this.FormClosed += Form1_FormClosed; this.FormBorderStyle = FormBorderStyle.FixedSingle; mainFileWriteThread = new EasyLoopThread(mainFileWriteThreadAction, null, 100); script = new Emugen.Script.Script <ConfigScriptAPI>(configFilePath, new ConfigScriptAPI()); script.Run(); script.Run(); if (script.api.OutputDirectoryPath != "") { targetRootDirectory = textBox1.Text = script.api.OutputDirectoryPath; } else { targetRootDirectory = textBox1.Text = System.IO.Directory.GetCurrentDirectory(); } //WaveInEvent.DeviceCount、WaveInEvent.GetCapabilities for (var i = 0; i < WaveInEvent.DeviceCount; i++) { var p = WaveInEvent.GetCapabilities(i); comboBox1.Items.Add(p.ProductName); if (script.api.DeviceName == p.ProductName) { inputDeviceNo = i; } } comboBox1.SelectedIndex = inputDeviceNo; checkBox1.Checked = script.api.IsMonaural; comboBox2.Items.Add("mp3"); comboBox2.Items.Add("wav"); if (script.api.SaveType == "mp3") { comboBox2.SelectedIndex = 0; } else { comboBox2.SelectedIndex = 1; } { var btn = new VoiceRecoder.EmugenWFUI.Button(this, 5, 5, 160, 60, "録音開始", 24); btn.Click = () => { if (isStart) { btnStop_Click(); isStart = !isStart; btn.Text = "録音開始"; } else { btnStart(); isStart = !isStart; btn.Text = "録音終了"; } }; } { var btn = new VoiceRecoder.EmugenWFUI.Button(this, 5, 70, 160, 40, "フォルダを開く", 14); btn.Click = () => { var dir = CreateTargetDirectory(); System.Diagnostics.Process.Start(dir); }; } }