Revision | 3fac3705623c715f196f1e644a9debbb8ca58bc1 (tree) |
---|---|
Zeit | 2013-04-01 00:39:46 |
Autor | yyagi <yyagi@16f4...> |
Commiter | yyagi |
#31076 TimeStretch=ON時の動作を高速化。(hBassStreamをプロパティとして扱うのを止めた。少し設計が汚くなったが、やむなし。)
#xxxxx バージョン情報を変更。
git-svn-id: http://svn.osdn.jp/svnroot/dtxmania/trunk@547 16f42ceb-6dc6-49c8-ba94-f2d53467949d
@@ -20,7 +20,7 @@ namespace DTXMania | ||
20 | 20 | { |
21 | 21 | // プロパティ |
22 | 22 | #region [ properties ] |
23 | - public static readonly string VERSION = "097(130401)"; | |
23 | + public static readonly string VERSION = "097(130405)"; | |
24 | 24 | public static readonly string SLIMDXDLL = "c_net20x86_Jun2010"; |
25 | 25 | public static readonly string D3DXDLL = "d3dx9_43.dll"; // June 2010 |
26 | 26 | //public static readonly string D3DXDLL = "d3dx9_42.dll"; // February 2010 |
@@ -393,6 +393,15 @@ namespace FDK | ||
393 | 393 | bIs1倍速再生 = ( _db再生速度 == 1.000f ); |
394 | 394 | if ( bBASSサウンドである ) |
395 | 395 | { |
396 | + if ( _hTempoStream != 0 && !this.bIs1倍速再生 ) // 再生速度がx1.000のときは、TempoStreamを用いないようにして高速化する | |
397 | + { | |
398 | + this.hBassStream = _hTempoStream; | |
399 | + } | |
400 | + else | |
401 | + { | |
402 | + this.hBassStream = _hBassStream; | |
403 | + } | |
404 | + | |
396 | 405 | if ( CSound管理.bIsTimeStretch ) |
397 | 406 | { |
398 | 407 | Bass.BASS_ChannelSetAttribute( this.hBassStream, BASSAttribute.BASS_ATTRIB_TEMPO, (float) ( db再生速度 * 100 - 100 ) ); |
@@ -1117,9 +1126,10 @@ Debug.WriteLine("更に再生に失敗: " + Path.GetFileName(this.strファイ | ||
1117 | 1126 | BassMix.BASS_Mixer_ChannelRemove( this._hTempoStream ); |
1118 | 1127 | Bass.BASS_StreamFree( this._hTempoStream ); |
1119 | 1128 | } |
1120 | - BassMix.BASS_Mixer_ChannelRemove( this.hBassStream ); | |
1121 | - Bass.BASS_StreamFree( this.hBassStream ); | |
1129 | + BassMix.BASS_Mixer_ChannelRemove( this._hBassStream ); | |
1130 | + Bass.BASS_StreamFree( this._hBassStream ); | |
1122 | 1131 | this.hBassStream = -1; |
1132 | + this._hBassStream = -1; | |
1123 | 1133 | this._hTempoStream = 0; |
1124 | 1134 | //----------------- |
1125 | 1135 | #endregion |
@@ -1208,24 +1218,27 @@ Debug.WriteLine("更に再生に失敗: " + Path.GetFileName(this.strファイ | ||
1208 | 1218 | protected GCHandle hGC; |
1209 | 1219 | protected int _hTempoStream = 0; |
1210 | 1220 | protected int _hBassStream = -1; // ASIO, WASAPI 用 |
1211 | - protected int hBassStream | |
1212 | - { | |
1213 | - get | |
1214 | - { | |
1215 | - if ( _hTempoStream != 0 && !this.bIs1倍速再生 ) // 再生速度がx1.000のときは、TempoStreamを用いないようにして高速化する | |
1216 | - { | |
1217 | - return _hTempoStream; | |
1218 | - } | |
1219 | - else | |
1220 | - { | |
1221 | - return _hBassStream; | |
1222 | - } | |
1223 | - } | |
1224 | - set | |
1225 | - { | |
1226 | - _hBassStream = value; | |
1227 | - } | |
1228 | - } | |
1221 | + protected int hBassStream = 0; // #31076 2013.4.1 yyagi; プロパティとして実装すると動作が低速になったため、 | |
1222 | + // tBASSサウンドを作成する・ストリーム生成後の共通処理()のタイミングと、 | |
1223 | + // 再生速度を変更したタイミングでのみ、 | |
1224 | + // hBassStreamを更新するようにした。 | |
1225 | + //{ | |
1226 | + // get | |
1227 | + // { | |
1228 | + // if ( _hTempoStream != 0 && !this.bIs1倍速再生 ) // 再生速度がx1.000のときは、TempoStreamを用いないようにして高速化する | |
1229 | + // { | |
1230 | + // return _hTempoStream; | |
1231 | + // } | |
1232 | + // else | |
1233 | + // { | |
1234 | + // return _hBassStream; | |
1235 | + // } | |
1236 | + // } | |
1237 | + // set | |
1238 | + // { | |
1239 | + // _hBassStream = value; | |
1240 | + // } | |
1241 | + //} | |
1229 | 1242 | protected SoundBuffer Buffer = null; // DirectSound 用 |
1230 | 1243 | protected DirectSound DirectSound; |
1231 | 1244 | protected int hMixer = -1; // 設計壊してゴメン Mixerに後で登録するときに使う |
@@ -1273,11 +1286,11 @@ Debug.WriteLine("更に再生に失敗: " + Path.GetFileName(this.strファイ | ||
1273 | 1286 | |
1274 | 1287 | // BASSファイルストリームを作成。 |
1275 | 1288 | |
1276 | - this.hBassStream = Bass.BASS_StreamCreateFile( strファイル名, 0, 0, flags ); | |
1277 | - if( this.hBassStream == 0 ) | |
1289 | + this._hBassStream = Bass.BASS_StreamCreateFile( strファイル名, 0, 0, flags ); | |
1290 | + if( this._hBassStream == 0 ) | |
1278 | 1291 | throw new Exception( string.Format( "サウンドストリームの生成に失敗しました。(BASS_StreamCreateFile)[{0}]", Bass.BASS_ErrorGetCode().ToString() ) ); |
1279 | 1292 | |
1280 | - nBytes = Bass.BASS_ChannelGetLength( this.hBassStream ); | |
1293 | + nBytes = Bass.BASS_ChannelGetLength( this._hBassStream ); | |
1281 | 1294 | |
1282 | 1295 | tBASSサウンドを作成する・ストリーム生成後の共通処理( hMixer ); |
1283 | 1296 | } |
@@ -1290,11 +1303,11 @@ Debug.WriteLine("更に再生に失敗: " + Path.GetFileName(this.strファイ | ||
1290 | 1303 | |
1291 | 1304 | // BASSファイルストリームを作成。 |
1292 | 1305 | |
1293 | - this.hBassStream = Bass.BASS_StreamCreateFile( hGC.AddrOfPinnedObject(), 0, byArrWAVファイルイメージ.Length, flags ); | |
1294 | - if ( this.hBassStream == 0 ) | |
1306 | + this._hBassStream = Bass.BASS_StreamCreateFile( hGC.AddrOfPinnedObject(), 0, byArrWAVファイルイメージ.Length, flags ); | |
1307 | + if ( this._hBassStream == 0 ) | |
1295 | 1308 | throw new Exception( string.Format( "サウンドストリームの生成に失敗しました。(BASS_StreamCreateFile)[{0}]", Bass.BASS_ErrorGetCode().ToString() ) ); |
1296 | 1309 | |
1297 | - nBytes = Bass.BASS_ChannelGetLength( this.hBassStream ); | |
1310 | + nBytes = Bass.BASS_ChannelGetLength( this._hBassStream ); | |
1298 | 1311 | |
1299 | 1312 | tBASSサウンドを作成する・ストリーム生成後の共通処理( hMixer ); |
1300 | 1313 | } |
@@ -1319,8 +1332,8 @@ Debug.WriteLine("更に再生に失敗: " + Path.GetFileName(this.strファイ | ||
1319 | 1332 | // BASSファイルストリームを作成。 |
1320 | 1333 | |
1321 | 1334 | //this.hBassStream = Bass.BASS_StreamCreate( xa.xaheader.nSamplesPerSec, xa.xaheader.nChannels, BASSFlag.BASS_STREAM_DECODE, _myStreamCreate, IntPtr.Zero ); |
1322 | - this.hBassStream = Bass.BASS_StreamCreate( (int) wfx.nSamplesPerSec, (int) wfx.nChannels, BASSFlag.BASS_STREAM_DECODE, _cbStreamXA, IntPtr.Zero ); | |
1323 | - if ( this.hBassStream == 0 ) | |
1335 | + this._hBassStream = Bass.BASS_StreamCreate( (int) wfx.nSamplesPerSec, (int) wfx.nChannels, BASSFlag.BASS_STREAM_DECODE, _cbStreamXA, IntPtr.Zero ); | |
1336 | + if ( this._hBassStream == 0 ) | |
1324 | 1337 | { |
1325 | 1338 | hGC.Free(); |
1326 | 1339 | throw new Exception( string.Format( "サウンドストリームの生成に失敗しました。(BASS_SampleCreate)[{0}]", Bass.BASS_ErrorGetCode().ToString() ) ); |
@@ -1334,25 +1347,11 @@ Debug.WriteLine("更に再生に失敗: " + Path.GetFileName(this.strファイ | ||
1334 | 1347 | { |
1335 | 1348 | CSound管理.nStreams++; |
1336 | 1349 | |
1337 | - // ミキサーにBASSファイルストリームを追加。 | |
1338 | - | |
1339 | - //if ( !BassMix.BASS_Mixer_StreamAddChannel( hMixer, this.hBassStream, BASSFlag.BASS_SPEAKER_FRONT | BASSFlag.BASS_MIXER_PAUSE | BASSFlag.BASS_MIXER_NORAMPIN ) ) | |
1340 | - //// if ( !tBASSサウンドをミキサーに追加する() ) | |
1341 | - //{ | |
1342 | - // hGC.Free(); | |
1343 | - // throw new Exception( string.Format( "サウンドストリームの生成に失敗しました。(BASS_Mixer_StreamAddChannel)[{0}]", Bass.BASS_ErrorGetCode().ToString() ) ); | |
1344 | - //} | |
1345 | - //CSound管理.nStreams++; | |
1346 | - | |
1347 | - // _cbEndofStream = new SYNCPROC( CallbackEndofStream ); | |
1348 | - // Bass.BASS_ChannelSetSync( hBassStream, BASSSync.BASS_SYNC_END |BASSSync.BASS_SYNC_MIXTIME, 0, _cbEndofStream, IntPtr.Zero ); | |
1349 | - | |
1350 | - | |
1351 | 1350 | // 個々のストリームの出力をテンポ変更のストリームに入力する。テンポ変更ストリームの出力を、Mixerに出力する。 |
1352 | 1351 | |
1353 | - if ( CSound管理.bIsTimeStretch ) | |
1352 | +// if ( CSound管理.bIsTimeStretch ) // TimeStretchのON/OFFに関わりなく、テンポ変更のストリームを生成する。後からON/OFF切り替え可能とするため。 | |
1354 | 1353 | { |
1355 | - this._hTempoStream = BassFx.BASS_FX_TempoCreate( this.hBassStream, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_FX_FREESOURCE ); | |
1354 | + this._hTempoStream = BassFx.BASS_FX_TempoCreate( this._hBassStream, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_FX_FREESOURCE ); | |
1356 | 1355 | if ( this._hTempoStream == 0 ) |
1357 | 1356 | { |
1358 | 1357 | hGC.Free(); |
@@ -1360,22 +1359,30 @@ Debug.WriteLine("更に再生に失敗: " + Path.GetFileName(this.strファイ | ||
1360 | 1359 | } |
1361 | 1360 | else |
1362 | 1361 | { |
1363 | - Bass.BASS_ChannelSetAttribute( this.hBassStream, BASSAttribute.BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO, 1f ); // 高速化(音の品質は少し落ちる) | |
1362 | + Bass.BASS_ChannelSetAttribute( this._hTempoStream, BASSAttribute.BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO, 1f ); // 高速化(音の品質は少し落ちる) | |
1364 | 1363 | } |
1365 | 1364 | } |
1366 | 1365 | |
1366 | + if ( _hTempoStream != 0 && !this.bIs1倍速再生 ) // 再生速度がx1.000のときは、TempoStreamを用いないようにして高速化する | |
1367 | + { | |
1368 | + this.hBassStream = _hTempoStream; | |
1369 | + } | |
1370 | + else | |
1371 | + { | |
1372 | + this.hBassStream = _hBassStream; | |
1373 | + } | |
1367 | 1374 | |
1368 | 1375 | // インスタンスリストに登録。 |
1369 | 1376 | |
1370 | 1377 | CSound.listインスタンス.Add( this ); |
1371 | 1378 | |
1372 | 1379 | // n総演奏時間の取得; DTXMania用に追加。 |
1373 | - double seconds = Bass.BASS_ChannelBytes2Seconds( this.hBassStream, nBytes ); | |
1380 | + double seconds = Bass.BASS_ChannelBytes2Seconds( this._hBassStream, nBytes ); | |
1374 | 1381 | this.n総演奏時間ms = (int) ( seconds * 1000 ); |
1375 | 1382 | this.pos = 0; |
1376 | 1383 | this.hMixer = hMixer; |
1377 | 1384 | float freq = 0.0f; |
1378 | - if ( !Bass.BASS_ChannelGetAttribute( this.hBassStream, BASSAttribute.BASS_ATTRIB_FREQ, ref freq ) ) | |
1385 | + if ( !Bass.BASS_ChannelGetAttribute( this._hBassStream, BASSAttribute.BASS_ATTRIB_FREQ, ref freq ) ) | |
1379 | 1386 | { |
1380 | 1387 | hGC.Free(); |
1381 | 1388 | throw new Exception( string.Format( "サウンドストリームの周波数取得に失敗しました。(BASS_ChannelGetAttribute)[{0}]", Bass.BASS_ErrorGetCode().ToString() ) ); |