void InitMusic() { if (musicThread != null) { musicOut.SetVolume(game.MusicVolume / 100.0f); return; } int musicCount = 0; for (int i = 0; i < files.Length; i++) { if (Utils.CaselessEnds(files[i], ".ogg")) { musicCount++; } } musicFiles = new string[musicCount]; for (int i = 0, j = 0; i < files.Length; i++) { if (!Utils.CaselessEnds(files[i], ".ogg")) { continue; } musicFiles[j] = files[i]; j++; } disposingMusic = false; musicOut = GetPlatformOut(); musicOut.Create(10); musicThread = MakeThread(DoMusicThread, "ClassicalSharp.DoMusic"); }
void PlayCurrentSound(IAudioOutput[] outputs) { for (int i = 0; i < monoOutputs.Length; i++) { IAudioOutput output = outputs[i]; if (output == null) { output = GetPlatformOut(); output.Create(1, firstSoundOut); if (firstSoundOut == null) { firstSoundOut = output; } outputs[i] = output; } if (!output.DoneRawAsync()) { continue; } try { output.PlayRawAsync(chunk); } catch (InvalidOperationException ex) { HandleSoundError(ex); } return; } }
IAudioOutput MakeSoundOutput(IAudioOutput[] outputs, int i) { IAudioOutput output = GetPlatformOut(); output.Create(1, firstSoundOut); if (firstSoundOut == null) firstSoundOut = output; outputs[i] = output; return output; }
Thread MakeThread(ThreadStart func, ref IAudioOutput output, string name) { output = GetPlatformOut(); output.Create(10); Thread thread = new Thread(func); thread.Name = name; thread.IsBackground = true; thread.Start(); return(thread); }
void PlayCurrentSound(IAudioOutput[] outputs) { for (int i = 0; i < monoOutputs.Length; i++) { IAudioOutput output = outputs[i]; if (output == null) { output = GetPlatformOut(); output.Create(1, firstSoundOut); if (firstSoundOut == null) { firstSoundOut = output; } outputs[i] = output; } if (output.DoneRawAsync()) { output.PlayRawAsync(chunk); return; } } }
void PlayCurrentSound(IAudioOutput[] outputs, float volume) { for (int i = 0; i < outputs.Length; i++) { IAudioOutput output = outputs[i]; if (output == null) { output = GetPlatformOut(); output.Create(1); outputs[i] = output; } if (!output.IsFinished()) { continue; } AudioFormat fmt = output.Format; if (fmt.Channels == 0 || fmt.Equals(format)) { PlaySound(output, volume); return; } } // This time we try to play the sound on all possible devices, // even if it requires the expensive case of recreating a device for (int i = 0; i < outputs.Length; i++) { IAudioOutput output = outputs[i]; if (!output.IsFinished()) { continue; } PlaySound(output, volume); return; } }
Thread MakeThread( ThreadStart func, ref IAudioOutput output, string name ) { output = GetPlatformOut(); output.Create( 5 ); Thread thread = new Thread( func ); thread.Name = name; thread.IsBackground = true; thread.Start(); return thread; }