示例#1
0
 private void BtnQueryFromMicrophoneClick(object sender, EventArgs e)
 {
     DefaultFingerprintConfiguration configuration = new DefaultFingerprintConfiguration();
     int secondsToRecord = (int)_nudSecondsToRecord.Value;
     int sampleRate = (int)_nudSampleRate.Value;
     string pathToFile = "mic_" + DateTime.Now.Ticks + ".wav";
     _gbQueryMicrophoneBox.Enabled = false;
     Task<float[]>.Factory.StartNew(() => audioService.ReadMonoFromMicrophoneToFile(pathToFile, sampleRate, secondsToRecord)).ContinueWith(
         task =>
             {
                 _gbQueryMicrophoneBox.Enabled = true;
                 WinQueryResults winQueryResults = new WinQueryResults(
                     secondsToRecord,
                     0,
                     (int)_nudHashtables.Value,
                     (int)_nudKeys.Value,
                     (int)_nudThreshold.Value,
                     WinUtils.GetStride((StrideType)_cmbStrideType.SelectedIndex, (int)_nudQueryStrideMax.Value, (int)_nudQueryStrideMin.Value, configuration.SamplesPerFingerprint),
                     tagService,
                     modelService,
                     queryCommandBuilder);
                 winQueryResults.Show();
                 winQueryResults.Refresh();
                 winQueryResults.ExtractCandidatesUsingSamples(task.Result);
             },
         TaskScheduler.FromCurrentSynchronizationContext());
 }
示例#2
0
        private void BtnStartClick(object sender, EventArgs e)
        {
            DefaultFingerprintConfiguration configuration = new DefaultFingerprintConfiguration();
            switch (hashAlgorithm)
            {
                case HashAlgorithm.LSH:
                    if (!fileList.Any())
                    {
                        MessageBox.Show(Resources.SelectFolderWithSongs, Resources.Songs, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;
                    }

                    WinQueryResults winQueryResults = new WinQueryResults(
                        _numSecondsToAnalyze.Enabled ? (int)_numSecondsToAnalyze.Value : 0,
                        _numStartAtSecond.Enabled ? (int)_numStartAtSecond.Value : 0,
                        (int)_nudHashtables.Value,
                        (int)_nudKeys.Value,
                        Convert.ToInt32(_nudThreshold.Value),
                        WinUtils.GetStride((StrideType)_cmbStrideType.SelectedIndex, (int)_nudQueryStrideMax.Value, (int)_nudQueryStrideMin.Value, configuration.SamplesPerFingerprint),
                        tagService,
                        modelService,
                        queryCommandBuilder);
                    winQueryResults.Show();
                    winQueryResults.Refresh();
                    winQueryResults.ExtractCandidatesWithMinHashAlgorithm(fileList);
                    break;
                case HashAlgorithm.NeuralHasher:
                    throw new NotImplementedException();
                case HashAlgorithm.None:
                    throw new NotImplementedException();
            }
        }
        private void BtnStartClick(object sender, EventArgs e)
        {
            DefaultFingerprintingConfiguration configuration = new DefaultFingerprintingConfiguration();
            switch (hashAlgorithm)
            {
                case HashAlgorithm.LSH:
                    if (!fileList.Any())
                    {
                        MessageBox.Show(Resources.SelectFolderWithSongs, Resources.Songs, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;
                    }

                    WinQueryResults winQueryResults = new WinQueryResults(
                        (int)_nudNumberOfFingerprints.Value,
                        (int)_numStaratSeconds.Value,
                        (int)_nudHashtables.Value,
                        (int)_nudKeys.Value,
                        Convert.ToInt32(_nudThreshold.Value),
                        WinUtils.GetStride((StrideType)_cmbStrideType.SelectedIndex, (int)_nudQueryStrideMax.Value, (int)_nudQueryStrideMin.Value, configuration.SamplesPerFingerprint),
                        tagService,
                        modelService,
                        queryBuilder);
                    winQueryResults.Show();
                    winQueryResults.Refresh();
                    winQueryResults.ExtractCandidatesWithMinHashAlgorithm(fileList);
                    break;
                case HashAlgorithm.NeuralHasher:
                    throw new NotImplementedException();
                case HashAlgorithm.None:
                    throw new NotImplementedException();
            }
        }
 private void BtnQueryFromMicrophoneClick(object sender, EventArgs e)
 {
     DefaultFingerprintingConfiguration configuration = new DefaultFingerprintingConfiguration();
     int secondsToRecord = (int)_nudSecondsToRecord.Value;
     int sampleRate = (int)_nudSampleRate.Value;
     string pathToFile = "mic_" + DateTime.Now.Ticks + ".wav";
     _gbQueryMicrophoneBox.Enabled = false;
     Task<float[]>.Factory.StartNew(() => audioService.RecordFromMicrophoneToFile(pathToFile, sampleRate, secondsToRecord)).ContinueWith(
         task =>
             {
                 _gbQueryMicrophoneBox.Enabled = true;
                 WinQueryResults winQueryResults = new WinQueryResults(
                     secondsToRecord,
                     0,
                     (int)_nudHashtables.Value,
                     (int)_nudKeys.Value,
                     (int)_nudThreshold.Value,
                     WinUtils.GetStride((StrideType)_cmbStrideType.SelectedIndex, (int)_nudQueryStrideMax.Value, (int)_nudQueryStrideMin.Value, configuration.SamplesPerFingerprint),
                     tagService,
                     modelService,
                     queryBuilder);
                 winQueryResults.Show();
                 winQueryResults.Refresh();
                 winQueryResults.ExtractCandidatesUsingSamples(task.Result);
             },
         TaskScheduler.FromCurrentSynchronizationContext());
 }