├── src ├── SoundFingerprinting.DuplicatesDetector │ ├── Settings.StyleCop │ ├── Application.ico │ ├── Images │ │ └── icon.png │ ├── View │ │ ├── GenericView.xaml.cs │ │ ├── ReportView.xaml.cs │ │ ├── PathListView.xaml.cs │ │ ├── GenericView.xaml │ │ ├── PathListView.xaml │ │ └── ReportView.xaml │ ├── MainWindow.xaml.cs │ ├── Services │ │ ├── ISaveFileDialogService.cs │ │ ├── IOpenFileDialogService.cs │ │ ├── IWindowService.cs │ │ ├── IFolderBrowserDialogService.cs │ │ ├── FolderBrowserDialogService.cs │ │ ├── IGenericViewWindow.cs │ │ ├── SaveFileDialogService.cs │ │ ├── WindowService.cs │ │ ├── IMessageBoxService.cs │ │ ├── MessageBoxService.cs │ │ ├── OpenFileDialogService.cs │ │ └── GenericViewWindowService.cs │ ├── ViewModel │ │ ├── GenericViewModel.cs │ │ ├── MainWindowViewModel.cs │ │ ├── BooleanToVisibilityConverter.cs │ │ ├── ViewModelBase.cs │ │ ├── Helper.cs │ │ ├── ReportViewModel.cs │ │ └── PathListViewModel.cs │ ├── app.config │ ├── Themes │ │ ├── Converters.xaml │ │ ├── TextBlock.xaml │ │ ├── ItemContStyle.xaml │ │ ├── SetIdConverter.cs │ │ ├── Brushes.xaml │ │ ├── Datagrid.xaml │ │ ├── RoundedButton.xaml │ │ └── ProgressBar.xaml │ ├── App.xaml.cs │ ├── Infrastructure │ │ ├── ServiceContainer.cs │ │ ├── ServiceInjector.cs │ │ ├── TrackHelper.cs │ │ └── CSVWriter.cs │ ├── MainWindowResourceDictionary.xaml │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Model │ │ ├── ResultItem.cs │ │ └── Item.cs │ ├── App.xaml │ ├── MainWindow.xaml │ ├── RelayCommand.cs │ ├── DuplicatesDetectorService.cs │ ├── SoundFingerprinting.DuplicatesDetector.csproj │ └── DuplicatesDetectorFacade.cs ├── .nuget │ ├── NuGet.exe │ ├── NuGet.Config │ └── NuGet.targets ├── SoundFingerprinting.DuplicatesDetector.sln └── Settings.StyleCop ├── .gitignore └── licence.txt /src/SoundFingerprinting.DuplicatesDetector/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AddictedCS/soundfingerprinting.duplicatesdetector/HEAD/src/.nuget/NuGet.exe -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Application.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AddictedCS/soundfingerprinting.duplicatesdetector/HEAD/src/SoundFingerprinting.DuplicatesDetector/Application.ico -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AddictedCS/soundfingerprinting.duplicatesdetector/HEAD/src/SoundFingerprinting.DuplicatesDetector/Images/icon.png -------------------------------------------------------------------------------- /src/.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | release/ 2 | debug/ 3 | msbuild.log 4 | *.suo 5 | *.user 6 | bin 7 | Bin 8 | obj 9 | _ReSharper* 10 | *.csproj.user 11 | *.resharper.user 12 | *.suo 13 | *.cache 14 | *.nupkg 15 | TestResult.xml 16 | src/TestResults/ 17 | .vagrant 18 | packages*/ 19 | *.exe 20 | !NuGet.exe 21 | .vs/ -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/View/GenericView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.View 2 | { 3 | public partial class GenericView 4 | { 5 | public GenericView() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector 2 | { 3 | using System.Windows; 4 | 5 | public partial class MainWindow : Window 6 | { 7 | public MainWindow() 8 | { 9 | InitializeComponent(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/View/ReportView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.View 2 | { 3 | using System.Windows.Controls; 4 | 5 | public partial class ReportView : UserControl 6 | { 7 | public ReportView() 8 | { 9 | InitializeComponent(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/View/PathListView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.View 2 | { 3 | using System.Windows.Controls; 4 | 5 | public partial class PathListView : UserControl 6 | { 7 | public PathListView() 8 | { 9 | InitializeComponent(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/ISaveFileDialogService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System.Windows.Forms; 4 | 5 | internal interface ISaveFileDialogService 6 | { 7 | string Filename { get; } 8 | 9 | DialogResult SaveFile(string title, string filename, string extension); 10 | } 11 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/IOpenFileDialogService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System.Windows.Forms; 4 | 5 | public interface IOpenFileDialogService 6 | { 7 | string[] SelectedPaths { get; } 8 | 9 | DialogResult Show(string title, string filename, string filter, bool multiselect); 10 | } 11 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/ViewModel/GenericViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.ViewModel 2 | { 3 | using System.Collections.ObjectModel; 4 | 5 | public class GenericViewModel : ViewModelBase 6 | { 7 | private ObservableCollection workspaces; 8 | 9 | public ObservableCollection Workspaces 10 | { 11 | get { return workspaces ?? (workspaces = new ObservableCollection()); } 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/IWindowService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System; 4 | 5 | /// 6 | /// Window service works as mediator between the View and View/Model 7 | /// 8 | public interface IWindowService 9 | { 10 | void ShowDialog(IGenericViewWindow view, TViewModel viewModel, Action onDialogClose); 11 | 12 | void ShowDialog(IGenericViewWindow view, TDialogViewModel viewModel); 13 | } 14 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Themes/Converters.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/IFolderBrowserDialogService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System.Windows.Forms; 4 | 5 | /// 6 | /// Contract for FolderBrowserDialog service 7 | /// 8 | public interface IFolderBrowserDialogService 9 | { 10 | /// 11 | /// Gets selected path 12 | /// 13 | string SelectedPath { get; } 14 | 15 | /// 16 | /// Show FolderBrowserDialog 17 | /// 18 | /// Dialog results 19 | DialogResult Show(); 20 | } 21 | } -------------------------------------------------------------------------------- /licence.txt: -------------------------------------------------------------------------------- 1 | This file is part of Soundfingerprinting project - https://github.com/AddictedCS/soundfingerprinting 2 | 3 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 4 | 5 | You should have received a copy of the MIT along with Soundfingerprinting If not, see . -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/FolderBrowserDialogService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System.Windows.Forms; 4 | 5 | public class FolderBrowserDialogService : IFolderBrowserDialogService 6 | { 7 | #region IFolderBrowserDialogService Members 8 | 9 | public string SelectedPath { get; private set; } 10 | 11 | public DialogResult Show() 12 | { 13 | using (FolderBrowserDialog dlg = new FolderBrowserDialog()) 14 | { 15 | DialogResult result = dlg.ShowDialog(); 16 | SelectedPath = dlg.SelectedPath; 17 | return result; 18 | } 19 | } 20 | 21 | #endregion 22 | } 23 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector 2 | { 3 | using System.Windows; 4 | 5 | using SoundFingerprinting.DuplicatesDetector.Infrastructure; 6 | using SoundFingerprinting.DuplicatesDetector.Services; 7 | using SoundFingerprinting.DuplicatesDetector.ViewModel; 8 | 9 | public partial class App 10 | { 11 | protected override void OnStartup(StartupEventArgs e) 12 | { 13 | base.OnStartup(e); 14 | MainWindow window = new MainWindow(); 15 | ServiceInjector.InjectServices(); 16 | ViewModelBase mainViewModel = new MainWindowViewModel(); 17 | window.DataContext = mainViewModel; 18 | window.Show(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Infrastructure/ServiceContainer.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Infrastructure 2 | { 3 | using Ninject; 4 | 5 | /// 6 | /// Class which will hold services injected by dependency injection on Application startup 7 | /// Ninject lib is used for cross class injection 8 | /// 9 | /// 10 | /// Follows the Service Locator pattern. 11 | /// More details can be found here: 12 | /// http://martinfowler.com/articles/injection.html 13 | /// 14 | public static class ServiceContainer 15 | { 16 | /// 17 | /// Actual service container 18 | /// 19 | public static readonly IKernel Kernel = new StandardKernel(); 20 | } 21 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/IGenericViewWindow.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | 6 | /// 7 | /// Interface to be implemented by views 8 | /// 9 | /// 10 | /// The binding between the views and view-models will be performed by a 11 | /// mediator IWindowService which will take care of the abstraction 12 | /// 13 | public interface IGenericViewWindow 14 | { 15 | event EventHandler Closed; 16 | 17 | event CancelEventHandler Closing; 18 | 19 | bool? DialogResult { get; set; } 20 | 21 | object DataContext { get; set; } 22 | 23 | void Show(); 24 | 25 | void Close(); 26 | } 27 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/MainWindowResourceDictionary.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/SaveFileDialogService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System.Windows.Forms; 4 | 5 | internal class SaveFileDialogService : ISaveFileDialogService 6 | { 7 | #region ISaveFileDialogService Members 8 | 9 | public string Filename { get; private set; } 10 | 11 | public DialogResult SaveFile(string title, string filename, string extension) 12 | { 13 | using (SaveFileDialog sfd = new SaveFileDialog { Title = title, FileName = filename, Filter = extension }) 14 | { 15 | DialogResult result = sfd.ShowDialog(); 16 | Filename = sfd.FileName; 17 | return result; 18 | } 19 | } 20 | 21 | #endregion 22 | } 23 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Themes/TextBlock.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using System.Windows; 4 | 5 | [assembly: AssemblyTitle("DuplicateTracks")] 6 | [assembly: AssemblyDescription("Duplicate audio files detector. Tool for finding duplicate audio file by their perceptual identity.")] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany("Ciumac Sergiu")] 9 | [assembly: AssemblyProduct("DuplicateTracks")] 10 | [assembly: AssemblyCopyright("Copyright © Ciumac Sergiu 2017")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | [assembly: ComVisible(false)] 14 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] 15 | [assembly: AssemblyVersion("2.0.0")] 16 | [assembly: AssemblyFileVersion("2.0.0")] -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/ViewModel/MainWindowViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.ViewModel 2 | { 3 | using System.Collections.ObjectModel; 4 | 5 | /// 6 | /// Main window view model 7 | /// 8 | public class MainWindowViewModel : ViewModelBase 9 | { 10 | private ObservableCollection workspaces; 11 | 12 | public MainWindowViewModel() 13 | { 14 | /*Adding PathList view model to workspaces collection*/ 15 | ViewModelBase pathList = new PathListViewModel(); 16 | Workspaces.Add(pathList); 17 | } 18 | 19 | public ObservableCollection Workspaces 20 | { 21 | get { return workspaces ?? (workspaces = new ObservableCollection()); } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/WindowService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System; 4 | 5 | public class WindowService : IWindowService 6 | { 7 | #region IWindowService Members 8 | 9 | public void ShowDialog(IGenericViewWindow view, TViewModel viewModel, Action onDialogClose) 10 | { 11 | view.DataContext = viewModel; 12 | if (onDialogClose != null) 13 | { 14 | view.Closing += (o, args) => onDialogClose(o, args); 15 | } 16 | 17 | view.Show(); 18 | } 19 | 20 | public void ShowDialog(IGenericViewWindow view, TViewModel viewModel) 21 | { 22 | ShowDialog(view, viewModel, null); 23 | } 24 | 25 | #endregion 26 | } 27 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Model/ResultItem.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Model 2 | { 3 | using SoundFingerprinting.DAO.Data; 4 | 5 | public class ResultItem 6 | { 7 | private readonly TrackData track; 8 | 9 | public ResultItem(int setId, TrackData track) 10 | { 11 | SetId = setId; 12 | this.track = track; 13 | } 14 | 15 | public int SetId { get; private set; } 16 | 17 | public string FileName 18 | { 19 | get { return System.IO.Path.GetFileName(track.MetaFields["FilePath"]); } 20 | } 21 | 22 | public string Path 23 | { 24 | get { return track.MetaFields["FilePath"]; } 25 | } 26 | 27 | public double TrackLength 28 | { 29 | get { return track.Length; } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/IMessageBoxService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System.Windows; 4 | 5 | /// 6 | /// Service Contract to be implemented by the types which would like to provide MessageBox.Show services 7 | /// 8 | public interface IMessageBoxService 9 | { 10 | /// 11 | /// Show the MessageBox to the client 12 | /// 13 | /// Message to be shown 14 | /// Title of the MessageBox 15 | /// Buttons 16 | /// Image to be shown 17 | /// MessageBox results 18 | MessageBoxResult Show(string message, string title, MessageBoxButton buttons, MessageBoxImage image); 19 | } 20 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Themes/ItemContStyle.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/MessageBoxService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System.Windows; 4 | 5 | /// 6 | /// MessageBox service 7 | /// 8 | public class MessageBoxService : IMessageBoxService 9 | { 10 | #region IMessageBoxService Members 11 | 12 | /// 13 | /// Show actual MessageBox 14 | /// 15 | /// Message to be shown 16 | /// Title of the MessageBox 17 | /// Buttons in the MessageBox 18 | /// Image on the MessageBox 19 | /// MessageBox results 20 | public MessageBoxResult Show(string message, string title, MessageBoxButton buttons, MessageBoxImage image) 21 | { 22 | return MessageBox.Show(message, title, buttons, image); 23 | } 24 | 25 | #endregion 26 | } 27 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Themes/SetIdConverter.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Themes 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows.Data; 6 | using System.Windows.Media; 7 | 8 | /// 9 | /// Converter which alternates the color on duplicate sets 10 | /// 11 | [ValueConversion(typeof(object), typeof(int))] 12 | public class SetIdConverter : IValueConverter 13 | { 14 | #region IValueConverter Members 15 | 16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | if (value is int) 19 | { 20 | int setId = (int)value; 21 | return setId % 2 == 0 ? new SolidColorBrush(Color.FromArgb(100, 0, 100, 150)) : new SolidColorBrush(Colors.Transparent); 22 | } 23 | 24 | return new SolidColorBrush(Colors.Transparent); 25 | } 26 | 27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 28 | { 29 | throw new NotImplementedException(); 30 | } 31 | 32 | #endregion 33 | } 34 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/ViewModel/BooleanToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.ViewModel 2 | { 3 | using System; 4 | using System.Globalization; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | 8 | [ValueConversion(typeof(bool), typeof(Visibility))] 9 | public class BooleanToVisibilityConverter : IValueConverter 10 | { 11 | #region IValueConverter Members 12 | 13 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 14 | { 15 | bool isprocessing = (bool)value; 16 | return isprocessing ? Visibility.Visible : Visibility.Hidden; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | Visibility v = (Visibility)value; 22 | switch (v) 23 | { 24 | case Visibility.Hidden: 25 | return false; 26 | case Visibility.Collapsed: 27 | return false; 28 | case Visibility.Visible: 29 | return true; 30 | } 31 | 32 | return DependencyProperty.UnsetValue; 33 | } 34 | 35 | #endregion 36 | } 37 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/View/GenericView.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Themes/Brushes.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/OpenFileDialogService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System.Windows.Forms; 4 | 5 | /// 6 | /// Open file dialog service 7 | /// 8 | public class OpenFileDialogService : IOpenFileDialogService 9 | { 10 | #region IOpenFileDialogService Members 11 | 12 | public string[] SelectedPaths { get; private set; } 13 | 14 | /// 15 | /// Show open file dialog 16 | /// 17 | /// Title of the dialog 18 | /// Default filename 19 | /// Filter of the file dialog 20 | /// Multi-select enabled 21 | /// Dialog result 22 | public DialogResult Show(string title, string filename, string filter, bool multiselect) 23 | { 24 | using (OpenFileDialog ofd = new OpenFileDialog { Title = title, FileName = filename, Filter = filter, Multiselect = multiselect }) 25 | { 26 | DialogResult result = ofd.ShowDialog(); 27 | SelectedPaths = ofd.FileNames; 28 | return result; 29 | } 30 | } 31 | 32 | #endregion 33 | } 34 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoundFingerprinting.DuplicatesDetector", "SoundFingerprinting.DuplicatesDetector\SoundFingerprinting.DuplicatesDetector.csproj", "{572367D4-0F0C-4DC9-BE1C-4D037530D785}" 5 | EndProject 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{117D487C-9775-4689-B639-5B80E73DA38A}" 7 | ProjectSection(SolutionItems) = preProject 8 | .nuget\NuGet.Config = .nuget\NuGet.Config 9 | .nuget\NuGet.exe = .nuget\NuGet.exe 10 | .nuget\NuGet.targets = .nuget\NuGet.targets 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {572367D4-0F0C-4DC9-BE1C-4D037530D785}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {572367D4-0F0C-4DC9-BE1C-4D037530D785}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {572367D4-0F0C-4DC9-BE1C-4D037530D785}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {572367D4-0F0C-4DC9-BE1C-4D037530D785}.Release|Any CPU.Build.0 = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Infrastructure/ServiceInjector.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Infrastructure 2 | { 3 | using SoundFingerprinting.Audio; 4 | using SoundFingerprinting.Audio.Bass; 5 | using SoundFingerprinting.Builder; 6 | using SoundFingerprinting.DuplicatesDetector.Services; 7 | using SoundFingerprinting.InMemory; 8 | 9 | public static class ServiceInjector 10 | { 11 | public static void InjectServices() 12 | { 13 | ServiceContainer.Kernel.Bind().To(); 14 | ServiceContainer.Kernel.Bind().To(); 15 | ServiceContainer.Kernel.Bind().To(); 16 | ServiceContainer.Kernel.Bind().To(); 17 | ServiceContainer.Kernel.Bind().To(); 18 | ServiceContainer.Kernel.Bind().To(); 19 | 20 | ServiceContainer.Kernel.Bind().ToConstant(FingerprintCommandBuilder.Instance).InSingletonScope(); 21 | ServiceContainer.Kernel.Bind().ToConstant(QueryFingerprintService.Instance).InSingletonScope(); 22 | ServiceContainer.Kernel.Bind().ToSelf().InSingletonScope(); 23 | ServiceContainer.Kernel.Bind().ToSelf().InSingletonScope(); 24 | ServiceContainer.Kernel.Bind().To().InSingletonScope(); 25 | ServiceContainer.Kernel.Bind().To().InSingletonScope(); 26 | ServiceContainer.Kernel.Bind().To().InSingletonScope(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Infrastructure/TrackHelper.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Infrastructure 2 | { 3 | using System.Collections.Generic; 4 | using System.IO; 5 | 6 | using SoundFingerprinting.Audio; 7 | using SoundFingerprinting.DAO.Data; 8 | using SoundFingerprinting.Data; 9 | 10 | public class TrackHelper 11 | { 12 | private readonly IAudioService audioService; 13 | 14 | public TrackHelper(IAudioService audioService) 15 | { 16 | this.audioService = audioService; 17 | } 18 | 19 | public AudioSamples GetTrackSamples(TrackInfo track, int sampleRate, int secondsToRead, int startAtSecond) 20 | { 21 | string filePath = track.MetaFields["FilePath"]; 22 | if (track == null || filePath == null) 23 | { 24 | return null; 25 | } 26 | 27 | return audioService.ReadMonoSamplesFromFile(filePath, sampleRate, secondsToRead, startAtSecond); 28 | } 29 | 30 | public TrackInfo GetTrack(int mintracklen, int maxtracklen, string filename) 31 | { 32 | string artist, title, isrc; 33 | /*The song does not contain any tags*/ 34 | artist = "Unknown Artist"; 35 | title = "Unknown Title"; 36 | isrc = Path.GetFileNameWithoutExtension(filename); 37 | var meta = new Dictionary(); 38 | meta["FilePath"] = Path.GetFullPath(filename); 39 | 40 | double duration = audioService.GetLengthInSeconds(Path.GetFullPath(filename)); 41 | /*check the duration of a music file*/ 42 | if (duration < mintracklen || duration > maxtracklen) 43 | { 44 | return null; 45 | } 46 | 47 | return new TrackInfo(isrc, title, artist, meta, MediaType.Audio); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Model/Item.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Model 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | 6 | /// 7 | /// Class for folder representation in the UI element 8 | /// 9 | [Serializable] 10 | public class Item : INotifyPropertyChanged 11 | { 12 | /// 13 | /// Number of music files within the folder 14 | /// 15 | private int count; 16 | 17 | /// 18 | /// Path to folder 19 | /// 20 | private string path; 21 | 22 | #region INotifyPropertyChanged Members 23 | 24 | public event PropertyChangedEventHandler PropertyChanged; 25 | 26 | #endregion 27 | 28 | public bool IsFolder { get; set; } 29 | 30 | public string Path 31 | { 32 | get 33 | { 34 | return path; 35 | } 36 | 37 | set 38 | { 39 | if (path != value) 40 | { 41 | path = value; 42 | OnPropertyChanged("Path"); 43 | } 44 | } 45 | } 46 | 47 | public int Count 48 | { 49 | get 50 | { 51 | return count; 52 | } 53 | 54 | set 55 | { 56 | if (count != value) 57 | { 58 | count = value; 59 | OnPropertyChanged("Count"); 60 | } 61 | } 62 | } 63 | 64 | private void OnPropertyChanged(string property) 65 | { 66 | PropertyChangedEventHandler temp = PropertyChanged; 67 | if (temp != null) 68 | { 69 | PropertyChanged(this, new PropertyChangedEventArgs(property)); 70 | } 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/RelayCommand.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector 2 | { 3 | using System; 4 | using System.Windows.Input; 5 | 6 | public class RelayCommand : ICommand 7 | { 8 | /// 9 | /// Method which verifies whether the command can execute 10 | /// 11 | private readonly Predicate canExecute; 12 | 13 | /// 14 | /// Method to execute 15 | /// 16 | private readonly Action execute; 17 | 18 | public RelayCommand(Action execute) 19 | : this(execute, null) 20 | { 21 | } 22 | 23 | public RelayCommand(Action execute, Predicate canExecute) 24 | { 25 | this.execute = execute; 26 | this.canExecute = canExecute; 27 | } 28 | 29 | /// 30 | /// Fires when the CanExecute status of this command changes. 31 | /// 32 | public event EventHandler CanExecuteChanged 33 | { 34 | add 35 | { 36 | CommandManager.RequerySuggested += value; 37 | } 38 | 39 | remove 40 | { 41 | CommandManager.RequerySuggested -= value; 42 | } 43 | } 44 | 45 | /// 46 | /// Check if the method can be executed 47 | /// 48 | /// Parameter 49 | /// True/False 50 | public bool CanExecute(object parameter) 51 | { 52 | return canExecute == null || canExecute.Invoke(parameter); 53 | } 54 | 55 | /// 56 | /// Execute the method 57 | /// 58 | /// Parameter for execution 59 | public void Execute(object parameter) 60 | { 61 | execute(parameter); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /src/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | False 8 | 9 | 10 | 11 | 12 | False 13 | 14 | 15 | 16 | 17 | False 18 | 19 | 20 | 21 | 22 | False 23 | 24 | 25 | 26 | 27 | False 28 | 29 | 30 | 31 | 32 | False 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | False 43 | 44 | 45 | 46 | 47 | False 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Infrastructure/CSVWriter.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Infrastructure 2 | { 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Security.Permissions; 6 | using System.Text; 7 | 8 | /// 9 | /// Class for writing any object values in comma separated file 10 | /// 11 | [DebuggerDisplay("Path={pathToFile}")] 12 | public class CSVWriter 13 | { 14 | /// 15 | /// Separator used while writing to CVS 16 | /// 17 | private const char Separator = ','; 18 | 19 | /// 20 | /// Carriage return line feed 21 | /// 22 | private const string Crlf = "\r\n"; 23 | 24 | /// 25 | /// Path to file 26 | /// 27 | private readonly string pathToFile; 28 | 29 | /// 30 | /// Writer 31 | /// 32 | private StreamWriter writer; 33 | 34 | public CSVWriter(string pathToFile) 35 | { 36 | this.pathToFile = pathToFile; 37 | } 38 | 39 | /// 40 | /// Write the data into CSV 41 | /// 42 | /// Data to be written 43 | [FileIOPermission(SecurityAction.Demand)] 44 | public void Write(object[][] data) 45 | { 46 | if (data == null) 47 | { 48 | return; 49 | } 50 | 51 | using (writer = new StreamWriter(pathToFile)) 52 | { 53 | int cols = data[0].Length; 54 | StringBuilder builder = new StringBuilder(); 55 | for (int i = 0, n = data.Length; i < n; i++) 56 | { 57 | for (int j = 0; j < cols; j++) 58 | { 59 | builder.Append(data[i][j]); 60 | if (j != cols - 1) 61 | { 62 | builder.Append(Separator); 63 | } 64 | } 65 | 66 | builder.Append(Crlf); 67 | } 68 | 69 | writer.Write(builder.ToString()); 70 | writer.Close(); 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Themes/Datagrid.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 18 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/Services/GenericViewWindowService.cs: -------------------------------------------------------------------------------- 1 | namespace SoundFingerprinting.DuplicatesDetector.Services 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | 6 | using SoundFingerprinting.DuplicatesDetector.View; 7 | 8 | /// 9 | /// Generic view window service 10 | /// 11 | public class GenericViewWindowService : IGenericViewWindow 12 | { 13 | /// 14 | /// Lock object 15 | /// 16 | private static readonly object LockObject = new object(); 17 | 18 | /// 19 | /// Actual view (uninitialized) 20 | /// 21 | private GenericView view; 22 | 23 | #region IGenericViewWindow Members 24 | 25 | public event EventHandler Closed; 26 | 27 | public event CancelEventHandler Closing; 28 | 29 | public bool? DialogResult 30 | { 31 | get { return GetView().DialogResult; } 32 | set { GetView().DialogResult = value; } 33 | } 34 | 35 | public object DataContext 36 | { 37 | get { return GetView().DataContext; } 38 | set { GetView().DataContext = value; } 39 | } 40 | 41 | public void Show() 42 | { 43 | GetView().Show(); 44 | } 45 | 46 | public void Close() 47 | { 48 | GetView().Close(); 49 | view = null; 50 | } 51 | 52 | #endregion 53 | 54 | /// 55 | /// Lazy initialization of the view 56 | /// 57 | /// Actual view 58 | private GenericView GetView() 59 | { 60 | lock (LockObject) 61 | { 62 | if (view != null) 63 | { 64 | return view; 65 | } 66 | 67 | view = new GenericView(); 68 | view.Closed += (sender, e) => 69 | { 70 | if (Closed != null) 71 | { 72 | Closed(sender, e); 73 | } 74 | 75 | view = null; 76 | }; 77 | view.Closing += (sender, e) => 78 | { 79 | if (Closing != null) 80 | { 81 | Closing(sender, e); 82 | } 83 | }; 84 | return view; 85 | } 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /src/SoundFingerprinting.DuplicatesDetector/View/PathListView.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 |