add rec to audio and base modern concepts

This commit is contained in:
2025-09-02 12:28:56 +03:00
parent 7832b2095b
commit e08f299d5c
10 changed files with 633 additions and 91 deletions

View File

@@ -1,10 +1,6 @@
#include <vector>
#include <forward_list>
#include "hack/audio/generate.hpp"
#include "hack/audio/play.hpp"
#include "hack/audio/save.hpp"
#include "hack/logger/logger.hpp"
#include "hack/range/sort.hpp"
@@ -18,28 +14,16 @@
auto main(int argc, char *argv[]) -> int
{
// HERE
// concepts
{
int sample_rate = 44100;
// Воспроизведение последовательности нот
hack::warn()("Пример использования: audio");
std::vector<double> frequencies = { 130.81, 138.59, 146.83, 155.56, 164.81, 174.61, 185.00, 196.00, 207.65, 220.00, 233.08, 246.94 };
std::vector<double> melody;
for (double freq : frequencies)
{
auto note = hack::audio::generate::sine(freq, 0.3, sample_rate);
melody.insert(melody.end(), note.begin(), note.end());
// Добавляем небольшую паузу между нотами. Т.е. вставляем кол-во с нулевым значением.
melody.insert(melody.end(), sample_rate * 0.05, 0.0);
}
hack::log()("Воспроизведение последовательности нот...");
hack::audio::play(melody, sample_rate);
hack::log()("Запись последовательности нот в файл");
hack::audio::save("/mnt/raid/projects/hack/hack/bin/test/note.wav", melody, sample_rate);
}
// patterns::ring_buffer
{
hack::patterns::ring_buffer<int> rb;