Skip to content

Instantly share code, notes, and snippets.

View chbtoys's full-sized avatar

Carl H. Blomqvist chbtoys

View GitHub Profile
@chbtoys
chbtoys / 06-la.cpp
Created July 17, 2022 09:43
audio programming - beginner level
// compile: clang++ -std=c++20 -lpng 06-la.cpp -o 06-la
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <random>
#include <filesystem>
#include "indicators.hpp"
#include <png++/png.hpp>
#include "AudioFile/AudioFile.h"
#include "Envelope.hpp"
@chbtoys
chbtoys / 05-fm.cpp
Created July 17, 2022 09:41
audio programming - beginner level
// compile: clang++ -std=c++20 -lpng 05-fm.cpp -o 05-fm
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <random>
#include <filesystem>
#include "indicators.hpp"
#include <png++/png.hpp>
#include "AudioFile/AudioFile.h"
#include "Envelope.hpp"
@chbtoys
chbtoys / 04-granular.cpp
Last active July 29, 2022 23:18
audio programming - beginner level
// compile: clang++ -std=c++20 -lpng 04-granular.cpp -o 04-granular
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <random>
#include <filesystem>
#include "indicators.hpp"
#include <png++/png.hpp>
#include "AudioFile/AudioFile.h"
#include "Envelope.hpp"
@chbtoys
chbtoys / 03-formant.cpp
Created July 17, 2022 09:39
audio programming - beginner level
// compile: clang++ -std=c++20 -lpng 03-formant.cpp -o 03-formant
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <random>
#include <filesystem>
#include "indicators.hpp"
#include <png++/png.hpp>
#include "AudioFile/AudioFile.h"
@chbtoys
chbtoys / 02-subtractive.cpp
Created July 17, 2022 09:37
audio programming - beginner level
// compile: clang++ -std=c++20 -lpng 02-subtractive.cpp -o 02-subtractive
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <random>
#include <filesystem>
#include "indicators.hpp"
#include <png++/png.hpp>
#include "AudioFile/AudioFile.h"
@chbtoys
chbtoys / 01-additive.cpp
Created July 17, 2022 09:35
audio programming - beginner level
// compile: clang++ -std=c++20 -lpng 01-additive.cpp -o 01-additive
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <random>
#include <filesystem>
#include "indicators.hpp"
#include <png++/png.hpp>
#include "AudioFile/AudioFile.h"
@chbtoys
chbtoys / 00-signalgenerators.cpp
Created July 17, 2022 09:32
audio programming - beginner level
// Signal Generators
//
// Compile: clang++ -std=c++20 -lpng 00-signalgenerators.cpp -o 00-signalgenerators
//
// If #include <png++/png.hpp> is missing:
// > brew install png++
// png++ (header-only) is used to render audio as images to visualize the waveform.
// Install with homebrew on macOS or with other package manager.
// https://savannah.nongnu.org/projects/pngpp/
//
@chbtoys
chbtoys / 05-intro.cpp
Created July 1, 2021 09:18
Code Example. From Paper to Code.
// From Paper to Code
// Summation
// Run with: https://www.jdoodle.com/online-compiler-c++17/
// LaTeX: X = \{X_{1},X_{2},...,X_{n} \};
// LaTeX: var(X) = \frac{1}{|x|^2} \sum_{x \epsilon X} \sum_{x \epsilon X} \frac{1}{2} (i - j)^2
// Test LaTeX: https://quicklatex.com/
#include <iostream>
#include <vector>
#include <cmath>
@chbtoys
chbtoys / 04-intro.cpp
Created July 1, 2021 09:04
Code Example. From Paper to Code.
// From Paper to Code
// Summation
// Run with: https://www.jdoodle.com/online-compiler-c++17/
// LaTeX: X = \{X_{1},X_{2},...,X_{n} \};
// LaTeX: avg(X) = \frac{1}{|x|} \sum_{x \epsilon X} x
// Test LaTeX: https://quicklatex.com/
#include <iostream>
#include <vector>
double avg(std::vector<double> &X)
@chbtoys
chbtoys / 03-intro.cpp
Created July 1, 2021 08:54
Code Example. From Paper to Code.
// From Paper to Code
// Summation
// Run with: https://www.jdoodle.com/online-compiler-c++17/
// LaTeX: X = \{X_{1},X_{2},...,X_{n} \};
// LaTeX: avg(X) = \frac{1}{|x|} \sum_{i\epsilon\{1,2..n\}} x_{i}
// Test LaTeX: https://quicklatex.com/
#include <iostream>
#include <vector>
double avg(std::vector<double> &X)