Exemple #1
0
        internal AudioPlayable(IAudio audio, IAudioStorage storage, IWebDownloader downloader, Uri url)
        {
            __Audio = audio;
            __Storage = storage;
            __Downloader = downloader;
            __Url = url;

            __BassFileProcs = new BASS_FILEPROCS(user => { },
                                                 user => 
                                                     __CacheStream.AudioSize,
                                                 BassReadProc,
                                                 (offset, user) => true);

            __EndStreamProc = (handle, channel, data, user) =>
            {
                __RequestTasksStop = true;
                CleanActions();
                OnAudioNaturallyEnded();
            };

            if (storage.CheckCached(audio))
            {
                DownloadedFracion = 1.0;
            }
        }
Exemple #2
0
 public bool Play(string fullPath)
 {
     if (State != ChannelStates.Ready)
     {
         throw new NotSupportedException($"ChannelState not valid! [ChannelState = {State.ToString()}]");
     }
     Stream = GetStream(fullPath);
     if (Stream != 0)
     {
         var playBackStartSyncProc  = new SYNCPROC(playBackStartCallback);
         var playBackEndSyncProc    = new SYNCPROC(playBackEndCallBack);
         var playBackPausedSyncProc = new SYNCPROC(playBackPausedCallBack);
         Bass.BASS_ChannelSetSync(Stream, BASSSync.BASS_SYNC_POS | BASSSync.BASS_SYNC_MIXTIME, 0, playBackStartSyncProc, IntPtr.Zero);
         Bass.BASS_ChannelSetSync(Stream, BASSSync.BASS_SYNC_END | BASSSync.BASS_SYNC_MIXTIME, 0, playBackEndSyncProc, IntPtr.Zero);
         Bass.BASS_ChannelSetSync(Stream, BASSSync.BASS_SYNC_STALL | BASSSync.BASS_SYNC_MIXTIME, 0, playBackPausedSyncProc, IntPtr.Zero);
         if (Bass.BASS_ChannelPlay(Stream, false))
         {
             State = ChannelStates.Playing;
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
        private BassEngine(BASS_DEVICEINFO deviceInfo = null)
        {
            this.PlayCommand = new DelegateCommand(() =>
            {
                if (!IsPlaying)
                {
                    Play();
                }
            }, () => this.CanPlay);

            this.PauseCommand = new DelegateCommand(() =>
            {
                if (IsPlaying)
                {
                    Pause();
                }
            }, () => this.CanPause);

            this.StopCommand = new DelegateCommand(() => Stop(), () => CanStop);

            Initialize(deviceInfo);
            endTrackSyncProc = (handle, channel, data, user) =>
            {
                OnTrackEnded();
            };
        }
 protected void PlayStream()
 {
     Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
     sync = BASS_PlaybackEnded;
     Bass.BASS_ChannelSetSync(handle, BASSSync.BASS_SYNC_END, 0, sync, IntPtr.Zero);
     Bass.BASS_ChannelPlay(handle, false);
 }
Exemple #5
0
        public Channel(int nr, string file, float bpm, int length, Form1 form)
        {
            this.form   = form;
            this.bpm    = bpm;
            this.nr     = nr;
            this.length = length;

            measure = 0;
            random  = new Random(Guid.NewGuid().GetHashCode());

            // GUI stuff
            form.InitTrackbar(nr, length);
            form.SetTrackbar(nr, 0);

            // load track
            channel = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_DEFAULT);
            if (channel == 0)
            {
                throw new System.ArgumentException("Error: " + channel + " Can not load sample", file);
            }

            // init sync point for callback
            sync       = new SYNCPROC(LoopEnd);
            synchandle = Bass.BASS_ChannelSetSync(channel, BASSSync.BASS_SYNC_POS | BASSSync.BASS_SYNC_MIXTIME, MeasuresToBytes(1), sync, IntPtr.Zero);
        }
        /// <summary>
        /// Fade Out  Procedure
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="stream"></param>
        /// <param name="data"></param>
        /// <param name="userData"></param>
        private void PlaybackCrossFadeProc(int handle, int stream, int data, IntPtr userData)
        {
            new Thread(() =>
            {
                try
                {
                    Log.Debug("BASS: X-Fading out stream {0}", _filePath);

                    // We want to get informed, when Crossfading has ended
                    _playBackSlideEndDelegate = new SYNCPROC(SlideEndedProc);
                    Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_SLIDE, 0, _playBackSlideEndDelegate,
                                             IntPtr.Zero);

                    _crossFading = true;
                    Bass.BASS_ChannelSlideAttribute(stream, BASSAttribute.BASS_ATTRIB_VOL, 0,
                                                    Config.CrossFadeIntervalMs);
                }
                catch (AccessViolationException)
                {
                    Log.Error("BASS: Caught AccessViolationException in Crossfade Proc");
                }
            }
                       )
            {
                Name = "BASS X-Fade"
            }.Start();
        }
 public WASAPIOutputDevice(Controller controller)
   : base(controller)
 {
   _streamWriteProcDelegate = OutputStreamWriteProc;
   _onPlaybackEndDelegate = OnPlaybackEnd;
   _deviceNo = GetDeviceNo();
 }
Exemple #8
0
        internal AudioPlayable(IAudio audio, IAudioStorage storage, IWebDownloader downloader, Uri url)
        {
            __Audio      = audio;
            __Storage    = storage;
            __Downloader = downloader;
            __Url        = url;

            __BassFileProcs = new BASS_FILEPROCS(user => { },
                                                 user =>
                                                 __CacheStream.AudioSize,
                                                 BassReadProc,
                                                 (offset, user) => true);

            __EndStreamProc = (handle, channel, data, user) =>
            {
                __RequestTasksStop = true;
                CleanActions();
                OnAudioNaturallyEnded();
            };

            if (storage.CheckCached(audio))
            {
                DownloadedFracion = 1.0;
            }
        }
 public WASAPIOutputDevice(Controller controller)
     : base(controller)
 {
     _streamWriteProcDelegate = OutputStreamWriteProc;
     _onPlaybackEndDelegate   = OnPlaybackEnd;
     _deviceNo = GetDeviceNo();
 }
Exemple #10
0
        private void Simple_Load(object sender, System.EventArgs e)
        {
            // BassNet.Registration("your email", "your regkey");

            if (!Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle))
            {
                MessageBox.Show(this, "Bass_Init error!");
                this.Close();
                return;
            }
            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, 200);
            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 20);

            // already create a mixer
            _mixer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_SAMPLE_FLOAT);
            if (_mixer == 0)
            {
                MessageBox.Show(this, "Could not create mixer!");
                Bass.BASS_Free();
                this.Close();
                return;
            }

            _mixerStallSync = new SYNCPROC(OnMixerStall);
            Bass.BASS_ChannelSetSync(_mixer, BASSSync.BASS_SYNC_STALL, 0L, _mixerStallSync, IntPtr.Zero);

            timerUpdate.Start();
            Bass.BASS_ChannelPlay(_mixer, false);
        }
        public AudioPlayer()
        {
            InitializeComponent();
            timerUpdate = new Timer();

            this.timerUpdate.Interval = 50;
            this.timerUpdate.Elapsed += new ElapsedEventHandler(timerUpdate_Elapsed);
            this.pictureBoxWaveForm.MouseDown += new MouseButtonEventHandler(pictureBoxWaveForm_MouseDown);
            this.wavePosition.MouseDown += new MouseButtonEventHandler(pictureBoxWaveForm_MouseDown);
            
            
            this.wavePosition.Width = 2;
            this.wavePosition.Height = this.pictureBoxWaveForm.Height;
            this.wavePosition.Opacity = 0.5;
            this.wavePosition.Fill = Brushes.Red;

           
            _mixer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_SAMPLE_FLOAT);
            if (_mixer == 0)
            {
                MessageBox.Show("Could not create mixer!");
                Bass.BASS_Free();
                return;
            }

            _mixerStallSync = new SYNCPROC(OnMixerStall);
            Bass.BASS_ChannelSetSync(_mixer, BASSSync.BASS_SYNC_STALL, 0L, _mixerStallSync, IntPtr.Zero);

            timerUpdate.Start();
            Bass.BASS_ChannelPlay(_mixer, false);


            newtrack(@"D:\OAIBC\2-13 California.mp3", null);

        }
