Example #1
0
        private List <Tuple <enmInstType, string, string, string> > GetInstsAtGwi(string srcFn)
        {
            List <Tuple <enmInstType, string, string, string> > ret = new List <Tuple <enmInstType, string, string, string> >();

            try
            {
                string       stPath = System.Windows.Forms.Application.StartupPath;
                Core.Mml2vgm mv     = new Core.Mml2vgm(null, srcFn, "", stPath, Disp);
                mv.isIDE = true;
                if (mv.Start_Analyze() != 0)
                {
                    return(null);
                }

                int renban = 0;
                //inst FM
                Dictionary <int, Tuple <string, byte[]> > instFM = mv.desVGM.instFM;
                foreach (int num in instFM.Keys)
                {
                    if (instFM[num].Item2.Length == 47)
                    {
                        string name = instFM[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("OPN instrument noname {0}", renban++);
                        }

                        int[][] prms = new int[][] { new int[11], new int[11], new int[11], new int[11] };
                        int     alg = 0, fb = 0;
                        for (int i = 0; i < 4; i++)
                        {
                            for (int j = 0; j < 11; j++)
                            {
                                prms[i][j] = (byte)instFM[num].Item2[i * 11 + j + 1];
                            }
                        }
                        alg = (int)instFM[num].Item2[45];
                        fb  = (int)instFM[num].Item2[46];
                        string sdatV, sdatM;
                        sdatV = MakeVoiceDefineForGWI_OPN(name + add, num, prms, alg, fb);
                        sdatM = MakeVoiceDefineForMUC_OPN(name + add, num, prms, alg, fb);
                        ret.Add(new Tuple <enmInstType, string, string, string>(enmInstType.FM_N, Path.Combine(srcFn, name).Replace(baseDir, ""), sdatV, sdatM));
                    }
                    else
                    {
                        ;
                    }
                }

                //inst OPM
                Dictionary <int, Tuple <string, byte[]> > instOPM = mv.desVGM.instOPM;
                foreach (int num in instOPM.Keys)
                {
                    if (instOPM[num].Item2.Length == 47)
                    {
                        string name = instOPM[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("OPM instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiFmOPMString(num, name, instOPM[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string, string>(enmInstType.FM_N, Path.Combine(srcFn, name).Replace(baseDir, ""), str, ""));
                        }
                    }
                    else
                    {
                        ;
                    }
                }

                //inst OPL
                Dictionary <int, Tuple <string, byte[]> > instOPL = mv.desVGM.instOPL;
                foreach (int num in instOPL.Keys)
                {
                    if (instOPL[num].Item2.Length == Core.Const.OPLL_INSTRUMENT_SIZE)
                    {
                        string name = instOPL[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("OPLL instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiFmOPLLString(num, name, instOPL[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string, string>(enmInstType.FM_L, Path.Combine(srcFn, name).Replace(baseDir, ""), str, ""));
                        }
                    }
                    else if (instOPL[num].Item2.Length == Core.Const.OPL3_INSTRUMENT_SIZE)
                    {
                        string name = instOPL[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("OPL instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiFmOPLString(num, name, instOPL[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string, string>(enmInstType.FM_L, Path.Combine(srcFn, name).Replace(baseDir, ""), str, ""));
                        }
                    }
                    else if (instOPL[num].Item2.Length == Core.Const.OPL_OP4_INSTRUMENT_SIZE)
                    {
                        string name = instOPL[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("OPL4 4OP instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiFmOPL4String(num, name, instOPL[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string, string>(enmInstType.FM_L, Path.Combine(srcFn, name).Replace(baseDir, ""), str, ""));
                        }
                    }
                    else
                    {
                        ;
                    }
                }

                //inst WF
                Dictionary <int, Tuple <string, byte[]> > instWF = mv.desVGM.instWF;
                foreach (int num in instWF.Keys)
                {
                    if (instWF[num].Item2.Length == 33)
                    {
                        string name = instWF[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("HuC instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiWFString(num, name, instWF[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string, string>(enmInstType.FM_M, Path.Combine(srcFn, name).Replace(baseDir, ""), str, ""));
                        }
                    }
                    else
                    {
                        ;
                    }
                }

                //inst WFS
                Dictionary <int, Tuple <string, byte[]> > instOPNA2WFS = mv.desVGM.instOPNA2WFS;
                foreach (int num in instOPNA2WFS.Keys)
                {
                    string name = instOPNA2WFS[num].Item1;
                    if (string.IsNullOrEmpty(name))
                    {
                        name = string.Format("OPNA2 SSG WF instrument noname {0}", renban++);
                    }
                    string str = GetInstrumentGwiWfsString(num, name, instOPNA2WFS[num].Item2);

                    if (!string.IsNullOrEmpty(str))
                    {
                        ret.Add(new Tuple <enmInstType, string, string, string>(enmInstType.SSG_WF, Path.Combine(srcFn, name).Replace(baseDir, ""), str, ""));
                    }
                }
            }
            catch
            {
                return(null);
            }

            return(ret);
        }
Example #2
0
        private List <Tuple <enmInstType, string, string> > GetInstsAtGwi(string srcFn)
        {
            List <Tuple <enmInstType, string, string> > ret = new List <Tuple <enmInstType, string, string> >();

            try
            {
                string       stPath = System.Windows.Forms.Application.StartupPath;
                Core.Mml2vgm mv     = new Core.Mml2vgm(null, srcFn, "", stPath, Disp);
                mv.isIDE = true;
                if (mv.Start_Analyze() != 0)
                {
                    return(null);
                }

                int renban = 0;
                //inst FM
                Dictionary <int, Tuple <string, byte[]> > instFM = mv.desVGM.instFM;
                foreach (int num in instFM.Keys)
                {
                    if (instFM[num].Item2.Length == 47)
                    {
                        string name = instFM[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("OPN instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiFmString(num, name, instFM[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string>(enmInstType.FM_N, Path.Combine(srcFn, name).Replace(baseDir, ""), str));
                        }
                    }
                    else
                    {
                        ;
                    }
                }

                //inst OPM
                Dictionary <int, Tuple <string, byte[]> > instOPM = mv.desVGM.instOPM;
                foreach (int num in instOPM.Keys)
                {
                    if (instOPM[num].Item2.Length == 47)
                    {
                        string name = instOPM[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("OPM instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiFmOPMString(num, name, instOPM[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string>(enmInstType.FM_N, Path.Combine(srcFn, name).Replace(baseDir, ""), str));
                        }
                    }
                    else
                    {
                        ;
                    }
                }

                //inst OPL
                Dictionary <int, Tuple <string, byte[]> > instOPL = mv.desVGM.instOPL;
                foreach (int num in instOPL.Keys)
                {
                    if (instOPL[num].Item2.Length == Core.Const.OPLL_INSTRUMENT_SIZE)
                    {
                        string name = instOPL[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("OPLL instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiFmOPLLString(num, name, instOPL[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string>(enmInstType.FM_L, Path.Combine(srcFn, name).Replace(baseDir, ""), str));
                        }
                    }
                    else if (instOPL[num].Item2.Length == Core.Const.OPL3_INSTRUMENT_SIZE)
                    {
                        string name = instOPL[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("OPL instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiFmOPLString(num, name, instOPL[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string>(enmInstType.FM_L, Path.Combine(srcFn, name).Replace(baseDir, ""), str));
                        }
                    }
                    else if (instOPL[num].Item2.Length == Core.Const.OPL_OP4_INSTRUMENT_SIZE)
                    {
                        string name = instOPL[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("OPL4 4OP instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiFmOPL4String(num, name, instOPL[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string>(enmInstType.FM_L, Path.Combine(srcFn, name).Replace(baseDir, ""), str));
                        }
                    }
                    else
                    {
                        ;
                    }
                }

                //inst WF
                Dictionary <int, Tuple <string, byte[]> > instWF = mv.desVGM.instWF;
                foreach (int num in instWF.Keys)
                {
                    if (instWF[num].Item2.Length == 33)
                    {
                        string name = instWF[num].Item1;
                        if (string.IsNullOrEmpty(name))
                        {
                            name = string.Format("HuC instrument noname {0}", renban++);
                        }
                        string str = GetInstrumentGwiWFString(num, name, instWF[num].Item2);
                        if (!string.IsNullOrEmpty(str))
                        {
                            ret.Add(new Tuple <enmInstType, string, string>(enmInstType.FM_M, Path.Combine(srcFn, name).Replace(baseDir, ""), str));
                        }
                    }
                    else
                    {
                        ;
                    }
                }

                //inst WFS
                Dictionary <int, Tuple <string, byte[]> > instOPNA2WFS = mv.desVGM.instOPNA2WFS;
                foreach (int num in instOPNA2WFS.Keys)
                {
                    string name = instOPNA2WFS[num].Item1;
                    if (string.IsNullOrEmpty(name))
                    {
                        name = string.Format("OPNA2 SSG WF instrument noname {0}", renban++);
                    }
                    string str = GetInstrumentGwiWfsString(num, name, instOPNA2WFS[num].Item2);

                    if (!string.IsNullOrEmpty(str))
                    {
                        ret.Add(new Tuple <enmInstType, string, string>(enmInstType.SSG_WF, Path.Combine(srcFn, name).Replace(baseDir, ""), str));
                    }
                }
            }
            catch
            {
                return(null);
            }

            return(ret);
        }