/// <summary>
        ///     Handles the Load event of the TrackDetails control.
        /// </summary>
        private void TrackDetails_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }
            if (_loaded)
            {
                return;
            }

            DisplayCurrentTrackDetails();

            slider.Dock  = DockStyle.None;
            slider.Width = pnlSlider.Width;
            slider.Dock  = DockStyle.Fill;

            if (!Timer.Enabled)
            {
                Timer.Start();
                BassPlayer.OnTrackChange += BassPlayer_OnTrackChange;
            }

            sldVolume.Minimum = 0;
            sldVolume.Maximum = 100;
            var volume = Convert.ToInt32(BassPlayer.GetMixerVolume());

            lblVolume.Text  = volume.ToString();
            sldVolume.Value = volume;

            _loaded = true;
        }
 internal void Initialize(BassPlayer bassPlayer, ISampleLibrary trackSampleLibrary, ISampleRecipient sampleRecipient = null)
 {
     sampleLibraryControl.BassPlayer      = bassPlayer;
     sampleLibraryControl.SampleLibrary   = trackSampleLibrary;
     sampleLibraryControl.SampleRecipient = sampleRecipient;
     sampleLibraryControl.Initialize();
 }
Beispiel #3
0
        /// <summary>
        ///     Updates the shuffler details.
        /// </summary>
        private void UpdateShufflerDetails()
        {
            var selectedTrack = GetSelectedTrack();

            if (selectedTrack == null)
            {
                return;
            }

            var form = new FrmShufflerDetails
            {
                BassPlayer = BassPlayer,
                Filename   = selectedTrack.Filename
            };

            var result = form.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }
            Library.LoadTrack(selectedTrack.Filename);
            BassPlayer.ReloadTrack(selectedTrack.Filename);
            BindData();
        }
        public List <Sample> GetMixSectionsAsSamples(Track track)
        {
            var bassTrack = BassPlayer.LoadTrackAndAudio(track.Filename);
            var samples   = new List <Sample>();

            var fadeIn = new Sample
            {
                Description = "FadeIn",
                Start       = bassTrack.SamplesToSeconds(bassTrack.FadeInStart),
                Length      = bassTrack.FadeInLengthSeconds,
                Bpm         = BpmHelper.GetBpmFromLoopLength(bassTrack.FadeInLengthSeconds),
                Gain        = bassTrack.Gain
            };

            UpdateSampleFromTrack(fadeIn, track);

            samples.Add(fadeIn);

            var fadeOut = new Sample
            {
                Description = "FadeOut",
                Start       = bassTrack.SamplesToSeconds(bassTrack.FadeOutStart),
                Length      = bassTrack.FadeOutLengthSeconds,
                Bpm         = BpmHelper.GetBpmFromLoopLength(bassTrack.FadeOutLengthSeconds),
                Gain        = bassTrack.Gain
            };

            UpdateSampleFromTrack(fadeOut, track);

            samples.Add(fadeOut);

            BassPlayer.UnloadTrackAudioData(bassTrack);

            return(samples);
        }
Beispiel #5
0
        /// <summary>
        ///     Initializes this instance.
        /// </summary>
        public void Initialize()
        {
            CurrentTrack  = BassPlayer.CurrentTrack;
            PreviousTrack = BassPlayer.PreviousTrack;
            NextTrack     = BassPlayer.NextTrack;

            BassPlayer.OnTrackQueued += BassPlayer_OnTrackChange;
            BassPlayer.OnTrackChange += BassPlayer_OnTrackChange;

            BassPlayer.OnManualMixVolumeChanged += BassPlayer_OnManualMixVolumeChanged;
            BassPlayer.OnManualMixModeChanged   += BassPlayer_OnManualMixModeChanged;

            sldFader.Minimum = 0;
            sldFader.Maximum = 100;

            rdbDelay2.Checked = true;

            chkEnableTrackFXAutomation.Checked = BassPlayer.TrackFxAutomationEnabled;

            cmbFadeOutType.SelectedIndex = 0;

            BassPlayer.DisableManualMixMode();

            BindData();

            _timer.Tick    += Timer_Tick;
            _timer.Interval = 200;
            _timer.Start();
        }
