Exemple #1
0
        public void Play(int velocity)
        {
            this.fSongPlayerStatus = SongPlayerStatus.Playing;
            this.fTimer.Start();

            fExecutionLog.Add("Play()");
        }
Exemple #2
0
        public void Stop()
        {
            this.fSongPlayerStatus = SongPlayerStatus.Stopped;
            this.fTimer.Stop();

            fExecutionLog.Add("Stop()");
        }
Exemple #3
0
 /// <summary>
 /// Evento disparado quando uma música termina.
 /// </summary>
 /// <param name="handle"></param>
 /// <param name="channel"></param>
 /// <param name="data"></param>
 /// <param name="user"></param>
 private void OnFinished(int handle, int channel, int data, IntPtr user)
 {
     lock (this)
     {
         this.fStatus = SongPlayerStatus.Stopped;
     }
 }
Exemple #4
0
        public void Pause()
        {
            this.fSongPlayerStatus = SongPlayerStatus.Paused;
            this.fTimer.Stop();

            fExecutionLog.Add("Pause()");
        }
Exemple #5
0
        public void Pause()
        {
            lock (this)
            {
                if (fStatus != SongPlayerStatus.Playing)
                {
                    throw new SongPlayerInconsistence(
                              string.Format("Unexpected SongPlayer status {0}.", fStatus.ToString()));
                }

                //if (fStreamHandler != 0)
                if (fStreamFxHandler != 0)
                {
                    //bool status = Bass.BASS_ChannelPause(fStreamHandler);
                    bool status = Bass.BASS_ChannelPause(fStreamFxHandler);

                    if (!status)
                    {
                        throw new AudioProcessingError(
                                  string.Format("SongPlayer.Pause() couldn´t pause the file [{0}].", fFileName));
                    }
                }

                //Update the SongPlayer.Status
                this.fStatus = SongPlayerStatus.Paused;
            }
        }
Exemple #6
0
 public void Unload()
 {
     if (SPStatus == SongPlayerStatus.Stopped)
     {
         return;
     }
     Bass.StreamFree(SPStream);
     SPStream = 0;
     SPStatus = SongPlayerStatus.Stopped;
 }
Exemple #7
0
        public void Play(int velocity, float pitch)
        {
            Velocity = velocity;
            Pitch    = pitch;

            LoadStream();

            lock (this)
            {
                if (this.Status == SongPlayerStatus.Stopped)
                {
                    fLastBeatNotified = 1;
                    fLastTickNotified = 0;

                    InstallCallbackMethods();
                }

                bool restart = (this.Status == SongPlayerStatus.Stopped);

                InstallBeatNotifyEvent();

                //Update the SongPlayer.Status
                this.fStatus = SongPlayerStatus.Playing;

                if (TickNotifyEvent != null)
                {
                    //Trace.TraceInformation(string.Format("OnBeatNotify({0})", counterTest++));
                    TickNotifyEvent(this, fLastBeatNotified, fLastTickNotified);
                }

                if (fStreamFxHandler != 0)
                {
                    bool status = false;

                    Bass.BASS_ChannelSetAttribute(fStreamFxHandler, BASSAttribute.BASS_ATTRIB_TEMPO, (Velocity - 100));

                    if (Pitch != 0)
                    {
                        if (!Bass.BASS_ChannelSetAttribute(fStreamFxHandler, BASSAttribute.BASS_ATTRIB_TEMPO_PITCH, Pitch))
                        {
                            throw new AudioProcessingError(string.Format("SongPlayer.Play() couldn´t change the pitch for the file [{0}].", fFileName));
                        }
                    }

                    //Start playing with FX
                    status = Bass.BASS_ChannelPlay(fStreamFxHandler, restart);

                    if (!status)
                    {
                        throw new AudioProcessingError(string.Format("SongPlayer.Play() couldn´t play the file [{0}].", fFileName));
                    }
                }
            }
        }
Exemple #8
0
 public void Pause()
 {
     if (SPStatus == SongPlayerStatus.Paused)
     {
         return;
     }
     if (SPStream == 0)
     {
         throw new InvalidOperationException("Stream not loaded");
     }
     Bass.ChannelPause(SPStream);
     SPStatus = SongPlayerStatus.Paused;
 }
Exemple #9
0
 public void Play()
 {
     if (SPStatus == SongPlayerStatus.Playing)
     {
         return;
     }
     if (SPStream == 0)
     {
         this.Load();
     }
     Bass.ChannelPlay(SPStream);
     SPStatus = SongPlayerStatus.Playing;
 }
Exemple #10
0
 static Track()
 {
     try
     {
         Bass.Init();
     }
     catch (DllNotFoundException)
     {
         throw new Exception("You are missing bass.dll. If you are on windows, the updater should get it for you. If you are on linux, then you need to download `libbass.so` for your platform (32 bit or 64 bit) from un4seen.com and put it in your /usr/lib.");
     }
     SPStream = 0;
     SPStatus = SongPlayerStatus.Stopped;
 }
Exemple #11
0
        public void Stop()
        {
            lock (this)
            {
                ValidateSongPlayingOrPaused();

                //if (fStreamHandler != 0)
                if (fStreamFxHandler != 0)
                {
                    //bool status = Bass.BASS_ChannelStop(fStreamHandler);
                    bool status = Bass.BASS_ChannelStop(fStreamFxHandler);

                    if (!status)
                    {
                        throw new AudioProcessingError(
                                  string.Format("SongPlayer.Stop() couldn´t stop the file [{0}].", fFileName));
                    }
                }

                //Update the SongPlayer.Status
                this.fStatus = SongPlayerStatus.Stopped;
            }
        }