Пример #1
0
        private void Initialize()
        {
            positionTimer.Interval = TimeSpan.FromMilliseconds(50);
            positionTimer.Tick    += positionTimer_Tick;

            IsPlaying = false;

            Window mainWindow = Application.Current.MainWindow;
            WindowInteropHelper interopHelper = new WindowInteropHelper(mainWindow);

            if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_SPEAKERS, interopHelper.Handle))
            {
                int pluginAAC = Bass.BASS_PluginLoad("bass_aac.dll");
#if DEBUG
                BASS_INFO info = new BASS_INFO();
                Bass.BASS_GetInfo(info);
                Debug.WriteLine(info.ToString());
                BASS_PLUGININFO aacInfo = Bass.BASS_PluginGetInfo(pluginAAC);
                foreach (BASS_PLUGINFORM f in aacInfo.formats)
                {
                    Debug.WriteLine("Type={0}, Name={1}, Exts={2}", f.ctype, f.name, f.exts);
                }
#endif
            }
            else
            {
                MessageBox.Show(mainWindow, "Bass initialization error!");
                mainWindow.Close();
            }
        }
Пример #2
0
        private void InitBassLibrary(int deviceNumber)
        {
            BassNet.Registration("*****@*****.**", "2X1132816322322");

            if (Bass.BASS_Init(deviceNumber, 44100, BASSInit.BASS_DEVICE_DEFAULT | BASSInit.BASS_DEVICE_LATENCY, IntPtr.Zero, Guid.Empty))
            {
                var exts = new List <string>();
                _sysInfo  = "Player version: " + this.GetType().Assembly.GetName().Version.ToString();
                _sysInfo += "\nBass Version: " + GetVersion(Bass.BASS_GetVersion());
                var info = new BASS_INFO();
                try
                {
                    Bass.BASS_GetInfo(info);
                    _sysInfo += "\nInfo: " + info.ToString();
                }
                catch
                {
                    _sysInfo += "\nError when loading info.";
                }
                exts.AddRange(Bass.SupportedStreamExtensions.Split(';'));
                Dictionary <int, string> h = Bass.BASS_PluginLoadDirectory(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location));
                if (h != null)
                {
                    foreach (int handle in h.Keys)
                    {
                        try
                        {
                            BASS_PLUGININFO inf = Bass.BASS_PluginGetInfo(handle);
                            _sysInfo += "\n" + System.IO.Path.GetFileName(h[handle].ToString());
                            _sysInfo += ", Version: " + GetVersion(inf.version);
                            foreach (BASS_PLUGINFORM form in inf.formats)
                            {
                                exts.AddRange(form.exts.Split(';'));
                            }
                        }
                        catch
                        {
                            _sysInfo += "\nError, could not load plugin: " + System.IO.Path.GetFileName(h[handle].ToString());
                        }
                    }
                }

                _supportedExtensions = exts.ToArray();
                _sysInfo            += "\n\nSupported File Formats: " + string.Join(", ", _supportedExtensions);
            }
            else
            {
                HandleBassError(true);
            }
        }
Пример #3
0
 public IEnumerable <string> GetPluginSupportedExt()
 {
     if (this.loadedPlugin == null || this.loadedPlugin.Count == 0)
     {
         yield break;
     }
     foreach (var kv in this.loadedPlugin)
     {
         BASS_PLUGININFO info = Bass.BASS_PluginGetInfo(kv.Key);
         foreach (BASS_PLUGINFORM form in info.formats)
         {
             yield return(form.name + "(" + form.exts + ")" + "|" + form.exts);
         }
     }
 }
Пример #4
0
 private void button2_Click(object sender, System.EventArgs e)
 {
     folderBrowserDialog.SelectedPath = Application.StartupPath;
     // this will try to load all bass*.dll add-ons from that directory...
     if (folderBrowserDialog.ShowDialog(this) == DialogResult.OK)
     {
         this.listBox1.Items.Clear();
         string dir = folderBrowserDialog.SelectedPath;
         // load all (bass*.dll) add-ons from the given directory
         this.Cursor = Cursors.WaitCursor;
         Dictionary <int, string> loadedPlugIns = Bass.BASS_PluginLoadDirectory(dir);
         openFileDialog.Filter = Utils.BASSAddOnGetSupportedFileFilter(loadedPlugIns, "All supported Audio Files", true);
         this.Cursor           = Cursors.Default;
         // lets see what we have received...
         if (loadedPlugIns != null)
         {
             foreach (string file in loadedPlugIns.Values)
             {
                 this.listBox1.Items.Add(file);
             }
             foreach (int plugin in loadedPlugIns.Keys)
             {
                 BASS_PLUGININFO pluginInfo = Bass.BASS_PluginGetInfo(plugin);
                 // or this might also be used as an alternative:
                 //BASS_PLUGININFO pluginInfo = new BASS_PLUGININFO( Bass.BASS_PluginGetInfoPtr(plugin) );
                 foreach (BASS_PLUGINFORM formats in pluginInfo.formats)
                 {
                     Console.WriteLine(formats.ToString());
                 }
             }
             Console.WriteLine(Utils.BASSAddOnGetPluginFileFilter(loadedPlugIns, "All supported Audio Files", true));
             Console.WriteLine(Utils.BASSAddOnGetPluginFileFilter(loadedPlugIns, null, false));
         }
         else
         {
             MessageBox.Show(this, "No BASS add-on loaded!");
         }
     }
 }
