using System.IO;\r
using System.Runtime.CompilerServices;\r
using System.Threading;\r
-using SlimDX;\r
-using SlimDX.DirectSound;\r
-using SlimDX.Multimedia;\r
+using SharpDX;\r
+using SharpDX.DirectSound;\r
+using SharpDX.Multimedia;\r
using Un4seen.Bass;\r
using Un4seen.BassAsio;\r
using Un4seen.BassWasapi;\r
throw new NotImplementedException();\r
}\r
CSound clone = (CSound) MemberwiseClone(); // これだけだとCY連打が途切れる&タイトルに戻る際にNullRef例外発生\r
- this.DirectSound.DuplicateSoundBuffer( this.Buffer, out clone.Buffer );\r
+ clone.Buffer = this.DirectSound.DuplicateSoundBuffer( this.Buffer );\r
\r
// CSound.listインスタンス.Add( this ); // インスタンスリストに登録。\r
// 本来これを加えるべきだが、Add後Removeできなくなっている。Clone()の仕方の問題であろう。\r
//-----------------\r
try\r
{\r
- using ( var ws = new WaveStream( strファイル名 ) )\r
+ using( var ws = new SoundStream( new FileStream( strファイル名, FileMode.Open ) ) )\r
{\r
- if ( ws.Format.FormatTag != WaveFormatTag.Pcm )\r
+ if( ws.Format.Encoding != WaveFormatEncoding.Pcm )\r
bファイルがWAVかつPCMフォーマットである = false;\r
}\r
}\r
this.strファイル名 = strファイル名;\r
\r
\r
- WaveFormat wfx = new WaveFormat();\r
int nPCMデータの先頭インデックス = 0;\r
// int nPCMサイズbyte = (int) ( xa.xaheader.nSamples * xa.xaheader.nChannels * 2 ); // nBytes = Bass.BASS_ChannelGetLength( this.hBassStream );\r
\r
CWin32.WAVEFORMATEX cw32wfx;\r
tオンメモリ方式でデコードする( strファイル名, out this.byArrWAVファイルイメージ,\r
out nPCMデータの先頭インデックス, out nPCMサイズbyte, out cw32wfx, false );\r
-\r
- wfx.AverageBytesPerSecond = (int) cw32wfx.nAvgBytesPerSec;\r
- wfx.BitsPerSample = (short) cw32wfx.wBitsPerSample;\r
- wfx.BlockAlignment = (short) cw32wfx.nBlockAlign;\r
- wfx.Channels = (short) cw32wfx.nChannels;\r
- wfx.FormatTag = WaveFormatTag.Pcm; // xa.waveformatex.wFormatTag;\r
- wfx.SamplesPerSecond = (int) cw32wfx.nSamplesPerSec;\r
+ WaveFormat wfx = WaveFormat.CreateCustomFormat( WaveFormatEncoding.Pcm, (int) cw32wfx.nSamplesPerSec, (int) cw32wfx.nChannels, (int) cw32wfx.nAvgBytesPerSec, (int) cw32wfx.nBlockAlign, (int) cw32wfx.wBitsPerSample );\r
\r
// セカンダリバッファを作成し、PCMデータを書き込む。\r
tDirectSoundサウンドを作成する_セカンダリバッファの作成とWAVデータ書き込み\r
{\r
long chunkSize = (long) br.ReadUInt32();\r
\r
- var tag = (WaveFormatTag) br.ReadUInt16();\r
+ var tag = (WaveFormatEncoding) br.ReadUInt16();\r
+ var channels = br.ReadInt16();\r
+ var samplesPerSecond = br.ReadInt32();\r
+ var averageBytesPerSecond = br.ReadInt32();\r
+ var blockAlignment = br.ReadInt16();\r
+ var bitsPerSample = br.ReadInt16();\r
\r
- if( tag == WaveFormatTag.Pcm ) wfx = new WaveFormat();\r
- else if( tag == WaveFormatTag.Extensible ) wfx = new SlimDX.Multimedia.WaveFormatExtensible(); // このクラスは WaveFormat を継承している。\r
+ if( tag == WaveFormatEncoding.Pcm )\r
+ {\r
+ wfx = WaveFormat.CreateCustomFormat( tag, samplesPerSecond, channels, averageBytesPerSecond, blockAlignment, bitsPerSample );\r
+ }\r
+ else if( tag == WaveFormatEncoding.Extensible )\r
+ {\r
+ wfx = SharpDX.Multimedia.WaveFormatExtensible.CreateCustomFormat( // このクラスは WaveFormat を継承している。\r
+ tag, samplesPerSecond, channels, averageBytesPerSecond, blockAlignment, bitsPerSample );\r
+ }\r
else\r
throw new InvalidDataException( string.Format( "未対応のWAVEフォーマットタグです。(Tag:{0})", tag.ToString() ) );\r
\r
- wfx.FormatTag = tag;\r
- wfx.Channels = br.ReadInt16();\r
- wfx.SamplesPerSecond = br.ReadInt32();\r
- wfx.AverageBytesPerSecond = br.ReadInt32();\r
- wfx.BlockAlignment = br.ReadInt16();\r
- wfx.BitsPerSample = br.ReadInt16();\r
-\r
long nフォーマットサイズbyte = 16;\r
\r
- if( wfx.FormatTag == WaveFormatTag.Extensible )\r
+ if( wfx.Encoding == WaveFormatEncoding.Extensible )\r
{\r
- br.ReadUInt16(); // 拡張領域サイズbyte\r
- var wfxEx = (SlimDX.Multimedia.WaveFormatExtensible) wfx;\r
- wfxEx.ValidBitsPerSample = br.ReadInt16();\r
+ br.ReadUInt16(); // 拡張領域サイズbyte\r
+ var wfxEx = (SharpDX.Multimedia.WaveFormatExtensible) wfx;\r
+ /*wfxEx.ValidBitsPerSample = */br.ReadInt16(); // 対応するメンバがない?\r
wfxEx.ChannelMask = (Speakers) br.ReadInt32();\r
- wfxEx.SubFormat = new Guid( br.ReadBytes( 16 ) ); // GUID は 16byte (128bit)\r
+ wfxEx.GuidSubFormat = new Guid( br.ReadBytes( 16 ) ); // GUID は 16byte (128bit)\r
\r
nフォーマットサイズbyte += 24;\r
}\r
{\r
// セカンダリバッファを作成し、PCMデータを書き込む。\r
\r
+ this._Format = wfx;\r
+\r
this.Buffer = new SecondarySoundBuffer( DirectSound, new SoundBufferDescription()\r
{\r
- Format = ( wfx.FormatTag == WaveFormatTag.Pcm ) ? wfx : (SlimDX.Multimedia.WaveFormatExtensible) wfx,\r
+ Format = this._Format,\r
Flags = flags,\r
- SizeInBytes = nPCMサイズbyte,\r
+ BufferBytes = nPCMサイズbyte,\r
} );\r
this.Buffer.Write( byArrWAVファイルイメージ, nPCMデータの先頭インデックス, nPCMサイズbyte, 0, LockFlags.None );\r
\r
this.DirectSound = DirectSound;\r
\r
// DTXMania用に追加\r
- this.nオリジナルの周波数 = wfx.SamplesPerSecond;\r
- n総演奏時間ms = (int) ( ( (double) nPCMサイズbyte ) / ( this.Buffer.Format.AverageBytesPerSecond * 0.001 ) );\r
-\r
+ this.nオリジナルの周波数 = wfx.SampleRate;\r
+ n総演奏時間ms = (int) ( ( (double) nPCMサイズbyte ) / ( this._Format.AverageBytesPerSecond * 0.001 ) );\r
\r
// インスタンスリストに登録。\r
-\r
CSound.listインスタンス.Add( this );\r
}\r
\r
{\r
if ( this.eデバイス種別 == ESoundDeviceType.DirectSound )\r
{\r
- return ( ( this.Buffer.Status & BufferStatus.Playing ) != BufferStatus.None );\r
+ return ( ( this.Buffer.Status & (int) BufferStatus.Playing ) != (int) BufferStatus.None );\r
}\r
else\r
{\r
}\r
else if( this.bDirectSoundである )\r
{\r
- this.Buffer.CurrentPlayPosition = 0;\r
+ this.Buffer.CurrentPosition = 0;\r
}\r
}\r
public void t再生位置を変更する( long n位置ms )\r
}\r
else if( this.bDirectSoundである )\r
{\r
- int n位置sample = (int) ( this.Buffer.Format.SamplesPerSecond * n位置ms * 0.001 * _db周波数倍率 * _db再生速度 ); // #30839 2013.2.24 yyagi; add _db周波数倍率 and _db再生速度\r
+ int n位置sample = (int) ( this._Format.SampleRate * n位置ms * 0.001 * _db周波数倍率 * _db再生速度 ); // #30839 2013.2.24 yyagi; add _db周波数倍率 and _db再生速度\r
try\r
{\r
- this.Buffer.CurrentPlayPosition = n位置sample * this.Buffer.Format.BlockAlignment;\r
+ this.Buffer.CurrentPosition = n位置sample * this._Format.BlockAlign;\r
}\r
- catch ( DirectSoundException e )\r
+ catch ( Exception e )\r
{\r
Trace.TraceError( "{0}: Seek error: {1}", Path.GetFileName( this.strファイル名 ), n位置ms, e.Message );\r
}\r
}\r
else if ( this.bDirectSoundである )\r
{\r
- n位置byte = this.Buffer.CurrentPlayPosition;\r
- db位置ms = n位置byte / this.Buffer.Format.SamplesPerSecond / 0.001 / _db周波数倍率 / _db再生速度;\r
+ this.Buffer.GetCurrentPosition( out int pos, out _ );\r
+ n位置byte = (long) pos;\r
+ db位置ms = n位置byte / this._Format.SampleRate / 0.001 / _db周波数倍率 / _db再生速度;\r
}\r
else\r
{\r
private double _db周波数倍率 = 1.0;\r
private double _db再生速度 = 1.0;\r
private bool bIs1倍速再生 = true;\r
+ private WaveFormat _Format;\r
\r
private void tBASSサウンドを作成する( string strファイル名, int hMixer, BASSFlag flags )\r
{\r
//-----------------\r
try\r
{\r
- using ( var ws = new WaveStream( strファイル名 ) )\r
+ using( var ws = new SoundStream( new FileStream( strファイル名, FileMode.Open ) ) )\r
{\r
- if ( ws.Format.FormatTag == (WaveFormatTag) 0x6770 || // Ogg Vorbis Mode 2+\r
- ws.Format.FormatTag == (WaveFormatTag) 0x6771 ) // Ogg Vorbis Mode 3+\r
+ if( ws.Format.Encoding == WaveFormatEncoding.OggVorbisMode2Plus ||\r
+ ws.Format.Encoding == WaveFormatEncoding.OggVorbisMode3Plus )\r
{\r
Trace.TraceInformation( Path.GetFileName( strファイル名 ) + ": RIFF chunked Vorbis. Decode to raw Wave first, to avoid BASS.DLL troubles" );\r
try\r