Mercurial > hg > svgui
changeset 1321:4616e1e89189 import-audio-data
Move out these bits which are now in CSVFormat
author | Chris Cannam |
---|---|
date | Fri, 07 Sep 2018 18:12:44 +0100 |
parents | 6440ba1ffc86 |
children | f33ee2702447 |
files | widgets/CSVAudioFormatDialog.cpp widgets/CSVAudioFormatDialog.h |
diffstat | 2 files changed, 3 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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;