public static void t現在のユーザConfigに従ってサウンドデバイスとすべての既存サウンドを再構築する() { #region [ すでにサウンドデバイスと演奏タイマが構築されていれば解放する。] //----------------- if (SoundDevice != null) { // すでに生成済みのサウンドがあれば初期状態に戻す。 CSound.tすべてのサウンドを初期状態に戻す(); // リソースは解放するが、CSoundのインスタンスは残す。 // サウンドデバイスと演奏タイマを解放する。 CCommon.tDispose(SoundDevice); SoundDevice = null; CCommon.tDispose(ref rc演奏用タイマ); // Global.SoundDevice を解放した後に解放すること。(Global.SoundDevice で参照されているため) } //----------------- #endregion #region [ 新しいサウンドデバイスを構築する。] //----------------- switch (SoundDeviceType) { case ESoundDeviceType.ExclusiveWASAPI: SoundDevice = new CSoundDeviceWASAPI(CSoundDeviceWASAPI.Eデバイスモード.Exclusive, SoundDelayExclusiveWASAPI, SoundUpdatePeriodExclusiveWASAPI); break; case ESoundDeviceType.SharedWASAPI: SoundDevice = new CSoundDeviceWASAPI(CSoundDeviceWASAPI.Eデバイスモード.Shared, SoundDelaySharedWASAPI, SoundUpdatePeriodSharedWASAPI); break; case ESoundDeviceType.ASIO: SoundDevice = new CSoundDeviceASIO(SoundDelayASIO, ASIODevice); break; case ESoundDeviceType.BASS: SoundDevice = new CSoundDeviceBASS(SoundUpdatePeriodBASS, SoundDelayBASS); break; case ESoundDeviceType.OpenAL: SoundDevice = new CSoundDeviceOpenAL(SoundDelayOpenAL, bUseOSTimer); break; default: throw new Exception(string.Format("未対応の SoundDeviceType です。[{0}]", SoundDeviceType.ToString())); } //----------------- #endregion #region [ 新しい演奏タイマを構築する。] //----------------- rc演奏用タイマ = new CSoundTimer(SoundDevice); //----------------- #endregion SoundDevice.nMasterVolume = _nMasterVolume; // サウンドデバイスに対して、マスターボリュームを再設定する CSound.tすべてのサウンドを再構築する(SoundDevice); // すでに生成済みのサウンドがあれば作り直す。 }
private void Find(SoundDeviceType type) { switch (type) { case SoundDeviceType.Default: this._selectedDevice = 0; break; case SoundDeviceType.Microphone: this._selectedDevice = FindMicrophone(); break; } }
public CSound tCreateSound(string filename, ESoundGroup soundGroup) { if (!File.Exists(filename)) { Trace.TraceWarning($"[i18n] File does not exist: {filename}"); return(null); } if (SoundDeviceType == ESoundDeviceType.Unknown) { throw new Exception(string.Format("未対応の SoundDeviceType です。[{0}]", SoundDeviceType.ToString())); } return(SoundDevice.tCreateSound(filename, soundGroup)); }
/// <summary> /// Create a new sound recorder. /// </summary> /// <param name="type">Sound capture device.</param> /// <param name="rate">Desired sample rate.</param> /// <param name="size">Desired sample size.</param> /// <param name="channels">Desired channels to use.</param> public SoundRecorder(SoundDeviceType type, SampleRate rate, SampleSize size, short channels) { this._desiredDeviceType = type; this._devices = new CaptureDevicesCollection(); if (this._devices == null || this._devices.Count < 1) { throw new InvalidOperationException("No sound capture devices detected."); } this.Find(type); InitDirectSound(); this._recorderFormat = new SoundFormat(this._applicationDevice, rate, size, channels); }
/// <summary> /// Get the GUID for the specified sound device type. /// </summary> /// <param name="type">Sound capture device type to select.</param> /// <returns>GUID of selected sound device type.</returns> private Guid Select(SoundDeviceType type) { Find(type); return(this._devices[this._selectedDevice].DriverGuid); }