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-2017 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: //  http://stdkmd.com/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=768
    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=1/512
    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:   //pcmInit ()
   305:   //  PCMを初期化する
   306:   public static void pcmInit () {
   307:     //動作
   308:     //pcmOutputOn = true;
   309:     pcmActive = false;
   310:     pcmEncodedData = -1;
   311:     pcmDecodedData1 = 0;
   312:     pcmDecodedData2 = 0;
   313:     pcmDecodedData3 = 0;
   314:     //ADPCM→PCM変換
   315:     //  4bitデータのADPCM→PCM変換テーブルを作る
   316:     //    d4[予測指標<<4|4bitデータ] = 4bitデータに対応する差分
   317:     //    p4[予測指標<<4|4bitデータ] = 次の予測指標
   318:     int[] d4 = new int[16 * 49];
   319:     int[] p4 = new int[16 * 49];
   320:     for (int p = 0; p < 49; p++) {  //予測指標
   321:       int x = (int) Math.floor (16.0 * Math.pow (1.1, p));  //PCM8.X,PCMLIB.a,MAMEなど
   322:       //int x = (int) Math.floor (32768.0 / Math.pow (1.1, (double) (80 - p)));  //PCM8A.X
   323:       for (int n = 0; n < 16; n++) {  //4bitデータ
   324:         int i = p << 4 | n;
   325:         d4[i] = (1 - (n >> 2 & 2)) * ((n >> 2 & 1) * x + (n >> 1 & 1) * (x >> 1) + (n & 1) * (x >> 2) + (x >> 3));  //4bitデータに対応する差分
   326:         p4[i] = Math.max (0, Math.min (48, p + ((n & 7) - 4 >> 3 | (n & 3) + 1 << 1)));  //次の予測指標。p+={-1,-1,-1,-1,2,4,6,8}[n&7]
   327:         if (false) {
   328:           System.out.printf ("(%2d,%2d,%5d,%2d),", p, n, d4[i], p4[i]);
   329:           if ((n & 7) == 7) {
   330:             System.out.println ();
   331:           }
   332:         }
   333:       }
   334:     }
   335:     //  8bitデータのADPCM→PCM変換テーブルを作る
   336:     //pcmDecoderTable = new int[256 * 49];
   337:     //pcmDecoderTableP = new int[256 * 49];
   338:     //pcmDecoderTableM = new int[256 * 49];
   339:     for (int p = 0; p < 49; p++) {  //予測指標
   340:       for (int n2 = 0; n2 < 16; n2++) {  //8bitデータの上位4bit
   341:         int i4 = p << 8 | n2 << 4;
   342:         for (int n1 = 0; n1 < 16; n1++) {  //8bitデータの下位4bit
   343:           int i = p << 4 | n1;
   344:           int delta1 = d4[i];  //8bitデータの下位4ビットに対応する差分
   345:           i = p4[i] << 4 | n2;
   346:           int delta2 = d4[i];  //8bitデータの上位4ビットに対応する差分
   347:           int q = p4[i];  //次の予測指標
   348:           int t = delta1 << 19 | (delta2 & 8191) << 6 | q;
   349:           pcmDecoderTable[i4 | n1] = t;
   350:           if (PCM_MODIFY_ZERO_ZERO) {
   351:             //pcmDecoderTablePは0x00の、pcmDecoderTableMは0x88の、delta1を符号反転する
   352:             //  notで-1から引いてから1を加えれば0から引いたことになる
   353:             pcmDecoderTableP[i4 | n1] = n1 == 0 && n2 == 0 ? (t ^ -1 << 19) + (1 << 19) : t;
   354:             pcmDecoderTableM[i4 | n1] = n1 == 8 && n2 == 8 ? (t ^ -1 << 19) + (1 << 19) : t;
   355:           }
   356:         }
   357:       }
   358:     }
   359:     if (PCM_MODIFY_ZERO_TWICE) {
   360:       pcmZeroPreviousData = -1;
   361:     }
   362:     //補間
   363:     //pcmInterpolationAlgorithm = PCM_INTERPOLATION_LINEAR;
   364:     //アタック
   365:     //pcmAttackCurve = new int[PCM_ATTACK_SPAN * 4];
   366:     for (int i = 0; i < PCM_ATTACK_SPAN; i++) {
   367:       pcmAttackCurve[i] =
   368:         (int) Math.round (0.5 * (double) (1 << PCM_ATTACK_SHIFT) *
   369:                           (1.0 + Math.cos (Math.PI / (double) PCM_ATTACK_SPAN * (double) i)));  //(1+cos(0→π))/2=1→0
   370:       pcmAttackCurve[PCM_ATTACK_SPAN * 2 + i] =
   371:         (int) Math.round (0.5 * (double) (1 << PCM_ATTACK_SHIFT) *
   372:                           (1.0 + Math.cos (Math.PI / (double) PCM_ATTACK_SPAN * (double) i)));  //(1-cos(0→π))/2=0→1
   373:     }
   374:     Arrays.fill (pcmAttackCurve, PCM_ATTACK_SPAN, PCM_ATTACK_SPAN * 2, 0);
   375:     Arrays.fill (pcmAttackCurve, PCM_ATTACK_SPAN * 3, PCM_ATTACK_SPAN * 4, 1 << PCM_ATTACK_SHIFT);
   376:     pcmPanLeft = 0;
   377:     if (SoundSource.SND_CHANNELS == 2) {  //ステレオ
   378:       pcmPanRight = 0;
   379:     }
   380:     //バッファ
   381:     //pcmBuffer = new int[SoundSource.SND_CHANNELS * (PCM_BLOCK_SAMPLES + PCM_MAX_REPEAT * 2)];
   382:     //リセット
   383:     pcmReset ();
   384:   }  //pcmInit()
   385: 
   386:   //リセット
   387:   public static void pcmReset () {
   388:     //原発振周波数、分周比、パン
   389:     //pcmOSCFreqRequest = 0;  //8MHz/4MHz
   390:     pcmOSCFreqMode = 0;  //8MHz/4MHz
   391:     pcmOscillator = 0;  //8MHz/8MHz
   392:     pcmDivider = 2;  //1/512
   393:     pcmUpdateRepeatInterval ();
   394:     pcmSetPan (0);  //LeftON,RightON
   395:     //ADPCM→PCM変換
   396:     pcmDecoderPointer = 0;
   397:     //バッファ
   398:     Arrays.fill (pcmBuffer, 0);
   399:     pcmPointer = 0;
   400:     //タイマ
   401:     pcmClock = XEiJ.FAR_FUTURE;
   402:     TickerQueue.tkqRemove (SoundSource.sndPcmTicker);
   403:     //動作
   404:     pcmActive = false;  //ADPCM出力停止
   405:     pcmEncodedData = -1;  //ADPCMデータなし
   406:   }  //pcmReset()
   407: 
   408:   //pcmUpdateRepeatInterval ()
   409:   //  原発振周波数と分周比に従ってADPCMのサンプリング周波数を設定する
   410:   public static void pcmUpdateRepeatInterval () {
   411:     pcmRepeat = PCM_SAMPLE_REPEAT[pcmOSCFreqMode << 3 | pcmOscillator << 2 | pcmDivider];
   412:     pcmInterval = PCM_SAMPLE_TIME * 2 * pcmRepeat;
   413:     pcmSetInterpolationAlgorithm (pcmInterpolationAlgorithm);
   414:   }  //pcmUpdateRepeatInterval()
   415: 
   416:   //pcmSetInterpolationAlgorithm (algorithm)
   417:   //  補間アルゴリズムを指定する
   418:   public static void pcmSetInterpolationAlgorithm (int algorithm) {
   419:     pcmInterpolationAlgorithm = algorithm;
   420:     pcmInterpolationEngine = (SoundSource.SND_CHANNELS == 1 ? PCM_INTERPOLATION_MONO : PCM_INTERPOLATION_STEREO)
   421:       [algorithm][pcmOSCFreqMode << 3 | pcmOscillator << 2 | pcmDivider];
   422:   }  //pcmSetInterpolationAlgorithm(int)
   423: 
   424:   //pcmSetOutputOn (on)
   425:   //  PCM出力のON/OFF
   426:   public static void pcmSetOutputOn (boolean on) {
   427:     pcmOutputOn = on;
   428:     pcmSetPan (XEiJ.ppiPortC);
   429:   }  //pcmSetOutputOn(boolean)
   430: 
   431:   //pcmSetPan (pan)
   432:   //  発音するチャンネルの設定
   433:   //  bit0  0=RightON,1=RightOFF
   434:   //  bit1  0=LeftON,1=LeftOFF
   435:   //    0/1,Left/Right共にOPMと逆になっていることに注意
   436:   public static void pcmSetPan (int pan) {
   437:     boolean on0 = !(pcmPanLeft == 0 || pcmPanLeft < 0x80000000 + PCM_ATTACK_SPAN * 2);  //true=ONまたはOFF→ON,false=OFFまたはON→OFF
   438:     boolean on1 = pcmOutputOn && (SoundSource.SND_CHANNELS == 1 ? (pan & 3) != 3 : (pan & 2) == 0);  //true=ON,false=OFF
   439:     if (on0 != on1) {
   440:       if (on1) {  //OFF→ONまたはON→OFF→ON
   441:         if (pcmPanLeft < 0x80000000 + PCM_ATTACK_SPAN) {  //ON→OFF→ONでON→OFFが終了していない
   442:           pcmPanLeft ^= PCM_ATTACK_SPAN * 2 | PCM_ATTACK_MASK;  //ON→OFFを反転してOFF→ONの途中から
   443:         } else {  //ON→OFF→ONでON→OFFが終了しているか、OFF→ON
   444:           pcmPanLeft = 0x80000000 + PCM_ATTACK_SPAN * 2;  //OFF→ONの最初から
   445:         }
   446:       } else {  //ON→OFF
   447:         if (pcmPanLeft < 0x80000000 + PCM_ATTACK_SPAN * 3) {  //OFF→ON→OFFでOFF→ONが終了していない
   448:           pcmPanLeft ^= PCM_ATTACK_SPAN * 2 | PCM_ATTACK_MASK;  //OFF→ONを反転してON→OFFの途中から
   449:         } else {  //ON→OFF→ONでOFF→ONが終了しているか、ON→OFF
   450:           pcmPanLeft = 0x80000000 + PCM_ATTACK_SPAN * 0;  //ON→OFFの最初から
   451:         }
   452:       }
   453:     }
   454:     if (SoundSource.SND_CHANNELS == 2) {  //ステレオ
   455:       on0 = !(pcmPanRight == 0 || pcmPanRight < 0x80000000 + PCM_ATTACK_SPAN * 2);  //true=ONまたはOFF→ON,false=OFFまたはON→OFF
   456:       on1 = pcmOutputOn && (pan & 1) == 0;  //true=ON,false=OFF
   457:       if (on0 != on1) {
   458:         if (on1) {  //OFF→ONまたはON→OFF→ON
   459:           if (pcmPanRight < 0x80000000 + PCM_ATTACK_SPAN) {  //ON→OFF→ONでON→OFFが終了していない
   460:             pcmPanRight ^= PCM_ATTACK_SPAN * 2 | PCM_ATTACK_MASK;  //ON→OFFを反転してOFF→ONの途中から
   461:           } else {  //ON→OFF→ONでON→OFFが終了しているか、OFF→ON
   462:             pcmPanRight = 0x80000000 + PCM_ATTACK_SPAN * 2;  //OFF→ONの最初から
   463:           }
   464:         } else {  //ON→OFF
   465:           if (pcmPanRight < 0x80000000 + PCM_ATTACK_SPAN * 3) {  //OFF→ON→OFFでOFF→ONが終了していない
   466:             pcmPanRight ^= PCM_ATTACK_SPAN * 2 | PCM_ATTACK_MASK;  //OFF→ONを反転してON→OFFの途中から
   467:           } else {  //ON→OFF→ONでOFF→ONが終了しているか、ON→OFF
   468:             pcmPanRight = 0x80000000 + PCM_ATTACK_SPAN * 0;  //ON→OFFの最初から
   469:           }
   470:         }
   471:       }
   472:     }
   473:   }  //pcmSetPan(int)
   474: 
   475:   //pcmFillBuffer (endPointer)
   476:   public static void pcmFillBuffer (int endPointer) {
   477:     if (Profiling.PFF_ON) {
   478:       Profiling.pffStart[Profiling.PRF.pcmFillBuffer.ordinal ()] = System.nanoTime ();
   479:     }
   480:     while (pcmPointer < endPointer && (pcmDecodedData1 | pcmDecodedData2 | pcmDecodedData3) != 0) {
   481:       if (PCM_DECAY_ON) {  //減衰させる
   482:         int m = pcmDecodedData1;
   483:         pcmInterpolationEngine.write (m + (m >>> 31) - (-m >>> 31));
   484:       } else {  //減衰させない
   485:         pcmInterpolationEngine.write (0);
   486:       }
   487:     }
   488:     if (pcmPointer < endPointer) {  //残りは無音
   489:       Arrays.fill (pcmBuffer, pcmPointer, endPointer, 0);
   490:       pcmPointer = endPointer;
   491:     } else if (endPointer < pcmPointer) {  //進み過ぎたので戻る
   492:       Arrays.fill (pcmBuffer, endPointer, pcmPointer, 0);
   493:       pcmPointer = endPointer;
   494:     }
   495:     if (Profiling.PFF_ON) {
   496:       Profiling.pffTotal[Profiling.PRF.pcmFillBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmFillBuffer.ordinal ()];
   497:       Profiling.pffCount[Profiling.PRF.pcmFillBuffer.ordinal ()]++;
   498:     }
   499:   }  //pcmFillBuffer
   500: 
   501: 
   502: 
   503:   //PIP PCM補間エンジン
   504:   public static enum PIP {
   505: 
   506:     //モノラル 区分定数補間 3906.25Hz
   507:     PIP_MONO_CONSTANT_16 {
   508:       @Override public void write (int m) {
   509:         if (Profiling.PFF_ON) {
   510:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
   511:         }
   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:         if (Profiling.PFF_ON) {
   572:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
   573:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
   574:         }
   575:       }
   576:     },  //PIP_MONO_CONSTANT_16
   577: 
   578:     //モノラル 区分定数補間 5208.33Hz
   579:     PIP_MONO_CONSTANT_12 {
   580:       @Override public void write (int m) {
   581:         if (Profiling.PFF_ON) {
   582:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
   583:         }
   584:         int i = pcmPointer;
   585:         int p = pcmPanLeft;
   586:         if (p > 0) {  //ON
   587:           pcmBuffer[  i     ] = (
   588:             pcmBuffer[i +  1] =
   589:             pcmBuffer[i +  2] =
   590:             pcmBuffer[i +  3] =
   591:             pcmBuffer[i +  4] =
   592:             pcmBuffer[i +  5] =
   593:             pcmBuffer[i +  6] =
   594:             pcmBuffer[i +  7] =
   595:             pcmBuffer[i +  8] =
   596:             pcmBuffer[i +  9] =
   597:             pcmBuffer[i + 10] =
   598:             pcmBuffer[i + 11] = m);
   599:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   600:           p = (char) p;
   601:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   602:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   603:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  2] >> 14;
   604:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  3] >> 14;
   605:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  4] >> 14;
   606:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  5] >> 14;
   607:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  6] >> 14;
   608:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  7] >> 14;
   609:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  8] >> 14;
   610:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  9] >> 14;
   611:           pcmBuffer[i + 10] = m * pcmAttackCurve[p + 10] >> 14;
   612:           pcmBuffer[i + 11] = m * pcmAttackCurve[p + 11] >> 14;
   613:           p += 12;
   614:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   615:         } else {  //OFF
   616:           pcmBuffer[  i     ] = (
   617:             pcmBuffer[i +  1] =
   618:             pcmBuffer[i +  2] =
   619:             pcmBuffer[i +  3] =
   620:             pcmBuffer[i +  4] =
   621:             pcmBuffer[i +  5] =
   622:             pcmBuffer[i +  6] =
   623:             pcmBuffer[i +  7] =
   624:             pcmBuffer[i +  8] =
   625:             pcmBuffer[i +  9] =
   626:             pcmBuffer[i + 10] =
   627:             pcmBuffer[i + 11] = 0);
   628:         }
   629:         pcmDecodedData1 = m;
   630:         pcmPointer = i + 12;
   631:         if (Profiling.PFF_ON) {
   632:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
   633:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
   634:         }
   635:       }
   636:     },  //PIP_MONO_CONSTANT_12
   637: 
   638:     //モノラル 区分定数補間 7812.50Hz
   639:     PIP_MONO_CONSTANT_8 {
   640:       @Override public void write (int m) {
   641:         if (Profiling.PFF_ON) {
   642:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
   643:         }
   644:         int i = pcmPointer;
   645:         int p = pcmPanLeft;
   646:         if (p > 0) {  //ON
   647:           pcmBuffer[  i     ] = (
   648:             pcmBuffer[i +  1] =
   649:             pcmBuffer[i +  2] =
   650:             pcmBuffer[i +  3] =
   651:             pcmBuffer[i +  4] =
   652:             pcmBuffer[i +  5] =
   653:             pcmBuffer[i +  6] =
   654:             pcmBuffer[i +  7] = m);
   655:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   656:           p = (char) p;
   657:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   658:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   659:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  2] >> 14;
   660:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  3] >> 14;
   661:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  4] >> 14;
   662:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  5] >> 14;
   663:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  6] >> 14;
   664:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  7] >> 14;
   665:           p += 8;
   666:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   667:         } else {  //OFF
   668:           pcmBuffer[  i     ] = (
   669:             pcmBuffer[i +  1] =
   670:             pcmBuffer[i +  2] =
   671:             pcmBuffer[i +  3] =
   672:             pcmBuffer[i +  4] =
   673:             pcmBuffer[i +  5] =
   674:             pcmBuffer[i +  6] =
   675:             pcmBuffer[i +  7] = 0);
   676:         }
   677:         pcmDecodedData1 = m;
   678:         pcmPointer = i + 8;
   679:         if (Profiling.PFF_ON) {
   680:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
   681:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
   682:         }
   683:       }
   684:     },  //PIP_MONO_CONSTANT_8
   685: 
   686:     //モノラル 区分定数補間 10416.67Hz
   687:     PIP_MONO_CONSTANT_6 {
   688:       @Override public void write (int m) {
   689:         if (Profiling.PFF_ON) {
   690:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
   691:         }
   692:         int i = pcmPointer;
   693:         int p = pcmPanLeft;
   694:         if (p > 0) {  //ON
   695:           pcmBuffer[  i     ] = (
   696:             pcmBuffer[i +  1] =
   697:             pcmBuffer[i +  2] =
   698:             pcmBuffer[i +  3] =
   699:             pcmBuffer[i +  4] =
   700:             pcmBuffer[i +  5] = m);
   701:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   702:           p = (char) p;
   703:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   704:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   705:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  2] >> 14;
   706:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  3] >> 14;
   707:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  4] >> 14;
   708:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  5] >> 14;
   709:           p += 6;
   710:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   711:         } else {  //OFF
   712:           pcmBuffer[  i     ] = (
   713:             pcmBuffer[i +  1] =
   714:             pcmBuffer[i +  2] =
   715:             pcmBuffer[i +  3] =
   716:             pcmBuffer[i +  4] =
   717:             pcmBuffer[i +  5] = 0);
   718:         }
   719:         pcmDecodedData1 = m;
   720:         pcmPointer = i + 6;
   721:         if (Profiling.PFF_ON) {
   722:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
   723:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
   724:         }
   725:       }
   726:     },  //PIP_MONO_CONSTANT_6
   727: 
   728:     //モノラル 区分定数補間 15625.00Hz
   729:     PIP_MONO_CONSTANT_4 {
   730:       @Override public void write (int m) {
   731:         if (Profiling.PFF_ON) {
   732:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
   733:         }
   734:         int i = pcmPointer;
   735:         int p = pcmPanLeft;
   736:         if (p > 0) {  //ON
   737:           pcmBuffer[  i     ] = (
   738:             pcmBuffer[i +  1] =
   739:             pcmBuffer[i +  2] =
   740:             pcmBuffer[i +  3] = 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:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  3] >> 14;
   747:           p += 4;
   748:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   749:         } else {  //OFF
   750:           pcmBuffer[  i     ] = (
   751:             pcmBuffer[i +  1] =
   752:             pcmBuffer[i +  2] =
   753:             pcmBuffer[i +  3] = 0);
   754:         }
   755:         pcmDecodedData1 = m;
   756:         pcmPointer = i + 4;
   757:         if (Profiling.PFF_ON) {
   758:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
   759:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
   760:         }
   761:       }
   762:     },  //PIP_MONO_CONSTANT_4
   763: 
   764:     //モノラル 区分定数補間 20833.33Hz
   765:     PIP_MONO_CONSTANT_3 {
   766:       @Override public void write (int m) {
   767:         if (Profiling.PFF_ON) {
   768:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
   769:         }
   770:         int i = pcmPointer;
   771:         int p = pcmPanLeft;
   772:         if (p > 0) {  //ON
   773:           pcmBuffer[  i     ] = (
   774:             pcmBuffer[i +  1] =
   775:             pcmBuffer[i +  2] = m);
   776:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   777:           p = (char) p;
   778:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   779:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   780:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  2] >> 14;
   781:           p += 3;
   782:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   783:         } else {  //OFF
   784:           pcmBuffer[  i     ] = (
   785:             pcmBuffer[i +  1] =
   786:             pcmBuffer[i +  2] = 0);
   787:         }
   788:         pcmDecodedData1 = m;
   789:         pcmPointer = i + 3;
   790:         if (Profiling.PFF_ON) {
   791:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
   792:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
   793:         }
   794:       }
   795:     },  //PIP_MONO_CONSTANT_3
   796: 
   797:     //モノラル 区分定数補間 31250.00Hz
   798:     PIP_MONO_CONSTANT_2 {
   799:       @Override public void write (int m) {
   800:         if (Profiling.PFF_ON) {
   801:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
   802:         }
   803:         int i = pcmPointer;
   804:         int p = pcmPanLeft;
   805:         if (p > 0) {  //ON
   806:           pcmBuffer[  i     ] = (
   807:             pcmBuffer[i +  1] = m);
   808:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   809:           p = (char) p;
   810:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
   811:           pcmBuffer[i +  1] = m * pcmAttackCurve[p +  1] >> 14;
   812:           p += 2;
   813:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   814:         } else {  //OFF
   815:           pcmBuffer[  i     ] = (
   816:             pcmBuffer[i +  1] = 0);
   817:         }
   818:         pcmDecodedData1 = m;
   819:         pcmPointer = i + 2;
   820:         if (Profiling.PFF_ON) {
   821:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
   822:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
   823:         }
   824:       }
   825:     },  //PIP_MONO_CONSTANT_2
   826: 
   827:     //モノラル 線形補間 3906.25Hz
   828:     PIP_MONO_LINEAR_16 {
   829:       @Override public void write (int m1) {
   830:         if (Profiling.PFF_ON) {
   831:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
   832:         }
   833:         int i = pcmPointer;
   834:         int p = pcmPanLeft;
   835:         if (p > 0) {  //ON
   836:           int m0 = pcmDecodedData1;
   837:           pcmBuffer[i     ] = 15 * m0 +      m1 >> 4;
   838:           pcmBuffer[i +  1] =  7 * m0 +      m1 >> 3;
   839:           pcmBuffer[i +  2] = 13 * m0 +  3 * m1 >> 4;
   840:           pcmBuffer[i +  3] =  3 * m0 +      m1 >> 2;
   841:           pcmBuffer[i +  4] = 11 * m0 +  5 * m1 >> 4;
   842:           pcmBuffer[i +  5] =  5 * m0 +  3 * m1 >> 3;
   843:           pcmBuffer[i +  6] =  9 * m0 +  7 * m1 >> 4;
   844:           pcmBuffer[i +  7] =      m0 +      m1 >> 1;
   845:           pcmBuffer[i +  8] =  7 * m0 +  9 * m1 >> 4;
   846:           pcmBuffer[i +  9] =  3 * m0 +  5 * m1 >> 3;
   847:           pcmBuffer[i + 10] =  5 * m0 + 11 * m1 >> 4;
   848:           pcmBuffer[i + 11] =      m0 +  3 * m1 >> 2;
   849:           pcmBuffer[i + 12] =  3 * m0 + 13 * m1 >> 4;
   850:           pcmBuffer[i + 13] =      m0 +  7 * m1 >> 3;
   851:           pcmBuffer[i + 14] =      m0 + 15 * m1 >> 4;
   852:           pcmBuffer[i + 15] =                m1;
   853:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   854:           p = (char) p;
   855:           int m0 = pcmDecodedData1;
   856:           pcmBuffer[i     ] = (15 * m0 +      m1 >> 4) * pcmAttackCurve[p     ] >> 14;
   857:           pcmBuffer[i +  1] = ( 7 * m0 +      m1 >> 3) * pcmAttackCurve[p +  1] >> 14;
   858:           pcmBuffer[i +  2] = (13 * m0 +  3 * m1 >> 4) * pcmAttackCurve[p +  2] >> 14;
   859:           pcmBuffer[i +  3] = ( 3 * m0 +      m1 >> 2) * pcmAttackCurve[p +  3] >> 14;
   860:           pcmBuffer[i +  4] = (11 * m0 +  5 * m1 >> 4) * pcmAttackCurve[p +  4] >> 14;
   861:           pcmBuffer[i +  5] = ( 5 * m0 +  3 * m1 >> 3) * pcmAttackCurve[p +  5] >> 14;
   862:           pcmBuffer[i +  6] = ( 9 * m0 +  7 * m1 >> 4) * pcmAttackCurve[p +  6] >> 14;
   863:           pcmBuffer[i +  7] = (     m0 +      m1 >> 1) * pcmAttackCurve[p +  7] >> 14;
   864:           pcmBuffer[i +  8] = ( 7 * m0 +  9 * m1 >> 4) * pcmAttackCurve[p +  8] >> 14;
   865:           pcmBuffer[i +  9] = ( 3 * m0 +  5 * m1 >> 3) * pcmAttackCurve[p +  9] >> 14;
   866:           pcmBuffer[i + 10] = ( 5 * m0 + 11 * m1 >> 4) * pcmAttackCurve[p + 10] >> 14;
   867:           pcmBuffer[i + 11] = (     m0 +  3 * m1 >> 2) * pcmAttackCurve[p + 11] >> 14;
   868:           pcmBuffer[i + 12] = ( 3 * m0 + 13 * m1 >> 4) * pcmAttackCurve[p + 12] >> 14;
   869:           pcmBuffer[i + 13] = (     m0 +  7 * m1 >> 3) * pcmAttackCurve[p + 13] >> 14;
   870:           pcmBuffer[i + 14] = (     m0 + 15 * m1 >> 4) * pcmAttackCurve[p + 14] >> 14;
   871:           pcmBuffer[i + 15] = (               m1     ) * pcmAttackCurve[p + 15] >> 14;
   872:           p += 16;
   873:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   874:         } else {  //OFF
   875:           pcmBuffer[  i     ] = (
   876:             pcmBuffer[i +  1] =
   877:             pcmBuffer[i +  2] =
   878:             pcmBuffer[i +  3] =
   879:             pcmBuffer[i +  4] =
   880:             pcmBuffer[i +  5] =
   881:             pcmBuffer[i +  6] =
   882:             pcmBuffer[i +  7] =
   883:             pcmBuffer[i +  8] =
   884:             pcmBuffer[i +  9] =
   885:             pcmBuffer[i + 10] =
   886:             pcmBuffer[i + 11] =
   887:             pcmBuffer[i + 12] =
   888:             pcmBuffer[i + 13] =
   889:             pcmBuffer[i + 14] =
   890:             pcmBuffer[i + 15] = 0);
   891:         }
   892:         pcmDecodedData1 = m1;
   893:         pcmPointer = i + 16;
   894:         if (Profiling.PFF_ON) {
   895:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
   896:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
   897:         }
   898:       }
   899:     },  //PIP_MONO_LINEAR_16
   900: 
   901:     //モノラル 線形補間 5208.33Hz
   902:     PIP_MONO_LINEAR_12 {
   903:       @Override public void write (int m1) {
   904:         if (Profiling.PFF_ON) {
   905:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
   906:         }
   907:         int i = pcmPointer;
   908:         int p = pcmPanLeft;
   909:         if (p > 0) {  //ON
   910:           int m0 = pcmDecodedData1;
   911:           pcmBuffer[i     ] = 65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16;
   912:           pcmBuffer[i +  1] = 65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16;
   913:           pcmBuffer[i +  2] =          3      * m0 +                   m1 >>  2;
   914:           pcmBuffer[i +  3] = 65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16;
   915:           pcmBuffer[i +  4] = 65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16;
   916:           pcmBuffer[i +  5] =                   m0 +                   m1 >>  1;
   917:           pcmBuffer[i +  6] = 65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16;
   918:           pcmBuffer[i +  7] = 65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16;
   919:           pcmBuffer[i +  8] =                   m0 +          3      * m1 >>  2;
   920:           pcmBuffer[i +  9] = 65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16;
   921:           pcmBuffer[i + 10] = 65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16;
   922:           pcmBuffer[i + 11] =                                          m1;
   923:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   924:           p = (char) p;
   925:           int m0 = pcmDecodedData1;
   926:           pcmBuffer[i     ] = (65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16) * pcmAttackCurve[p     ] >> 14;
   927:           pcmBuffer[i +  1] = (65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16) * pcmAttackCurve[p +  1] >> 14;
   928:           pcmBuffer[i +  2] = (         3      * m0 +                   m1 >>  2) * pcmAttackCurve[p +  2] >> 14;
   929:           pcmBuffer[i +  3] = (65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16) * pcmAttackCurve[p +  3] >> 14;
   930:           pcmBuffer[i +  4] = (65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16) * pcmAttackCurve[p +  4] >> 14;
   931:           pcmBuffer[i +  5] = (                  m0 +                   m1 >>  1) * pcmAttackCurve[p +  5] >> 14;
   932:           pcmBuffer[i +  6] = (65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16) * pcmAttackCurve[p +  6] >> 14;
   933:           pcmBuffer[i +  7] = (65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16) * pcmAttackCurve[p +  7] >> 14;
   934:           pcmBuffer[i +  8] = (                  m0 +          3      * m1 >>  2) * pcmAttackCurve[p +  8] >> 14;
   935:           pcmBuffer[i +  9] = (65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16) * pcmAttackCurve[p +  9] >> 14;
   936:           pcmBuffer[i + 10] = (65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16) * pcmAttackCurve[p + 10] >> 14;
   937:           pcmBuffer[i + 11] = (                                         m1      ) * pcmAttackCurve[p + 11] >> 14;
   938:           p += 12;
   939:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   940:         } else {  //OFF
   941:           pcmBuffer[  i     ] = (
   942:             pcmBuffer[i +  1] =
   943:             pcmBuffer[i +  2] =
   944:             pcmBuffer[i +  3] =
   945:             pcmBuffer[i +  4] =
   946:             pcmBuffer[i +  5] =
   947:             pcmBuffer[i +  6] =
   948:             pcmBuffer[i +  7] =
   949:             pcmBuffer[i +  8] =
   950:             pcmBuffer[i +  9] =
   951:             pcmBuffer[i + 10] =
   952:             pcmBuffer[i + 11] = 0);
   953:         }
   954:         pcmDecodedData1 = m1;
   955:         pcmPointer = i + 12;
   956:         if (Profiling.PFF_ON) {
   957:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
   958:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
   959:         }
   960:       }
   961:     },  //PIP_MONO_LINEAR_12
   962: 
   963:     //モノラル 線形補間 7812.50Hz
   964:     PIP_MONO_LINEAR_8 {
   965:       @Override public void write (int m1) {
   966:         if (Profiling.PFF_ON) {
   967:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
   968:         }
   969:         int i = pcmPointer;
   970:         int p = pcmPanLeft;
   971:         if (p > 0) {  //ON
   972:           int m0 = pcmDecodedData1;
   973:           pcmBuffer[i    ] = 7 * m0 +     m1 >> 3;
   974:           pcmBuffer[i + 1] = 3 * m0 +     m1 >> 2;
   975:           pcmBuffer[i + 2] = 5 * m0 + 3 * m1 >> 3;
   976:           pcmBuffer[i + 3] =     m0 +     m1 >> 1;
   977:           pcmBuffer[i + 4] = 3 * m0 + 5 * m1 >> 3;
   978:           pcmBuffer[i + 5] =     m0 + 3 * m1 >> 2;
   979:           pcmBuffer[i + 6] =     m0 + 7 * m1 >> 3;
   980:           pcmBuffer[i + 7] =              m1;
   981:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
   982:           p = (char) p;
   983:           int m0 = pcmDecodedData1;
   984:           pcmBuffer[i    ] = (7 * m0 +     m1 >> 3) * pcmAttackCurve[p    ] >> 14;
   985:           pcmBuffer[i + 1] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p + 1] >> 14;
   986:           pcmBuffer[i + 2] = (5 * m0 + 3 * m1 >> 3) * pcmAttackCurve[p + 2] >> 14;
   987:           pcmBuffer[i + 3] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 3] >> 14;
   988:           pcmBuffer[i + 4] = (3 * m0 + 5 * m1 >> 3) * pcmAttackCurve[p + 4] >> 14;
   989:           pcmBuffer[i + 5] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 5] >> 14;
   990:           pcmBuffer[i + 6] = (    m0 + 7 * m1 >> 3) * pcmAttackCurve[p + 6] >> 14;
   991:           pcmBuffer[i + 7] = (             m1     ) * pcmAttackCurve[p + 7] >> 14;
   992:           p += 8;
   993:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
   994:         } else {  //OFF
   995:           pcmBuffer[  i    ] = (
   996:             pcmBuffer[i + 1] =
   997:             pcmBuffer[i + 2] =
   998:             pcmBuffer[i + 3] =
   999:             pcmBuffer[i + 4] =
  1000:             pcmBuffer[i + 5] =
  1001:             pcmBuffer[i + 6] =
  1002:             pcmBuffer[i + 7] = 0);
  1003:         }
  1004:         pcmDecodedData1 = m1;
  1005:         pcmPointer = i + 8;
  1006:         if (Profiling.PFF_ON) {
  1007:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1008:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1009:         }
  1010:       }
  1011:     },  //PIP_MONO_LINEAR_8
  1012: 
  1013:     //モノラル 線形補間 10416.67Hz
  1014:     PIP_MONO_LINEAR_6 {
  1015:       @Override public void write (int m1) {
  1016:         if (Profiling.PFF_ON) {
  1017:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1018:         }
  1019:         int i = pcmPointer;
  1020:         int p = pcmPanLeft;
  1021:         if (p > 0) {  //ON
  1022:           int m0 = pcmDecodedData1;
  1023:           pcmBuffer[i    ] = 65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16;
  1024:           pcmBuffer[i + 1] = 65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16;
  1025:           pcmBuffer[i + 2] =                 m0 +                 m1 >>  1;
  1026:           pcmBuffer[i + 3] = 65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16;
  1027:           pcmBuffer[i + 4] = 65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16;
  1028:           pcmBuffer[i + 5] =                                      m1;
  1029:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1030:           p = (char) p;
  1031:           int m0 = pcmDecodedData1;
  1032:           pcmBuffer[i    ] = (65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  1033:           pcmBuffer[i + 1] = (65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  1034:           pcmBuffer[i + 2] = (                m0 +                 m1 >>  1) * pcmAttackCurve[p + 2] >> 14;
  1035:           pcmBuffer[i + 3] = (65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16) * pcmAttackCurve[p + 3] >> 14;
  1036:           pcmBuffer[i + 4] = (65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16) * pcmAttackCurve[p + 4] >> 14;
  1037:           pcmBuffer[i + 5] = (                                     m1      ) * pcmAttackCurve[p + 5] >> 14;
  1038:           p += 6;
  1039:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1040:         } else {  //OFF
  1041:           pcmBuffer[  i    ] = (
  1042:             pcmBuffer[i + 1] =
  1043:             pcmBuffer[i + 2] =
  1044:             pcmBuffer[i + 3] =
  1045:             pcmBuffer[i + 4] =
  1046:             pcmBuffer[i + 5] = 0);
  1047:         }
  1048:         pcmDecodedData1 = m1;
  1049:         pcmPointer = i + 6;
  1050:         if (Profiling.PFF_ON) {
  1051:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1052:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1053:         }
  1054:       }
  1055:     },  //PIP_MONO_LINEAR_6
  1056: 
  1057:     //モノラル 線形補間 15625.00Hz
  1058:     PIP_MONO_LINEAR_4 {
  1059:       @Override public void write (int m1) {
  1060:         if (Profiling.PFF_ON) {
  1061:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1062:         }
  1063:         int i = pcmPointer;
  1064:         int p = pcmPanLeft;
  1065:         if (p > 0) {  //ON
  1066:           int m0 = pcmDecodedData1;
  1067:           pcmBuffer[i    ] = 3 * m0 +     m1 >> 2;
  1068:           pcmBuffer[i + 1] =     m0 +     m1 >> 1;
  1069:           pcmBuffer[i + 2] =     m0 + 3 * m1 >> 2;
  1070:           pcmBuffer[i + 3] =              m1;
  1071:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1072:           p = (char) p;
  1073:           int m0 = pcmDecodedData1;
  1074:           pcmBuffer[i    ] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p    ] >> 14;
  1075:           pcmBuffer[i + 1] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 1] >> 14;
  1076:           pcmBuffer[i + 2] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 2] >> 14;
  1077:           pcmBuffer[i + 3] = (             m1     ) * pcmAttackCurve[p + 3] >> 14;
  1078:           p += 4;
  1079:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1080:         } else {  //OFF
  1081:           pcmBuffer[  i    ] = (
  1082:             pcmBuffer[i + 1] =
  1083:             pcmBuffer[i + 2] =
  1084:             pcmBuffer[i + 3] = 0);
  1085:         }
  1086:         pcmDecodedData1 = m1;
  1087:         pcmPointer = i + 4;
  1088:         if (Profiling.PFF_ON) {
  1089:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1090:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1091:         }
  1092:       }
  1093:     },  //PIP_MONO_LINEAR_4
  1094: 
  1095:     //モノラル 線形補間 20833.33Hz
  1096:     PIP_MONO_LINEAR_3 {
  1097:       @Override public void write (int m1) {
  1098:         if (Profiling.PFF_ON) {
  1099:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1100:         }
  1101:         int i = pcmPointer;
  1102:         int p = pcmPanLeft;
  1103:         if (p > 0) {  //ON
  1104:           int m0 = pcmDecodedData1;
  1105:           pcmBuffer[i    ] = 65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16;
  1106:           pcmBuffer[i + 1] = 65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16;
  1107:           pcmBuffer[i + 2] =                                      m1;
  1108:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1109:           p = (char) p;
  1110:           int m0 = pcmDecodedData1;
  1111:           pcmBuffer[i    ] = (65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  1112:           pcmBuffer[i + 1] = (65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  1113:           pcmBuffer[i + 2] = (                                     m1      ) * pcmAttackCurve[p + 2] >> 14;
  1114:           p += 3;
  1115:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1116:         } else {  //OFF
  1117:           pcmBuffer[  i    ] = (
  1118:             pcmBuffer[i + 1] =
  1119:             pcmBuffer[i + 2] = 0);
  1120:         }
  1121:         pcmDecodedData1 = m1;
  1122:         pcmPointer = i + 3;
  1123:         if (Profiling.PFF_ON) {
  1124:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1125:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1126:         }
  1127:       }
  1128:     },  //PIP_MONO_LINEAR_3
  1129: 
  1130:     //モノラル 線形補間 31250.00Hz
  1131:     PIP_MONO_LINEAR_2 {
  1132:       @Override public void write (int m1) {
  1133:         if (Profiling.PFF_ON) {
  1134:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1135:         }
  1136:         int i = pcmPointer;
  1137:         int p = pcmPanLeft;
  1138:         if (p > 0) {  //ON
  1139:           int m0 = pcmDecodedData1;
  1140:           pcmBuffer[i    ] = m0 + m1 >> 1;
  1141:           pcmBuffer[i + 1] =      m1;
  1142:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1143:           p = (char) p;
  1144:           int m0 = pcmDecodedData1;
  1145:           pcmBuffer[i    ] = (m0 + m1 >> 1) * pcmAttackCurve[p    ] >> 14;
  1146:           pcmBuffer[i + 1] = (     m1     ) * pcmAttackCurve[p + 1] >> 14;
  1147:           p += 2;
  1148:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1149:         } else {  //OFF
  1150:           pcmBuffer[  i    ] = (
  1151:             pcmBuffer[i + 1] = 0);
  1152:         }
  1153:         pcmDecodedData1 = m1;
  1154:         pcmPointer = i + 2;
  1155:         if (Profiling.PFF_ON) {
  1156:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1157:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1158:         }
  1159:       }
  1160:     },  //PIP_MONO_LINEAR_2
  1161: 
  1162:     //モノラル エルミート補間 3906.25Hz
  1163:     PIP_MONO_HERMITE_16 {
  1164:       @Override public void write (int m2) {
  1165:         if (Profiling.PFF_ON) {
  1166:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1167:         }
  1168:         //  echo read("hermite.gp");hermite_code(1,16) | gp-2.7 -q
  1169:         int i = pcmPointer;
  1170:         int mm = pcmDecodedData3;
  1171:         int m0 = pcmDecodedData2;
  1172:         int m1 = pcmDecodedData1;
  1173:         int p = pcmPanLeft;
  1174:         if (p > 0) {  //ON
  1175:           pcmBuffer[i     ] =          -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13;
  1176:           pcmBuffer[i +  1] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  1177:           pcmBuffer[i +  2] =          -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13;
  1178:           pcmBuffer[i +  3] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  1179:           pcmBuffer[i +  4] =          -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13;
  1180:           pcmBuffer[i +  5] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  1181:           pcmBuffer[i +  6] =          -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13;
  1182:           pcmBuffer[i +  7] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1183:           pcmBuffer[i +  8] =          -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13;
  1184:           pcmBuffer[i +  9] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  1185:           pcmBuffer[i + 10] =          -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13;
  1186:           pcmBuffer[i + 11] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  1187:           pcmBuffer[i + 12] =          -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13;
  1188:           pcmBuffer[i + 13] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  1189:           pcmBuffer[i + 14] =           -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13;
  1190:           pcmBuffer[i + 15] =                                         m1;
  1191:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1192:           p = (char) p;
  1193:           pcmBuffer[i     ] = (         -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13) * pcmAttackCurve[p     ] >> 14;
  1194:           pcmBuffer[i +  1] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p +  1] >> 14;
  1195:           pcmBuffer[i +  2] = (         -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13) * pcmAttackCurve[p +  2] >> 14;
  1196:           pcmBuffer[i +  3] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p +  3] >> 14;
  1197:           pcmBuffer[i +  4] = (         -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13) * pcmAttackCurve[p +  4] >> 14;
  1198:           pcmBuffer[i +  5] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p +  5] >> 14;
  1199:           pcmBuffer[i +  6] = (         -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13) * pcmAttackCurve[p +  6] >> 14;
  1200:           pcmBuffer[i +  7] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p +  7] >> 14;
  1201:           pcmBuffer[i +  8] = (         -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13) * pcmAttackCurve[p +  8] >> 14;
  1202:           pcmBuffer[i +  9] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p +  9] >> 14;
  1203:           pcmBuffer[i + 10] = (         -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13) * pcmAttackCurve[p + 10] >> 14;
  1204:           pcmBuffer[i + 11] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 11] >> 14;
  1205:           pcmBuffer[i + 12] = (         -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13) * pcmAttackCurve[p + 12] >> 14;
  1206:           pcmBuffer[i + 13] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 13] >> 14;
  1207:           pcmBuffer[i + 14] = (          -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13) * pcmAttackCurve[p + 14] >> 14;
  1208:           pcmBuffer[i + 15] = (                                        m1                  ) * pcmAttackCurve[p + 15] >> 14;
  1209:           p += 16;
  1210:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1211:         } else {  //OFF
  1212:           pcmBuffer[  i     ] = (
  1213:             pcmBuffer[i +  1] =
  1214:             pcmBuffer[i +  2] =
  1215:             pcmBuffer[i +  3] =
  1216:             pcmBuffer[i +  4] =
  1217:             pcmBuffer[i +  5] =
  1218:             pcmBuffer[i +  6] =
  1219:             pcmBuffer[i +  7] =
  1220:             pcmBuffer[i +  8] =
  1221:             pcmBuffer[i +  9] =
  1222:             pcmBuffer[i + 10] =
  1223:             pcmBuffer[i + 11] =
  1224:             pcmBuffer[i + 12] =
  1225:             pcmBuffer[i + 13] =
  1226:             pcmBuffer[i + 14] =
  1227:             pcmBuffer[i + 15] = 0);
  1228:         }
  1229:         pcmDecodedData3 = m0;
  1230:         pcmDecodedData2 = m1;
  1231:         pcmDecodedData1 = m2;
  1232:         pcmPointer = i + 16;
  1233:         if (Profiling.PFF_ON) {
  1234:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1235:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1236:         }
  1237:       }
  1238:     },  //PIP_MONO_HERMITE_16
  1239: 
  1240:     //モノラル エルミート補間 5208.33Hz
  1241:     PIP_MONO_HERMITE_12 {
  1242:       @Override public void write (int m2) {
  1243:         if (Profiling.PFF_ON) {
  1244:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1245:         }
  1246:         //  echo read("hermite.gp");hermite_code(1,12) | gp-2.7 -q
  1247:         int i = pcmPointer;
  1248:         int mm = pcmDecodedData3;
  1249:         int m0 = pcmDecodedData2;
  1250:         int m1 = pcmDecodedData1;
  1251:         int p = pcmPanLeft;
  1252:         if (p > 0) {  //ON
  1253:           pcmBuffer[i     ] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32);
  1254:           pcmBuffer[i +  1] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  1255:           pcmBuffer[i +  2] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  1256:           pcmBuffer[i +  3] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  1257:           pcmBuffer[i +  4] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32);
  1258:           pcmBuffer[i +  5] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1259:           pcmBuffer[i +  6] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32);
  1260:           pcmBuffer[i +  7] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  1261:           pcmBuffer[i +  8] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  1262:           pcmBuffer[i +  9] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  1263:           pcmBuffer[i + 10] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32);
  1264:           pcmBuffer[i + 11] =                                         m1;
  1265:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1266:           p = (char) p;
  1267:           pcmBuffer[i     ] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32) * pcmAttackCurve[p     ] >> 14;
  1268:           pcmBuffer[i +  1] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  1] >> 14;
  1269:           pcmBuffer[i +  2] =       (    -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7               ) * pcmAttackCurve[p +  2] >> 14;
  1270:           pcmBuffer[i +  3] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p +  3] >> 14;
  1271:           pcmBuffer[i +  4] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  4] >> 14;
  1272:           pcmBuffer[i +  5] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p +  5] >> 14;
  1273:           pcmBuffer[i +  6] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  6] >> 14;
  1274:           pcmBuffer[i +  7] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p +  7] >> 14;
  1275:           pcmBuffer[i +  8] =       (    -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7               ) * pcmAttackCurve[p +  8] >> 14;
  1276:           pcmBuffer[i +  9] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  9] >> 14;
  1277:           pcmBuffer[i + 10] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32) * pcmAttackCurve[p + 10] >> 14;
  1278:           pcmBuffer[i + 11] =       (                                 m1                                 ) * pcmAttackCurve[p + 11] >> 14;
  1279:           p += 12;
  1280:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1281:         } else {  //OFF
  1282:           pcmBuffer[  i     ] = (
  1283:             pcmBuffer[i +  1] =
  1284:             pcmBuffer[i +  2] =
  1285:             pcmBuffer[i +  3] =
  1286:             pcmBuffer[i +  4] =
  1287:             pcmBuffer[i +  5] =
  1288:             pcmBuffer[i +  6] =
  1289:             pcmBuffer[i +  7] =
  1290:             pcmBuffer[i +  8] =
  1291:             pcmBuffer[i +  9] =
  1292:             pcmBuffer[i + 10] =
  1293:             pcmBuffer[i + 11] = 0);
  1294:         }
  1295:         pcmDecodedData3 = m0;
  1296:         pcmDecodedData2 = m1;
  1297:         pcmDecodedData1 = m2;
  1298:         pcmPointer = i + 12;
  1299:         if (Profiling.PFF_ON) {
  1300:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1301:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1302:         }
  1303:       }
  1304:     },  //PIP_MONO_HERMITE_12
  1305: 
  1306:     //モノラル エルミート補間 7812.50Hz
  1307:     PIP_MONO_HERMITE_8 {
  1308:       @Override public void write (int m2) {
  1309:         if (Profiling.PFF_ON) {
  1310:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1311:         }
  1312:         //  echo read("hermite.gp");hermite_code(1,8) | gp-2.7 -q
  1313:         int i = pcmPointer;
  1314:         int mm = pcmDecodedData3;
  1315:         int m0 = pcmDecodedData2;
  1316:         int m1 = pcmDecodedData1;
  1317:         int p = pcmPanLeft;
  1318:         if (p > 0) {  //ON
  1319:           pcmBuffer[i    ] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  1320:           pcmBuffer[i + 1] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  1321:           pcmBuffer[i + 2] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  1322:           pcmBuffer[i + 3] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1323:           pcmBuffer[i + 4] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  1324:           pcmBuffer[i + 5] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  1325:           pcmBuffer[i + 6] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  1326:           pcmBuffer[i + 7] =                                         m1;
  1327:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1328:           p = (char) p;
  1329:           pcmBuffer[i    ] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p    ] >> 14;
  1330:           pcmBuffer[i + 1] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p + 1] >> 14;
  1331:           pcmBuffer[i + 2] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p + 2] >> 14;
  1332:           pcmBuffer[i + 3] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 3] >> 14;
  1333:           pcmBuffer[i + 4] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p + 4] >> 14;
  1334:           pcmBuffer[i + 5] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 5] >> 14;
  1335:           pcmBuffer[i + 6] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 6] >> 14;
  1336:           pcmBuffer[i + 7] = (                                        m1                  ) * pcmAttackCurve[p + 7] >> 14;
  1337:           p += 8;
  1338:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1339:         } else {  //OFF
  1340:           pcmBuffer[  i     ] = (
  1341:             pcmBuffer[i +  1] =
  1342:             pcmBuffer[i +  2] =
  1343:             pcmBuffer[i +  3] =
  1344:             pcmBuffer[i +  4] =
  1345:             pcmBuffer[i +  5] =
  1346:             pcmBuffer[i +  6] =
  1347:             pcmBuffer[i +  7] = 0);
  1348:         }
  1349:         pcmDecodedData3 = m0;
  1350:         pcmDecodedData2 = m1;
  1351:         pcmDecodedData1 = m2;
  1352:         pcmPointer = i + 8;
  1353:         if (Profiling.PFF_ON) {
  1354:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1355:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1356:         }
  1357:       }
  1358:     },  //PIP_MONO_HERMITE_8
  1359: 
  1360:     //モノラル エルミート補間 10416.67Hz
  1361:     PIP_MONO_HERMITE_6 {
  1362:       @Override public void write (int m2) {
  1363:         if (Profiling.PFF_ON) {
  1364:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1365:         }
  1366:         //  echo read("hermite.gp");hermite_code(1,6) | gp-2.7 -q
  1367:         int i = pcmPointer;
  1368:         int mm = pcmDecodedData3;
  1369:         int m0 = pcmDecodedData2;
  1370:         int m1 = pcmDecodedData1;
  1371:         int p = pcmPanLeft;
  1372:         if (p > 0) {  //ON
  1373:           pcmBuffer[i    ] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  1374:           pcmBuffer[i + 1] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  1375:           pcmBuffer[i + 2] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1376:           pcmBuffer[i + 3] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  1377:           pcmBuffer[i + 4] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  1378:           pcmBuffer[i + 5] =                                         m1;
  1379:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1380:           p = (char) p;
  1381:           pcmBuffer[i    ] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p    ] >> 14;
  1382:           pcmBuffer[i + 1] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  1383:           pcmBuffer[i + 2] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p + 2] >> 14;
  1384:           pcmBuffer[i + 3] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 3] >> 14;
  1385:           pcmBuffer[i + 4] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p + 4] >> 14;
  1386:           pcmBuffer[i + 5] =       (                                 m1                                 ) * pcmAttackCurve[p + 5] >> 14;
  1387:           p += 6;
  1388:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1389:         } else {  //OFF
  1390:           pcmBuffer[  i     ] = (
  1391:             pcmBuffer[i +  1] =
  1392:             pcmBuffer[i +  2] =
  1393:             pcmBuffer[i +  3] =
  1394:             pcmBuffer[i +  4] =
  1395:             pcmBuffer[i +  5] = 0);
  1396:         }
  1397:         pcmDecodedData3 = m0;
  1398:         pcmDecodedData2 = m1;
  1399:         pcmDecodedData1 = m2;
  1400:         pcmPointer = i + 6;
  1401:         if (Profiling.PFF_ON) {
  1402:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1403:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1404:         }
  1405:       }
  1406:     },  //PIP_MONO_HERMITE_6
  1407: 
  1408:     //モノラル エルミート補間 15625.00Hz
  1409:     PIP_MONO_HERMITE_4 {
  1410:       @Override public void write (int m2) {
  1411:         if (Profiling.PFF_ON) {
  1412:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1413:         }
  1414:         //  echo read("hermite.gp");hermite_code(1,4) | gp-2.7 -q
  1415:         int i = pcmPointer;
  1416:         int mm = pcmDecodedData3;
  1417:         int m0 = pcmDecodedData2;
  1418:         int m1 = pcmDecodedData1;
  1419:         int p = pcmPanLeft;
  1420:         if (p > 0) {  //ON
  1421:           pcmBuffer[i    ] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  1422:           pcmBuffer[i + 1] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1423:           pcmBuffer[i + 2] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  1424:           pcmBuffer[i + 3] =                                         m1;
  1425:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1426:           p = (char) p;
  1427:           pcmBuffer[i    ] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p    ] >> 14;
  1428:           pcmBuffer[i + 1] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 1] >> 14;
  1429:           pcmBuffer[i + 2] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 2] >> 14;
  1430:           pcmBuffer[i + 3] = (                                        m1                  ) * pcmAttackCurve[p + 3] >> 14;
  1431:           p += 4;
  1432:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1433:         } else {  //OFF
  1434:           pcmBuffer[  i     ] = (
  1435:             pcmBuffer[i +  1] =
  1436:             pcmBuffer[i +  2] =
  1437:             pcmBuffer[i +  3] = 0);
  1438:         }
  1439:         pcmDecodedData3 = m0;
  1440:         pcmDecodedData2 = m1;
  1441:         pcmDecodedData1 = m2;
  1442:         pcmPointer = i + 4;
  1443:         if (Profiling.PFF_ON) {
  1444:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1445:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1446:         }
  1447:       }
  1448:     },  //PIP_MONO_HERMITE_4
  1449: 
  1450:     //モノラル エルミート補間 20833.33Hz
  1451:     PIP_MONO_HERMITE_3 {
  1452:       @Override public void write (int m2) {
  1453:         if (Profiling.PFF_ON) {
  1454:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1455:         }
  1456:         //  echo read("hermite.gp");hermite_code(1,3) | gp-2.7 -q
  1457:         int i = pcmPointer;
  1458:         int mm = pcmDecodedData3;
  1459:         int m0 = pcmDecodedData2;
  1460:         int m1 = pcmDecodedData1;
  1461:         int p = pcmPanLeft;
  1462:         if (p > 0) {  //ON
  1463:           pcmBuffer[i    ] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  1464:           pcmBuffer[i + 1] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  1465:           pcmBuffer[i + 2] =                                         m1;
  1466:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1467:           p = (char) p;
  1468:           pcmBuffer[i    ] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p    ] >> 14;
  1469:           pcmBuffer[i + 1] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  1470:           pcmBuffer[i + 2] =       (                                 m1                                 ) * pcmAttackCurve[p + 2] >> 14;
  1471:           p += 3;
  1472:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1473:         } else {  //OFF
  1474:           pcmBuffer[  i     ] = (
  1475:             pcmBuffer[i +  1] =
  1476:             pcmBuffer[i +  2] = 0);
  1477:         }
  1478:         pcmDecodedData3 = m0;
  1479:         pcmDecodedData2 = m1;
  1480:         pcmDecodedData1 = m2;
  1481:         pcmPointer = i + 3;
  1482:         if (Profiling.PFF_ON) {
  1483:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1484:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1485:         }
  1486:       }
  1487:     },  //PIP_MONO_HERMITE_3
  1488: 
  1489:     //モノラル エルミート補間 31250.00Hz
  1490:     PIP_MONO_HERMITE_2 {
  1491:       @Override public void write (int m2) {
  1492:         if (Profiling.PFF_ON) {
  1493:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1494:         }
  1495:         //  echo read("hermite.gp");hermite_code(1,2) | gp-2.7 -q
  1496:         int i = pcmPointer;
  1497:         int mm = pcmDecodedData3;
  1498:         int m0 = pcmDecodedData2;
  1499:         int m1 = pcmDecodedData1;
  1500:         int p = pcmPanLeft;
  1501:         if (p > 0) {  //ON
  1502:           pcmBuffer[i    ] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  1503:           pcmBuffer[i + 1] =                                         m1;
  1504:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1505:           p = (char) p;
  1506:           pcmBuffer[i    ] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p    ] >> 14;
  1507:           pcmBuffer[i + 1] = (                                        m1                  ) * pcmAttackCurve[p + 1] >> 14;
  1508:           p += 2;
  1509:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1510:         } else {  //OFF
  1511:           pcmBuffer[  i     ] = (
  1512:             pcmBuffer[i +  1] = 0);
  1513:         }
  1514:         pcmDecodedData3 = m0;
  1515:         pcmDecodedData2 = m1;
  1516:         pcmDecodedData1 = m2;
  1517:         pcmPointer = i + 2;
  1518:         if (Profiling.PFF_ON) {
  1519:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1520:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1521:         }
  1522:       }
  1523:     },  //PIP_MONO_HERMITE_2
  1524: 
  1525:     //ステレオ 区分定数補間 3906.25Hz
  1526:     PIP_STEREO_CONSTANT_16 {
  1527:       @Override public void write (int m) {
  1528:         if (Profiling.PFF_ON) {
  1529:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1530:         }
  1531:         int i = pcmPointer;
  1532:         int p = pcmPanLeft;
  1533:         if (p > 0) {  //ON
  1534:           pcmBuffer[  i     ] = (
  1535:             pcmBuffer[i +  2] =
  1536:             pcmBuffer[i +  4] =
  1537:             pcmBuffer[i +  6] =
  1538:             pcmBuffer[i +  8] =
  1539:             pcmBuffer[i + 10] =
  1540:             pcmBuffer[i + 12] =
  1541:             pcmBuffer[i + 14] =
  1542:             pcmBuffer[i + 16] =
  1543:             pcmBuffer[i + 18] =
  1544:             pcmBuffer[i + 20] =
  1545:             pcmBuffer[i + 22] =
  1546:             pcmBuffer[i + 24] =
  1547:             pcmBuffer[i + 26] =
  1548:             pcmBuffer[i + 28] =
  1549:             pcmBuffer[i + 30] = m);
  1550:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1551:           p = (char) p;
  1552:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1553:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1554:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1555:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  3] >> 14;
  1556:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  4] >> 14;
  1557:           pcmBuffer[i + 10] = m * pcmAttackCurve[p +  5] >> 14;
  1558:           pcmBuffer[i + 12] = m * pcmAttackCurve[p +  6] >> 14;
  1559:           pcmBuffer[i + 14] = m * pcmAttackCurve[p +  7] >> 14;
  1560:           pcmBuffer[i + 16] = m * pcmAttackCurve[p +  8] >> 14;
  1561:           pcmBuffer[i + 18] = m * pcmAttackCurve[p +  9] >> 14;
  1562:           pcmBuffer[i + 20] = m * pcmAttackCurve[p + 10] >> 14;
  1563:           pcmBuffer[i + 22] = m * pcmAttackCurve[p + 11] >> 14;
  1564:           pcmBuffer[i + 24] = m * pcmAttackCurve[p + 12] >> 14;
  1565:           pcmBuffer[i + 26] = m * pcmAttackCurve[p + 13] >> 14;
  1566:           pcmBuffer[i + 28] = m * pcmAttackCurve[p + 14] >> 14;
  1567:           pcmBuffer[i + 30] = m * pcmAttackCurve[p + 15] >> 14;
  1568:           p += 16;
  1569:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1570:         } else {  //OFF
  1571:           pcmBuffer[  i     ] = (
  1572:             pcmBuffer[i +  2] =
  1573:             pcmBuffer[i +  4] =
  1574:             pcmBuffer[i +  6] =
  1575:             pcmBuffer[i +  8] =
  1576:             pcmBuffer[i + 10] =
  1577:             pcmBuffer[i + 12] =
  1578:             pcmBuffer[i + 14] =
  1579:             pcmBuffer[i + 16] =
  1580:             pcmBuffer[i + 18] =
  1581:             pcmBuffer[i + 20] =
  1582:             pcmBuffer[i + 22] =
  1583:             pcmBuffer[i + 24] =
  1584:             pcmBuffer[i + 26] =
  1585:             pcmBuffer[i + 28] =
  1586:             pcmBuffer[i + 30] = 0);
  1587:         }
  1588:         p = pcmPanRight;
  1589:         if (p > 0) {  //ON
  1590:           pcmBuffer[  i +  1] = (
  1591:             pcmBuffer[i +  3] =
  1592:             pcmBuffer[i +  5] =
  1593:             pcmBuffer[i +  7] =
  1594:             pcmBuffer[i +  9] =
  1595:             pcmBuffer[i + 11] =
  1596:             pcmBuffer[i + 13] =
  1597:             pcmBuffer[i + 15] =
  1598:             pcmBuffer[i + 17] =
  1599:             pcmBuffer[i + 19] =
  1600:             pcmBuffer[i + 21] =
  1601:             pcmBuffer[i + 23] =
  1602:             pcmBuffer[i + 25] =
  1603:             pcmBuffer[i + 27] =
  1604:             pcmBuffer[i + 29] =
  1605:             pcmBuffer[i + 31] = m);
  1606:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1607:           p = (char) p;
  1608:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1609:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1610:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1611:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  3] >> 14;
  1612:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  4] >> 14;
  1613:           pcmBuffer[i + 11] = m * pcmAttackCurve[p +  5] >> 14;
  1614:           pcmBuffer[i + 13] = m * pcmAttackCurve[p +  6] >> 14;
  1615:           pcmBuffer[i + 15] = m * pcmAttackCurve[p +  7] >> 14;
  1616:           pcmBuffer[i + 17] = m * pcmAttackCurve[p +  8] >> 14;
  1617:           pcmBuffer[i + 19] = m * pcmAttackCurve[p +  9] >> 14;
  1618:           pcmBuffer[i + 21] = m * pcmAttackCurve[p + 10] >> 14;
  1619:           pcmBuffer[i + 23] = m * pcmAttackCurve[p + 11] >> 14;
  1620:           pcmBuffer[i + 25] = m * pcmAttackCurve[p + 12] >> 14;
  1621:           pcmBuffer[i + 27] = m * pcmAttackCurve[p + 13] >> 14;
  1622:           pcmBuffer[i + 29] = m * pcmAttackCurve[p + 14] >> 14;
  1623:           pcmBuffer[i + 31] = m * pcmAttackCurve[p + 15] >> 14;
  1624:           p += 16;
  1625:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1626:         } else {  //OFF
  1627:           pcmBuffer[  i +  1] = (
  1628:             pcmBuffer[i +  3] =
  1629:             pcmBuffer[i +  5] =
  1630:             pcmBuffer[i +  7] =
  1631:             pcmBuffer[i +  9] =
  1632:             pcmBuffer[i + 11] =
  1633:             pcmBuffer[i + 13] =
  1634:             pcmBuffer[i + 15] =
  1635:             pcmBuffer[i + 17] =
  1636:             pcmBuffer[i + 19] =
  1637:             pcmBuffer[i + 21] =
  1638:             pcmBuffer[i + 23] =
  1639:             pcmBuffer[i + 25] =
  1640:             pcmBuffer[i + 27] =
  1641:             pcmBuffer[i + 29] =
  1642:             pcmBuffer[i + 31] = 0);
  1643:         }
  1644:         pcmDecodedData1 = m;
  1645:         pcmPointer = i + 32;
  1646:         if (Profiling.PFF_ON) {
  1647:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1648:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1649:         }
  1650:       }
  1651:     },  //PIP_STEREO_CONSTANT_16
  1652: 
  1653:     //ステレオ 区分定数補間 5208.33Hz
  1654:     PIP_STEREO_CONSTANT_12 {
  1655:       @Override public void write (int m) {
  1656:         if (Profiling.PFF_ON) {
  1657:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1658:         }
  1659:         int i = pcmPointer;
  1660:         int p = pcmPanLeft;
  1661:         if (p > 0) {  //ON
  1662:           pcmBuffer[  i     ] = (
  1663:             pcmBuffer[i +  2] =
  1664:             pcmBuffer[i +  4] =
  1665:             pcmBuffer[i +  6] =
  1666:             pcmBuffer[i +  8] =
  1667:             pcmBuffer[i + 10] =
  1668:             pcmBuffer[i + 12] =
  1669:             pcmBuffer[i + 14] =
  1670:             pcmBuffer[i + 16] =
  1671:             pcmBuffer[i + 18] =
  1672:             pcmBuffer[i + 20] =
  1673:             pcmBuffer[i + 22] = m);
  1674:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1675:           p = (char) p;
  1676:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1677:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1678:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1679:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  3] >> 14;
  1680:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  4] >> 14;
  1681:           pcmBuffer[i + 10] = m * pcmAttackCurve[p +  5] >> 14;
  1682:           pcmBuffer[i + 12] = m * pcmAttackCurve[p +  6] >> 14;
  1683:           pcmBuffer[i + 14] = m * pcmAttackCurve[p +  7] >> 14;
  1684:           pcmBuffer[i + 16] = m * pcmAttackCurve[p +  8] >> 14;
  1685:           pcmBuffer[i + 18] = m * pcmAttackCurve[p +  9] >> 14;
  1686:           pcmBuffer[i + 20] = m * pcmAttackCurve[p + 10] >> 14;
  1687:           pcmBuffer[i + 22] = m * pcmAttackCurve[p + 11] >> 14;
  1688:           p += 12;
  1689:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1690:         } else {  //OFF
  1691:           pcmBuffer[  i     ] = (
  1692:             pcmBuffer[i +  2] =
  1693:             pcmBuffer[i +  4] =
  1694:             pcmBuffer[i +  6] =
  1695:             pcmBuffer[i +  8] =
  1696:             pcmBuffer[i + 10] =
  1697:             pcmBuffer[i + 12] =
  1698:             pcmBuffer[i + 14] =
  1699:             pcmBuffer[i + 16] =
  1700:             pcmBuffer[i + 18] =
  1701:             pcmBuffer[i + 20] =
  1702:             pcmBuffer[i + 22] = 0);
  1703:         }
  1704:         p = pcmPanRight;
  1705:         if (p > 0) {  //ON
  1706:           pcmBuffer[  i +  1] = (
  1707:             pcmBuffer[i +  3] =
  1708:             pcmBuffer[i +  5] =
  1709:             pcmBuffer[i +  7] =
  1710:             pcmBuffer[i +  9] =
  1711:             pcmBuffer[i + 11] =
  1712:             pcmBuffer[i + 13] =
  1713:             pcmBuffer[i + 15] =
  1714:             pcmBuffer[i + 17] =
  1715:             pcmBuffer[i + 19] =
  1716:             pcmBuffer[i + 21] =
  1717:             pcmBuffer[i + 23] = m);
  1718:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1719:           p = (char) p;
  1720:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1721:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1722:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1723:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  3] >> 14;
  1724:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  4] >> 14;
  1725:           pcmBuffer[i + 11] = m * pcmAttackCurve[p +  5] >> 14;
  1726:           pcmBuffer[i + 13] = m * pcmAttackCurve[p +  6] >> 14;
  1727:           pcmBuffer[i + 15] = m * pcmAttackCurve[p +  7] >> 14;
  1728:           pcmBuffer[i + 17] = m * pcmAttackCurve[p +  8] >> 14;
  1729:           pcmBuffer[i + 19] = m * pcmAttackCurve[p +  9] >> 14;
  1730:           pcmBuffer[i + 21] = m * pcmAttackCurve[p + 10] >> 14;
  1731:           pcmBuffer[i + 23] = m * pcmAttackCurve[p + 11] >> 14;
  1732:           p += 12;
  1733:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1734:         } else {  //OFF
  1735:           pcmBuffer[  i +  1] = (
  1736:             pcmBuffer[i +  3] =
  1737:             pcmBuffer[i +  5] =
  1738:             pcmBuffer[i +  7] =
  1739:             pcmBuffer[i +  9] =
  1740:             pcmBuffer[i + 11] =
  1741:             pcmBuffer[i + 13] =
  1742:             pcmBuffer[i + 15] =
  1743:             pcmBuffer[i + 17] =
  1744:             pcmBuffer[i + 19] =
  1745:             pcmBuffer[i + 21] =
  1746:             pcmBuffer[i + 23] = 0);
  1747:         }
  1748:         pcmDecodedData1 = m;
  1749:         pcmPointer = i + 24;
  1750:         if (Profiling.PFF_ON) {
  1751:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1752:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1753:         }
  1754:       }
  1755:     },  //PIP_STEREO_CONSTANT_12
  1756: 
  1757:     //ステレオ 区分定数補間 7812.50Hz
  1758:     PIP_STEREO_CONSTANT_8 {
  1759:       @Override public void write (int m) {
  1760:         if (Profiling.PFF_ON) {
  1761:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1762:         }
  1763:         int i = pcmPointer;
  1764:         int p = pcmPanLeft;
  1765:         if (p > 0) {  //ON
  1766:           pcmBuffer[  i     ] = (
  1767:             pcmBuffer[i +  2] =
  1768:             pcmBuffer[i +  4] =
  1769:             pcmBuffer[i +  6] =
  1770:             pcmBuffer[i +  8] =
  1771:             pcmBuffer[i + 10] =
  1772:             pcmBuffer[i + 12] =
  1773:             pcmBuffer[i + 14] = m);
  1774:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1775:           p = (char) p;
  1776:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1777:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1778:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1779:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  3] >> 14;
  1780:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  4] >> 14;
  1781:           pcmBuffer[i + 10] = m * pcmAttackCurve[p +  5] >> 14;
  1782:           pcmBuffer[i + 12] = m * pcmAttackCurve[p +  6] >> 14;
  1783:           pcmBuffer[i + 14] = m * pcmAttackCurve[p +  7] >> 14;
  1784:           p += 8;
  1785:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1786:         } else {  //OFF
  1787:           pcmBuffer[  i     ] = (
  1788:             pcmBuffer[i +  2] =
  1789:             pcmBuffer[i +  4] =
  1790:             pcmBuffer[i +  6] =
  1791:             pcmBuffer[i +  8] =
  1792:             pcmBuffer[i + 10] =
  1793:             pcmBuffer[i + 12] =
  1794:             pcmBuffer[i + 14] = 0);
  1795:         }
  1796:         p = pcmPanRight;
  1797:         if (p > 0) {  //ON
  1798:           pcmBuffer[  i +  1] = (
  1799:             pcmBuffer[i +  3] =
  1800:             pcmBuffer[i +  5] =
  1801:             pcmBuffer[i +  7] =
  1802:             pcmBuffer[i +  9] =
  1803:             pcmBuffer[i + 11] =
  1804:             pcmBuffer[i + 13] =
  1805:             pcmBuffer[i + 15] = m);
  1806:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1807:           p = (char) p;
  1808:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1809:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1810:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1811:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  3] >> 14;
  1812:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  4] >> 14;
  1813:           pcmBuffer[i + 11] = m * pcmAttackCurve[p +  5] >> 14;
  1814:           pcmBuffer[i + 13] = m * pcmAttackCurve[p +  6] >> 14;
  1815:           pcmBuffer[i + 15] = m * pcmAttackCurve[p +  7] >> 14;
  1816:           p += 8;
  1817:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1818:         } else {  //OFF
  1819:           pcmBuffer[  i +  1] = (
  1820:             pcmBuffer[i +  3] =
  1821:             pcmBuffer[i +  5] =
  1822:             pcmBuffer[i +  7] =
  1823:             pcmBuffer[i +  9] =
  1824:             pcmBuffer[i + 11] =
  1825:             pcmBuffer[i + 13] =
  1826:             pcmBuffer[i + 15] = 0);
  1827:         }
  1828:         pcmDecodedData1 = m;
  1829:         pcmPointer = i + 16;
  1830:         if (Profiling.PFF_ON) {
  1831:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1832:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1833:         }
  1834:       }
  1835:     },  //PIP_STEREO_CONSTANT_8
  1836: 
  1837:     //ステレオ 区分定数補間 10416.67Hz
  1838:     PIP_STEREO_CONSTANT_6 {
  1839:       @Override public void write (int m) {
  1840:         if (Profiling.PFF_ON) {
  1841:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1842:         }
  1843:         int i = pcmPointer;
  1844:         int p = pcmPanLeft;
  1845:         if (p > 0) {  //ON
  1846:           pcmBuffer[  i     ] = (
  1847:             pcmBuffer[i +  2] =
  1848:             pcmBuffer[i +  4] =
  1849:             pcmBuffer[i +  6] =
  1850:             pcmBuffer[i +  8] =
  1851:             pcmBuffer[i + 10] = m);
  1852:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1853:           p = (char) p;
  1854:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1855:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1856:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1857:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  3] >> 14;
  1858:           pcmBuffer[i +  8] = m * pcmAttackCurve[p +  4] >> 14;
  1859:           pcmBuffer[i + 10] = m * pcmAttackCurve[p +  5] >> 14;
  1860:           p += 6;
  1861:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1862:         } else {  //OFF
  1863:           pcmBuffer[  i     ] = (
  1864:             pcmBuffer[i +  2] =
  1865:             pcmBuffer[i +  4] =
  1866:             pcmBuffer[i +  6] =
  1867:             pcmBuffer[i +  8] =
  1868:             pcmBuffer[i + 10] = 0);
  1869:         }
  1870:         p = pcmPanRight;
  1871:         if (p > 0) {  //ON
  1872:           pcmBuffer[  i +  1] = (
  1873:             pcmBuffer[i +  3] =
  1874:             pcmBuffer[i +  5] =
  1875:             pcmBuffer[i +  7] =
  1876:             pcmBuffer[i +  9] =
  1877:             pcmBuffer[i + 11] = m);
  1878:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1879:           p = (char) p;
  1880:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1881:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1882:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1883:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  3] >> 14;
  1884:           pcmBuffer[i +  9] = m * pcmAttackCurve[p +  4] >> 14;
  1885:           pcmBuffer[i + 11] = m * pcmAttackCurve[p +  5] >> 14;
  1886:           p += 6;
  1887:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1888:         } else {  //OFF
  1889:           pcmBuffer[  i +  1] = (
  1890:             pcmBuffer[i +  3] =
  1891:             pcmBuffer[i +  5] =
  1892:             pcmBuffer[i +  7] =
  1893:             pcmBuffer[i +  9] =
  1894:             pcmBuffer[i + 11] = 0);
  1895:         }
  1896:         pcmDecodedData1 = m;
  1897:         pcmPointer = i + 12;
  1898:         if (Profiling.PFF_ON) {
  1899:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1900:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1901:         }
  1902:       }
  1903:     },  //PIP_STEREO_CONSTANT_6
  1904: 
  1905:     //ステレオ 区分定数補間 15625.00Hz
  1906:     PIP_STEREO_CONSTANT_4 {
  1907:       @Override public void write (int m) {
  1908:         if (Profiling.PFF_ON) {
  1909:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1910:         }
  1911:         int i = pcmPointer;
  1912:         int p = pcmPanLeft;
  1913:         if (p > 0) {  //ON
  1914:           pcmBuffer[  i     ] = (
  1915:             pcmBuffer[i +  2] =
  1916:             pcmBuffer[i +  4] =
  1917:             pcmBuffer[i +  6] = m);
  1918:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1919:           p = (char) p;
  1920:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1921:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1922:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1923:           pcmBuffer[i +  6] = m * pcmAttackCurve[p +  3] >> 14;
  1924:           p += 4;
  1925:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1926:         } else {  //OFF
  1927:           pcmBuffer[  i     ] = (
  1928:             pcmBuffer[i +  2] =
  1929:             pcmBuffer[i +  4] =
  1930:             pcmBuffer[i +  6] = 0);
  1931:         }
  1932:         p = pcmPanRight;
  1933:         if (p > 0) {  //ON
  1934:           pcmBuffer[  i +  1] = (
  1935:             pcmBuffer[i +  3] =
  1936:             pcmBuffer[i +  5] =
  1937:             pcmBuffer[i +  7] = m);
  1938:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1939:           p = (char) p;
  1940:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1941:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1942:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1943:           pcmBuffer[i +  7] = m * pcmAttackCurve[p +  3] >> 14;
  1944:           p += 4;
  1945:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1946:         } else {  //OFF
  1947:           pcmBuffer[  i +  1] = (
  1948:             pcmBuffer[i +  3] =
  1949:             pcmBuffer[i +  5] =
  1950:             pcmBuffer[i +  7] = 0);
  1951:         }
  1952:         pcmDecodedData1 = m;
  1953:         pcmPointer = i + 8;
  1954:         if (Profiling.PFF_ON) {
  1955:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  1956:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  1957:         }
  1958:       }
  1959:     },  //PIP_STEREO_CONSTANT_4
  1960: 
  1961:     //ステレオ 区分定数補間 20833.33Hz
  1962:     PIP_STEREO_CONSTANT_3 {
  1963:       @Override public void write (int m) {
  1964:         if (Profiling.PFF_ON) {
  1965:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  1966:         }
  1967:         int i = pcmPointer;
  1968:         int p = pcmPanLeft;
  1969:         if (p > 0) {  //ON
  1970:           pcmBuffer[  i     ] = (
  1971:             pcmBuffer[i +  2] =
  1972:             pcmBuffer[i +  4] = m);
  1973:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1974:           p = (char) p;
  1975:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  1976:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  1977:           pcmBuffer[i +  4] = m * pcmAttackCurve[p +  2] >> 14;
  1978:           p += 3;
  1979:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1980:         } else {  //OFF
  1981:           pcmBuffer[  i     ] = (
  1982:             pcmBuffer[i +  2] =
  1983:             pcmBuffer[i +  4] = 0);
  1984:         }
  1985:         p = pcmPanRight;
  1986:         if (p > 0) {  //ON
  1987:           pcmBuffer[  i +  1] = (
  1988:             pcmBuffer[i +  3] =
  1989:             pcmBuffer[i +  5] = m);
  1990:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  1991:           p = (char) p;
  1992:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  1993:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  1994:           pcmBuffer[i +  5] = m * pcmAttackCurve[p +  2] >> 14;
  1995:           p += 3;
  1996:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  1997:         } else {  //OFF
  1998:           pcmBuffer[  i +  1] = (
  1999:             pcmBuffer[i +  3] =
  2000:             pcmBuffer[i +  5] = 0);
  2001:         }
  2002:         pcmDecodedData1 = m;
  2003:         pcmPointer = i + 6;
  2004:         if (Profiling.PFF_ON) {
  2005:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2006:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2007:         }
  2008:       }
  2009:     },  //PIP_STEREO_CONSTANT_3
  2010: 
  2011:     //ステレオ 区分定数補間 31250.00Hz
  2012:     PIP_STEREO_CONSTANT_2 {
  2013:       @Override public void write (int m) {
  2014:         if (Profiling.PFF_ON) {
  2015:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2016:         }
  2017:         int i = pcmPointer;
  2018:         int p = pcmPanLeft;
  2019:         if (p > 0) {  //ON
  2020:           pcmBuffer[  i     ] = (
  2021:             pcmBuffer[i +  2] = m);
  2022:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2023:           p = (char) p;
  2024:           pcmBuffer[i     ] = m * pcmAttackCurve[p     ] >> 14;
  2025:           pcmBuffer[i +  2] = m * pcmAttackCurve[p +  1] >> 14;
  2026:           p += 2;
  2027:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2028:         } else {  //OFF
  2029:           pcmBuffer[  i     ] = (
  2030:             pcmBuffer[i +  2] = 0);
  2031:         }
  2032:         p = pcmPanRight;
  2033:         if (p > 0) {  //ON
  2034:           pcmBuffer[  i +  1] = (
  2035:             pcmBuffer[i +  3] = m);
  2036:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2037:           p = (char) p;
  2038:           pcmBuffer[i +  1] = m * pcmAttackCurve[p     ] >> 14;
  2039:           pcmBuffer[i +  3] = m * pcmAttackCurve[p +  1] >> 14;
  2040:           p += 2;
  2041:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2042:         } else {  //OFF
  2043:           pcmBuffer[  i +  1] = (
  2044:             pcmBuffer[i +  3] = 0);
  2045:         }
  2046:         pcmDecodedData1 = m;
  2047:         pcmPointer = i + 4;
  2048:         if (Profiling.PFF_ON) {
  2049:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2050:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2051:         }
  2052:       }
  2053:     },  //PIP_STEREO_CONSTANT_2
  2054: 
  2055:     //ステレオ 線形補間 3906.25Hz
  2056:     PIP_STEREO_LINEAR_16 {
  2057:       @Override public void write (int m1) {
  2058:         if (Profiling.PFF_ON) {
  2059:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2060:         }
  2061:         int i = pcmPointer;
  2062:         int p = pcmPanLeft;
  2063:         if (p > 0) {  //ON
  2064:           int m0 = pcmDecodedData1;
  2065:           pcmBuffer[i     ] = 15 * m0 +      m1 >> 4;
  2066:           pcmBuffer[i +  2] =  7 * m0 +      m1 >> 3;
  2067:           pcmBuffer[i +  4] = 13 * m0 +  3 * m1 >> 4;
  2068:           pcmBuffer[i +  6] =  3 * m0 +      m1 >> 2;
  2069:           pcmBuffer[i +  8] = 11 * m0 +  5 * m1 >> 4;
  2070:           pcmBuffer[i + 10] =  5 * m0 +  3 * m1 >> 3;
  2071:           pcmBuffer[i + 12] =  9 * m0 +  7 * m1 >> 4;
  2072:           pcmBuffer[i + 14] =      m0 +      m1 >> 1;
  2073:           pcmBuffer[i + 16] =  7 * m0 +  9 * m1 >> 4;
  2074:           pcmBuffer[i + 18] =  3 * m0 +  5 * m1 >> 3;
  2075:           pcmBuffer[i + 20] =  5 * m0 + 11 * m1 >> 4;
  2076:           pcmBuffer[i + 22] =      m0 +  3 * m1 >> 2;
  2077:           pcmBuffer[i + 24] =  3 * m0 + 13 * m1 >> 4;
  2078:           pcmBuffer[i + 26] =      m0 +  7 * m1 >> 3;
  2079:           pcmBuffer[i + 28] =      m0 + 15 * m1 >> 4;
  2080:           pcmBuffer[i + 30] =                m1;
  2081:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2082:           p = (char) p;
  2083:           int m0 = pcmDecodedData1;
  2084:           pcmBuffer[i     ] = (15 * m0 +      m1 >> 4) * pcmAttackCurve[p     ] >> 14;
  2085:           pcmBuffer[i +  2] = ( 7 * m0 +      m1 >> 3) * pcmAttackCurve[p +  1] >> 14;
  2086:           pcmBuffer[i +  4] = (13 * m0 +  3 * m1 >> 4) * pcmAttackCurve[p +  2] >> 14;
  2087:           pcmBuffer[i +  6] = ( 3 * m0 +      m1 >> 2) * pcmAttackCurve[p +  3] >> 14;
  2088:           pcmBuffer[i +  8] = (11 * m0 +  5 * m1 >> 4) * pcmAttackCurve[p +  4] >> 14;
  2089:           pcmBuffer[i + 10] = ( 5 * m0 +  3 * m1 >> 3) * pcmAttackCurve[p +  5] >> 14;
  2090:           pcmBuffer[i + 12] = ( 9 * m0 +  7 * m1 >> 4) * pcmAttackCurve[p +  6] >> 14;
  2091:           pcmBuffer[i + 14] = (     m0 +      m1 >> 1) * pcmAttackCurve[p +  7] >> 14;
  2092:           pcmBuffer[i + 16] = ( 7 * m0 +  9 * m1 >> 4) * pcmAttackCurve[p +  8] >> 14;
  2093:           pcmBuffer[i + 18] = ( 3 * m0 +  5 * m1 >> 3) * pcmAttackCurve[p +  9] >> 14;
  2094:           pcmBuffer[i + 20] = ( 5 * m0 + 11 * m1 >> 4) * pcmAttackCurve[p + 10] >> 14;
  2095:           pcmBuffer[i + 22] = (     m0 +  3 * m1 >> 2) * pcmAttackCurve[p + 11] >> 14;
  2096:           pcmBuffer[i + 24] = ( 3 * m0 + 13 * m1 >> 4) * pcmAttackCurve[p + 12] >> 14;
  2097:           pcmBuffer[i + 26] = (     m0 +  7 * m1 >> 3) * pcmAttackCurve[p + 13] >> 14;
  2098:           pcmBuffer[i + 28] = (     m0 + 15 * m1 >> 4) * pcmAttackCurve[p + 14] >> 14;
  2099:           pcmBuffer[i + 30] = (               m1     ) * pcmAttackCurve[p + 15] >> 14;
  2100:           p += 16;
  2101:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2102:         } else {  //OFF
  2103:           pcmBuffer[  i     ] = (
  2104:             pcmBuffer[i +  2] =
  2105:             pcmBuffer[i +  4] =
  2106:             pcmBuffer[i +  6] =
  2107:             pcmBuffer[i +  8] =
  2108:             pcmBuffer[i + 10] =
  2109:             pcmBuffer[i + 12] =
  2110:             pcmBuffer[i + 14] =
  2111:             pcmBuffer[i + 16] =
  2112:             pcmBuffer[i + 18] =
  2113:             pcmBuffer[i + 20] =
  2114:             pcmBuffer[i + 22] =
  2115:             pcmBuffer[i + 24] =
  2116:             pcmBuffer[i + 26] =
  2117:             pcmBuffer[i + 28] =
  2118:             pcmBuffer[i + 30] = 0);
  2119:         }
  2120:         p = pcmPanRight;
  2121:         if (p > 0) {  //ON
  2122:           int m0 = pcmDecodedData1;
  2123:           pcmBuffer[i +  1] = 15 * m0 +      m1 >> 4;
  2124:           pcmBuffer[i +  3] =  7 * m0 +      m1 >> 3;
  2125:           pcmBuffer[i +  5] = 13 * m0 +  3 * m1 >> 4;
  2126:           pcmBuffer[i +  7] =  3 * m0 +      m1 >> 2;
  2127:           pcmBuffer[i +  9] = 11 * m0 +  5 * m1 >> 4;
  2128:           pcmBuffer[i + 11] =  5 * m0 +  3 * m1 >> 3;
  2129:           pcmBuffer[i + 13] =  9 * m0 +  7 * m1 >> 4;
  2130:           pcmBuffer[i + 15] =      m0 +      m1 >> 1;
  2131:           pcmBuffer[i + 17] =  7 * m0 +  9 * m1 >> 4;
  2132:           pcmBuffer[i + 19] =  3 * m0 +  5 * m1 >> 3;
  2133:           pcmBuffer[i + 21] =  5 * m0 + 11 * m1 >> 4;
  2134:           pcmBuffer[i + 23] =      m0 +  3 * m1 >> 2;
  2135:           pcmBuffer[i + 25] =  3 * m0 + 13 * m1 >> 4;
  2136:           pcmBuffer[i + 27] =      m0 +  7 * m1 >> 3;
  2137:           pcmBuffer[i + 29] =      m0 + 15 * m1 >> 4;
  2138:           pcmBuffer[i + 31] =                m1;
  2139:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2140:           p = (char) p;
  2141:           int m0 = pcmDecodedData1;
  2142:           pcmBuffer[i +  1] = (15 * m0 +      m1 >> 4) * pcmAttackCurve[p     ] >> 14;
  2143:           pcmBuffer[i +  3] = ( 7 * m0 +      m1 >> 3) * pcmAttackCurve[p +  1] >> 14;
  2144:           pcmBuffer[i +  5] = (13 * m0 +  3 * m1 >> 4) * pcmAttackCurve[p +  2] >> 14;
  2145:           pcmBuffer[i +  7] = ( 3 * m0 +      m1 >> 2) * pcmAttackCurve[p +  3] >> 14;
  2146:           pcmBuffer[i +  9] = (11 * m0 +  5 * m1 >> 4) * pcmAttackCurve[p +  4] >> 14;
  2147:           pcmBuffer[i + 11] = ( 5 * m0 +  3 * m1 >> 3) * pcmAttackCurve[p +  5] >> 14;
  2148:           pcmBuffer[i + 13] = ( 9 * m0 +  7 * m1 >> 4) * pcmAttackCurve[p +  6] >> 14;
  2149:           pcmBuffer[i + 15] = (     m0 +      m1 >> 1) * pcmAttackCurve[p +  7] >> 14;
  2150:           pcmBuffer[i + 17] = ( 7 * m0 +  9 * m1 >> 4) * pcmAttackCurve[p +  8] >> 14;
  2151:           pcmBuffer[i + 19] = ( 3 * m0 +  5 * m1 >> 3) * pcmAttackCurve[p +  9] >> 14;
  2152:           pcmBuffer[i + 21] = ( 5 * m0 + 11 * m1 >> 4) * pcmAttackCurve[p + 10] >> 14;
  2153:           pcmBuffer[i + 23] = (     m0 +  3 * m1 >> 2) * pcmAttackCurve[p + 11] >> 14;
  2154:           pcmBuffer[i + 25] = ( 3 * m0 + 13 * m1 >> 4) * pcmAttackCurve[p + 12] >> 14;
  2155:           pcmBuffer[i + 27] = (     m0 +  7 * m1 >> 3) * pcmAttackCurve[p + 13] >> 14;
  2156:           pcmBuffer[i + 29] = (     m0 + 15 * m1 >> 4) * pcmAttackCurve[p + 14] >> 14;
  2157:           pcmBuffer[i + 31] = (               m1     ) * pcmAttackCurve[p + 15] >> 14;
  2158:           p += 16;
  2159:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2160:         } else {  //OFF
  2161:           pcmBuffer[  i +  1] = (
  2162:             pcmBuffer[i +  3] =
  2163:             pcmBuffer[i +  5] =
  2164:             pcmBuffer[i +  7] =
  2165:             pcmBuffer[i +  9] =
  2166:             pcmBuffer[i + 11] =
  2167:             pcmBuffer[i + 13] =
  2168:             pcmBuffer[i + 15] =
  2169:             pcmBuffer[i + 17] =
  2170:             pcmBuffer[i + 19] =
  2171:             pcmBuffer[i + 21] =
  2172:             pcmBuffer[i + 23] =
  2173:             pcmBuffer[i + 25] =
  2174:             pcmBuffer[i + 27] =
  2175:             pcmBuffer[i + 29] =
  2176:             pcmBuffer[i + 31] = 0);
  2177:         }
  2178:         pcmDecodedData1 = m1;
  2179:         pcmPointer = i + 32;
  2180:         if (Profiling.PFF_ON) {
  2181:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2182:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2183:         }
  2184:       }
  2185:     },  //PIP_STEREO_LINEAR_16
  2186: 
  2187:     //ステレオ 線形補間 5208.33Hz
  2188:     PIP_STEREO_LINEAR_12 {
  2189:       @Override public void write (int m1) {
  2190:         if (Profiling.PFF_ON) {
  2191:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2192:         }
  2193:         int i = pcmPointer;
  2194:         int p = pcmPanLeft;
  2195:         if (p > 0) {  //ON
  2196:           int m0 = pcmDecodedData1;
  2197:           pcmBuffer[i     ] = 65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16;
  2198:           pcmBuffer[i +  2] = 65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16;
  2199:           pcmBuffer[i +  4] =          3      * m0 +                   m1 >>  2;
  2200:           pcmBuffer[i +  6] = 65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16;
  2201:           pcmBuffer[i +  8] = 65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16;
  2202:           pcmBuffer[i + 10] =                   m0 +                   m1 >>  1;
  2203:           pcmBuffer[i + 12] = 65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16;
  2204:           pcmBuffer[i + 14] = 65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16;
  2205:           pcmBuffer[i + 16] =                   m0 +          3      * m1 >>  2;
  2206:           pcmBuffer[i + 18] = 65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16;
  2207:           pcmBuffer[i + 20] = 65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16;
  2208:           pcmBuffer[i + 22] =                                          m1;
  2209:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2210:           p = (char) p;
  2211:           int m0 = pcmDecodedData1;
  2212:           pcmBuffer[i     ] = (65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16) * pcmAttackCurve[p     ] >> 14;
  2213:           pcmBuffer[i +  2] = (65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16) * pcmAttackCurve[p +  1] >> 14;
  2214:           pcmBuffer[i +  4] = (         3      * m0 +                   m1 >>  2) * pcmAttackCurve[p +  2] >> 14;
  2215:           pcmBuffer[i +  6] = (65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16) * pcmAttackCurve[p +  3] >> 14;
  2216:           pcmBuffer[i +  8] = (65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16) * pcmAttackCurve[p +  4] >> 14;
  2217:           pcmBuffer[i + 10] = (                  m0 +                   m1 >>  1) * pcmAttackCurve[p +  5] >> 14;
  2218:           pcmBuffer[i + 12] = (65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16) * pcmAttackCurve[p +  6] >> 14;
  2219:           pcmBuffer[i + 14] = (65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16) * pcmAttackCurve[p +  7] >> 14;
  2220:           pcmBuffer[i + 16] = (                  m0 +          3      * m1 >>  2) * pcmAttackCurve[p +  8] >> 14;
  2221:           pcmBuffer[i + 18] = (65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16) * pcmAttackCurve[p +  9] >> 14;
  2222:           pcmBuffer[i + 20] = (65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16) * pcmAttackCurve[p + 10] >> 14;
  2223:           pcmBuffer[i + 22] = (                                         m1      ) * pcmAttackCurve[p + 11] >> 14;
  2224:           p += 12;
  2225:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2226:         } else {  //OFF
  2227:           pcmBuffer[  i     ] = (
  2228:             pcmBuffer[i +  2] =
  2229:             pcmBuffer[i +  4] =
  2230:             pcmBuffer[i +  6] =
  2231:             pcmBuffer[i +  8] =
  2232:             pcmBuffer[i + 10] =
  2233:             pcmBuffer[i + 12] =
  2234:             pcmBuffer[i + 14] =
  2235:             pcmBuffer[i + 16] =
  2236:             pcmBuffer[i + 18] =
  2237:             pcmBuffer[i + 20] =
  2238:             pcmBuffer[i + 22] = 0);
  2239:         }
  2240:         p = pcmPanRight;
  2241:         if (p > 0) {  //ON
  2242:           int m0 = pcmDecodedData1;
  2243:           pcmBuffer[i +  1] = 65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16;
  2244:           pcmBuffer[i +  3] = 65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16;
  2245:           pcmBuffer[i +  5] =          3      * m0 +                   m1 >>  2;
  2246:           pcmBuffer[i +  7] = 65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16;
  2247:           pcmBuffer[i +  9] = 65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16;
  2248:           pcmBuffer[i + 11] =                   m0 +                   m1 >>  1;
  2249:           pcmBuffer[i + 13] = 65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16;
  2250:           pcmBuffer[i + 15] = 65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16;
  2251:           pcmBuffer[i + 17] =                   m0 +          3      * m1 >>  2;
  2252:           pcmBuffer[i + 19] = 65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16;
  2253:           pcmBuffer[i + 21] = 65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16;
  2254:           pcmBuffer[i + 23] =                                          m1;
  2255:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2256:           p = (char) p;
  2257:           int m0 = pcmDecodedData1;
  2258:           pcmBuffer[i +  1] = (65536 * 11 / 12 * m0 + 65536 *  1 / 12 * m1 >> 16) * pcmAttackCurve[p     ] >> 14;
  2259:           pcmBuffer[i +  3] = (65536 * 10 / 12 * m0 + 65536 *  2 / 12 * m1 >> 16) * pcmAttackCurve[p +  1] >> 14;
  2260:           pcmBuffer[i +  5] = (         3      * m0 +                   m1 >>  2) * pcmAttackCurve[p +  2] >> 14;
  2261:           pcmBuffer[i +  7] = (65536 *  8 / 12 * m0 + 65536 *  4 / 12 * m1 >> 16) * pcmAttackCurve[p +  3] >> 14;
  2262:           pcmBuffer[i +  9] = (65536 *  7 / 12 * m0 + 65536 *  5 / 12 * m1 >> 16) * pcmAttackCurve[p +  4] >> 14;
  2263:           pcmBuffer[i + 11] = (                  m0 +                   m1 >>  1) * pcmAttackCurve[p +  5] >> 14;
  2264:           pcmBuffer[i + 13] = (65536 *  5 / 12 * m0 + 65536 *  7 / 12 * m1 >> 16) * pcmAttackCurve[p +  6] >> 14;
  2265:           pcmBuffer[i + 15] = (65536 *  4 / 12 * m0 + 65536 *  8 / 12 * m1 >> 16) * pcmAttackCurve[p +  7] >> 14;
  2266:           pcmBuffer[i + 17] = (                  m0 +          3      * m1 >>  2) * pcmAttackCurve[p +  8] >> 14;
  2267:           pcmBuffer[i + 19] = (65536 *  2 / 12 * m0 + 65536 * 10 / 12 * m1 >> 16) * pcmAttackCurve[p +  9] >> 14;
  2268:           pcmBuffer[i + 21] = (65536 *  1 / 12 * m0 + 65536 * 11 / 12 * m1 >> 16) * pcmAttackCurve[p + 10] >> 14;
  2269:           pcmBuffer[i + 23] = (                                         m1      ) * pcmAttackCurve[p + 11] >> 14;
  2270:           p += 12;
  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] =
  2277:             pcmBuffer[i +  9] =
  2278:             pcmBuffer[i + 11] =
  2279:             pcmBuffer[i + 13] =
  2280:             pcmBuffer[i + 15] =
  2281:             pcmBuffer[i + 17] =
  2282:             pcmBuffer[i + 19] =
  2283:             pcmBuffer[i + 21] =
  2284:             pcmBuffer[i + 23] = 0);
  2285:         }
  2286:         pcmDecodedData1 = m1;
  2287:         pcmPointer = i + 24;
  2288:         if (Profiling.PFF_ON) {
  2289:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2290:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2291:         }
  2292:       }
  2293:     },  //PIP_STEREO_LINEAR_12
  2294: 
  2295:     //ステレオ 線形補間 7812.50Hz
  2296:     PIP_STEREO_LINEAR_8 {
  2297:       @Override public void write (int m1) {
  2298:         if (Profiling.PFF_ON) {
  2299:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2300:         }
  2301:         int i = pcmPointer;
  2302:         int p = pcmPanLeft;
  2303:         if (p > 0) {  //ON
  2304:           int m0 = pcmDecodedData1;
  2305:           pcmBuffer[i     ] = 7 * m0 +     m1 >> 3;
  2306:           pcmBuffer[i +  2] = 3 * m0 +     m1 >> 2;
  2307:           pcmBuffer[i +  4] = 5 * m0 + 3 * m1 >> 3;
  2308:           pcmBuffer[i +  6] =     m0 +     m1 >> 1;
  2309:           pcmBuffer[i +  8] = 3 * m0 + 5 * m1 >> 3;
  2310:           pcmBuffer[i + 10] =     m0 + 3 * m1 >> 2;
  2311:           pcmBuffer[i + 12] =     m0 + 7 * m1 >> 3;
  2312:           pcmBuffer[i + 14] =              m1;
  2313:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2314:           p = (char) p;
  2315:           int m0 = pcmDecodedData1;
  2316:           pcmBuffer[i     ] = (7 * m0 +     m1 >> 3) * pcmAttackCurve[p    ] >> 14;
  2317:           pcmBuffer[i +  2] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p + 1] >> 14;
  2318:           pcmBuffer[i +  4] = (5 * m0 + 3 * m1 >> 3) * pcmAttackCurve[p + 2] >> 14;
  2319:           pcmBuffer[i +  6] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 3] >> 14;
  2320:           pcmBuffer[i +  8] = (3 * m0 + 5 * m1 >> 3) * pcmAttackCurve[p + 4] >> 14;
  2321:           pcmBuffer[i + 10] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 5] >> 14;
  2322:           pcmBuffer[i + 12] = (    m0 + 7 * m1 >> 3) * pcmAttackCurve[p + 6] >> 14;
  2323:           pcmBuffer[i + 14] = (             m1     ) * pcmAttackCurve[p + 7] >> 14;
  2324:           p += 8;
  2325:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2326:         } else {  //OFF
  2327:           pcmBuffer[  i     ] = (
  2328:             pcmBuffer[i +  2] =
  2329:             pcmBuffer[i +  4] =
  2330:             pcmBuffer[i +  6] =
  2331:             pcmBuffer[i +  8] =
  2332:             pcmBuffer[i + 10] =
  2333:             pcmBuffer[i + 12] =
  2334:             pcmBuffer[i + 14] = 0);
  2335:         }
  2336:         p = pcmPanRight;
  2337:         if (p > 0) {  //ON
  2338:           int m0 = pcmDecodedData1;
  2339:           pcmBuffer[i +  1] = 7 * m0 +     m1 >> 3;
  2340:           pcmBuffer[i +  3] = 3 * m0 +     m1 >> 2;
  2341:           pcmBuffer[i +  5] = 5 * m0 + 3 * m1 >> 3;
  2342:           pcmBuffer[i +  7] =     m0 +     m1 >> 1;
  2343:           pcmBuffer[i +  9] = 3 * m0 + 5 * m1 >> 3;
  2344:           pcmBuffer[i + 11] =     m0 + 3 * m1 >> 2;
  2345:           pcmBuffer[i + 13] =     m0 + 7 * m1 >> 3;
  2346:           pcmBuffer[i + 15] =              m1;
  2347:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2348:           p = (char) p;
  2349:           int m0 = pcmDecodedData1;
  2350:           pcmBuffer[i +  1] = (7 * m0 +     m1 >> 3) * pcmAttackCurve[p    ] >> 14;
  2351:           pcmBuffer[i +  3] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p + 1] >> 14;
  2352:           pcmBuffer[i +  5] = (5 * m0 + 3 * m1 >> 3) * pcmAttackCurve[p + 2] >> 14;
  2353:           pcmBuffer[i +  7] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 3] >> 14;
  2354:           pcmBuffer[i +  9] = (3 * m0 + 5 * m1 >> 3) * pcmAttackCurve[p + 4] >> 14;
  2355:           pcmBuffer[i + 11] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 5] >> 14;
  2356:           pcmBuffer[i + 13] = (    m0 + 7 * m1 >> 3) * pcmAttackCurve[p + 6] >> 14;
  2357:           pcmBuffer[i + 15] = (             m1     ) * pcmAttackCurve[p + 7] >> 14;
  2358:           p += 8;
  2359:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2360:         } else {  //OFF
  2361:           pcmBuffer[  i +  1] = (
  2362:             pcmBuffer[i +  3] =
  2363:             pcmBuffer[i +  5] =
  2364:             pcmBuffer[i +  7] =
  2365:             pcmBuffer[i +  9] =
  2366:             pcmBuffer[i + 11] =
  2367:             pcmBuffer[i + 13] =
  2368:             pcmBuffer[i + 15] = 0);
  2369:         }
  2370:         pcmDecodedData1 = m1;
  2371:         pcmPointer = i + 16;
  2372:         if (Profiling.PFF_ON) {
  2373:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2374:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2375:         }
  2376:       }
  2377:     },  //PIP_STEREO_LINEAR_8
  2378: 
  2379:     //ステレオ 線形補間 10416.67Hz
  2380:     PIP_STEREO_LINEAR_6 {
  2381:       @Override public void write (int m1) {
  2382:         if (Profiling.PFF_ON) {
  2383:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2384:         }
  2385:         int i = pcmPointer;
  2386:         int p = pcmPanLeft;
  2387:         if (p > 0) {  //ON
  2388:           int m0 = pcmDecodedData1;
  2389:           pcmBuffer[i     ] = 65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16;
  2390:           pcmBuffer[i +  2] = 65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16;
  2391:           pcmBuffer[i +  4] =                 m0 +                 m1 >>  1;
  2392:           pcmBuffer[i +  6] = 65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16;
  2393:           pcmBuffer[i +  8] = 65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16;
  2394:           pcmBuffer[i + 10] =                                      m1;
  2395:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2396:           p = (char) p;
  2397:           int m0 = pcmDecodedData1;
  2398:           pcmBuffer[i     ] = (65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  2399:           pcmBuffer[i +  2] = (65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  2400:           pcmBuffer[i +  4] = (                m0 +                 m1 >>  1) * pcmAttackCurve[p + 2] >> 14;
  2401:           pcmBuffer[i +  6] = (65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16) * pcmAttackCurve[p + 3] >> 14;
  2402:           pcmBuffer[i +  8] = (65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16) * pcmAttackCurve[p + 4] >> 14;
  2403:           pcmBuffer[i + 10] = (                                     m1      ) * pcmAttackCurve[p + 5] >> 14;
  2404:           p += 6;
  2405:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2406:         } else {  //OFF
  2407:           pcmBuffer[  i     ] = (
  2408:             pcmBuffer[i +  2] =
  2409:             pcmBuffer[i +  4] =
  2410:             pcmBuffer[i +  6] =
  2411:             pcmBuffer[i +  8] =
  2412:             pcmBuffer[i + 10] = 0);
  2413:         }
  2414:         p = pcmPanRight;
  2415:         if (p > 0) {  //ON
  2416:           int m0 = pcmDecodedData1;
  2417:           pcmBuffer[i +  1] = 65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16;
  2418:           pcmBuffer[i +  3] = 65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16;
  2419:           pcmBuffer[i +  5] =                 m0 +                 m1 >>  1;
  2420:           pcmBuffer[i +  7] = 65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16;
  2421:           pcmBuffer[i +  9] = 65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16;
  2422:           pcmBuffer[i + 11] =                                      m1;
  2423:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2424:           p = (char) p;
  2425:           int m0 = pcmDecodedData1;
  2426:           pcmBuffer[i +  1] = (65536 * 5 / 6 * m0 + 65536 * 1 / 6 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  2427:           pcmBuffer[i +  3] = (65536 * 4 / 6 * m0 + 65536 * 2 / 6 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  2428:           pcmBuffer[i +  5] = (                m0 +                 m1 >>  1) * pcmAttackCurve[p + 2] >> 14;
  2429:           pcmBuffer[i +  7] = (65536 * 2 / 6 * m0 + 65536 * 4 / 6 * m1 >> 16) * pcmAttackCurve[p + 3] >> 14;
  2430:           pcmBuffer[i +  9] = (65536 * 1 / 6 * m0 + 65536 * 5 / 6 * m1 >> 16) * pcmAttackCurve[p + 4] >> 14;
  2431:           pcmBuffer[i + 11] = (                                     m1      ) * pcmAttackCurve[p + 5] >> 14;
  2432:           p += 6;
  2433:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2434:         } else {  //OFF
  2435:           pcmBuffer[  i +  1] = (
  2436:             pcmBuffer[i +  3] =
  2437:             pcmBuffer[i +  5] =
  2438:             pcmBuffer[i +  7] =
  2439:             pcmBuffer[i +  9] =
  2440:             pcmBuffer[i + 11] = 0);
  2441:         }
  2442:         pcmDecodedData1 = m1;
  2443:         pcmPointer = i + 12;
  2444:         if (Profiling.PFF_ON) {
  2445:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2446:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2447:         }
  2448:       }
  2449:     },  //PIP_STEREO_LINEAR_6
  2450: 
  2451:     //ステレオ 線形補間 15625.00Hz
  2452:     PIP_STEREO_LINEAR_4 {
  2453:       @Override public void write (int m1) {
  2454:         if (Profiling.PFF_ON) {
  2455:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2456:         }
  2457:         int i = pcmPointer;
  2458:         int p = pcmPanLeft;
  2459:         if (p > 0) {  //ON
  2460:           int m0 = pcmDecodedData1;
  2461:           pcmBuffer[i    ] = 3 * m0 +     m1 >> 2;
  2462:           pcmBuffer[i + 2] =     m0 +     m1 >> 1;
  2463:           pcmBuffer[i + 4] =     m0 + 3 * m1 >> 2;
  2464:           pcmBuffer[i + 6] =              m1;
  2465:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2466:           p = (char) p;
  2467:           int m0 = pcmDecodedData1;
  2468:           pcmBuffer[i    ] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p    ] >> 14;
  2469:           pcmBuffer[i + 2] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 1] >> 14;
  2470:           pcmBuffer[i + 4] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 2] >> 14;
  2471:           pcmBuffer[i + 6] = (             m1     ) * pcmAttackCurve[p + 3] >> 14;
  2472:           p += 4;
  2473:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2474:         } else {  //OFF
  2475:           pcmBuffer[  i    ] = (
  2476:             pcmBuffer[i + 2] =
  2477:             pcmBuffer[i + 4] =
  2478:             pcmBuffer[i + 6] = 0);
  2479:         }
  2480:         p = pcmPanRight;
  2481:         if (p > 0) {  //ON
  2482:           int m0 = pcmDecodedData1;
  2483:           pcmBuffer[i + 1] = 3 * m0 +     m1 >> 2;
  2484:           pcmBuffer[i + 3] =     m0 +     m1 >> 1;
  2485:           pcmBuffer[i + 5] =     m0 + 3 * m1 >> 2;
  2486:           pcmBuffer[i + 7] =              m1;
  2487:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2488:           p = (char) p;
  2489:           int m0 = pcmDecodedData1;
  2490:           pcmBuffer[i + 1] = (3 * m0 +     m1 >> 2) * pcmAttackCurve[p    ] >> 14;
  2491:           pcmBuffer[i + 3] = (    m0 +     m1 >> 1) * pcmAttackCurve[p + 1] >> 14;
  2492:           pcmBuffer[i + 5] = (    m0 + 3 * m1 >> 2) * pcmAttackCurve[p + 2] >> 14;
  2493:           pcmBuffer[i + 7] = (             m1     ) * pcmAttackCurve[p + 3] >> 14;
  2494:           p += 4;
  2495:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2496:         } else {  //OFF
  2497:           pcmBuffer[  i + 1] = (
  2498:             pcmBuffer[i + 3] =
  2499:             pcmBuffer[i + 5] =
  2500:             pcmBuffer[i + 7] = 0);
  2501:         }
  2502:         pcmDecodedData1 = m1;
  2503:         pcmPointer = i + 8;
  2504:         if (Profiling.PFF_ON) {
  2505:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2506:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2507:         }
  2508:       }
  2509:     },  //PIP_STEREO_LINEAR_4
  2510: 
  2511:     //ステレオ 線形補間 20833.33Hz
  2512:     PIP_STEREO_LINEAR_3 {
  2513:       @Override public void write (int m1) {
  2514:         if (Profiling.PFF_ON) {
  2515:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2516:         }
  2517:         int i = pcmPointer;
  2518:         int p = pcmPanLeft;
  2519:         if (p > 0) {  //ON
  2520:           int m0 = pcmDecodedData1;
  2521:           pcmBuffer[i    ] = 65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16;
  2522:           pcmBuffer[i + 2] = 65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16;
  2523:           pcmBuffer[i + 4] =                                      m1;
  2524:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2525:           p = (char) p;
  2526:           int m0 = pcmDecodedData1;
  2527:           pcmBuffer[i    ] = (65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  2528:           pcmBuffer[i + 2] = (65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  2529:           pcmBuffer[i + 4] = (                                     m1      ) * pcmAttackCurve[p + 2] >> 14;
  2530:           p += 3;
  2531:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2532:         } else {  //OFF
  2533:           pcmBuffer[  i    ] = (
  2534:             pcmBuffer[i + 2] =
  2535:             pcmBuffer[i + 4] = 0);
  2536:         }
  2537:         p = pcmPanRight;
  2538:         if (p > 0) {  //ON
  2539:           int m0 = pcmDecodedData1;
  2540:           pcmBuffer[i + 1] = 65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16;
  2541:           pcmBuffer[i + 3] = 65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16;
  2542:           pcmBuffer[i + 5] =                                      m1;
  2543:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2544:           p = (char) p;
  2545:           int m0 = pcmDecodedData1;
  2546:           pcmBuffer[i + 1] = (65536 * 2 / 3 * m0 + 65536 * 1 / 3 * m1 >> 16) * pcmAttackCurve[p    ] >> 14;
  2547:           pcmBuffer[i + 3] = (65536 * 1 / 3 * m0 + 65536 * 2 / 3 * m1 >> 16) * pcmAttackCurve[p + 1] >> 14;
  2548:           pcmBuffer[i + 5] = (                                     m1      ) * pcmAttackCurve[p + 2] >> 14;
  2549:           p += 3;
  2550:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2551:         } else {  //OFF
  2552:           pcmBuffer[  i + 1] = (
  2553:             pcmBuffer[i + 3] =
  2554:             pcmBuffer[i + 5] = 0);
  2555:         }
  2556:         pcmDecodedData1 = m1;
  2557:         pcmPointer = i + 6;
  2558:         if (Profiling.PFF_ON) {
  2559:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2560:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2561:         }
  2562:       }
  2563:     },  //PIP_STEREO_LINEAR_3
  2564: 
  2565:     //ステレオ 線形補間 31250.00Hz
  2566:     PIP_STEREO_LINEAR_2 {
  2567:       @Override public void write (int m1) {
  2568:         if (Profiling.PFF_ON) {
  2569:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2570:         }
  2571:         int i = pcmPointer;
  2572:         int p = pcmPanLeft;
  2573:         if (p > 0) {  //ON
  2574:           int m0 = pcmDecodedData1;
  2575:           pcmBuffer[i    ] = m0 + m1 >> 1;
  2576:           pcmBuffer[i + 2] =      m1;
  2577:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2578:           p = (char) p;
  2579:           int m0 = pcmDecodedData1;
  2580:           pcmBuffer[i    ] = (m0 + m1 >> 1) * pcmAttackCurve[p    ] >> 14;
  2581:           pcmBuffer[i + 2] = (     m1     ) * pcmAttackCurve[p + 1] >> 14;
  2582:           p += 2;
  2583:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2584:         } else {  //OFF
  2585:           pcmBuffer[  i    ] = (
  2586:             pcmBuffer[i + 2] = 0);
  2587:         }
  2588:         p = pcmPanRight;
  2589:         if (p > 0) {  //ON
  2590:           int m0 = pcmDecodedData1;
  2591:           pcmBuffer[i + 1] = m0 + m1 >> 1;
  2592:           pcmBuffer[i + 3] =      m1;
  2593:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2594:           p = (char) p;
  2595:           int m0 = pcmDecodedData1;
  2596:           pcmBuffer[i + 1] = (m0 + m1 >> 1) * pcmAttackCurve[p    ] >> 14;
  2597:           pcmBuffer[i + 3] = (     m1     ) * pcmAttackCurve[p + 1] >> 14;
  2598:           p += 2;
  2599:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2600:         } else {  //OFF
  2601:           pcmBuffer[  i + 1] = (
  2602:             pcmBuffer[i + 3] = 0);
  2603:         }
  2604:         pcmDecodedData1 = m1;
  2605:         pcmPointer = i + 4;
  2606:         if (Profiling.PFF_ON) {
  2607:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2608:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2609:         }
  2610:       }
  2611:     },  //PIP_STEREO_LINEAR_2
  2612: 
  2613:     //ステレオ エルミート補間 3906.25Hz
  2614:     PIP_STEREO_HERMITE_16 {
  2615:       @Override public void write (int m2) {
  2616:         if (Profiling.PFF_ON) {
  2617:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2618:         }
  2619:         //  echo read("hermite.gp");hermite_code(2,16) | gp-2.7 -q
  2620:         int i = pcmPointer;
  2621:         int mm = pcmDecodedData3;
  2622:         int m0 = pcmDecodedData2;
  2623:         int m1 = pcmDecodedData1;
  2624:         int p = pcmPanLeft;
  2625:         if (p > 0) {  //ON
  2626:           pcmBuffer[i     ] =          -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13;
  2627:           pcmBuffer[i +  2] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  2628:           pcmBuffer[i +  4] =          -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13;
  2629:           pcmBuffer[i +  6] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2630:           pcmBuffer[i +  8] =          -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13;
  2631:           pcmBuffer[i + 10] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  2632:           pcmBuffer[i + 12] =          -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13;
  2633:           pcmBuffer[i + 14] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2634:           pcmBuffer[i + 16] =          -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13;
  2635:           pcmBuffer[i + 18] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  2636:           pcmBuffer[i + 20] =          -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13;
  2637:           pcmBuffer[i + 22] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2638:           pcmBuffer[i + 24] =          -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13;
  2639:           pcmBuffer[i + 26] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  2640:           pcmBuffer[i + 28] =           -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13;
  2641:           pcmBuffer[i + 30] =                                         m1;
  2642:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2643:           p = (char) p;
  2644:           pcmBuffer[i     ] = (         -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13) * pcmAttackCurve[p     ] >> 14;
  2645:           pcmBuffer[i +  2] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p +  1] >> 14;
  2646:           pcmBuffer[i +  4] = (         -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13) * pcmAttackCurve[p +  2] >> 14;
  2647:           pcmBuffer[i +  6] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p +  3] >> 14;
  2648:           pcmBuffer[i +  8] = (         -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13) * pcmAttackCurve[p +  4] >> 14;
  2649:           pcmBuffer[i + 10] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p +  5] >> 14;
  2650:           pcmBuffer[i + 12] = (         -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13) * pcmAttackCurve[p +  6] >> 14;
  2651:           pcmBuffer[i + 14] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p +  7] >> 14;
  2652:           pcmBuffer[i + 16] = (         -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13) * pcmAttackCurve[p +  8] >> 14;
  2653:           pcmBuffer[i + 18] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p +  9] >> 14;
  2654:           pcmBuffer[i + 20] = (         -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13) * pcmAttackCurve[p + 10] >> 14;
  2655:           pcmBuffer[i + 22] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 11] >> 14;
  2656:           pcmBuffer[i + 24] = (         -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13) * pcmAttackCurve[p + 12] >> 14;
  2657:           pcmBuffer[i + 26] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 13] >> 14;
  2658:           pcmBuffer[i + 28] = (          -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13) * pcmAttackCurve[p + 14] >> 14;
  2659:           pcmBuffer[i + 30] = (                                        m1                  ) * pcmAttackCurve[p + 15] >> 14;
  2660:           p += 16;
  2661:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2662:         } else {  //OFF
  2663:           pcmBuffer[  i     ] = (
  2664:             pcmBuffer[i +  2] =
  2665:             pcmBuffer[i +  4] =
  2666:             pcmBuffer[i +  6] =
  2667:             pcmBuffer[i +  8] =
  2668:             pcmBuffer[i + 10] =
  2669:             pcmBuffer[i + 12] =
  2670:             pcmBuffer[i + 14] =
  2671:             pcmBuffer[i + 16] =
  2672:             pcmBuffer[i + 18] =
  2673:             pcmBuffer[i + 20] =
  2674:             pcmBuffer[i + 22] =
  2675:             pcmBuffer[i + 24] =
  2676:             pcmBuffer[i + 26] =
  2677:             pcmBuffer[i + 28] =
  2678:             pcmBuffer[i + 30] = 0);
  2679:         }
  2680:         p = pcmPanRight;
  2681:         if (p > 0) {  //ON
  2682:           pcmBuffer[i +  1] =          -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13;
  2683:           pcmBuffer[i +  3] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  2684:           pcmBuffer[i +  5] =          -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13;
  2685:           pcmBuffer[i +  7] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2686:           pcmBuffer[i +  9] =          -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13;
  2687:           pcmBuffer[i + 11] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  2688:           pcmBuffer[i + 13] =          -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13;
  2689:           pcmBuffer[i + 15] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2690:           pcmBuffer[i + 17] =          -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13;
  2691:           pcmBuffer[i + 19] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  2692:           pcmBuffer[i + 21] =          -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13;
  2693:           pcmBuffer[i + 23] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2694:           pcmBuffer[i + 25] =          -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13;
  2695:           pcmBuffer[i + 27] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  2696:           pcmBuffer[i + 29] =           -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13;
  2697:           pcmBuffer[i + 31] =                                         m1;
  2698:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2699:           p = (char) p;
  2700:           pcmBuffer[i +  1] = (         -225 * mm + 8115 * m0 +  317 * m1 -   15 * m2 >> 13) * pcmAttackCurve[p     ] >> 14;
  2701:           pcmBuffer[i +  3] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p +  1] >> 14;
  2702:           pcmBuffer[i +  5] = (         -507 * mm + 7553 * m0 + 1263 * m1 -  117 * m2 >> 13) * pcmAttackCurve[p +  2] >> 14;
  2703:           pcmBuffer[i +  7] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p +  3] >> 14;
  2704:           pcmBuffer[i +  9] = (         -605 * mm + 6567 * m0 + 2505 * m1 -  275 * m2 >> 13) * pcmAttackCurve[p +  4] >> 14;
  2705:           pcmBuffer[i + 11] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p +  5] >> 14;
  2706:           pcmBuffer[i + 13] = (         -567 * mm + 5301 * m0 + 3899 * m1 -  441 * m2 >> 13) * pcmAttackCurve[p +  6] >> 14;
  2707:           pcmBuffer[i + 15] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p +  7] >> 14;
  2708:           pcmBuffer[i + 17] = (         -441 * mm + 3899 * m0 + 5301 * m1 -  567 * m2 >> 13) * pcmAttackCurve[p +  8] >> 14;
  2709:           pcmBuffer[i + 19] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p +  9] >> 14;
  2710:           pcmBuffer[i + 21] = (         -275 * mm + 2505 * m0 + 6567 * m1 -  605 * m2 >> 13) * pcmAttackCurve[p + 10] >> 14;
  2711:           pcmBuffer[i + 23] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 11] >> 14;
  2712:           pcmBuffer[i + 25] = (         -117 * mm + 1263 * m0 + 7553 * m1 -  507 * m2 >> 13) * pcmAttackCurve[p + 12] >> 14;
  2713:           pcmBuffer[i + 27] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 13] >> 14;
  2714:           pcmBuffer[i + 29] = (          -15 * mm +  317 * m0 + 8115 * m1 -  225 * m2 >> 13) * pcmAttackCurve[p + 14] >> 14;
  2715:           pcmBuffer[i + 31] = (                                        m1                  ) * pcmAttackCurve[p + 15] >> 14;
  2716:           p += 16;
  2717:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2718:         } else {  //OFF
  2719:           pcmBuffer[  i +  1] = (
  2720:             pcmBuffer[i +  3] =
  2721:             pcmBuffer[i +  5] =
  2722:             pcmBuffer[i +  7] =
  2723:             pcmBuffer[i +  9] =
  2724:             pcmBuffer[i + 11] =
  2725:             pcmBuffer[i + 13] =
  2726:             pcmBuffer[i + 15] =
  2727:             pcmBuffer[i + 17] =
  2728:             pcmBuffer[i + 19] =
  2729:             pcmBuffer[i + 21] =
  2730:             pcmBuffer[i + 23] =
  2731:             pcmBuffer[i + 25] =
  2732:             pcmBuffer[i + 27] =
  2733:             pcmBuffer[i + 29] =
  2734:             pcmBuffer[i + 31] = 0);
  2735:         }
  2736:         pcmDecodedData3 = m0;
  2737:         pcmDecodedData2 = m1;
  2738:         pcmDecodedData1 = m2;
  2739:         pcmPointer = i + 32;
  2740:         if (Profiling.PFF_ON) {
  2741:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2742:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2743:         }
  2744:       }
  2745:     },  //PIP_STEREO_HERMITE_16
  2746: 
  2747:     //ステレオ エルミート補間 5208.33Hz
  2748:     PIP_STEREO_HERMITE_12 {
  2749:       @Override public void write (int m2) {
  2750:         if (Profiling.PFF_ON) {
  2751:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2752:         }
  2753:         //  echo read("hermite.gp");hermite_code(2,12) | gp-2.7 -q
  2754:         int i = pcmPointer;
  2755:         int mm = pcmDecodedData3;
  2756:         int m0 = pcmDecodedData2;
  2757:         int m1 = pcmDecodedData1;
  2758:         int p = pcmPanLeft;
  2759:         if (p > 0) {  //ON
  2760:           pcmBuffer[i     ] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32);
  2761:           pcmBuffer[i +  2] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  2762:           pcmBuffer[i +  4] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2763:           pcmBuffer[i +  6] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  2764:           pcmBuffer[i +  8] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32);
  2765:           pcmBuffer[i + 10] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2766:           pcmBuffer[i + 12] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32);
  2767:           pcmBuffer[i + 14] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  2768:           pcmBuffer[i + 16] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2769:           pcmBuffer[i + 18] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  2770:           pcmBuffer[i + 20] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32);
  2771:           pcmBuffer[i + 22] =                                         m1;
  2772:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2773:           p = (char) p;
  2774:           pcmBuffer[i     ] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32) * pcmAttackCurve[p     ] >> 14;
  2775:           pcmBuffer[i +  2] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  1] >> 14;
  2776:           pcmBuffer[i +  4] =       (    -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7               ) * pcmAttackCurve[p +  2] >> 14;
  2777:           pcmBuffer[i +  6] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p +  3] >> 14;
  2778:           pcmBuffer[i +  8] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  4] >> 14;
  2779:           pcmBuffer[i + 10] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p +  5] >> 14;
  2780:           pcmBuffer[i + 12] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  6] >> 14;
  2781:           pcmBuffer[i + 14] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p +  7] >> 14;
  2782:           pcmBuffer[i + 16] =       (    -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7               ) * pcmAttackCurve[p +  8] >> 14;
  2783:           pcmBuffer[i + 18] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  9] >> 14;
  2784:           pcmBuffer[i + 20] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32) * pcmAttackCurve[p + 10] >> 14;
  2785:           pcmBuffer[i + 22] =       (                                 m1                                 ) * pcmAttackCurve[p + 11] >> 14;
  2786:           p += 12;
  2787:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2788:         } else {  //OFF
  2789:           pcmBuffer[  i     ] = (
  2790:             pcmBuffer[i +  2] =
  2791:             pcmBuffer[i +  4] =
  2792:             pcmBuffer[i +  6] =
  2793:             pcmBuffer[i +  8] =
  2794:             pcmBuffer[i + 10] =
  2795:             pcmBuffer[i + 12] =
  2796:             pcmBuffer[i + 14] =
  2797:             pcmBuffer[i + 16] =
  2798:             pcmBuffer[i + 18] =
  2799:             pcmBuffer[i + 20] =
  2800:             pcmBuffer[i + 22] = 0);
  2801:         }
  2802:         p = pcmPanRight;
  2803:         if (p > 0) {  //ON
  2804:           pcmBuffer[i +  1] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32);
  2805:           pcmBuffer[i +  3] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  2806:           pcmBuffer[i +  5] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2807:           pcmBuffer[i +  7] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  2808:           pcmBuffer[i +  9] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32);
  2809:           pcmBuffer[i + 11] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2810:           pcmBuffer[i + 13] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32);
  2811:           pcmBuffer[i + 15] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  2812:           pcmBuffer[i + 17] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2813:           pcmBuffer[i + 19] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  2814:           pcmBuffer[i + 21] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32);
  2815:           pcmBuffer[i + 23] =                                         m1;
  2816:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2817:           p = (char) p;
  2818:           pcmBuffer[i +  1] = (int) (( -121 * mm + 3399 * m0 +  189 * m1 -   11 * m2) *    1242757L >> 32) * pcmAttackCurve[p     ] >> 14;
  2819:           pcmBuffer[i +  3] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  1] >> 14;
  2820:           pcmBuffer[i +  5] =       (    -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7               ) * pcmAttackCurve[p +  2] >> 14;
  2821:           pcmBuffer[i +  7] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p +  3] >> 14;
  2822:           pcmBuffer[i +  9] = (int) (( -245 * mm + 2331 * m0 + 1545 * m1 -  175 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  4] >> 14;
  2823:           pcmBuffer[i + 11] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p +  5] >> 14;
  2824:           pcmBuffer[i + 13] = (int) (( -175 * mm + 1545 * m0 + 2331 * m1 -  245 * m2) *    1242757L >> 32) * pcmAttackCurve[p +  6] >> 14;
  2825:           pcmBuffer[i + 15] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p +  7] >> 14;
  2826:           pcmBuffer[i + 17] =       (    -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7               ) * pcmAttackCurve[p +  8] >> 14;
  2827:           pcmBuffer[i + 19] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p +  9] >> 14;
  2828:           pcmBuffer[i + 21] = (int) ((  -11 * mm +  189 * m0 + 3399 * m1 -  121 * m2) *    1242757L >> 32) * pcmAttackCurve[p + 10] >> 14;
  2829:           pcmBuffer[i + 23] =       (                                 m1                                 ) * pcmAttackCurve[p + 11] >> 14;
  2830:           p += 12;
  2831:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2832:         } else {  //OFF
  2833:           pcmBuffer[  i +  1] = (
  2834:             pcmBuffer[i +  3] =
  2835:             pcmBuffer[i +  5] =
  2836:             pcmBuffer[i +  7] =
  2837:             pcmBuffer[i +  9] =
  2838:             pcmBuffer[i + 11] =
  2839:             pcmBuffer[i + 13] =
  2840:             pcmBuffer[i + 15] =
  2841:             pcmBuffer[i + 17] =
  2842:             pcmBuffer[i + 19] =
  2843:             pcmBuffer[i + 21] =
  2844:             pcmBuffer[i + 23] = 0);
  2845:         }
  2846:         pcmDecodedData3 = m0;
  2847:         pcmDecodedData2 = m1;
  2848:         pcmDecodedData1 = m2;
  2849:         pcmPointer = i + 24;
  2850:         if (Profiling.PFF_ON) {
  2851:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2852:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2853:         }
  2854:       }
  2855:     },  //PIP_STEREO_HERMITE_12
  2856: 
  2857:     //ステレオ エルミート補間 7812.50Hz
  2858:     PIP_STEREO_HERMITE_8 {
  2859:       @Override public void write (int m2) {
  2860:         if (Profiling.PFF_ON) {
  2861:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2862:         }
  2863:         //  echo read("hermite.gp");hermite_code(2,8) | gp-2.7 -q
  2864:         int i = pcmPointer;
  2865:         int mm = pcmDecodedData3;
  2866:         int m0 = pcmDecodedData2;
  2867:         int m1 = pcmDecodedData1;
  2868:         int p = pcmPanLeft;
  2869:         if (p > 0) {  //ON
  2870:           pcmBuffer[i     ] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  2871:           pcmBuffer[i +  2] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2872:           pcmBuffer[i +  4] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  2873:           pcmBuffer[i +  6] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2874:           pcmBuffer[i +  8] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  2875:           pcmBuffer[i + 10] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2876:           pcmBuffer[i + 12] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  2877:           pcmBuffer[i + 14] =                                         m1;
  2878:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2879:           p = (char) p;
  2880:           pcmBuffer[i     ] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p    ] >> 14;
  2881:           pcmBuffer[i +  2] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p + 1] >> 14;
  2882:           pcmBuffer[i +  4] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p + 2] >> 14;
  2883:           pcmBuffer[i +  6] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 3] >> 14;
  2884:           pcmBuffer[i +  8] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p + 4] >> 14;
  2885:           pcmBuffer[i + 10] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 5] >> 14;
  2886:           pcmBuffer[i + 12] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 6] >> 14;
  2887:           pcmBuffer[i + 14] = (                                        m1                  ) * pcmAttackCurve[p + 7] >> 14;
  2888:           p += 8;
  2889:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2890:         } else {  //OFF
  2891:           pcmBuffer[  i     ] = (
  2892:             pcmBuffer[i +  2] =
  2893:             pcmBuffer[i +  4] =
  2894:             pcmBuffer[i +  6] =
  2895:             pcmBuffer[i +  8] =
  2896:             pcmBuffer[i + 10] =
  2897:             pcmBuffer[i + 12] =
  2898:             pcmBuffer[i + 14] = 0);
  2899:         }
  2900:         p = pcmPanRight;
  2901:         if (p > 0) {  //ON
  2902:           pcmBuffer[i +  1] =           -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10;
  2903:           pcmBuffer[i +  3] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  2904:           pcmBuffer[i +  5] =           -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10;
  2905:           pcmBuffer[i +  7] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2906:           pcmBuffer[i +  9] =           -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10;
  2907:           pcmBuffer[i + 11] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  2908:           pcmBuffer[i + 13] =            -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10;
  2909:           pcmBuffer[i + 15] =                                         m1;
  2910:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2911:           p = (char) p;
  2912:           pcmBuffer[i +  1] = (          -49 * mm +  987 * m0 +   93 * m1 -    7 * m2 >> 10) * pcmAttackCurve[p    ] >> 14;
  2913:           pcmBuffer[i +  3] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p + 1] >> 14;
  2914:           pcmBuffer[i +  5] = (          -75 * mm +  745 * m0 +  399 * m1 -   45 * m2 >> 10) * pcmAttackCurve[p + 2] >> 14;
  2915:           pcmBuffer[i +  7] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 3] >> 14;
  2916:           pcmBuffer[i +  9] = (          -45 * mm +  399 * m0 +  745 * m1 -   75 * m2 >> 10) * pcmAttackCurve[p + 4] >> 14;
  2917:           pcmBuffer[i + 11] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 5] >> 14;
  2918:           pcmBuffer[i + 13] = (           -7 * mm +   93 * m0 +  987 * m1 -   49 * m2 >> 10) * pcmAttackCurve[p + 6] >> 14;
  2919:           pcmBuffer[i + 15] = (                                        m1                  ) * pcmAttackCurve[p + 7] >> 14;
  2920:           p += 8;
  2921:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2922:         } else {  //OFF
  2923:           pcmBuffer[  i +  1] = (
  2924:             pcmBuffer[i +  3] =
  2925:             pcmBuffer[i +  5] =
  2926:             pcmBuffer[i +  7] =
  2927:             pcmBuffer[i +  9] =
  2928:             pcmBuffer[i + 11] =
  2929:             pcmBuffer[i + 13] =
  2930:             pcmBuffer[i + 15] = 0);
  2931:         }
  2932:         pcmDecodedData3 = m0;
  2933:         pcmDecodedData2 = m1;
  2934:         pcmDecodedData1 = m2;
  2935:         pcmPointer = i + 16;
  2936:         if (Profiling.PFF_ON) {
  2937:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  2938:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  2939:         }
  2940:       }
  2941:     },  //PIP_STEREO_HERMITE_8
  2942: 
  2943:     //ステレオ エルミート補間 10416.67Hz
  2944:     PIP_STEREO_HERMITE_6 {
  2945:       @Override public void write (int m2) {
  2946:         if (Profiling.PFF_ON) {
  2947:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  2948:         }
  2949:         //  echo read("hermite.gp");hermite_code(2,6) | gp-2.7 -q
  2950:         int i = pcmPointer;
  2951:         int mm = pcmDecodedData3;
  2952:         int m0 = pcmDecodedData2;
  2953:         int m1 = pcmDecodedData1;
  2954:         int p = pcmPanLeft;
  2955:         if (p > 0) {  //ON
  2956:           pcmBuffer[i     ] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  2957:           pcmBuffer[i +  2] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  2958:           pcmBuffer[i +  4] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2959:           pcmBuffer[i +  6] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  2960:           pcmBuffer[i +  8] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  2961:           pcmBuffer[i + 10] =                                         m1;
  2962:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2963:           p = (char) p;
  2964:           pcmBuffer[i     ] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p    ] >> 14;
  2965:           pcmBuffer[i +  2] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  2966:           pcmBuffer[i +  4] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p + 2] >> 14;
  2967:           pcmBuffer[i +  6] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 3] >> 14;
  2968:           pcmBuffer[i +  8] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p + 4] >> 14;
  2969:           pcmBuffer[i + 10] =       (                                 m1                                 ) * pcmAttackCurve[p + 5] >> 14;
  2970:           p += 6;
  2971:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2972:         } else {  //OFF
  2973:           pcmBuffer[  i     ] = (
  2974:             pcmBuffer[i +  2] =
  2975:             pcmBuffer[i +  4] =
  2976:             pcmBuffer[i +  6] =
  2977:             pcmBuffer[i +  8] =
  2978:             pcmBuffer[i + 10] = 0);
  2979:         }
  2980:         p = pcmPanRight;
  2981:         if (p > 0) {  //ON
  2982:           pcmBuffer[i +  1] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32);
  2983:           pcmBuffer[i +  3] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  2984:           pcmBuffer[i +  5] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  2985:           pcmBuffer[i +  7] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  2986:           pcmBuffer[i +  9] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32);
  2987:           pcmBuffer[i + 11] =                                         m1;
  2988:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  2989:           p = (char) p;
  2990:           pcmBuffer[i +  1] = (int) ((  -25 * mm +  405 * m0 +   57 * m1 -    5 * m2) *    9942054L >> 32) * pcmAttackCurve[p    ] >> 14;
  2991:           pcmBuffer[i +  3] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  2992:           pcmBuffer[i +  5] =       (        -mm +    9 *      (m0 + m1) -        m2 >>  4               ) * pcmAttackCurve[p + 2] >> 14;
  2993:           pcmBuffer[i +  7] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 3] >> 14;
  2994:           pcmBuffer[i +  9] = (int) ((   -5 * mm +   57 * m0 +  405 * m1 -   25 * m2) *    9942054L >> 32) * pcmAttackCurve[p + 4] >> 14;
  2995:           pcmBuffer[i + 11] =       (                                 m1                                 ) * pcmAttackCurve[p + 5] >> 14;
  2996:           p += 6;
  2997:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  2998:         } else {  //OFF
  2999:           pcmBuffer[  i +  1] = (
  3000:             pcmBuffer[i +  3] =
  3001:             pcmBuffer[i +  5] =
  3002:             pcmBuffer[i +  7] =
  3003:             pcmBuffer[i +  9] =
  3004:             pcmBuffer[i + 11] = 0);
  3005:         }
  3006:         pcmDecodedData3 = m0;
  3007:         pcmDecodedData2 = m1;
  3008:         pcmDecodedData1 = m2;
  3009:         pcmPointer = i + 6;
  3010:         if (Profiling.PFF_ON) {
  3011:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  3012:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  3013:         }
  3014:       }
  3015:     },  //PIP_STEREO_HERMITE_6
  3016: 
  3017:     //ステレオ エルミート補間 15625.00Hz
  3018:     PIP_STEREO_HERMITE_4 {
  3019:       @Override public void write (int m2) {
  3020:         if (Profiling.PFF_ON) {
  3021:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  3022:         }
  3023:         //  echo read("hermite.gp");hermite_code(2,4) | gp-2.7 -q
  3024:         int i = pcmPointer;
  3025:         int mm = pcmDecodedData3;
  3026:         int m0 = pcmDecodedData2;
  3027:         int m1 = pcmDecodedData1;
  3028:         int p = pcmPanLeft;
  3029:         if (p > 0) {  //ON
  3030:           pcmBuffer[i    ] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  3031:           pcmBuffer[i + 2] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  3032:           pcmBuffer[i + 4] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  3033:           pcmBuffer[i + 6] =                                         m1;
  3034:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  3035:           p = (char) p;
  3036:           pcmBuffer[i    ] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p    ] >> 14;
  3037:           pcmBuffer[i + 2] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 1] >> 14;
  3038:           pcmBuffer[i + 4] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 2] >> 14;
  3039:           pcmBuffer[i + 6] = (                                        m1                  ) * pcmAttackCurve[p + 3] >> 14;
  3040:           p += 4;
  3041:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  3042:         } else {  //OFF
  3043:           pcmBuffer[  i    ] = (
  3044:             pcmBuffer[i + 2] =
  3045:             pcmBuffer[i + 4] =
  3046:             pcmBuffer[i + 6] = 0);
  3047:         }
  3048:         p = pcmPanRight;
  3049:         if (p > 0) {  //ON
  3050:           pcmBuffer[i + 1] =            -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7;
  3051:           pcmBuffer[i + 3] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  3052:           pcmBuffer[i + 5] =            -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7;
  3053:           pcmBuffer[i + 7] =                                         m1;
  3054:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  3055:           p = (char) p;
  3056:           pcmBuffer[i + 1] = (           -9 * mm +  111 * m0 +   29 * m1 -    3 * m2 >>  7) * pcmAttackCurve[p    ] >> 14;
  3057:           pcmBuffer[i + 3] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p + 1] >> 14;
  3058:           pcmBuffer[i + 5] = (           -3 * mm +   29 * m0 +  111 * m1 -    9 * m2 >>  7) * pcmAttackCurve[p + 2] >> 14;
  3059:           pcmBuffer[i + 7] = (                                        m1                  ) * pcmAttackCurve[p + 3] >> 14;
  3060:           p += 4;
  3061:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  3062:         } else {  //OFF
  3063:           pcmBuffer[  i + 1] = (
  3064:             pcmBuffer[i + 3] =
  3065:             pcmBuffer[i + 5] =
  3066:             pcmBuffer[i + 7] = 0);
  3067:         }
  3068:         pcmDecodedData3 = m0;
  3069:         pcmDecodedData2 = m1;
  3070:         pcmDecodedData1 = m2;
  3071:         pcmPointer = i + 8;
  3072:         if (Profiling.PFF_ON) {
  3073:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  3074:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  3075:         }
  3076:       }
  3077:     },  //PIP_STEREO_HERMITE_4
  3078: 
  3079:     //ステレオ エルミート補間 20833.33Hz
  3080:     PIP_STEREO_HERMITE_3 {
  3081:       @Override public void write (int m2) {
  3082:         if (Profiling.PFF_ON) {
  3083:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  3084:         }
  3085:         //  echo read("hermite.gp");hermite_code(2,3) | gp-2.7 -q
  3086:         int i = pcmPointer;
  3087:         int mm = pcmDecodedData3;
  3088:         int m0 = pcmDecodedData2;
  3089:         int m1 = pcmDecodedData1;
  3090:         int p = pcmPanLeft;
  3091:         if (p > 0) {  //ON
  3092:           pcmBuffer[i    ] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  3093:           pcmBuffer[i + 2] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  3094:           pcmBuffer[i + 4] =                                         m1;
  3095:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  3096:           p = (char) p;
  3097:           pcmBuffer[i    ] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p    ] >> 14;
  3098:           pcmBuffer[i + 2] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  3099:           pcmBuffer[i + 4] =       (                                 m1                                 ) * pcmAttackCurve[p + 2] >> 14;
  3100:           p += 3;
  3101:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  3102:         } else {  //OFF
  3103:           pcmBuffer[  i    ] = (
  3104:             pcmBuffer[i + 2] =
  3105:             pcmBuffer[i + 4] = 0);
  3106:         }
  3107:         p = pcmPanRight;
  3108:         if (p > 0) {  //ON
  3109:           pcmBuffer[i + 1] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32);
  3110:           pcmBuffer[i + 3] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32);
  3111:           pcmBuffer[i + 5] =                                         m1;
  3112:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  3113:           p = (char) p;
  3114:           pcmBuffer[i + 1] = (int) ((   -2 * mm +   21 * m0 +    9 * m1 -        m2) *  159072863L >> 32) * pcmAttackCurve[p    ] >> 14;
  3115:           pcmBuffer[i + 3] = (int) ((       -mm +    9 * m0 +   21 * m1 -    2 * m2) *  159072863L >> 32) * pcmAttackCurve[p + 1] >> 14;
  3116:           pcmBuffer[i + 5] =       (                                 m1                                 ) * pcmAttackCurve[p + 2] >> 14;
  3117:           p += 3;
  3118:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  3119:         } else {  //OFF
  3120:           pcmBuffer[  i + 1] = (
  3121:             pcmBuffer[i + 3] =
  3122:             pcmBuffer[i + 5] = 0);
  3123:         }
  3124:         pcmDecodedData3 = m0;
  3125:         pcmDecodedData2 = m1;
  3126:         pcmDecodedData1 = m2;
  3127:         pcmPointer = i + 6;
  3128:         if (Profiling.PFF_ON) {
  3129:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  3130:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  3131:         }
  3132:       }
  3133:     },  //PIP_STEREO_HERMITE_3
  3134: 
  3135:     //ステレオ エルミート補間 31250.00Hz
  3136:     PIP_STEREO_HERMITE_2 {
  3137:       @Override public void write (int m2) {
  3138:         if (Profiling.PFF_ON) {
  3139:           Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()] = System.nanoTime ();
  3140:         }
  3141:         //  echo read("hermite.gp");hermite_code(2,2) | gp-2.7 -q
  3142:         int i = pcmPointer;
  3143:         int mm = pcmDecodedData3;
  3144:         int m0 = pcmDecodedData2;
  3145:         int m1 = pcmDecodedData1;
  3146:         int p = pcmPanLeft;
  3147:         if (p > 0) {  //ON
  3148:           pcmBuffer[i    ] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  3149:           pcmBuffer[i + 2] =                                         m1;
  3150:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  3151:           p = (char) p;
  3152:           pcmBuffer[i    ] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p    ] >> 14;
  3153:           pcmBuffer[i + 2] = (                                        m1                  ) * pcmAttackCurve[p + 1] >> 14;
  3154:           p += 2;
  3155:           pcmPanLeft = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  3156:         } else {  //OFF
  3157:           pcmBuffer[  i    ] = (
  3158:             pcmBuffer[i + 2] = 0);
  3159:         }
  3160:         p = pcmPanRight;
  3161:         if (p > 0) {  //ON
  3162:           pcmBuffer[i + 1] =                -mm +    9 *      (m0 + m1) -        m2 >>  4;
  3163:           pcmBuffer[i + 3] =                                         m1;
  3164:         } else if (p < 0) {  //ON→OFFまたはOFF→ON
  3165:           p = (char) p;
  3166:           pcmBuffer[i + 1] = (               -mm +    9 *      (m0 + m1) -        m2 >>  4) * pcmAttackCurve[p    ] >> 14;
  3167:           pcmBuffer[i + 3] = (                                        m1                  ) * pcmAttackCurve[p + 1] >> 14;
  3168:           p += 2;
  3169:           pcmPanRight = p << -(PCM_ATTACK_RATE + 1) >= 0 ? 0x80000000 + p : p >> PCM_ATTACK_RATE + 1;
  3170:         } else {  //OFF
  3171:           pcmBuffer[  i + 1] = (
  3172:             pcmBuffer[i + 3] = 0);
  3173:         }
  3174:         pcmDecodedData3 = m0;
  3175:         pcmDecodedData2 = m1;
  3176:         pcmDecodedData1 = m2;
  3177:         pcmPointer = i + 4;
  3178:         if (Profiling.PFF_ON) {
  3179:           Profiling.pffTotal[Profiling.PRF.pcmWriteBuffer.ordinal ()] += System.nanoTime () - Profiling.pffStart[Profiling.PRF.pcmWriteBuffer.ordinal ()];
  3180:           Profiling.pffCount[Profiling.PRF.pcmWriteBuffer.ordinal ()]++;
  3181:         }
  3182:       }
  3183:     };  //PIP_STEREO_HERMITE_2
  3184: 
  3185:     public abstract void write (int m);
  3186: 
  3187:   }  //enum PIP
  3188: 
  3189: 
  3190: 
  3191: }  //class ADPCM
  3192: 
  3193: 
  3194: