public void addSong(Track t, bool addToActivePlaylist, bool threadWrap) { if (addToActivePlaylist) { this.Invoke((MethodInvoker) delegate() { mp.addTrack(t); //[UPDATE TRACKS] nameListBox.Items.Add(t.Name); lengthListBox.Items.Add(msToString(t.Length)); nameListBox.SelectedIndex = mp.SelectedTrackIndex; if (mp.deshuffle()) { cmdShuffle.Image = Properties.Resources.shuffle_white; } }); } if (dbAdapter.getTrack(t.Path) == null) { SignalProcessing.SignalProcessor sp = new SignalProcessing.SignalProcessor(); if (threadWrap) { lock (songsToAdd) { songsToAdd.Add(t); } } else { sp.ComputeBPM(t.Data, (t.Length / 1000), false, false); t.BPM = sp.BPM; sp.computeTimbre(t.Data, t.Length / 1000, false); t.ZCR = sp.ZCR; t.SpectralIrregularity = sp.SpectralIrregularity; lock (dbAdapter) { dbAdapter.addTrack(t); } updateSettings(true); matcherForm.updateTrackList(mp.LoadedPlaylist.TrackList); } } }
public MainForm(bool devMode) { this.mp = new MusicPlayer.MusicPlayer(); this.loop = false; this.musicTrackbarScrolling = false; this.Running = true; this.lastMouseX = 0; trackNameToPathIndices = null; InitializeComponent(); this.FormBorderStyle = FormBorderStyle.FixedSingle; this.MaximizeBox = false; if (!devMode) { cmdShowGrapher.Hide(); cmdToggleMatcher.Hide(); cmdSaveCsv.Hide(); cmdViewDB.Hide(); } onPlayingChange += playingChanged; onSongComplete += songComplete; AutoPick = true; seekLabel.Text = ""; txtMusicProgress.Text = ""; updateMusicTrackbarThread = new Thread(new ThreadStart(updateMusicTrackbar)); grapherForm = new Grapher(this); vm = new VolumeMixer(); vm.OnPeakChanged += onPeakChanged; loweredVolume = false; dbAdapter = new DatabaseAdapter(ConfigurationManager.ConnectionStrings["GamingMusicPlayer.Properties.Settings.SongsDBConnectionString"].ConnectionString); matcherForm = new SongMatcher(this, dbAdapter); settingsForm = new SettingsForm(this); overlayForm = new OverlayForm(this, 200, 0); driveScanner = null; ToolTip vpToggleTooltip = new ToolTip(); vpToggleTooltip.ToolTipIcon = ToolTipIcon.None; vpToggleTooltip.IsBalloon = true; vpToggleTooltip.ShowAlways = true; vpToggleTooltip.AutoPopDelay = 20000; vpToggleTooltip.SetToolTip(cmdVp, "Voice Prioritization Feature"); ToolTip songMatchToggleTooltip = new ToolTip(); songMatchToggleTooltip.ToolTipIcon = ToolTipIcon.None; songMatchToggleTooltip.IsBalloon = true; songMatchToggleTooltip.ShowAlways = true; songMatchToggleTooltip.AutoPopDelay = 20000; songMatchToggleTooltip.SetToolTip(cmdSongMatchToggle, "Automatic Song Matching Feature"); dbListBox.SelectionMode = SelectionMode.MultiExtended; songsToAdd = new List <Track>(); addSongsToDbThread = new Thread(delegate() { SignalProcessing.SignalProcessor sp = new SignalProcessing.SignalProcessor(); while (true) { int c = 0; lock (songsToAdd) { c = songsToAdd.Count; } while (c > 0) { Track t = songsToAdd[0]; sp.ComputeBPM(t.Data, (t.Length / 1000), false, false); t.BPM = sp.BPM; sp.computeTimbre(t.Data, t.Length / 1000, false); t.ZCR = sp.ZCR; t.SpectralIrregularity = sp.SpectralIrregularity; lock (dbAdapter) { dbAdapter.addTrack(t); } updateSettings(true); sp.clearMemory(); lock (songsToAdd) { songsToAdd.RemoveAt(0); c = songsToAdd.Count; } matcherForm.updateTrackList(mp.LoadedPlaylist.TrackList); } Thread.Sleep(1000); } }); addSongsToDbThread.Start(); }