/// <summary>
 /// Load samples associated to a patch
 /// </summary>
 /// <param name="ibank"></param>
 /// <param name="ipatch"></param>
 private static void LoadSamples(int ibank, int ipatch)
 {
     try
     {
         float start = Time.realtimeSinceStartup;
         //Debug.Log(">>> Load Preset - b:" + ibank + " p:" + ipatch);
         if (ImSFCurrent != null)
         {
             ImPreset preset = ImSFCurrent.Banks[ibank].Presets[ipatch];
             //Debug.Log("Loading Preset - " + index + " '" + preset.Name + "'");
             // Load each sample associated with this preset in DicAudioClip
             foreach (ImInstrument inst in preset.Instruments)
             {
                 foreach (ImSample smpl in inst.Samples)
                 {
                     if (smpl.WaveFile != null)
                     {
                         if (!DicAudioClip.Exist(smpl.WaveFile))
                         {
                             AudioClip ac = Resources.Load <AudioClip>(WavePath + "/" + Path.GetFileNameWithoutExtension(smpl.WaveFile));
                             if (ac != null)
                             {
                                 DicAudioClip.Add(smpl.WaveFile, ac);
                                 MPTK_CountWaveLoaded++;
                             }
                             //else Debug.LogWarning("Wave " + smpl.WaveFile + " not found");
                         }
                     }
                 }
             }
             //Debug.Log("--- Loaded Preset - " + ipatch + " '" + preset.Name + "' " + count + " samples loaded");
         }
         else
         {
             Debug.Log("Presets not loaded ");
         }
     }
     catch (System.Exception ex)
     {
         MidiPlayerGlobal.ErrorDetail(ex);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Load samples associated to a patch for High SF
        /// </summary>
        private static void LoadAudioClip()
        {
            try
            {
                float start = Time.realtimeSinceStartup;
                //Debug.Log(">>> Load Sample");
                //int count = 0;
                if (ImSFCurrent != null)
                {
                    foreach (HiSample smpl in ImSFCurrent.HiSf.Samples)
                    {
                        if (smpl.Name != null)
                        {
                            if (!DicAudioClip.Exist(smpl.Name))
                            {
                                string    path = WavePath + "/" + Path.GetFileNameWithoutExtension(smpl.Name);// + ".wav";
                                AudioClip ac   = Resources.Load <AudioClip>(path);
                                if (ac != null)
                                {
                                    //Debug.Log("Sample load " + path);
                                    DicAudioClip.Add(smpl.Name, ac);

                                    MPTK_CountWaveLoaded++;
                                }
                                //else Debug.LogWarning("Sample " + smpl.WaveFile + " not found");
                            }
                        }
                    }
                }
                else
                {
                    Debug.Log("SoundFont not loaded ");
                }
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }