Example #1
0
bool AnalyserGain::initialise(TrackPointer tio, int sampleRate, int totalSamples) {
    if (loadStored(tio) || totalSamples == 0) {
        return false;
    }
    m_bStepControl = m_pReplayGain->initialise((long)sampleRate, 2);
    return true;
}
Example #2
0
bool AnalyzerWaveform::initialize(TrackPointer tio, int sampleRate, int totalSamples) {
    m_skipProcessing = false;

    m_timer.start();

    if (totalSamples == 0) {
        qWarning() << "AnalyzerWaveform::initialize - no waveform/waveform summary";
        return false;
    }

    // If we don't need to calculate the waveform/wavesummary, skip.
    if (loadStored(tio)) {
        m_skipProcessing = true;
    } else {
        // Now actually initialize the AnalyzerWaveform:
        destroyFilters();
        createFilters(sampleRate);

        //TODO (vrince) Do we want to expose this as settings or whatever ?
        const int mainWaveformSampleRate = 441;
        // two visual sample per pixel in full width overview in full hd
        const int summaryWaveformSamples = 2 * 1920;

        m_waveform = WaveformPointer(new Waveform(
                sampleRate, totalSamples, mainWaveformSampleRate, -1));
        m_waveformSummary = WaveformPointer(new Waveform(
                sampleRate, totalSamples, mainWaveformSampleRate,
                summaryWaveformSamples));

        // Now, that the Waveform memory is initialized, we can set set them to
        // the TIO. Be aware that other threads of Mixxx can touch them from
        // now.
        tio->setWaveform(m_waveform);
        tio->setWaveformSummary(m_waveformSummary);

        m_waveformData = m_waveform->data();
        m_waveformSummaryData = m_waveformSummary->data();

        m_stride = WaveformStride(m_waveform->getAudioVisualRatio(),
                                  m_waveformSummary->getAudioVisualRatio());

        m_currentStride = 0;
        m_currentSummaryStride = 0;

        //debug
        //m_waveform->dump();
        //m_waveformSummary->dump();

    #ifdef TEST_HEAT_MAP
        test_heatMap = new QImage(256,256,QImage::Format_RGB32);
        test_heatMap->fill(0xFFFFFFFF);
    #endif
    }
    return !m_skipProcessing;
}
Example #3
0
void MozJSImplScope::localConnectForDbEval(OperationContext* txn, const char* dbName) {
    MozJSEntry entry(this);

    invariant(_opCtx == NULL);
    _opCtx = txn;

    if (_connectState == ConnectState::External)
        uasserted(12510, "externalSetup already called, can't call localConnect");
    if (_connectState == ConnectState::Local) {
        if (_localDBName == dbName)
            return;
        uasserted(12511,
                  str::stream() << "localConnect previously called with name " << _localDBName);
    }

    // NOTE: order is important here.  the following methods must be called after
    //       the above conditional statements.

    // install db access functions in the global object
    installDBAccess();

    // install the Mongo function object and instantiate the 'db' global
    _mongoLocalProto.install(_global);
    execCoreFiles();

    const char* const makeMongo = "_mongo = new Mongo()";
    exec(makeMongo, "local connect 2", false, true, true, 0);

    std::string makeDB = str::stream() << "db = _mongo.getDB(\"" << dbName << "\");";
    exec(makeDB, "local connect 3", false, true, true, 0);

    _connectState = ConnectState::Local;
    _localDBName = dbName;

    loadStored(txn);
}
Example #4
0
bool AnalyserBeats::initialise(TrackPointer tio, int sampleRate, int totalSamples) {
    if (totalSamples == 0) {
        return false;
    }

    bool bPreferencesBeatDetectionEnabled = static_cast<bool>(
        m_pConfig->getValueString(
            ConfigKey(BPM_CONFIG_KEY, BPM_DETECTION_ENABLED)).toInt());
    if (!bPreferencesBeatDetectionEnabled) {
        qDebug() << "Beat calculation is deactivated";
        return false;
    }

    bool bpmLock = tio->hasBpmLock();
    if (bpmLock) {
        qDebug() << "Track is BpmLocked: Beat calculation will not start";
        return false;
    }

    bool allow_above = static_cast<bool>(m_pConfig->getValueString(
        ConfigKey(BPM_CONFIG_KEY, BPM_ABOVE_RANGE_ENABLED)).toInt());
    if (allow_above) {
        m_iMinBpm = 0;
        m_iMaxBpm = 9999;
    } else {
        m_iMinBpm = m_pConfig->getValueString(ConfigKey(BPM_CONFIG_KEY, BPM_RANGE_START)).toInt();
        m_iMaxBpm = m_pConfig->getValueString(ConfigKey(BPM_CONFIG_KEY, BPM_RANGE_END)).toInt();
    }

    m_bPreferencesFixedTempo = static_cast<bool>(
        m_pConfig->getValueString(
            ConfigKey(BPM_CONFIG_KEY, BPM_FIXED_TEMPO_ASSUMPTION)).toInt());
    m_bPreferencesOffsetCorrection = static_cast<bool>(
        m_pConfig->getValueString(
            ConfigKey(BPM_CONFIG_KEY, BPM_FIXED_TEMPO_OFFSET_CORRECTION)).toInt());
    m_bPreferencesFastAnalysis = static_cast<bool>(
        m_pConfig->getValueString(
            ConfigKey(BPM_CONFIG_KEY, BPM_FAST_ANALYSIS_ENABLED)).toInt());


    QString library = m_pConfig->getValueString(
        ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYSER_BEAT_LIBRARY));
    QString pluginID = m_pConfig->getValueString(
        ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYSER_BEAT_PLUGIN_ID));

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

    // if we can load a stored track don't reanalyze it
    bool bShouldAnalyze = !loadStored(tio);

    if (bShouldAnalyze) {
        m_pVamp = new VampAnalyser();
        bShouldAnalyze = m_pVamp->Init(library, pluginID, m_iSampleRate, totalSamples,
                                       m_bPreferencesFastAnalysis);
        if (!bShouldAnalyze) {
            delete m_pVamp;
            m_pVamp = NULL;
        }
    }

    if (bShouldAnalyze) {
        qDebug() << "Beat calculation started with plugin" << pluginID;
    } else {
        qDebug() << "Beat calculation will not start";
    }

    return bShouldAnalyze;
}