Mercurial > hg > svcore
diff data/fileio/CSVFormat.cpp @ 1515:ffec849858a7 import-audio-data
Add sample-range support to CSVFormat
author | Chris Cannam |
---|---|
date | Fri, 07 Sep 2018 16:55:29 +0100 |
parents | c9c2aa17439a |
children | 2d291eac9f21 |
line wrap: on
line diff
--- a/data/fileio/CSVFormat.cpp Fri Sep 07 16:13:48 2018 +0100 +++ b/data/fileio/CSVFormat.cpp Fri Sep 07 16:55:29 2018 +0100 @@ -84,6 +84,7 @@ } guessPurposes(); + guessAudioSampleRange(); } void @@ -351,6 +352,55 @@ SVDEBUG << "Estimated units: " << m_timeUnits << endl; } +void +CSVFormat::guessAudioSampleRange() +{ + AudioSampleRange range = SampleRangeSigned1; + + range = SampleRangeSigned1; + bool knownSigned = false; + bool knownNonIntegral = false; + + for (int i = 0; i < m_columnCount; ++i) { + if (!(m_columnQualities[i] & ColumnIntegral)) { + knownNonIntegral = true; + if (range == SampleRangeUnsigned255 || + range == SampleRangeSigned32767) { + range = SampleRangeOther; + } + } + if (m_columnQualities[i] & ColumnLarge) { + if (range == SampleRangeSigned1 || + range == SampleRangeUnsigned255) { + if (knownNonIntegral) { + range = SampleRangeOther; + } else { + range = SampleRangeSigned32767; + } + } + } + if (m_columnQualities[i] & ColumnSigned) { + knownSigned = true; + if (range == SampleRangeUnsigned255) { + range = SampleRangeSigned32767; + } + } + if (!(m_columnQualities[i] & ColumnSmall)) { + if (range == SampleRangeSigned1) { + if (knownNonIntegral) { + range = SampleRangeOther; + } else if (knownSigned) { + range = SampleRangeSigned32767; + } else { + range = SampleRangeUnsigned255; + } + } + } + } + + m_audioSampleRange = range; +} + CSVFormat::ColumnPurpose CSVFormat::getColumnPurpose(int i) {