示例#1
0
文件: c352.cs 项目: BouKiCHi/MDSound
        private static void c352_ramp_volume(C352_Voice v, int ch, byte val)
        {
            short vol_delta = (short)(v.curr_vol[ch] - val);

            if (vol_delta != 0)
            {
                v.curr_vol[ch] = (byte)(v.curr_vol[ch] + ((vol_delta > 0) ? -1 : 1));
            }
            //Console.WriteLine("v.curr_vol[ch{0}] = {1} val={2}", ch, v.curr_vol[ch], val);
        }
示例#2
0
文件: c352.cs 项目: kuma4649/MDSound
        private static void c352_ramp_volume(C352_Voice v, int ch, byte val)
        {
            if ((v.flags & (int)C352_FLG.FILTER) != 0)
            {
                v.curr_vol[ch] = val;
                return;
            }

            short vol_delta = (short)(v.curr_vol[ch] - val);

            if (vol_delta != 0)
            {
                v.curr_vol[ch] = (byte)(v.curr_vol[ch] + ((vol_delta > 0) ? -1 : 1));
            }
            //Console.WriteLine("v.curr_vol[ch{0}] = {1} val={2}", ch, v.curr_vol[ch], val);
        }
示例#3
0
文件: c352.cs 项目: BouKiCHi/MDSound
        private static void C352_fetch_sample(C352 c, C352_Voice v)
        {
            //Console.WriteLine("v->sample = {0}  v->pos = {1}  c->wave_mask = {2}  v->flags ={3} ", v.sample, v.pos, c.wave_mask, v.flags);

            v.last_sample = v.sample;

            //if (v.flags & C352_FLG_NOISE)
            if ((v.flags & 0x0010) != 0)
            {
                c.random = (ushort)((c.random >> 1) ^ ((-(c.random & 1)) & 0xfff6));
                v.sample = (short)c.random;
            }
            else
            {
                sbyte  s, s2;
                ushort pos;

                s = (sbyte)c.wave[v.pos & c.wave_mask];

                v.sample = (short)(s << 8);
                //if (v.flags & C352_FLG_MULAW)
                if ((v.flags & 0x0008) != 0)
                {
                    s2 = (sbyte)((s & 0x7f) >> 4);

                    v.sample = (short)(((s2 * s2) << 4) - (~(s2 << 1)) * (s & 0x0f));
                    v.sample = (short)(((s & 0x80) != 0) ? ((~v.sample) << 5) : (v.sample << 5));
                }

                pos = (ushort)(v.pos & 0xffff);

                //if ((v.flags & C352_FLG_LOOP) && v.flags & C352_FLG_REVERSE)
                if ((v.flags & 0x0002) != 0 && (v.flags & 0x0001) != 0)
                {
                    // backwards>forwards
                    //if ((v.flags & C352_FLG_LDIR) && pos == v.wave_loop)
                    if ((v.flags & 0x0040) != 0 && pos == v.wave_loop)
                    {
                        //v.flags &= ~C352_FLG_LDIR;
                        v.flags &= 0xffbf;
                    }
                    // forwards>backwards
                    //else if (!(v.flags & C352_FLG_LDIR) && pos == v.wave_end)
                    else if ((v.flags & 0x0040) == 0 && pos == v.wave_end)
                    {
                        //v.flags |= C352_FLG_LDIR;
                        v.flags |= 0x0040;
                    }

                    //v.pos += (v.flags & C352_FLG_LDIR) ? -1 : 1;
                    v.pos = (uint)(v.pos + ((v.flags & 0x0040) != 0 ? -1 : 1));
                }
                else if (pos == v.wave_end)
                {
                    //if ((v.flags & C352_FLG_LINK) && (v.flags & C352_FLG_LOOP))
                    if ((v.flags & 0x0020) != 0 && (v.flags & 0x0002) != 0)
                    {
                        v.pos = (uint)((v.wave_start << 16) | v.wave_loop);
                        //v.flags |= C352_FLG_LOOPHIST;
                        v.flags |= 0x0800;
                    }
                    //else if (v.flags & C352_FLG_LOOP)
                    else if ((v.flags & 0x0002) != 0)
                    {
                        v.pos = (v.pos & 0xff0000) | v.wave_loop;
                        //v.flags |= C352_FLG_LOOPHIST;
                        v.flags |= 0x0800;
                    }
                    else
                    {
                        //v.flags |= C352_FLG_KEYOFF;
                        v.flags |= 0x2000;
                        //v.flags &= ~C352_FLG_BUSY;
                        v.flags &= 0x7fff;
                        v.sample = 0;
                    }
                }
                else
                {
                    //v.pos += (v.flags & C352_FLG_REVERSE) ? -1 : 1;
                    v.pos = (uint)(v.pos + ((v.flags & 0x0001) != 0 ? -1 : 1));
                }
            }
        }