Skip to content

Commit

Permalink
Working through CI errors; this commit will be squashed
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1ff committed Mar 3, 2024
1 parent f35b281 commit 57e9b67
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 28 deletions.
3 changes: 2 additions & 1 deletion src/output/plugins/visualization/SoundAnalysis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Visualization::SoundAnalysisParameters::SoundAnalysisParameters(
* <a href="http://fftw.org/fftw3_doc/The-1d-Discrete-Fourier-Transform-_0028DFT_0029.html">here</a>).
*
* The DFT library I'm using (<a href="http://fftw.org">fftw</a> AKA "The
* Fastest Fourier Transofrm in the West") takes advantage of the Hermitian
* Fastest Fourier Transform in the West") takes advantage of the Hermitian
* property of the Fourier Transform of real data in which the k-th Fourier
* coefficient is the complex conjugate of the the (n-k)-th coefficient and ony
* returns the first n/2+1 Fourier coefficients (i.e. indicies 0 to n/2,
Expand Down Expand Up @@ -228,6 +228,7 @@ Visualization::SoundAnalysis::SoundAnalysis(
* indices in an array. For example, we say that a 2d transform has rank
* 2, a 3d transform has rank 3, and so on."
*
* This is always 1, for us.
*
* layout of `in`:
Expand Down
21 changes: 11 additions & 10 deletions src/output/plugins/visualization/SoundAnalysis.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class SoundAnalysis {
/// # of samples to be used in each analysis
size_t num_samples;
/* # of Fourier coefficients computed by FFTW (should be
(num_samples / 2) + 1) */
* (num_samples / 2) + 1) */
size_t out_samples;
std::shared_ptr<SoundInfoCache> pcache;
AudioFormat audio_format;
Expand Down Expand Up @@ -263,9 +263,9 @@ public:
size_t upper_freq_per_chan =
std::min(idx_hi, total_freq_per_chan);

/* In both `out` & `pout`, the coefficients are laid out as: |
* coeffs for chan #0... | coeffs for chan #1... | ... |
* so outer loop will be on channel. */
/* In both `out` & `pout`, the coefficients are laid out as:
* | coeffs for chan #0... | coeffs for chan #1... | ... |
* so the outer loop will be on channel. */
for (unsigned chan = 0; chan < num_channels; ++chan) {

/* This is the index into `out` of the very first
Expand All @@ -281,18 +281,19 @@ public:
++i) {
pout = op(po[i], pout);
}
/* *If* idx_hi is greater than num_samp/2+1, walk back
* *down* the Fourier coefficients (taking advantiage of
* the Hermetian property) */
if (idx_hi > total_freq_per_chan) {
/* *If* idx_hi is greater or equal to than num_samp/2+1,
* walk back down* the Fourier coefficients (taking
* advantiage of * the Hermetian property). */
if (idx_hi >= total_freq_per_chan) {
for (size_t i =
first_freq_this_chan + idx_hi - 1;
i >= first_freq_this_chan +
total_freq_per_chan;
--i) {
fftwf_complex c = {
po[num_samples - i][0],
-po[num_samples-i][1] };
po[num_samples - i][0],
-po[num_samples - i][1]
};
pout = op(c, pout);
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/TestVisualization.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -761,16 +761,16 @@ TEST(VisualizationTest, TrivialDft)
EXPECT_NEAR(float_at(p0, 2), 0.0, ZERO_THRESH);
EXPECT_NEAR(float_at(p0, 3), 0.0, ZERO_THRESH);
EXPECT_NEAR(float_at(p0, 4), 0.0, ZERO_THRESH);
EXPECT_NEAR(float_at(p0, 5), 0.0, ZERO_THRESH); // p0[5] is -2
EXPECT_NEAR(float_at(p0, 5), 0.0, ZERO_THRESH); // p0[5] is random
p0 += 24;

// coefficients, channel 2
EXPECT_NEAR(float_at(p0, 0), 2.0, ZERO_THRESH);
EXPECT_NEAR(float_at(p0, 1), 2.0, ZERO_THRESH);
EXPECT_NEAR(float_at(p0, 2), 2.0, ZERO_THRESH);
EXPECT_FLOAT_EQ(float_at(p0, 0), 2.0);
EXPECT_FLOAT_EQ(float_at(p0, 1), 2.0);
EXPECT_FLOAT_EQ(float_at(p0, 2), 2.0);
EXPECT_NEAR(float_at(p0, 3), 0.0, ZERO_THRESH);
EXPECT_NEAR(float_at(p0, 4), 0.0, ZERO_THRESH);
EXPECT_NEAR(float_at(p0, 5), 0.0, ZERO_THRESH); // p0[2] is 2
EXPECT_NEAR(float_at(p0, 5), 0.0, ZERO_THRESH); // p0[5] is random
p0 += 24;

// bass/mids/trebs
Expand Down
23 changes: 11 additions & 12 deletions test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -642,18 +642,18 @@ subdir('fs')

if enable_visualization_output
test(
'test_vis',
executable(
'test_vis',
'TestVisualization.cxx',
include_directories: inc,
dependencies: [
output_plugins_dep,
gtest_dep,
],
),
protocol: 'gtest',
)
executable(
'test_vis',
'TestVisualization.cxx',
include_directories: inc,
dependencies: [
output_plugins_dep,
gtest_dep,
],
),
protocol: 'gtest',
)
endif

#
Expand All @@ -671,4 +671,3 @@ executable(
cmdline_dep,
],
)

0 comments on commit 57e9b67

Please sign in to comment.