SpeedDial and FeedBack

Post Reply
adriankapka
Posts: 30
Joined: Sat May 30, 2015 4:56 pm
Location: Poland
Real Name: Adrian Kapka
Contact:

Hello

In the attached log with added debug lines
edit file /qlcplus/ui/src/virtualconsole/vcspeeddial.cpp

Code: Select all

void VCSpeedDial::slotDialValueChanged(int ms)
{
    qDebug() << "[VCSpeedDial::slotDialValueChanged] ms:" << ms;
    const QVector <quint32> multipliers = VCSpeedDialFunction::speedMultiplierValuesTimes1000();

    foreach (const VCSpeedDialFunction &speeddialfunction, m_functions)
    {
        Function* function = m_doc->function(speeddialfunction.functionId);
        if (function != NULL)
        {
            if (speeddialfunction.fadeInMultiplier != VCSpeedDialFunction::None)
                function->setFadeInSpeed(ms * multipliers[speeddialfunction.fadeInMultiplier] / 1000);
            if (speeddialfunction.fadeOutMultiplier != VCSpeedDialFunction::None)
                function->setFadeOutSpeed(ms * multipliers[speeddialfunction.fadeOutMultiplier] / 1000);
            if (speeddialfunction.durationMultiplier != VCSpeedDialFunction::None)
                function->setDuration(ms * multipliers[speeddialfunction.durationMultiplier] / 1000);
        }
    }
    updateFeedback();
}
and

Code: Select all

void VCSpeedDial::slotInputValueChanged(quint32 universe, quint32 channel, uchar value)
{
    if (isEnabled() == false)
        return;

    quint32 pagedCh = (page() << 16) | channel;

    if (checkInputSource(universe, pagedCh, value, sender(), tapInputSourceId))
    {
        if (value != 0)
            m_dial->tap();
    }
    else if (checkInputSource(universe, pagedCh, value, sender(), absoluteInputSourceId))
    {
        int ms = static_cast<int> (SCALE(qreal(value), qreal(0), qreal(255),
                                         qreal(absoluteValueMin()),
                                         qreal(absoluteValueMax())));
        m_dial->setValue(ms, true);
	qDebug() << "[VCSpeedDial::slotInputValueChanged()] value:" << value << ", ms:" << ms;
    }
    else if (checkInputSource(universe, pagedCh, value, sender(), infiniteInputSourceId))
    {
        if (value != 0)
            m_dial->toggleInfinite();
    }
}

You can see the differences between the values of the function
VCSpeedDial :: slotInputValueChanged where it is 78ms and
VCSpeedDial :: slotDialValueChanged where it is 700ms.

This sends through the feedback values for 700ms to 78ms and instead of looping while decreasing.

Where is the value passed to the function void VCSpeedDial::slotDialValueChanged (int ms)?
Attachments
QLC+.log
(20.59 KiB) Downloaded 76 times
janosvitok
Posts: 1325
Joined: Mon Apr 13, 2015 7:05 am
Location: Bratislava, Slovakia
Real Name: Jano Svitok
Contact:

the interesting call is m_dial->setValue(ms, true)

which in turn calls setSpinValues (that divides ms by MS_DIV == 10, i.e. m_ms == 7), and that in turn calls spinValues() that multiplies m_ms by MS_DIV and if m_ms <10 then also by 10 (i.e. m_ms * 100).

https://github.com/mcallegari/qlcplus/b ... l.cpp#L293
janosvitok
Posts: 1325
Joined: Mon Apr 13, 2015 7:05 am
Location: Bratislava, Slovakia
Real Name: Jano Svitok
Contact:

Sometime ago I wrote this: viewtopic.php?f=5&t=7722&p=32841#p32841

