|
|
|
@ -35,12 +35,12 @@ using std::cout;
|
|
|
|
|
using std::cerr;
|
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
|
|
//#define DEBUG_PEATDEFILE 1
|
|
|
|
|
//#define DEBUG_PEATDEFILE_BRIEF 1
|
|
|
|
|
//#define DEBUG_PEATDEFILE_CACHE 1
|
|
|
|
|
//#define DEBUG_PEAKFILE 1
|
|
|
|
|
//#define DEBUG_PEAKFILE_BRIEF 1
|
|
|
|
|
//#define DEBUG_PEAKFILE_CACHE 1
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#define DEBUG_PEATDEFILE_BRIEF 1
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
#define DEBUG_PEAKFILE_BRIEF 1
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace Rosegarden
|
|
|
|
@ -94,7 +94,7 @@ PeakFile::open()
|
|
|
|
|
parseHeader();
|
|
|
|
|
} catch (BadSoundFileException s) {
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
cerr << "PeakFile::open - EXCEPTION \"" << s.getMessage() << "\""
|
|
|
|
|
<< endl;
|
|
|
|
|
#endif
|
|
|
|
@ -216,7 +216,7 @@ PeakFile::write(unsigned short updatePercentage)
|
|
|
|
|
if (!m_audioFile->open())
|
|
|
|
|
return false;
|
|
|
|
|
} catch (BadSoundFileException e) {
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
std::cerr << "PeakFile::write - \"" << e.getMessage() << "\"" << std::endl;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -484,7 +484,7 @@ PeakFile::writePeaks(unsigned short /*updatePercentage*/,
|
|
|
|
|
return ;
|
|
|
|
|
m_keepProcessing = true;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
|
|
|
|
|
cout << "PeakFile::writePeaks - calculating peaks" << endl;
|
|
|
|
|
#endif
|
|
|
|
@ -624,7 +624,7 @@ PeakFile::writePeaks(unsigned short /*updatePercentage*/,
|
|
|
|
|
m_numberOfPeaks++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
cout << "PeakFile::writePeaks - "
|
|
|
|
|
<< "completed peaks" << endl;
|
|
|
|
|
#endif
|
|
|
|
@ -642,7 +642,7 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
int width,
|
|
|
|
|
bool showMinima)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE_BRIEF
|
|
|
|
|
#ifdef DEBUG_PEAKFILE_BRIEF
|
|
|
|
|
std::cout << "PeakFile::getPreview - "
|
|
|
|
|
<< "startTime = " << startTime
|
|
|
|
|
<< ", endTime = " << endTime
|
|
|
|
@ -658,7 +658,7 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
// Regenerate cache on these conditions
|
|
|
|
|
//
|
|
|
|
|
if (!m_peakCache.length()) {
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE_CACHE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE_CACHE
|
|
|
|
|
std::cerr << "PeakFile::getPreview - no peak cache" << std::endl;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -675,13 +675,13 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
<< std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE_CACHE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE_CACHE
|
|
|
|
|
std::cout << "PeakFile::getPreview - generated peak cache - "
|
|
|
|
|
<< "size = " << m_peakCache.length() << std::endl;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE_CACHE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE_CACHE
|
|
|
|
|
std::cout << "PeakFile::getPreview - file size = " << getSize()
|
|
|
|
|
<< ", not generating cache" << std::endl;
|
|
|
|
|
#endif
|
|
|
|
@ -694,13 +694,13 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
//
|
|
|
|
|
if (startTime == m_lastPreviewStartTime && endTime == m_lastPreviewEndTime
|
|
|
|
|
&& width == m_lastPreviewWidth && showMinima == m_lastPreviewShowMinima) {
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE_CACHE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE_CACHE
|
|
|
|
|
std::cout << "PeakFile::getPreview - hit last preview cache" << std::endl;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return m_lastPreviewCache;
|
|
|
|
|
} else {
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE_CACHE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE_CACHE
|
|
|
|
|
std::cout << "PeakFile::getPreview - last preview " << m_lastPreviewStartTime
|
|
|
|
|
<< " -> " << m_lastPreviewEndTime << ", w " << m_lastPreviewWidth << "; this " << startTime << " -> " << endTime << ", w " << width << std::endl;
|
|
|
|
|
#endif
|
|
|
|
@ -724,7 +724,7 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
std::string peakData;
|
|
|
|
|
int peakNumber;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE_BRIEF
|
|
|
|
|
#ifdef DEBUG_PEAKFILE_BRIEF
|
|
|
|
|
|
|
|
|
|
std::cout << "PeakFile::getPreview - getting preview for \""
|
|
|
|
|
<< m_audioFile->getFilename() << "\"" << endl;
|
|
|
|
@ -743,7 +743,7 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE_BRIEF
|
|
|
|
|
#ifdef DEBUG_PEAKFILE_BRIEF
|
|
|
|
|
|
|
|
|
|
std::cout << "PeakFile::getPreview - "
|
|
|
|
|
<< "unsupported peak length format (" << m_format << ")"
|
|
|
|
@ -766,14 +766,14 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
if (!m_peakCache.length()) {
|
|
|
|
|
|
|
|
|
|
if (scanToPeak(peakNumber) == false) {
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
std::cout << "PeakFile::getPreview: scanToPeak(" << peakNumber << ") failed" << std::endl;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
m_lastPreviewCache.push_back(0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
std::cout << "PeakFile::getPreview: step is " << step << ", format * pointsPerValue * chans is " << (m_format * m_pointsPerValue * m_channels) << std::endl;
|
|
|
|
|
std::cout << "i = " << i << ", peakNumber = " << peakNumber << ", nextPeakNumber = " << nextPeakNumber << std::endl;
|
|
|
|
|
#endif
|
|
|
|
@ -797,14 +797,14 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
// Problem with the get - probably an EOF
|
|
|
|
|
// return the results so far.
|
|
|
|
|
//
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
std::cout << "PeakFile::getPreview - \"" << e.getMessage() << "\"\n"
|
|
|
|
|
<< endl;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
std::cout << "PeakFile::getPreview - "
|
|
|
|
|
<< "read from file" << std::endl;
|
|
|
|
|
#endif
|
|
|
|
@ -820,7 +820,7 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
//
|
|
|
|
|
if (charNum + charLength <= m_peakCache.length()) {
|
|
|
|
|
peakData = m_peakCache.substr(charNum, charLength);
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
|
|
|
|
|
std::cout << "PeakFile::getPreview - "
|
|
|
|
|
<< "hit peakCache" << std::endl;
|
|
|
|
@ -835,7 +835,7 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
// We didn't get the whole peak block - return what
|
|
|
|
|
// we've got so far
|
|
|
|
|
//
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
std::cout << "PeakFile::getPreview - "
|
|
|
|
|
<< "failed to get complete peak block"
|
|
|
|
|
<< endl;
|
|
|
|
@ -852,7 +852,7 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
inValue -= (1 << (m_format * 8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE
|
|
|
|
|
#ifdef DEBUG_PEAKFILE
|
|
|
|
|
std::cout << "found potential hivalue " << inValue << std::endl;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -883,7 +883,7 @@ PeakFile::getPreview(const RealTime &startTime,
|
|
|
|
|
|
|
|
|
|
float value = hiValues[ch] / divisor;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE_BRIEF
|
|
|
|
|
#ifdef DEBUG_PEAKFILE_BRIEF
|
|
|
|
|
|
|
|
|
|
std::cout << "VALUE = " << hiValues[ch] / divisor << std::endl;
|
|
|
|
|
#endif
|
|
|
|
@ -912,7 +912,7 @@ done:
|
|
|
|
|
m_lastPreviewWidth = width;
|
|
|
|
|
m_lastPreviewShowMinima = showMinima;
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_PEATDEFILE_BRIEF
|
|
|
|
|
#ifdef DEBUG_PEAKFILE_BRIEF
|
|
|
|
|
|
|
|
|
|
std::cout << "Returning " << m_lastPreviewCache.size() << " items" << std::endl;
|
|
|
|
|
#endif
|
|
|
|
|