Exemple #12
0
        public override void Initialize(int deviceid)
        {
            Bass.BASS_SetDevice(deviceid);

            int handle = Bass.BASS_StreamCreateFile(this.filename, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);

            BASSFlag flag = BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_FX_FREESOURCE;

            if (this.IsDecoding)
            {
                flag = flag | BASSFlag.BASS_STREAM_DECODE;
            }

            if (this.Mono)
            {
                flag = flag | BASSFlag.BASS_SAMPLE_MONO;
            }

            handle = BassFx.BASS_FX_TempoCreate(handle, flag);

            long len = Bass.BASS_ChannelGetLength(handle);

            this.Length = Bass.BASS_ChannelBytes2Seconds(handle, len);

            this.BassHandle = handle;

            _syncProc = new SYNCPROC(TrackSync);

            // setup a new sync
            Bass.BASS_ChannelSetSync(handle, BASSSync.BASS_SYNC_END, 0, _syncProc, IntPtr.Zero);

            this.OnInitialize();
        }
Exemple #13
0
        public void playStream()
        {
            // set a sync to get the title updates out of the meta data...
            mySync = new SYNCPROC(MetaSync);
            Bass.BASS_ChannelSetSync(_Stream, BASSSync.BASS_SYNC_META, 0, mySync, IntPtr.Zero);
            Bass.BASS_ChannelSetSync(_Stream, BASSSync.BASS_SYNC_WMA_CHANGE, 0, mySync, IntPtr.Zero);

            //// start recording...
            //int rechandle = 0;
            //if (Bass.BASS_RecordInit(-1))
            //{
            //    _byteswritten = 0;
            //    myRecProc = new RECORDPROC(MyRecoring);
            //    rechandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, myRecProc, IntPtr.Zero);
            //}
            ////this.statusBar1.Text = "Playling...";

            // play the stream

            try
            {
                Bass.BASS_ChannelPlay(_Stream, false);
            }
            catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); }
            // record the stream
            //Bass.BASS_ChannelPlay(rechandle, false);
        }
Exemple #14
0
        /// <summary>
        /// Fade Out  Procedure
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="stream"></param>
        /// <param name="data"></param>
        /// <param name="userData"></param>
        private void PlaybackCrossFadeProc(int handle, int stream, int data, IntPtr userData)
        {
            new Thread(() =>
            {
                try
                {
                    Log.Debug("BASS: X-Fading out stream {0}", _filePath);

                    if (Config.CrossFadeIntervalMs > 0)
                    {
                        // Only sent GUI_MSG_PLAYBACK_CROSSFADING when gapless/crossfading mode is used
                        GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_CROSSFADING, 0, 0,
                                                        0, 0, 0, null);
                        GUIWindowManager.SendThreadMessage(msg);
                    }

                    // We want to get informed, when Crossfading has ended
                    _playBackSlideEndDelegate = new SYNCPROC(SlideEndedProc);
                    Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_SLIDE, 0, _playBackSlideEndDelegate,
                                             IntPtr.Zero);

                    _crossFading = true;
                    Bass.BASS_ChannelSlideAttribute(stream, BASSAttribute.BASS_ATTRIB_VOL, 0,
                                                    Config.CrossFadeIntervalMs);
                }
                catch (AccessViolationException)
                {
                    Log.Error("BASS: Caught AccessViolationException in Crossfade Proc");
                }
            }
                       )
            {
                Name = "BASS X-Fade"
            }.Start();
        }
Exemple #15
0
        public static bool Init()
        {
            #region dumb obfuscation for email and registration key, just to prevent bots.
            byte   obfu = 0xDA;
            byte[] eml  = new byte[]
            {
                0xBE, 0xBB, 0xB4, 0xBF, 0x9A, 0xA2, 0xBB, 0xA3, 0xA8, 0xF4, 0xBD, 0xBB,
            };

            byte[] rkey = new byte[]
            {
                0xE8, 0x82, 0xE3, 0xE9, 0xE8, 0xE9, 0xEB, 0xE8, 0xEE, 0xE9, 0xE9,
            };
            for (int i = 0; i < eml.Length; i++)
            {
                eml[i] ^= (obfu);
            }
            for (int i = 0; i < rkey.Length; i++)
            {
                rkey[i] ^= (obfu);
            }
            #endregion
            Un4seen.Bass.BassNet.Registration(Encoding.ASCII.GetString(eml), Encoding.ASCII.GetString(rkey));
            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); // Initialize audio engine
            BassFx.LoadMe();
            BASS_DEVICEINFO info = new BASS_DEVICEINFO();                         // Print device info.
            for (int n = 0; Bass.BASS_GetDeviceInfo(n, info); n++)
            {
                //Console.WriteLine(info.ToString());
            }
            globalLoopProc = new SYNCPROC(DoLoop);
            return(true);
        }
        public void MusicUpdate()
        {
            if (m_NewMusic != "")
            {
                float maxVolume = GlobalSettings.Default.MusicVolume / 10.0f;
                m_MusicFade -= 1.0 / 60.0;
                if (m_MusicChannel != -1)
                {
                    Bass.BASS_ChannelSetAttribute(m_MusicChannel, BASSAttribute.BASS_ATTRIB_VOL, maxVolume * (float)Math.Max(0, (m_MusicFade - 0.5) / 1.5));
                }
                if (m_MusicFade <= 0)
                {
                    if (m_MusicChannel != -1)
                    {
                        Bass.BASS_ChannelStop(m_MusicChannel);
                    }
                    if (m_NewMusic != "none")
                    {
                        m_MusicChannel = LoadMusicTrack(m_NewMusic, 1, false);
                        Bass.BASS_ChannelSetAttribute(m_MusicChannel, BASSAttribute.BASS_ATTRIB_VOL, maxVolume);
                        m_EndedEvent = new SYNCPROC(MusicEnded);

                        Bass.BASS_ChannelSetSync(m_MusicChannel, BASSSync.BASS_SYNC_END, 0, m_EndedEvent, (IntPtr)0);
                        m_MusicFade = 2;
                    }
                    m_NewMusic = "";
                }
            }
        }
Exemple #17
0
        private static void syncCallback(int handle, int channel, int data, IntPtr user)
        {
            Console.WriteLine("sync at " + user.ToInt32());
            SYNCPROC proc = syncCallback;

            Bass.BASS_ChannelSetSync(handle, BASSSync.BASS_SYNC_POS, user.ToInt32() + 100000, proc,
                                     new IntPtr(user.ToInt32() + 100000));
        }
        public SamplePlayer()
        {
            endTrackSyncProc = EndTrack;
            repeatSyncProc = RepeatCallback;

            positionTimer.Interval = TimeSpan.FromMilliseconds(50);
            positionTimer.Tick += positionTimer_Tick;
        }
