Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1009:96cf499fad62 tony-2.0-integration
Fix incorrect reload of old Tony v1.0 files
author | Chris Cannam |
---|---|
date | Tue, 20 Oct 2015 12:55:09 +0100 |
parents | 2f8340c22e8a |
children | fccee028a522 |
comparison
equal
deleted
inserted
replaced
1008:2f8340c22e8a | 1009:96cf499fad62 |
---|---|
3542 .arg(m_colourMap) | 3542 .arg(m_colourMap) |
3543 .arg(m_colourRotation) | 3543 .arg(m_colourRotation) |
3544 .arg(m_frequencyScale) | 3544 .arg(m_frequencyScale) |
3545 .arg(m_binDisplay); | 3545 .arg(m_binDisplay); |
3546 | 3546 |
3547 s += QString("normalizeColumns=\"%1\" " | 3547 // New-style normalization attributes, allowing for more types of |
3548 "normalizeVisibleArea=\"%2\" " | 3548 // normalization in future: write out the column normalization |
3549 "normalizeHybrid=\"%3\" ") | 3549 // type separately, and then whether we are normalizing visible |
3550 .arg(m_normalization == NormalizeColumns ? "true" : "false") | 3550 // area as well afterwards |
3551 .arg(m_normalization == NormalizeVisibleArea ? "true" : "false") | 3551 |
3552 .arg(m_normalization == NormalizeHybrid ? "true" : "false"); | 3552 s += QString("columnNormalization=\"%1\" ") |
3553 | 3553 .arg(m_normalization == NormalizeColumns ? "peak" : |
3554 m_normalization == NormalizeHybrid ? "hybrid" : "none"); | |
3555 | |
3556 // Old-style normalization attribute. We *don't* write out | |
3557 // normalizeHybrid here because the only release that would accept | |
3558 // it (Tony v1.0) has a totally different scale factor for | |
3559 // it. We'll just have to accept that session files from Tony | |
3560 // v2.0+ will look odd in Tony v1.0 | |
3561 | |
3562 s += QString("normalizeColumns=\"%1\" ") | |
3563 .arg(m_normalization == NormalizeColumns ? "true" : "false"); | |
3564 | |
3565 // And this applies to both old- and new-style attributes | |
3566 | |
3567 s += QString("normalizeVisibleArea=\"%1\" ") | |
3568 .arg(m_normalization == NormalizeVisibleArea ? "true" : "false"); | |
3569 | |
3554 Layer::toXml(stream, indent, extraAttributes + " " + s); | 3570 Layer::toXml(stream, indent, extraAttributes + " " + s); |
3555 } | 3571 } |
3556 | 3572 |
3557 void | 3573 void |
3558 SpectrogramLayer::setProperties(const QXmlAttributes &attributes) | 3574 SpectrogramLayer::setProperties(const QXmlAttributes &attributes) |
3613 | 3629 |
3614 BinDisplay binDisplay = (BinDisplay) | 3630 BinDisplay binDisplay = (BinDisplay) |
3615 attributes.value("binDisplay").toInt(&ok); | 3631 attributes.value("binDisplay").toInt(&ok); |
3616 if (ok) setBinDisplay(binDisplay); | 3632 if (ok) setBinDisplay(binDisplay); |
3617 | 3633 |
3618 bool normalizeColumns = | 3634 bool haveNewStyleNormalization = false; |
3619 (attributes.value("normalizeColumns").trimmed() == "true"); | 3635 |
3620 if (normalizeColumns) { | 3636 QString columnNormalization = attributes.value("columnNormalization"); |
3621 setNormalization(NormalizeColumns); | 3637 |
3638 if (columnNormalization != "") { | |
3639 | |
3640 haveNewStyleNormalization = true; | |
3641 | |
3642 if (columnNormalization == "peak") { | |
3643 setNormalization(NormalizeColumns); | |
3644 } else if (columnNormalization == "hybrid") { | |
3645 setNormalization(NormalizeHybrid); | |
3646 } else if (columnNormalization == "none") { | |
3647 // do nothing | |
3648 } else { | |
3649 cerr << "NOTE: Unknown or unsupported columnNormalization attribute \"" | |
3650 << columnNormalization << "\"" << endl; | |
3651 } | |
3652 } | |
3653 | |
3654 if (!haveNewStyleNormalization) { | |
3655 | |
3656 bool normalizeColumns = | |
3657 (attributes.value("normalizeColumns").trimmed() == "true"); | |
3658 if (normalizeColumns) { | |
3659 setNormalization(NormalizeColumns); | |
3660 } | |
3661 | |
3662 bool normalizeHybrid = | |
3663 (attributes.value("normalizeHybrid").trimmed() == "true"); | |
3664 if (normalizeHybrid) { | |
3665 setNormalization(NormalizeHybrid); | |
3666 } | |
3622 } | 3667 } |
3623 | 3668 |
3624 bool normalizeVisibleArea = | 3669 bool normalizeVisibleArea = |
3625 (attributes.value("normalizeVisibleArea").trimmed() == "true"); | 3670 (attributes.value("normalizeVisibleArea").trimmed() == "true"); |
3626 if (normalizeVisibleArea) { | 3671 if (normalizeVisibleArea) { |
3627 setNormalization(NormalizeVisibleArea); | 3672 setNormalization(NormalizeVisibleArea); |
3628 } | 3673 } |
3629 | 3674 |
3630 bool normalizeHybrid = | 3675 if (!haveNewStyleNormalization && m_normalization == NormalizeHybrid) { |
3631 (attributes.value("normalizeHybrid").trimmed() == "true"); | 3676 // Tony v1.0 is (and hopefully will remain!) the only released |
3632 if (normalizeHybrid) { | 3677 // SV-a-like to use old-style attributes when saving sessions |
3633 setNormalization(NormalizeHybrid); | 3678 // that ask for hybrid normalization. It saves them with the |
3634 } | 3679 // wrong gain factor, so hack in a fix for that here -- this |
3635 } | 3680 // gives us backward but not forward compatibility. |
3636 | 3681 setGain(m_gain / float(m_fftSize / 2)); |
3682 } | |
3683 } | |
3684 |