コード例 #1
0
ファイル: analyzerkey.cpp プロジェクト: Pegasus-RPG/mixxx
bool AnalyzerKey::loadStored(TrackPointer tio) const {
    bool bPreferencesFastAnalysisEnabled = static_cast<bool>(
        m_pConfig->getValueString(
            ConfigKey(KEY_CONFIG_KEY, KEY_FAST_ANALYSIS)).toInt());

    QString library = m_pConfig->getValueString(
        ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_KEY_LIBRARY));
    QString pluginID = m_pConfig->getValueString(
        ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_KEY_PLUGIN_ID));

    // TODO(rryan): This belongs elsewhere.
    if (library.isEmpty() || library.isNull())
        library = "libmixxxminimal";

    // TODO(rryan): This belongs elsewhere.
    if (pluginID.isEmpty() || pluginID.isNull())
        pluginID = VAMP_ANALYZER_KEY_DEFAULT_PLUGIN_ID;

    const Keys& keys = tio->getKeys();
    if (keys.isValid()) {
        QString version = keys.getVersion();
        QString subVersion = keys.getSubVersion();

        QHash<QString, QString> extraVersionInfo = getExtraVersionInfo(
            pluginID, bPreferencesFastAnalysisEnabled);
        QString newVersion = KeyFactory::getPreferredVersion();
        QString newSubVersion = KeyFactory::getPreferredSubVersion(extraVersionInfo);

        if (version == newVersion && subVersion == newSubVersion) {
            // If the version and settings have not changed then if the world is
            // sane, re-analyzing will do nothing.
            qDebug() << "Keys version/sub-version unchanged since previous analysis. Not analyzing.";
            return true;
        } else if (m_bPreferencesReanalyzeEnabled) {
            return false;
        } else {
            qDebug() << "Track has previous key detection result that is not up"
                     << "to date with latest settings but user preferences"
                     << "indicate we should not re-analyze it.";
            return true;
        }
    } else {
        // If we got here, we want to analyze this track.
        return false;
    }
}
コード例 #2
0
ファイル: analyserkey.cpp プロジェクト: kain88-de/mixxx
// TODO(XXX): Get rid of the horrible duplication here between initialise and
// loadStored.
bool AnalyserKey::initialise(TrackPointer tio, int sampleRate, int totalSamples) {
    if (totalSamples == 0) {
        return false;
    }

    m_bPreferencesKeyDetectionEnabled = static_cast<bool>(
                                            m_pConfig->getValueString(
                                                    ConfigKey(KEY_CONFIG_KEY, KEY_DETECTION_ENABLED)).toInt());
    if (!m_bPreferencesKeyDetectionEnabled) {
        qDebug() << "Key detection is deactivated";
        return false;
    }

    m_bPreferencesFastAnalysisEnabled = static_cast<bool>(
                                            m_pConfig->getValueString(
                                                    ConfigKey(KEY_CONFIG_KEY, KEY_FAST_ANALYSIS)).toInt());
    m_bPreferencesReanalyzeEnabled = static_cast<bool>(
                                         m_pConfig->getValueString(
                                                 ConfigKey(KEY_CONFIG_KEY, KEY_REANALYZE_WHEN_SETTINGS_CHANGE)).toInt());

    QString library = m_pConfig->getValueString(
                          ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYSER_KEY_LIBRARY),
                          // TODO(rryan) this default really doesn't belong here.
                          "libmixxxminimal");
    QString pluginID = m_pConfig->getValueString(
                           ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYSER_KEY_PLUGIN_ID),
                           // TODO(rryan) this default really doesn't belong here.
                           VAMP_ANALYSER_KEY_DEFAULT_PLUGIN_ID);

    m_pluginId = pluginID;
    m_iSampleRate = sampleRate;
    m_iTotalSamples = totalSamples;

    bool bShouldAnalyze = false;
    const Keys& keys = tio->getKeys();
    if (keys.isValid()) {
        QString version = keys.getVersion();
        QString subVersion = keys.getSubVersion();

        QHash<QString, QString> extraVersionInfo = getExtraVersionInfo(
                    m_pluginId, m_bPreferencesFastAnalysisEnabled);
        QString newVersion = KeyFactory::getPreferredVersion();
        QString newSubVersion = KeyFactory::getPreferredSubVersion(extraVersionInfo);

        if (version == newVersion && subVersion == newSubVersion) {
            // If the version and settings have not changed then if the world is
            // sane, re-analyzing will do nothing.
            bShouldAnalyze = false;
            qDebug() << "Keys version/sub-version unchanged since previous analysis. Not analyzing.";
        } else if (m_bPreferencesReanalyzeEnabled) {
            bShouldAnalyze = true;
        } else {
            bShouldAnalyze = false;
            qDebug() << "Track has previous key detection result that is not up"
                     << "to date with latest settings but user preferences"
                     << "indicate we should not re-analyze it.";
        }
    } else {
        // No valid keys stored so we want to analyze this track.
        bShouldAnalyze = true;
    }

    if (bShouldAnalyze) {
        m_pVamp = new VampAnalyser(m_pConfig);
        bShouldAnalyze = m_pVamp->Init(
                             library, m_pluginId, sampleRate, totalSamples,
                             m_bPreferencesFastAnalysisEnabled);
        if (!bShouldAnalyze) {
            delete m_pVamp;
            m_pVamp = NULL;
        }
    }

    if (bShouldAnalyze) {
        qDebug() << "Key calculation started with plugin" << m_pluginId;
    } else {
        qDebug() << "Key calculation will not start.";
    }

    return bShouldAnalyze;
}