예제 #1
0
        private void Encoder_Load(object sender, System.EventArgs e)
        {
            //BassNet.Registration("your email", "your regkey");

            if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle))
            {
                BASS_INFO info = new BASS_INFO();
                Bass.BASS_GetInfo(info);
                Console.WriteLine(info.ToString());

                _wmaPlugIn = Bass.BASS_PluginLoad("basswma.dll");
                // all fine
                int[] rates = BassWma.BASS_WMA_EncodeGetRates(44100, 2, BASSWMAEncode.BASS_WMA_ENCODE_RATES_CBR);
                foreach (int rate in rates)
                {
                    this.comboBoxRate.Items.Add(rate);
                }
                this.comboBoxRate.SelectedIndex = 0;
            }
            else
            {
                MessageBox.Show(this, "Bass_Init error!");
            }

            // init your recording device (we use the default device)
            if (!Bass.BASS_RecordInit(-1))
            {
                MessageBox.Show(this, "Bass_RecordInit error!");
            }
        }
예제 #2
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();
            }
        }
예제 #3
0
        private void ComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            BASS_INFO info = new BASS_INFO();

            if (Bass.BASS_GetInfo(info))
            {
                Channels.Content = info.ToString();
                int speakers = info.speakers;
                //if speakers
            }
        }
예제 #4
0
        /// <summary>
        /// Init sound BASS
        /// </summary>
        private void InitSound()
        {
            try
            {
                Bass.BASS_Free();
            }
            catch (Exception e)
            {
                string tx = e.Message;
                Console.Write("\n" + tx);
                MessageBox.Show(e.InnerException.Message);
                return;
            }

            int outdevice = -1;

            // int outdevice = 0;
            //int outdevice = 1;
            //int outdevice = 2;
            //int outdevice = 3;
            if (Bass.BASS_Init(outdevice, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            {
                BASS_INFO info = new BASS_INFO();
                Bass.BASS_GetInfo(info);
                Msg(info.ToString());
            }
            else
            {
                if (bTryFreeBass == false)
                {
                    if (Bass.BASS_Free() == true)
                    {
                        bTryFreeBass = true;
                        InitSound();
                        return;
                    }
                }
                else
                {
                    Console.Write(Bass.BASS_ErrorGetCode().ToString());
                    MessageBox.Show(this, "Bass_Init error!: " + Bass.BASS_ErrorGetCode().ToString());
                }
            }

            if (!Bass.BASS_RecordInit(lstRecDevices.SelectedIndex))
            {
                //MessageBox.Show(this, "Bass_RecordInit error!");
                string err = Bass.BASS_ErrorGetCode().ToString();
                Console.Write(Bass.BASS_ErrorGetCode().ToString());
                Msg(err);
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
 private void InitXMPlayer()
 {
     //-1 默认设备 0=无声音
     try
     {
         if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, new IntPtr()))
         {
             BASS_INFO info = new BASS_INFO();
             Bass.BASS_GetInfo(info);
             Debug.Log("Init Success:" + info.ToString());
         }
     }
     catch (Exception e)
     {
         Debug.LogError(e.ToString());
     }
 }
예제 #7
0
        public SM(Form form)
        {
            this.form = form;

            if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            {
                BASS_INFO info = new BASS_INFO();
                Bass.BASS_GetInfo(info);
                Console.WriteLine(info.ToString());
                _deviceLatencyMS = info.latency;
            }
            else
                Console.WriteLine("Bass_Init error!");

            // create a secure timer
            _updateTimer = new Un4seen.Bass.BASSTimer(_updateInterval);
            _updateTimer.Tick += new EventHandler(timerUpdate_Tick);

            _sync = new SYNCPROC(EndPosition);

            th = new Thread(new ThreadStart(DelegateValueUpdate));
            th.Start();
        }
예제 #8
0
        private void InitSound()
        {
            try
            {
                Bass.BASS_Free();
            }
            catch (Exception e)
            {
                string tx = e.Message;
                Console.Write("\n" + tx);
                MessageBox.Show(e.InnerException.Message);
                return;
            }


            //if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            //if (Bass.BASS_Init(lstDevices.SelectedIndex, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            {
                BASS_INFO info = new BASS_INFO();
                Bass.BASS_GetInfo(info);
                Msg(info.ToString());
            }
            else
            {
                if (bTryFreeBass == false)
                {
                    if (Bass.BASS_Free() == true)
                    {
                        bTryFreeBass = true;
                        InitSound();
                        return;
                    }
                }
                else
                {
                    Console.Write(Bass.BASS_ErrorGetCode().ToString());
                    MessageBox.Show(this, "Bass_Init error!: " + Bass.BASS_ErrorGetCode().ToString());
                }
            }

            /*
             * BASS_DEVICEINFO[] devs = Bass.BASS_RecordGetDeviceInfos();
             * foreach (BASS_DEVICEINFO dev in devs)
             * {
             *  Msg(dev.name);
             *
             * }
             */

            // init your recording device (we use the default device)
            Bass.BASS_RecordFree();

            /*
             * if (!Bass.BASS_RecordInit(-1))
             *  MessageBox.Show(this, "Bass_RecordInit error!");
             */
            if (!Bass.BASS_RecordInit(lstRecDevices.SelectedIndex))
            {
                MessageBox.Show(this, "Bass_RecordInit error!");
            }
        }
예제 #9
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());
            }
        }