Exemple #19
0
        public void StreamAddChannel(int channel, SYNCPROC trackSync)
        {
            //BassMix.BASS_Mixer_StreamAddChannel(Player.Mixer, channel, BASSFlag.BASS_MIXER_PAUSE | BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_MIXER_DOWNMIX);
            BassMix.BASS_Mixer_StreamAddChannel(Player.Mixer, channel, BASSFlag.BASS_MIXER_PAUSE | BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_STREAM_AUTOFREE);

            // an BASS_SYNC_END is used to trigger the next track in the playlist (if no POS sync was set)
            BassMix.BASS_Mixer_ChannelSetSync(channel, BASSSync.BASS_SYNC_END, 0L, trackSync, new IntPtr(1));
        }
Exemple #20
0
 private void Play_B_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if (IsClosing)
     {
         return;
     }
     if (Sound_List.SelectedIndex == -1 && Change_List.SelectedIndex == -1)
     {
         return;
     }
     else if (Sound_List.SelectedIndex != -1 && !File.Exists(Voice_Set.Special_Path + "/Wwise/Temp_01.ogg"))
     {
         Message_Feed_Out("サウンドファイルが変換されませんでした。");
         return;
     }
     else if (Change_List.SelectedIndex != -1 && !File.Exists(Change_Sound_Full_Name[Change_List.SelectedIndex]))
     {
         Message_Feed_Out("選択されたファイルが存在しません。");
         return;
     }
     if (SelectIndex == Sound_List.SelectedIndex || SelectIndex == Change_List.SelectedIndex)
     {
         Bass.BASS_ChannelPlay(Stream, false);
     }
     else
     {
         Bass.BASS_ChannelStop(Stream);
         Location_S.Value = 0;
         Bass.BASS_StreamFree(Stream);
         if (Sound_List.SelectedIndex != -1)
         {
             int StreamHandle = Bass.BASS_StreamCreateFile(Voice_Set.Special_Path + "/Wwise/Temp_01.ogg", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_LOOP);
             Stream      = BassFx.BASS_FX_TempoCreate(StreamHandle, BASSFlag.BASS_FX_FREESOURCE);
             SelectIndex = Sound_List.SelectedIndex;
         }
         else if (Change_List.SelectedIndex != -1)
         {
             int StreamHandle = Bass.BASS_StreamCreateFile(Change_Sound_Full_Name[Change_List.SelectedIndex], 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_LOOP);
             Stream      = BassFx.BASS_FX_TempoCreate(StreamHandle, BASSFlag.BASS_FX_FREESOURCE);
             SelectIndex = Change_List.SelectedIndex;
         }
         else
         {
             Message_Feed_Out("エラーが発生しました。");
             return;
         }
         IsMusicEnd = new SYNCPROC(EndSync);
         Bass.BASS_ChannelSetDevice(Stream, Video_Mode.Sound_Device);
         Bass.BASS_ChannelSetSync(Stream, BASSSync.BASS_SYNC_END | BASSSync.BASS_SYNC_MIXTIME, 0, IsMusicEnd, IntPtr.Zero);
         Bass.BASS_ChannelPlay(Stream, true);
         Bass.BASS_ChannelSetAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, (float)Volume_S.Value / 100);
         Bass.BASS_ChannelGetAttribute(Stream, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, ref SetFirstFreq);
         Bass.BASS_ChannelSetAttribute(Stream, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, SetFirstFreq + (float)Speed_S.Value);
         Location_S.Maximum = Bass.BASS_ChannelBytes2Seconds(Stream, Bass.BASS_ChannelGetLength(Stream, BASSMode.BASS_POS_BYTES));
     }
     IsPaused = false;
 }
        /// <summary>
        ///   Register the Playback Events
        /// </summary>
        private void RegisterPlaybackEvents()
        {
            log.Debug("Player: Register Stream Playback events");

            PlaybackEndProcDelegate = new SYNCPROC(PlaybackEndProc);
            _syncHandleEnd          = RegisterPlaybackEndEvent();

            log.Debug("Player: Finished Registering Stream Playback events");
        }
Exemple #22
0
 public void UnloadFile()
 {
     if (this.stream.HasValue)
     {
         Bass.BASS_StreamFree(this.stream.Value);
         this.stream = null;
         this.syncProc = null;
     }
 }
Exemple #23
0
 protected void PlayStream()
 {
     if (handle != 0)
     {
         Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
         sync = BASS_PlaybackEnded;
         Bass.BASS_ChannelSetSync(handle, BASSSync.BASS_SYNC_END, 0, sync, IntPtr.Zero);
         Bass.BASS_ChannelPlay(handle, false);
     }
 }
Exemple #24
0
        /// <summary>
        /// Instantiate an AudioPlayer and initializes the default audio device.
        /// </summary>
        public AudioPlayer()
        {
            pluginFlac = Bass.BASS_PluginLoad("bassflac.dll");
            pluginAac  = Bass.BASS_PluginLoad("bass_aac.dll");

            EndTrackDelegate      = new SYNCPROC(EndTrackProc);
            ScrobbleTrackDelegate = new SYNCPROC(ScrobbleTrackProc);

            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, System.IntPtr.Zero);
        }
        public BassNetMediaPlayer()
        {
            InitBass(_sampleFrequency);
            InitBassMixer(_sampleFrequency);
            InitBassEncoder(_sampleFrequency, _httpBitrate);
            InitBassServer(PortNumber);

            _syncCallback = SyncCallback;
            myClientProc = clientProc;
        }
Exemple #26
0
        private BassEngine()
        {
            Initialize();
            endTrackSyncProc = EndTrack;
            repeatSyncProc   = RepeatCallback;

            waveformGenerateWorker.DoWork                    += waveformGenerateWorker_DoWork;
            waveformGenerateWorker.RunWorkerCompleted        += waveformGenerateWorker_RunWorkerCompleted;
            waveformGenerateWorker.WorkerSupportsCancellation = true;
        }
Exemple #27
0
        /// <summary>
        /// Instantiate an AudioPlayer and initializes the default audio device.
        /// </summary>
        public AudioPlayer()
        {
            pluginFlac = Bass.BASS_PluginLoad("bassflac.dll");
            pluginAac = Bass.BASS_PluginLoad("bass_aac.dll");

            EndTrackDelegate = new SYNCPROC(EndTrackProc);
            ScrobbleTrackDelegate = new SYNCPROC(ScrobbleTrackProc);

            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, System.IntPtr.Zero);
        }
Exemple #28
0
        private BassEngine()
        {
            Initialize();
            endTrackSyncProc = EndTrack;
            repeatSyncProc = RepeatCallback;

            waveformGenerateWorker.DoWork += waveformGenerateWorker_DoWork;
            waveformGenerateWorker.RunWorkerCompleted += waveformGenerateWorker_RunWorkerCompleted;
            waveformGenerateWorker.WorkerSupportsCancellation = true;
        }
 public void RadioSelected()
 {
     SetRadio();
     wnd_radio = new RadioWindow(this);
     metaSync  = new SYNCPROC(onMetaReceive);
     Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_META, 0, metaSync, IntPtr.Zero);
     Play();
     wnd_radio.ShowDialog(wnd);
     FreeStream();
     wnd_radio = null;
 }
