Ejemplo n.º 1
0
        private void Initialize()
        {
            if (this.listBeatPositions == null)
            {
                this.listBeatPositions = new List <stBeatPos>();
            }

            #region [ BASS registration ]
            // BASS.NET ユーザ登録(BASSスプラッシュが非表示になる)。

            BassNet.Registration("*****@*****.**", "2X9181017152222");
            #endregion
            #region [ BASS Version Check ]
            // BASS のバージョンチェック。
            int nBASSVersion = Utils.HighWord(Bass.BASS_GetVersion());
            if (nBASSVersion != Bass.BASSVERSION)
            {
                throw new DllNotFoundException(string.Format("bass.dll のバージョンが異なります({0})。このプログラムはバージョン{1}で動作します。", nBASSVersion, Bass.BASSVERSION));
            }

            int nBASSFXVersion = Utils.HighWord(BassFx.BASS_FX_GetVersion());
            if (nBASSFXVersion != BassFx.BASSFXVERSION)
            {
                throw new DllNotFoundException(string.Format("bass_fx.dll のバージョンが異なります({0})。このプログラムはバージョン{1}で動作します。", nBASSFXVersion, BassFx.BASSFXVERSION));
            }
            #endregion

            #region [ BASS の設定。]
            //this.bIsBASSFree = true;
            //Debug.Assert( Bass.BASS_SetConfig( BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0 ),		// 0:BASSストリームの自動更新を行わない。(サウンド出力しないため)
            //    string.Format( "BASS_SetConfig() に失敗しました。[{0}", Bass.BASS_ErrorGetCode() ) );
            #endregion
            #region [ BASS の初期化。]
            int nデバイス = 0;                      // 0:"no sound" … BASS からはデバイスへアクセスさせない。
            int n周波数  = 44100;                  // 仮決め。lデバイス(≠ドライバ)がネイティブに対応している周波数であれば何でもいい?ようだ。いずれにしろBASSMXで自動的にリサンプリングされる。
            if (!Bass.BASS_Init(nデバイス, n周波数, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            {
                throw new Exception(string.Format("BASS の初期化に失敗しました。(BASS_Init)[{0}]", Bass.BASS_ErrorGetCode().ToString()));
            }
            #endregion

            #region [ 指定されたサウンドファイルをBASSでオープンし、必要最小限の情報を取得する。]
            //this.hBassStream = Bass.BASS_StreamCreateFile( this.filename, 0, 0, BASSFlag.BASS_STREAM_PRESCAN | BASSFlag.BASS_STREAM_DECODE );
            this.hBassStream = Bass.BASS_StreamCreateFile(this.filename, 0, 0, BASSFlag.BASS_STREAM_DECODE);
            if (this.hBassStream == 0)
            {
                throw new Exception(string.Format("{0}: サウンドストリームの生成に失敗しました。(BASS_StreamCreateFile)[{1}]", filename, Bass.BASS_ErrorGetCode().ToString()));
            }

            this.nTotalBytes = Bass.BASS_ChannelGetLength(this.hBassStream);

            this.nTotalSeconds = Bass.BASS_ChannelBytes2Seconds(this.hBassStream, nTotalBytes);
            if (!Bass.BASS_ChannelGetAttribute(this.hBassStream, BASSAttribute.BASS_ATTRIB_FREQ, ref fFreq))
            {
                string errmes = string.Format("サウンドストリームの周波数取得に失敗しました。(BASS_ChannelGetAttribute)[{0}]", Bass.BASS_ErrorGetCode().ToString());
                Bass.BASS_Free();
                throw new Exception(errmes);
            }
            #endregion
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize Bass Library
        /// </summary>
        public static void Init()
        {
            if (!_initialized)
            {
                //Call to avoid the freeware splash screen. Didn't see it, but maybe it will appear if the Forms are used :D
                BassNet.Registration("*****@*****.**", "2X113120152222");

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

                int plg = Bass.BASS_PluginLoad("bassflac.dll");
                if (plg == 0)
                {
                    throw new Exception(Bass.BASS_ErrorGetCode().ToString());
                }
                if (!Bass.BASS_Init(-1, DEFAULT_SAMPLE_RATE, BASSInit.BASS_DEVICE_DEFAULT | BASSInit.BASS_DEVICE_MONO, IntPtr.Zero)) //Set Sample Rate / MONO
                {
                    throw new Exception(Bass.BASS_ErrorGetCode().ToString());
                }
                if (!Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_SRC, 1)) /*	Качество преобразования частоты дискретизации по умолчанию. */
                {
                    throw new Exception(Bass.BASS_ErrorGetCode().ToString());
                }
                if (!Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_FLOATDSP, true)) /*Set floating parameters to be passed*/
                {
                    throw new Exception(Bass.BASS_ErrorGetCode().ToString());
                }

                _initialized = true;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize Bass Library
        /// </summary>
        public static void Init()
        {
            if (!_initialized)
            {
                //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    = Un4seen.Bass.Bass.BASS_GetVersion();
                int bassMixVersion = BassMix.BASS_Mixer_GetVersion();
                int bassfxVersion  = BassFx.BASS_FX_GetVersion();

                int plg = Un4seen.Bass.Bass.BASS_PluginLoad("bassflac.dll");
                if (plg == 0)
                {
                    throw new Exception(Un4seen.Bass.Bass.BASS_ErrorGetCode().ToString());
                }
                if (!Un4seen.Bass.Bass.BASS_Init(-1, DEFAULT_SAMPLE_RATE, BASSInit.BASS_DEVICE_DEFAULT | BASSInit.BASS_DEVICE_MONO, IntPtr.Zero))                 //Set Sample Rate / MONO
                {
                    throw new Exception(Un4seen.Bass.Bass.BASS_ErrorGetCode().ToString());
                }
                if (!Un4seen.Bass.Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_MIXER_FILTER, 50))                 /*Set filter for anti aliasing*/
                {
                    throw new Exception(Un4seen.Bass.Bass.BASS_ErrorGetCode().ToString());
                }
                if (!Un4seen.Bass.Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_FLOATDSP, true))                 /*Set floating parameters to be passed*/
                {
                    throw new Exception(Un4seen.Bass.Bass.BASS_ErrorGetCode().ToString());
                }

                _initialized = true;
            }
        }
Ejemplo n.º 4
0
 private static void LoadLibraries()
 {
     BassEnc.BASS_Encode_GetVersion();
     BassMix.BASS_Mixer_GetVersion();
     BassFx.BASS_FX_GetVersion();
     Bass.BASS_GetVersion();
 }
Ejemplo n.º 5
0
 private void SimpleFX_Load(object sender, System.EventArgs e)
 {
     if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_SPEAKERS, this.Handle))
     {
         // all ok
         // load BASS_FX
         BassFx.BASS_FX_GetVersion();
     }
     else
     {
         MessageBox.Show(this, "Bass_Init error!");
     }
 }
