Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            // Use PFFFT as FFT implementation
            FFTFactory.Factory = new Aurio.PFFFT.FFTFactory();
            // Use Soxr as resampler implementation
            ResamplerFactory.Factory = new Aurio.Soxr.ResamplerFactory();
            // Use FFmpeg for file reading/decoding
            AudioStreamFactory.AddFactory(new FFmpegAudioStreamFactory());
        }
Пример #2
0
        private static void Main(string[] args)
        {
            // Use PFFFT as FFT implementation
            FFTFactory.Factory = new Aurio.PFFFT.FFTFactory();
            // Use Soxr as resampler implementation
            ResamplerFactory.Factory = new Aurio.Soxr.ResamplerFactory();
            // Use FFmpeg for file reading/decoding
            AudioStreamFactory.AddFactory(new FFmpegAudioStreamFactory());

            try
            {
                // read config file
                Dictionary <string, double> mapping = ReadConfig(args[0]);

                // read input dir
                DirectoryInfo indir = new DirectoryInfo(args[1]);

                // read output dir
                DirectoryInfo outdir = new DirectoryInfo(args[2]);
                if (!outdir.Exists)
                {
                    outdir.Create();
                }

                Process(mapping, indir, outdir);
            }
            catch (Exception e)
            {
                Console.WriteLine("Batch Resampling Tool to change the playback speed of audio files");
                Console.WriteLine();
                Console.WriteLine("Error: " + e.Message);
                Console.WriteLine();

                var info = "Usage: BatchResampler mappingFile inputDirectory outputDirectory" + Environment.NewLine +
                           Environment.NewLine +
                           "The mappingFile is a text file with at least one line of the pattern 'filenamePattern;resamplingFactor' (without quotes), " +
                           "where the filenamePattern can be a filename or a filename wildcard expression to be matched in the input directory, and the " +
                           "resamplingFactor is a floating point value specifying the input:output resampling ratio with which the files will be written" +
                           "to the output directory. The simplest mappingFile would be '*;1', which means that all files in the input directory will be" +
                           "resampled with a factor of 1.0 (i.e. no resampling at all) and written to the output directory. The nominal sampling rate of a file" +
                           "stays untouched, leading to altered playback speeds." + Environment.NewLine +
                           "A mappingFile with the content '*.wav;0.5' speeds up all wave audio files to 200% playback speed because they are getting resampled " +
                           "to half of their effective sampling rate while the nominal playback sample rate stays the same, cutting their playback duration in half.";

                Console.WriteLine(info);
            }
        }
Пример #3
0
        public MainWindow()
        {
            // Use PFFFT as FFT implementation
            FFTFactory.Factory = new Aurio.PFFFT.FFTFactory();
            // Use Soxr as resampler implementation
            ResamplerFactory.Factory = new Aurio.Soxr.ResamplerFactory();
            // Use FFmpeg for file reading/decoding
            AudioStreamFactory.AddFactory(new FFmpegAudioStreamFactory());

            recentProjects = new RecentProjects();

            /*
             * The menu items of the recently opened project are handled here in code behind
             * because in XAML (ItemsSource/CompositeCollection/CollectionViewSource/CollectionContainer)
             * there's a few problems I spent too much time with and could not solve. This
             * programmatic solution works perfectly.
             *
             * - When overriding the ItemContainerStyle, which is necessary to automatically
             *   set the Header and Command, the style breaks... this is probably because of
             *   the weird style combination I'm using in this app and wouldn't happen with
             *   the default style (setting ItemContainerStyle replaces the style in the locally
             *   included style file and falls back to proerties of the default style for the app).
             * - When setting the header text through the style, the header text of all statically
             *   defined MenuItems gets overwritten because they don't have the header directly
             *   set but get the header text from the associated command. So the header text
             *   overrules the command text.
             */
            recentProjects.MenuEntries.CollectionChanged += delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) {
                // Always rebuilt the whole menu... happens very seldomly and shouldn't be a noticable performance impact
                int separatorIndex = FileMenu.Items.IndexOf(RecentSeparator);

                // Clear old entries
                if (FileMenu.Items.Count > (separatorIndex + 1))
                {
                    for (int x = FileMenu.Items.Count - 1; x > separatorIndex; x--)
                    {
                        FileMenu.Items.RemoveAt(x);
                    }
                }

                Debug.Assert(FileMenu.Items.Count == separatorIndex + 1, "wrong menu delete count");

                // Add new entries
                int count = 0;
                foreach (RecentProjects.RecentEntry entry in recentProjects.MenuEntries)
                {
                    // Determine if this item represents a real project to be numbered
                    bool projectEntry = entry.Parameter != null && entry.Parameter != RecentProjects.ClearCommand;

                    FileMenu.Items.Add(new MenuItem {
                        Header           = (projectEntry ? (++count) + " " : "") + entry.Title.Replace("_", "__"),
                        IsEnabled        = entry.Enabled,
                        Command          = Commands.FileOpenRecentProject,
                        CommandParameter = entry.Parameter
                    });
                }

                Debug.Assert(FileMenu.Items.Count == separatorIndex + 1 + recentProjects.MenuEntries.Count, "wrong menu item count");
            };

            project   = new Project();
            trackList = new TrackList <AudioTrack>();

            InitializeComponent();
            recentProjects.Load();
        }
