Skip to content

Commit

Permalink
Bump revision of com_google_audio_tools.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 728680806
  • Loading branch information
MediaPipe Team authored and copybara-github committed Feb 19, 2025
1 parent ecbfda1 commit 2b2109e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 80 deletions.
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ http_archive(
sha256 = "ad37707084a6d4ff41be10cbe8540c75bea057ba79d0de6c367c1bfac6ba0852",
strip_prefix = "kleidiai-40a926833857fb64786e02f97703e42b1537cb57",
urls = [
"https://gitlab.arm.com/kleidi/kleidiai/-/archive/40a926833857fb64786e02f97703e42b1537cb57/kleidiai-40a926833857fb64786e02f97703e42b1537cb57.zip"
"https://gitlab.arm.com/kleidi/kleidiai/-/archive/40a926833857fb64786e02f97703e42b1537cb57/kleidiai-40a926833857fb64786e02f97703e42b1537cb57.zip",
],
)

Expand Down Expand Up @@ -469,9 +469,9 @@ http_archive(
# TODO: Fix this in AudioTools directly
patches = ["@//third_party:com_google_audio_tools_fixes.diff"],
repo_mapping = {"@com_github_glog_glog": "@com_github_glog_glog_no_gflags"},
sha256 = "0856be6971c636d62c9eaaf8fca3c8aa85b9be55ac5cf124d05d1dfe4a77eaf1",
strip_prefix = "multichannel-audio-tools-9aebbcabc1b5ed3827755f44339d8a0d572e16ec",
urls = ["https://github.com/google/multichannel-audio-tools/archive/9aebbcabc1b5ed3827755f44339d8a0d572e16ec.zip"],
sha256 = "7d7227cc6bb1f8917a9c9013e8f3578ec681c49e20fe2fc38ba90965394de60c",
strip_prefix = "multichannel-audio-tools-bbf15de4b7cd825d650296d21917afc07e8fe18b",
urls = ["https://github.com/google/multichannel-audio-tools/archive/bbf15de4b7cd825d650296d21917afc07e8fe18b.tar.gz"],
)

http_archive(
Expand Down
76 changes: 0 additions & 76 deletions third_party/com_google_audio_tools_fixes.diff
Original file line number Diff line number Diff line change
Expand Up @@ -35,82 +35,6 @@ index 56e45d2..37ab6e9 100644
#include <cmath>
#include <limits>
#include <string>
diff --git a/audio/dsp/spectrogram/spectrogram.cc b/audio/dsp/spectrogram/spectrogram.cc
index e52280d..13c45d0 100644
--- a/audio/dsp/spectrogram/spectrogram.cc
+++ b/audio/dsp/spectrogram/spectrogram.cc
@@ -18,6 +18,7 @@
#include "audio/dsp/spectrogram/spectrogram.h"

#include <math.h>
+#include <optional>

#include "audio/dsp/number_util.h"
#include "audio/dsp/window_functions.h"
@@ -38,14 +39,15 @@ bool Spectrogram::ResetSampleBuffer() {
return true;
}

-bool Spectrogram::Initialize(int window_length, int step_length) {
+bool Spectrogram::Initialize(int window_length, int step_length,
+ std::optional<int> fft_length) {
std::vector<double> window;
HannWindow().GetPeriodicSamples(window_length, &window);
- return Initialize(window, step_length);
+ return Initialize(window, step_length, fft_length);
}

-bool Spectrogram::Initialize(const std::vector<double>& window,
- int step_length) {
+bool Spectrogram::Initialize(const std::vector<double>& window, int step_length,
+ std::optional<int> fft_length) {
window_length_ = window.size();
window_ = window; // Copy window.
if (window_length_ < 2) {
@@ -61,7 +63,12 @@ bool Spectrogram::Initialize(const std::vector<double>& window,
return false;
}

- fft_length_ = NextPowerOfTwo(window_length_);
+ if (fft_length.has_value() && !IsPowerOfTwoOrZero(fft_length.value())) {
+ LOG(ERROR) << "FFT length must be a power of two.";
+ initialized_ = false;
+ return false;
+ }
+ fft_length_ = fft_length.value_or(NextPowerOfTwo(window_length_));
CHECK(fft_length_ >= window_length_);
output_frequency_channels_ = 1 + fft_length_ / 2;

diff --git a/audio/dsp/spectrogram/spectrogram.h b/audio/dsp/spectrogram/spectrogram.h
index 1214422..0f6ada6 100644
--- a/audio/dsp/spectrogram/spectrogram.h
+++ b/audio/dsp/spectrogram/spectrogram.h
@@ -36,6 +36,7 @@
#define AUDIO_DSP_SPECTROGRAM_SPECTROGRAM_H_

#include <complex>
+#include <optional>
#include <deque>
#include <vector>

@@ -57,11 +58,14 @@ class Spectrogram {
// (both in samples). Internally a Hann window is used as the window
// function. Returns true on success, after which calls to Process()
// are possible. window_length must be greater than 1 and step
- // length must be greater than 0.
- bool Initialize(int window_length, int step_length);
+ // length must be greater than 0. fft_length defines the fft length which must
+ // be greater than window_length and a power of 2.
+ bool Initialize(int window_length, int step_length,
+ std::optional<int> fft_length = std::nullopt);

// Initialize with an explicit window instead of a length.
- bool Initialize(const vector<double>& window, int step_length);
+ bool Initialize(const std::vector<double>& window, int step_length,
+ std::optional<int> fft_length = std::nullopt);

// Re-initializes/resets the internal sample buffer to the state before any
// samples have been passed to the Compute methods.
diff --git a/third_party/eigen3/BUILD b/third_party/eigen3/BUILD
index 497c1f0..de1c7f4 100644
--- a/third_party/eigen3/BUILD
Expand Down

0 comments on commit 2b2109e

Please sign in to comment.