예제 #1
0
		public TrackDetails() {
			InitializeComponent();
			m_Task = new TaskRunner(TaskException);
			// Set output format from settings
			for (int i = 0; i < cbFormat.Items.Count; i++) {
				if (cbFormat.Items[i].ToString() == Properties.Settings.Default.OutputType)
					cbFormat.SelectedIndex = i;
			}
		}
예제 #2
0
		public SplitAlbum() {
			InitializeComponent();
			if (Program.Album != null && Program.Album.Tracks.Count > 2) {
				// Default no of tracks is existing number
				txtTracks.Text = Program.Album.Tracks.Count.ToString();
			}
			// Load parameters from settings
			txtMinTrackLength.Text = Properties.Settings.Default.MinTrackLength.ToTimeSpanString();
			txtCentre.Text = Properties.Settings.Default.SilenceFilterCentre.ToString();
			txtQ.Text = Properties.Settings.Default.SilenceFilterQ.ToString();
			txtStartSilence.Text = Properties.Settings.Default.StartSilenceThreshold.ToString();
			txtEndSilence.Text = Properties.Settings.Default.EndSilenceThreshold.ToString();
			m_Task = new TaskRunner(TaskException);
		}
예제 #3
0
			public Task(TaskRunner runner, Action<Task> action) {
				new System.Threading.Tasks.Task(delegate() {
					try {
						action(this);
					} catch(Exception ex) {
						if (runner.ExceptionThrown != null)
							runner.ExceptionThrown(runner, ex);
					} finally {
						lock (runner) {
							if (runner.m_Task == this) {
								runner.m_Task = null;
							}
						}
					}
				}).Start();
			}
예제 #4
0
		/// <summary>
		/// Normalize (runs in separate thread)
		/// </summary>
		void normalize(TaskRunner.Task t) {
			float oldVolume = m_Reader.Volume;
			try {
				Volume = 1;
				float max = 0;	// Max volume in file
				float[] buffer = new float[m_Reader.WaveFormat.BlockAlign];
				// Number of buffers to read
				long total = m_Reader.Length / (m_Reader.WaveFormat.BlockAlign * m_Reader.WaveFormat.BitsPerSample / 8);
				long count = 0;	// Number read so far
				int pos = 0;	// Progress bar position (0-100)
				m_Reader.Position = 0;
				m_Reader.Volume = 1;
				ProgressBar(0);
				while (!t.Stop && m_Reader.Read(buffer, 0, m_Reader.WaveFormat.BlockAlign) == m_Reader.WaveFormat.BlockAlign) {
					count++;
					// Calculate progress bar position
					int p = (int)(100 * count / total);
					if (p != pos) {
						// Only update if it has changed a whole unit
						pos = p;
						ProgressBar(pos);
					}
					// Find max volume in this buffer
					for (int i = 0; i < m_Reader.WaveFormat.BlockAlign; i++)
						max = Math.Max(max, Math.Abs(buffer[i]));
				}
				if (!t.Stop) {
					Volume = Properties.Settings.Default.NormalizeLevel / max;
					Despatch(delegate() {
						// Have finished - can close dialog
						DialogResult = System.Windows.Forms.DialogResult.OK;
						Close();
					});
				}
			} catch {
			} finally {
				m_Reader.Volume = oldVolume;
			}
			btnOK.Enabled = true;
		}
예제 #5
0
		/// <summary>
		/// Download an album art image from the web
		/// </summary>
		/// <returns>True if successful</returns>
		bool downloadImage(Uri art, TaskRunner.Task task) {
			try {
				using (WebClient webClient = new WebClient()) {
					byte[] data = webClient.DownloadData(art);
					if (task.Stop)
						return true;
					using (MemoryStream mem = new MemoryStream(data)) {
						using (Image img = Image.FromStream(mem))
							if(!task.Stop)
								setImage(img);
					}
				}
				return true;
			} catch (Exception ex) {
				System.Diagnostics.Trace.WriteLine(ex);
				Status("{1} at {0}", art, ex.Message);
			}
			return false;
		}
예제 #6
0
		public Normalize(AudioFileReader reader) {
			m_Reader = reader;
			Volume = 1;
			m_Task = new TaskRunner();
			InitializeComponent();
		}
예제 #7
0
		public AlbumDetails() {
			InitializeComponent();
			m_Task = new TaskRunner(TaskException);
		}