Beispiel #1
0
void BpmControl::slotTapFilter(double averageLength, int numSamples) {
    // averageLength is the average interval in milliseconds tapped over
    // numSamples samples.  Have to convert to BPM now:

    if (averageLength <= 0)
        return;

    if (numSamples < 4)
        return;

    // (60 seconds per minute) * (1000 milliseconds per second) / (X millis per
    // beat) = Y beats/minute
    double averageBpm = 60.0 * 1000.0 / averageLength;
    double dRate = calcRateRatio();
    m_pFileBpm->set(averageBpm / dRate);
    slotUpdateEngineBpm();
}
Beispiel #2
0
double BpmControl::updateLocalBpm() {
    double prev_local_bpm = m_pLocalBpm->get();
    double local_bpm = 0;
    if (m_pBeats) {
        local_bpm = m_pBeats->getBpmAroundPosition(getCurrentSample(),
                                                   kLocalBpmSpan);
        if (local_bpm == -1) {
            local_bpm = m_pFileBpm->get();
        }
    } else {
        local_bpm = m_pFileBpm->get();
    }
    if (local_bpm != prev_local_bpm) {
        m_pLocalBpm->set(local_bpm);
        slotUpdateEngineBpm();
    }
    return local_bpm;
}
Beispiel #3
0
double BpmControl::updateLocalBpm() {
    double prev_local_bpm = m_pLocalBpm->get();
    double local_bpm = 0;
    BeatsPointer pBeats = m_pBeats;
    if (pBeats) {
        local_bpm = pBeats->getBpmAroundPosition(
                getSampleOfTrack().current, kLocalBpmSpan);
        if (local_bpm == -1) {
            local_bpm = m_pFileBpm->get();
        }
    } else {
        local_bpm = m_pFileBpm->get();
    }
    if (local_bpm != prev_local_bpm) {
        m_pLocalBpm->set(local_bpm);
        slotUpdateEngineBpm();
    }
    return local_bpm;
}
Beispiel #4
0
void BpmControl::slotFileBpmChanged(double bpm) {
    Q_UNUSED(bpm);
    // Adjust the file-bpm with the current setting of the rate to get the
    // engine BPM. We only do this for SYNC_NONE decks because EngineSync will
    // set our BPM if the file BPM changes. See SyncControl::fileBpmChanged().
    if (m_pBeats) {
        const double beats_bpm =
                m_pBeats->getBpmAroundPosition(getCurrentSample(),
                                               kLocalBpmSpan);
        if (beats_bpm != -1) {
            m_pLocalBpm->set(beats_bpm);
        } else {
            m_pLocalBpm->set(bpm);
        }
    } else {
        m_pLocalBpm->set(bpm);
    }
    if (getSyncMode() == SYNC_NONE) {
        slotUpdateEngineBpm();
    }
    resetSyncAdjustment();
}
Beispiel #5
0
BpmControl::BpmControl(QString group,
                       UserSettingsPointer pConfig) :
        EngineControl(group, pConfig),
        m_dPreviousSample(0),
        m_dSyncTargetBeatDistance(0.0),
        m_dSyncInstantaneousBpm(0.0),
        m_dLastSyncAdjustment(1.0),
        m_resetSyncAdjustment(false),
        m_dUserOffset(0.0),
        m_tapFilter(this, kFilterLength, kMaxInterval),
        m_sGroup(group) {
    m_pPlayButton = new ControlProxy(group, "play", this);
    m_pReverseButton = new ControlProxy(group, "reverse", this);
    m_pRateSlider = new ControlProxy(group, "rate", this);
    m_pRateSlider->connectValueChanged(SLOT(slotUpdateEngineBpm()),
                                       Qt::DirectConnection);
    m_pQuantize = ControlObject::getControl(group, "quantize");
    m_pRateRange = new ControlProxy(group, "rateRange", this);
    m_pRateRange->connectValueChanged(SLOT(slotUpdateRateSlider()),
                                      Qt::DirectConnection);
    m_pRateDir = new ControlProxy(group, "rate_dir", this);
    m_pRateDir->connectValueChanged(SLOT(slotUpdateEngineBpm()),
                                    Qt::DirectConnection);

    m_pPrevBeat.reset(new ControlProxy(group, "beat_prev"));
    m_pNextBeat.reset(new ControlProxy(group, "beat_next"));
    m_pClosestBeat.reset(new ControlProxy(group, "beat_closest"));

    m_pLoopEnabled = new ControlProxy(group, "loop_enabled", this);
    m_pLoopStartPosition = new ControlProxy(group, "loop_start_position", this);
    m_pLoopEndPosition = new ControlProxy(group, "loop_end_position", this);

    m_pFileBpm = new ControlObject(ConfigKey(group, "file_bpm"));
    connect(m_pFileBpm, SIGNAL(valueChanged(double)),
            this, SLOT(slotFileBpmChanged(double)),
            Qt::DirectConnection);
    m_pLocalBpm = new ControlObject(ConfigKey(group, "local_bpm"));
    m_pAdjustBeatsFaster = new ControlPushButton(ConfigKey(group, "beats_adjust_faster"), false);
    connect(m_pAdjustBeatsFaster, SIGNAL(valueChanged(double)),
            this, SLOT(slotAdjustBeatsFaster(double)),
            Qt::DirectConnection);
    m_pAdjustBeatsSlower = new ControlPushButton(ConfigKey(group, "beats_adjust_slower"), false);
    connect(m_pAdjustBeatsSlower, SIGNAL(valueChanged(double)),
            this, SLOT(slotAdjustBeatsSlower(double)),
            Qt::DirectConnection);
    m_pTranslateBeatsEarlier = new ControlPushButton(ConfigKey(group, "beats_translate_earlier"), false);
    connect(m_pTranslateBeatsEarlier, SIGNAL(valueChanged(double)),
            this, SLOT(slotTranslateBeatsEarlier(double)),
            Qt::DirectConnection);
    m_pTranslateBeatsLater = new ControlPushButton(ConfigKey(group, "beats_translate_later"), false);
    connect(m_pTranslateBeatsLater, SIGNAL(valueChanged(double)),
            this, SLOT(slotTranslateBeatsLater(double)),
            Qt::DirectConnection);

    // Pick a wide range (1 to 200) and allow out of bounds sets. This lets you
    // map a soft-takeover MIDI knob to the BPM. This also creates bpm_up and
    // bpm_down controls.
    // bpm_up / bpm_down steps by 1
    // bpm_up_small / bpm_down_small steps by 0.1
    m_pEngineBpm = new ControlLinPotmeter(ConfigKey(group, "bpm"), 1, 200, 1, 0.1, true);
    connect(m_pEngineBpm, SIGNAL(valueChanged(double)),
            this, SLOT(slotUpdateRateSlider()),
            Qt::DirectConnection);

    m_pButtonTap = new ControlPushButton(ConfigKey(group, "bpm_tap"));
    connect(m_pButtonTap, SIGNAL(valueChanged(double)),
            this, SLOT(slotBpmTap(double)),
            Qt::DirectConnection);

    // Beat sync (scale buffer tempo relative to tempo of other buffer)
    m_pButtonSync = new ControlPushButton(ConfigKey(group, "beatsync"));
    connect(m_pButtonSync, SIGNAL(valueChanged(double)),
            this, SLOT(slotControlBeatSync(double)),
            Qt::DirectConnection);

    m_pButtonSyncPhase = new ControlPushButton(ConfigKey(group, "beatsync_phase"));
    connect(m_pButtonSyncPhase, SIGNAL(valueChanged(double)),
            this, SLOT(slotControlBeatSyncPhase(double)),
            Qt::DirectConnection);

    m_pButtonSyncTempo = new ControlPushButton(ConfigKey(group, "beatsync_tempo"));
    connect(m_pButtonSyncTempo, SIGNAL(valueChanged(double)),
            this, SLOT(slotControlBeatSyncTempo(double)),
            Qt::DirectConnection);

    m_pTranslateBeats = new ControlPushButton(ConfigKey(group, "beats_translate_curpos"));
    connect(m_pTranslateBeats, SIGNAL(valueChanged(double)),
            this, SLOT(slotBeatsTranslate(double)),
            Qt::DirectConnection);

    m_pBeatsTranslateMatchAlignment = new ControlPushButton(ConfigKey(group, "beats_translate_match_alignment"));
    connect(m_pBeatsTranslateMatchAlignment, SIGNAL(valueChanged(double)),
            this, SLOT(slotBeatsTranslateMatchAlignment(double)),
            Qt::DirectConnection);

    connect(&m_tapFilter, SIGNAL(tapped(double,int)),
            this, SLOT(slotTapFilter(double,int)),
            Qt::DirectConnection);

    // Measures distance from last beat in percentage: 0.5 = half-beat away.
    m_pThisBeatDistance = new ControlProxy(group, "beat_distance", this);
    m_pSyncMode = ControlObject::getControl(ConfigKey(group, "sync_mode"));
}