namespace FDK.メディア.サウンド.WASAPI
{
- public class Sound
+ public class Sound : IDisposable
{
- public long Length
+ public long 長さsample
{
get { return this._SampleSource.Length; }
}
- public long Position
+ public double 長さsec
+ {
+ get { return this.長さsample / ( this.WaveFormat.Channels * this.WaveFormat.SampleRate ); }
+ }
+
+ public long 位置sample
{
get { return this._SampleSource.Position; }
set { this._SampleSource.Position = value; }
}
+ public double 位置sec
+ {
+ get
+ {
+ return this.位置sample / ( this.WaveFormat.Channels * this.WaveFormat.SampleRate );
+ }
+ set
+ {
+ long position = (long) ( value * this.WaveFormat.SampleRate * this.WaveFormat.Channels + 0.5 ); // +0.5 は四捨五入
+ position -= ( position % this.WaveFormat.Channels ); // チャンネル数の倍数にする。
+
+ if( ( 0 > position ) || ( this.長さsample <= position ) )
+ throw new ArgumentOutOfRangeException();
+
+ this.位置sample = position;
+ }
+ }
+
public WaveFormat WaveFormat
{
get { return this._SampleSource.WaveFormat; }
public void Dispose()
{
+ this.Stop();
+
FDK.Utilities.解放する( ref this._SampleSource );
FDK.Utilities.解放する( ref this._WaveSource );
this._MixerRef = null;
int hr = 0;
long デバイス周波数 = 0;
- //デバイス周波数 = audioClock.Pu64Frequency; --> たまにおかしくなるので、使わない。
+ //デバイス周波数 = audioClock.Pu64Frequency; --> Native 系で統一するため、こちらは使わない。
audioClock.GetFrequencyNative( out デバイス周波数 );
long QPC周波数 = FDK.カウンタ.QPCTimer.周波数;