コード例 #1
0
ファイル: guiprefs.cpp プロジェクト: b0m0x/is_KeyFinder
PrefsDialog::PrefsDialog(QWidget *parent): QDialog(parent),ui(new Ui::PrefsDialog){
  // map dropdown values to indices
  listTagFormat << TAG_FORMAT_KEYS;
  listTagFormat << TAG_FORMAT_CUSTOM;
  listTagFormat << TAG_FORMAT_BOTH;
  listStartingFreq << 27.5;
  listStartingFreq << 55;
  listStartingFreq << 110;
  listStartingFreq << 220;
  listStartingFreq << 440;
  listStartingFreq << 880;
  listHopSize << 128;
  listHopSize << 256;
  listHopSize << 512;
  listHopSize << 1024;
  listHopSize << 2048;
  listHopSize << 4096;
  listHopSize << 8192;
  listHopSize << 16384;
  listHopSize << 32768;
  listHopSize << 65536;
  listTemporalWindow << KeyFinder::WINDOW_BLACKMAN;
  listTemporalWindow << KeyFinder::WINDOW_HAMMING;
  listTemporalWindow << KeyFinder::WINDOW_HANN;
  listFftFrameSize << 512;
  listFftFrameSize << 1024;
  listFftFrameSize << 2048;
  listFftFrameSize << 4096;
  listFftFrameSize << 8192;
  listFftFrameSize << 16384;
  listFftFrameSize << 32768;
  listFftFrameSize << 65536;
  listFftFrameSize << 131072;
  listFftFrameSize << 262144;
  listTuningMethod << KeyFinder::TUNING_HARTE;
  listTuningMethod << KeyFinder::TUNING_BIN_ADAPTIVE;
  listSegmentation << KeyFinder::SEGMENTATION_NONE;
  listSegmentation << KeyFinder::SEGMENTATION_HARTE;
  listSegmentation << KeyFinder::SEGMENTATION_COSINE;
  listSegmentation << KeyFinder::SEGMENTATION_ARBITRARY;
  listToneProfile << KeyFinder::TONE_PROFILE_KRUMHANSL;
  listToneProfile << KeyFinder::TONE_PROFILE_TEMPERLEY;
  listToneProfile << KeyFinder::TONE_PROFILE_GOMEZ;
  listToneProfile << KeyFinder::TONE_PROFILE_SHAATH;
  listToneProfile << KeyFinder::TONE_PROFILE_CUSTOM;
  listSimilarityMeasure << KeyFinder::SIMILARITY_COSINE;
  listSimilarityMeasure << KeyFinder::SIMILARITY_CORRELATION;

  // UI
  ui->setupUi(this);
  this->setWindowFlags(Qt::WindowTitleHint | Qt::CustomizeWindowHint);

  // get values from preferences
  Preferences p;
  ui->writeToFilesAutomatically->setChecked(p.getWriteToFilesAutomatically());
  ui->parallelBatchJobs->setChecked(p.getParallelBatchJobs());
  ui->writeToTagComment->setChecked(p.getWriteToTagComment());
  ui->writeToTagGrouping->setChecked(p.getWriteToTagGrouping());
  ui->writeToTagKey->setChecked(p.getWriteToTagKey());
  ui->writeToFilePrefix->setChecked(p.getWriteToFilePrefix());
  ui->writeToFileSuffix->setChecked(p.getWriteToFileSuffix());
  ui->filenameDelimiter->setText(p.getFilenameDelimiter());
  ui->skipFilesWithExistingTags->setChecked(p.getSkipFilesWithExistingTags());
  ui->temporalWindow->setCurrentIndex(listTemporalWindow.indexOf(p.getTemporalWindow()));
  ui->segmentation->setCurrentIndex(listSegmentation.indexOf(p.getSegmentation()));
  ui->similarityMeasure->setCurrentIndex(listSimilarityMeasure.indexOf(p.getSimilarityMeasure()));
  ui->tagFormat->setCurrentIndex(listTagFormat.indexOf(p.getTagFormat()));
  ui->hopSize->setCurrentIndex(listHopSize.indexOf(p.getHopSize()));
  ui->fftFrameSize->setCurrentIndex(listFftFrameSize.indexOf(p.getFftFrameSize()));
  ui->octaves->setValue(p.getOctaves());
  ui->bps->setValue(p.getBpo()/12);
  ui->octaveOffset->setChecked(p.getOffsetToC());
  ui->dFactor->setValue(p.getDFactor());
  ui->toneProfile->setCurrentIndex(listToneProfile.indexOf(p.getToneProfile()));
  ui->hcdfPeakPickingNeighbours->setValue(p.getHcdfPeakPickingNeighbours());
  ui->arbitrarySegments->setValue(p.getArbitrarySegments());
  ui->hcdfGaussianSize->setValue(p.getHcdfGaussianSize());
  ui->tuningMethod->setCurrentIndex(listTuningMethod.indexOf(p.getTuningMethod()));
  ui->hcdfGaussianSigma->setValue(p.getHcdfGaussianSigma());
  ui->stFreq->setCurrentIndex(listStartingFreq.indexOf(p.getStartingFreqA()));
  ui->directSkStretch->setValue(p.getDirectSkStretch());
  ui->detunedBandWeight->setValue(p.getDetunedBandWeight());
  ui->iTunesLibraryPath->setText(p.getITunesLibraryPath());
  ui->traktorLibraryPath->setText(p.getTraktorLibraryPath());
  ui->seratoLibraryPath->setText(p.getSeratoLibraryPath());

  std::vector<float> ctp = p.getCustomToneProfile();
  ui->maj0->setValue(ctp[0]);
  ui->maj1->setValue(ctp[1]);
  ui->maj2->setValue(ctp[2]);
  ui->maj3->setValue(ctp[3]);
  ui->maj4->setValue(ctp[4]);
  ui->maj5->setValue(ctp[5]);
  ui->maj6->setValue(ctp[6]);
  ui->maj7->setValue(ctp[7]);
  ui->maj8->setValue(ctp[8]);
  ui->maj9->setValue(ctp[9]);
  ui->maj10->setValue(ctp[10]);
  ui->maj11->setValue(ctp[11]);
  ui->min0->setValue(ctp[12]);
  ui->min1->setValue(ctp[13]);
  ui->min2->setValue(ctp[14]);
  ui->min3->setValue(ctp[15]);
  ui->min4->setValue(ctp[16]);
  ui->min5->setValue(ctp[17]);
  ui->min6->setValue(ctp[18]);
  ui->min7->setValue(ctp[19]);
  ui->min8->setValue(ctp[20]);
  ui->min9->setValue(ctp[21]);
  ui->min10->setValue(ctp[22]);
  ui->min11->setValue(ctp[23]);

  QStringList ckc = p.getCustomKeyCodes();
  ui->majKey0->setText(ckc[0]);   ui->minKey0->setText(ckc[1]);
  ui->majKey1->setText(ckc[2]);   ui->minKey1->setText(ckc[3]);
  ui->majKey2->setText(ckc[4]);   ui->minKey2->setText(ckc[5]);
  ui->majKey3->setText(ckc[6]);   ui->minKey3->setText(ckc[7]);
  ui->majKey4->setText(ckc[8]);   ui->minKey4->setText(ckc[9]);
  ui->majKey5->setText(ckc[10]);  ui->minKey5->setText(ckc[11]);
  ui->majKey6->setText(ckc[12]);  ui->minKey6->setText(ckc[13]);
  ui->majKey7->setText(ckc[14]);  ui->minKey7->setText(ckc[15]);
  ui->majKey8->setText(ckc[16]);  ui->minKey8->setText(ckc[17]);
  ui->majKey9->setText(ckc[18]);  ui->minKey9->setText(ckc[19]);
  ui->majKey10->setText(ckc[20]); ui->minKey10->setText(ckc[21]);
  ui->majKey11->setText(ckc[22]); ui->minKey11->setText(ckc[23]);
  ui->silence->setText(ckc[24]);

  // enable/disable fields as necessary
  tuningEnabled();
  binAdaptiveTuningEnabled();
  segmentationEnabled();
  customProfileEnabled();
  filenameDelimiterEnabled();

  //relative sizing on Mac only
#ifdef Q_OS_MAC
  QFont smallerFont;
  smallerFont.setPointSize(smallerFont.pointSize() - 2);
  for(int i=0; i<ui->gridLayoutKeyCodes->count(); i++)
    if(!ui->gridLayoutKeyCodes->itemAt(i)->isEmpty())
      if(ui->gridLayoutKeyCodes->itemAt(i)->widget()->inherits("QLabel"))
        ui->gridLayoutKeyCodes->itemAt(i)->widget()->setFont(smallerFont);
  for(int i=0; i<ui->customMajor->count(); i++)
    if(!ui->customMajor->itemAt(i)->isEmpty())
      if(ui->customMajor->itemAt(i)->widget()->inherits("QLabel"))
        ui->customMajor->itemAt(i)->widget()->setFont(smallerFont);
  for(int i=0; i<ui->customMinor->count(); i++)
    if(!ui->customMinor->itemAt(i)->isEmpty())
      if(ui->customMinor->itemAt(i)->widget()->inherits("QLabel"))
        ui->customMinor->itemAt(i)->widget()->setFont(smallerFont);
#endif
}
コード例 #2
0
ファイル: guiprefs.cpp プロジェクト: b0m0x/is_KeyFinder
void PrefsDialog::on_toneProfile_currentIndexChanged(int /*index*/){
  customProfileEnabled();
}
コード例 #3
0
ファイル: guiprefs.cpp プロジェクト: GoBijan/is_KeyFinder
PrefsDialog::PrefsDialog(QWidget *parent): QDialog(parent),ui(new Ui::PrefsDialog){
	ui->setupUi(this);
	this->setWindowFlags(Qt::WindowTitleHint | Qt::CustomizeWindowHint);

	// initialise Preferences object to ensure initial QSettings is written
	Preferences prefsObj;

	// these strings store the chars relating to each index of their dropdowns
	temporalWindowComboIndex = "bmn";
	hcdfComboIndex = "nhca";
	similarityMeasureComboIndex = "ck";
  tagFieldComboIndex = "cgk";
  tagFormatComboIndex = "kcb";

	// set preferences from QSettings
	QSettings settings;

	settings.beginGroup("analysisFrequencies");
	ui->stFreq->setCurrentIndex(log2(settings.value("startingFrequencyA").toFloat()/27.5));
	ui->octaves->setValue(settings.value("numOctaves").toInt());
	ui->octaveOffset->setChecked(settings.value("octaveBeginOffset").toInt() > 0);
	ui->bps->setValue(settings.value("bandsPerSemitone").toInt());
	settings.endGroup();

	settings.beginGroup("spectralAnalysis");
	ui->temporalWindow->setCurrentIndex(temporalWindowComboIndex.indexOf(settings.value("temporalWindow").toChar()));
	ui->fftFrameSize->setCurrentIndex(log2(settings.value("fftFrameSize").toInt()/512));
	ui->hopSize->setCurrentIndex(log2(settings.value("hopSize").toInt()/128));
	ui->directSkStretch->setValue(settings.value("directSkStretch").toFloat());
	settings.endGroup();

	settings.beginGroup("downsampling");
	ui->dFactor->setValue(settings.value("dFactor").toInt());
	settings.endGroup();

	settings.beginGroup("tuning");
	ui->tuningMethod->setCurrentIndex(settings.value("tuningMethod").toInt());
	ui->detunedBandWeight->setValue(settings.value("detunedBandWeight").toFloat());
	settings.endGroup();

	settings.beginGroup("harmonicChangeDetectionFunction");
	ui->hcdf->setCurrentIndex(hcdfComboIndex.indexOf(settings.value("hcdf").toChar()));
	ui->hcdfGaussianSize->setValue(settings.value("hcdfGaussianSize").toInt());
	ui->hcdfGaussianSigma->setValue(settings.value("hcdfGaussianSigma").toFloat());
	ui->hcdfPeakPickingNeighbours->setValue(settings.value("hcdfPeakPickingNeighbours").toInt());
	ui->hcdfArbitrarySegments->setValue(settings.value("hcdfArbitrarySegments").toInt());
	settings.endGroup();

	settings.beginGroup("keyClassification");
  ui->toneProfile->setCurrentIndex(settings.value("toneProfile").toInt());
	ui->similarityMeasure->setCurrentIndex(similarityMeasureComboIndex.indexOf(settings.value("similarityMeasure").toChar()));
	settings.endGroup();

	settings.beginGroup("customToneProfile");
	ui->maj0->setValue(settings.value("maj0").toFloat());
	ui->maj1->setValue(settings.value("maj1").toFloat());
	ui->maj2->setValue(settings.value("maj2").toFloat());
	ui->maj3->setValue(settings.value("maj3").toFloat());
	ui->maj4->setValue(settings.value("maj4").toFloat());
	ui->maj5->setValue(settings.value("maj5").toFloat());
	ui->maj6->setValue(settings.value("maj6").toFloat());
	ui->maj7->setValue(settings.value("maj7").toFloat());
	ui->maj8->setValue(settings.value("maj8").toFloat());
	ui->maj9->setValue(settings.value("maj9").toFloat());
	ui->maj10->setValue(settings.value("maj10").toFloat());
	ui->maj11->setValue(settings.value("maj11").toFloat());
	ui->min0->setValue(settings.value("min0").toFloat());
	ui->min1->setValue(settings.value("min1").toFloat());
	ui->min2->setValue(settings.value("min2").toFloat());
	ui->min3->setValue(settings.value("min3").toFloat());
	ui->min4->setValue(settings.value("min4").toFloat());
	ui->min5->setValue(settings.value("min5").toFloat());
	ui->min6->setValue(settings.value("min6").toFloat());
	ui->min7->setValue(settings.value("min7").toFloat());
	ui->min8->setValue(settings.value("min8").toFloat());
	ui->min9->setValue(settings.value("min9").toFloat());
	ui->min10->setValue(settings.value("min10").toFloat());
	ui->min11->setValue(settings.value("min11").toFloat());
	settings.endGroup();

	settings.beginGroup("customKeyCodes");
	ui->majKey0->setText(settings.value("majKey0").toString());
	ui->majKey1->setText(settings.value("majKey1").toString());
	ui->majKey2->setText(settings.value("majKey2").toString());
	ui->majKey3->setText(settings.value("majKey3").toString());
	ui->majKey4->setText(settings.value("majKey4").toString());
	ui->majKey5->setText(settings.value("majKey5").toString());
	ui->majKey6->setText(settings.value("majKey6").toString());
	ui->majKey7->setText(settings.value("majKey7").toString());
	ui->majKey8->setText(settings.value("majKey8").toString());
	ui->majKey9->setText(settings.value("majKey9").toString());
	ui->majKey10->setText(settings.value("majKey10").toString());
	ui->majKey11->setText(settings.value("majKey11").toString());
	ui->minKey0->setText(settings.value("minKey0").toString());
	ui->minKey1->setText(settings.value("minKey1").toString());
	ui->minKey2->setText(settings.value("minKey2").toString());
	ui->minKey3->setText(settings.value("minKey3").toString());
	ui->minKey4->setText(settings.value("minKey4").toString());
	ui->minKey5->setText(settings.value("minKey5").toString());
	ui->minKey6->setText(settings.value("minKey6").toString());
	ui->minKey7->setText(settings.value("minKey7").toString());
	ui->minKey8->setText(settings.value("minKey8").toString());
	ui->minKey9->setText(settings.value("minKey9").toString());
	ui->minKey10->setText(settings.value("minKey10").toString());
	ui->minKey11->setText(settings.value("minKey11").toString());
	ui->silence->setText(settings.value("silence").toString());
	settings.endGroup();

  settings.beginGroup("tags");
  ui->tagFormat->setCurrentIndex(tagFormatComboIndex.indexOf(settings.value("tagFormat").toChar()));
  ui->tagField->setCurrentIndex(tagFieldComboIndex.indexOf(settings.value("tagField").toChar()));
  ui->writeTagsAutomatically->setChecked(settings.value(("writeTagsAutomatically")).toBool());
  settings.endGroup();

	// enable/disable fields as necessary
	tuningEnabled();
	binAdaptiveTuningEnabled();
	hcdfEnabled();
	customProfileEnabled();

  //relative sizing on Mac only
  #ifdef Q_OS_MAC
    QFont smallerFont;
    smallerFont.setPointSize(smallerFont.pointSize() - 2);
    for(int i=0; i<ui->gridLayoutKeyCodes->count(); i++)
      if(!ui->gridLayoutKeyCodes->itemAt(i)->isEmpty())
        if(ui->gridLayoutKeyCodes->itemAt(i)->widget()->inherits("QLabel"))
          ui->gridLayoutKeyCodes->itemAt(i)->widget()->setFont(smallerFont);
    for(int i=0; i<ui->customMajor->count(); i++)
      if(!ui->customMajor->itemAt(i)->isEmpty())
        if(ui->customMajor->itemAt(i)->widget()->inherits("QLabel"))
          ui->customMajor->itemAt(i)->widget()->setFont(smallerFont);
    for(int i=0; i<ui->customMinor->count(); i++)
      if(!ui->customMinor->itemAt(i)->isEmpty())
        if(ui->customMinor->itemAt(i)->widget()->inherits("QLabel"))
          ui->customMinor->itemAt(i)->widget()->setFont(smallerFont);
  #endif
}