예제 #1
0
        public void SetDriverOptionFromTags(List <Tuple <string, string> > tags)
        {
            if (tags == null)
            {
                return;
            }
            if (tags.Count < 1)
            {
                return;
            }

            foreach (var tag in tags)
            {
                if (tag == null)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(tag.Item1))
                {
                    continue;
                }

                if (tag.Item1.ToLower().Trim() == "carriercorrection")
                {
                    if (!string.IsNullOrEmpty(tag.Item2))
                    {
                        string val = tag.Item2.ToLower().Trim();

                        CarrierCorrection = false;
                        if (val == "yes" || val == "y" || val == "1" || val == "true" || val == "t")
                        {
                            CarrierCorrection = true;
                        }
                    }
                }
                else if (tag.Item1.ToLower().Trim() == "opmclockmode")
                {
                    if (!string.IsNullOrEmpty(tag.Item2))
                    {
                        string val = tag.Item2.ToLower().Trim();

                        OPMClockMode = enmOPMClockMode.normal;
                        if (val == "x68000" || val == "x68k" || val == "x68" || val == "x" || val == "4000000" || val == "x680x0")
                        {
                            OPMClockMode = enmOPMClockMode.X68000;
                        }
                    }
                }
            }
        }
예제 #2
0
        public MUBHeader(MmlDatum[] buf, iEncoding enc)
        {
            CarrierCorrection = false;
            OPMClockMode      = enmOPMClockMode.normal;

            this.enc = enc;

            magic = Cmn.getLE32(buf, 0x0000);

            if (magic == 0x3843554d) //'MUC8'
            {
                dataoffset    = Cmn.getLE32(buf, 0x0004);
                datasize      = Cmn.getLE32(buf, 0x0008);
                tagdata       = Cmn.getLE32(buf, 0x000c);
                tagsize       = Cmn.getLE32(buf, 0x0010);
                pcmdataPtr[0] = Cmn.getLE32(buf, 0x0014);
                pcmsize[0]    = Cmn.getLE32(buf, 0x0018);
                jumpcount     = Cmn.getLE16(buf, 0x001c);
                jumpline      = Cmn.getLE16(buf, 0x001e);
            }
            else if (magic == 0x3842554d) //'MUB8'
            {
                dataoffset    = Cmn.getLE32(buf, 0x0004);
                datasize      = Cmn.getLE32(buf, 0x0008);
                tagdata       = Cmn.getLE32(buf, 0x000c);
                tagsize       = Cmn.getLE32(buf, 0x0010);
                pcmdataPtr[0] = Cmn.getLE32(buf, 0x0014);
                pcmsize[0]    = Cmn.getLE32(buf, 0x0018);
                jumpcount     = Cmn.getLE16(buf, 0x001c);
                jumpline      = Cmn.getLE16(buf, 0x001e);

                ext_flags       = Cmn.getLE16(buf, 0x0020);
                ext_system      = (uint)buf[0x0022].dat;
                ext_target      = (uint)buf[0x0023].dat;
                ext_channel_num = Cmn.getLE16(buf, 0x0024);
                ext_fmvoice_num = Cmn.getLE16(buf, 0x0026);
                ext_player      = Cmn.getLE32(buf, 0x0028);
                pad1            = Cmn.getLE32(buf, 0x002c);
                for (int i = 0; i < 32; i++)
                {
                    ext_fmvoice[i] = (byte)buf[0x0030 + i].dat;
                }
            }
            else if (magic == 0x6250756d)
            {
                mupb                       = new MupbInfo();
                mupb.version               = Cmn.getLE32(buf, 0x0004);
                mupb.variableLengthCount   = buf[0x0008].dat;
                mupb.useChipCount          = buf[0x0009].dat;
                mupb.usePartCount          = (int)Cmn.getLE16(buf, 0x000a);
                mupb.usePageCount          = (int)Cmn.getLE16(buf, 0x000c);
                mupb.useInstrumentSetCount = (int)Cmn.getLE16(buf, 0x000e);
                mupb.usePCMSetCount        = (int)Cmn.getLE16(buf, 0x0010);
                tagdata                    = Cmn.getLE32(buf, 0x0012);
                tagsize                    = Cmn.getLE32(buf, 0x0016);
                jumpcount                  = Cmn.getLE32(buf, 0x001a);
                jumpline                   = Cmn.getLE32(buf, 0x001e);

                uint ptr = 0x0022;

                //Chip Define division.
                mupb.chips = new MupbInfo.ChipDefine[mupb.useChipCount];
                for (int i = 0; i < mupb.useChipCount; i++)
                {
                    mupb.chips[i] = new MupbInfo.ChipDefine();
                    MupbInfo.ChipDefine cd = mupb.chips[i];
                    cd.indexNumber    = Cmn.getLE16(buf, ptr); ptr += 2;
                    cd.identifyNumber = Cmn.getLE32(buf, ptr); ptr += 4;
                    cd.masterClock    = Cmn.getLE32(buf, ptr); ptr += 4;
                    cd.option         = Cmn.getLE32(buf, ptr); ptr += 4;
                    cd.heartBeat      = Cmn.getLE32(buf, ptr); ptr += 4;
                    cd.heartBeat2     = Cmn.getLE32(buf, ptr); ptr += 4;

                    cd.parts = new MupbInfo.ChipDefine.chipPart[buf[ptr].dat]; ptr++;
                    for (int j = 0; j < cd.parts.Length; j++)
                    {
                        cd.parts[j] = new MupbInfo.ChipDefine.chipPart();
                    }

                    cd.instrumentNumber = new uint[buf[ptr].dat]; ptr++;
                    for (int j = 0; j < cd.instrumentNumber.Length; j++)
                    {
                        cd.instrumentNumber[j] = Cmn.getLE16(buf, ptr); ptr += 2;
                    }

                    cd.pcmNumber = new uint[buf[ptr].dat]; ptr++;
                    for (int j = 0; j < cd.pcmNumber.Length; j++)
                    {
                        cd.pcmNumber[j] = Cmn.getLE16(buf, ptr); ptr += 2;
                    }
                }

                //Part division.
                mupb.parts = new MupbInfo.PartDefine[mupb.usePartCount];
                for (int i = 0; i < mupb.usePartCount; i++)
                {
                    mupb.parts[i] = new MupbInfo.PartDefine();
                    MupbInfo.PartDefine pd = mupb.parts[i];
                    pd.pageCount = buf[ptr].dat; ptr++;
                }

                //Page division.
                mupb.pages = new MupbInfo.PageDefine[mupb.usePageCount];
                for (int i = 0; i < mupb.usePageCount; i++)
                {
                    mupb.pages[i] = new MupbInfo.PageDefine();
                    MupbInfo.PageDefine pd = mupb.pages[i];
                    pd.length    = Cmn.getLE32(buf, ptr); ptr += 4;
                    pd.loopPoint = (int)Cmn.getLE32(buf, ptr); ptr += 4;
                }

                //Instrument set division.
                mupb.instruments = new MupbInfo.InstrumentDefine[mupb.useInstrumentSetCount];
                for (int i = 0; i < mupb.useInstrumentSetCount; i++)
                {
                    mupb.instruments[i] = new MupbInfo.InstrumentDefine();
                    MupbInfo.InstrumentDefine id = mupb.instruments[i];
                    id.length = Cmn.getLE32(buf, ptr); ptr += 4;
                }

                //PCM set division.
                mupb.pcms = new MupbInfo.PCMDefine[mupb.usePCMSetCount];
                for (int i = 0; i < mupb.usePCMSetCount; i++)
                {
                    mupb.pcms[i] = new MupbInfo.PCMDefine();
                    MupbInfo.PCMDefine pd = mupb.pcms[i];
                    pd.length = Cmn.getLE32(buf, ptr); ptr += 4;
                }

                //データ部開始位置
                mupbDataPtr = ptr;

                //Chip毎のページ情報割り当てとページデータの取り込み
                int pp = 0;
                int pr = 0;
                for (int i = 0; i < mupb.useChipCount; i++)
                {
                    MupbInfo.ChipDefine cd = mupb.chips[i];
                    for (int j = 0; j < cd.parts.Length; j++)
                    {
                        cd.parts[j].pages = new MupbInfo.PageDefine[mupb.parts[pr++].pageCount];
                        for (int k = 0; k < cd.parts[j].pages.Length; k++)
                        {
                            cd.parts[j].pages[k]      = mupb.pages[pp++];
                            cd.parts[j].pages[k].data = new MmlDatum[cd.parts[j].pages[k].length];
                            for (int l = 0; l < cd.parts[j].pages[k].length; l++)
                            {
                                cd.parts[j].pages[k].data[l] = buf[ptr++];
                            }
                        }
                    }
                }

                //instrumentデータの取り込み
                for (int i = 0; i < mupb.useInstrumentSetCount; i++)
                {
                    MupbInfo.InstrumentDefine id = mupb.instruments[i];
                    id.data = new byte[id.length];
                    for (int j = 0; j < id.length; j++)
                    {
                        id.data[j] = (byte)buf[ptr++].dat;
                    }
                }

                //pcmデータの取り込み
                for (int i = 0; i < mupb.usePCMSetCount; i++)
                {
                    MupbInfo.PCMDefine pd = mupb.pcms[i];
                    pd.data = new byte[pd.length];
                    for (int j = 0; j < pd.length; j++)
                    {
                        pd.data[j] = (byte)buf[ptr++].dat;
                    }
                }
            }
            else
            {
                throw new MubException("This data is not mucom88 data !");
            }
            srcBuf = buf;
        }
