mirror of
https://codeberg.org/tenacityteam/tenacity
synced 2025-10-04 11:09:34 +02:00
7470 Fix crash when importing short audio (#9096)
(cherry picked from commit efc959a77f2fbdd25966d70b32da91a384db16ca) Signed-off-by: Avery King <gperson@disroot.org>
This commit is contained in:
committed by
Avery King
parent
73ea436037
commit
830acf7838
@@ -137,9 +137,10 @@ std::optional<MusicalMeter> GetMusicalMeterFromSignal(
|
|||||||
if (audio.GetSampleRate() <= 0)
|
if (audio.GetSampleRate() <= 0)
|
||||||
return {};
|
return {};
|
||||||
const auto duration = 1. * audio.GetNumSamples() / audio.GetSampleRate();
|
const auto duration = 1. * audio.GetNumSamples() / audio.GetSampleRate();
|
||||||
if (duration > 60)
|
if (duration > 60 || duration < 1)
|
||||||
// A file longer than 1 minute is most likely not a loop, and processing
|
// A file longer than 1 minute is most likely not a loop, and processing
|
||||||
// it would be costly.
|
// it would be costly.
|
||||||
|
// A file shorter than 1 second is too short to be a loop.
|
||||||
return {};
|
return {};
|
||||||
DecimatingMirAudioReader decimatedAudio { audio };
|
DecimatingMirAudioReader decimatedAudio { audio };
|
||||||
return GetMeterUsingTatumQuantizationFit(
|
return GetMeterUsingTatumQuantizationFit(
|
||||||
|
@@ -21,7 +21,7 @@ namespace MIR
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
constexpr auto twoPi = 2 * 3.14159265358979323846;
|
constexpr auto twoPi = 2 * M_PI;
|
||||||
|
|
||||||
int GetFrameSize(int sampleRate)
|
int GetFrameSize(int sampleRate)
|
||||||
{
|
{
|
||||||
@@ -94,6 +94,8 @@ int StftFrameProvider::GetSampleRate() const
|
|||||||
|
|
||||||
double StftFrameProvider::GetFrameRate() const
|
double StftFrameProvider::GetFrameRate() const
|
||||||
{
|
{
|
||||||
|
if (mHopSize <= 0)
|
||||||
|
return 0;
|
||||||
return 1. * mAudio.GetSampleRate() / mHopSize;
|
return 1. * mAudio.GetSampleRate() / mHopSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user