Beispiel #6
0
 public Band()
 {
     this.drummer    = new Drummer();
     this.bassPlayer = new BassPlayer();
     this.singer     = new Singer();
     this.trianglist = new Trianglist();
 }
Beispiel #7
0
 /// <summary>
 ///     Handles the MouseUp event of the btnPlay control.
 /// </summary>
 private void btnPlay_MouseUp(object sender, MouseEventArgs e)
 {
     if (Sample == null)
     {
         return;
     }
     BassPlayer.PauseSample(Sample);
 }
Beispiel #8
0
 public void Pause()
 {
     if (Sample == null)
     {
         return;
     }
     BassPlayer.PauseSample(Sample);
 }
Beispiel #9
0
 private void btnSaveMix_Click(object sender, EventArgs e)
 {
     if (!chkManualFading.Checked)
     {
         return;
     }
     BassPlayer.SaveExtendedMix();
 }
Beispiel #10
0
 public void Unload()
 {
     SaveSettings();
     Library.SaveToDatabase();
     LoopLibrary.SaveToCache();
     BassPlayer.Dispose();
     MidiManager.Dispose();
 }
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public void Initialize()
        {
            sldVolume.Scrolled += new MediaSlider.MediaSlider.ScrollDelegate(sldVolume_Slid);
            sldVolume.Minimum   = 0;
            sldVolume.Maximum   = 100;

            SetVolume(Convert.ToInt32(BassPlayer.GetMonitorVolume()));
        }
        /// <summary>
        ///     Handles the OnEndFadeIn event of the BassPlayer control.
        /// </summary>
        private void PreloadTrack()
        {
            var preloadTrack = GetTrackAfterNext();

            if (preloadTrack != null)
            {
                BassPlayer.PreloadTrack(preloadTrack.Filename);
            }
        }
        /// <summary>
        ///     Handles the Slid event of the Slider control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
        private void Slider_Slid(object sender, EventArgs e)
        {
            Timer.Stop();
            var position = slider.Value;

            BassPlayer.SetAdjustedTrackPosition(position);
            Thread.Sleep(200);
            Timer.Start();
        }
        /// <summary>
        ///     Handles the Click event of the btnPlay control.
        /// </summary>
        private void btnPlay_Click(object sender, EventArgs e)
        {
            BeginInvoke(BassPlayer.PlayState == PlayState.Playing
                ? delegate { BassPlayer.Pause(); }
                : new MethodInvoker(delegate { BassPlayer.Play(); }));

            btnPause.Visible = BassPlayer.PlayState == PlayState.Playing;
            btnPlay.Visible  = BassPlayer.PlayState != PlayState.Playing;
        }
Beispiel #15
0
        public Player(ISession session, IPlayerPlaylist playerPlaylist)
        {
            Playlist = playerPlaylist;
            Playlist.CurrentChanged += CurrentTrackChanged;

            _session = session;
            _session.MusicDeliver += OnMusicDeliver;
            _bassPlayer = new BassPlayer();
        }
 private void Play()
 {
     BeginInvoke((MethodInvoker) delegate
     {
         BassPlayer.SetRawLoopPositions(ZoomStart, ZoomEnd, CurrentPosition);
         BassPlayer.PlayRawLoop();
         _timer.Enabled = true;
     });
 }
        /// <summary>
        ///     Handles the Slid event of the sldVolume control.
        /// </summary>
        private void sldVolume_Slid(object sender, EventArgs e)
        {
            _bindingVolumeSlider = true;
            var volume = Convert.ToDecimal(sldVolume.ScrollValue);

            BassPlayer.SetMixerVolume(volume);
            lblVolume.Text       = volume.ToString(CultureInfo.InvariantCulture);
            _bindingVolumeSlider = false;
        }
        /// <summary>
        ///     Handles the Tick event of the Timer control.
        /// </summary>
        private void Timer_Tick()
        {
            var form = FindForm();

            if (form != null && form.WindowState == FormWindowState.Minimized)
            {
                return;
            }

            if (_timerTick)
            {
                return;
            }
            _timerTick = true;

            var position = BassPlayer.GetTrackPosition();

            if (slider.Maximum != position.Length)
            {
                slider.Maximum = (int)position.Length;
            }
            if (slider.Value != position.Positition)
            {
                slider.Value = (int)position.Positition;
            }

            if (lblTimeElapsed.Text != position.ElapsedFormatted)
            {
                lblTimeElapsed.Text = position.ElapsedFormatted;
            }
            if (lblTimeRemaining.Text != position.RemainingFormatted)
            {
                lblTimeRemaining.Text = position.RemainingFormatted;
            }

            btnPause.Visible = BassPlayer.PlayState == PlayState.Playing;
            btnPlay.Visible  = BassPlayer.PlayState != PlayState.Playing;


            if (ToolStripLabel != null)
            {
                if (!Visible && BassPlayer.PlayState == PlayState.Playing)
                {
                    var text = lblCurrentTrackDescription.Text + " - " + position.ElapsedFormatted + " elapsed - " + position.RemainingFormatted + " remaining";
                    ToolStripLabel.Text = text;
                }
                else
                {
                    ToolStripLabel.Text = "";
                }
            }

            ShowVisuals();

            _timerTick = false;
        }
        private void ForcePlayTrack(Track track)
        {
            _doNotBind = true;

            BassPlayer.ForcePlay(track.Filename);

            _doNotBind = false;

            grdPlaylist.InvalidateDisplayedRows();
        }