예제 #3
0
        public void SetDriverOptionFromTags(List <Tuple <string, string> > tags)
        {
            if (tags == null)
            {
                return;
            }
            if (tags.Count < 1)
            {
                return;
            }

            foreach (var tag in tags)
            {
                if (tag == null)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(tag.Item1))
                {
                    continue;
                }

                if (tag.Item1.ToLower().Trim() == "carriercorrection")
                {
                    if (!string.IsNullOrEmpty(tag.Item2))
                    {
                        string val = tag.Item2.ToLower().Trim();

                        CarrierCorrection = false;
                        if (val == "yes" || val == "y" || val == "1" || val == "true" || val == "t")
                        {
                            CarrierCorrection = true;
                        }
                    }
                }
                else if (tag.Item1.ToLower().Trim() == "opmclockmode")
                {
                    if (!string.IsNullOrEmpty(tag.Item2))
                    {
                        string val = tag.Item2.ToLower().Trim();

                        OPMClockMode = enmOPMClockMode.normal;
                        if (val == "x68000" || val == "x68k" || val == "x68" || val == "x" || val == "4000000" || val == "x680x0")
                        {
                            OPMClockMode = enmOPMClockMode.X68000;
                        }
                    }
                }
                else if (tag.Item1.ToLower().Trim() == "ssgextend")
                {
                    if (!string.IsNullOrEmpty(tag.Item2))
                    {
                        string val = tag.Item2.ToLower().Trim();

                        SSGExtend = false;
                        if (val == "on" || val == "yes" || val == "y" || val == "1" || val == "true" || val == "t")
                        {
                            SSGExtend = true;
                        }
                    }
                }
                else if (tag.Item1.ToLower().Trim() == "opna1rhythmmute")
                {
                    if (!string.IsNullOrEmpty(tag.Item2))
                    {
                        string val = tag.Item2.ToLower().Trim();
                        RhythmMute[0] = 0;
                        if (val.IndexOf('b') > -1)
                        {
                            RhythmMute[0] |= 1;
                        }
                        if (val.IndexOf('s') > -1)
                        {
                            RhythmMute[0] |= 2;
                        }
                        if (val.IndexOf('c') > -1)
                        {
                            RhythmMute[0] |= 4;
                        }
                        if (val.IndexOf('h') > -1)
                        {
                            RhythmMute[0] |= 8;
                        }
                        if (val.IndexOf('t') > -1)
                        {
                            RhythmMute[0] |= 16;
                        }
                        if (val.IndexOf('r') > -1)
                        {
                            RhythmMute[0] |= 32;
                        }
                        RhythmMute[0] = (~RhythmMute[0]) & 0b0011_1111;
                    }
                }
                else if (tag.Item1.ToLower().Trim() == "opna2rhythmmute")
                {
                    if (!string.IsNullOrEmpty(tag.Item2))
                    {
                        string val = tag.Item2.ToLower().Trim();

                        RhythmMute[1] = 0;
                        if (val.IndexOf('b') > -1)
                        {
                            RhythmMute[1] |= 1;
                        }
                        if (val.IndexOf('s') > -1)
                        {
                            RhythmMute[1] |= 2;
                        }
                        if (val.IndexOf('c') > -1)
                        {
                            RhythmMute[1] |= 4;
                        }
                        if (val.IndexOf('h') > -1)
                        {
                            RhythmMute[1] |= 8;
                        }
                        if (val.IndexOf('t') > -1)
                        {
                            RhythmMute[1] |= 16;
                        }
                        if (val.IndexOf('r') > -1)
                        {
                            RhythmMute[1] |= 32;
                        }
                        RhythmMute[1] = (~RhythmMute[1]) & 0b0011_1111;
                    }
                }
                else if (tag.Item1.ToLower().Trim() == "opnb1adpcmamute")
                {
                    if (!string.IsNullOrEmpty(tag.Item2))
                    {
                        string val = tag.Item2.ToLower().Trim();

                        RhythmMute[2] = 0;
                        if (val.IndexOf('1') > -1)
                        {
                            RhythmMute[2] |= 1;
                        }
                        if (val.IndexOf('2') > -1)
                        {
                            RhythmMute[2] |= 2;
                        }
                        if (val.IndexOf('3') > -1)
                        {
                            RhythmMute[2] |= 4;
                        }
                        if (val.IndexOf('4') > -1)
                        {
                            RhythmMute[2] |= 8;
                        }
                        if (val.IndexOf('5') > -1)
                        {
                            RhythmMute[2] |= 16;
                        }
                        if (val.IndexOf('6') > -1)
                        {
                            RhythmMute[2] |= 32;
                        }
                        RhythmMute[2] = (~RhythmMute[2]) & 0b0011_1111;
                    }
                }
                else if (tag.Item1.ToLower().Trim() == "opnb2adpcmamute")
                {
                    if (!string.IsNullOrEmpty(tag.Item2))
                    {
                        string val = tag.Item2.ToLower().Trim();

                        RhythmMute[3] = 0;
                        if (val.IndexOf('1') > -1)
                        {
                            RhythmMute[3] |= 1;
                        }
                        if (val.IndexOf('2') > -1)
                        {
                            RhythmMute[3] |= 2;
                        }
                        if (val.IndexOf('3') > -1)
                        {
                            RhythmMute[3] |= 4;
                        }
                        if (val.IndexOf('4') > -1)
                        {
                            RhythmMute[3] |= 8;
                        }
                        if (val.IndexOf('5') > -1)
                        {
                            RhythmMute[3] |= 16;
                        }
                        if (val.IndexOf('6') > -1)
                        {
                            RhythmMute[3] |= 32;
                        }
                        RhythmMute[3] = (~RhythmMute[3]) & 0b0011_1111;
                    }
                }
            }
        }