Exemplo n.º 1
0
 void fluid_channel_init()
 {
     enabled = true;
     prognum = 0;
     banknum = channum == 9 ? MidiPlayerGlobal.ImSFCurrent.DrumKitBankNumber : MidiPlayerGlobal.ImSFCurrent.DefaultBankNumber;
     preset  = synth.fluid_synth_find_preset(banknum, prognum);
 }
Exemplo n.º 2
0
 void fluid_channel_init()
 {
     prognum = 0;
     if (MidiPlayerGlobal.ImSFCurrent != null)
     {
         banknum = channum == 9 ? MidiPlayerGlobal.ImSFCurrent.DrumKitBankNumber : MidiPlayerGlobal.ImSFCurrent.DefaultBankNumber;
         preset  = synth.fluid_synth_find_preset(banknum, prognum);
     }
 }
Exemplo n.º 3
0
        public fluid_channel(MidiSynth psynth, int pchanum)
        {
            gens    = new double[Enum.GetNames(typeof(fluid_gen_type)).Length];
            gen_abs = new bool[Enum.GetNames(typeof(fluid_gen_type)).Length];
            cc      = new short[128];

            synth   = psynth;
            channum = pchanum;
            preset  = null;
            tuning  = null;

            fluid_channel_init();
            fluid_channel_init_ctrl();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Build list of presets found in the SoundFont
        /// </summary>
        static public void BuildPresetList(bool forInstrument)
        {
            List <MPTKListItem> presets = new List <MPTKListItem>();

            try
            {
                //Debug.Log(">>> Load Preset - b:" + ibank + " p:" + ipatch);
                if (ImSFCurrent != null)
                {
                    if ((forInstrument && ImSFCurrent.DefaultBankNumber >= 0 && ImSFCurrent.DefaultBankNumber < ImSFCurrent.Banks.Length) ||
                        (!forInstrument && ImSFCurrent.DrumKitBankNumber >= 0 && ImSFCurrent.DrumKitBankNumber < ImSFCurrent.Banks.Length))
                    {
                        int ibank = forInstrument ? ImSFCurrent.DefaultBankNumber : ImSFCurrent.DrumKitBankNumber;
                        if (ImSFCurrent.Banks[ibank] != null)
                        {
                            ImSFCurrent.Banks[ibank].PatchCount = 0;
                            for (int ipreset = 0; ipreset < ImSFCurrent.Banks[ibank].defpresets.Length; ipreset++)
                            {
                                HiPreset p = ImSFCurrent.Banks[ibank].defpresets[ipreset];
                                if (p != null)
                                {
                                    presets.Add(new MPTKListItem()
                                    {
                                        Index = p.Num, Label = p.Num + " - " + p.Name
                                    });
                                    ImSFCurrent.Banks[ibank].PatchCount++;
                                }
                                //else
                                //    presets.Add(null);
                            }
                        }
                        else
                        {
                            Debug.LogWarningFormat("Default bank {0} for {1} is not defined.", ibank, forInstrument ? "Instrument" : "Drum");
                        }
                    }
                    else
                    {
                        Debug.LogWarningFormat("No default bank defined for {0}.", forInstrument ? "Instrument" : "Drum");
                    }

                    // Global count
                    //ImSFCurrent.PatchCount = 0;
                    foreach (ImBank bank in ImSFCurrent.Banks)
                    {
                        if (bank != null)
                        {
                            bank.PatchCount = 0;
                            foreach (HiPreset preset in bank.defpresets)
                            {
                                if (preset != null)
                                {
                                    // Bank count
                                    bank.PatchCount++;
                                }
                            }
                            //ImSFCurrent.PatchCount += bank.PatchCount;
                        }
                    }
                }
                else
                {
                    Debug.Log(MidiPlayerGlobal.ErrorNoSoundFont);
                }
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
            if (forInstrument)
            {
                MPTK_ListPreset = presets;
            }
            else
            {
                MPTK_ListPresetDrum = presets;
            }
        }