Exemple #30
0
 /// <summary>
 /// Constructor for the Bass Wrapper Class
 /// </summary>
 /// <param name="handle">Window Handle</param>
 public BassWrapper(IntPtr handle)
 {
     //############### BASS - REGISTRATION #####################
     //BassNet.Registration("*****@*****.**", "key");
     //############### BASS - INITIATION #######################
     Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, handle, null);
     //############### BASS - VISUAL INITIATION ################
     this.vis = new Visuals();
     //############### BASS - SYNCPROC INITIATION (End of Song Procedure)
     mySync = new SYNCPROC(EndSync);
 }
Exemple #31
0
        public Player(int deviceNumber)
        {
            _playlist = new Playlist(this);

            InitBassLibrary(deviceNumber);

            _timer          = new System.Timers.Timer(100);
            _timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);

            _meta_proc = new SYNCPROC(meta_sync);
        }
Exemple #32
0
        /// <summary>
        /// Sets up a synchronizer on a MOD music, stream or recording channel.
        /// </summary>
        /// <param name="handle">The channel handle... a HMUSIC, HSTREAM or HRECORD. </param>
        /// <param name="type">The type of sync (see the table below). The following flags may also be used.
        /// BASS_SYNC_MIXTIME Call the sync function immediately when the sync is triggered, instead of delaying the call until the sync event is actually heard. This is automatic with some sync types (see table below), and always with decoding and recording channels, as they cannot be played/heard.
        /// BASS_SYNC_ONETIME Call the sync only once and then remove it from the channel.
        /// BASS_SYNC_THREAD Call the sync asynchronously in the dedicated sync thread.This only affects mixtime syncs (except BASS_SYNC_FREE syncs) and allows the callback function to safely call BASS_StreamFree or BASS_MusicFree on the same channel handle.</param>
        /// <param name="param">The sync parameter. Depends on the sync type... see the table below. </param>
        /// <param name="proc">The callback function. </param>
        /// <param name="user">User instance data to pass to the callback function. </param>
        /// <returns>If successful, then the new synchronizer's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code. </returns>
        public static int ChannelSetSync(int handle, BASSSync type, long param, SYNCPROC proc, IntPtr user)
        {
            int result = NativeMethods.BASS_ChannelSetSync(handle, type, param, proc, user);

            if (result == 0)
            {
                throw new WavException(BassErrorCode.GetErrorInfo());
            }

            return(result);
        }
Exemple #33
0
        public FilePlayer()
        {
            m_EndSync      = new SYNCPROC(EndSync);
            m_CueOutSync   = new SYNCPROC(CueOutSync);
            m_FadeOutSync  = new SYNCPROC(FadeOutSync);
            m_LoopSync     = new SYNCPROC(LoopSync);
            m_StopSync     = new SYNCPROC(StopSync);
            m_RunningFiles = new Dictionary <int, RunningFileInfo>();
#if MONO
            m_GCHandles = new Dictionary <int, System.Runtime.InteropServices.GCHandle>();
#endif
        }
        public HttpInfinitePlaySource(string address, DownloadTypes downloadMode,
            IEventAggregator positionEventAggregator)
        {
            OnGetPosition += RefreshPositions;
            _positionEventAggregator = positionEventAggregator;
            _subscriptionToken = _positionEventAggregator.GetEvent<HttpPositionEvent>().Subscribe(GetReadPosition);
            _downloadType = downloadMode;
            _downloadProcURL = (_downloadType == DownloadTypes.NoDownload)
                ? null
                : new DOWNLOADPROC(DownloadProc);

            Path = address;

            DownloadStream = Bass.BASS_StreamCreateURL(Path, 0,
                BASSFlag.BASS_STREAM_AUTOFREE|BASSFlag.BASS_STREAM_STATUS |BASSFlag.BASS_SAMPLE_FLOAT, _downloadProcURL, IntPtr.Zero);

            BASSError error = Bass.BASS_ErrorGetCode();

            if (DownloadStream == 0)
                throw new ArgumentException("Parameter cannot be null", error.ToString());

            _syncProcMeta = new SYNCPROC(SyncMethodMeta);

            Bass.BASS_ChannelSetSync(DownloadStream, BASSSync.BASS_SYNC_WMA_META, 0, _syncProcMeta, IntPtr.Zero);
            Bass.BASS_ChannelSetSync(DownloadStream, BASSSync.BASS_SYNC_OGG_CHANGE, 0, _syncProcMeta, IntPtr.Zero);
            Bass.BASS_ChannelSetSync(DownloadStream, BASSSync.BASS_SYNC_META, 0, _syncProcMeta, IntPtr.Zero);
            Bass.BASS_ChannelSetSync(DownloadStream, BASSSync.BASS_SYNC_WMA_CHANGE, 0, _syncProcMeta, IntPtr.Zero);

            _previousTags = new List<Tag>();
            Tags = new TrackTags(DownloadStream, SourceType);
            Tags.GetIcyMetaTags(DownloadStream);
            ChannelInfo = Bass.BASS_ChannelGetInfo(DownloadStream);

            if (ProcessMusic())
            {
                _bufferFileStream = new FileStream("RadioBuffer", FileMode.OpenOrCreate, FileAccess.ReadWrite);
                _DSPHandler = new DSPPROC(DSPProc);
                _streamProc = new STREAMPROC(StreamRead);
                DSP = Bass.BASS_ChannelSetDSP(DownloadStream, _DSPHandler, IntPtr.Zero, 0);
                Stream = Bass.BASS_StreamCreate(ChannelInfo.freq, ChannelInfo.chans,
                    BASSFlag.BASS_STREAM_DECODE|BASSFlag.BASS_SAMPLE_FLOAT, _streamProc, IntPtr.Zero);

                Bass.BASS_ChannelPlay(DownloadStream, false);
                Bass.BASS_ChannelSetAttribute(DownloadStream, BASSAttribute.BASS_ATTRIB_VOL, 0);
                StreamFX = BassFx.BASS_FX_TempoCreate(Stream, BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_SAMPLE_FX);
            }
            else
            {
                error = Bass.BASS_ErrorGetCode();
                throw new ArgumentException("Parameter cannot be null", error.ToString());
            }
        }
Exemple #35
0
        /// <summary>
        /// Constructor
        /// </summary>
        public BASSService()
        {
            _publisher = Publisher.Instance;

            BassNet.Registration("*****@*****.**", "2X3923118152222");
            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

            _channel = 0;
            _syncHandle = -1;
            _syncProc = OnSongEnded;
            _playbackWatcher = new Thread(WatcherRoutine) {IsBackground = true};
            _playbackWatcher.Start();
        }
Exemple #36
0
        public MusicStream(string filePath)
        {
            _fileType.FileMainType = FileMainType.Unknown;
            _channelInfo           = new BASS_CHANNELINFO();
            _filePath = filePath;

            _playbackCrossFadeProcDelegate = new SYNCPROC(PlaybackCrossFadeProc);
            _playbackEndProcDelegate       = new SYNCPROC(PlaybackEndProc);
            _cueTrackEndProcDelegate       = new SYNCPROC(CueTrackEndProc);
            _metaTagSyncProcDelegate       = new SYNCPROC(MetaTagSyncProc);

            CreateStream();
        }
        public void CreateMixerChannel()
        {
            int mixer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_MIXER_END);

            this.StreamMixer = mixer;

            if (ChannelType != CHANNEL_TYPE.REMOTE_URL)
            {
                syncProcEnd = new SYNCPROC(SyncProcEndCallback);

                mySyncHandleEnd = Bass.BASS_ChannelSetSync(mixer, BASSSync.BASS_SYNC_END, 0, syncProcEnd, IntPtr.Zero);
            }
        }