Beispiel #20
0
        /// <summary>
        ///     Sets the tracks.
        /// </summary>
        private void SetTracks()
        {
            CurrentTrack  = BassPlayer.CurrentTrack;
            PreviousTrack = BassPlayer.PreviousTrack ?? GetPreviousTrack();

            sldFader.Value = 0;
            BassPlayer.SetManualMixVolume(sldFader.Value);

            NextTrack = BassPlayer.NextTrack;
        }
Beispiel #21
0
        private void BindMixVolume()
        {
            if (_bindingVolumeSlider)
            {
                return;
            }
            var volume = (int)BassPlayer.GetManualMixVolume();

            sldFader.Value = volume;
        }
Beispiel #22
0
        /// <summary>
        ///     Handles the Click event of the btnRemoveLastSend control.
        /// </summary>
        private void btnRemoveLastSend_Click(object sender, EventArgs e)
        {
            var track = BassPlayer.CurrentTrack;

            if (track == null)
            {
                return;
            }
            BassPlayer.RemovePreviousTrackFxTrigger();
        }
Beispiel #23
0
        public static void Init()
        {
            //Call this first to init it, so we can override it!
            var version = BassPlayer.BassVersion();

            Bass.Configure(Configuration.IOSMixAudio, 0);
            BassFileProceduresManager.CreateFileProcedureImpl = CreateProcedure;
            BassFileProceduresManager.CreateSyncProcedureImpl = CreateProcedure;
            BassFileProceduresManager.OnClearProcedure        = ClearProcedure;
        }
        public void Initialize()
        {
            var settings = Settings.Default;

            BassPlayer.SetMixerVolume(settings.Volume);

            SetVolume((int)settings.Volume);

            BassPlayer.OnVolumeChanged += BassPlayer_OnVolumeChanged;
        }