Пример #4
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("no file(s) specified");
                Console.WriteLine();
                Console.WriteLine("Usage: MusicDetector file_1 file_2 ... file_n");
                Console.WriteLine("");
                Console.WriteLine("This tool expects at least one file, either specified as filename or " +
                                  "filename wildcard pattern. It scans all files for music content and writes " +
                                  "detection results in separate text files named {file_x}.music. Errors are logged " +
                                  "to a seperate error.log text file.");
                return;
            }

            // Use PFFFT as FFT implementation
            FFTFactory.Factory = new Aurio.PFFFT.FFTFactory();
            // Use Soxr as resampler implementation
            ResamplerFactory.Factory = new Aurio.Soxr.ResamplerFactory();
            // Use FFmpeg for file reading/decoding
            AudioStreamFactory.AddFactory(new FFmpegAudioStreamFactory());

            Queue <FileInfo> scanQueue = new Queue <FileInfo>();

            foreach (string file in args)
            {
                if (file.Contains("*"))
                {
                    int slashIndex = file.LastIndexOf(@"\");
                    var di         = new DirectoryInfo(slashIndex > -1 ? file.Substring(0, slashIndex) : ".");
                    foreach (var fi in di.GetFiles(file.Substring(slashIndex > -1 ? slashIndex + 1 : 0), SearchOption.TopDirectoryOnly))
                    {
                        scanQueue.Enqueue(fi);
                    }
                }
                else
                {
                    scanQueue.Enqueue(new FileInfo(file));
                }
            }

            FileInfo     errorLogFileInfo = new FileInfo("error.log");
            StreamWriter errorLogWriter   = errorLogFileInfo.AppendText();

            foreach (var fi in scanQueue)
            {
                try {
                    if (fi.Exists && fi.Length > 0)
                    {
                        new CFA(new AudioTrack(fi), CFA.DEFAULT_THRESHOLD, true, true).Run();
                    }
                    else
                    {
                        throw new FileNotFoundException(String.Format("file '{0}' not existing or empty, skipping", fi.FullName));
                    }
                }
                catch (FileNotFoundException e) {
                    Console.WriteLine(DateTime.Now + " " + e.Message);
                    errorLogWriter.WriteLine(DateTime.Now + " " + e.Message);
                }
                catch (Exception e) {
                    Console.WriteLine(DateTime.Now + " " + e.ToString());
                    Console.WriteLine();

                    errorLogWriter.WriteLine(DateTime.Now + " " + fi.FullName);
                    errorLogWriter.WriteLine(e.ToString());
                }
            }

            errorLogWriter.Flush();
            errorLogWriter.Close();
        }