Exemplo n.º 1
0
        private void GetInfoFromStream_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                while (true)
                {
                    if (chan != 0)
                    {
                        normalpos = Bass.BASS_ChannelGetPosition(chan);
                        normallen = Bass.BASS_ChannelGetLength(chan);
                        tick      = Bass.BASS_ChannelGetPosition(chan, BASSMode.BASS_POS_MIDI_TICK);                       // get position in ticks
                        lentick   = Bass.BASS_ChannelGetLength(chan, BASSMode.BASS_POS_MIDI_TICK);                         // get length in ticks
                        Bass.BASS_ChannelSetAttribute(chan, BASSAttribute.BASS_ATTRIB_MIDI_VOICES, maxvoices);             // apply to current MIDI file too
                        Bass.BASS_ChannelSetAttribute(chan, BASSAttribute.BASS_ATTRIB_MIDI_CPU, Convert.ToSingle(maxcpu)); // apply to current MIDI file too
                        Bass.BASS_ChannelGetAttribute(chan, BASSAttribute.BASS_ATTRIB_MIDI_VOICES_ACTIVE, ref active);     // get active voices
                        Bass.BASS_ChannelGetAttribute(chan, BASSAttribute.BASS_ATTRIB_CPU, ref cpu);                       // get cpu usage
                        PassedTime = TimeSpan.FromSeconds(Bass.BASS_ChannelBytes2Seconds(chan, normalpos));
                        LengthTime = TimeSpan.FromSeconds(Bass.BASS_ChannelBytes2Seconds(chan, normallen));
                    }

                    BASS_MIDI_FONTINFO i = new BASS_MIDI_FONTINFO();
                    BassMidi.BASS_MIDI_FontGetInfo(font, i);
                    sfinfolabel = String.Format("Name: {0}\nLoaded: {1} / {2}", i.name, i.samload, i.samsize);

                    System.Threading.Thread.Sleep(1);
                }
            }
            catch { }
        }
Exemplo n.º 2
0
    /// <summary>
    /// Load External BASS Audio Decoder Plugins
    /// </summary>
    private void LoadAudioDecoderPlugins()
    {
      Log.Info("BASS: Loading audio decoder add-ins...");

      string appPath = Application.StartupPath;
      string decoderFolderPath = Path.Combine(appPath, @"musicplayer\plugins\audio decoders");

      if (!Directory.Exists(decoderFolderPath))
      {
        Log.Error(@"BASS: Unable to find \musicplayer\plugins\audio decoders folder in MediaPortal.exe path.");
        return;
      }

      DirectoryInfo dirInfo = new DirectoryInfo(decoderFolderPath);
      FileInfo[] decoders = dirInfo.GetFiles();

      int pluginHandle = 0;
      int decoderCount = 0;

      foreach (FileInfo file in decoders)
      {
        if (Path.GetExtension(file.Name).ToLower() != ".dll")
        {
          continue;
        }

        pluginHandle = Bass.BASS_PluginLoad(file.FullName);

        if (pluginHandle != 0)
        {
          DecoderPluginHandles.Add(pluginHandle);
          decoderCount++;
          Log.Debug("BASS: Added DecoderPlugin: {0}", file.FullName);
        }

        else
        {
          Log.Debug("BASS: Unable to load: {0}", file.FullName);
        }
      }

      if (decoderCount > 0)
      {
        Log.Info("BASS: Loaded {0} Audio Decoders.", decoderCount);
      }

      else
      {
        Log.Error(
          @"BASS: No audio decoders were loaded. Confirm decoders are present in \musicplayer\plugins\audio decoders folder.");
      }

      // Look for any SF2 files available in the folder.
      // SF2 files contain sound fonts needed for midi playback
      List<BASS_MIDI_FONT> tmpFonts = new List<BASS_MIDI_FONT>();
      foreach (FileInfo file in decoders)
      {
        if (Path.GetExtension(file.Name).ToLower() != ".sf2")
        {
          continue;
        }
        int font = BassMidi.BASS_MIDI_FontInit(file.FullName);
        if (font != 0)
        {
          BASS_MIDI_FONTINFO fontInfo = new BASS_MIDI_FONTINFO();
          BassMidi.BASS_MIDI_FontGetInfo(font, fontInfo);
          Log.Info("BASS: Loading Midi font: {0}", fontInfo.ToString());
          soundFontHandles.Add(font);
          BASS_MIDI_FONT soundFont = new BASS_MIDI_FONT(font, -1, 0);
          tmpFonts.Add(soundFont);
        }
      }

      if (tmpFonts.Count > 0)
      {
        soundFonts = tmpFonts.ToArray();
      }
    }
