Mercurial > hg > svgui
comparison widgets/CSVAudioFormatDialog.cpp @ 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 |
comparison
equal
deleted
inserted
replaced
1320:6440ba1ffc86 | 1321:4616e1e89189 |
---|---|
36 | 36 |
37 CSVAudioFormatDialog::CSVAudioFormatDialog(QWidget *parent, CSVFormat format, | 37 CSVAudioFormatDialog::CSVAudioFormatDialog(QWidget *parent, CSVFormat format, |
38 int maxDisplayCols) : | 38 int maxDisplayCols) : |
39 QDialog(parent), | 39 QDialog(parent), |
40 m_format(format), | 40 m_format(format), |
41 m_sampleRange(RangeSigned1), | |
42 m_maxDisplayCols(maxDisplayCols), | 41 m_maxDisplayCols(maxDisplayCols), |
43 m_fuzzyColumn(-1) | 42 m_fuzzyColumn(-1) |
44 { | 43 { |
45 setModal(true); | 44 setModal(true); |
46 setWindowTitle(tr("Select Audio Data Format")); | 45 setWindowTitle(tr("Select Audio Data Format")); |
136 layout->addWidget(m_sampleRateCombo, row++, 1); | 135 layout->addWidget(m_sampleRateCombo, row++, 1); |
137 connect(m_sampleRateCombo, SIGNAL(activated(QString)), | 136 connect(m_sampleRateCombo, SIGNAL(activated(QString)), |
138 this, SLOT(sampleRateChanged(QString))); | 137 this, SLOT(sampleRateChanged(QString))); |
139 connect(m_sampleRateCombo, SIGNAL(editTextChanged(QString)), | 138 connect(m_sampleRateCombo, SIGNAL(editTextChanged(QString)), |
140 this, SLOT(sampleRateChanged(QString))); | 139 this, SLOT(sampleRateChanged(QString))); |
141 | |
142 m_sampleRange = RangeSigned1; | |
143 bool knownSigned = false; | |
144 bool knownNonIntegral = false; | |
145 | |
146 for (int i = 0; i < columns; ++i) { | |
147 if (!(format.getColumnQualities()[i] & CSVFormat::ColumnIntegral)) { | |
148 knownNonIntegral = true; | |
149 if (m_sampleRange == RangeUnsigned255 || | |
150 m_sampleRange == RangeSigned32767) { | |
151 m_sampleRange = RangeOther; | |
152 } | |
153 } | |
154 if (format.getColumnQualities()[i] & CSVFormat::ColumnLarge) { | |
155 if (m_sampleRange == RangeSigned1 || | |
156 m_sampleRange == RangeUnsigned255) { | |
157 if (knownNonIntegral) { | |
158 m_sampleRange = RangeOther; | |
159 } else { | |
160 m_sampleRange = RangeSigned32767; | |
161 } | |
162 } | |
163 } | |
164 if (format.getColumnQualities()[i] & CSVFormat::ColumnSigned) { | |
165 knownSigned = true; | |
166 if (m_sampleRange == RangeUnsigned255) { | |
167 m_sampleRange = RangeSigned32767; | |
168 } | |
169 } | |
170 if (!(format.getColumnQualities()[i] & CSVFormat::ColumnSmall)) { | |
171 if (m_sampleRange == RangeSigned1) { | |
172 if (knownNonIntegral) { | |
173 m_sampleRange = RangeOther; | |
174 } else if (knownSigned) { | |
175 m_sampleRange = RangeSigned32767; | |
176 } else { | |
177 m_sampleRange = RangeUnsigned255; | |
178 } | |
179 } | |
180 } | |
181 } | |
182 | 140 |
183 layout->addWidget(new QLabel(tr("Sample values are:")), row, 0); | 141 layout->addWidget(new QLabel(tr("Sample values are:")), row, 0); |
184 | 142 |
185 m_sampleRangeCombo = new QComboBox; | 143 m_sampleRangeCombo = new QComboBox; |
186 // NB must be in the same order as the CSVSampleRange enum | 144 // NB must be in the same order as the CSVFormat::AudioSampleRange enum |
187 m_sampleRangeCombo->addItem(tr("Floating-point in range -1 to 1")); | 145 m_sampleRangeCombo->addItem(tr("Floating-point in range -1 to 1")); |
188 m_sampleRangeCombo->addItem(tr("8-bit in range 0 to 255")); | 146 m_sampleRangeCombo->addItem(tr("8-bit in range 0 to 255")); |
189 m_sampleRangeCombo->addItem(tr("16-bit in range -32768 to 32767")); | 147 m_sampleRangeCombo->addItem(tr("16-bit in range -32768 to 32767")); |
190 m_sampleRangeCombo->addItem(tr("Unknown range: normalise on load")); | 148 m_sampleRangeCombo->addItem(tr("Unknown range: normalise on load")); |
191 m_sampleRangeCombo->setCurrentIndex(int(m_sampleRange)); | 149 m_sampleRangeCombo->setCurrentIndex(int(m_format.getAudioSampleRange())); |
192 | 150 |
193 layout->addWidget(m_sampleRangeCombo, row++, 1); | 151 layout->addWidget(m_sampleRangeCombo, row++, 1); |
194 connect(m_sampleRangeCombo, SIGNAL(activated(int)), | 152 connect(m_sampleRangeCombo, SIGNAL(activated(int)), |
195 this, SLOT(sampleRangeChanged(int))); | 153 this, SLOT(sampleRangeChanged(int))); |
196 | 154 |
213 CSVAudioFormatDialog::getFormat() const | 171 CSVAudioFormatDialog::getFormat() const |
214 { | 172 { |
215 return m_format; | 173 return m_format; |
216 } | 174 } |
217 | 175 |
218 CSVAudioFormatDialog::CSVSampleRange | |
219 CSVAudioFormatDialog::getSampleRange() const | |
220 { | |
221 return m_sampleRange; | |
222 } | |
223 | |
224 void | 176 void |
225 CSVAudioFormatDialog::sampleRateChanged(QString rateString) | 177 CSVAudioFormatDialog::sampleRateChanged(QString rateString) |
226 { | 178 { |
227 bool ok = false; | 179 bool ok = false; |
228 int sampleRate = rateString.toInt(&ok); | 180 int sampleRate = rateString.toInt(&ok); |
230 } | 182 } |
231 | 183 |
232 void | 184 void |
233 CSVAudioFormatDialog::sampleRangeChanged(int range) | 185 CSVAudioFormatDialog::sampleRangeChanged(int range) |
234 { | 186 { |
235 m_sampleRange = (CSVSampleRange) range; | 187 m_format.setAudioSampleRange((CSVFormat::AudioSampleRange)range); |
236 } | 188 } |
237 | 189 |
238 void | 190 void |
239 CSVAudioFormatDialog::columnPurposeChanged(int) | 191 CSVAudioFormatDialog::columnPurposeChanged(int) |
240 { | 192 { |