Beispiel #25
0
        /// <summary>
        ///     Handles the FormClosed event of the frmTrack control.
        /// </summary>
        private void frmTrack_FormClosed(object sender, FormClosedEventArgs e)
        {
            trackWave.Unload();
            if (!_saved)
            {
                return;
            }

            BassPlayer.ReloadTrack(Track.Filename);
        }
        /// <summary>
        ///     Loads a track.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        public Track LoadTrack(string fileName)
        {
            Filename  = fileName;
            BassTrack = BassPlayer.LoadRawLoopTrack(Filename);

            LoadTrackWaveData();
            DrawWave();

            return(BassTrack);
        }
        /// <summary>
        ///     Initializes a new instance of the Library class.
        /// </summary>
        public TrackSampleLibrary(BassPlayer bassPlayer, Library trackLibrary)
        {
            Samples      = new List <Sample>();
            BassPlayer   = bassPlayer;
            TrackLibrary = trackLibrary;

            SampleLibraryFolder = Path.Combine(Path.GetTempPath(), "SampleLibary");
            if (!Directory.Exists(SampleLibraryFolder))
            {
                Directory.CreateDirectory(SampleLibraryFolder);
            }
        }
        private void BindVolume()
        {
            if (_bindingVolumeSlider)
            {
                return;
            }
            var volume = (int)BassPlayer.GetMixerVolume();

            if (volume != sldVolume.Value)
            {
                SetVolume(volume);
            }
        }
        /// <summary>
        ///     Plays the previous track.
        /// </summary>
        public void PlayPreviousTrack()
        {
            var track = GetPreviousTrack();

            if (track == null)
            {
                return;
            }
            var currentIndex = GetCurrentTrackIndex();

            TrackModels[currentIndex].IsCurrent     = false;
            TrackModels[currentIndex - 1].IsCurrent = true;
            BassPlayer.ForcePlay(track.Filename);
        }
 private void PlayCurrentSamples()
 {
     if (_playing)
     {
         return;
     }
     lock (_player)
     {
         _playing = true;
         _player.SetBpm(BassPlayer.GetCurrentBpm());
         _player.Unmute();
         _player.Play();
     }
 }
        private void SetVolume(int volume)
        {
            if (volume < 0 || volume > 100)
            {
                return;
            }

            BassPlayer.SetMonitorVolume(Convert.ToDecimal(volume));
            lblVolume.Text = volume.ToString();

            if (sldVolume.Value != volume)
            {
                sldVolume.Value = volume;
            }
        }
        public BassPlayerMidiMapper(BassPlayer bassPlayer, MidiManager midiManager)
        {
            _bassPlayer = bassPlayer;

            _controlMappings = new List<ControlMapping>
            {
                new ControlMapping {CommandName = "Play", MidiControlId = 45},
                new ControlMapping {CommandName = "PowerDownCurrent", MidiControlId = 46},
                new ControlMapping {CommandName = "Volume", MidiControlId = 2},
                new ControlMapping {CommandName = "PausePrevious", MidiControlId = 23},
                new ControlMapping {CommandName = "PowerDownPrevious", MidiControlId = 33},
                new ControlMapping {CommandName = "ManualMixVolume", MidiControlId = 14},
                new ControlMapping {CommandName = "FadeNow", MidiControlId = 48},
                new ControlMapping {CommandName = "TrackSendFx", MidiControlId = 24},
                new ControlMapping {CommandName = "TrackSendFxVolume", MidiControlId = 3},
                new ControlMapping {CommandName = "SamplerVolume", MidiControlId = 4},
                new ControlMapping {CommandName = "ToggleManualMixMode", MidiControlId = 44},
                new ControlMapping {CommandName = "LoopFadeInForever", MidiControlId = 49},
                new ControlMapping {CommandName = "JumpBack", MidiControlId = 47}
            };

            for (var i = 0; i < 12; i++)
            {
                _controlMappings.Add(new ControlMapping
                {
                    CommandName = "Sample" + (i + 1),
                    MidiControlId = (i < 6) ? i + 26 : i + 36
                });
            }

            _vstMappings = new List<VstMapping>
            {
                new VstMapping
                {
                    VstPlugin = _bassPlayer.MainVstPlugin,
                    MidiControlId = 17,
                    ParameterIndex = 4,
                }
            };


            midiManager.OnControlMessageEvent += MidiManager_OnControlMessageEvent;
        }
Beispiel #33
0
        void SpotifySession_OnMusicDelivery(Session sender, MusicDeliveryEventArgs e)
        {
            if (e.Samples.Length > 0)
            {

                if (player == null)
                {
                    //player = new AlsaPlayer(e.Rate / 2); // Buffer 500ms of audio
                    player = new BassPlayer();

                    Console.WriteLine("Player created");
                }

                // Don't forget to set how many frames we consumed
                e.ConsumedFrames = player.EnqueueSamples(new AudioData(e.Channels, e.Rate-12, e.Samples, e.Frames));

                /*X.Maximum = (float)currentTrack.Duration;
                X.Value  +=10;*/

            }
            else
            {
                e.ConsumedFrames = 0;
            }
        }