22 #ifndef EDSP_OSCILLATOR_SIN_HPP 23 #define EDSP_OSCILLATOR_SIN_HPP 30 namespace edsp {
namespace oscillators {
66 constexpr
value_type frequency() const noexcept;
72 constexpr
void set_frequency(
value_type frequency) noexcept;
102 constexpr
value_type samplerate() const noexcept;
108 constexpr
void set_samplerate(
value_type samplerate) noexcept;
115 constexpr
value_type sampling_period() const noexcept;
121 constexpr
value_type amplitude() const noexcept;
127 constexpr
void set_amplitude(
value_type amplitude) noexcept;
132 constexpr
void reset() noexcept;
136 value_type timestamp_{0.};
137 value_type samplerate_{0.};
138 value_type sampling_period_{0.};
139 value_type frequency_{1.};
140 value_type phase_{0.};
166 template <
typename T>
189 template <
typename T>
194 template <
typename T>
203 template <
typename T>
206 amplitude_(amplitude),
207 samplerate_(samplerate),
209 frequency_(frequency),
212 template <
typename T>
217 template <
typename T>
222 template <
typename T>
227 template <
typename T>
232 template <
typename T>
234 samplerate_ = samplerate;
235 sampling_period_ =
math::inv(samplerate_);
238 template <
typename T>
243 template <
typename T>
245 frequency_ = frequency;
248 template <
typename T>
253 template <
typename T>
258 template <
typename T>
263 template <
typename T>
265 amplitude_ = amplitude;
268 template <
typename T>
270 return sampling_period_;
275 #endif // EDSP_OSCILLATOR_SIN_HPP T value_type
Definition: sinusoidal.hpp:169
constexpr void set_samplerate(value_type samplerate) noexcept
Sets the sampling frequency.
Definition: sinusoidal.hpp:233
constexpr value_type timestamp() const noexcept
Returns the current timestamp of the signal in seconds.
Definition: sinusoidal.hpp:213
constexpr oscillator(value_type amplitude, value_type samplerate, value_type frequency, value_type phase) noexcept
Creates an oscillator that generates a waveform with the configuration.
Definition: sinusoidal.hpp:204
constexpr value_type sampling_period() const noexcept
Returns the sampling period in secs.
Definition: sinusoidal.hpp:269
The oscillator class generates a periodic signal.
Definition: sinusoidal.hpp:48
std::int64_t timestamp
Definition: timestamp.hpp:29
constexpr void set_amplitude(value_type amplitude) noexcept
Set the amplitude of the periodic signal.
Definition: sinusoidal.hpp:264
constexpr sin_oscillator(value_type amplitude, value_type samplerate, value_type frequency, value_type phase) noexcept
Creates a sinusoidal oscillator that generates a waveform with the configuration. ...
Definition: sinusoidal.hpp:190
T value_type
Definition: sinusoidal.hpp:50
constexpr value_type operator()()
Generates one step.
Definition: sinusoidal.hpp:195
constexpr value_type frequency() const noexcept
Returns the fundamental frequency in Hz.
Definition: sinusoidal.hpp:239
constexpr value_type samplerate() const noexcept
Returns the sampling frequency in Hz.
Definition: sinusoidal.hpp:228
constexpr T inv(T x)
Computes the inverse value of the input number.
Definition: numeric.hpp:208
constexpr value_type amplitude() const noexcept
Returns the amplitude of the periodic signal.
Definition: sinusoidal.hpp:259
constexpr value_type phase() const noexcept
Returns the phase shift in radians.
Definition: sinusoidal.hpp:249
constexpr void set_frequency(value_type frequency) noexcept
Sets the fundamental frequency of the periodic signal.
Definition: sinusoidal.hpp:244
constexpr void reset() noexcept
Reset the oscillator to the original state.
Definition: sinusoidal.hpp:223
constexpr void set_phase(value_type phase) noexcept
Sets the phase shift of the periodic signal.
Definition: sinusoidal.hpp:254
constexpr void set_timestamp(value_type timestamp) noexcept
Sets the current timestamp of the periodic signal.
Definition: sinusoidal.hpp:218
The class sin_oscillator generates a sinusoidal signal.
Definition: sinusoidal.hpp:167
constexpr T phase(const std::complex< T > &z)
Computes the phase of the complex number z.
Definition: complex.hpp:50
logger & reset(logger &stream)
Resets the logger to default configuration.
Definition: logger.hpp:416
Definition: amplifier.hpp:29
OscillatorType
the OscillatorType enum represents the different waveforms generated by tha available oscillators...
Definition: sinusoidal.hpp:35