Ejemplo n.º 6
0
        public void BassInit()
        {
            if (Global.EngineOnline)
            {
                //eq.intializeEQ();
                foreach (FxItem i in Stack.Children)
                {
                    i.Direct2Def();
                }
                BassFx.BASS_FX_GetVersion();

                BassEngine engine = BassEngine.Instance;
                engine.PropertyChanged += PropertyChanged;
            }
        }
Ejemplo n.º 7
0
        private void mainForm_Load(object sender, EventArgs e)
        {
            // Подгружаем BASS
            if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_SPEAKERS, this.Handle))
            {
                BASS_INFO info = new BASS_INFO();
                Bass.BASS_GetInfo(info);
                debugInfo.Text += info + "\n" + BassFx.BASS_FX_GetVersion();

                Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 200);
                Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, 1000);
            }
            else
            {
                MessageBox.Show(this, "BASS_Init() не сработал, басов не будет");
                Close();
            }
        }
Ejemplo n.º 8
0
 public int GetFxVersion()
 {
     return(BassFx.BASS_FX_GetVersion());
 }
 private void DummyCallToLoadBassLibraries()
 {
     Bass.BASS_GetVersion();
     BassMix.BASS_Mixer_GetVersion();
     BassFx.BASS_FX_GetVersion();
 }
Ejemplo n.º 10
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());
            }
        }