Exemplo n.º 3
0
        /// <summary>
        /// Load External BASS Audio Decoder Plugins
        /// </summary>
        public static void LoadAudioDecoderPlugins()
        {
            Log.Info("BASS: Loading audio decoder add-ins...");

            string appPath           = Application.StartupPath;
            string decoderFolderPath = Path.Combine(appPath, @"musicplayer\plugins\audio decoders");

            if (!Directory.Exists(decoderFolderPath))
            {
                Log.Error(@"BASS: Unable to find \musicplayer\plugins\audio decoders folder in MediaPortal.exe path.");
                return;
            }

            DirectoryInfo dirInfo = new DirectoryInfo(decoderFolderPath);

            FileInfo[] decoders = dirInfo.GetFiles();

            int pluginHandle = 0;
            int decoderCount = 0;

            foreach (FileInfo file in decoders)
            {
                if (Path.GetExtension(file.Name).ToLower() != ".dll")
                {
                    continue;
                }

                pluginHandle = Bass.BASS_PluginLoad(file.FullName);

                if (pluginHandle != 0)
                {
                    _decoderPluginHandles.Add(pluginHandle);
                    decoderCount++;
                    Log.Debug("BASS: Added DecoderPlugin: {0}", file.FullName);
                }

                else
                {
                    Log.Debug("BASS: Unable to load: {0}", file.FullName);
                }
            }

            if (decoderCount > 0)
            {
                Log.Info("BASS: Loaded {0} Audio Decoders.", decoderCount);
            }

            else
            {
                Log.Error(
                    @"BASS: No audio decoders were loaded. Confirm decoders are present in \musicplayer\plugins\audio decoders folder.");
            }

            // Look for any SF2 files available in the folder.
            // SF2 files contain sound fonts needed for midi playback
            List <BASS_MIDI_FONT> tmpFonts = new List <BASS_MIDI_FONT>();

            foreach (FileInfo file in decoders)
            {
                if (Path.GetExtension(file.Name).ToLower() != ".sf2")
                {
                    continue;
                }
                int font = BassMidi.BASS_MIDI_FontInit(file.FullName, BASSFlag.BASS_MIDI_FONT_MMAP);
                if (font != 0)
                {
                    BASS_MIDI_FONTINFO fontInfo = new BASS_MIDI_FONTINFO();
                    BassMidi.BASS_MIDI_FontGetInfo(font, fontInfo);
                    Log.Info("BASS: Loading Midi font: {0}", fontInfo.ToString());
                    _soundFontHandles.Add(font);
                    BASS_MIDI_FONT soundFont = new BASS_MIDI_FONT(font, -1, 0);
                    tmpFonts.Add(soundFont);
                }
            }

            if (tmpFonts.Count > 0)
            {
                _soundFonts = tmpFonts.ToArray();
            }
        }
Exemplo n.º 4
0
        public SoundFontInfo(String SoundFont)
        {
            InitializeComponent();

            ERROR = false;

            // Here we go
            String   next;
            String   sf = "";
            Int32    fonthandle;
            FileInfo f;

            OriginalSF = SoundFont;

            if (SoundFont.ToLower().IndexOf('=') != -1)
            {
                sf = SoundFont.Substring(SoundFont.LastIndexOf('|') + 1);
                if (!File.Exists(sf))
                {
                    Program.ShowError(4, "Error", String.Format("The SoundFont \"{0}\" doesn't exist.", SoundFont), null);
                    ERROR = true;
                    Close();
                    return;
                }
                fonthandle = BassMidi.BASS_MIDI_FontInit(sf);
                f          = new FileInfo(sf);
                next       = sf;
            }
            else
            {
                sf = SoundFont;
                if (!File.Exists(SoundFont))
                {
                    Program.ShowError(4, "Error", String.Format("The SoundFont \"{0}\" doesn't exist.", SoundFont), null);
                    ERROR = true;
                    Close();
                    return;
                }
                fonthandle = BassMidi.BASS_MIDI_FontInit(SoundFont);
                f          = new FileInfo(SoundFont);
                next       = SoundFont;
            }

            BASS_MIDI_FONTINFO fontinfo = BassMidi.BASS_MIDI_FontGetInfo(fonthandle);

            FNBox.Text  = next;
            ISFBox.Text = ReturnName(fontinfo.name, next);
            CIBox.Text  = ReturnCopyright(fontinfo.copyright);
            SamF.Text   = String.Format("{0} ({1})", ReturnSampleType(fontinfo.samtype), fontinfo.samtype);

            if (f.Length > (long)2147483648)
            {
                SofSFLab.Font      = new Font(SofSFLab.Font, FontStyle.Bold);
                SofSFLab.ForeColor = Color.DarkRed;
                SofSFLab.Cursor    = Cursors.Help;
                SizeWarning.SetToolTip(SofSFLab, "SoundFonts bigger than 2GB may not load correctly\non 32-bit applications, cause audio corruptions or even cause loss of data!\n\nBe careful!");
            }

            if (Path.GetExtension(sf).ToLowerInvariant() == ".sfz")
            {
                SofSFLab.Text = String.Format("{0} (Samples: {1}, Presets: {2})",
                                              Functions.ReturnLength(f.Length + SFZ.GetSoundFontZSize(sf), true),
                                              Functions.ReturnLength(SFZ.GetSoundFontZSize(sf), true),
                                              Functions.ReturnLength(f.Length - (long)fontinfo.samsize, false));
            }
            else
            {
                SofSFLab.Text = String.Format("{0} (Samples: {1}, Presets: {2})",
                                              Functions.ReturnLength(f.Length, false),
                                              Functions.ReturnLength(fontinfo.samsize, false),
                                              Functions.ReturnLength(f.Length - (long)fontinfo.samsize, false));
            }

            SFfLab.Text      = SoundFontListExtension.ReturnSoundFontFormatMore(Path.GetExtension(next));
            CommentRich.Text = ReturnComment(fontinfo.comment);
            LELabel.Text     = f.LastWriteTimeUtc.ToString();

            BassMidi.BASS_MIDI_FontFree(fonthandle);
        }
