# HG changeset patch # User Chris Cannam # Date 1536340364 -3600 # Node ID 4616e1e891894aa08b329569d64ede1820db60dd # Parent 6440ba1ffc86d6a03e2d89a34902ad22db4269ed Move out these bits which are now in CSVFormat diff -r 6440ba1ffc86 -r 4616e1e89189 widgets/CSVAudioFormatDialog.cpp --- a/widgets/CSVAudioFormatDialog.cpp Thu Sep 06 16:26:40 2018 +0100 +++ b/widgets/CSVAudioFormatDialog.cpp Fri Sep 07 18:12:44 2018 +0100 @@ -38,7 +38,6 @@ int maxDisplayCols) : QDialog(parent), m_format(format), - m_sampleRange(RangeSigned1), m_maxDisplayCols(maxDisplayCols), m_fuzzyColumn(-1) { @@ -138,57 +137,16 @@ this, SLOT(sampleRateChanged(QString))); connect(m_sampleRateCombo, SIGNAL(editTextChanged(QString)), this, SLOT(sampleRateChanged(QString))); - - m_sampleRange = RangeSigned1; - bool knownSigned = false; - bool knownNonIntegral = false; - - for (int i = 0; i < columns; ++i) { - if (!(format.getColumnQualities()[i] & CSVFormat::ColumnIntegral)) { - knownNonIntegral = true; - if (m_sampleRange == RangeUnsigned255 || - m_sampleRange == RangeSigned32767) { - m_sampleRange = RangeOther; - } - } - if (format.getColumnQualities()[i] & CSVFormat::ColumnLarge) { - if (m_sampleRange == RangeSigned1 || - m_sampleRange == RangeUnsigned255) { - if (knownNonIntegral) { - m_sampleRange = RangeOther; - } else { - m_sampleRange = RangeSigned32767; - } - } - } - if (format.getColumnQualities()[i] & CSVFormat::ColumnSigned) { - knownSigned = true; - if (m_sampleRange == RangeUnsigned255) { - m_sampleRange = RangeSigned32767; - } - } - if (!(format.getColumnQualities()[i] & CSVFormat::ColumnSmall)) { - if (m_sampleRange == RangeSigned1) { - if (knownNonIntegral) { - m_sampleRange = RangeOther; - } else if (knownSigned) { - m_sampleRange = RangeSigned32767; - } else { - m_sampleRange = RangeUnsigned255; - } - } - } - } layout->addWidget(new QLabel(tr("Sample values are:")), row, 0); m_sampleRangeCombo = new QComboBox; - // NB must be in the same order as the CSVSampleRange enum + // NB must be in the same order as the CSVFormat::AudioSampleRange enum m_sampleRangeCombo->addItem(tr("Floating-point in range -1 to 1")); m_sampleRangeCombo->addItem(tr("8-bit in range 0 to 255")); m_sampleRangeCombo->addItem(tr("16-bit in range -32768 to 32767")); m_sampleRangeCombo->addItem(tr("Unknown range: normalise on load")); - m_sampleRangeCombo->setCurrentIndex(int(m_sampleRange)); + m_sampleRangeCombo->setCurrentIndex(int(m_format.getAudioSampleRange())); layout->addWidget(m_sampleRangeCombo, row++, 1); connect(m_sampleRangeCombo, SIGNAL(activated(int)), @@ -215,12 +173,6 @@ return m_format; } -CSVAudioFormatDialog::CSVSampleRange -CSVAudioFormatDialog::getSampleRange() const -{ - return m_sampleRange; -} - void CSVAudioFormatDialog::sampleRateChanged(QString rateString) { @@ -232,7 +184,7 @@ void CSVAudioFormatDialog::sampleRangeChanged(int range) { - m_sampleRange = (CSVSampleRange) range; + m_format.setAudioSampleRange((CSVFormat::AudioSampleRange)range); } void diff -r 6440ba1ffc86 -r 4616e1e89189 widgets/CSVAudioFormatDialog.h --- a/widgets/CSVAudioFormatDialog.h Thu Sep 06 16:26:40 2018 +0100 +++ b/widgets/CSVAudioFormatDialog.h Fri Sep 07 18:12:44 2018 +0100 @@ -33,16 +33,8 @@ CSVFormat initialFormat, int maxDisplayCols = 5); ~CSVAudioFormatDialog(); - - enum CSVSampleRange { - RangeSigned1 = 0, // -1 .. 1 - RangeUnsigned255, // 0 .. 255 - RangeSigned32767, // -32768 .. 32767 - RangeOther // Other/unknown: Normalise on load - }; CSVFormat getFormat() const; - CSVSampleRange getSampleRange() const; protected slots: void sampleRateChanged(QString); @@ -53,7 +45,6 @@ protected: CSVFormat m_format; - CSVSampleRange m_sampleRange; int m_maxDisplayCols; QComboBox *m_sampleRateCombo;