Ejemplo n.º 1
0
        public void LoadSoundFontBytes(byte[] data)
        {
            if (State != SynthPlayerState.Stopped)
            {
                return;
            }
            var input = ByteBuffer.FromBuffer(data);

            try
            {
                Logger.Info("Loading soundfont from bytes");
                var bank = new PatchBank();
                bank.LoadSf2(input);
                Synth.LoadBank(bank);
                IsSoundFontLoaded = true;
                OnSoundFontLoaded();
                Logger.Info("soundFont successfully loaded");
                if (IsReady)
                {
                    OnReadyForPlay();
                }
            }
            catch (Exception e)
            {
                Logger.Error("Could not load soundfont from bytes " + e);
                IsSoundFontLoaded = false;
                Synth.UnloadBank();
                OnSoundFontLoadFailed();
            }
        }