Пример #5
0
        static BassProxy()
        {
            // Call to avoid the freeware splash screen. Didn't see it, but maybe it will appear if the Forms are used :D
            BassNet.Registration("*****@*****.**", "2X155323152222");

            //Dummy calls made for loading the assemblies
            int bassVersion    = Bass.BASS_GetVersion();
            int bassMixVersion = BassMix.BASS_Mixer_GetVersion();
            int bassfxVersion  = BassFx.BASS_FX_GetVersion();

                        #if DEBUG
            Debug.WriteLine("Bass Version: {0}, Mix Version: {1}, FX Version: {2}", bassVersion, bassMixVersion, bassfxVersion);
                        #endif

            //Set Sample Rate / MONO
            //if (Bass.BASS_Init(-1, DEFAULT_SAMPLE_RATE, BASSInit.BASS_DEVICE_SPEAKERS | BASSInit.BASS_DEVICE_MONO | BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            if (Bass.BASS_Init(-1, DEFAULT_SAMPLE_RATE, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            {
                // Load the plugins
                int pluginFlac = Bass.BASS_PluginLoad("bassflac.dll");
                int pluginAAC  = Bass.BASS_PluginLoad("bass_aac.dll");
                int pluginMPC  = Bass.BASS_PluginLoad("bass_mpc.dll");
                int pluginAC3  = Bass.BASS_PluginLoad("bass_ac3.dll");
                int pluginWMA  = Bass.BASS_PluginLoad("basswma.dll");
                int pluginAPE  = Bass.BASS_PluginLoad("bass_ape.dll");

                if (pluginFlac == 0 ||
                    pluginAAC == 0 ||
                    pluginMPC == 0 ||
                    pluginAC3 == 0 ||
                    pluginWMA == 0 ||
                    pluginAPE == 0)
                {
                    throw new Exception(Bass.BASS_ErrorGetCode().ToString());
                }

                                #if DEBUG
                BASS_INFO info = new BASS_INFO();
                Bass.BASS_GetInfo(info);
                Debug.WriteLine(info.ToString());

                string nativeSupport = Utils.BASSAddOnGetSupportedFileExtensions(null);
                Debug.WriteLine("Native Bass Supported Extensions: " + nativeSupport);

                BASS_PLUGININFO flacInfo = Bass.BASS_PluginGetInfo(pluginFlac);
                foreach (BASS_PLUGINFORM f in flacInfo.formats)
                {
                    Debug.WriteLine("Type={0}, Name={1}, Exts={2}", f.ctype, f.name, f.exts);
                }
                BASS_PLUGININFO aacInfo = Bass.BASS_PluginGetInfo(pluginAAC);
                foreach (BASS_PLUGINFORM f in aacInfo.formats)
                {
                    Debug.WriteLine("Type={0}, Name={1}, Exts={2}", f.ctype, f.name, f.exts);
                }
                BASS_PLUGININFO mpcInfo = Bass.BASS_PluginGetInfo(pluginMPC);
                foreach (BASS_PLUGINFORM f in mpcInfo.formats)
                {
                    Debug.WriteLine("Type={0}, Name={1}, Exts={2}", f.ctype, f.name, f.exts);
                }
                BASS_PLUGININFO ac3Info = Bass.BASS_PluginGetInfo(pluginAC3);
                foreach (BASS_PLUGINFORM f in ac3Info.formats)
                {
                    Debug.WriteLine("Type={0}, Name={1}, Exts={2}", f.ctype, f.name, f.exts);
                }
                BASS_PLUGININFO wmaInfo = Bass.BASS_PluginGetInfo(pluginWMA);
                foreach (BASS_PLUGINFORM f in wmaInfo.formats)
                {
                    Debug.WriteLine("Type={0}, Name={1}, Exts={2}", f.ctype, f.name, f.exts);
                }
                BASS_PLUGININFO apeInfo = Bass.BASS_PluginGetInfo(pluginAPE);
                foreach (BASS_PLUGINFORM f in apeInfo.formats)
                {
                    Debug.WriteLine("Type={0}, Name={1}, Exts={2}", f.ctype, f.name, f.exts);
                }

                Dictionary <int, string> loadedPlugIns = new Dictionary <int, string>();
                loadedPlugIns.Add(pluginFlac, "bassflac.dll");
                loadedPlugIns.Add(pluginAAC, "bass_aac.dll");
                loadedPlugIns.Add(pluginMPC, "bass_mpc.dll");
                loadedPlugIns.Add(pluginAC3, "bass_ac3.dll");
                loadedPlugIns.Add(pluginWMA, "basswma.dll");
                loadedPlugIns.Add(pluginAPE, "bass_ape.dll");

                string fileSupportedExtFilter = Utils.BASSAddOnGetPluginFileFilter(loadedPlugIns, "All supported Audio Files", true);
                Debug.WriteLine("Bass generated FileFilter: " + fileSupportedExtFilter);
                                #endif
            }
            else
            {
                throw new Exception(Bass.BASS_ErrorGetCode().ToString());
            }

            // Set filter for anti aliasing
            if (!Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_MIXER_FILTER, 50))
            {
                throw new Exception(Bass.BASS_ErrorGetCode().ToString());
            }

            // Set floating parameters to be passed
            if (!Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_FLOATDSP, true))
            {
                throw new Exception(Bass.BASS_ErrorGetCode().ToString());
            }
        }