OSDN Git Service

#24820 XA対応を試みるも、System.ExecutionEngineExceptionが発生しているコード。
authoryyagi <yyagi@16f42ceb-6dc6-49c8-ba94-f2d53467949d>
Sat, 22 Dec 2012 12:12:45 +0000 (12:12 +0000)
committeryyagi <yyagi@16f42ceb-6dc6-49c8-ba94-f2d53467949d>
Sat, 22 Dec 2012 12:12:45 +0000 (12:12 +0000)
git-svn-id: http://svn.osdn.jp/svnroot/dtxmania/branches/120724(DTXMania%20with%20%2324820)@466 16f42ceb-6dc6-49c8-ba94-f2d53467949d

DTXManiaプロジェクト/コード/全体/CDTXMania.cs
FDK17プロジェクト/FDK19.csproj
FDK17プロジェクト/コード/03.サウンド/CSound.cs
実行時フォルダ/DTXManiaGR.exe
実行時フォルダ/FDK.dll

index 5c2045c..2f4374a 100644 (file)
@@ -1802,6 +1802,12 @@ for (int i = 0; i < 3; i++) {
 \r
                        Trace.TraceInformation( "アプリケーションの初期化を完了しました。" );\r
 \r
+                       \r
+                       byte[] buf;\r
+                       Cxa.XAHEADER xah;\r
+                       Cxa.XASTREAMHEADER xash;\r
+                       Cxa.Decode( @"bass1.xa", out xah, out xash, out buf );\r
+                       \r
                        #region [ 最初のステージの起動 ]\r
                        //---------------------\r
                        Trace.TraceInformation( "----------------------" );\r
index b8f9715..b7fbe38 100644 (file)
     <Compile Include="コード\03.サウンド\CSoundDeviceDirectSound.cs" />\r
     <Compile Include="コード\03.サウンド\CSoundDeviceWASAPI.cs" />\r
     <Compile Include="コード\03.サウンド\CSoundTimer.cs" />\r
+    <Compile Include="コード\03.サウンド\Cxa.cs" />\r
     <Compile Include="コード\03.サウンド\ESoundDeviceType.cs" />\r
     <Compile Include="コード\03.サウンド\ISoundDevice.cs" />\r
     <Compile Include="コード\04.グラフィック\BitmapUtil.cs" />\r
index 6813a2a..51bbce9 100644 (file)
@@ -163,7 +163,7 @@ namespace FDK
                }\r
                public CSound tサウンドを生成する( string filename )\r
                {\r
-Debug.WriteLine( "★★tサウンドを生成する()" + SoundDevice.e出力デバイス + " " + filename );\r
+Debug.WriteLine( "★★tサウンドを生成する()" + SoundDevice.e出力デバイス + " " + Path.GetFileName( filename ) );\r
                        if ( SoundDeviceType == ESoundDeviceType.Unknown )\r
                        {\r
                                throw new Exception( string.Format( "未対応の SoundDeviceType です。[{0}]", SoundDeviceType.ToString() ) );\r
@@ -627,15 +627,6 @@ Debug.WriteLine( "★★tサウンドを生成する()" + SoundDevice.e出力デ
                        if( this.bBASSサウンドである )\r
                        {\r
 Debug.WriteLine( "再生中?: " +  System.IO.Path.GetFileName(this.strファイル名) + " status=" + BassMix.BASS_Mixer_ChannelIsActive( this.hBassStream ) + " current=" + BassMix.BASS_Mixer_ChannelGetPosition( this.hBassStream ) + " nBytes=" + nBytes );\r
-\r
-                               //if ( ( BassMix.BASS_Mixer_ChannelIsActive( this.hBassStream ) == BASSActive.BASS_ACTIVE_PLAYING ) &&\r
-                               //     ( BassMix.BASS_Mixer_ChannelGetPosition( this.hBassStream ) >= nBytes )\r
-                               //     )\r
-//                             if ( b再生中 )\r
-//                             {\r
-//                                     BassMix.BASS_Mixer_ChannelPause( this.hBassStream );    // 再生中だと多重再生不可。とりあえずPAUSEしてrewindして再生しておく。後日多重再生対応する。\r
-//                             }\r
-//                             BassMix.BASS_Mixer_ChannelSetPosition( this.hBassStream, 0 );\r
                                BassMix.BASS_Mixer_ChannelPlay( this.hBassStream );\r
                        }\r
                        else if( this.bDirectSoundである )\r
@@ -799,7 +790,7 @@ Debug.WriteLine( "停止: " + System.IO.Path.GetFileName( this.strファイル
                protected E作成方法 e作成方法 = E作成方法.Unknown;\r
                protected ESoundDeviceType eデバイス種別 = ESoundDeviceType.Unknown;\r
                protected string strファイル名 = null;\r
-               protected byte[] byArrWAVファイルイメージ = null;\r
+               protected byte[] byArrWAVファイルイメージ = null;       // WAVファイルイメージ、もしくはchunkのDATA部のみ\r
                protected GCHandle hGC;\r
                protected int hBassStream = -1;                                 // ASIO, WASAPI 用\r
                protected SecondarySoundBuffer Buffer = null;   // DirectSound 用\r
@@ -830,6 +821,12 @@ Debug.WriteLine( "停止: " + System.IO.Path.GetFileName( this.strファイル
 \r
                private void tBASSサウンドを作成する( string strファイル名, int hMixer, BASSFlag flags )\r
                {\r
+                       if ( Path.GetExtension( strファイル名 ) == ".xa" )\r
+                       {\r
+                               tBASSサウンドを作成するXA( strファイル名, hMixer, flags );\r
+                               return;\r
+                       }\r
+\r
                        this.e作成方法 = E作成方法.ファイルから;\r
                        this.strファイル名 = strファイル名;\r
 \r
@@ -885,6 +882,63 @@ Debug.WriteLine( "停止: " + System.IO.Path.GetFileName( this.strファイル
                        double seconds = Bass.BASS_ChannelBytes2Seconds( this.hBassStream, nBytes );\r
                        this.n総演奏時間ms = (int) ( seconds * 1000 );\r
                }\r
+               private void tBASSサウンドを作成するXA( string strファイル名, int hMixer, BASSFlag flags )\r
+               {\r
+                       byte[] buf;\r
+                       Cxa.XAHEADER xah;\r
+                       Cxa.XASTREAMHEADER xash;\r
+                       Debug.WriteLine( "xaデコード開始: " + Path.GetFileName( strファイル名 ) );\r
+                       Cxa.Decode( strファイル名, out xah, out xash, out buf );\r
+\r
+                       this.e作成方法 = E作成方法.WAVファイルイメージから;\r
+                       this.byArrWAVファイルイメージ = buf;\r
+                       this.hGC = GCHandle.Alloc( byArrWAVファイルイメージ, GCHandleType.Pinned );             // byte[] をピン留め\r
+\r
+                       // BASSファイルストリームを作成。\r
+                       //xah.id = br.ReadUInt32();\r
+                       //xah.nDataLen = br.ReadUInt32();\r
+                       //xah.nSamples = br.ReadUInt32();\r
+                       //xah.nSamplesPerSec = br.ReadUInt16();\r
+                       //xah.nBits = br.ReadByte();\r
+                       //xah.nChannels = br.ReadByte();\r
+                       //xah.nLoopPtr = br.ReadUInt32();\r
+                       //            Debug.WriteLine( "**WAVEFORMATEX**" );\r
+                       //Debug.WriteLine( "wFormatTag=      " + wfx.wFormatTag.ToString("X4") );\r
+                       //Debug.WriteLine( "nChannels =      " + wfx.nChannels.ToString( "X4" ) );\r
+                       //Debug.WriteLine( "nSamplesPerSec=  " + wfx.nSamplesPerSec.ToString( "X8" ) );\r
+                       //Debug.WriteLine( "nAvgBytesPerSec= " + wfx.nAvgBytesPerSec.ToString( "X8" ) );\r
+                       //Debug.WriteLine( "nBlockAlign=     " + wfx.nBlockAlign.ToString( "X4" ) );\r
+                       //Debug.WriteLine( "wBitsPerSample=  " + wfx.wBitsPerSample.ToString( "X4" ) );\r
+                       //Debug.WriteLine( "cbSize=          " + wfx.cbSize.ToString( "X4" ) );\r
+                               //xash.pSrc = pXaBuf;\r
+                               //xash.nSrcLen = xah.nDataLen;\r
+                               //xash.nSrcUsed = 0;\r
+                               //xash.pDst = pWavBuf;\r
+                               //xash.nDstLen = dlen2;\r
+                               //xash.nDstUsed = 0;\r
+                               //xaDecodeConvert( hxas, ref xash );\r
+                       this.hBassStream = Bass.BASS_SampleCreate( (int)xash.nDstLen, xah.nSamplesPerSec, xah.nChannels, 1, flags );\r
+                       if ( this.hBassStream == 0 )\r
+                               throw new Exception( "サウンドストリームの生成に失敗しました。(BASS_SampleCreate)" );\r
+                       bool b = Bass.BASS_SampleSetData( this.hBassStream, buf );\r
+                       if ( !b )\r
+                               throw new Exception( "サウンドストリームの生成に失敗しました。(BASS_SampleSetData)" );\r
+\r
+\r
+                       // ミキサーにBASSファイルストリームを追加。\r
+\r
+                       BassMix.BASS_Mixer_StreamAddChannel( hMixer, this.hBassStream, BASSFlag.BASS_SPEAKER_FRONT | BASSFlag.BASS_MIXER_PAUSE | BASSFlag.BASS_MIXER_NORAMPIN );\r
+                       //                      BassMix.BASS_Mixer_ChannelPause( this.hBassStream );    // 追加すると勝手に再生(ミキサへの出力)が始まるので即停止。\r
+\r
+                       // インスタンスリストに登録。\r
+\r
+                       CSound.listインスタンス.Add( this );\r
+\r
+                       // nBytesとn総演奏時間の取得; DTXMania用に追加。\r
+                       nBytes = Bass.BASS_ChannelGetLength( this.hBassStream );\r
+                       double seconds = Bass.BASS_ChannelBytes2Seconds( this.hBassStream, nBytes );\r
+                       this.n総演奏時間ms = (int) ( seconds * 1000 );\r
+               }\r
                //-----------------\r
                #endregion\r
        }\r
index ab618fd..726b967 100644 (file)
Binary files a/実行時フォルダ/DTXManiaGR.exe and b/実行時フォルダ/DTXManiaGR.exe differ
index e487e65..49fa08d 100644 (file)
Binary files a/実行時フォルダ/FDK.dll and b/実行時フォルダ/FDK.dll differ