Exemple #38
0
 public void Dispose()
 {
     try { _meta_proc = null; }
     catch { }
     try { _timer.Stop(); }
     catch { }
     try { _timer.Dispose(); }
     catch { }
     try { Bass.BASS_Stop(); }
     catch { }
     try { Bass.BASS_Free(); }
     catch { }
     try { Bass.FreeMe(); }
     catch { }
 }
Exemple #39
0
        public Mp3Player()
        {
            PlaybackState = PlaybackStates.STOPPED;

            tmrUpdatePosition          = new Timer(1000);
            tmrUpdatePosition.Elapsed += TmrUpdatePosition_Elapsed;

            if (!Bass.BASS_Init(-1, 44100, 0, IntPtr.Zero))
            {
                OnException?.Invoke(this, new Exception("Failed to initialize audio device."));
            }

            playbackStopped = OnPlaybackStopped;
            playbackStalled = OnPlaybackStalled;
        }
Exemple #40
0
        public Play(MainWindow win)
        {
            BassNet.Registration("*****@*****.**", "2X2417151729148");
            var pluginDirHandle = Bass.BASS_PluginLoadDirectory(pluginDirPath);

            Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            syncProcEndStream = new SYNCPROC(endPlay);

            Config config = configManager.load();

            playlist = new PlayListWindow(win, config);
            if (config.currState == "play")
            {
                this.playSong(playlist.config.currPlay, playlist.config.currStatePosition);
            }
        }
Exemple #41
0
        public Scene()
        {
            FadeOutLength             = DEFAULT_FADEOUT_LENGTH;
            Name                      = "Unnamed Scene";
            slideSync                 = new SYNCPROC(SlideSync);
            SoundEffects.ListChanged += new ListChangedEventHandler(SoundEffects_ListChanged);
            SceneMixerChannel         = BassMix.BASS_Mixer_StreamCreate(44100, 2,
                                                                        BASSFlag.BASS_MIXER_NONSTOP |
                                                                        BASSFlag.BASS_STREAM_DECODE |
                                                                        BASSFlag.BASS_SAMPLE_FLOAT);
            BassMix.BASS_Mixer_ChannelFlags(SceneMixerChannel, BASSFlag.BASS_MIXER_NORAMPIN, BASSFlag.BASS_MIXER_NORAMPIN);
            Bass.BASS_ChannelSetSync(SceneMixerChannel, BASSSync.BASS_SYNC_SLIDE, 0, slideSync, IntPtr.Zero);

            this.SceneVolume = 1;
            this.IsFading    = false;
        }
        public PlayBarBASSVM()
        {
            PlayList = new ObservableCollection<Song>();
            _playedList = new ObservableCollection<Song>();
            _mySync = new SYNCPROC(EndSync);
            //MusicPlayer = new MusicPlayerBASS();
            Devices = BASSHelper.GetDeviceInfoList();

            //initalizing BASS
            InitBASS();
            _updateTimer = new Un4seen.Bass.BASSTimer(_updateTimerInterval);
            _updateTimer.Tick += new EventHandler(timerUpdate_Tick);

            //PlayStream();
            SelectedSoundCard = Devices[1];
        }
Exemple #43
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="deviceId">输出设备ID</param>
        /// <param name="rate">输出采样率</param>
        /// <param name="bassInit">初始化模式</param>
        /// <param name="intPtr">窗体句柄</param>
        public MusicKernel(int deviceId, int rate, BASSInit bassInit, IntPtr intPtr)
        {
            BassNet.Registration("*****@*****.**", "2X34243714232222");
            if (!Bass.BASS_Init(deviceId, rate, bassInit, intPtr))
            {
                throw new ApplicationException(" Bass初始化出错! " + Bass.BASS_ErrorGetCode().ToString());
            }

            //初始化DSP
            DSP.InitDSP(intPtr);

            PlayEndSync = new SYNCPROC(PlayEnd);
            StalledSync = new SYNCPROC(Stalled);

            controlObject.CreateControl();
        }
Exemple #44
0
        public Scene()
        {
            FadeOutLength = DEFAULT_FADEOUT_LENGTH;
            Name = "Unnamed Scene";
            slideSync = new SYNCPROC(SlideSync);
            SoundEffects.ListChanged += new ListChangedEventHandler(SoundEffects_ListChanged);
            SceneMixerChannel = BassMix.BASS_Mixer_StreamCreate(44100, 2,
                BASSFlag.BASS_MIXER_NONSTOP |
                BASSFlag.BASS_STREAM_DECODE |
                BASSFlag.BASS_SAMPLE_FLOAT);
            BassMix.BASS_Mixer_ChannelFlags(SceneMixerChannel, BASSFlag.BASS_MIXER_NORAMPIN, BASSFlag.BASS_MIXER_NORAMPIN);
            Bass.BASS_ChannelSetSync(SceneMixerChannel, BASSSync.BASS_SYNC_SLIDE, 0, slideSync, IntPtr.Zero);

            this.SceneVolume = 1;
            this.IsFading = false;
        }
 public SoundEffect()
 {
     IsLooping = false;
     LoopGap = 0;
     LoopGapVariance = 0;
     gapTimer.Interval = 1;
     SoundEffectVolume = 1;
     gapTimer.Elapsed += new System.Timers.ElapsedEventHandler(gapTimer_Elapsed);
     Samples.ListChanged += new ListChangedEventHandler(Samples_ListChanged);
     endSync = new SYNCPROC(EndSync);
     Name = "Unnamed Sound Effect";
     SoundEffectMixerChannel = BassMix.BASS_Mixer_StreamCreate(44100, 2,
         BASSFlag.BASS_MIXER_NONSTOP |
         BASSFlag.BASS_STREAM_DECODE |
         BASSFlag.BASS_SAMPLE_FLOAT);
     BassMix.BASS_Mixer_ChannelFlags(SoundEffectMixerChannel, BASSFlag.BASS_MIXER_NORAMPIN, BASSFlag.BASS_MIXER_NORAMPIN);
 }
Exemple #46
0
        public BASSSound(int streamnum)
        {
            soundstopproc = BASSCallbackStop;
            _soundStream=streamnum;
            if (!_noFx)
            {
                try
                {
                    _tempoStream = Un4seen.Bass.AddOn.Fx.BassFx.BASS_FX_TempoCreate(streamnum, (BASSFlag)0);

                }
                catch (DllNotFoundException exx)
                {
                    _noFx = true;
                    //grrr...
                    //oh well. Seems like BASS.NET ignores the call if it doesn't understand the tempo stuff.
                    _tempoStream = 0;

                }
            }
        }
Exemple #47
0
        //Konstruktor
        public Form1()
        {
            //A splash elnyomásához
            BassNet.Registration("*****@*****.**", "2X14323717152222");

            if (!Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_LATENCY, this.Handle))
                MessageBox.Show(this, "Bass_Init error!");

            //Timer a zene streamje és az UI közötti szinkronizációhoz
            _updateTimer = new Un4seen.Bass.BASSTimer(_updateInterval);
            _updateTimer.Tick += new EventHandler(timerUpdate_Tick);

            //Callback a pausekori hangerő fadehez
            pausefading = new SYNCPROC(delegate(int handle, int channel, int data, IntPtr user)
            {
                if (paused)
                    Bass.BASS_ChannelPause(channel);
            });

            nexttrack = new SYNCPROC(delegate(int handle, int channel, int data, IntPtr user)
            {
                playlist_stop_Click(null, EventArgs.Empty);
                if (playlist.Rows.Count > playlist.CurrentRow.Index + 1)
                {
                    playlist_forward_Click(null, EventArgs.Empty);
                }
            });

            InitializeComponent();
            playlist.AutoGenerateColumns = false;

            playlist.Columns[0].DataPropertyName = "asstring";
            playlist.Columns[1].DataPropertyName = "length";
            playlist.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            playlist.DataSource = trackList;
        }
