Source browser
examples/signal.cpp
Read the complete file below or download its original bytes. Line numbers provide stable links to a declaration or processing step.
File fingerprint
1/** @file signal.cpp
2 * @brief Run FFT and time-domain signal pipelines on the CPU or a headless GPU.
3 * Independent reference checks validate complex transforms and filter responses.
4 */
5#include "runner.hpp" // Select the backend from the example command line.
6#include "fft_checks.hpp" // Check FFT, spectral masks, and input windows.
7#include "signal_filters_checks.hpp" // Check causal FIR and streaming biquad filters.
8int main(int argc, char** argv) { // Run every signal example with the same selected backend.
9 try { // Report dimension or numerical errors as a failed example.
10 shdr_examples::runner run(argc, argv); // Use CPU by default or the requested GPU profile.
11 shdr_examples::check_fft1d(run); // Validate the forward and inverse complex transforms.
12 shdr_examples::check_frequency_filters(run); // Validate all frequency-domain filter modes.
13 shdr_examples::check_signal_windows(run); // Validate windowed spectral analysis.
14 shdr_examples::check_signal_filters( // Validate FIR responses and persistent biquad state.
15 run); // Validate FIR responses and persistent biquad state.
16 std::cout << (run.gpu() ? "GPU" : "CPU") // Report the completed real-data processing check.
17 << " signal pipelines passed\n"; // Show which backend completed the checks.
18 return 0; // All processing and reference comparisons succeeded.
19#ifdef SHDR_HAVE_EGL // The optional EGL backend can identify unavailable contexts.
20 } catch (const shdr_examples::context_unavailable& // Report an unavailable optional profile with the skip status.
21 error) { // Report an unavailable optional profile with the skip status.
22 std::cerr << "SKIP: " << error.what() << '\n'; // Explain why this backend was unavailable.
23 return 77; // Report an unavailable optional context with the CTest skip code.
24#endif // Finish the optional graphics-context exception handler.
25 } catch (const std::exception& error) { // Preserve all actual processing failures.
26 std::cerr << error.what() << '\n'; // Print the numerical or resource diagnostic.
27 return 1; // Mark the example as failed.
28 } // Exception handling keeps the command-line result explicit.
29} // The executable contains its native shader sources after the CMake build.