1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-26 07:13:49 +01:00

GetMinMax, GetRMS functions take a mayThrow argument, return numbers

This commit is contained in:
Paul Licameli
2016-12-25 08:40:15 -05:00
parent dcac8788ff
commit 70d9e4bdc7
17 changed files with 183 additions and 184 deletions

View File

@@ -29,6 +29,7 @@ The summary is eventually computed and written to a file in a background thread.
#include "../FileFormats.h"
#include "../Internat.h"
#include "NotYetAvailableException.h"
const int bheaderTagLen = 20;
char bheaderTag[bheaderTagLen + 1] = "AudacityBlockFile112";
@@ -91,37 +92,45 @@ auto ODDecodeBlockFile::GetSpaceUsage() const -> DiskByteCount
/// Gets extreme values for the specified region
void ODDecodeBlockFile::GetMinMax(size_t start, size_t len,
float *outMin, float *outMax, float *outRMS) const
auto ODDecodeBlockFile::GetMinMaxRMS(
size_t start, size_t len, bool mayThrow) const -> MinMaxRMS
{
if(IsSummaryAvailable())
{
SimpleBlockFile::GetMinMax(start,len,outMin,outMax,outRMS);
return SimpleBlockFile::GetMinMaxRMS(start, len, mayThrow);
}
else
{
if (mayThrow)
// throw NotYetAvailableException{ mAudioFileName }
;
//fake values. These values are used usually for normalization and amplifying, so we want
//the max to be maximal and the min to be minimal
*outMin = -1.0;
*outMax = 1.0;
*outRMS = (float)0.707;//sin with amp of 1 rms
return {
-1.0f, 1.0f, 0.707f //sin with amp of 1 rms
};
}
}
/// Gets extreme values for the entire block
void ODDecodeBlockFile::GetMinMax(float *outMin, float *outMax, float *outRMS) const
auto ODDecodeBlockFile::GetMinMaxRMS(bool mayThrow) const -> MinMaxRMS
{
if(IsSummaryAvailable())
{
SimpleBlockFile::GetMinMax(outMin,outMax,outRMS);
return SimpleBlockFile::GetMinMaxRMS(mayThrow);
}
else
{
if (mayThrow)
// throw NotYetAvailableException{ mAudioFileName }
;
//fake values. These values are used usually for normalization and amplifying, so we want
//the max to be maximal and the min to be minimal
*outMin = -1.0;
*outMax = 1.0;
*outRMS = (float)0.707;//sin with amp of 1 rms
return {
-1.0f, 1.0f, 0.707f //sin with amp of 1 rms
};
}
}

View File

@@ -63,10 +63,10 @@ class ODDecodeBlockFile final : public SimpleBlockFile
//Calls that rely on summary files need to be overidden
DiskByteCount GetSpaceUsage() const override;
/// Gets extreme values for the specified region
void GetMinMax(size_t start, size_t len,
float *outMin, float *outMax, float *outRMS) const override;
MinMaxRMS GetMinMaxRMS(
size_t start, size_t len, bool mayThrow) const override;
/// Gets extreme values for the entire block
void GetMinMax(float *outMin, float *outMax, float *outRMS) const override;
MinMaxRMS GetMinMaxRMS(bool mayThrow) const override;
/// Returns the 256 byte summary data block
bool Read256(float *buffer, size_t start, size_t len) override;
/// Returns the 64K summary data block

View File

@@ -36,6 +36,8 @@ The summary is eventually computed and written to a file in a background thread.
#include "../ondemand/ODManager.h"
#include "../AudioIO.h"
#include "NotYetAvailableException.h"
//#include <errno.h>
extern AudioIO *gAudioIO;
@@ -121,37 +123,49 @@ void ODPCMAliasBlockFile::Unlock()
/// Gets extreme values for the specified region
void ODPCMAliasBlockFile::GetMinMax(size_t start, size_t len,
float *outMin, float *outMax, float *outRMS) const
auto ODPCMAliasBlockFile::GetMinMaxRMS(
size_t start, size_t len, bool mayThrow) const -> MinMaxRMS
{
if(IsSummaryAvailable())
{
PCMAliasBlockFile::GetMinMax(start,len,outMin,outMax,outRMS);
return PCMAliasBlockFile::GetMinMaxRMS(start, len, mayThrow);
}
else
{
if (mayThrow)
//throw NotYetAvailableException{ GetAliasedFileName() }
;
//fake values. These values are used usually for normalization and amplifying, so we want
//the max to be maximal and the min to be minimal
*outMin = -1.0*JUST_BELOW_MAX_AUDIO;
*outMax = 1.0*JUST_BELOW_MAX_AUDIO;
*outRMS = (float)0.707;//sin with amp of 1 rms
return {
-JUST_BELOW_MAX_AUDIO,
JUST_BELOW_MAX_AUDIO,
0.707f //sin with amp of 1 rms
};
}
}
/// Gets extreme values for the entire block
void ODPCMAliasBlockFile::GetMinMax(float *outMin, float *outMax, float *outRMS) const
auto ODPCMAliasBlockFile::GetMinMaxRMS(bool mayThrow) const -> MinMaxRMS
{
if(IsSummaryAvailable())
{
PCMAliasBlockFile::GetMinMax(outMin,outMax,outRMS);
return PCMAliasBlockFile::GetMinMaxRMS(mayThrow);
}
else
{
if (mayThrow)
//throw NotYetAvailableException{ GetAliasedFileName() }
;
//fake values. These values are used usually for normalization and amplifying, so we want
//the max to be maximal and the min to be minimal
*outMin = -1.0*JUST_BELOW_MAX_AUDIO;
*outMax = 1.0*JUST_BELOW_MAX_AUDIO;
*outRMS = (float)0.707;//sin with amp of 1 rms
return {
-JUST_BELOW_MAX_AUDIO,
JUST_BELOW_MAX_AUDIO,
0.707f //sin with amp of 1 rms
};
}
}

View File

@@ -65,10 +65,10 @@ class ODPCMAliasBlockFile final : public PCMAliasBlockFile
//Calls that rely on summary files need to be overidden
DiskByteCount GetSpaceUsage() const override;
/// Gets extreme values for the specified region
void GetMinMax(size_t start, size_t len,
float *outMin, float *outMax, float *outRMS) const override;
MinMaxRMS GetMinMaxRMS(
size_t start, size_t len, bool mayThrow) const override;
/// Gets extreme values for the entire block
void GetMinMax(float *outMin, float *outMax, float *outRMS) const override;
MinMaxRMS GetMinMaxRMS(bool mayThrow) const override;
/// Returns the 256 byte summary data block
bool Read256(float *buffer, size_t start, size_t len) override;
/// Returns the 64K summary data block