It seems that subclassing QSpinBox is the most straightforward way to do this (i.e. make a spin box that will hold real ms value and display it in as a fraction with proper leading zeroes (and maybe just 2 digits of he number).
adriankapka
Posts: 30
Joined: Sat May 30, 2015 4:56 pm
Location: Poland
Real Name: Adrian Kapka
Contact:

Please hint where I can find functions DMX2MIDI, because sharing 255/2 behave incorrectly when 1/2 sends a 0, and assume that she just works. And with the first step sends MIDI device to 0 instead of 1.
plugz
Posts: 637
Joined: Sun Apr 12, 2015 6:30 pm
Real Name: David

adriankapka wrote:Please hint where I can find functions DMX2MIDI, because sharing 255/2 behave incorrectly when 1/2 sends a 0, and assume that she just works. And with the first step sends MIDI device to 0 instead of 1.
You mean the feedback sent from a speeddial widget to it's midi input? See VCSpeedDial::updateFeedback
adriankapka
Posts: 30
Joined: Sat May 30, 2015 4:56 pm
Location: Poland
Real Name: Adrian Kapka
Contact:

Hello, proposes several changes to the feedback to work correctly using the setting position encoders (tested on AKAI APC40).
Changes also display milliseconds in speeddial.
Please verify and comments.

Edit: /qlcplus/ui/src/virtualconsole/vcspeeddial.cpp

Code: Select all

void VCSpeedDial::updateFeedback()
{
    int fbv = (int)SCALE(float(m_dial->value()), float(m_absoluteValueMin),
                     float(m_absoluteValueMax), float(1), float(UCHAR_MAX)); // modify float(0) -> 1

    sendFeedback(fbv, absoluteInputSourceId);

    sendFeedback(m_dial->value() == (int)Function::infiniteSpeed() ? UCHAR_MAX : 0, infiniteInputSourceId);
}
Edit: /qlcplus/ui/src/speeddial.cpp
line about 160

Code: Select all

.....
    m_ms = new FocusSpinBox(this);
//    m_ms->setRange(0, MS_MAX / MS_DIV);  	//remove
//    m_ms->setPrefix(".");			//remove
    m_ms->setRange(0, MS_MAX); 			//add
    m_ms->setSuffix("ms"); 			//add
    m_ms->setButtonSymbols(QSpinBox::NoButtons);
    m_ms->setToolTip(tr("Milliseconds"));
    timeHBox->addWidget(m_ms);
    connect(m_ms, SIGNAL(valueChanged(int)), this, SLOT(slotMSChanged()));
    connect(m_ms, SIGNAL(focusGained()), this, SLOT(slotSpinFocusGained()));

......

line about 270

Code: Select all

void SpeedDial::setSpinValues(int ms)
{
    // block signals to prevent each single SpinBox to send
    // a valueChanged signal. For example going from 1m0s to 59s
    // would send two signals: 0 and then 59000.
    // We want to avoid that non-sense 0
    // Just send one single signal when everything has changed
    m_hrs->blockSignals(true);
    m_min->blockSignals(true);
    m_sec->blockSignals(true);
    m_ms->blockSignals(true);

    if (ms == (int) Function::infiniteSpeed())
    {
        m_hrs->setValue(m_hrs->minimum());
        m_min->setValue(m_min->minimum());
        m_sec->setValue(m_sec->minimum());
        m_ms->setValue(m_ms->minimum());
    }
    else
    {
        ms = CLAMP(ms, 0, INT_MAX);

        m_hrs->setValue(ms / MS_PER_HOUR);
        ms -= (m_hrs->value() * MS_PER_HOUR);

        m_min->setValue(ms / MS_PER_MINUTE);
        ms -= (m_min->value() * MS_PER_MINUTE);

        m_sec->setValue(ms / MS_PER_SECOND);
        ms -= (m_sec->value() * MS_PER_SECOND);

    //    m_ms->setValue(ms / MS_DIV);			//remove
	m_ms->setValue(ms);				//add
    }
    m_hrs->blockSignals(false);
    m_min->blockSignals(false);
    m_sec->blockSignals(false);
    m_ms->blockSignals(false);
    if (m_preventSignals == false)
    {
        m_value = spinValues();
        emit valueChanged(m_value);
    }
}
line about 300

Code: Select all

int SpeedDial::spinValues() const
{
    int value = 0;

    if (m_infiniteCheck->isChecked() == false)
    {
        value += m_hrs->value() * MS_PER_HOUR;
        value += m_min->value() * MS_PER_MINUTE;
        value += m_sec->value() * MS_PER_SECOND;
        QString msText = m_ms->text();
        int msInt = m_ms->value();
    //    if (msInt < 10 && msText.contains("0") == false)		//remove
    //        value += (msInt * MS_DIV * 10);				//remove
    //    else								//remove
    //        value += (msInt * MS_DIV);				//remove
	value += (msInt);						//add
    }
    else
    {
        value = Function::infiniteSpeed();
    }

    return CLAMP(value, 0, INT_MAX);
}
line about 440

Code: Select all

void SpeedDial::slotMSChanged()
{
    m_ms->blockSignals(true);
//    if (m_ms->value() < 10)			//remove
//        m_ms->setPrefix(".0");		//remove
//    else					//remove
//        m_ms->setPrefix(".");			//remove
    m_ms->setSuffix("ms");			//add
    m_ms->blockSignals(false);

    if (m_preventSignals == false)
    {
        m_value = spinValues();
        emit valueChanged(m_value);
    }
    // stop tap button blinking if it was
    stopTimers();
}
Attachments
speeddial.cpp
(15.88 KiB) Downloaded 67 times
vcspeeddial.cpp
(16.99 KiB) Downloaded 76 times
User avatar
mcallegari
Posts: 4711
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

Adrian, this is not the right place to propose code patches. Surely not like this.
Sources are on GitHub and you can submit a Pull Request that can be discussed, reviewed, and so on.

Also, I moved this topic into the software development area

Thanks
adriankapka
Posts: 30
Joined: Sat May 30, 2015 4:56 pm
Location: Poland
Real Name: Adrian Kapka
Contact:

OK, thanks for the explanation.
Post Reply