修订版 | 15ced175e0578d4219008381b15299d47da23c89 (tree) |
---|---|
时间 | 2023-03-24 01:46:20 |
作者 | yyagi <yyagi.dtxmania@gmai...> |
Commiter | yyagi |
#47668 DTXC内で扱う分解能を下辺にするための布石。
@@ -116,6 +116,7 @@ | ||
116 | 116 | </ItemGroup> |
117 | 117 | <ItemGroup> |
118 | 118 | <Compile Include="コード\00.全体\AppSetting.cs" /> |
119 | + <Compile Include="コード\05.譜面\CWholeNoteDivision.cs" /> | |
119 | 120 | <Compile Include="コード\06.汎用\CDialog.cs"> |
120 | 121 | <SubType>Form</SubType> |
121 | 122 | </Compile> |
@@ -533,7 +533,7 @@ namespace DTXCreator | ||
533 | 533 | } |
534 | 534 | #endregion |
535 | 535 | //Debug.WriteLine( "入力: n小節番号=" + n小節番号 + ", nGrid=" + nGrid + ", f値=" + f値 + ", strParam=" + strParams[i] ); |
536 | - this.dicBEATチップf値.Add( n小節番号 * 192 + nGrid, (float) f値 ); | |
536 | + this.dicBEATチップf値.Add( n小節番号 * CWholeNoteDivision.n分解能 + nGrid, (float) f値 ); | |
537 | 537 | |
538 | 538 | return true; |
539 | 539 | } |
@@ -1437,7 +1437,7 @@ namespace DTXCreator | ||
1437 | 1437 | cチップ.b裏 = flag; |
1438 | 1438 | float f; |
1439 | 1439 | if ( ( nCh == 0xF8 || nCh == 0xF3 ) && // BEATチップの場合 |
1440 | - dicBEATチップf値.TryGetValue( nBar * 192 + (i * 192 / nChips ), out f ) ) | |
1440 | + dicBEATチップf値.TryGetValue( nBar * CWholeNoteDivision.n分解能 + (i * CWholeNoteDivision.n分解能 / nChips ), out f ) ) | |
1441 | 1441 | { |
1442 | 1442 | cチップ.f値_浮動小数 = f; |
1443 | 1443 | //Debug.WriteLine( "f値: nBar=" + nBar + ", f値=" + f ); |
@@ -1206,8 +1206,8 @@ namespace DTXCreator | ||
1206 | 1206 | } |
1207 | 1207 | #endregion |
1208 | 1208 | |
1209 | - int n旧Grid数 = (int) ( c小節.f小節長倍率 * 192 + 0.5 ); | |
1210 | - int n新Grid数 = (int) ( dlg.f倍率 * 192 + 0.5 ); | |
1209 | + int n旧Grid数 = (int) ( c小節.f小節長倍率 * CWholeNoteDivision.n分解能 + 0.5 ); | |
1210 | + int n新Grid数 = (int) ( dlg.f倍率 * CWholeNoteDivision.n分解能 + 0.5 ); | |
1211 | 1211 | int nGrid増減 = n旧Grid数 - n新Grid数; |
1212 | 1212 | |
1213 | 1213 | this.t小節長を変更する_小節単位( n小節番号, dlg.f倍率 ); |
@@ -5431,7 +5431,7 @@ namespace DTXCreator | ||
5431 | 5431 | } |
5432 | 5432 | private void toolStripComboBox譜面拡大率_SelectedIndexChanged( object sender, EventArgs e ) |
5433 | 5433 | { |
5434 | - C小節.n基準の高さdot = 192 * ( this.toolStripComboBox譜面拡大率.SelectedIndex + 1 ); | |
5434 | + C小節.n基準の高さdot = CWholeNoteDivision.n分解能_表示用 * ( this.toolStripComboBox譜面拡大率.SelectedIndex + 1 ); | |
5435 | 5435 | |
5436 | 5436 | this.pictureBox譜面パネル.Refresh(); |
5437 | 5437 | } |
@@ -5642,11 +5642,11 @@ namespace DTXCreator | ||
5642 | 5642 | // float f小節長倍率 = 1.0f; |
5643 | 5643 | C小節 c小節_0小節目 = this.mgr譜面管理者.dic小節[ nBGMチップの小節番号 ]; |
5644 | 5644 | Cチップ cチップBGM = c小節_0小節目.listチップ[ nBGMチップのindex ]; |
5645 | - nBGM位置grid = (int) ( 192f * c小節_0小節目.f小節長倍率 * listBeatPositions[ n1拍目のBeatPositionIndex ].fBeatTime / ( ( 60 * 4 ) / tempo ) + 0.5 ); | |
5645 | + nBGM位置grid = (int) ( CWholeNoteDivision.n分解能 * c小節_0小節目.f小節長倍率 * listBeatPositions[ n1拍目のBeatPositionIndex ].fBeatTime / ( ( 60 * 4 ) / tempo ) + 0.5 ); | |
5646 | 5646 | // ここでnBGM位置Gridが192(x小節長)を超えることがある |
5647 | 5647 | // → 192(x小節長)をひいて、次の小節に回す。(小節ごとに小節長倍率が変化する可能性があることに注意) |
5648 | 5648 | // → スマン、この実装ではまだ、DTXデータの最初はしばらく小節倍率が一定である前提になっちゃってる・・ |
5649 | - cチップBGM.n位置grid = (int) ( 192 * c小節_0小節目.f小節長倍率 + 0.5f ) - ( nBGM位置grid % 192 ); // "192-" が必要なことに注意 | |
5649 | + cチップBGM.n位置grid = (int) ( CWholeNoteDivision.n分解能 * c小節_0小節目.f小節長倍率 + 0.5f ) - ( nBGM位置grid % CWholeNoteDivision.n分解能 ); // "192-" が必要なことに注意 | |
5650 | 5650 | c小節_0小節目.listチップ[ nBGMチップのindex ] = cチップBGM; |
5651 | 5651 | this.mgr譜面管理者.dic小節[ nBGMチップの小節番号 ] = c小節_0小節目; |
5652 | 5652 | } |
@@ -5654,15 +5654,15 @@ namespace DTXCreator | ||
5654 | 5654 | |
5655 | 5655 | #region [ 0小節目のBPMを設定し、1つ目の拍が1小節目の頭に来るようにする。] |
5656 | 5656 | // まず、0小節の頭にBPM設定を追加する。 |
5657 | - this.mgr編集モード管理者.tBPMチップを配置する( 0 * 192, tempo ); // 既にBPMチップが配置されている場合の処理は???????????????? | |
5657 | + this.mgr編集モード管理者.tBPMチップを配置する( 0 * CWholeNoteDivision.n分解能, tempo ); // 既にBPMチップが配置されている場合の処理は???????????????? | |
5658 | 5658 | this.numericUpDownBPM.Value = (decimal) ( (int) ( tempo + 0.5 ) ); |
5659 | 5659 | numericUpDownBPM_ValueChanged( null, null ); |
5660 | 5660 | numericUpDownBPM_Leave( null, null ); |
5661 | 5661 | |
5662 | 5662 | // 更に、先の1グリッド分の誤差をなくすために、BGMチップの位置だけでなく、0小節目のBPMも微調整する。 |
5663 | 5663 | float f小節長倍率_ = this.mgr譜面管理者.dic小節[ nBGMチップの小節番号 ].f小節長倍率; // 手抜き。すまん。 |
5664 | - float fBGM再生直後のBPM = ( 60 * 4 ) * nBGM位置grid / ( 192.0f * f小節長倍率_ ) / listBeatPositions[ n1拍目のBeatPositionIndex ].fBeatTime; | |
5665 | - this.mgr編集モード管理者.tBPMチップを配置する( 192 - ( nBGM位置grid % 192 ), fBGM再生直後のBPM ); | |
5664 | + float fBGM再生直後のBPM = ( 60 * 4 ) * nBGM位置grid / ( CWholeNoteDivision.n分解能 * f小節長倍率_ ) / listBeatPositions[ n1拍目のBeatPositionIndex ].fBeatTime; | |
5665 | + this.mgr編集モード管理者.tBPMチップを配置する( CWholeNoteDivision.n分解能 - ( nBGM位置grid % CWholeNoteDivision.n分解能 ), fBGM再生直後のBPM ); | |
5666 | 5666 | #endregion |
5667 | 5667 | |
5668 | 5668 |
@@ -5675,7 +5675,7 @@ namespace DTXCreator | ||
5675 | 5675 | // int lastGrid = (int) ( 192 * this.mgr譜面管理者.dic小節[ 0 ].f小節長倍率 ); // 0小節目の倍率 |
5676 | 5676 | //int last小節内Grid = 0; |
5677 | 5677 | //int last小節番号 = nBGMチップの小節番号; |
5678 | - int n最初の拍のある小節番号 = 1 + ( nBGM位置grid / 192 ); | |
5678 | + int n最初の拍のある小節番号 = 1 + ( nBGM位置grid / CWholeNoteDivision.n分解能 ); | |
5679 | 5679 | float lastBeatTime = listBeatPositions[ n1拍目のBeatPositionIndex ].fBeatTime; |
5680 | 5680 | int lastnGrid = -1; |
5681 | 5681 |
@@ -5749,7 +5749,7 @@ namespace DTXCreator | ||
5749 | 5749 | |
5750 | 5750 | #region [ BEATチップを置く ] |
5751 | 5751 | float f小節長倍率 = this.mgr譜面管理者.dic小節[ n小節番号 ].f小節長倍率; |
5752 | - int n小節内Grid = (int) ( 192f * f小節長倍率 * deltatime / ( ( 60 * 4 ) / tempo ) + 0.5 ); | |
5752 | + int n小節内Grid = (int) ( CWholeNoteDivision.n分解能 * f小節長倍率 * deltatime / ( ( 60 * 4 ) / tempo ) + 0.5 ); | |
5753 | 5753 | |
5754 | 5754 | #region [ Gridを16分音符単位(==12grid単位)でquantizeする ] |
5755 | 5755 | //Debug.Write( "nGrid: " + n小節内Grid + " -> " ); |
@@ -0,0 +1,14 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Threading.Tasks; | |
6 | + | |
7 | +namespace DTXCreator | |
8 | +{ | |
9 | + public static class CWholeNoteDivision | |
10 | + { | |
11 | + public static int n分解能 = 192; | |
12 | + public static int n分解能_表示用 = 192; | |
13 | + } | |
14 | +} |
@@ -1,6 +1,7 @@ | ||
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Text; |
4 | +using System.Diagnostics; | |
4 | 5 | |
5 | 6 | namespace DTXCreator.譜面 |
6 | 7 | { |
@@ -8,12 +9,13 @@ namespace DTXCreator.譜面 | ||
8 | 9 | { |
9 | 10 | public float f小節長倍率 = 1f; |
10 | 11 | public List<Cチップ> listチップ = new List<Cチップ>(); |
11 | - public static int n基準の高さdot = 0xc0; | |
12 | - public static readonly int n基準の高さgrid = 0xc0; | |
13 | - public static int n1グリッドの高さdot | |
12 | + public static int n基準の高さdot = CWholeNoteDivision.n分解能_表示用; //0xc0; | |
13 | + public static int n基準の高さgrid = CWholeNoteDivision.n分解能; //0xc0; | |
14 | + public static float n1グリッドの高さdot | |
14 | 15 | { |
15 | 16 | get |
16 | 17 | { |
18 | + //return ( n基準の高さdot < n基準の高さgrid ) ? 1 : (n基準の高さdot / n基準の高さgrid); | |
17 | 19 | return ( n基準の高さdot / n基準の高さgrid ); |
18 | 20 | } |
19 | 21 | } |
@@ -57,7 +59,7 @@ namespace DTXCreator.譜面 | ||
57 | 59 | } |
58 | 60 | public int n位置変換count2grid( int nCount ) |
59 | 61 | { |
60 | - return (int) ( ( ( n基準の高さgrid * this.f小節長倍率 ) * nCount ) / 384f ); | |
62 | + return (int) ( ( ( n基準の高さgrid * this.f小節長倍率 ) * nCount ) / CWholeNoteDivision.n分解能*2f ); | |
61 | 63 | } |
62 | 64 | public static int n位置変換dot2grid( int nDot ) |
63 | 65 | { |
@@ -65,7 +67,7 @@ namespace DTXCreator.譜面 | ||
65 | 67 | } |
66 | 68 | public int n位置変換grid2count( int nGrid ) |
67 | 69 | { |
68 | - return (int) ( ( nGrid * 384f ) / ( n基準の高さgrid * this.f小節長倍率 ) ); | |
70 | + return (int) ( ( nGrid * CWholeNoteDivision.n分解能*2f ) / ( n基準の高さgrid * this.f小節長倍率 ) ); | |
69 | 71 | } |
70 | 72 | public static int n位置変換grid2dot( int nGrid ) |
71 | 73 | { |
@@ -102,7 +102,7 @@ namespace DTXCreator.譜面 | ||
102 | 102 | public int nY座標dotが位置するgridを返す_最高解像度( int nY ) |
103 | 103 | { |
104 | 104 | int num = this._Form.pictureBox譜面パネル.ClientSize.Height - nY; |
105 | - return ( ( num / C小節.n1グリッドの高さdot ) + this.n現在の譜面表示下辺の譜面先頭からの位置grid ); | |
105 | + return (int)( ( num / C小節.n1グリッドの高さdot ) + this.n現在の譜面表示下辺の譜面先頭からの位置grid ); | |
106 | 106 | } |
107 | 107 | public int nレーンの左端X座標dotを返す( int nレーン番号0to ) |
108 | 108 | { |
@@ -159,7 +159,7 @@ namespace DTXCreator.譜面 | ||
159 | 159 | public int n譜面先頭からの位置gridから描画領域内のY座標dotを返す( int n譜面先頭からの位置grid, Size sz描画領域dot ) |
160 | 160 | { |
161 | 161 | int num = n譜面先頭からの位置grid - this.n現在の譜面表示下辺の譜面先頭からの位置grid; |
162 | - return ( sz描画領域dot.Height - ( num * C小節.n1グリッドの高さdot ) ); | |
162 | + return (int)( sz描画領域dot.Height - ( num * C小節.n1グリッドの高さdot ) ); | |
163 | 163 | } |
164 | 164 | public int n譜面先頭からみた小節先頭の位置gridを返す( int n小節番号0to3599 ) |
165 | 165 | { |
@@ -648,7 +648,7 @@ namespace DTXCreator.譜面 | ||
648 | 648 | this.strfmtレーン割付チップ番号文字フォーマット.Alignment = StringAlignment.Near; |
649 | 649 | int h = 0; |
650 | 650 | int num2 = 0; |
651 | - int num3 = this.n現在の譜面表示下辺の譜面先頭からの位置grid * C小節.n1グリッドの高さdot; | |
651 | + int num3 = (int)(this.n現在の譜面表示下辺の譜面先頭からの位置grid * C小節.n1グリッドの高さdot); | |
652 | 652 | int num4 = num3 + rc可視領域dot.Height; |
653 | 653 | int maxBar = this.n現在の最大の小節番号を返す(); |
654 | 654 | int bar = 0; |
@@ -917,7 +917,7 @@ namespace DTXCreator.譜面 | ||
917 | 917 | int num = cs.n小節長倍率を考慮した現在の小節の高さgrid; |
918 | 918 | for( int i = 0; i < num; i += this.n現在のガイド幅grid ) |
919 | 919 | { |
920 | - int num3 = rc小節のPicBox内描画領域.Bottom - ( i * C小節.n1グリッドの高さdot ); | |
920 | + int num3 = (int)(rc小節のPicBox内描画領域.Bottom - ( i * C小節.n1グリッドの高さdot )); | |
921 | 921 | g.DrawLine( this.penガイド線ペン, rc小節のPicBox内描画領域.X, num3, rc小節のPicBox内描画領域.Right, num3 ); |
922 | 922 | } |
923 | 923 | } |
@@ -939,7 +939,7 @@ namespace DTXCreator.譜面 | ||
939 | 939 | continue; |
940 | 940 | } |
941 | 941 | rectangle.X = cレーン.n位置Xdot; |
942 | - rectangle.Y = ( rc小節のPicBox内描画領域.Bottom - ( num * C小節.n1グリッドの高さdot ) ) - cチップの高さ.nチップの高さdot; | |
942 | + rectangle.Y = (int)(( rc小節のPicBox内描画領域.Bottom - ( num * C小節.n1グリッドの高さdot ) ) - cチップの高さ.nチップの高さdot); | |
943 | 943 | rectangle.Width = cレーン.n幅dot; |
944 | 944 | rectangle.Height = cチップの高さ.nチップの高さdot; |
945 | 945 | if( !cチップ.b裏 ) |
@@ -1017,7 +1017,7 @@ namespace DTXCreator.譜面 | ||
1017 | 1017 | int num = cs.n小節長倍率を考慮した現在の小節の高さgrid; |
1018 | 1018 | for( int i = 0; i < num; i += C小節.n基準の高さgrid / 4 ) |
1019 | 1019 | { |
1020 | - int num3 = rc小節のPicBox内描画領域.Bottom - ( i * C小節.n1グリッドの高さdot ); | |
1020 | + int num3 = (int)(rc小節のPicBox内描画領域.Bottom - ( i * C小節.n1グリッドの高さdot )); | |
1021 | 1021 | g.DrawLine( this.pen拍線ペン, rc小節のPicBox内描画領域.X, num3, rc小節のPicBox内描画領域.Right, num3 ); |
1022 | 1022 | } |
1023 | 1023 | } |
@@ -78,7 +78,7 @@ namespace DTXCreator.MIDIインポート | ||
78 | 78 | public override void 挿入( Cメインフォーム mf, int n四分音符の分解能 ) |
79 | 79 | { |
80 | 80 | mf.mgr譜面管理者.tチップを配置または置換する |
81 | - ( nレーン番号, (int) n時間 * ( 192 / 4 ) / n四分音符の分解能, nWAV, 0f, b裏チャンネル ); | |
81 | + ( nレーン番号, (int) n時間 * ( CWholeNoteDivision.n分解能 / 4 ) / n四分音符の分解能, nWAV, 0f, b裏チャンネル ); | |
82 | 82 | } |
83 | 83 | } |
84 | 84 |
@@ -100,7 +100,7 @@ namespace DTXCreator.MIDIインポート | ||
100 | 100 | |
101 | 101 | public override void 挿入( Cメインフォーム mf, int n四分音符の分解能 ) |
102 | 102 | { |
103 | - int nGrid = (int) n時間 * ( 192 / 4 ) / n四分音符の分解能; | |
103 | + int nGrid = (int) n時間 * ( CWholeNoteDivision.n分解能 / 4 ) / n四分音符の分解能; | |
104 | 104 | mf.mgr編集モード管理者.tBPMチップを配置する( nGrid, fBPM ); |
105 | 105 | } |
106 | 106 | } |
@@ -644,13 +644,13 @@ namespace DTXCreator.MIDIインポート | ||
644 | 644 | |
645 | 645 | C小節 c最終小節 = this.formメインフォーム.mgr譜面管理者.p譜面先頭からの位置gridを含む小節を返す( nCurremtMaxBar_FirstGrid ); |
646 | 646 | float fCurrent小節倍率 = (c最終小節 == null) ? 1.0f : c最終小節.f小節長倍率; |
647 | - int nCurrentMaxGrid = nCurremtMaxBar_FirstGrid + (int) ( 192 * fCurrent小節倍率 ) - 1; | |
647 | + int nCurrentMaxGrid = nCurremtMaxBar_FirstGrid + (int) ( CWholeNoteDivision.n分解能 * fCurrent小節倍率 ) - 1; | |
648 | 648 | if ( nCurrentMaxBar < 0 ) nCurrentMaxGrid = -1; |
649 | 649 | |
650 | 650 | // 拍子変更イベントの絶対時間が、小節外にあれば、新規に小節を一つ追加する。 |
651 | 651 | // 小節長は前の小節長を継承するか、MIDIイベント指定による新しい値にするか。 |
652 | 652 | // 小節を1つ追加しただけでは足りないのであれば、whileループで繰り返し追加し続ける。 |
653 | - int nEvent時間 = (int)cm.n時間 * ( 192 / 4 ) / n四分音符の分解能; | |
653 | + int nEvent時間 = (int)cm.n時間 * ( CWholeNoteDivision.n分解能 / 4 ) / n四分音符の分解能; | |
654 | 654 | if ( nCurrentMaxGrid < (int) nEvent時間 ) |
655 | 655 | { |
656 | 656 | ++nCurrentMaxBar; |
@@ -404,7 +404,7 @@ namespace DTXCreator.MIDIExport | ||
404 | 404 | #endregion |
405 | 405 | |
406 | 406 | // 次の小節へ |
407 | - basetick += (ulong)(192.0 * cBAR.f小節長倍率); | |
407 | + basetick += (ulong)(CWholeNoteDivision.n分解能 * cBAR.f小節長倍率); | |
408 | 408 | |
409 | 409 | if (existChipInnerBar) EoTtick = basetick; // 小節内に有意なチップがある限り、その小節は演奏データに含まれるものとする(→データ末尾を定義するtickを更新する) |
410 | 410 | } |
@@ -480,7 +480,7 @@ namespace DTXCreator.MIDIExport | ||
480 | 480 | bw.Write(new byte[] { 0x00, 0x01 }); // tracks = 1 |
481 | 481 | |
482 | 482 | { |
483 | - Int16 division = (Int16)(192 / 4); | |
483 | + Int16 division = (Int16)( CWholeNoteDivision.n分解能 / 4); | |
484 | 484 | byte[] b = BitConverter.GetBytes(division); |
485 | 485 | if (BitConverter.IsLittleEndian) Array.Reverse(b); |
486 | 486 | bw.Write(new byte[] { b[0], b[1] }); // division of quarter note |