Exemple #48
0
    /// <summary>
    /// Initialise the Visualisation Window and Load Decoder/DSP Plugins
    /// The BASS engine itself is not initialised at this stage, since it may cause S/PDIF for Movies not working on some systems.
    /// </summary>
    private void Initialize()
    {
      try
      {
        Log.Info("BASS: Initialize BASS environment ...");
        LoadSettings();

        BassRegistration.BassRegistration.Register();
        // Set the Global Volume. 0 = silent, 10000 = Full
        // We get 0 - 100 from Configuration, so multiply by 100
        Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_GVOL_STREAM, _StreamVolume * 100);

        if (_Mixing || _useASIO)
        {
          // In case of mixing use a Buffer of 500ms only, because the Mixer plays the complete bufer, before for example skipping
          BufferingMS = 500;
        }
        else
        {
          Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, _BufferingMS);
        }

        for (int i = 0; i < MAXSTREAMS; i++)
        {
          Streams.Add(0);
        }

        PlaybackFadeOutProcDelegate = new SYNCPROC(PlaybackFadeOutProc);
        PlaybackEndProcDelegate = new SYNCPROC(PlaybackEndProc);
        CueTrackEndProcDelegate = new SYNCPROC(CueTrackEndProc);
        PlaybackStreamFreedProcDelegate = new SYNCPROC(PlaybackStreamFreedProc);
        MetaTagSyncProcDelegate = new SYNCPROC(MetaTagSyncProc);

        StreamEventSyncHandles.Add(new List<int>());
        StreamEventSyncHandles.Add(new List<int>());

        InitializeControls();
        LoadAudioDecoderPlugins();
        LoadDSPPlugins();
        GetCDDrives();
        Log.Info("BASS: Initializing BASS environment done.");

        _Initialized = true;
        _BassFreed = true;
      }

      catch (Exception ex)
      {
        Log.Error("BASS: Initialize thread failed.  Reason: {0}", ex.Message);
      }
    }
Exemple #49
0
        /// <summary>
        /// Initialize the sound system. Only called once within the engine.
        /// </summary>
        public static void Init()
        {
            try
            {
                if (init) return;
                //This is so you don't see the dumb HERPADERP BASS IS STARTING splash screen
                BassNet.Registration("*****@*****.**", "2X2832371834322");
                Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_3D, IntPtr.Zero);

                init = true;

                //Set the distance for 3D sounds
                Bass.BASS_Set3DFactors(1.0f, 0.0f, 1.0f);
                Bass.BASS_Apply3D(); // apply the change

                //Set default volume
                SetGlobalVolume(Utilities.EngineSettings.GlobalVolume);

                _SyncDel = new SYNCPROC(SyncThink);
            }
            catch (Exception ex)
            {
                Utilities.Print("FAILED TO INITIALIZE AUDIO CONTEXT! " + ex.Message, Utilities.PrintCode.ERROR);
            }
        }
Exemple #50
0
    /// <summary>
    /// Register Slide End Event for Soft Stop
    /// </summary>
    /// <param name="stream"></param>
    /// <returns></returns>
    private void RegisterStreamSlideEndEvent(int stream)
    {
      PlayBackSlideEndDelegate = new SYNCPROC(SlideEndedProc);
      int syncHandle = Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_SLIDE, 0, PlayBackSlideEndDelegate,
                                                IntPtr.Zero);
      if (syncHandle == 0)
      {
        Log.Debug("BASS: RegisterSlideEndEvent of stream {0} failed with error {1}", stream,
                  Enum.GetName(typeof (BASSError), Bass.BASS_ErrorGetCode()));
      }

      return;
    }
        public BASSPlayer()
        {
            _VizAGC = new DSP_VizAGC();
              _ReplayGainDSP = new DSP_Gain();
              _ASIOEngine = new AsioEngine();

              _StreamWriteProcDelegate = new STREAMPROC(StreamWriteProc);
              _VizRawStreamWriteProcDelegate = new STREAMPROC(VizRawStreamWriteProc);
              _DSOutputStreamWriteProcDelegate = new STREAMPROC(DSOutputStreamWriteProc);
              _MetaTagSyncProcDelegate = new SYNCPROC(StreamMetaTagSyncProc);
              _WasapiProcDelegate = new WASAPIPROC(WasApiProc);

              // Make sure threads are stopped in case Dispose does not get called.
              Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

              _WakeupMainThread = new AutoResetEvent(false);
              _WakeupMonitorThread = new AutoResetEvent(false);
              _WakeupBufferUpdateThread = new AutoResetEvent(false);
              _BufferUpdated = new ManualResetEvent(false);

              _MainThread = new Thread(new ThreadStart(ThreadMain));
              _MonitorThread = new Thread(new ThreadStart(ThreadMonitor));
              _BufferUpdateThread = new Thread(new ThreadStart(ThreadBufferUpdate));

              _MainThread.Name = "PureAudio.Main";
              _MainThread.Start();

              _BufferUpdateThread.Name = "PureAudio.BufferUpdate";
              _BufferUpdateThread.IsBackground = true;
              _BufferUpdateThread.Start();

              _MonitorThread.Name = "PureAudio.Monitor";
              _MonitorThread.IsBackground = true;
              _MonitorThread.Start();
        }
Exemple #52
0
 /// <summary>
 /// Stops playback of the outside broadcast stream
 /// </summary>
 private void StopOB()
 {
     // Set sync function for fade down
     SYNCPROC streamEndSync = new SYNCPROC(RemoveOBStream);
     Bass.BASS_ChannelSetSync(obHandle, BASSSync.BASS_SYNC_SLIDE, 0, streamEndSync, IntPtr.Zero);
     // Fade down
     Bass.BASS_ChannelSlideAttribute(obHandle, BASSAttribute.BASS_ATTRIB_VOL, 0, 500);
 }