Exemplo n.º 5
0
        public SoundFontInfo(String SoundFont)
        {
            InitializeComponent();

            ERROR = false;

            LastMIDIPath = KeppySynthConfiguratorMain.SynthPaths.GetValue("lastpathmidimport", Environment.GetFolderPath(Environment.SpecialFolder.Desktop)).ToString();

            // Here we go
            String   next;
            String   sf = "";
            Int32    fonthandle;
            FileInfo f;

            OriginalSF = SoundFont;

            if (SoundFont.ToLower().IndexOf('=') != -1)
            {
                sf = SoundFont.Substring(SoundFont.LastIndexOf('|') + 1);
                if (!File.Exists(sf))
                {
                    Functions.ShowErrorDialog(2, System.Media.SystemSounds.Exclamation, "Error", String.Format("The SoundFont \"{0}\" doesn't exist.", SoundFont), false, null);
                    ERROR = true;
                    Close();
                }
                SoundFontT = sf;
                fonthandle = BassMidi.BASS_MIDI_FontInit(sf);
                f          = new FileInfo(sf);
                next       = sf;
            }
            else
            {
                sf = SoundFont;
                if (!File.Exists(SoundFont))
                {
                    Functions.ShowErrorDialog(2, System.Media.SystemSounds.Exclamation, "Error", String.Format("The SoundFont \"{0}\" doesn't exist.", SoundFont), false, null);
                    ERROR = true;
                    Close();
                }
                SoundFontT = SoundFont;
                fonthandle = BassMidi.BASS_MIDI_FontInit(SoundFont);
                f          = new FileInfo(SoundFont);
                next       = SoundFont;
            }

            BASS_MIDI_FONTINFO fontinfo = BassMidi.BASS_MIDI_FontGetInfo(fonthandle);

            FNBox.Text  = next;
            ISFBox.Text = ReturnName(fontinfo.name, next);
            CIBox.Text  = ReturnCopyright(fontinfo.copyright);

            if (f.Length > (long)2147483648)
            {
                SofSFLab.Font      = new Font(SofSFLab.Font, FontStyle.Bold);
                SofSFLab.ForeColor = Color.DarkRed;
                SofSFLab.Cursor    = Cursors.Help;
                SizeWarning.SetToolTip(SofSFLab, "SoundFonts bigger than 2GB may not load correctly\non 32-bit applications, cause audio corruptions or even cause loss of data!\n\nBe careful!");
            }

            if (Path.GetExtension(sf).ToLowerInvariant() == ".sfz")
            {
                SofSFLab.Text = String.Format("{0} (Samples: {1}, Presets: {2})",
                                              Functions.ReturnLength(f.Length + SFZInfo.GetSoundFontZSize(sf)),
                                              Functions.ReturnLength(SFZInfo.GetSoundFontZSize(sf)),
                                              Functions.ReturnLength(f.Length - (long)fontinfo.samsize));
            }
            else
            {
                SofSFLab.Text = String.Format("{0} (Samples: {1}, Presets: {2})",
                                              Functions.ReturnLength(f.Length),
                                              Functions.ReturnLength(fontinfo.samsize),
                                              Functions.ReturnLength(f.Length - (long)fontinfo.samsize));
            }

            SFfLab.Text      = Functions.ReturnSoundFontFormatMore(Path.GetExtension(next));
            CommentRich.Text = ReturnComment(fontinfo.comment);
            LELabel.Text     = f.LastWriteTimeUtc.ToString();

            BassMidi.BASS_MIDI_FontFree(fonthandle);
        }