22 lines
444 B
C++
22 lines
444 B
C++
#include <psemek/audio/wave/sine.hpp>
|
|
#include <psemek/audio/wave/generator.hpp>
|
|
#include <psemek/geom/math.hpp>
|
|
#include <psemek/util/to_shared.hpp>
|
|
|
|
#include <cmath>
|
|
|
|
namespace psemek::audio
|
|
{
|
|
|
|
stream_ptr sine_wave(float frequency)
|
|
{
|
|
float angular_frequency = frequency * 2.f * geom::pi;
|
|
|
|
auto func = [angular_frequency](float t){
|
|
return std::sin(angular_frequency * t);
|
|
};
|
|
|
|
return util::to_shared(generator_stream(func));
|
|
}
|
|
|
|
}
|