Exemple #53
0
        public void MusicUpdate()
        {
            if (m_NewMusic != "")
            {
                float maxVolume = GlobalSettings.Default.MusicVolume / 10.0f;
                m_MusicFade -= 1.0 / 60.0;
                if (m_MusicChannel != -1) Bass.BASS_ChannelSetAttribute(m_MusicChannel, BASSAttribute.BASS_ATTRIB_VOL, maxVolume * (float)Math.Max(0, (m_MusicFade - 0.5) / 1.5));
                if (m_MusicFade <= 0)
                {
                    if (m_MusicChannel != -1) { Bass.BASS_ChannelStop(m_MusicChannel); }
                    if (m_NewMusic != "none")
                    {
                        m_MusicChannel = LoadMusicTrack(m_NewMusic, 1, false);
                        Bass.BASS_ChannelSetAttribute(m_MusicChannel, BASSAttribute.BASS_ATTRIB_VOL, maxVolume);
                        m_EndedEvent = new SYNCPROC(MusicEnded);

                        Bass.BASS_ChannelSetSync(m_MusicChannel, BASSSync.BASS_SYNC_END, 0, m_EndedEvent, (IntPtr)0);
                        m_MusicFade = 2;
                    }
                    m_NewMusic = "";
                }
            }
        }
        /// <summary>
        /// Initialize the bass library
        /// </summary>
        /// <returns></returns>
        protected bool BassNetInitialize()
        {
            // Keep Bass.Net from putting a popup on the screen
            BassNet.Registration(email, registrationKey);

            if (Bass.BASS_Init(-1, BASS_SAMPLE_RATE, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)) // 0=console application otherwise this.Handle
            {
#if __IOS__
                //Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_IOS_SPEAKER, 1); 
#endif
                bassFileProcs = new BASS_FILEPROCS(
                    new FILECLOSEPROC(_BassCallback_FileProcUserClose),
                    new FILELENPROC(_BassCallback_FileProcUserLength),
                    new FILEREADPROC(_BassCallback_FileProcUserRead),
                    new FILESEEKPROC(_BassCallback_FileProcUserSeek));
                bassStalledSync = new SYNCPROC(_BassCallback_StalledSync);
                bassEndSync = new SYNCPROC(_BassCallback_EndSync);

                Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_BUFFER, 1000 * 2); // 2 seconds buffer (the default of bass also)

                return true;
            }

            return false;
        }
    /// <summary>
    /// Fade Out  Procedure
    /// </summary>
    /// <param name="handle"></param>
    /// <param name="stream"></param>
    /// <param name="data"></param>
    /// <param name="userData"></param>
    private void PlaybackCrossFadeProc(int handle, int stream, int data, IntPtr userData)
    {
      new Thread(() =>
                   {
                     try
                     {
                       Log.Debug("BASS: X-Fading out stream {0}", _filePath);

                       // We want to get informed, when Crossfading has ended
                       _playBackSlideEndDelegate = new SYNCPROC(SlideEndedProc);
                       Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_SLIDE, 0, _playBackSlideEndDelegate,
                                                IntPtr.Zero);

                       _crossFading = true;
                       Bass.BASS_ChannelSlideAttribute(stream, BASSAttribute.BASS_ATTRIB_VOL, 0,
                                                       Config.CrossFadeIntervalMs);
                     }
                     catch (AccessViolationException)
                     {
                       Log.Error("BASS: Caught AccessViolationException in Crossfade Proc");
                     }
                   }
      ) { Name = "BASS X-Fade" }.Start();
    }
        /// <summary>
        /// The BASS engine itself is not initialised at this stage, since it may cause S/PDIF for Movies not working on some systems.
        /// </summary>
        private void Initialize()
        {
            try
            {
                Log.Info("BASS: Initialize BASS environment ...");
                LoadSettings();

                //TODO: Make this configurable
                if (_regEmail != string.Empty)
                    BassNet.Registration(_regEmail, _regKey);

                // Set the Global Volume. 0 = silent, 10000 = Full
                // We get 0 - 100 from Configuration, so multiply by 100
                Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_GVOL_STREAM, _StreamVolume*100);

                if (_Mixing)
                {
                    // In case of mixing use a Buffer of 500ms only, because the Mixer plays the complete bufer, before for example skipping
                    BufferingMS = 500;
                }
                else
                {
                    Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_BUFFER, _BufferingMS);
                }

                for (int i = 0; i < MAXSTREAMS; i++)
                {
                    Streams.Add(0);
                }

                PlaybackFadeOutProcDelegate = PlaybackFadeOutProc;
                PlaybackEndProcDelegate = PlaybackEndProc;
                PlaybackStreamFreedProcDelegate = PlaybackStreamFreedProc;
                MetaTagSyncProcDelegate = MetaTagSyncProc;

                DownloadProcDelegate = DownloadProc;

                StreamEventSyncHandles.Add(new List<int>());
                StreamEventSyncHandles.Add(new List<int>());

                LoadAudioDecoderPlugins();

                Log.Info("BASS: Initializing BASS environment done.");

                _Initialized = true;
                _BassFreed = true;
            }

            catch (Exception ex)
            {
                Log.Error("BASS: Initialize thread failed.  Reason: {0}", ex.Message);
                throw new BassException("BASS: Initialize thread failed.  Reason: " + ex);
            }
        }
Exemple #57
0
        /// <summary>
        /// Called when a stream has been created. This actually starts the playback of the stream.
        /// </summary>
        /// <param name="track">The track that is to be played.</param>
        /// <param name="stream">The BASS.NET stream pointer to play.</param>
        protected virtual void StreamCreated(IAudioItem track, int stream)
        {
            // Init mixer
            if (_mixer == -1) {
                _mixer = BassMix.BASS_Mixer_StreamCreate(44100, 6, BASSFlag.BASS_MIXER_END);

                // Set playback done callback on mixer
                _channelEndCallback = new SYNCPROC(ChannelEnd);
                Bass.BASS_ChannelSetSync(_mixer, BASSSync.BASS_SYNC_END | BASSSync.BASS_SYNC_MIXTIME, 0, _channelEndCallback, IntPtr.Zero);
            }

            // Load streamin mixer
            bool ok = BassMix.BASS_Mixer_StreamAddChannel(_mixer, stream, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_MIXER_MATRIX);
            if (!ok) Log(Bass.BASS_ErrorGetCode().ToString(), Logger.LogLevel.Error);

            // Set matrix
            SetMatrix(stream);

            // Remove current channel from mixer
            if (_currentStream != -1) {
                BassMix.BASS_Mixer_ChannelRemove(_currentStream);
                Bass.BASS_StreamFree(_currentStream);
            }

            //
            if (track is IWebcast) {
                SYNCPROC _mySync = new SYNCPROC(MetaSync);
                Bass.BASS_ChannelSetSync(_currentStream, BASSSync.BASS_SYNC_META, 0, _mySync, IntPtr.Zero);
            }

            // Play it!
            Bass.BASS_ChannelSetPosition(_mixer, 0);
            Bass.BASS_Start();
            Bass.BASS_ChannelPlay(_mixer, false);

            // Set current stuff
            _currentStream = stream;
        }
Exemple #58
0
        /// <summary>
        /// Sets a synchronization callback.
        /// </summary>
        /// <param name="type">Sync type</param>
        /// <param name="param">Parameter (depends on sync type)</param>
        /// <param name="syncProc">Instance of the synchronization callback</param>
        /// <returns>Synchronization callback handle</returns>
        public int SetSync(BASSSync type, long param, SYNCPROC syncProc)
        {
            // Set sync
            int syncHandle = Bass.BASS_ChannelSetSync(handle, type, param, syncProc, IntPtr.Zero);

            // Check for error
            if (syncHandle == 0)
            {
                Base.CheckForError();
            }

            return syncHandle;
        }
Exemple #59
0
 public static extern int BASS_ChannelSetSync(int handle, BASSSync type, long param, SYNCPROC proc, IntPtr user);
