F.E.I.S/src/aubio_cpp.hpp

27 lines
849 B
C++
Raw Normal View History

2023-05-10 02:00:20 +02:00
#pragma once
#include <functional>
#include <memory>
#include <optional>
2023-05-10 02:00:20 +02:00
#include <aubio/aubio.h>
#include <aubio/onset/onset.h>
#include <SFML/Config.hpp>
// Thanks stack overflow !
// https://stackoverflow.com/a/54121092/10768117
template <auto F>
struct Functor {
template <typename... Args>
auto operator()(Args&&... args) const { return std::invoke(F, std::forward<Args>(args)...); }
};
namespace aubio {
using _aubio_onset_t_unique_ptr = std::unique_ptr<aubio_onset_t, Functor<del_aubio_onset>>;
struct onset_detector : _aubio_onset_t_unique_ptr {
template <typename... Args>
onset_detector(Args&&... args) : _aubio_onset_t_unique_ptr(new_aubio_onset(std::forward<Args>(args)...)) {}
2023-05-15 01:44:02 +02:00
// takes in Mono samples
2023-05-10 02:00:20 +02:00
std::optional<std::size_t> detect(const std::vector<sf::Int16>& samples);
};
}