Example #1
0
        private void SFList_SelectedIndexChanged(object sender, EventArgs e)
        {
            Int32     NotSFZ = -1;
            SoundFont SF     = (SoundFont)SFList.SelectedItem;
            Boolean   Valid  = (SF != null);

            NotSFZ     = Valid ? ((Path.GetExtension(SF.GetSoundFontPath).ToLowerInvariant() != ".sfz") ? -1 : 0) : 0;
            SP.Minimum = NotSFZ;
            SB.Minimum = NotSFZ;
            DP.Minimum = NotSFZ;

            SP.Value        = Valid ? SF.GetSourcePreset : 0;
            SB.Value        = Valid ? SF.GetSourceBank : 0;
            DP.Value        = Valid ? SF.GetDestinationPreset : 0;
            DB.Value        = Valid ? SF.GetDestinationBank : 0;
            DBLSB.Value     = Valid ? SF.GetDestinationBankLSB : 0;
            Enabled.Checked = Valid ? SF.IsEnabled : false;
            XGM.Checked     = Valid ? SF.GetXGMode : false;

            SFSettings.Enabled = Valid;
            MvU.Enabled        = Valid;
            MvD.Enabled        = Valid;
            RmvSF.Enabled      = Valid;
        }
Example #2
0
        public static bool LoadCSF()
        {
            Program.SFArray.List = new List <SoundFont>();

            Debug.PrintToConsole("ok", "Checking if Common SoundFonts list exists...");
            if (File.Exists(CSFFixedPath))
            {
                Debug.PrintToConsole("ok", "It does, loading to memory...");

                MemoryStream MS = new MemoryStream(File.ReadAllBytes(CSFFixedPath));
                using (StreamReader SFR = new StreamReader(MS))
                {
                    string SF = null;
                    bool   AI = false, ES = false, XG = false;
                    int    BV = -1, PV = -1, DBV = 0, DPV = -1, DBLSBV = 0;

                    SoundFont iSF;

                    String L;
                    Int64  Count = 1;
                    while ((L = SFR.ReadLine()) != null)
                    {
                        try
                        {
                            if (L.Equals("sf.start"))
                            {
                                if (AI)
                                {
                                    continue;
                                }

                                // Start of SoundFont item detected
                                AI = true;
                            }
                            else if (L.Equals("sf.end"))
                            {
                                if (!AI)
                                {
                                    continue;
                                }

                                if (ES)
                                {
                                    Debug.PrintToConsole("ok", "============================");
                                    Debug.PrintToConsole("ok", String.Format("SoundFont {0}", Count));
                                    Debug.PrintToConsole("ok", String.Format("SFP = {0}", SF));
                                    Debug.PrintToConsole("ok", String.Format("SP = {0}", PV));
                                    Debug.PrintToConsole("ok", String.Format("SB = {0}", BV));
                                    Debug.PrintToConsole("ok", String.Format("DP = {0}", DPV));
                                    Debug.PrintToConsole("ok", String.Format("DB = {0}", DBV));
                                    Debug.PrintToConsole("ok", String.Format("DBLSB = {0}", DBLSBV));
                                    Debug.PrintToConsole("ok", String.Format("XG = {0}", XG));
                                    Debug.PrintToConsole("ok", String.Format("Enabled = {0}", ES));
                                    Debug.PrintToConsole("ok", "============================");

                                    // Add to the list
                                    iSF = new SoundFont(SF, PV, BV, DPV, DBV, DBLSBV, ES, XG);
                                    Program.SFArray.List.Add(iSF);

                                    Count++;
                                }

                                SF = null;
                            }
                            else if (GetName(L).Equals("sf.path"))
                            {
                                if (!AI | SF != null)
                                {
                                    continue;
                                }

                                SF = GetValue(L);
                            }
                            else if (GetName(L).Equals("sf.enabled"))
                            {
                                if (!AI)
                                {
                                    continue;
                                }

                                ES = Convert.ToBoolean(Convert.ToInt32(GetValue(L)));
                            }
                            else if (GetName(L).Equals("sf.xgdrums"))
                            {
                                if (!AI)
                                {
                                    continue;
                                }

                                XG = Convert.ToBoolean(Convert.ToInt32(GetValue(L)));
                            }
                            else if (GetName(L).Equals("sf.srcb"))
                            {
                                if (!AI)
                                {
                                    continue;
                                }

                                BV = Convert.ToInt32(GetValue(L));
                            }
                            else if (GetName(L).Equals("sf.srcp"))
                            {
                                if (!AI)
                                {
                                    continue;
                                }

                                PV = Convert.ToInt32(GetValue(L));
                            }
                            else if (GetName(L).Equals("sf.desb"))
                            {
                                if (!AI)
                                {
                                    continue;
                                }

                                DBV = Convert.ToInt32(GetValue(L));
                            }
                            else if (GetName(L).Equals("sf.desp"))
                            {
                                if (!AI)
                                {
                                    continue;
                                }

                                DPV = Convert.ToInt32(GetValue(L));
                            }
                            else if (GetName(L).Equals("sf.desblsb"))
                            {
                                if (!AI)
                                {
                                    continue;
                                }

                                DBLSBV = Convert.ToInt32(GetValue(L));
                            }
                            else if (L.Contains("//") || L.Contains('#') || String.IsNullOrWhiteSpace(L))
                            {
                                continue;
                            }
                        }
                        catch { }
                    }
                }
                MS.Dispose();

                Debug.PrintToConsole("ok", "Common SoundFonts list successfully loaded.");
                return(true);
            }

            Debug.PrintToConsole("ok", "It doesn't.");
            return(false);
        }