Exemple #60
0
        public AudioEngine()
        {

            Path = @"http://psv4.vk.me/c613621/u23628424/audios/45049760ad7c.mp3?extra=xy8j8Fwc0OnSqJcxvITYLiX-D4akkd_Rkl8cvuVgLlLvD9G133yv-_MAqCspCcmxxUdw9OMZGdrq702KUJ2PdO1oGDkTRvw&/Scratch%20Bandits%20Crew%20-%20Surround%20Me.mp3";
            //Path = @"D:\Documents and Settings\Admin\Рабочий стол\C#\Music Primer\6ddb8171688e23.mp3";
            // Path = @"http://www.sky.fm/mp3/the80s.pls";
            //Path = @"http://download.wavetlan.com/SVV/Media/HTTP/WMA/WMALossless/Coldplay_StrawberrySwing_WMALossless.wma";
            //Path = @"http://yp.shoutcast.com/sbin/tunein-station.pls?id=193174";
            //+Path = @"http://yp.shoutcast.com/sbin/tunein-station.pls?id=193174";
            //Path = @"http://radiocaroline259.nl/winamp_rc259_320.pls";
            //Path = @"http://yp.shoutcast.com/sbin/tunein-station.pls?id=94181";
            //Path = @"http://yp.shoutcast.com/sbin/tunein-station.pls?id=256410";
            //Path = @"http://flacradio.esy.es/playlist/AI-Radio.m3u";
            //Path = @"http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/llnw/bbc_1xtra.m3u8";
            ListSongs = new List<string>(
                Directory.GetFiles(@"D:\Documents and Settings\Admin\Рабочий стол\C#\Music Primer"));
            /* ListSongs = new List<string>();
             ListSongs.Add(@"http://cs1-34v4.vk-cdn.net/p6/d1483bd42febd1.mp3?extra=vi0VwGa9y_QGmZqu8zXS2NNAuPHuBuHM-yChSaH3-vezjVEJMN7tvO6WDQq3CRsOk0SJw9apaTVSamib5nHTPROhCr8kCz3n&/CunninLynguists%20-%20Darkness%20(Dream%20On)%20(Instrumental).mp3");
             ListSongs.Add(@"http://psv4.vk.me/c613231/u23628424/audios/bca9f0bb9989.mp3?extra=c7lN4T5gQC3FOQPpHCgWnmtCTk2F89a-HjouOB5qAPoKePRg_0OSR7nbm8tsFqS1ypEXhrV5khECX449brMq9qzqtiYNOfq1&/Mr.%20Moods%20-%20Rainbow.mp3");
             ListSongs.Add(@"http://psv4.vk.me/c613924/u64887148/audios/73b365664dbb.mp3?extra=qbIEMne5L7HEkwI8l57HvsJbjpHEap8WEapQ5BVETzm-bo_6lpu3UPJ4gDnGJyc-G4-7cWHb_gqO9fDT9Ly87XQPYfwcEcaO&/PhybaOptikz%20-%20Chronicles.mp3");
             ListSongs.Add(@"http://psv4.vk.me/c521100/u4594424/audios/0277415e656d.mp3?extra=tUmU_lLbAdXrMsDon27ayCWW3l6soR7fHTiQ0-6Qj6xuim7tQLXcEBXS0lq9uJ1TxuFkG-4xyQyWR004b_BL7nkaLcKZqMbd&/Roger%20Molls%20-%20You.mp3");
             ListSongs.Add(@"http://psv4.vk.me/c613126/u247179947/audios/5b4259f1d5c3.mp3?extra=Fo_qX0TC-RHoozxSTQQZBedY9vxIlLk1VcPyRMziMarqYxCBZqIhX7cCPCPfB4XvYy2Gbnz9Zdl34KXdNtXu0ovlSeG_B86E&/Keizan%20-%20Keizan%20-%20Damn%20feat%20Dj%20Meloman.mp3");
             ListSongs.Add(@"http://psv4.vk.me/c611427/u221922242/audios/d196c39b7b28.mp3?extra=OgcU7H3jJrRB94KkUdGFxqXRlGwh7ttN3sIB0LGRqYUIxFpXfm48v6FQWyHWHge3DDI5U02KBoSRHOJTQX9Pdwj31aeoWBFw&/Billa%20Qause%20-%20Slow%20Down.mp3");
             ListSongs.Add(@"http://psv4.vk.me/c611324/u1444216/audios/36a640799476.mp3?extra=sr0Y8gulc4N5Wr4wEPavdJ98vK3FRAFX6pQbCC6JeDypyPoT8RGLsR4618C8CpZE1YaLlUfGmFMAyJCsXsnjSo4sg-lH87qq&/GRiZ%20-%20Love%20Will%20Follow%20You%20(feat.%20Russ%20Liquid).mp3");
             ListSongs.Add(@"http://psv4.vk.me/c613327/u23628424/audios/fb86d3ceae8f.mp3?extra=q7-2v9Jh_Cq0V4QlhgEz7E4pvf3NxS9yPCE5MIdu_0NQsdQ13572JElzEgZt9Kj7VafbWfxb-vq2IP1BvLLqCE6MSD7MZRA6&/Kinack%20-%20Shine.mp3");
             ListSongs.Add(@"http://cs1-42v4.vk-cdn.net/p23/7ffb834f38273a.mp3?extra=-mJYId08Rdph4HddpqC6noOAFcs6jvCw0hauKmXWQkREoEUclM-MMSstShqEYPguWrAemIoc5zA57nx89XmbnkHGh-E_5WgD&/Frameworks%20-%20Music%20Box.mp3");
             ListSongs.Add(@"http://psv4.vk.me/c613121/u23628424/audios/659402091c6c.mp3?extra=ZfCP0UugdWy6oapnqKBTnvwtC2vXa_WQXZsE648_vkKMgn2e-3nP1E1fREEgJnUsSka0pMvOHvOlBwU6oyjird1po-WO0J8W&/Travelers%20Of%20Tyme%20-%20Raining%20Castanets%20(The%20Rains%20of%20Castamere).mp3");
 */

            WahWahEffect = new WahWahService();
            PitchShiftEffect = new PitchShiftService();
            PhaserEffect = new PhaserService();
            ChorusEffect = new ChorusService();
            DistortionEffect = new DistortionService();
            DynamicAmplificationEffect = new DynamicAmplificationService();
            ReverberationEffect = new ReverberationService();
            EchoEffect = new EchoService();
            CompressorEffect = new CompressorService();
            BiQuadFilterEffect = new BiQuadFilterService();
            DSPEffect = new DSP();
            WaveFormClass = new WaveFormService();
            Spectrum = new Spectrum();

            MemoryPlay = true;
            _timer = new BASSTimer();
            _timer.Tick += MusicTrackTick;
            _timer.Start();
            CurrentVolume = 1;
            Crossfade = new CrossfadeService(CurrentVolume);
            EqualizerEffect = new EqualizerService();
            CrossfadeActive = true;
            SoundOutProvider = new SoundOutProviderBASS();
            _myUserAgentPtr = Marshal.StringToHGlobalAnsi(_myUserAgent);
            _positionEventAggregator = new EventAggregator();
            _waveFormEventAggregator = new EventAggregator();
            DownloadMode = DownloadTypes.NoDownload;

            _syncProcPos = SyncMethodPos;
            

            Bass.BASS_SetConfigPtr(BASSConfig.BASS_CONFIG_NET_AGENT, _myUserAgentPtr);

            SoundOutProvider.SetConfig(BASSConfig.BASS_CONFIG_FLOATDSP, true);
            SoundOutProvider.SetConfig(BASSConfig.BASS_CONFIG_NET_TIMEOUT, 5000);
            SoundOutProvider.SetConfig(BASSConfig.BASS_CONFIG_WMA_PREBUF, 0);
            SoundOutProvider.SetConfig(BASSConfig.BASS_CONFIG_NET_PREBUF, 0);
            SoundOutProvider.SetConfig(BASSConfig.BASS_CONFIG_NET_PLAYLIST, 2);
        }