ADPCM.java
     1: //========================================================================================
     2: //  ADPCM.java
     3: //    en:ADPCM sound source -- It decodes the compressed data written in MSM6258V and calculates interpolated values.
     4: //    ja:ADPCM音源 -- MSM6258Vに書き込まれたデータを展開して補間値を計算します。
     5: //  Copyright (C) 2003-2023 Makoto Kamada
     6: //
     7: //  This file is part of the XEiJ (X68000 Emulator in Java).
     8: //  You can use, modify and redistribute the XEiJ if the conditions are met.
     9: //  Read the XEiJ License for more details.
    10: //  https://stdkmd.net/xeij/
    11: //========================================================================================
    12: 
    13: package xeij;
    14: 
    15: import java.lang.*;  //Boolean,Character,Class,Comparable,Double,Exception,Float,IllegalArgumentException,Integer,Long,Math,Number,Object,Runnable,SecurityException,String,StringBuilder,System
    16: import java.util.*;  //ArrayList,Arrays,Calendar,GregorianCalendar,HashMap,Map,Map.Entry,Timer,TimerTask,TreeMap
    17: 
    18: public class ADPCM {
    19: 
    20:   public static final boolean PCM_ON = true;  //true=PCMを出力する
    21: 
    22:   //  ADPCMのサンプリング周波数は8000000Hzまたは4000000Hzの原発振周波数を1/1024,1/768,1/512に分周して作られる
    23:   //  同じデータを繰り返す回数を変更することで原発振周波数と分周比の組み合わせを再現する
    24:   //  原発振周波数   分周比   サンプリング周波数
    25:   //     8000000   /  1024  =     7812.5000
    26:   //     8000000   /   768  =    10416.6667
    27:   //     8000000   /   512  =    15625.0000
    28:   //     4000000   /  1024  =     3906.2500
    29:   //     4000000   /   768  =     5208.3333
    30:   //     4000000   /   512  =     7812.5000
    31:   //    16000000   /  1024  =    15625.0000
    32:   //    16000000   /   768  =    20833.3333
    33:   //    16000000   /   512  =    31250.0000
    34:   public static final int PCM_SAMPLE_FREQ = 62500;  //基本サンプリング周波数(Hz)。62500Hzに固定
    35:   public static final long PCM_SAMPLE_TIME = XEiJ.TMR_FREQ / PCM_SAMPLE_FREQ;  //1サンプルの時間(XEiJ.TMR_FREQ単位)
    36:   public static final int PCM_BLOCK_SAMPLES = PCM_SAMPLE_FREQ / SoundSource.SND_BLOCK_FREQ;  //1ブロックのサンプル数。2500
    37: 
    38:   //原発振周波数、分周比、パン
    39:   //  原発振周波数は0=8MHz/8MHz,1=4MHz/16MHz
    40:   //  分周比は0=1024,1=768,2=512,3=inhibited
    41:   public static final int PCM_MAX_REPEAT = PCM_SAMPLE_FREQ * 1024 / 4000000;  //データ繰り返す回数の最大。16
    42:   public static final int[] PCM_SAMPLE_REPEAT = {  //データを繰り返す回数
    43:     PCM_SAMPLE_FREQ * 1024 /  8000000,  // 8
    44:     PCM_SAMPLE_FREQ *  768 /  8000000,  // 6
    45:     PCM_SAMPLE_FREQ *  512 /  8000000,  // 4
    46:     PCM_SAMPLE_FREQ *  768 /  8000000,  // 6
    47:     PCM_SAMPLE_FREQ * 1024 /  4000000,  //16
    48:     PCM_SAMPLE_FREQ *  768 /  4000000,  //12
    49:     PCM_SAMPLE_FREQ *  512 /  4000000,  // 8
    50:     PCM_SAMPLE_FREQ *  768 /  4000000,  //12
    51:     PCM_SAMPLE_FREQ * 1024 /  8000000,  // 8
    52:     PCM_SAMPLE_FREQ *  768 /  8000000,  // 6
    53:     PCM_SAMPLE_FREQ *  512 /  8000000,  // 4
    54:     PCM_SAMPLE_FREQ *  768 /  8000000,  // 6
    55:     PCM_SAMPLE_FREQ * 1024 / 16000000,  // 4
    56:     PCM_SAMPLE_FREQ *  768 / 16000000,  // 3
    57:     PCM_SAMPLE_FREQ *  512 / 16000000,  // 2
    58:     PCM_SAMPLE_FREQ *  768 / 16000000,  // 3
    59:   };
    60:   public static int pcmOSCFreqRequest;  //pcmOSCFreqModeに設定する値。非同期に変更できないので切りの良いところで転送する。リセットさせる必要はない
    61:   public static int pcmOSCFreqMode;  //原発振周波数の改造。0=8MHz/4MHz,1=8MHz/16MHz
    62:   public static int pcmOscillator;  //原発振周波数の選択。0=8MHz/8MHz,1=4MHz/16MHz
    63:   public static int pcmDivider;  //分周比の選択。0=1/1024,1=1/768,2=1/512,3=inhibited
    64:   public static int pcmRepeat;  //データを繰り返す回数
    65:   public static long pcmInterval;  //1データ(2サンプル)あたりの割り込み間隔(XEiJ.TMR_FREQ単位)
    66: 
    67:   //ADPCM→PCM変換
    68:   //  予測指標p(0..48)と4bitデータn(0..15)の組み合わせでPCMデータの差分が決まる
    69:   //    x = floor (32768 / pow (1.1, 80 - p))
    70:   //    delta = (1 - (n >> 2 & 2)) * ((n >> 2 & 1) * x + (n >> 1 & 1) * (x >> 1) + (n & 1) * (x >> 2) + (x >> 3))
    71:   //    data = max (-2048, min (2047, data + delta))
    72:   //  データで予測指標の差分が決まる
    73:   //    p = max (0, min (48, p + ((n & 7) - 4 >> 3 | (n & 3) + 1 << 1)))
    74:   //  8bitデータを下位4bit、上位4bitの順にデコードする
    75:   //  8bitまとめてテーブルを参照することで2データ分の予測指標の遷移を1回で済ませる
    76:   //  変換テーブル
    77:   //    pcmDecoderTable[予測指標<<8|8bitデータ] = 下位4bitに対応する差分<<19|(上位4bitに対応する差分&8191)<<6|次の予測指標
    78:   //    データの範囲が12bitのときmin-maxからmax-minまでの差分の範囲は符号を含めて13bit必要
    79:   //      ±(1552+(1552>>1)+(1552>>2)+(1552>>3))=±2910
    80:   //    テーブルを作る段階で12bitにクリッピングすると波形が変わってしまう
    81:   //  ソフトウェアによってテーブルの内容に若干の差異がある
    82:   //    PCM8.X,PCMLIB.a,MAMEなど
    83:   //      zmusic2の組み込みと解除でそれぞれ+70ずつくらいずれる
    84:   //      perl -e "for$p(0..48){$p%10==0 and print'      //    ';print int(16*1.1**$p).',';$p%10==9 and print chr(10);}"
    85:   //      16,17,19,21,23,25,28,31,34,37,
    86:   //      41,45,50,55,60,66,73,80,88,97,
    87:   //      107,118,130,143,157,173,190,209,230,253,
    88:   //      279,307,337,371,408,449,494,544,598,658,
    89:   //      724,796,876,963,1060,1166,1282,1411,1552,
    90:   //    PCM8A.X
    91:   //      zmusic2の組み込みで+34、解除で+32ずれる
    92:   //      log(32768/16)/log(1.1)=79.99795<80なのでPCM8.Xのテーブルと比較すると値がわずかに小さい
    93:   //      perl -e "for$p(0..48){$p%10==0 and print'      //    ';print int(2**15/1.1**(80-$p)).',';$p%10==9 and print chr(10);}"
    94:   //      15,17,19,21,23,25,28,31,34,37,
    95:   //      41,45,50,55,60,66,73,80,88,97,
    96:   //      107,118,130,143,157,173,190,209,230,253,
    97:   //      279,307,337,371,408,449,494,543,598,658,
    98:   //      724,796,876,963,1060,1166,1282,1410,1551,
    99:   public static final int[] pcmDecoderTable = new int[256 * 49];  //ADPCM→PCM変換テーブル
   100:   public static int pcmDecoderPointer;  //予測指標。0..48
   101: 
   102:   //バッファ
   103:   public static final int[] pcmBuffer = new int[SoundSource.SND_CHANNELS * (PCM_BLOCK_SAMPLES + PCM_MAX_REPEAT * 2)];  //出力バッファ。ステレオのときはleft→rightの順序
   104:   public static int pcmPointer;  //出力バッファの中を遷移するポインタ
   105: 
   106:   //タイマ
   107:   public static long pcmClock;  //次のADPCMデータを取り込む時刻
   108: 
   109:   //動作
   110:   public static boolean pcmOutputOn;  //true=PCMを出力する
   111:   public static boolean pcmActive;  //pcmClock!=XEiJ.FAR_FUTURE。true=動作中,false=停止中
   112:   public static int pcmEncodedData;  //次に出力する8ビットのADPCMデータ。-1=データなし
   113:   public static int pcmDecodedData1;  //ADPCM→PCM変換されたPCMデータ<<4。1つ前
   114:   public static int pcmDecodedData2;  //ADPCM→PCM変換されたPCMデータ<<4。2つ前
   115:   public static int pcmDecodedData3;  //ADPCM→PCM変換されたPCMデータ<<4。3つ前
   116: 
   117:   //ゼロデータ補正
   118:   //  予測指標が大きい状態から0x00や0x88を繰り返して予測指標を下げようとすると変位が+側または-側に振り切ってしまう
   119:   //    perl -e "$s=0;for($p=48;$p>0;$p--){$s+=int(1.1**$p*16)>>3;}print$s*16"
   120:   //    33454
   121:   //    予測指標が48のとき0x00を48回繰り返して予測指標を0にすると変位が33454増える
   122:   //  そのままパンで0に戻されるとプチノイズの原因になる
   123:   //  データが97以上のとき0x00を0x08に、-97以下のとき0x88を0x80に変更することで変位が0から離れないようにする
   124:   //    97は予測指標が48のときの0の増分の半分。予測指標を無視しても絶対値が大きくなってしまわない下限
   125:   //    perl -e "print int(1.1**48*16)>>3>>1"
   126:   //    97
   127:   //! 軽量化。0以上かどうかで分けている
   128:   //! 軽量化。delta1だけ補正している。delta2を加えるときの符号はテーブルを参照する時点で確定できないのでdelta2の補正は負荷が大きくなる
   129:   public static final boolean PCM_MODIFY_ZERO_ZERO = true;  //true=ゼロデータ補正を行う。0x00/0x88を0x08/0x80に読み替える
   130:   public static final boolean PCM_MODIFY_ZERO_TWICE = false;  //true=0x00/0x88が2回以上繰り返されたときだけ補正する
   131:   public static final int[] pcmDecoderTableP = new int[256 * 49];  //0x00を0x08に読み替えたテーブル
   132:   public static final int[] pcmDecoderTableM = new int[256 * 49];  //0x88を0x80に読み替えたテーブル
   133:   public static int pcmZeroPreviousData;  //0x00=直前が0x00、0x88=直前が0x88、-1=その他
   134: 
   135:   //減衰
   136:   //  データがないとき変位をゆっくり0に近付ける
   137:   //  データによっては変位が0から離れた状態で再生が終わってしまうことがある
   138:   //  そのとき再生終了と同時に変位を0にするとブチッという音が出てしまう
   139:   //  また、変位が偏ってクリッピングが多発するのもノイズの原因になる
   140:   //  データがないとき、変位をゆっくり0に近付けることでノイズを低減する
   141:   //
   142:   //  PCM8A.Xが組み込まれているときは無音でもADPCMはONのままなので、データが間に合わなかったのか再生が終わったのかすぐに判断できない
   143:   //  ADPCMがOFFのときだけでなくADPCMがONでデータがないときも減衰させる必要がある
   144:   //  ゆっくり0に近付ければ、データが間に合わなかったときは変位がわずかにずれるだけで済む
   145:   public static final boolean PCM_DECAY_ON = true;  //true=減衰させる
   146: 
   147:   //補間
   148:   //  ADPCMの出力周波数を62500Hzに上げるための補間アルゴリズムを選択する
   149:   //  区分定数補間
   150:   //    同じ値を繰り返す
   151:   //    サンプリングデータをコピーするだけなので単純で高速だが、波形が階段状になるためノイズが増える
   152:   //  線形補間
   153:   //    前後2つのサンプリングデータを直線で結んで補間する
   154:   //    前後2つのサンプリングデータの線形結合で求まる
   155:   //  エルミート補間
   156:   //    前後4つのサンプリングデータを用いて前後2つのサンプリングデータを曲線で結んで補間する
   157:   //    前後4つのサンプリングデータの線形結合で求まる
   158:   public static final int PCM_INTERPOLATION_CONSTANT = 0;  //Piecewise-constant interpolation 区分定数補間
   159:   public static final int PCM_INTERPOLATION_LINEAR   = 1;  //Liear interpolation 線形補間
   160:   public static final int PCM_INTERPOLATION_HERMITE  = 2;  //Hermite interpolation エルミート補間
   161:   public static int pcmInterpolationAlgorithm;  //PCM_INTERPOLATION_CONSTANT,PCM_INTERPOLATION_LINEAR,PCM_INTERPOLATION_HERMITE
   162:   //  モノラル
   163:   public static final PIP[][] PCM_INTERPOLATION_MONO = {
   164:     //                    分割数  原発振  分周比     出力
   165:     //                            周波数            周波数
   166:     //区分定数補間
   167:     {
   168:       PIP.PIP_MONO_CONSTANT_8,   // 8MHz  1/1024   7812.50Hz
   169:       PIP.PIP_MONO_CONSTANT_6,   // 8MHz  1/768   10416.67Hz
   170:       PIP.PIP_MONO_CONSTANT_4,   // 8MHz  1/512   15625.00Hz
   171:       PIP.PIP_MONO_CONSTANT_6,   // 8MHz  1/768   10416.67Hz
   172:       PIP.PIP_MONO_CONSTANT_16,  // 4MHz  1/1024   3906.25Hz
   173:       PIP.PIP_MONO_CONSTANT_12,  // 4MHz  1/768    5208.33Hz
   174:       PIP.PIP_MONO_CONSTANT_8,   // 4MHz  1/512    7812.50Hz
   175:       PIP.PIP_MONO_CONSTANT_12,  // 4MHz  1/768    5208.33Hz
   176:       PIP.PIP_MONO_CONSTANT_8,   // 8MHz  1/1024   7812.50Hz
   177:       PIP.PIP_MONO_CONSTANT_6,   // 8MHz  1/768   10416.67Hz
   178:       PIP.PIP_MONO_CONSTANT_4,   // 8MHz  1/512   15625.00Hz
   179:       PIP.PIP_MONO_CONSTANT_6,   // 8MHz  1/768   10416.67Hz
   180:       PIP.PIP_MONO_CONSTANT_4,   //16MHz  1/1024  15625.00Hz
   181:       PIP.PIP_MONO_CONSTANT_3,   //16MHz  1/768   20833.33Hz
   182:       PIP.PIP_MONO_CONSTANT_2,   //16MHz  1/512   31250.00Hz
   183:       PIP.PIP_MONO_CONSTANT_3,   //16MHz  1/768   20833.33Hz
   184:     },
   185:     //線形補間
   186:     {
   187:       PIP.PIP_MONO_LINEAR_8,     // 8MHz  1/1024   7812.50Hz
   188:       PIP.PIP_MONO_LINEAR_6,     // 8MHz  1/768   10416.67Hz
   189:       PIP.PIP_MONO_LINEAR_4,     // 8MHz  1/512   15625.00Hz
   190:       PIP.PIP_MONO_LINEAR_6,     // 8MHz  1/768   10416.67Hz
   191:       PIP.PIP_MONO_LINEAR_16,    // 4MHz  1/1024   3906.25Hz
   192:       PIP.PIP_MONO_LINEAR_12,    // 4MHz  1/768    5208.33Hz
   193:       PIP.PIP_MONO_LINEAR_8,     // 4MHz  1/512    7812.50Hz
   194:       PIP.PIP_MONO_LINEAR_12,    // 4MHz  1/768    5208.33Hz
   195:       PIP.PIP_MONO_LINEAR_8,     // 8MHz  1/1024   7812.50Hz
   196:       PIP.PIP_MONO_LINEAR_6,     // 8MHz  1/768   10416.67Hz
   197:       PIP.PIP_MONO_LINEAR_4,     // 8MHz  1/512   15625.00Hz
   198:       PIP.PIP_MONO_LINEAR_6,     // 8MHz  1/768   10416.67Hz
   199:       PIP.PIP_MONO_LINEAR_4,     //16MHz  1/1024  15625.00Hz
   200:       PIP.PIP_MONO_LINEAR_3,     //16MHz  1/768   20833.33Hz
   201:       PIP.PIP_MONO_LINEAR_2,     //16MHz  1/512   31250.00Hz
   202:       PIP.PIP_MONO_LINEAR_3,     //16MHz  1/768   20833.33Hz
   203:     },
   204:     //エルミート補間
   205:     {
   206:       PIP.PIP_MONO_HERMITE_8,    // 8MHz  1/1024   7812.50Hz
   207:       PIP.PIP_MONO_HERMITE_6,    // 8MHz  1/768   10416.67Hz
   208:       PIP.PIP_MONO_HERMITE_4,    // 8MHz  1/512   15625.00Hz
   209:       PIP.PIP_MONO_HERMITE_6,    // 8MHz  1/768   10416.67Hz
   210:       PIP.PIP_MONO_HERMITE_16,   // 4MHz  1/1024   3906.25Hz
   211:       PIP.PIP_MONO_HERMITE_12,   // 4MHz  1/768    5208.33Hz
   212:       PIP.PIP_MONO_HERMITE_8,    // 4MHz  1/512    7812.50Hz
   213:       PIP.PIP_MONO_HERMITE_12,   // 4MHz  1/768    5208.33Hz
   214:       PIP.PIP_MONO_HERMITE_8,    // 8MHz  1/1024   7812.50Hz
   215:       PIP.PIP_MONO_HERMITE_6,    // 8MHz  1/768   10416.67Hz
   216:       PIP.PIP_MONO_HERMITE_4,    // 8MHz  1/512   15625.00Hz
   217:       PIP.PIP_MONO_HERMITE_6,    // 8MHz  1/768   10416.67Hz
   218:       PIP.PIP_MONO_HERMITE_4,    //16MHz  1/1024  15625.00Hz
   219:       PIP.PIP_MONO_HERMITE_3,    //16MHz  1/768   20833.33Hz
   220:       PIP.PIP_MONO_HERMITE_2,    //16MHz  1/512   31250.00Hz
   221:       PIP.PIP_MONO_HERMITE_3,    //16MHz  1/768   20833.33Hz
   222:     },
   223:   };  //PCM_INTERPOLATION_MONO
   224:   //  ステレオ
   225:   public static final PIP[][] PCM_INTERPOLATION_STEREO = {
   226:     //                      分割数  原発振  分周比     出力
   227:     //                              周波数            周波数
   228:     //区分定数補間
   229:     {
   230:       PIP.PIP_STEREO_CONSTANT_8,   // 8MHz  1/1024   7812.50Hz
   231:       PIP.PIP_STEREO_CONSTANT_6,   // 8MHz  1/768   10416.67Hz
   232:       PIP.PIP_STEREO_CONSTANT_4,   // 8MHz  1/512   15625.00Hz
   233:       PIP.PIP_STEREO_CONSTANT_6,   // 8MHz  1/768   10416.67Hz
   234:       PIP.PIP_STEREO_CONSTANT_16,  // 4MHz  1/1024   3906.25Hz
   235:       PIP.PIP_STEREO_CONSTANT_12,  // 4MHz  1/768    5208.33Hz
   236:       PIP.PIP_STEREO_CONSTANT_8,   // 4MHz  1/512    7812.50Hz
   237:       PIP.PIP_STEREO_CONSTANT_12,  // 4MHz  1/768    5208.33Hz
   238:       PIP.PIP_STEREO_CONSTANT_8,   // 8MHz  1/1024   7812.50Hz
   239:       PIP.PIP_STEREO_CONSTANT_6,   // 8MHz  1/768   10416.67Hz
   240:       PIP.PIP_STEREO_CONSTANT_4,   // 8MHz  1/512   15625.00Hz
   241:       PIP.PIP_STEREO_CONSTANT_6,   // 8MHz  1/768   10416.67Hz
   242:       PIP.PIP_STEREO_CONSTANT_4,   //16MHz  1/1024  15625.00Hz
   243:       PIP.PIP_STEREO_CONSTANT_3,   //16MHz  1/768   20833.33Hz
   244:       PIP.PIP_STEREO_CONSTANT_2,   //16MHz  1/512   31250.00Hz
   245:       PIP.PIP_STEREO_CONSTANT_3,   //16MHz  1/768   20833.33Hz
   246:     },
   247:     //線形補間
   248:     {
   249:       PIP.PIP_STEREO_LINEAR_8,     // 8MHz  1/1024   7812.50Hz
   250:       PIP.PIP_STEREO_LINEAR_6,     // 8MHz  1/768   10416.67Hz
   251:       PIP.PIP_STEREO_LINEAR_4,     // 8MHz  1/512   15625.00Hz
   252:       PIP.PIP_STEREO_LINEAR_6,     // 8MHz  1/768   10416.67Hz
   253:       PIP.PIP_STEREO_LINEAR_16,    // 4MHz  1/1024   3906.25Hz
   254:       PIP.PIP_STEREO_LINEAR_12,    // 4MHz  1/768    5208.33Hz
   255:       PIP.PIP_STEREO_LINEAR_8,     // 4MHz  1/512    7812.50Hz
   256:       PIP.PIP_STEREO_LINEAR_12,    // 4MHz  1/768    5208.33Hz
   257:       PIP.PIP_STEREO_LINEAR_8,     // 8MHz  1/1024   7812.50Hz
   258:       PIP.PIP_STEREO_LINEAR_6,     // 8MHz  1/768   10416.67Hz
   259:       PIP.PIP_STEREO_LINEAR_4,     // 8MHz  1/512   15625.00Hz
   260:       PIP.PIP_STEREO_LINEAR_6,     // 8MHz  1/768   10416.67Hz
   261:       PIP.PIP_STEREO_LINEAR_4,     //16MHz  1/1024  15625.00Hz
   262:       PIP.PIP_STEREO_LINEAR_3,     //16MHz  1/768   20833.33Hz
   263:       PIP.PIP_STEREO_LINEAR_2,     //16MHz  1/512   31250.00Hz
   264:       PIP.PIP_STEREO_LINEAR_3,     //16MHz  1/768   20833.33Hz
   265:     },
   266:     //エルミート補間
   267:     {
   268:       PIP.PIP_STEREO_HERMITE_8,    // 8MHz  1/1024   7812.50Hz
   269:       PIP.PIP_STEREO_HERMITE_6,    // 8MHz  1/768   10416.67Hz
   270:       PIP.PIP_STEREO_HERMITE_4,    // 8MHz  1/512   15625.00Hz
   271:       PIP.PIP_STEREO_HERMITE_6,    // 8MHz  1/768   10416.67Hz
   272:       PIP.PIP_STEREO_HERMITE_16,   // 4MHz  1/1024   3906.25Hz
   273:       PIP.PIP_STEREO_HERMITE_12,   // 4MHz  1/768    5208.33Hz
   274:       PIP.PIP_STEREO_HERMITE_8,    // 4MHz  1/512    7812.50Hz
   275:       PIP.PIP_STEREO_HERMITE_12,   // 4MHz  1/768    5208.33Hz
   276:       PIP.PIP_STEREO_HERMITE_8,    // 8MHz  1/1024   7812.50Hz
   277:       PIP.PIP_STEREO_HERMITE_6,    // 8MHz  1/768   10416.67Hz
   278:       PIP.PIP_STEREO_HERMITE_4,    // 8MHz  1/512   15625.00Hz
   279:       PIP.PIP_STEREO_HERMITE_6,    // 8MHz  1/768   10416.67Hz
   280:       PIP.PIP_STEREO_HERMITE_4,    //16MHz  1/1024  15625.00Hz
   281:       PIP.PIP_STEREO_HERMITE_3,    //16MHz  1/768   20833.33Hz
   282:       PIP.PIP_STEREO_HERMITE_2,    //16MHz  1/512   31250.00Hz
   283:       PIP.PIP_STEREO_HERMITE_3,    //16MHz  1/768   20833.33Hz
   284:     },
   285:   };  //PCM_INTERPOLATION_STEREO
   286:   public static PIP pcmInterpolationEngine;  //補間エンジン
   287: 
   288:   //アタック
   289:   //  パンのON/OFFでプチノイズが出ないように曲線で補間する
   290:   public static final int PCM_ATTACK_RATE = 10;
   291:   public static final int PCM_ATTACK_SPAN = 1 << PCM_ATTACK_RATE;  //曲線の長さ
   292:   public static final int PCM_ATTACK_MASK = PCM_ATTACK_SPAN - 1;
   293:   public static final int PCM_ATTACK_SHIFT = 14;
   294:   public static final int[] pcmAttackCurve = new int[PCM_ATTACK_SPAN * 4];
   295:   //  0=OFF
   296:   //  1=ON
   297:   //  0x80000000+(0..PCM_ATTACK_SPAN-1)=ON→OFF
   298:   //  0x80000000+(PCM_ATTACK_SPAN*2..PCM_ATTACK_SPAN*3-1)=OFF→ON
   299:   //  (pcmPanLeft==0||pcmPanLeft<0x80000000+PCM_ATTACK_SPAN*2)==OFF
   300:   //  !(pcmPanLeft==0||pcmPanLeft<0x80000000+PCM_ATTACK_SPAN*2)==ON
   301:   public static int pcmPanLeft;  //モノラルのときleftをmiddleとして使う
   302:   public static int pcmPanRight;  //rightはステレオのときだけ使う
   303: 
   304:   public static int pcmLastPan;
   305: 
   306:   //pcmInit ()
   307:   //  PCMを初期化する
   308:   public static void pcmInit () {
   309:     //動作
   310:     //pcmOutputOn = true;
   311:     pcmActive = false;
   312:     pcmEncodedData = -1;
   313:     pcmDecodedData1 = 0;
   314:     pcmDecodedData2 = 0;
   315:     pcmDecodedData3 = 0;
   316:     //ADPCM→PCM変換
   317:     //  4bitデータのADPCM→PCM変換テーブルを作る
   318:     //    d4[予測指標<<4|4bitデータ] = 4bitデータに対応する差分
   319:     //    p4[予測指標<<4|4bitデータ] = 次の予測指標
   320:     int[] d4 = new int[16 * 49];
   321:     int[] p4 = new int[16 * 49];
   322:     int[] deltaP = new int[] { -1, -1, -1, -1, 2, 4, 6, 8 };  //PCM8,PCM8A,X68Soundなど
   323:     for (int p = 0; p < 49; p++) {  //予測指標
   324:       int x = (int) Math.floor (16.0 * Math.pow (1.1, p));  //PCM8.X,PCMLIB.a,MAMEなど
   325:       //int x = (int) Math.floor (32768.0 / Math.pow (1.1, (double) (80 - p)));  //PCM8A.X
   326:       for (int n = 0; n < 16; n++) {  //4bitデータ
   327:         int i = p << 4 | n;
   328:         if (true) {
   329:           int t = ((((n & 7) << 1) | 1) * x) >> 3;
   330:           d4[i] = (n & 8) == 0 ? t : -t;  //4bitデータに対応する差分
   331:         } else {  //PCM8
   332:           d4[i] = (1 - (n >> 2 & 2)) * ((n >> 2 & 1) * x + (n >> 1 & 1) * (x >> 1) + (n & 1) * (x >> 2) + (x >> 3));  //4bitデータに対応する差分
   333:         }
   334:         p4[i] = Math.max (0, Math.min (48, p + deltaP[n & 7]));  //次の予測指標
   335:         if (false) {
   336:           System.out.printf ("(%2d,%2d,%5d,%2d),", p, n, d4[i], p4[i]);
   337:           if ((n & 7) == 7) {
   338:             System.out.println ();
   339:           }
   340:         }
   341:       }
   342:     }
   343:     //  8bitデータのADPCM→PCM変換テーブルを作る
   344:     //pcmDecoderTable = new int[256 * 49];
   345:     //pcmDecoderTableP = new int[256 * 49];
   346:     //pcmDecoderTableM = new int[256 * 49];
   347:     for (int p = 0; p < 49; p++) {  //予測指標
   348:       for (int n2 = 0; n2 < 16; n2++) {  //8bitデータの上位4bit
   349:         int i4 = p << 8 | n2 << 4;
   350:         for (int n1 = 0; n1 < 16; n1++) {  //8bitデータの下位4bit
   351:           int i = p << 4 | n1;
   352:           int delta1 = d4[i];  //8bitデータの下位4ビットに対応する差分
   353:           i = p4[i] << 4 | n2;
   354:           int delta2 = d4[i];  //8bitデータの上位4ビットに対応する差分
   355:           int q = p4[i];  //次の予測指標
   356:           int t = delta1 << 19 | (delta2 & 8191) << 6 | q;
   357:           pcmDecoderTable[i4 | n1] = t;
   358:           if (PCM_MODIFY_ZERO_ZERO) {
   359:             //pcmDecoderTablePは0x00の、pcmDecoderTableMは0x88の、delta1を符号反転する
   360:             //  notで-1から引いてから1を加えれば0から引いたことになる
   361:             pcmDecoderTableP[i4 | n1] = n1 == 0 && n2 == 0 ? (t ^ -1 << 19) + (1 << 19) : t;
   362:             pcmDecoderTableM[i4 | n1] = n1 == 8 && n2 == 8 ? (t ^ -1 << 19) + (1 << 19) : t;
   363:           }
   364:         }
   365:       }
   366:     }
   367:     if (PCM_MODIFY_ZERO_TWICE) {
   368:       pcmZeroPreviousData = -1;
   369:     }
   370:     //補間
   371:     //pcmInterpolationAlgorithm = PCM_INTERPOLATION_LINEAR;
   372:     //アタック
   373:     //pcmAttackCurve = new int[PCM_ATTACK_SPAN * 4];
   374:     for (int i = 0; i < PCM_ATTACK_SPAN; i++) {
   375:       pcmAttackCurve[i] =
   376:         (int) Math.round (0.5 * (double) (1 << PCM_ATTACK_SHIFT) *
   377:                           (1.0 + Math.cos (Math.PI / (double) PCM_ATTACK_SPAN * (double) i)));  //(1+cos(0→π))/2=1→0
   378:       pcmAttackCurve[PCM_ATTACK_SPAN * 2 + i] =
   379:         (int) Math.round (0.5 * (double) (1 << PCM_ATTACK_SHIFT) *
   380:                           (1.0 + Math.cos (Math.PI / (double) PCM_ATTACK_SPAN * (double) i)));  //(1-cos(0→π))/2=0→1
   381:     }
   382:     Arrays.fill (pcmAttackCurve, PCM_ATTACK_SPAN, PCM_ATTACK_SPAN * 2, 0);
   383:     Arrays.fill (pcmAttackCurve, PCM_ATTACK_SPAN * 3, PCM_ATTACK_SPAN * 4, 1 << PCM_ATTACK_SHIFT);
   384:     pcmPanLeft = 0;
   385:     if (SoundSource.SND_CHANNELS == 2) {  //ステレオ
   386:       pcmPanRight = 0;
   387:     }
   388:     //バッファ
   389:     //pcmBuffer = new int[SoundSource.SND_CHANNELS * (PCM_BLOCK_SAMPLES + PCM_MAX_REPEAT * 2)];
   390:     //リセット
   391:     pcmReset ();
   392:   }  //pcmInit()
   393: 
   394:   //リセット
   395:   public static void pcmReset () {
   396:     //原発振周波数、分周比、パン
   397:     //pcmOSCFreqRequest = 0;  //8MHz/4MHz
   398:     pcmOSCFreqMode = 0;  //8MHz/4MHz
   399:     pcmOscillator = 0;  //8MHz/8MHz
   400:     pcmDivider = 2;  //1/512
   401:     pcmUpdateRepeatInterval ();
   402:     pcmLastPan = 0;
   403:     pcmSetPan (pcmLastPan);  //LeftON,RightON
   404:     //ADPCM→PCM変換
   405:     pcmDecoderPointer = 0;
   406:     //バッファ
   407:     Arrays.fill (pcmBuffer, 0);
   408:     pcmPointer = 0;
   409:     //タイマ
   410:     pcmClock = XEiJ.FAR_FUTURE;
   411:     TickerQueue.tkqRemove (SoundSource.sndPcmTicker);
   412:     //動作
   413:     pcmActive = false;  //ADPCM出力停止
   414:     pcmEncodedData = -1;  //ADPCMデータなし
   415:   }  //pcmReset()
   416: 
   417:   //pcmUpdateRepeatInterval ()
   418:   //  原発振周波数と分周比に従ってADPCMのサンプリング周波数を設定する
   419:   public static void pcmUpdateRepeatInterval () {
   420:     pcmRepeat = PCM_SAMPLE_REPEAT[pcmOSCFreqMode << 3 | pcmOscillator << 2 | pcmDivider];
   421:     pcmInterval = PCM_SAMPLE_TIME * 2 * pcmRepeat;
   422:     pcmSetInterpolationAlgorithm (pcmInterpolationAlgorithm);
   423:   }  //pcmUpdateRepeatInterval()
   424: 
   425:   //pcmSetInterpolationAlgorithm (algorithm)
   426:   //  補間アルゴリズムを指定する
   427:   public static void pcmSetInterpolationAlgorithm (int algorithm) {
   428:     pcmInterpolationAlgorithm = algorithm;
   429:     pcmInterpolationEngine = (SoundSource.SND_CHANNELS == 1 ? PCM_INTERPOLATION_MONO : PCM_INTERPOLATION_STEREO)
   430:       [algorithm][pcmOSCFreqMode << 3 | pcmOscillator << 2 | pcmDivider];
   431:   }  //pcmSetInterpolationAlgorithm(int)
   432: 
   433:   //pcmSetOutputOn (on)
   434:   //  PCM出力のON/OFF
   435:   public static void pcmSetOutputOn (boolean on) {
   436:     pcmOutputOn = on;
   437:     pcmSetPan (pcmLastPan);
   438:   }  //pcmSetOutputOn(boolean)
   439: 
   440:   //pcmSetPan (pan)
   441:   //  発音するチャンネルの設定
   442:   //  bit0  0=RightON,1=RightOFF
   443:   //  bit1  0=LeftON,1=LeftOFF
   444:   //    0/1,Left/Right共にOPMと逆になっていることに注意
   445:   public static void pcmSetPan (int pan) {
   446:     pcmLastPan = pan;
   447:     boolean on0 = !(pcmPanLeft == 0 || pcmPanLeft < 0x80000000 + PCM_ATTACK_SPAN * 2);  //true=ONまたはOFF→ON,false=OFFまたはON→OFF
   448:     boolean on1 = pcmOutputOn && (SoundSource.SND_CHANNELS == 1 ? (pan & 3) != 3 : (pan & 2) == 0);  //true=ON,false=OFF
   449:     if (on0 != on1) {
   450:       if (on1) {  //OFF→ONまたはON→OFF→ON
   451:         if (pcmPanLeft < 0x80000000 + PCM_ATTACK_SPAN) {  //ON→OFF→ONでON→OFFが終了していない
   452:           pcmPanLeft ^= PCM_ATTACK_SPAN * 2 | PCM_ATTACK_MASK;  //ON→OFFを反転してOFF→ONの途中から
   453:         } else {  //ON→OFF→ONでON→OFFが終了しているか、OFF→ON
   454:           pcmPanLeft = 0x80000000 + PCM_ATTACK_SPAN * 2;  //OFF→ONの最初から
   455:         }
   456:       } else {  //ON→OFF
   457:         if (pcmPanLeft < 0x80000000 + PCM_ATTACK_SPAN * 3) {  //OFF→ON→OFFでOFF→ONが終了していない
   458:           pcmPanLeft ^= PCM_ATTACK_SPAN * 2 | PCM_ATTACK_MASK;  //OFF→ONを反転してON→OFFの途中から
   459:         } else {  //ON→OFF→ONでOFF→ONが終了しているか、ON→OFF
   460:           pcmPanLeft = 0x80000000 + PCM_ATTACK_SPAN * 0;  //ON→OFFの最初から
   461:         }
   462:       }
   463:     }
   464:     if (SoundSource.SND_CHANNELS == 2) {  //ステレオ
   465:       on0 = !(pcmPanRight == 0 || pcmPanRight < 0x80000000 + PCM_ATTACK_SPAN * 2);  //true=ONまたはOFF→ON,false=OFFまたはON→OFF
   466:       on1 = pcmOutputOn && (pan & 1) == 0;  //true=ON,false=OFF
   467:       if (on0 != on1) {
   468:         if (on1) {  //OFF→ONまたはON→OFF→ON
   469:           if (pcmPanRight < 0x80000000 + PCM_ATTACK_SPAN) {  //ON→OFF→ONでON→OFFが終了していない
   470:             pcmPanRight ^= PCM_ATTACK_SPAN * 2 | PCM_ATTACK_MASK;  //ON→OFFを反転してOFF→ONの途中から
   471:           } else {  //ON→OFF→ONでON→OFFが終了しているか、OFF→ON
   472:             pcmPanRight = 0x80000000 + PCM_ATTACK_SPAN * 2;  //OFF→ONの最初から
   473:           }
   474:         } else {  //ON→OFF
   475:           if (pcmPanRight < 0x80000000 + PCM_ATTACK_SPAN * 3) {  //OFF→ON→OFFでOFF→ONが終了していない
   476:             pcmPanRight ^= PCM_ATTACK_SPAN * 2 | PCM_ATTACK_MASK;  //OFF→ONを反転してON→OFFの途中から
   477:           } else {  //ON→OFF→ONでOFF→ONが終了しているか、ON→OFF
   478:             pcmPanRight = 0x80000000 + PCM_ATTACK_SPAN * 0;  //ON→OFFの最初から
   479:           }
   480:         }
   481:       }
   482:     }
   483:   }  //pcmSetPan(int)
   484: 
   485:   //pcmFillBuffer (endPointer)
   486:   public static void pcmFillBuffer (int endPointer) {
   487:     while (pcmPointer < endPointer && (pcmDecodedData1 | pcmDecodedData2 | pcmDecodedData3) != 0) {
   488:       if (PCM_DECAY_ON) {  //減衰させる
   489:         int m = pcmDecodedData1;
   490:         pcmInterpolationEngine.write (m + (m >>> 31) - (-m >>> 31));
   491:       } else {  //減衰させない
   492:         pcmInterpolationEngine.write (0);
   493:       }
   494:     }
   495:     if (pcmPointer < endPointer) {  //残りは無音
   496:       Arrays.fill (pcmBuffer, pcmPointer, endPointer, 0);
   497:       pcmPointer = endPointer;
   498:     } else if (endPointer < pcmPointer) {  //進み過ぎたので戻る
   499:       Arrays.fill (pcmBuffer, endPointer, pcmPointer, 0);
   500:       pcmPointer = endPointer;
   501:     }
   502:   }  //pcmFillBuffer
   503: 
   504: 
   505: 
   506:   //PIP PCM補間エンジン
   507:   public static enum PIP {
   508: 
   509:     //モノラル 区分定数補間 3906.25Hz
   510:     PIP_MONO_CONSTANT_16 {
   511:       @Override public void write (int m) {
   512:         int i = pcmPointer;
   513:         int p = pcmPanLeft;
   514:         if (p > 0) {  //ON
   515:           pcmBuffer[  i     ] = (
   516:             pcmBuffer[i +  1] =
   517:             pcmBuffer[i +  2] =
   518:             pcmBuffer[i +  3] =
   519:             pcmBuffer[i +  4] =
   520:             pcmBuffer[i +  5] =
   521:             pcmBuffer[i +  6] =
   522:             pcmBuffer[i +  7] =
   523:             pcmBuffer[i +  8] =
   524:             pcmBuffer[i +  9] =
   525:             pcmBuffer[i + 10] =
   526:             pcmBuffer[i + 11] =
   527:             pcmBuffer[i + 12] =
   528:             pcmBuffer[i + 13] =
   529:             pcmBuffer[i + 14] =
   530:             pcmBuffer[i + 15] = m);
   531:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   532:           p = (char) p;
   533:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   534:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   535:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  2] >> 14;
   536:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  3] >> 14;
   537:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  4] >> 14;
   538:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  5] >> 14;
   539:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  6] >> 14;
   540:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  7] >> 14;
   541:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  8] >> 14;
   542:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  9] >> 14;
   543:           pcmBuffer[i + 10] = m * pcmAttackCurve[p + 10] >> 14;
   544:           pcmBuffer[i + 11] = m * pcmAttackCurve[p + 11] >> 14;
   545:           pcmBuffer[i + 12] = m * pcmAttackCurve[p + 12] >> 14;
   546:           pcmBuffer[i + 13] = m * pcmAttackCurve[p + 13] >> 14;
   547:           pcmBuffer[i + 14] = m * pcmAttackCurve[p + 14] >> 14;
   548:           pcmBuffer[i + 15] = m * pcmAttackCurve[p + 15] >> 14;
   549:           p += 16;
   550:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   551:         } else {  //OFF
   552:           pcmBuffer[  i     ] = (
   553:             pcmBuffer[i +  1] =
   554:             pcmBuffer[i +  2] =
   555:             pcmBuffer[i +  3] =
   556:             pcmBuffer[i +  4] =
   557:             pcmBuffer[i +  5] =
   558:             pcmBuffer[i +  6] =
   559:             pcmBuffer[i +  7] =
   560:             pcmBuffer[i +  8] =
   561:             pcmBuffer[i +  9] =
   562:             pcmBuffer[i + 10] =
   563:             pcmBuffer[i + 11] =
   564:             pcmBuffer[i + 12] =
   565:             pcmBuffer[i + 13] =
   566:             pcmBuffer[i + 14] =
   567:             pcmBuffer[i + 15] = 0);
   568:         }
   569:         pcmDecodedData1 = m;
   570:         pcmPointer = i + 16;
   571:       }
   572:     },  //PIP_MONO_CONSTANT_16
   573: 
   574:     //モノラル 区分定数補間 5208.33Hz
   575:     PIP_MONO_CONSTANT_12 {
   576:       @Override public void write (int m) {
   577:         int i = pcmPointer;
   578:         int p = pcmPanLeft;
   579:         if (p > 0) {  //ON
   580:           pcmBuffer[  i     ] = (
   581:             pcmBuffer[i +  1] =
   582:             pcmBuffer[i +  2] =
   583:             pcmBuffer[i +  3] =
   584:             pcmBuffer[i +  4] =
   585:             pcmBuffer[i +  5] =
   586:             pcmBuffer[i +  6] =
   587:             pcmBuffer[i +  7] =
   588:             pcmBuffer[i +  8] =
   589:             pcmBuffer[i +  9] =
   590:             pcmBuffer[i + 10] =
   591:             pcmBuffer[i + 11] = m);
   592:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   593:           p = (char) p;
   594:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   595:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   596:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  2] >> 14;
   597:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  3] >> 14;
   598:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  4] >> 14;
   599:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  5] >> 14;
   600:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  6] >> 14;
   601:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  7] >> 14;
   602:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  8] >> 14;
   603:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  9] >> 14;
   604:           pcmBuffer[i + 10] = m * pcmAttackCurve[p + 10] >> 14;
   605:           pcmBuffer[i + 11] = m * pcmAttackCurve[p + 11] >> 14;
   606:           p += 12;
   607:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   608:         } else {  //OFF
   609:           pcmBuffer[  i     ] = (
   610:             pcmBuffer[i +  1] =
   611:             pcmBuffer[i +  2] =
   612:             pcmBuffer[i +  3] =
   613:             pcmBuffer[i +  4] =
   614:             pcmBuffer[i +  5] =
   615:             pcmBuffer[i +  6] =
   616:             pcmBuffer[i +  7] =
   617:             pcmBuffer[i +  8] =
   618:             pcmBuffer[i +  9] =
   619:             pcmBuffer[i + 10] =
   620:             pcmBuffer[i + 11] = 0);
   621:         }
   622:         pcmDecodedData1 = m;
   623:         pcmPointer = i + 12;
   624:       }
   625:     },  //PIP_MONO_CONSTANT_12
   626: 
   627:     //モノラル 区分定数補間 7812.50Hz
   628:     PIP_MONO_CONSTANT_8 {
   629:       @Override public void write (int m) {
   630:         int i = pcmPointer;
   631:         int p = pcmPanLeft;
   632:         if (p > 0) {  //ON
   633:           pcmBuffer[  i     ] = (
   634:             pcmBuffer[i +  1] =
   635:             pcmBuffer[i +  2] =
   636:             pcmBuffer[i +  3] =
   637:             pcmBuffer[i +  4] =
   638:             pcmBuffer[i +  5] =
   639:             pcmBuffer[i +  6] =
   640:             pcmBuffer[i +  7] = m);
   641:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   642:           p = (char) p;
   643:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   644:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   645:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  2] >> 14;
   646:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  3] >> 14;
   647:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  4] >> 14;
   648:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  5] >> 14;
   649:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  6] >> 14;
   650:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  7] >> 14;
   651:           p += 8;
   652:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   653:         } else {  //OFF
   654:           pcmBuffer[  i     ] = (
   655:             pcmBuffer[i +  1] =
   656:             pcmBuffer[i +  2] =
   657:             pcmBuffer[i +  3] =
   658:             pcmBuffer[i +  4] =
   659:             pcmBuffer[i +  5] =
   660:             pcmBuffer[i +  6] =
   661:             pcmBuffer[i +  7] = 0);
   662:         }
   663:         pcmDecodedData1 = m;
   664:         pcmPointer = i + 8;
   665:       }
   666:     },  //PIP_MONO_CONSTANT_8
   667: 
   668:     //モノラル 区分定数補間 10416.67Hz
   669:     PIP_MONO_CONSTANT_6 {
   670:       @Override public void write (int m) {
   671:         int i = pcmPointer;
   672:         int p = pcmPanLeft;
   673:         if (p > 0) {  //ON
   674:           pcmBuffer[  i     ] = (
   675:             pcmBuffer[i +  1] =
   676:             pcmBuffer[i +  2] =
   677:             pcmBuffer[i +  3] =
   678:             pcmBuffer[i +  4] =
   679:             pcmBuffer[i +  5] = m);
   680:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   681:           p = (char) p;
   682:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   683:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   684:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  2] >> 14;
   685:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  3] >> 14;
   686:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  4] >> 14;
   687:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  5] >> 14;
   688:           p += 6;
   689:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   690:         } else {  //OFF
   691:           pcmBuffer[  i     ] = (
   692:             pcmBuffer[i +  1] =
   693:             pcmBuffer[i +  2] =
   694:             pcmBuffer[i +  3] =
   695:             pcmBuffer[i +  4] =
   696:             pcmBuffer[i +  5] = 0);
   697:         }
   698:         pcmDecodedData1 = m;
   699:         pcmPointer = i + 6;
   700:       }
   701:     },  //PIP_MONO_CONSTANT_6
   702: 
   703:     //モノラル 区分定数補間 15625.00Hz
   704:     PIP_MONO_CONSTANT_4 {
   705:       @Override public void write (int m) {
   706:         int i = pcmPointer;
   707:         int p = pcmPanLeft;
   708:         if (p > 0) {  //ON
   709:           pcmBuffer[  i     ] = (
   710:             pcmBuffer[i +  1] =
   711:             pcmBuffer[i +  2] =
   712:             pcmBuffer[i +  3] = m);
   713:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   714:           p = (char) p;
   715:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   716:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   717:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  2] >> 14;
   718:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  3] >> 14;
   719:           p += 4;
   720:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   721:         } else {  //OFF
   722:           pcmBuffer[  i     ] = (
   723:             pcmBuffer[i +  1] =
   724:             pcmBuffer[i +  2] =
   725:             pcmBuffer[i +  3] = 0);
   726:         }
   727:         pcmDecodedData1 = m;
   728:         pcmPointer = i + 4;
   729:       }
   730:     },  //PIP_MONO_CONSTANT_4
   731: 
   732:     //モノラル 区分定数補間 20833.33Hz
   733:     PIP_MONO_CONSTANT_3 {
   734:       @Override public void write (int m) {
   735:         int i = pcmPointer;
   736:         int p = pcmPanLeft;
   737:         if (p > 0) {  //ON
   738:           pcmBuffer[  i     ] = (
   739:             pcmBuffer[i +  1] =
   740:             pcmBuffer[i +  2] = m);
   741:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   742:           p = (char) p;
   743:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   744:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   745:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  2] >> 14;
   746:           p += 3;
   747:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   748:         } else {  //OFF
   749:           pcmBuffer[  i     ] = (
   750:             pcmBuffer[i +  1] =
   751:             pcmBuffer[i +  2] = 0);
   752:         }
   753:         pcmDecodedData1 = m;
   754:         pcmPointer = i + 3;
   755:       }
   756:     },  //PIP_MONO_CONSTANT_3
   757: 
   758:     //モノラル 区分定数補間 31250.00Hz
   759:     PIP_MONO_CONSTANT_2 {
   760:       @Override public void write (int m) {
   761:         int i = pcmPointer;
   762:         int p = pcmPanLeft;
   763:         if (p > 0) {  //ON
   764:           pcmBuffer[  i     ] = (
   765:             pcmBuffer[i +  1] = m);
   766:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   767:           p = (char) p;
   768:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   769:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   770:           p += 2;
   771:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   772:         } else {  //OFF
   773:           pcmBuffer[  i     ] = (
   774:             pcmBuffer[i +  1] = 0);
   775:         }
   776:         pcmDecodedData1 = m;
   777:         pcmPointer = i + 2;
   778:       }
   779:     },  //PIP_MONO_CONSTANT_2
   780: 
   781:     //モノラル 線形補間 3906.25Hz
   782:     PIP_MONO_LINEAR_16 {
   783:       @Override public void write (int m1) {
   784:         int i = pcmPointer;
   785:         int p = pcmPanLeft;
   786:         if (p > 0) {  //ON
   787:           int m0 = pcmDecodedData1;
   788:           pcmBuffer[i     ] = 15 * m0 +      m1 >> 4;
   789:           pcmBuffer[i +  1] =  7 * m0 +      m1 >> 3;
   790:           pcmBuffer[i +  2] = 13 * m0 +  3 * m1 >> 4;
   791:           pcmBuffer[i +  3] =  3 * m0 +      m1 >> 2;
   792:           pcmBuffer[i +  4] = 11 * m0 +  5 * m1 >> 4;
   793:           pcmBuffer[i +  5] =  5 * m0 +  3 * m1 >> 3;
   794:           pcmBuffer[i +  6] =  9 * m0 +  7 * m1 >> 4;
   795:           pcmBuffer[i +  7] =      m0 +      m1 >> 1;
   796:           pcmBuffer[i +  8] =  7 * m0 +  9 * m1 >> 4;
   797:           pcmBuffer[i +  9] =  3 * m0 +  5 * m1 >> 3;
   798:           pcmBuffer[i + 10] =  5 * m0 + 11 * m1 >> 4;
   799:           pcmBuffer[i + 11] =      m0 +  3 * m1 >> 2;
   800:           pcmBuffer[i + 12] =  3 * m0 + 13 * m1 >> 4;
   801:           pcmBuffer[i + 13] =      m0 +  7 * m1 >> 3;
   802:           pcmBuffer[i + 14] =      m0 + 15 * m1 >> 4;
   803:           pcmBuffer[i + 15] =                m1;
   804:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   805:           p = (char) p;
   806:           int m0 = pcmDecodedData1;
   807:           pcmBuffer[i     ] = (15 * m0 +      m1 >> 4) * pcmAttackCurve[p     ] >> 14;
   808:           pcmBuffer[i +  1] = ( 7 * m0 +      m1 >> 3) * pcmAttackCurve[p +  1] >> 14;
   809:           pcmBuffer[i +  2] = (13 * m0 +  3 * m1 >> 4) * pcmAttackCurve[p +  2] >> 14;
   810:           pcmBuffer[i +  3] = ( 3 * m0 +      m1 >> 2) * pcmAttackCurve[p +  3] >> 14;
   811:           pcmBuffer[i +  4] = (11 * m0 +  5 * m1 >> 4) * pcmAttackCurve[p +  4] >> 14;
   812:           pcmBuffer[i +  5] = ( 5 * m0 +  3 * m1 >> 3) * pcmAttackCurve[p +  5] >> 14;
   813:           pcmBuffer[i +  6] = ( 9 * m0 +  7 * m1 >> 4) * pcmAttackCurve[p +  6] >> 14;
   814:           pcmBuffer[i +  7] = (     m0 +      m1 >> 1) * pcmAttackCurve[p +  7] >> 14;
   815:           pcmBuffer[i +  8] = ( 7 * m0 +  9 * m1 >> 4) * pcmAttackCurve[p +  8] >> 14;
   816:           pcmBuffer[i +  9] = ( 3 * m0 +  5 * m1 >> 3) * pcmAttackCurve[p +  9] >> 14;
   817:           pcmBuffer[i + 10] = ( 5 * m0 + 11 * m1 >> 4) * pcmAttackCurve[p + 10] >> 14;
   818:           pcmBuffer[i + 11] = (     m0 +  3 * m1 >> 2) * pcmAttackCurve[p + 11] >> 14;
   819:           pcmBuffer[i + 12] = ( 3 * m0 + 13 * m1 >> 4) * pcmAttackCurve[p + 12] >> 14;
   820:           pcmBuffer[i + 13] = (     m0 +  7 * m1 >> 3) * pcmAttackCurve[p + 13] >> 14;
   821:           pcmBuffer[i + 14] = (     m0 + 15 * m1 >> 4) * pcmAttackCurve[p + 14] >> 14;
   822:           pcmBuffer[i + 15] = (               m1     ) * pcmAttackCurve[p + 15] >> 14;
   823:           p += 16;
   824:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   825:         } else {  //OFF
   826:           pcmBuffer[  i     ] = (
   827:             pcmBuffer[i +  1] =
   828:             pcmBuffer[i +  2] =
   829:             pcmBuffer[i +  3] =
   830:             pcmBuffer[i +  4] =
   831:             pcmBuffer[i +  5] =
   832:             pcmBuffer[i +  6] =
   833:             pcmBuffer[i +  7] =
   834:             pcmBuffer[i +  8] =
   835:             pcmBuffer[i +  9] =
   836:             pcmBuffer[i + 10] =
   837:             pcmBuffer[i + 11] =
   838:             pcmBuffer[i + 12] =
   839:             pcmBuffer[i + 13] =
   840:             pcmBuffer[i + 14] =
   841:             pcmBuffer[i + 15] = 0);
   842:         }
   843:         pcmDecodedData1 = m1;
   844:         pcmPointer = i + 16;
   845:       }
   846:     },  //PIP_MONO_LINEAR_16
   847: 
   848:     //モノラル 線形補間 5208.33Hz
   849:     PIP_MONO_LINEAR_12 {
   850:       @Override public void write (int m1) {
   851:         int i = pcmPointer;
   852:         int p = pcmPanLeft;
   853:         if (p > 0) {  //ON
   854:           int m0 = pcmDecodedData1;
   855:           pcmBuffer[i     ] = 65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16;
   856:           pcmBuffer[i +  1] = 65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16;
   857:           pcmBuffer[i +  2] =          3      * m0 +                   m1 >>  2;
   858:           pcmBuffer[i +  3] = 65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16;
   859:           pcmBuffer[i +  4] = 65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16;
   860:           pcmBuffer[i +  5] =                   m0 +                   m1 >>  1;
   861:           pcmBuffer[i +  6] = 65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16;
   862:           pcmBuffer[i +  7] = 65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16;
   863:           pcmBuffer[i +  8] =                   m0 +          3      * m1 >>  2;
   864:           pcmBuffer[i +  9] = 65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16;
   865:           pcmBuffer[i + 10] = 65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16;
   866:           pcmBuffer[i + 11] =                                          m1;
   867:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   868:           p = (char) p;
   869:           int m0 = pcmDecodedData1;
   870:           pcmBuffer[i     ] = (65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16) * pcmAttackCurve[p     ] >> 14;
   871:           pcmBuffer[i +  1] = (65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16) * pcmAttackCurve[p +  1] >> 14;
   872:           pcmBuffer[i +  2] = (         3      * m0 +                   m1 >>  2) * pcmAttackCurve[p +  2] >> 14;
   873:           pcmBuffer[i +  3] = (65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16) * pcmAttackCurve[p +  3] >> 14;
   874:           pcmBuffer[i +  4] = (65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16) * pcmAttackCurve[p +  4] >> 14;
   875:           pcmBuffer[i +  5] = (                  m0 +                   m1 >>  1) * pcmAttackCurve[p +  5] >> 14;
   876:           pcmBuffer[i +  6] = (65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16) * pcmAttackCurve[p +  6] >> 14;
   877:           pcmBuffer[i +  7] = (65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16) * pcmAttackCurve[p +  7] >> 14;
   878:           pcmBuffer[i +  8] = (                  m0 +          3      * m1 >>  2) * pcmAttackCurve[p +  8] >> 14;
   879:           pcmBuffer[i +  9] = (65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16) * pcmAttackCurve[p +  9] >> 14;
   880:           pcmBuffer[i + 10] = (65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16) * pcmAttackCurve[p + 10] >> 14;
   881:           pcmBuffer[i + 11] = (                                         m1      ) * pcmAttackCurve[p + 11] >> 14;
   882:           p += 12;
   883:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   884:         } else {  //OFF
   885:           pcmBuffer[  i     ] = (
   886:             pcmBuffer[i +  1] =
   887:             pcmBuffer[i +  2] =
   888:             pcmBuffer[i +  3] =
   889:             pcmBuffer[i +  4] =
   890:             pcmBuffer[i +  5] =
   891:             pcmBuffer[i +  6] =
   892:             pcmBuffer[i +  7] =
   893:             pcmBuffer[i +  8] =
   894:             pcmBuffer[i +  9] =
   895:             pcmBuffer[i + 10] =
   896:             pcmBuffer[i + 11] = 0);
   897:         }
   898:         pcmDecodedData1 = m1;
   899:         pcmPointer = i + 12;
   900:       }
   901:     },  //PIP_MONO_LINEAR_12
   902: 
   903:     //モノラル 線形補間 7812.50Hz
   904:     PIP_MONO_LINEAR_8 {
   905:       @Override public void write (int m1) {
   906:         int i = pcmPointer;
   907:         int p = pcmPanLeft;
   908:         if (p > 0) {  //ON
   909:           int m0 = pcmDecodedData1;
   910:           pcmBuffer[i    ] = 7 * m0 +     m1 >> 3;
   911:           pcmBuffer[i + 1] = 3 * m0 +     m1 >> 2;
   912:           pcmBuffer[i + 2] = 5 * m0 + 3 * m1 >> 3;
   913:           pcmBuffer[i + 3] =     m0 +     m1 >> 1;
   914:           pcmBuffer[i + 4] = 3 * m0 + 5 * m1 >> 3;
   915:           pcmBuffer[i + 5] =     m0 + 3 * m1 >> 2;
   916:           pcmBuffer[i + 6] =     m0 + 7 * m1 >> 3;
   917:           pcmBuffer[i + 7] =              m1;
   918:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   919:           p = (char) p;
   920:           int m0 = pcmDecodedData1;
   921:           pcmBuffer[i    ] = (7 * m0 +     m1 >> 3) * pcmAttackCurve[p    ] >> 14;
   922:           pcmBuffer[i + 1] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p + 1] >> 14;
   923:           pcmBuffer[i + 2] = (5 * m0 + 3 * m1 >> 3) * pcmAttackCurve[p + 2] >> 14;
   924:           pcmBuffer[i + 3] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 3] >> 14;
   925:           pcmBuffer[i + 4] = (3 * m0 + 5 * m1 >> 3) * pcmAttackCurve[p + 4] >> 14;
   926:           pcmBuffer[i + 5] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 5] >> 14;
   927:           pcmBuffer[i + 6] = (    m0 + 7 * m1 >> 3) * pcmAttackCurve[p + 6] >> 14;
   928:           pcmBuffer[i + 7] = (             m1     ) * pcmAttackCurve[p + 7] >> 14;
   929:           p += 8;
   930:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   931:         } else {  //OFF
   932:           pcmBuffer[  i    ] = (
   933:             pcmBuffer[i + 1] =
   934:             pcmBuffer[i + 2] =
   935:             pcmBuffer[i + 3] =
   936:             pcmBuffer[i + 4] =
   937:             pcmBuffer[i + 5] =
   938:             pcmBuffer[i + 6] =
   939:             pcmBuffer[i + 7] = 0);
   940:         }
   941:         pcmDecodedData1 = m1;
   942:         pcmPointer = i + 8;
   943:       }
   944:     },  //PIP_MONO_LINEAR_8
   945: 
   946:     //モノラル 線形補間 10416.67Hz
   947:     PIP_MONO_LINEAR_6 {
   948:       @Override public void write (int m1) {
   949:         int i = pcmPointer;
   950:         int p = pcmPanLeft;
   951:         if (p > 0) {  //ON
   952:           int m0 = pcmDecodedData1;
   953:           pcmBuffer[i    ] = 65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16;
   954:           pcmBuffer[i + 1] = 65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16;
   955:           pcmBuffer[i + 2] =                 m0 +                 m1 >>  1;
   956:           pcmBuffer[i + 3] = 65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16;
   957:           pcmBuffer[i + 4] = 65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16;
   958:           pcmBuffer[i + 5] =                                      m1;
   959:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   960:           p = (char) p;
   961:           int m0 = pcmDecodedData1;
   962:           pcmBuffer[i    ] = (65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
   963:           pcmBuffer[i + 1] = (65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
   964:           pcmBuffer[i + 2] = (                m0 +                 m1 >>  1) * pcmAttackCurve[p + 2] >> 14;
   965:           pcmBuffer[i + 3] = (65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16) * pcmAttackCurve[p + 3] >> 14;
   966:           pcmBuffer[i + 4] = (65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16) * pcmAttackCurve[p + 4] >> 14;
   967:           pcmBuffer[i + 5] = (                                     m1      ) * pcmAttackCurve[p + 5] >> 14;
   968:           p += 6;
   969:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   970:         } else {  //OFF
   971:           pcmBuffer[  i    ] = (
   972:             pcmBuffer[i + 1] =
   973:             pcmBuffer[i + 2] =
   974:             pcmBuffer[i + 3] =
   975:             pcmBuffer[i + 4] =
   976:             pcmBuffer[i + 5] = 0);
   977:         }
   978:         pcmDecodedData1 = m1;
   979:         pcmPointer = i + 6;
   980:       }
   981:     },  //PIP_MONO_LINEAR_6
   982: 
   983:     //モノラル 線形補間 15625.00Hz
   984:     PIP_MONO_LINEAR_4 {
   985:       @Override public void write (int m1) {
   986:         int i = pcmPointer;
   987:         int p = pcmPanLeft;
   988:         if (p > 0) {  //ON
   989:           int m0 = pcmDecodedData1;
   990:           pcmBuffer[i    ] = 3 * m0 +     m1 >> 2;
   991:           pcmBuffer[i + 1] =     m0 +     m1 >> 1;
   992:           pcmBuffer[i + 2] =     m0 + 3 * m1 >> 2;
   993:           pcmBuffer[i + 3] =              m1;
   994:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   995:           p = (char) p;
   996:           int m0 = pcmDecodedData1;
   997:           pcmBuffer[i    ] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p    ] >> 14;
   998:           pcmBuffer[i + 1] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 1] >> 14;
   999:           pcmBuffer[i + 2] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 2] >> 14;
  1000:           pcmBuffer[i + 3] = (             m1     ) * pcmAttackCurve[p + 3] >> 14;
  1001:           p += 4;
  1002:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1003:         } else {  //OFF
  1004:           pcmBuffer[  i    ] = (
  1005:             pcmBuffer[i + 1] =
  1006:             pcmBuffer[i + 2] =
  1007:             pcmBuffer[i + 3] = 0);
  1008:         }
  1009:         pcmDecodedData1 = m1;
  1010:         pcmPointer = i + 4;
  1011:       }
  1012:     },  //PIP_MONO_LINEAR_4
  1013: 
  1014:     //モノラル 線形補間 20833.33Hz
  1015:     PIP_MONO_LINEAR_3 {
  1016:       @Override public void write (int m1) {
  1017:         int i = pcmPointer;
  1018:         int p = pcmPanLeft;
  1019:         if (p > 0) {  //ON
  1020:           int m0 = pcmDecodedData1;
  1021:           pcmBuffer[i    ] = 65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16;
  1022:           pcmBuffer[i + 1] = 65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16;
  1023:           pcmBuffer[i + 2] =                                      m1;
  1024:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1025:           p = (char) p;
  1026:           int m0 = pcmDecodedData1;
  1027:           pcmBuffer[i    ] = (65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  1028:           pcmBuffer[i + 1] = (65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  1029:           pcmBuffer[i + 2] = (                                     m1      ) * pcmAttackCurve[p + 2] >> 14;
  1030:           p += 3;
  1031:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1032:         } else {  //OFF
  1033:           pcmBuffer[  i    ] = (
  1034:             pcmBuffer[i + 1] =
  1035:             pcmBuffer[i + 2] = 0);
  1036:         }
  1037:         pcmDecodedData1 = m1;
  1038:         pcmPointer = i + 3;
  1039:       }
  1040:     },  //PIP_MONO_LINEAR_3
  1041: 
  1042:     //モノラル 線形補間 31250.00Hz
  1043:     PIP_MONO_LINEAR_2 {
  1044:       @Override public void write (int m1) {
  1045:         int i = pcmPointer;
  1046:         int p = pcmPanLeft;
  1047:         if (p > 0) {  //ON
  1048:           int m0 = pcmDecodedData1;
  1049:           pcmBuffer[i    ] = m0 + m1 >> 1;
  1050:           pcmBuffer[i + 1] =      m1;
  1051:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1052:           p = (char) p;
  1053:           int m0 = pcmDecodedData1;
  1054:           pcmBuffer[i    ] = (m0 + m1 >> 1) * pcmAttackCurve[p    ] >> 14;
  1055:           pcmBuffer[i + 1] = (     m1     ) * pcmAttackCurve[p + 1] >> 14;
  1056:           p += 2;
  1057:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1058:         } else {  //OFF
  1059:           pcmBuffer[  i    ] = (
  1060:             pcmBuffer[i + 1] = 0);
  1061:         }
  1062:         pcmDecodedData1 = m1;
  1063:         pcmPointer = i + 2;
  1064:       }
  1065:     },  //PIP_MONO_LINEAR_2
  1066: 
  1067:     //モノラル エルミート補間 3906.25Hz
  1068:     PIP_MONO_HERMITE_16 {
  1069:       @Override public void write (int m2) {
  1070:         //  echo read("hermite.gp");hermite_code(1,16) | gp-2.7 -q
  1071:         int i = pcmPointer;
  1072:         int mm = pcmDecodedData3;
  1073:         int m0 = pcmDecodedData2;
  1074:         int m1 = pcmDecodedData1;
  1075:         int p = pcmPanLeft;
  1076:         if (p > 0) {  //ON
  1077:           pcmBuffer[i     ] =          -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13;
  1078:           pcmBuffer[i +  1] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  1079:           pcmBuffer[i +  2] =          -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13;
  1080:           pcmBuffer[i +  3] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  1081:           pcmBuffer[i +  4] =          -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13;
  1082:           pcmBuffer[i +  5] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  1083:           pcmBuffer[i +  6] =          -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13;
  1084:           pcmBuffer[i +  7] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1085:           pcmBuffer[i +  8] =          -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13;
  1086:           pcmBuffer[i +  9] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  1087:           pcmBuffer[i + 10] =          -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13;
  1088:           pcmBuffer[i + 11] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  1089:           pcmBuffer[i + 12] =          -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13;
  1090:           pcmBuffer[i + 13] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  1091:           pcmBuffer[i + 14] =           -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13;
  1092:           pcmBuffer[i + 15] =                                         m1;
  1093:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1094:           p = (char) p;
  1095:           pcmBuffer[i     ] = (         -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13) * pcmAttackCurve[p     ] >> 14;
  1096:           pcmBuffer[i +  1] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p +  1] >> 14;
  1097:           pcmBuffer[i +  2] = (         -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13) * pcmAttackCurve[p +  2] >> 14;
  1098:           pcmBuffer[i +  3] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p +  3] >> 14;
  1099:           pcmBuffer[i +  4] = (         -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13) * pcmAttackCurve[p +  4] >> 14;
  1100:           pcmBuffer[i +  5] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p +  5] >> 14;
  1101:           pcmBuffer[i +  6] = (         -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13) * pcmAttackCurve[p +  6] >> 14;
  1102:           pcmBuffer[i +  7] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p +  7] >> 14;
  1103:           pcmBuffer[i +  8] = (         -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13) * pcmAttackCurve[p +  8] >> 14;
  1104:           pcmBuffer[i +  9] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p +  9] >> 14;
  1105:           pcmBuffer[i + 10] = (         -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13) * pcmAttackCurve[p + 10] >> 14;
  1106:           pcmBuffer[i + 11] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 11] >> 14;
  1107:           pcmBuffer[i + 12] = (         -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13) * pcmAttackCurve[p + 12] >> 14;
  1108:           pcmBuffer[i + 13] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 13] >> 14;
  1109:           pcmBuffer[i + 14] = (          -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13) * pcmAttackCurve[p + 14] >> 14;
  1110:           pcmBuffer[i + 15] = (                                        m1                  ) * pcmAttackCurve[p + 15] >> 14;
  1111:           p += 16;
  1112:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1113:         } else {  //OFF
  1114:           pcmBuffer[  i     ] = (
  1115:             pcmBuffer[i +  1] =
  1116:             pcmBuffer[i +  2] =
  1117:             pcmBuffer[i +  3] =
  1118:             pcmBuffer[i +  4] =
  1119:             pcmBuffer[i +  5] =
  1120:             pcmBuffer[i +  6] =
  1121:             pcmBuffer[i +  7] =
  1122:             pcmBuffer[i +  8] =
  1123:             pcmBuffer[i +  9] =
  1124:             pcmBuffer[i + 10] =
  1125:             pcmBuffer[i + 11] =
  1126:             pcmBuffer[i + 12] =
  1127:             pcmBuffer[i + 13] =
  1128:             pcmBuffer[i + 14] =
  1129:             pcmBuffer[i + 15] = 0);
  1130:         }
  1131:         pcmDecodedData3 = m0;
  1132:         pcmDecodedData2 = m1;
  1133:         pcmDecodedData1 = m2;
  1134:         pcmPointer = i + 16;
  1135:       }
  1136:     },  //PIP_MONO_HERMITE_16
  1137: 
  1138:     //モノラル エルミート補間 5208.33Hz
  1139:     PIP_MONO_HERMITE_12 {
  1140:       @Override public void write (int m2) {
  1141:         //  echo read("hermite.gp");hermite_code(1,12) | gp-2.7 -q
  1142:         int i = pcmPointer;
  1143:         int mm = pcmDecodedData3;
  1144:         int m0 = pcmDecodedData2;
  1145:         int m1 = pcmDecodedData1;
  1146:         int p = pcmPanLeft;
  1147:         if (p > 0) {  //ON
  1148:           pcmBuffer[i     ] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32);
  1149:           pcmBuffer[i +  1] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  1150:           pcmBuffer[i +  2] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  1151:           pcmBuffer[i +  3] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  1152:           pcmBuffer[i +  4] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32);
  1153:           pcmBuffer[i +  5] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1154:           pcmBuffer[i +  6] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32);
  1155:           pcmBuffer[i +  7] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  1156:           pcmBuffer[i +  8] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  1157:           pcmBuffer[i +  9] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  1158:           pcmBuffer[i + 10] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32);
  1159:           pcmBuffer[i + 11] =                                         m1;
  1160:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1161:           p = (char) p;
  1162:           pcmBuffer[i     ] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32) * pcmAttackCurve[p     ] >> 14;
  1163:           pcmBuffer[i +  1] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  1] >> 14;
  1164:           pcmBuffer[i +  2] =       (    -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7               ) * pcmAttackCurve[p +  2] >> 14;
  1165:           pcmBuffer[i +  3] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p +  3] >> 14;
  1166:           pcmBuffer[i +  4] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  4] >> 14;
  1167:           pcmBuffer[i +  5] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p +  5] >> 14;
  1168:           pcmBuffer[i +  6] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  6] >> 14;
  1169:           pcmBuffer[i +  7] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p +  7] >> 14;
  1170:           pcmBuffer[i +  8] =       (    -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7               ) * pcmAttackCurve[p +  8] >> 14;
  1171:           pcmBuffer[i +  9] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  9] >> 14;
  1172:           pcmBuffer[i + 10] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32) * pcmAttackCurve[p + 10] >> 14;
  1173:           pcmBuffer[i + 11] =       (                                 m1                                 ) * pcmAttackCurve[p + 11] >> 14;
  1174:           p += 12;
  1175:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1176:         } else {  //OFF
  1177:           pcmBuffer[  i     ] = (
  1178:             pcmBuffer[i +  1] =
  1179:             pcmBuffer[i +  2] =
  1180:             pcmBuffer[i +  3] =
  1181:             pcmBuffer[i +  4] =
  1182:             pcmBuffer[i +  5] =
  1183:             pcmBuffer[i +  6] =
  1184:             pcmBuffer[i +  7] =
  1185:             pcmBuffer[i +  8] =
  1186:             pcmBuffer[i +  9] =
  1187:             pcmBuffer[i + 10] =
  1188:             pcmBuffer[i + 11] = 0);
  1189:         }
  1190:         pcmDecodedData3 = m0;
  1191:         pcmDecodedData2 = m1;
  1192:         pcmDecodedData1 = m2;
  1193:         pcmPointer = i + 12;
  1194:       }
  1195:     },  //PIP_MONO_HERMITE_12
  1196: 
  1197:     //モノラル エルミート補間 7812.50Hz
  1198:     PIP_MONO_HERMITE_8 {
  1199:       @Override public void write (int m2) {
  1200:         //  echo read("hermite.gp");hermite_code(1,8) | gp-2.7 -q
  1201:         int i = pcmPointer;
  1202:         int mm = pcmDecodedData3;
  1203:         int m0 = pcmDecodedData2;
  1204:         int m1 = pcmDecodedData1;
  1205:         int p = pcmPanLeft;
  1206:         if (p > 0) {  //ON
  1207:           pcmBuffer[i    ] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  1208:           pcmBuffer[i + 1] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  1209:           pcmBuffer[i + 2] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  1210:           pcmBuffer[i + 3] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1211:           pcmBuffer[i + 4] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  1212:           pcmBuffer[i + 5] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  1213:           pcmBuffer[i + 6] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  1214:           pcmBuffer[i + 7] =                                         m1;
  1215:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1216:           p = (char) p;
  1217:           pcmBuffer[i    ] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p    ] >> 14;
  1218:           pcmBuffer[i + 1] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p + 1] >> 14;
  1219:           pcmBuffer[i + 2] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p + 2] >> 14;
  1220:           pcmBuffer[i + 3] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 3] >> 14;
  1221:           pcmBuffer[i + 4] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p + 4] >> 14;
  1222:           pcmBuffer[i + 5] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 5] >> 14;
  1223:           pcmBuffer[i + 6] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 6] >> 14;
  1224:           pcmBuffer[i + 7] = (                                        m1                  ) * pcmAttackCurve[p + 7] >> 14;
  1225:           p += 8;
  1226:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1227:         } else {  //OFF
  1228:           pcmBuffer[  i     ] = (
  1229:             pcmBuffer[i +  1] =
  1230:             pcmBuffer[i +  2] =
  1231:             pcmBuffer[i +  3] =
  1232:             pcmBuffer[i +  4] =
  1233:             pcmBuffer[i +  5] =
  1234:             pcmBuffer[i +  6] =
  1235:             pcmBuffer[i +  7] = 0);
  1236:         }
  1237:         pcmDecodedData3 = m0;
  1238:         pcmDecodedData2 = m1;
  1239:         pcmDecodedData1 = m2;
  1240:         pcmPointer = i + 8;
  1241:       }
  1242:     },  //PIP_MONO_HERMITE_8
  1243: 
  1244:     //モノラル エルミート補間 10416.67Hz
  1245:     PIP_MONO_HERMITE_6 {
  1246:       @Override public void write (int m2) {
  1247:         //  echo read("hermite.gp");hermite_code(1,6) | gp-2.7 -q
  1248:         int i = pcmPointer;
  1249:         int mm = pcmDecodedData3;
  1250:         int m0 = pcmDecodedData2;
  1251:         int m1 = pcmDecodedData1;
  1252:         int p = pcmPanLeft;
  1253:         if (p > 0) {  //ON
  1254:           pcmBuffer[i    ] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  1255:           pcmBuffer[i + 1] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  1256:           pcmBuffer[i + 2] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1257:           pcmBuffer[i + 3] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  1258:           pcmBuffer[i + 4] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  1259:           pcmBuffer[i + 5] =                                         m1;
  1260:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1261:           p = (char) p;
  1262:           pcmBuffer[i    ] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p    ] >> 14;
  1263:           pcmBuffer[i + 1] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  1264:           pcmBuffer[i + 2] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p + 2] >> 14;
  1265:           pcmBuffer[i + 3] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 3] >> 14;
  1266:           pcmBuffer[i + 4] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p + 4] >> 14;
  1267:           pcmBuffer[i + 5] =       (                                 m1                                 ) * pcmAttackCurve[p + 5] >> 14;
  1268:           p += 6;
  1269:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1270:         } else {  //OFF
  1271:           pcmBuffer[  i     ] = (
  1272:             pcmBuffer[i +  1] =
  1273:             pcmBuffer[i +  2] =
  1274:             pcmBuffer[i +  3] =
  1275:             pcmBuffer[i +  4] =
  1276:             pcmBuffer[i +  5] = 0);
  1277:         }
  1278:         pcmDecodedData3 = m0;
  1279:         pcmDecodedData2 = m1;
  1280:         pcmDecodedData1 = m2;
  1281:         pcmPointer = i + 6;
  1282:       }
  1283:     },  //PIP_MONO_HERMITE_6
  1284: 
  1285:     //モノラル エルミート補間 15625.00Hz
  1286:     PIP_MONO_HERMITE_4 {
  1287:       @Override public void write (int m2) {
  1288:         //  echo read("hermite.gp");hermite_code(1,4) | gp-2.7 -q
  1289:         int i = pcmPointer;
  1290:         int mm = pcmDecodedData3;
  1291:         int m0 = pcmDecodedData2;
  1292:         int m1 = pcmDecodedData1;
  1293:         int p = pcmPanLeft;
  1294:         if (p > 0) {  //ON
  1295:           pcmBuffer[i    ] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  1296:           pcmBuffer[i + 1] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1297:           pcmBuffer[i + 2] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  1298:           pcmBuffer[i + 3] =                                         m1;
  1299:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1300:           p = (char) p;
  1301:           pcmBuffer[i    ] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p    ] >> 14;
  1302:           pcmBuffer[i + 1] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 1] >> 14;
  1303:           pcmBuffer[i + 2] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 2] >> 14;
  1304:           pcmBuffer[i + 3] = (                                        m1                  ) * pcmAttackCurve[p + 3] >> 14;
  1305:           p += 4;
  1306:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1307:         } else {  //OFF
  1308:           pcmBuffer[  i     ] = (
  1309:             pcmBuffer[i +  1] =
  1310:             pcmBuffer[i +  2] =
  1311:             pcmBuffer[i +  3] = 0);
  1312:         }
  1313:         pcmDecodedData3 = m0;
  1314:         pcmDecodedData2 = m1;
  1315:         pcmDecodedData1 = m2;
  1316:         pcmPointer = i + 4;
  1317:       }
  1318:     },  //PIP_MONO_HERMITE_4
  1319: 
  1320:     //モノラル エルミート補間 20833.33Hz
  1321:     PIP_MONO_HERMITE_3 {
  1322:       @Override public void write (int m2) {
  1323:         //  echo read("hermite.gp");hermite_code(1,3) | gp-2.7 -q
  1324:         int i = pcmPointer;
  1325:         int mm = pcmDecodedData3;
  1326:         int m0 = pcmDecodedData2;
  1327:         int m1 = pcmDecodedData1;
  1328:         int p = pcmPanLeft;
  1329:         if (p > 0) {  //ON
  1330:           pcmBuffer[i    ] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  1331:           pcmBuffer[i + 1] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  1332:           pcmBuffer[i + 2] =                                         m1;
  1333:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1334:           p = (char) p;
  1335:           pcmBuffer[i    ] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p    ] >> 14;
  1336:           pcmBuffer[i + 1] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  1337:           pcmBuffer[i + 2] =       (                                 m1                                 ) * pcmAttackCurve[p + 2] >> 14;
  1338:           p += 3;
  1339:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1340:         } else {  //OFF
  1341:           pcmBuffer[  i     ] = (
  1342:             pcmBuffer[i +  1] =
  1343:             pcmBuffer[i +  2] = 0);
  1344:         }
  1345:         pcmDecodedData3 = m0;
  1346:         pcmDecodedData2 = m1;
  1347:         pcmDecodedData1 = m2;
  1348:         pcmPointer = i + 3;
  1349:       }
  1350:     },  //PIP_MONO_HERMITE_3
  1351: 
  1352:     //モノラル エルミート補間 31250.00Hz
  1353:     PIP_MONO_HERMITE_2 {
  1354:       @Override public void write (int m2) {
  1355:         //  echo read("hermite.gp");hermite_code(1,2) | gp-2.7 -q
  1356:         int i = pcmPointer;
  1357:         int mm = pcmDecodedData3;
  1358:         int m0 = pcmDecodedData2;
  1359:         int m1 = pcmDecodedData1;
  1360:         int p = pcmPanLeft;
  1361:         if (p > 0) {  //ON
  1362:           pcmBuffer[i    ] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1363:           pcmBuffer[i + 1] =                                         m1;
  1364:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1365:           p = (char) p;
  1366:           pcmBuffer[i    ] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p    ] >> 14;
  1367:           pcmBuffer[i + 1] = (                                        m1                  ) * pcmAttackCurve[p + 1] >> 14;
  1368:           p += 2;
  1369:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1370:         } else {  //OFF
  1371:           pcmBuffer[  i     ] = (
  1372:             pcmBuffer[i +  1] = 0);
  1373:         }
  1374:         pcmDecodedData3 = m0;
  1375:         pcmDecodedData2 = m1;
  1376:         pcmDecodedData1 = m2;
  1377:         pcmPointer = i + 2;
  1378:       }
  1379:     },  //PIP_MONO_HERMITE_2
  1380: 
  1381:     //ステレオ 区分定数補間 3906.25Hz
  1382:     PIP_STEREO_CONSTANT_16 {
  1383:       @Override public void write (int m) {
  1384:         int i = pcmPointer;
  1385:         int p = pcmPanLeft;
  1386:         if (p > 0) {  //ON
  1387:           pcmBuffer[  i     ] = (
  1388:             pcmBuffer[i +  2] =
  1389:             pcmBuffer[i +  4] =
  1390:             pcmBuffer[i +  6] =
  1391:             pcmBuffer[i +  8] =
  1392:             pcmBuffer[i + 10] =
  1393:             pcmBuffer[i + 12] =
  1394:             pcmBuffer[i + 14] =
  1395:             pcmBuffer[i + 16] =
  1396:             pcmBuffer[i + 18] =
  1397:             pcmBuffer[i + 20] =
  1398:             pcmBuffer[i + 22] =
  1399:             pcmBuffer[i + 24] =
  1400:             pcmBuffer[i + 26] =
  1401:             pcmBuffer[i + 28] =
  1402:             pcmBuffer[i + 30] = m);
  1403:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1404:           p = (char) p;
  1405:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1406:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1407:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1408:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  3] >> 14;
  1409:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  4] >> 14;
  1410:           pcmBuffer[i + 10] = m * pcmAttackCurve[p +  5] >> 14;
  1411:           pcmBuffer[i + 12] = m * pcmAttackCurve[p +  6] >> 14;
  1412:           pcmBuffer[i + 14] = m * pcmAttackCurve[p +  7] >> 14;
  1413:           pcmBuffer[i + 16] = m * pcmAttackCurve[p +  8] >> 14;
  1414:           pcmBuffer[i + 18] = m * pcmAttackCurve[p +  9] >> 14;
  1415:           pcmBuffer[i + 20] = m * pcmAttackCurve[p + 10] >> 14;
  1416:           pcmBuffer[i + 22] = m * pcmAttackCurve[p + 11] >> 14;
  1417:           pcmBuffer[i + 24] = m * pcmAttackCurve[p + 12] >> 14;
  1418:           pcmBuffer[i + 26] = m * pcmAttackCurve[p + 13] >> 14;
  1419:           pcmBuffer[i + 28] = m * pcmAttackCurve[p + 14] >> 14;
  1420:           pcmBuffer[i + 30] = m * pcmAttackCurve[p + 15] >> 14;
  1421:           p += 16;
  1422:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1423:         } else {  //OFF
  1424:           pcmBuffer[  i     ] = (
  1425:             pcmBuffer[i +  2] =
  1426:             pcmBuffer[i +  4] =
  1427:             pcmBuffer[i +  6] =
  1428:             pcmBuffer[i +  8] =
  1429:             pcmBuffer[i + 10] =
  1430:             pcmBuffer[i + 12] =
  1431:             pcmBuffer[i + 14] =
  1432:             pcmBuffer[i + 16] =
  1433:             pcmBuffer[i + 18] =
  1434:             pcmBuffer[i + 20] =
  1435:             pcmBuffer[i + 22] =
  1436:             pcmBuffer[i + 24] =
  1437:             pcmBuffer[i + 26] =
  1438:             pcmBuffer[i + 28] =
  1439:             pcmBuffer[i + 30] = 0);
  1440:         }
  1441:         p = pcmPanRight;
  1442:         if (p > 0) {  //ON
  1443:           pcmBuffer[  i +  1] = (
  1444:             pcmBuffer[i +  3] =
  1445:             pcmBuffer[i +  5] =
  1446:             pcmBuffer[i +  7] =
  1447:             pcmBuffer[i +  9] =
  1448:             pcmBuffer[i + 11] =
  1449:             pcmBuffer[i + 13] =
  1450:             pcmBuffer[i + 15] =
  1451:             pcmBuffer[i + 17] =
  1452:             pcmBuffer[i + 19] =
  1453:             pcmBuffer[i + 21] =
  1454:             pcmBuffer[i + 23] =
  1455:             pcmBuffer[i + 25] =
  1456:             pcmBuffer[i + 27] =
  1457:             pcmBuffer[i + 29] =
  1458:             pcmBuffer[i + 31] = m);
  1459:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1460:           p = (char) p;
  1461:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1462:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1463:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1464:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  3] >> 14;
  1465:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  4] >> 14;
  1466:           pcmBuffer[i + 11] = m * pcmAttackCurve[p +  5] >> 14;
  1467:           pcmBuffer[i + 13] = m * pcmAttackCurve[p +  6] >> 14;
  1468:           pcmBuffer[i + 15] = m * pcmAttackCurve[p +  7] >> 14;
  1469:           pcmBuffer[i + 17] = m * pcmAttackCurve[p +  8] >> 14;
  1470:           pcmBuffer[i + 19] = m * pcmAttackCurve[p +  9] >> 14;
  1471:           pcmBuffer[i + 21] = m * pcmAttackCurve[p + 10] >> 14;
  1472:           pcmBuffer[i + 23] = m * pcmAttackCurve[p + 11] >> 14;
  1473:           pcmBuffer[i + 25] = m * pcmAttackCurve[p + 12] >> 14;
  1474:           pcmBuffer[i + 27] = m * pcmAttackCurve[p + 13] >> 14;
  1475:           pcmBuffer[i + 29] = m * pcmAttackCurve[p + 14] >> 14;
  1476:           pcmBuffer[i + 31] = m * pcmAttackCurve[p + 15] >> 14;
  1477:           p += 16;
  1478:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1479:         } else {  //OFF
  1480:           pcmBuffer[  i +  1] = (
  1481:             pcmBuffer[i +  3] =
  1482:             pcmBuffer[i +  5] =
  1483:             pcmBuffer[i +  7] =
  1484:             pcmBuffer[i +  9] =
  1485:             pcmBuffer[i + 11] =
  1486:             pcmBuffer[i + 13] =
  1487:             pcmBuffer[i + 15] =
  1488:             pcmBuffer[i + 17] =
  1489:             pcmBuffer[i + 19] =
  1490:             pcmBuffer[i + 21] =
  1491:             pcmBuffer[i + 23] =
  1492:             pcmBuffer[i + 25] =
  1493:             pcmBuffer[i + 27] =
  1494:             pcmBuffer[i + 29] =
  1495:             pcmBuffer[i + 31] = 0);
  1496:         }
  1497:         pcmDecodedData1 = m;
  1498:         pcmPointer = i + 32;
  1499:       }
  1500:     },  //PIP_STEREO_CONSTANT_16
  1501: 
  1502:     //ステレオ 区分定数補間 5208.33Hz
  1503:     PIP_STEREO_CONSTANT_12 {
  1504:       @Override public void write (int m) {
  1505:         int i = pcmPointer;
  1506:         int p = pcmPanLeft;
  1507:         if (p > 0) {  //ON
  1508:           pcmBuffer[  i     ] = (
  1509:             pcmBuffer[i +  2] =
  1510:             pcmBuffer[i +  4] =
  1511:             pcmBuffer[i +  6] =
  1512:             pcmBuffer[i +  8] =
  1513:             pcmBuffer[i + 10] =
  1514:             pcmBuffer[i + 12] =
  1515:             pcmBuffer[i + 14] =
  1516:             pcmBuffer[i + 16] =
  1517:             pcmBuffer[i + 18] =
  1518:             pcmBuffer[i + 20] =
  1519:             pcmBuffer[i + 22] = m);
  1520:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1521:           p = (char) p;
  1522:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1523:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1524:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1525:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  3] >> 14;
  1526:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  4] >> 14;
  1527:           pcmBuffer[i + 10] = m * pcmAttackCurve[p +  5] >> 14;
  1528:           pcmBuffer[i + 12] = m * pcmAttackCurve[p +  6] >> 14;
  1529:           pcmBuffer[i + 14] = m * pcmAttackCurve[p +  7] >> 14;
  1530:           pcmBuffer[i + 16] = m * pcmAttackCurve[p +  8] >> 14;
  1531:           pcmBuffer[i + 18] = m * pcmAttackCurve[p +  9] >> 14;
  1532:           pcmBuffer[i + 20] = m * pcmAttackCurve[p + 10] >> 14;
  1533:           pcmBuffer[i + 22] = m * pcmAttackCurve[p + 11] >> 14;
  1534:           p += 12;
  1535:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1536:         } else {  //OFF
  1537:           pcmBuffer[  i     ] = (
  1538:             pcmBuffer[i +  2] =
  1539:             pcmBuffer[i +  4] =
  1540:             pcmBuffer[i +  6] =
  1541:             pcmBuffer[i +  8] =
  1542:             pcmBuffer[i + 10] =
  1543:             pcmBuffer[i + 12] =
  1544:             pcmBuffer[i + 14] =
  1545:             pcmBuffer[i + 16] =
  1546:             pcmBuffer[i + 18] =
  1547:             pcmBuffer[i + 20] =
  1548:             pcmBuffer[i + 22] = 0);
  1549:         }
  1550:         p = pcmPanRight;
  1551:         if (p > 0) {  //ON
  1552:           pcmBuffer[  i +  1] = (
  1553:             pcmBuffer[i +  3] =
  1554:             pcmBuffer[i +  5] =
  1555:             pcmBuffer[i +  7] =
  1556:             pcmBuffer[i +  9] =
  1557:             pcmBuffer[i + 11] =
  1558:             pcmBuffer[i + 13] =
  1559:             pcmBuffer[i + 15] =
  1560:             pcmBuffer[i + 17] =
  1561:             pcmBuffer[i + 19] =
  1562:             pcmBuffer[i + 21] =
  1563:             pcmBuffer[i + 23] = m);
  1564:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1565:           p = (char) p;
  1566:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1567:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1568:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1569:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  3] >> 14;
  1570:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  4] >> 14;
  1571:           pcmBuffer[i + 11] = m * pcmAttackCurve[p +  5] >> 14;
  1572:           pcmBuffer[i + 13] = m * pcmAttackCurve[p +  6] >> 14;
  1573:           pcmBuffer[i + 15] = m * pcmAttackCurve[p +  7] >> 14;
  1574:           pcmBuffer[i + 17] = m * pcmAttackCurve[p +  8] >> 14;
  1575:           pcmBuffer[i + 19] = m * pcmAttackCurve[p +  9] >> 14;
  1576:           pcmBuffer[i + 21] = m * pcmAttackCurve[p + 10] >> 14;
  1577:           pcmBuffer[i + 23] = m * pcmAttackCurve[p + 11] >> 14;
  1578:           p += 12;
  1579:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1580:         } else {  //OFF
  1581:           pcmBuffer[  i +  1] = (
  1582:             pcmBuffer[i +  3] =
  1583:             pcmBuffer[i +  5] =
  1584:             pcmBuffer[i +  7] =
  1585:             pcmBuffer[i +  9] =
  1586:             pcmBuffer[i + 11] =
  1587:             pcmBuffer[i + 13] =
  1588:             pcmBuffer[i + 15] =
  1589:             pcmBuffer[i + 17] =
  1590:             pcmBuffer[i + 19] =
  1591:             pcmBuffer[i + 21] =
  1592:             pcmBuffer[i + 23] = 0);
  1593:         }
  1594:         pcmDecodedData1 = m;
  1595:         pcmPointer = i + 24;
  1596:       }
  1597:     },  //PIP_STEREO_CONSTANT_12
  1598: 
  1599:     //ステレオ 区分定数補間 7812.50Hz
  1600:     PIP_STEREO_CONSTANT_8 {
  1601:       @Override public void write (int m) {
  1602:         int i = pcmPointer;
  1603:         int p = pcmPanLeft;
  1604:         if (p > 0) {  //ON
  1605:           pcmBuffer[  i     ] = (
  1606:             pcmBuffer[i +  2] =
  1607:             pcmBuffer[i +  4] =
  1608:             pcmBuffer[i +  6] =
  1609:             pcmBuffer[i +  8] =
  1610:             pcmBuffer[i + 10] =
  1611:             pcmBuffer[i + 12] =
  1612:             pcmBuffer[i + 14] = m);
  1613:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1614:           p = (char) p;
  1615:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1616:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1617:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1618:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  3] >> 14;
  1619:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  4] >> 14;
  1620:           pcmBuffer[i + 10] = m * pcmAttackCurve[p +  5] >> 14;
  1621:           pcmBuffer[i + 12] = m * pcmAttackCurve[p +  6] >> 14;
  1622:           pcmBuffer[i + 14] = m * pcmAttackCurve[p +  7] >> 14;
  1623:           p += 8;
  1624:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1625:         } else {  //OFF
  1626:           pcmBuffer[  i     ] = (
  1627:             pcmBuffer[i +  2] =
  1628:             pcmBuffer[i +  4] =
  1629:             pcmBuffer[i +  6] =
  1630:             pcmBuffer[i +  8] =
  1631:             pcmBuffer[i + 10] =
  1632:             pcmBuffer[i + 12] =
  1633:             pcmBuffer[i + 14] = 0);
  1634:         }
  1635:         p = pcmPanRight;
  1636:         if (p > 0) {  //ON
  1637:           pcmBuffer[  i +  1] = (
  1638:             pcmBuffer[i +  3] =
  1639:             pcmBuffer[i +  5] =
  1640:             pcmBuffer[i +  7] =
  1641:             pcmBuffer[i +  9] =
  1642:             pcmBuffer[i + 11] =
  1643:             pcmBuffer[i + 13] =
  1644:             pcmBuffer[i + 15] = m);
  1645:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1646:           p = (char) p;
  1647:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1648:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1649:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1650:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  3] >> 14;
  1651:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  4] >> 14;
  1652:           pcmBuffer[i + 11] = m * pcmAttackCurve[p +  5] >> 14;
  1653:           pcmBuffer[i + 13] = m * pcmAttackCurve[p +  6] >> 14;
  1654:           pcmBuffer[i + 15] = m * pcmAttackCurve[p +  7] >> 14;
  1655:           p += 8;
  1656:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1657:         } else {  //OFF
  1658:           pcmBuffer[  i +  1] = (
  1659:             pcmBuffer[i +  3] =
  1660:             pcmBuffer[i +  5] =
  1661:             pcmBuffer[i +  7] =
  1662:             pcmBuffer[i +  9] =
  1663:             pcmBuffer[i + 11] =
  1664:             pcmBuffer[i + 13] =
  1665:             pcmBuffer[i + 15] = 0);
  1666:         }
  1667:         pcmDecodedData1 = m;
  1668:         pcmPointer = i + 16;
  1669:       }
  1670:     },  //PIP_STEREO_CONSTANT_8
  1671: 
  1672:     //ステレオ 区分定数補間 10416.67Hz
  1673:     PIP_STEREO_CONSTANT_6 {
  1674:       @Override public void write (int m) {
  1675:         int i = pcmPointer;
  1676:         int p = pcmPanLeft;
  1677:         if (p > 0) {  //ON
  1678:           pcmBuffer[  i     ] = (
  1679:             pcmBuffer[i +  2] =
  1680:             pcmBuffer[i +  4] =
  1681:             pcmBuffer[i +  6] =
  1682:             pcmBuffer[i +  8] =
  1683:             pcmBuffer[i + 10] = m);
  1684:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1685:           p = (char) p;
  1686:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1687:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1688:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1689:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  3] >> 14;
  1690:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  4] >> 14;
  1691:           pcmBuffer[i + 10] = m * pcmAttackCurve[p +  5] >> 14;
  1692:           p += 6;
  1693:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1694:         } else {  //OFF
  1695:           pcmBuffer[  i     ] = (
  1696:             pcmBuffer[i +  2] =
  1697:             pcmBuffer[i +  4] =
  1698:             pcmBuffer[i +  6] =
  1699:             pcmBuffer[i +  8] =
  1700:             pcmBuffer[i + 10] = 0);
  1701:         }
  1702:         p = pcmPanRight;
  1703:         if (p > 0) {  //ON
  1704:           pcmBuffer[  i +  1] = (
  1705:             pcmBuffer[i +  3] =
  1706:             pcmBuffer[i +  5] =
  1707:             pcmBuffer[i +  7] =
  1708:             pcmBuffer[i +  9] =
  1709:             pcmBuffer[i + 11] = m);
  1710:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1711:           p = (char) p;
  1712:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1713:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1714:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1715:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  3] >> 14;
  1716:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  4] >> 14;
  1717:           pcmBuffer[i + 11] = m * pcmAttackCurve[p +  5] >> 14;
  1718:           p += 6;
  1719:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1720:         } else {  //OFF
  1721:           pcmBuffer[  i +  1] = (
  1722:             pcmBuffer[i +  3] =
  1723:             pcmBuffer[i +  5] =
  1724:             pcmBuffer[i +  7] =
  1725:             pcmBuffer[i +  9] =
  1726:             pcmBuffer[i + 11] = 0);
  1727:         }
  1728:         pcmDecodedData1 = m;
  1729:         pcmPointer = i + 12;
  1730:       }
  1731:     },  //PIP_STEREO_CONSTANT_6
  1732: 
  1733:     //ステレオ 区分定数補間 15625.00Hz
  1734:     PIP_STEREO_CONSTANT_4 {
  1735:       @Override public void write (int m) {
  1736:         int i = pcmPointer;
  1737:         int p = pcmPanLeft;
  1738:         if (p > 0) {  //ON
  1739:           pcmBuffer[  i     ] = (
  1740:             pcmBuffer[i +  2] =
  1741:             pcmBuffer[i +  4] =
  1742:             pcmBuffer[i +  6] = m);
  1743:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1744:           p = (char) p;
  1745:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1746:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1747:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1748:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  3] >> 14;
  1749:           p += 4;
  1750:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1751:         } else {  //OFF
  1752:           pcmBuffer[  i     ] = (
  1753:             pcmBuffer[i +  2] =
  1754:             pcmBuffer[i +  4] =
  1755:             pcmBuffer[i +  6] = 0);
  1756:         }
  1757:         p = pcmPanRight;
  1758:         if (p > 0) {  //ON
  1759:           pcmBuffer[  i +  1] = (
  1760:             pcmBuffer[i +  3] =
  1761:             pcmBuffer[i +  5] =
  1762:             pcmBuffer[i +  7] = m);
  1763:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1764:           p = (char) p;
  1765:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1766:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1767:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1768:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  3] >> 14;
  1769:           p += 4;
  1770:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1771:         } else {  //OFF
  1772:           pcmBuffer[  i +  1] = (
  1773:             pcmBuffer[i +  3] =
  1774:             pcmBuffer[i +  5] =
  1775:             pcmBuffer[i +  7] = 0);
  1776:         }
  1777:         pcmDecodedData1 = m;
  1778:         pcmPointer = i + 8;
  1779:       }
  1780:     },  //PIP_STEREO_CONSTANT_4
  1781: 
  1782:     //ステレオ 区分定数補間 20833.33Hz
  1783:     PIP_STEREO_CONSTANT_3 {
  1784:       @Override public void write (int m) {
  1785:         int i = pcmPointer;
  1786:         int p = pcmPanLeft;
  1787:         if (p > 0) {  //ON
  1788:           pcmBuffer[  i     ] = (
  1789:             pcmBuffer[i +  2] =
  1790:             pcmBuffer[i +  4] = m);
  1791:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1792:           p = (char) p;
  1793:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1794:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1795:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1796:           p += 3;
  1797:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1798:         } else {  //OFF
  1799:           pcmBuffer[  i     ] = (
  1800:             pcmBuffer[i +  2] =
  1801:             pcmBuffer[i +  4] = 0);
  1802:         }
  1803:         p = pcmPanRight;
  1804:         if (p > 0) {  //ON
  1805:           pcmBuffer[  i +  1] = (
  1806:             pcmBuffer[i +  3] =
  1807:             pcmBuffer[i +  5] = m);
  1808:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1809:           p = (char) p;
  1810:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1811:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1812:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1813:           p += 3;
  1814:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1815:         } else {  //OFF
  1816:           pcmBuffer[  i +  1] = (
  1817:             pcmBuffer[i +  3] =
  1818:             pcmBuffer[i +  5] = 0);
  1819:         }
  1820:         pcmDecodedData1 = m;
  1821:         pcmPointer = i + 6;
  1822:       }
  1823:     },  //PIP_STEREO_CONSTANT_3
  1824: 
  1825:     //ステレオ 区分定数補間 31250.00Hz
  1826:     PIP_STEREO_CONSTANT_2 {
  1827:       @Override public void write (int m) {
  1828:         int i = pcmPointer;
  1829:         int p = pcmPanLeft;
  1830:         if (p > 0) {  //ON
  1831:           pcmBuffer[  i     ] = (
  1832:             pcmBuffer[i +  2] = m);
  1833:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1834:           p = (char) p;
  1835:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1836:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1837:           p += 2;
  1838:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1839:         } else {  //OFF
  1840:           pcmBuffer[  i     ] = (
  1841:             pcmBuffer[i +  2] = 0);
  1842:         }
  1843:         p = pcmPanRight;
  1844:         if (p > 0) {  //ON
  1845:           pcmBuffer[  i +  1] = (
  1846:             pcmBuffer[i +  3] = m);
  1847:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1848:           p = (char) p;
  1849:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1850:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1851:           p += 2;
  1852:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1853:         } else {  //OFF
  1854:           pcmBuffer[  i +  1] = (
  1855:             pcmBuffer[i +  3] = 0);
  1856:         }
  1857:         pcmDecodedData1 = m;
  1858:         pcmPointer = i + 4;
  1859:       }
  1860:     },  //PIP_STEREO_CONSTANT_2
  1861: 
  1862:     //ステレオ 線形補間 3906.25Hz
  1863:     PIP_STEREO_LINEAR_16 {
  1864:       @Override public void write (int m1) {
  1865:         int i = pcmPointer;
  1866:         int p = pcmPanLeft;
  1867:         if (p > 0) {  //ON
  1868:           int m0 = pcmDecodedData1;
  1869:           pcmBuffer[i     ] = 15 * m0 +      m1 >> 4;
  1870:           pcmBuffer[i +  2] =  7 * m0 +      m1 >> 3;
  1871:           pcmBuffer[i +  4] = 13 * m0 +  3 * m1 >> 4;
  1872:           pcmBuffer[i +  6] =  3 * m0 +      m1 >> 2;
  1873:           pcmBuffer[i +  8] = 11 * m0 +  5 * m1 >> 4;
  1874:           pcmBuffer[i + 10] =  5 * m0 +  3 * m1 >> 3;
  1875:           pcmBuffer[i + 12] =  9 * m0 +  7 * m1 >> 4;
  1876:           pcmBuffer[i + 14] =      m0 +      m1 >> 1;
  1877:           pcmBuffer[i + 16] =  7 * m0 +  9 * m1 >> 4;
  1878:           pcmBuffer[i + 18] =  3 * m0 +  5 * m1 >> 3;
  1879:           pcmBuffer[i + 20] =  5 * m0 + 11 * m1 >> 4;
  1880:           pcmBuffer[i + 22] =      m0 +  3 * m1 >> 2;
  1881:           pcmBuffer[i + 24] =  3 * m0 + 13 * m1 >> 4;
  1882:           pcmBuffer[i + 26] =      m0 +  7 * m1 >> 3;
  1883:           pcmBuffer[i + 28] =      m0 + 15 * m1 >> 4;
  1884:           pcmBuffer[i + 30] =                m1;
  1885:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1886:           p = (char) p;
  1887:           int m0 = pcmDecodedData1;
  1888:           pcmBuffer[i     ] = (15 * m0 +      m1 >> 4) * pcmAttackCurve[p     ] >> 14;
  1889:           pcmBuffer[i +  2] = ( 7 * m0 +      m1 >> 3) * pcmAttackCurve[p +  1] >> 14;
  1890:           pcmBuffer[i +  4] = (13 * m0 +  3 * m1 >> 4) * pcmAttackCurve[p +  2] >> 14;
  1891:           pcmBuffer[i +  6] = ( 3 * m0 +      m1 >> 2) * pcmAttackCurve[p +  3] >> 14;
  1892:           pcmBuffer[i +  8] = (11 * m0 +  5 * m1 >> 4) * pcmAttackCurve[p +  4] >> 14;
  1893:           pcmBuffer[i + 10] = ( 5 * m0 +  3 * m1 >> 3) * pcmAttackCurve[p +  5] >> 14;
  1894:           pcmBuffer[i + 12] = ( 9 * m0 +  7 * m1 >> 4) * pcmAttackCurve[p +  6] >> 14;
  1895:           pcmBuffer[i + 14] = (     m0 +      m1 >> 1) * pcmAttackCurve[p +  7] >> 14;
  1896:           pcmBuffer[i + 16] = ( 7 * m0 +  9 * m1 >> 4) * pcmAttackCurve[p +  8] >> 14;
  1897:           pcmBuffer[i + 18] = ( 3 * m0 +  5 * m1 >> 3) * pcmAttackCurve[p +  9] >> 14;
  1898:           pcmBuffer[i + 20] = ( 5 * m0 + 11 * m1 >> 4) * pcmAttackCurve[p + 10] >> 14;
  1899:           pcmBuffer[i + 22] = (     m0 +  3 * m1 >> 2) * pcmAttackCurve[p + 11] >> 14;
  1900:           pcmBuffer[i + 24] = ( 3 * m0 + 13 * m1 >> 4) * pcmAttackCurve[p + 12] >> 14;
  1901:           pcmBuffer[i + 26] = (     m0 +  7 * m1 >> 3) * pcmAttackCurve[p + 13] >> 14;
  1902:           pcmBuffer[i + 28] = (     m0 + 15 * m1 >> 4) * pcmAttackCurve[p + 14] >> 14;
  1903:           pcmBuffer[i + 30] = (               m1     ) * pcmAttackCurve[p + 15] >> 14;
  1904:           p += 16;
  1905:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1906:         } else {  //OFF
  1907:           pcmBuffer[  i     ] = (
  1908:             pcmBuffer[i +  2] =
  1909:             pcmBuffer[i +  4] =
  1910:             pcmBuffer[i +  6] =
  1911:             pcmBuffer[i +  8] =
  1912:             pcmBuffer[i + 10] =
  1913:             pcmBuffer[i + 12] =
  1914:             pcmBuffer[i + 14] =
  1915:             pcmBuffer[i + 16] =
  1916:             pcmBuffer[i + 18] =
  1917:             pcmBuffer[i + 20] =
  1918:             pcmBuffer[i + 22] =
  1919:             pcmBuffer[i + 24] =
  1920:             pcmBuffer[i + 26] =
  1921:             pcmBuffer[i + 28] =
  1922:             pcmBuffer[i + 30] = 0);
  1923:         }
  1924:         p = pcmPanRight;
  1925:         if (p > 0) {  //ON
  1926:           int m0 = pcmDecodedData1;
  1927:           pcmBuffer[i +  1] = 15 * m0 +      m1 >> 4;
  1928:           pcmBuffer[i +  3] =  7 * m0 +      m1 >> 3;
  1929:           pcmBuffer[i +  5] = 13 * m0 +  3 * m1 >> 4;
  1930:           pcmBuffer[i +  7] =  3 * m0 +      m1 >> 2;
  1931:           pcmBuffer[i +  9] = 11 * m0 +  5 * m1 >> 4;
  1932:           pcmBuffer[i + 11] =  5 * m0 +  3 * m1 >> 3;
  1933:           pcmBuffer[i + 13] =  9 * m0 +  7 * m1 >> 4;
  1934:           pcmBuffer[i + 15] =      m0 +      m1 >> 1;
  1935:           pcmBuffer[i + 17] =  7 * m0 +  9 * m1 >> 4;
  1936:           pcmBuffer[i + 19] =  3 * m0 +  5 * m1 >> 3;
  1937:           pcmBuffer[i + 21] =  5 * m0 + 11 * m1 >> 4;
  1938:           pcmBuffer[i + 23] =      m0 +  3 * m1 >> 2;
  1939:           pcmBuffer[i + 25] =  3 * m0 + 13 * m1 >> 4;
  1940:           pcmBuffer[i + 27] =      m0 +  7 * m1 >> 3;
  1941:           pcmBuffer[i + 29] =      m0 + 15 * m1 >> 4;
  1942:           pcmBuffer[i + 31] =                m1;
  1943:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1944:           p = (char) p;
  1945:           int m0 = pcmDecodedData1;
  1946:           pcmBuffer[i +  1] = (15 * m0 +      m1 >> 4) * pcmAttackCurve[p     ] >> 14;
  1947:           pcmBuffer[i +  3] = ( 7 * m0 +      m1 >> 3) * pcmAttackCurve[p +  1] >> 14;
  1948:           pcmBuffer[i +  5] = (13 * m0 +  3 * m1 >> 4) * pcmAttackCurve[p +  2] >> 14;
  1949:           pcmBuffer[i +  7] = ( 3 * m0 +      m1 >> 2) * pcmAttackCurve[p +  3] >> 14;
  1950:           pcmBuffer[i +  9] = (11 * m0 +  5 * m1 >> 4) * pcmAttackCurve[p +  4] >> 14;
  1951:           pcmBuffer[i + 11] = ( 5 * m0 +  3 * m1 >> 3) * pcmAttackCurve[p +  5] >> 14;
  1952:           pcmBuffer[i + 13] = ( 9 * m0 +  7 * m1 >> 4) * pcmAttackCurve[p +  6] >> 14;
  1953:           pcmBuffer[i + 15] = (     m0 +      m1 >> 1) * pcmAttackCurve[p +  7] >> 14;
  1954:           pcmBuffer[i + 17] = ( 7 * m0 +  9 * m1 >> 4) * pcmAttackCurve[p +  8] >> 14;
  1955:           pcmBuffer[i + 19] = ( 3 * m0 +  5 * m1 >> 3) * pcmAttackCurve[p +  9] >> 14;
  1956:           pcmBuffer[i + 21] = ( 5 * m0 + 11 * m1 >> 4) * pcmAttackCurve[p + 10] >> 14;
  1957:           pcmBuffer[i + 23] = (     m0 +  3 * m1 >> 2) * pcmAttackCurve[p + 11] >> 14;
  1958:           pcmBuffer[i + 25] = ( 3 * m0 + 13 * m1 >> 4) * pcmAttackCurve[p + 12] >> 14;
  1959:           pcmBuffer[i + 27] = (     m0 +  7 * m1 >> 3) * pcmAttackCurve[p + 13] >> 14;
  1960:           pcmBuffer[i + 29] = (     m0 + 15 * m1 >> 4) * pcmAttackCurve[p + 14] >> 14;
  1961:           pcmBuffer[i + 31] = (               m1     ) * pcmAttackCurve[p + 15] >> 14;
  1962:           p += 16;
  1963:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1964:         } else {  //OFF
  1965:           pcmBuffer[  i +  1] = (
  1966:             pcmBuffer[i +  3] =
  1967:             pcmBuffer[i +  5] =
  1968:             pcmBuffer[i +  7] =
  1969:             pcmBuffer[i +  9] =
  1970:             pcmBuffer[i + 11] =
  1971:             pcmBuffer[i + 13] =
  1972:             pcmBuffer[i + 15] =
  1973:             pcmBuffer[i + 17] =
  1974:             pcmBuffer[i + 19] =
  1975:             pcmBuffer[i + 21] =
  1976:             pcmBuffer[i + 23] =
  1977:             pcmBuffer[i + 25] =
  1978:             pcmBuffer[i + 27] =
  1979:             pcmBuffer[i + 29] =
  1980:             pcmBuffer[i + 31] = 0);
  1981:         }
  1982:         pcmDecodedData1 = m1;
  1983:         pcmPointer = i + 32;
  1984:       }
  1985:     },  //PIP_STEREO_LINEAR_16
  1986: 
  1987:     //ステレオ 線形補間 5208.33Hz
  1988:     PIP_STEREO_LINEAR_12 {
  1989:       @Override public void write (int m1) {
  1990:         int i = pcmPointer;
  1991:         int p = pcmPanLeft;
  1992:         if (p > 0) {  //ON
  1993:           int m0 = pcmDecodedData1;
  1994:           pcmBuffer[i     ] = 65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16;
  1995:           pcmBuffer[i +  2] = 65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16;
  1996:           pcmBuffer[i +  4] =          3      * m0 +                   m1 >>  2;
  1997:           pcmBuffer[i +  6] = 65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16;
  1998:           pcmBuffer[i +  8] = 65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16;
  1999:           pcmBuffer[i + 10] =                   m0 +                   m1 >>  1;
  2000:           pcmBuffer[i + 12] = 65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16;
  2001:           pcmBuffer[i + 14] = 65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16;
  2002:           pcmBuffer[i + 16] =                   m0 +          3      * m1 >>  2;
  2003:           pcmBuffer[i + 18] = 65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16;
  2004:           pcmBuffer[i + 20] = 65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16;
  2005:           pcmBuffer[i + 22] =                                          m1;
  2006:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2007:           p = (char) p;
  2008:           int m0 = pcmDecodedData1;
  2009:           pcmBuffer[i     ] = (65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16) * pcmAttackCurve[p     ] >> 14;
  2010:           pcmBuffer[i +  2] = (65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16) * pcmAttackCurve[p +  1] >> 14;
  2011:           pcmBuffer[i +  4] = (         3      * m0 +                   m1 >>  2) * pcmAttackCurve[p +  2] >> 14;
  2012:           pcmBuffer[i +  6] = (65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16) * pcmAttackCurve[p +  3] >> 14;
  2013:           pcmBuffer[i +  8] = (65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16) * pcmAttackCurve[p +  4] >> 14;
  2014:           pcmBuffer[i + 10] = (                  m0 +                   m1 >>  1) * pcmAttackCurve[p +  5] >> 14;
  2015:           pcmBuffer[i + 12] = (65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16) * pcmAttackCurve[p +  6] >> 14;
  2016:           pcmBuffer[i + 14] = (65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16) * pcmAttackCurve[p +  7] >> 14;
  2017:           pcmBuffer[i + 16] = (                  m0 +          3      * m1 >>  2) * pcmAttackCurve[p +  8] >> 14;
  2018:           pcmBuffer[i + 18] = (65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16) * pcmAttackCurve[p +  9] >> 14;
  2019:           pcmBuffer[i + 20] = (65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16) * pcmAttackCurve[p + 10] >> 14;
  2020:           pcmBuffer[i + 22] = (                                         m1      ) * pcmAttackCurve[p + 11] >> 14;
  2021:           p += 12;
  2022:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2023:         } else {  //OFF
  2024:           pcmBuffer[  i     ] = (
  2025:             pcmBuffer[i +  2] =
  2026:             pcmBuffer[i +  4] =
  2027:             pcmBuffer[i +  6] =
  2028:             pcmBuffer[i +  8] =
  2029:             pcmBuffer[i + 10] =
  2030:             pcmBuffer[i + 12] =
  2031:             pcmBuffer[i + 14] =
  2032:             pcmBuffer[i + 16] =
  2033:             pcmBuffer[i + 18] =
  2034:             pcmBuffer[i + 20] =
  2035:             pcmBuffer[i + 22] = 0);
  2036:         }
  2037:         p = pcmPanRight;
  2038:         if (p > 0) {  //ON
  2039:           int m0 = pcmDecodedData1;
  2040:           pcmBuffer[i +  1] = 65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16;
  2041:           pcmBuffer[i +  3] = 65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16;
  2042:           pcmBuffer[i +  5] =          3      * m0 +                   m1 >>  2;
  2043:           pcmBuffer[i +  7] = 65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16;
  2044:           pcmBuffer[i +  9] = 65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16;
  2045:           pcmBuffer[i + 11] =                   m0 +                   m1 >>  1;
  2046:           pcmBuffer[i + 13] = 65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16;
  2047:           pcmBuffer[i + 15] = 65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16;
  2048:           pcmBuffer[i + 17] =                   m0 +          3      * m1 >>  2;
  2049:           pcmBuffer[i + 19] = 65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16;
  2050:           pcmBuffer[i + 21] = 65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16;
  2051:           pcmBuffer[i + 23] =                                          m1;
  2052:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2053:           p = (char) p;
  2054:           int m0 = pcmDecodedData1;
  2055:           pcmBuffer[i +  1] = (65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16) * pcmAttackCurve[p     ] >> 14;
  2056:           pcmBuffer[i +  3] = (65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16) * pcmAttackCurve[p +  1] >> 14;
  2057:           pcmBuffer[i +  5] = (         3      * m0 +                   m1 >>  2) * pcmAttackCurve[p +  2] >> 14;
  2058:           pcmBuffer[i +  7] = (65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16) * pcmAttackCurve[p +  3] >> 14;
  2059:           pcmBuffer[i +  9] = (65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16) * pcmAttackCurve[p +  4] >> 14;
  2060:           pcmBuffer[i + 11] = (                  m0 +                   m1 >>  1) * pcmAttackCurve[p +  5] >> 14;
  2061:           pcmBuffer[i + 13] = (65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16) * pcmAttackCurve[p +  6] >> 14;
  2062:           pcmBuffer[i + 15] = (65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16) * pcmAttackCurve[p +  7] >> 14;
  2063:           pcmBuffer[i + 17] = (                  m0 +          3      * m1 >>  2) * pcmAttackCurve[p +  8] >> 14;
  2064:           pcmBuffer[i + 19] = (65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16) * pcmAttackCurve[p +  9] >> 14;
  2065:           pcmBuffer[i + 21] = (65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16) * pcmAttackCurve[p + 10] >> 14;
  2066:           pcmBuffer[i + 23] = (                                         m1      ) * pcmAttackCurve[p + 11] >> 14;
  2067:           p += 12;
  2068:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2069:         } else {  //OFF
  2070:           pcmBuffer[  i +  1] = (
  2071:             pcmBuffer[i +  3] =
  2072:             pcmBuffer[i +  5] =
  2073:             pcmBuffer[i +  7] =
  2074:             pcmBuffer[i +  9] =
  2075:             pcmBuffer[i + 11] =
  2076:             pcmBuffer[i + 13] =
  2077:             pcmBuffer[i + 15] =
  2078:             pcmBuffer[i + 17] =
  2079:             pcmBuffer[i + 19] =
  2080:             pcmBuffer[i + 21] =
  2081:             pcmBuffer[i + 23] = 0);
  2082:         }
  2083:         pcmDecodedData1 = m1;
  2084:         pcmPointer = i + 24;
  2085:       }
  2086:     },  //PIP_STEREO_LINEAR_12
  2087: 
  2088:     //ステレオ 線形補間 7812.50Hz
  2089:     PIP_STEREO_LINEAR_8 {
  2090:       @Override public void write (int m1) {
  2091:         int i = pcmPointer;
  2092:         int p = pcmPanLeft;
  2093:         if (p > 0) {  //ON
  2094:           int m0 = pcmDecodedData1;
  2095:           pcmBuffer[i     ] = 7 * m0 +     m1 >> 3;
  2096:           pcmBuffer[i +  2] = 3 * m0 +     m1 >> 2;
  2097:           pcmBuffer[i +  4] = 5 * m0 + 3 * m1 >> 3;
  2098:           pcmBuffer[i +  6] =     m0 +     m1 >> 1;
  2099:           pcmBuffer[i +  8] = 3 * m0 + 5 * m1 >> 3;
  2100:           pcmBuffer[i + 10] =     m0 + 3 * m1 >> 2;
  2101:           pcmBuffer[i + 12] =     m0 + 7 * m1 >> 3;
  2102:           pcmBuffer[i + 14] =              m1;
  2103:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2104:           p = (char) p;
  2105:           int m0 = pcmDecodedData1;
  2106:           pcmBuffer[i     ] = (7 * m0 +     m1 >> 3) * pcmAttackCurve[p    ] >> 14;
  2107:           pcmBuffer[i +  2] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p + 1] >> 14;
  2108:           pcmBuffer[i +  4] = (5 * m0 + 3 * m1 >> 3) * pcmAttackCurve[p + 2] >> 14;
  2109:           pcmBuffer[i +  6] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 3] >> 14;
  2110:           pcmBuffer[i +  8] = (3 * m0 + 5 * m1 >> 3) * pcmAttackCurve[p + 4] >> 14;
  2111:           pcmBuffer[i + 10] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 5] >> 14;
  2112:           pcmBuffer[i + 12] = (    m0 + 7 * m1 >> 3) * pcmAttackCurve[p + 6] >> 14;
  2113:           pcmBuffer[i + 14] = (             m1     ) * pcmAttackCurve[p + 7] >> 14;
  2114:           p += 8;
  2115:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2116:         } else {  //OFF
  2117:           pcmBuffer[  i     ] = (
  2118:             pcmBuffer[i +  2] =
  2119:             pcmBuffer[i +  4] =
  2120:             pcmBuffer[i +  6] =
  2121:             pcmBuffer[i +  8] =
  2122:             pcmBuffer[i + 10] =
  2123:             pcmBuffer[i + 12] =
  2124:             pcmBuffer[i + 14] = 0);
  2125:         }
  2126:         p = pcmPanRight;
  2127:         if (p > 0) {  //ON
  2128:           int m0 = pcmDecodedData1;
  2129:           pcmBuffer[i +  1] = 7 * m0 +     m1 >> 3;
  2130:           pcmBuffer[i +  3] = 3 * m0 +     m1 >> 2;
  2131:           pcmBuffer[i +  5] = 5 * m0 + 3 * m1 >> 3;
  2132:           pcmBuffer[i +  7] =     m0 +     m1 >> 1;
  2133:           pcmBuffer[i +  9] = 3 * m0 + 5 * m1 >> 3;
  2134:           pcmBuffer[i + 11] =     m0 + 3 * m1 >> 2;
  2135:           pcmBuffer[i + 13] =     m0 + 7 * m1 >> 3;
  2136:           pcmBuffer[i + 15] =              m1;
  2137:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2138:           p = (char) p;
  2139:           int m0 = pcmDecodedData1;
  2140:           pcmBuffer[i +  1] = (7 * m0 +     m1 >> 3) * pcmAttackCurve[p    ] >> 14;
  2141:           pcmBuffer[i +  3] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p + 1] >> 14;
  2142:           pcmBuffer[i +  5] = (5 * m0 + 3 * m1 >> 3) * pcmAttackCurve[p + 2] >> 14;
  2143:           pcmBuffer[i +  7] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 3] >> 14;
  2144:           pcmBuffer[i +  9] = (3 * m0 + 5 * m1 >> 3) * pcmAttackCurve[p + 4] >> 14;
  2145:           pcmBuffer[i + 11] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 5] >> 14;
  2146:           pcmBuffer[i + 13] = (    m0 + 7 * m1 >> 3) * pcmAttackCurve[p + 6] >> 14;
  2147:           pcmBuffer[i + 15] = (             m1     ) * pcmAttackCurve[p + 7] >> 14;
  2148:           p += 8;
  2149:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2150:         } else {  //OFF
  2151:           pcmBuffer[  i +  1] = (
  2152:             pcmBuffer[i +  3] =
  2153:             pcmBuffer[i +  5] =
  2154:             pcmBuffer[i +  7] =
  2155:             pcmBuffer[i +  9] =
  2156:             pcmBuffer[i + 11] =
  2157:             pcmBuffer[i + 13] =
  2158:             pcmBuffer[i + 15] = 0);
  2159:         }
  2160:         pcmDecodedData1 = m1;
  2161:         pcmPointer = i + 16;
  2162:       }
  2163:     },  //PIP_STEREO_LINEAR_8
  2164: 
  2165:     //ステレオ 線形補間 10416.67Hz
  2166:     PIP_STEREO_LINEAR_6 {
  2167:       @Override public void write (int m1) {
  2168:         int i = pcmPointer;
  2169:         int p = pcmPanLeft;
  2170:         if (p > 0) {  //ON
  2171:           int m0 = pcmDecodedData1;
  2172:           pcmBuffer[i     ] = 65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16;
  2173:           pcmBuffer[i +  2] = 65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16;
  2174:           pcmBuffer[i +  4] =                 m0 +                 m1 >>  1;
  2175:           pcmBuffer[i +  6] = 65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16;
  2176:           pcmBuffer[i +  8] = 65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16;
  2177:           pcmBuffer[i + 10] =                                      m1;
  2178:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2179:           p = (char) p;
  2180:           int m0 = pcmDecodedData1;
  2181:           pcmBuffer[i     ] = (65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  2182:           pcmBuffer[i +  2] = (65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  2183:           pcmBuffer[i +  4] = (                m0 +                 m1 >>  1) * pcmAttackCurve[p + 2] >> 14;
  2184:           pcmBuffer[i +  6] = (65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16) * pcmAttackCurve[p + 3] >> 14;
  2185:           pcmBuffer[i +  8] = (65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16) * pcmAttackCurve[p + 4] >> 14;
  2186:           pcmBuffer[i + 10] = (                                     m1      ) * pcmAttackCurve[p + 5] >> 14;
  2187:           p += 6;
  2188:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2189:         } else {  //OFF
  2190:           pcmBuffer[  i     ] = (
  2191:             pcmBuffer[i +  2] =
  2192:             pcmBuffer[i +  4] =
  2193:             pcmBuffer[i +  6] =
  2194:             pcmBuffer[i +  8] =
  2195:             pcmBuffer[i + 10] = 0);
  2196:         }
  2197:         p = pcmPanRight;
  2198:         if (p > 0) {  //ON
  2199:           int m0 = pcmDecodedData1;
  2200:           pcmBuffer[i +  1] = 65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16;
  2201:           pcmBuffer[i +  3] = 65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16;
  2202:           pcmBuffer[i +  5] =                 m0 +                 m1 >>  1;
  2203:           pcmBuffer[i +  7] = 65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16;
  2204:           pcmBuffer[i +  9] = 65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16;
  2205:           pcmBuffer[i + 11] =                                      m1;
  2206:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2207:           p = (char) p;
  2208:           int m0 = pcmDecodedData1;
  2209:           pcmBuffer[i +  1] = (65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  2210:           pcmBuffer[i +  3] = (65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  2211:           pcmBuffer[i +  5] = (                m0 +                 m1 >>  1) * pcmAttackCurve[p + 2] >> 14;
  2212:           pcmBuffer[i +  7] = (65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16) * pcmAttackCurve[p + 3] >> 14;
  2213:           pcmBuffer[i +  9] = (65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16) * pcmAttackCurve[p + 4] >> 14;
  2214:           pcmBuffer[i + 11] = (                                     m1      ) * pcmAttackCurve[p + 5] >> 14;
  2215:           p += 6;
  2216:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2217:         } else {  //OFF
  2218:           pcmBuffer[  i +  1] = (
  2219:             pcmBuffer[i +  3] =
  2220:             pcmBuffer[i +  5] =
  2221:             pcmBuffer[i +  7] =
  2222:             pcmBuffer[i +  9] =
  2223:             pcmBuffer[i + 11] = 0);
  2224:         }
  2225:         pcmDecodedData1 = m1;
  2226:         pcmPointer = i + 12;
  2227:       }
  2228:     },  //PIP_STEREO_LINEAR_6
  2229: 
  2230:     //ステレオ 線形補間 15625.00Hz
  2231:     PIP_STEREO_LINEAR_4 {
  2232:       @Override public void write (int m1) {
  2233:         int i = pcmPointer;
  2234:         int p = pcmPanLeft;
  2235:         if (p > 0) {  //ON
  2236:           int m0 = pcmDecodedData1;
  2237:           pcmBuffer[i    ] = 3 * m0 +     m1 >> 2;
  2238:           pcmBuffer[i + 2] =     m0 +     m1 >> 1;
  2239:           pcmBuffer[i + 4] =     m0 + 3 * m1 >> 2;
  2240:           pcmBuffer[i + 6] =              m1;
  2241:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2242:           p = (char) p;
  2243:           int m0 = pcmDecodedData1;
  2244:           pcmBuffer[i    ] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p    ] >> 14;
  2245:           pcmBuffer[i + 2] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 1] >> 14;
  2246:           pcmBuffer[i + 4] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 2] >> 14;
  2247:           pcmBuffer[i + 6] = (             m1     ) * pcmAttackCurve[p + 3] >> 14;
  2248:           p += 4;
  2249:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2250:         } else {  //OFF
  2251:           pcmBuffer[  i    ] = (
  2252:             pcmBuffer[i + 2] =
  2253:             pcmBuffer[i + 4] =
  2254:             pcmBuffer[i + 6] = 0);
  2255:         }
  2256:         p = pcmPanRight;
  2257:         if (p > 0) {  //ON
  2258:           int m0 = pcmDecodedData1;
  2259:           pcmBuffer[i + 1] = 3 * m0 +     m1 >> 2;
  2260:           pcmBuffer[i + 3] =     m0 +     m1 >> 1;
  2261:           pcmBuffer[i + 5] =     m0 + 3 * m1 >> 2;
  2262:           pcmBuffer[i + 7] =              m1;
  2263:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2264:           p = (char) p;
  2265:           int m0 = pcmDecodedData1;
  2266:           pcmBuffer[i + 1] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p    ] >> 14;
  2267:           pcmBuffer[i + 3] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 1] >> 14;
  2268:           pcmBuffer[i + 5] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 2] >> 14;
  2269:           pcmBuffer[i + 7] = (             m1     ) * pcmAttackCurve[p + 3] >> 14;
  2270:           p += 4;
  2271:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2272:         } else {  //OFF
  2273:           pcmBuffer[  i + 1] = (
  2274:             pcmBuffer[i + 3] =
  2275:             pcmBuffer[i + 5] =
  2276:             pcmBuffer[i + 7] = 0);
  2277:         }
  2278:         pcmDecodedData1 = m1;
  2279:         pcmPointer = i + 8;
  2280:       }
  2281:     },  //PIP_STEREO_LINEAR_4
  2282: 
  2283:     //ステレオ 線形補間 20833.33Hz
  2284:     PIP_STEREO_LINEAR_3 {
  2285:       @Override public void write (int m1) {
  2286:         int i = pcmPointer;
  2287:         int p = pcmPanLeft;
  2288:         if (p > 0) {  //ON
  2289:           int m0 = pcmDecodedData1;
  2290:           pcmBuffer[i    ] = 65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16;
  2291:           pcmBuffer[i + 2] = 65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16;
  2292:           pcmBuffer[i + 4] =                                      m1;
  2293:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2294:           p = (char) p;
  2295:           int m0 = pcmDecodedData1;
  2296:           pcmBuffer[i    ] = (65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  2297:           pcmBuffer[i + 2] = (65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  2298:           pcmBuffer[i + 4] = (                                     m1      ) * pcmAttackCurve[p + 2] >> 14;
  2299:           p += 3;
  2300:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2301:         } else {  //OFF
  2302:           pcmBuffer[  i    ] = (
  2303:             pcmBuffer[i + 2] =
  2304:             pcmBuffer[i + 4] = 0);
  2305:         }
  2306:         p = pcmPanRight;
  2307:         if (p > 0) {  //ON
  2308:           int m0 = pcmDecodedData1;
  2309:           pcmBuffer[i + 1] = 65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16;
  2310:           pcmBuffer[i + 3] = 65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16;
  2311:           pcmBuffer[i + 5] =                                      m1;
  2312:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2313:           p = (char) p;
  2314:           int m0 = pcmDecodedData1;
  2315:           pcmBuffer[i + 1] = (65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  2316:           pcmBuffer[i + 3] = (65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  2317:           pcmBuffer[i + 5] = (                                     m1      ) * pcmAttackCurve[p + 2] >> 14;
  2318:           p += 3;
  2319:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2320:         } else {  //OFF
  2321:           pcmBuffer[  i + 1] = (
  2322:             pcmBuffer[i + 3] =
  2323:             pcmBuffer[i + 5] = 0);
  2324:         }
  2325:         pcmDecodedData1 = m1;
  2326:         pcmPointer = i + 6;
  2327:       }
  2328:     },  //PIP_STEREO_LINEAR_3
  2329: 
  2330:     //ステレオ 線形補間 31250.00Hz
  2331:     PIP_STEREO_LINEAR_2 {
  2332:       @Override public void write (int m1) {
  2333:         int i = pcmPointer;
  2334:         int p = pcmPanLeft;
  2335:         if (p > 0) {  //ON
  2336:           int m0 = pcmDecodedData1;
  2337:           pcmBuffer[i    ] = m0 + m1 >> 1;
  2338:           pcmBuffer[i + 2] =      m1;
  2339:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2340:           p = (char) p;
  2341:           int m0 = pcmDecodedData1;
  2342:           pcmBuffer[i    ] = (m0 + m1 >> 1) * pcmAttackCurve[p    ] >> 14;
  2343:           pcmBuffer[i + 2] = (     m1     ) * pcmAttackCurve[p + 1] >> 14;
  2344:           p += 2;
  2345:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2346:         } else {  //OFF
  2347:           pcmBuffer[  i    ] = (
  2348:             pcmBuffer[i + 2] = 0);
  2349:         }
  2350:         p = pcmPanRight;
  2351:         if (p > 0) {  //ON
  2352:           int m0 = pcmDecodedData1;
  2353:           pcmBuffer[i + 1] = m0 + m1 >> 1;
  2354:           pcmBuffer[i + 3] =      m1;
  2355:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2356:           p = (char) p;
  2357:           int m0 = pcmDecodedData1;
  2358:           pcmBuffer[i + 1] = (m0 + m1 >> 1) * pcmAttackCurve[p    ] >> 14;
  2359:           pcmBuffer[i + 3] = (     m1     ) * pcmAttackCurve[p + 1] >> 14;
  2360:           p += 2;
  2361:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2362:         } else {  //OFF
  2363:           pcmBuffer[  i + 1] = (
  2364:             pcmBuffer[i + 3] = 0);
  2365:         }
  2366:         pcmDecodedData1 = m1;
  2367:         pcmPointer = i + 4;
  2368:       }
  2369:     },  //PIP_STEREO_LINEAR_2
  2370: 
  2371:     //ステレオ エルミート補間 3906.25Hz
  2372:     PIP_STEREO_HERMITE_16 {
  2373:       @Override public void write (int m2) {
  2374:         //  echo read("hermite.gp");hermite_code(2,16) | gp-2.7 -q
  2375:         int i = pcmPointer;
  2376:         int mm = pcmDecodedData3;
  2377:         int m0 = pcmDecodedData2;
  2378:         int m1 = pcmDecodedData1;
  2379:         int p = pcmPanLeft;
  2380:         if (p > 0) {  //ON
  2381:           pcmBuffer[i     ] =          -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13;
  2382:           pcmBuffer[i +  2] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  2383:           pcmBuffer[i +  4] =          -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13;
  2384:           pcmBuffer[i +  6] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2385:           pcmBuffer[i +  8] =          -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13;
  2386:           pcmBuffer[i + 10] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  2387:           pcmBuffer[i + 12] =          -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13;
  2388:           pcmBuffer[i + 14] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2389:           pcmBuffer[i + 16] =          -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13;
  2390:           pcmBuffer[i + 18] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  2391:           pcmBuffer[i + 20] =          -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13;
  2392:           pcmBuffer[i + 22] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2393:           pcmBuffer[i + 24] =          -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13;
  2394:           pcmBuffer[i + 26] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  2395:           pcmBuffer[i + 28] =           -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13;
  2396:           pcmBuffer[i + 30] =                                         m1;
  2397:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2398:           p = (char) p;
  2399:           pcmBuffer[i     ] = (         -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13) * pcmAttackCurve[p     ] >> 14;
  2400:           pcmBuffer[i +  2] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p +  1] >> 14;
  2401:           pcmBuffer[i +  4] = (         -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13) * pcmAttackCurve[p +  2] >> 14;
  2402:           pcmBuffer[i +  6] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p +  3] >> 14;
  2403:           pcmBuffer[i +  8] = (         -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13) * pcmAttackCurve[p +  4] >> 14;
  2404:           pcmBuffer[i + 10] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p +  5] >> 14;
  2405:           pcmBuffer[i + 12] = (         -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13) * pcmAttackCurve[p +  6] >> 14;
  2406:           pcmBuffer[i + 14] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p +  7] >> 14;
  2407:           pcmBuffer[i + 16] = (         -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13) * pcmAttackCurve[p +  8] >> 14;
  2408:           pcmBuffer[i + 18] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p +  9] >> 14;
  2409:           pcmBuffer[i + 20] = (         -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13) * pcmAttackCurve[p + 10] >> 14;
  2410:           pcmBuffer[i + 22] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 11] >> 14;
  2411:           pcmBuffer[i + 24] = (         -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13) * pcmAttackCurve[p + 12] >> 14;
  2412:           pcmBuffer[i + 26] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 13] >> 14;
  2413:           pcmBuffer[i + 28] = (          -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13) * pcmAttackCurve[p + 14] >> 14;
  2414:           pcmBuffer[i + 30] = (                                        m1                  ) * pcmAttackCurve[p + 15] >> 14;
  2415:           p += 16;
  2416:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2417:         } else {  //OFF
  2418:           pcmBuffer[  i     ] = (
  2419:             pcmBuffer[i +  2] =
  2420:             pcmBuffer[i +  4] =
  2421:             pcmBuffer[i +  6] =
  2422:             pcmBuffer[i +  8] =
  2423:             pcmBuffer[i + 10] =
  2424:             pcmBuffer[i + 12] =
  2425:             pcmBuffer[i + 14] =
  2426:             pcmBuffer[i + 16] =
  2427:             pcmBuffer[i + 18] =
  2428:             pcmBuffer[i + 20] =
  2429:             pcmBuffer[i + 22] =
  2430:             pcmBuffer[i + 24] =
  2431:             pcmBuffer[i + 26] =
  2432:             pcmBuffer[i + 28] =
  2433:             pcmBuffer[i + 30] = 0);
  2434:         }
  2435:         p = pcmPanRight;
  2436:         if (p > 0) {  //ON
  2437:           pcmBuffer[i +  1] =          -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13;
  2438:           pcmBuffer[i +  3] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  2439:           pcmBuffer[i +  5] =          -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13;
  2440:           pcmBuffer[i +  7] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2441:           pcmBuffer[i +  9] =          -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13;
  2442:           pcmBuffer[i + 11] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  2443:           pcmBuffer[i + 13] =          -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13;
  2444:           pcmBuffer[i + 15] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2445:           pcmBuffer[i + 17] =          -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13;
  2446:           pcmBuffer[i + 19] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  2447:           pcmBuffer[i + 21] =          -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13;
  2448:           pcmBuffer[i + 23] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2449:           pcmBuffer[i + 25] =          -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13;
  2450:           pcmBuffer[i + 27] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  2451:           pcmBuffer[i + 29] =           -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13;
  2452:           pcmBuffer[i + 31] =                                         m1;
  2453:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2454:           p = (char) p;
  2455:           pcmBuffer[i +  1] = (         -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13) * pcmAttackCurve[p     ] >> 14;
  2456:           pcmBuffer[i +  3] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p +  1] >> 14;
  2457:           pcmBuffer[i +  5] = (         -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13) * pcmAttackCurve[p +  2] >> 14;
  2458:           pcmBuffer[i +  7] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p +  3] >> 14;
  2459:           pcmBuffer[i +  9] = (         -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13) * pcmAttackCurve[p +  4] >> 14;
  2460:           pcmBuffer[i + 11] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p +  5] >> 14;
  2461:           pcmBuffer[i + 13] = (         -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13) * pcmAttackCurve[p +  6] >> 14;
  2462:           pcmBuffer[i + 15] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p +  7] >> 14;
  2463:           pcmBuffer[i + 17] = (         -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13) * pcmAttackCurve[p +  8] >> 14;
  2464:           pcmBuffer[i + 19] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p +  9] >> 14;
  2465:           pcmBuffer[i + 21] = (         -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13) * pcmAttackCurve[p + 10] >> 14;
  2466:           pcmBuffer[i + 23] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 11] >> 14;
  2467:           pcmBuffer[i + 25] = (         -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13) * pcmAttackCurve[p + 12] >> 14;
  2468:           pcmBuffer[i + 27] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 13] >> 14;
  2469:           pcmBuffer[i + 29] = (          -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13) * pcmAttackCurve[p + 14] >> 14;
  2470:           pcmBuffer[i + 31] = (                                        m1                  ) * pcmAttackCurve[p + 15] >> 14;
  2471:           p += 16;
  2472:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2473:         } else {  //OFF
  2474:           pcmBuffer[  i +  1] = (
  2475:             pcmBuffer[i +  3] =
  2476:             pcmBuffer[i +  5] =
  2477:             pcmBuffer[i +  7] =
  2478:             pcmBuffer[i +  9] =
  2479:             pcmBuffer[i + 11] =
  2480:             pcmBuffer[i + 13] =
  2481:             pcmBuffer[i + 15] =
  2482:             pcmBuffer[i + 17] =
  2483:             pcmBuffer[i + 19] =
  2484:             pcmBuffer[i + 21] =
  2485:             pcmBuffer[i + 23] =
  2486:             pcmBuffer[i + 25] =
  2487:             pcmBuffer[i + 27] =
  2488:             pcmBuffer[i + 29] =
  2489:             pcmBuffer[i + 31] = 0);
  2490:         }
  2491:         pcmDecodedData3 = m0;
  2492:         pcmDecodedData2 = m1;
  2493:         pcmDecodedData1 = m2;
  2494:         pcmPointer = i + 32;
  2495:       }
  2496:     },  //PIP_STEREO_HERMITE_16
  2497: 
  2498:     //ステレオ エルミート補間 5208.33Hz
  2499:     PIP_STEREO_HERMITE_12 {
  2500:       @Override public void write (int m2) {
  2501:         //  echo read("hermite.gp");hermite_code(2,12) | gp-2.7 -q
  2502:         int i = pcmPointer;
  2503:         int mm = pcmDecodedData3;
  2504:         int m0 = pcmDecodedData2;
  2505:         int m1 = pcmDecodedData1;
  2506:         int p = pcmPanLeft;
  2507:         if (p > 0) {  //ON
  2508:           pcmBuffer[i     ] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32);
  2509:           pcmBuffer[i +  2] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  2510:           pcmBuffer[i +  4] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2511:           pcmBuffer[i +  6] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  2512:           pcmBuffer[i +  8] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32);
  2513:           pcmBuffer[i + 10] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2514:           pcmBuffer[i + 12] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32);
  2515:           pcmBuffer[i + 14] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  2516:           pcmBuffer[i + 16] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2517:           pcmBuffer[i + 18] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  2518:           pcmBuffer[i + 20] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32);
  2519:           pcmBuffer[i + 22] =                                         m1;
  2520:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2521:           p = (char) p;
  2522:           pcmBuffer[i     ] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32) * pcmAttackCurve[p     ] >> 14;
  2523:           pcmBuffer[i +  2] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  1] >> 14;
  2524:           pcmBuffer[i +  4] =       (    -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7               ) * pcmAttackCurve[p +  2] >> 14;
  2525:           pcmBuffer[i +  6] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p +  3] >> 14;
  2526:           pcmBuffer[i +  8] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  4] >> 14;
  2527:           pcmBuffer[i + 10] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p +  5] >> 14;
  2528:           pcmBuffer[i + 12] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  6] >> 14;
  2529:           pcmBuffer[i + 14] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p +  7] >> 14;
  2530:           pcmBuffer[i + 16] =       (    -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7               ) * pcmAttackCurve[p +  8] >> 14;
  2531:           pcmBuffer[i + 18] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  9] >> 14;
  2532:           pcmBuffer[i + 20] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32) * pcmAttackCurve[p + 10] >> 14;
  2533:           pcmBuffer[i + 22] =       (                                 m1                                 ) * pcmAttackCurve[p + 11] >> 14;
  2534:           p += 12;
  2535:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2536:         } else {  //OFF
  2537:           pcmBuffer[  i     ] = (
  2538:             pcmBuffer[i +  2] =
  2539:             pcmBuffer[i +  4] =
  2540:             pcmBuffer[i +  6] =
  2541:             pcmBuffer[i +  8] =
  2542:             pcmBuffer[i + 10] =
  2543:             pcmBuffer[i + 12] =
  2544:             pcmBuffer[i + 14] =
  2545:             pcmBuffer[i + 16] =
  2546:             pcmBuffer[i + 18] =
  2547:             pcmBuffer[i + 20] =
  2548:             pcmBuffer[i + 22] = 0);
  2549:         }
  2550:         p = pcmPanRight;
  2551:         if (p > 0) {  //ON
  2552:           pcmBuffer[i +  1] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32);
  2553:           pcmBuffer[i +  3] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  2554:           pcmBuffer[i +  5] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2555:           pcmBuffer[i +  7] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  2556:           pcmBuffer[i +  9] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32);
  2557:           pcmBuffer[i + 11] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2558:           pcmBuffer[i + 13] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32);
  2559:           pcmBuffer[i + 15] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  2560:           pcmBuffer[i + 17] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2561:           pcmBuffer[i + 19] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  2562:           pcmBuffer[i + 21] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32);
  2563:           pcmBuffer[i + 23] =                                         m1;
  2564:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2565:           p = (char) p;
  2566:           pcmBuffer[i +  1] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32) * pcmAttackCurve[p     ] >> 14;
  2567:           pcmBuffer[i +  3] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  1] >> 14;
  2568:           pcmBuffer[i +  5] =       (    -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7               ) * pcmAttackCurve[p +  2] >> 14;
  2569:           pcmBuffer[i +  7] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p +  3] >> 14;
  2570:           pcmBuffer[i +  9] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  4] >> 14;
  2571:           pcmBuffer[i + 11] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p +  5] >> 14;
  2572:           pcmBuffer[i + 13] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  6] >> 14;
  2573:           pcmBuffer[i + 15] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p +  7] >> 14;
  2574:           pcmBuffer[i + 17] =       (    -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7               ) * pcmAttackCurve[p +  8] >> 14;
  2575:           pcmBuffer[i + 19] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  9] >> 14;
  2576:           pcmBuffer[i + 21] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32) * pcmAttackCurve[p + 10] >> 14;
  2577:           pcmBuffer[i + 23] =       (                                 m1                                 ) * pcmAttackCurve[p + 11] >> 14;
  2578:           p += 12;
  2579:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2580:         } else {  //OFF
  2581:           pcmBuffer[  i +  1] = (
  2582:             pcmBuffer[i +  3] =
  2583:             pcmBuffer[i +  5] =
  2584:             pcmBuffer[i +  7] =
  2585:             pcmBuffer[i +  9] =
  2586:             pcmBuffer[i + 11] =
  2587:             pcmBuffer[i + 13] =
  2588:             pcmBuffer[i + 15] =
  2589:             pcmBuffer[i + 17] =
  2590:             pcmBuffer[i + 19] =
  2591:             pcmBuffer[i + 21] =
  2592:             pcmBuffer[i + 23] = 0);
  2593:         }
  2594:         pcmDecodedData3 = m0;
  2595:         pcmDecodedData2 = m1;
  2596:         pcmDecodedData1 = m2;
  2597:         pcmPointer = i + 24;
  2598:       }
  2599:     },  //PIP_STEREO_HERMITE_12
  2600: 
  2601:     //ステレオ エルミート補間 7812.50Hz
  2602:     PIP_STEREO_HERMITE_8 {
  2603:       @Override public void write (int m2) {
  2604:         //  echo read("hermite.gp");hermite_code(2,8) | gp-2.7 -q
  2605:         int i = pcmPointer;
  2606:         int mm = pcmDecodedData3;
  2607:         int m0 = pcmDecodedData2;
  2608:         int m1 = pcmDecodedData1;
  2609:         int p = pcmPanLeft;
  2610:         if (p > 0) {  //ON
  2611:           pcmBuffer[i     ] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  2612:           pcmBuffer[i +  2] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2613:           pcmBuffer[i +  4] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  2614:           pcmBuffer[i +  6] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2615:           pcmBuffer[i +  8] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  2616:           pcmBuffer[i + 10] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2617:           pcmBuffer[i + 12] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  2618:           pcmBuffer[i + 14] =                                         m1;
  2619:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2620:           p = (char) p;
  2621:           pcmBuffer[i     ] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p    ] >> 14;
  2622:           pcmBuffer[i +  2] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p + 1] >> 14;
  2623:           pcmBuffer[i +  4] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p + 2] >> 14;
  2624:           pcmBuffer[i +  6] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 3] >> 14;
  2625:           pcmBuffer[i +  8] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p + 4] >> 14;
  2626:           pcmBuffer[i + 10] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 5] >> 14;
  2627:           pcmBuffer[i + 12] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 6] >> 14;
  2628:           pcmBuffer[i + 14] = (                                        m1                  ) * pcmAttackCurve[p + 7] >> 14;
  2629:           p += 8;
  2630:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2631:         } else {  //OFF
  2632:           pcmBuffer[  i     ] = (
  2633:             pcmBuffer[i +  2] =
  2634:             pcmBuffer[i +  4] =
  2635:             pcmBuffer[i +  6] =
  2636:             pcmBuffer[i +  8] =
  2637:             pcmBuffer[i + 10] =
  2638:             pcmBuffer[i + 12] =
  2639:             pcmBuffer[i + 14] = 0);
  2640:         }
  2641:         p = pcmPanRight;
  2642:         if (p > 0) {  //ON
  2643:           pcmBuffer[i +  1] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  2644:           pcmBuffer[i +  3] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2645:           pcmBuffer[i +  5] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  2646:           pcmBuffer[i +  7] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2647:           pcmBuffer[i +  9] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  2648:           pcmBuffer[i + 11] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2649:           pcmBuffer[i + 13] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  2650:           pcmBuffer[i + 15] =                                         m1;
  2651:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2652:           p = (char) p;
  2653:           pcmBuffer[i +  1] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p    ] >> 14;
  2654:           pcmBuffer[i +  3] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p + 1] >> 14;
  2655:           pcmBuffer[i +  5] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p + 2] >> 14;
  2656:           pcmBuffer[i +  7] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 3] >> 14;
  2657:           pcmBuffer[i +  9] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p + 4] >> 14;
  2658:           pcmBuffer[i + 11] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 5] >> 14;
  2659:           pcmBuffer[i + 13] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 6] >> 14;
  2660:           pcmBuffer[i + 15] = (                                        m1                  ) * pcmAttackCurve[p + 7] >> 14;
  2661:           p += 8;
  2662:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2663:         } else {  //OFF
  2664:           pcmBuffer[  i +  1] = (
  2665:             pcmBuffer[i +  3] =
  2666:             pcmBuffer[i +  5] =
  2667:             pcmBuffer[i +  7] =
  2668:             pcmBuffer[i +  9] =
  2669:             pcmBuffer[i + 11] =
  2670:             pcmBuffer[i + 13] =
  2671:             pcmBuffer[i + 15] = 0);
  2672:         }
  2673:         pcmDecodedData3 = m0;
  2674:         pcmDecodedData2 = m1;
  2675:         pcmDecodedData1 = m2;
  2676:         pcmPointer = i + 16;
  2677:       }
  2678:     },  //PIP_STEREO_HERMITE_8
  2679: 
  2680:     //ステレオ エルミート補間 10416.67Hz
  2681:     PIP_STEREO_HERMITE_6 {
  2682:       @Override public void write (int m2) {
  2683:         //  echo read("hermite.gp");hermite_code(2,6) | gp-2.7 -q
  2684:         int i = pcmPointer;
  2685:         int mm = pcmDecodedData3;
  2686:         int m0 = pcmDecodedData2;
  2687:         int m1 = pcmDecodedData1;
  2688:         int p = pcmPanLeft;
  2689:         if (p > 0) {  //ON
  2690:           pcmBuffer[i     ] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  2691:           pcmBuffer[i +  2] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  2692:           pcmBuffer[i +  4] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2693:           pcmBuffer[i +  6] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  2694:           pcmBuffer[i +  8] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  2695:           pcmBuffer[i + 10] =                                         m1;
  2696:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2697:           p = (char) p;
  2698:           pcmBuffer[i     ] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p    ] >> 14;
  2699:           pcmBuffer[i +  2] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  2700:           pcmBuffer[i +  4] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p + 2] >> 14;
  2701:           pcmBuffer[i +  6] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 3] >> 14;
  2702:           pcmBuffer[i +  8] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p + 4] >> 14;
  2703:           pcmBuffer[i + 10] =       (                                 m1                                 ) * pcmAttackCurve[p + 5] >> 14;
  2704:           p += 6;
  2705:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2706:         } else {  //OFF
  2707:           pcmBuffer[  i     ] = (
  2708:             pcmBuffer[i +  2] =
  2709:             pcmBuffer[i +  4] =
  2710:             pcmBuffer[i +  6] =
  2711:             pcmBuffer[i +  8] =
  2712:             pcmBuffer[i + 10] = 0);
  2713:         }
  2714:         p = pcmPanRight;
  2715:         if (p > 0) {  //ON
  2716:           pcmBuffer[i +  1] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  2717:           pcmBuffer[i +  3] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  2718:           pcmBuffer[i +  5] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2719:           pcmBuffer[i +  7] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  2720:           pcmBuffer[i +  9] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  2721:           pcmBuffer[i + 11] =                                         m1;
  2722:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2723:           p = (char) p;
  2724:           pcmBuffer[i +  1] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p    ] >> 14;
  2725:           pcmBuffer[i +  3] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  2726:           pcmBuffer[i +  5] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p + 2] >> 14;
  2727:           pcmBuffer[i +  7] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 3] >> 14;
  2728:           pcmBuffer[i +  9] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p + 4] >> 14;
  2729:           pcmBuffer[i + 11] =       (                                 m1                                 ) * pcmAttackCurve[p + 5] >> 14;
  2730:           p += 6;
  2731:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2732:         } else {  //OFF
  2733:           pcmBuffer[  i +  1] = (
  2734:             pcmBuffer[i +  3] =
  2735:             pcmBuffer[i +  5] =
  2736:             pcmBuffer[i +  7] =
  2737:             pcmBuffer[i +  9] =
  2738:             pcmBuffer[i + 11] = 0);
  2739:         }
  2740:         pcmDecodedData3 = m0;
  2741:         pcmDecodedData2 = m1;
  2742:         pcmDecodedData1 = m2;
  2743:         pcmPointer = i + 6;
  2744:       }
  2745:     },  //PIP_STEREO_HERMITE_6
  2746: 
  2747:     //ステレオ エルミート補間 15625.00Hz
  2748:     PIP_STEREO_HERMITE_4 {
  2749:       @Override public void write (int m2) {
  2750:         //  echo read("hermite.gp");hermite_code(2,4) | gp-2.7 -q
  2751:         int i = pcmPointer;
  2752:         int mm = pcmDecodedData3;
  2753:         int m0 = pcmDecodedData2;
  2754:         int m1 = pcmDecodedData1;
  2755:         int p = pcmPanLeft;
  2756:         if (p > 0) {  //ON
  2757:           pcmBuffer[i    ] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2758:           pcmBuffer[i + 2] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2759:           pcmBuffer[i + 4] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2760:           pcmBuffer[i + 6] =                                         m1;
  2761:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2762:           p = (char) p;
  2763:           pcmBuffer[i    ] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p    ] >> 14;
  2764:           pcmBuffer[i + 2] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 1] >> 14;
  2765:           pcmBuffer[i + 4] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 2] >> 14;
  2766:           pcmBuffer[i + 6] = (                                        m1                  ) * pcmAttackCurve[p + 3] >> 14;
  2767:           p += 4;
  2768:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2769:         } else {  //OFF
  2770:           pcmBuffer[  i    ] = (
  2771:             pcmBuffer[i + 2] =
  2772:             pcmBuffer[i + 4] =
  2773:             pcmBuffer[i + 6] = 0);
  2774:         }
  2775:         p = pcmPanRight;
  2776:         if (p > 0) {  //ON
  2777:           pcmBuffer[i + 1] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2778:           pcmBuffer[i + 3] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2779:           pcmBuffer[i + 5] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2780:           pcmBuffer[i + 7] =                                         m1;
  2781:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2782:           p = (char) p;
  2783:           pcmBuffer[i + 1] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p    ] >> 14;
  2784:           pcmBuffer[i + 3] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 1] >> 14;
  2785:           pcmBuffer[i + 5] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 2] >> 14;
  2786:           pcmBuffer[i + 7] = (                                        m1                  ) * pcmAttackCurve[p + 3] >> 14;
  2787:           p += 4;
  2788:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2789:         } else {  //OFF
  2790:           pcmBuffer[  i + 1] = (
  2791:             pcmBuffer[i + 3] =
  2792:             pcmBuffer[i + 5] =
  2793:             pcmBuffer[i + 7] = 0);
  2794:         }
  2795:         pcmDecodedData3 = m0;
  2796:         pcmDecodedData2 = m1;
  2797:         pcmDecodedData1 = m2;
  2798:         pcmPointer = i + 8;
  2799:       }
  2800:     },  //PIP_STEREO_HERMITE_4
  2801: 
  2802:     //ステレオ エルミート補間 20833.33Hz
  2803:     PIP_STEREO_HERMITE_3 {
  2804:       @Override public void write (int m2) {
  2805:         //  echo read("hermite.gp");hermite_code(2,3) | gp-2.7 -q
  2806:         int i = pcmPointer;
  2807:         int mm = pcmDecodedData3;
  2808:         int m0 = pcmDecodedData2;
  2809:         int m1 = pcmDecodedData1;
  2810:         int p = pcmPanLeft;
  2811:         if (p > 0) {  //ON
  2812:           pcmBuffer[i    ] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  2813:           pcmBuffer[i + 2] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  2814:           pcmBuffer[i + 4] =                                         m1;
  2815:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2816:           p = (char) p;
  2817:           pcmBuffer[i    ] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p    ] >> 14;
  2818:           pcmBuffer[i + 2] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  2819:           pcmBuffer[i + 4] =       (                                 m1                                 ) * pcmAttackCurve[p + 2] >> 14;
  2820:           p += 3;
  2821:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2822:         } else {  //OFF
  2823:           pcmBuffer[  i    ] = (
  2824:             pcmBuffer[i + 2] =
  2825:             pcmBuffer[i + 4] = 0);
  2826:         }
  2827:         p = pcmPanRight;
  2828:         if (p > 0) {  //ON
  2829:           pcmBuffer[i + 1] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  2830:           pcmBuffer[i + 3] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  2831:           pcmBuffer[i + 5] =                                         m1;
  2832:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2833:           p = (char) p;
  2834:           pcmBuffer[i + 1] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p    ] >> 14;
  2835:           pcmBuffer[i + 3] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  2836:           pcmBuffer[i + 5] =       (                                 m1                                 ) * pcmAttackCurve[p + 2] >> 14;
  2837:           p += 3;
  2838:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2839:         } else {  //OFF
  2840:           pcmBuffer[  i + 1] = (
  2841:             pcmBuffer[i + 3] =
  2842:             pcmBuffer[i + 5] = 0);
  2843:         }
  2844:         pcmDecodedData3 = m0;
  2845:         pcmDecodedData2 = m1;
  2846:         pcmDecodedData1 = m2;
  2847:         pcmPointer = i + 6;
  2848:       }
  2849:     },  //PIP_STEREO_HERMITE_3
  2850: 
  2851:     //ステレオ エルミート補間 31250.00Hz
  2852:     PIP_STEREO_HERMITE_2 {
  2853:       @Override public void write (int m2) {
  2854:         //  echo read("hermite.gp");hermite_code(2,2) | gp-2.7 -q
  2855:         int i = pcmPointer;
  2856:         int mm = pcmDecodedData3;
  2857:         int m0 = pcmDecodedData2;
  2858:         int m1 = pcmDecodedData1;
  2859:         int p = pcmPanLeft;
  2860:         if (p > 0) {  //ON
  2861:           pcmBuffer[i    ] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2862:           pcmBuffer[i + 2] =                                         m1;
  2863:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2864:           p = (char) p;
  2865:           pcmBuffer[i    ] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p    ] >> 14;
  2866:           pcmBuffer[i + 2] = (                                        m1                  ) * pcmAttackCurve[p + 1] >> 14;
  2867:           p += 2;
  2868:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2869:         } else {  //OFF
  2870:           pcmBuffer[  i    ] = (
  2871:             pcmBuffer[i + 2] = 0);
  2872:         }
  2873:         p = pcmPanRight;
  2874:         if (p > 0) {  //ON
  2875:           pcmBuffer[i + 1] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2876:           pcmBuffer[i + 3] =                                         m1;
  2877:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2878:           p = (char) p;
  2879:           pcmBuffer[i + 1] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p    ] >> 14;
  2880:           pcmBuffer[i + 3] = (                                        m1                  ) * pcmAttackCurve[p + 1] >> 14;
  2881:           p += 2;
  2882:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2883:         } else {  //OFF
  2884:           pcmBuffer[  i + 1] = (
  2885:             pcmBuffer[i + 3] = 0);
  2886:         }
  2887:         pcmDecodedData3 = m0;
  2888:         pcmDecodedData2 = m1;
  2889:         pcmDecodedData1 = m2;
  2890:         pcmPointer = i + 4;
  2891:       }
  2892:     };  //PIP_STEREO_HERMITE_2
  2893: 
  2894:     public abstract void write (int m);
  2895: 
  2896:   }  //enum PIP
  2897: 
  2898: 
  2899: 
  2900: }  //class ADPCM
  2901: 
  2902: 
  2903: