• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Commit MetaInfo

修订版f6c981f0ff47bc7c8f77d902ec9f69616cc6dccb (tree)
时间2021-10-17 03:30:13
作者yyagi <yyagi.dtxmania@gmai...>
Commiteryyagi

Log Message

#43055 データ単位が8bitのwavファイルを再生するとノイズまみれの再生となる問題を修正。
#43056 mp3/wavファイルの再生でノイズが乗る問題を修正。

更改概述

  • delete: "FDK/\343\202\263\343\203\274\343\203\211/03.\343\202\265\343\202\246\343\203\263\343\203\211/CSound.cs"
  • delete: "FDK/\343\202\263\343\203\274\343\203\211/03.\343\202\265\343\202\246\343\203\263\343\203\211/Cmp3.cs"

差异

--- "a/FDK/\343\202\263\343\203\274\343\203\211/03.\343\202\265\343\202\246\343\203\263\343\203\211/CSound.cs"
+++ "b/FDK/\343\202\263\343\203\274\343\203\211/03.\343\202\265\343\202\246\343\203\263\343\203\211/CSound.cs"
@@ -2172,7 +2172,7 @@ Debug.WriteLine("更に再生に失敗: " + Path.GetFileName(this.strファイ
21722172 bw.Close();
21732173 ms.Close();
21742174
2175- for ( int i = 0; i < bs.Length; i++ )
2175+ for ( int i = 0; i < bs.Length; i++ ) // copying header
21762176 {
21772177 buffer[ i ] = bs[ i ];
21782178 }
--- "a/FDK/\343\202\263\343\203\274\343\203\211/03.\343\202\265\343\202\246\343\203\263\343\203\211/Cmp3.cs"
+++ "b/FDK/\343\202\263\343\203\274\343\203\211/03.\343\202\265\343\202\246\343\203\263\343\203\211/Cmp3.cs"
@@ -27,21 +27,25 @@ namespace FDK
2727 {
2828 BASSError be = Bass.BASS_ErrorGetCode();
2929 Trace.TraceInformation("Cmp3: StreamCreateFile error: " + be.ToString());
30- return 0;
30+ return -1;
3131 }
3232 nTotalPCMSize = Bass.BASS_ChannelGetLength(stream_in);
3333
3434 #region [ Getting WAVEFORMEX info ]
3535 var chinfo = Bass.BASS_ChannelGetInfo(stream_in);
36+ int wBitsPerSample = (chinfo.origres==0)? 16 : chinfo.origres; // for no3, origres might be zero
37+
3638 wfx = new CWin32.WAVEFORMATEX(
3739 (ushort)1, // wFormatTag
3840 (ushort)chinfo.chans, // nChannels
3941 (uint)chinfo.freq, // nSamplesPerSec
40- (uint)(chinfo.freq * 2 * chinfo.chans), // nAvgBytesPerSec
41- (ushort)(2 * chinfo.chans), // nBlockAlign
42- 16, // wBitsPerSample
43- 0 // cbSize
42+ (uint)(chinfo.freq * chinfo.chans * wBitsPerSample / 8 ), // nAvgBytesPerSec == SampleRate(freq) * NumChannels(chans) * BitsPerSample/8
43+ (ushort)(chinfo.chans * wBitsPerSample / 8), // nBlockAlign== NumChannels * BitsPerSample/8
44+ (ushort)( wBitsPerSample ), // wBitsPerSample (8, 16, ...)
45+ (ushort)0 // cbSize
4446 );
47+ Trace.TraceInformation($"chans={chinfo.chans}, freq={chinfo.freq}, chinfo.origres={chinfo.origres}, BitsPerSample={wBitsPerSample}, nAvgBytePerSec={wfx.nAvgBytesPerSec}, nBlockAlign={wfx.nBlockAlign}");
48+ Trace.TraceInformation( $"totalPCMSize={nTotalPCMSize}:{nTotalPCMSize.ToString("x8")}" );
4549 #endregion
4650
4751 //string fn = Path.GetFileName(filename);
@@ -55,8 +59,14 @@ namespace FDK
5559 #region [ decode ]
5660 int LEN = 65536;
5761 byte[] data = new byte[LEN]; // 2 x 16-bit and length in is bytes
62+
63+ for (int i = 0; i < offset; i++ )
64+ {
65+ Dest[ i ] = 0;
66+ }
67+
5868 long len = 0;
59- long p = 0;
69+ long p = offset;
6070 do
6171 {
6272 len = Bass.BASS_ChannelGetData(stream_in, data, LEN);
@@ -64,14 +74,15 @@ namespace FDK
6474 {
6575 BASSError be = Bass.BASS_ErrorGetCode();
6676 Trace.TraceInformation("Cmp3: BASS_ChannelGetData Error: " + be.ToString());
77+ break;
6778 }
68- if (p + len > nTotalPCMSize)
79+ if (p + len > nTotalPCMSize + offset)
6980 {
70- len = nTotalPCMSize - p;
81+ len = nTotalPCMSize - p + offset;
7182 }
7283 Array.Copy(data, 0, Dest, p, len);
7384 p += len;
74- } while (p < nTotalPCMSize);
85+ } while (p < nTotalPCMSize + offset);
7586 #endregion
7687
7788 //SaveWav(filename, Dest);