1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:27:35 +00:00

LibDSP: Improve const correctness

This commit is contained in:
kleines Filmröllchen 2022-05-11 21:49:41 +02:00 committed by Linus Groh
parent 4a6ebb8beb
commit bcb331b862
8 changed files with 23 additions and 22 deletions

View file

@ -15,10 +15,9 @@
namespace LibDSP {
// FIXME: Audio::Frame is 64-bit float, which is quite large for long clips.
using Sample = Audio::Sample;
Sample const SAMPLE_OFF = { 0.0, 0.0 };
constexpr Sample const SAMPLE_OFF = { 0.0, 0.0 };
struct RollNote {
constexpr u32 length() const { return (off_sample - on_sample) + 1; }
@ -28,7 +27,7 @@ struct RollNote {
u8 pitch;
i8 velocity;
Envelope to_envelope(u32 time, u32 attack_samples, u32 decay_samples, u32 release_samples)
constexpr Envelope to_envelope(u32 time, u32 attack_samples, u32 decay_samples, u32 release_samples) const
{
i64 time_since_end = static_cast<i64>(time) - static_cast<i64>(off_sample);
// We're before the end of this note.
@ -58,7 +57,7 @@ struct RollNote {
return Envelope::from_release(static_cast<double>(time_since_end) / static_cast<double>(release_samples));
}
constexpr bool is_playing(u32 time) { return on_sample <= time && time <= off_sample; }
constexpr bool is_playing(u32 time) const { return on_sample <= time && time <= off_sample; }
};
enum class SignalType : u8 {
@ -178,8 +177,8 @@ constexpr double note_frequencies[] = {
3729.3100921447249,
3951.0664100489994,
};
constexpr size_t note_count = array_size(note_frequencies);
constexpr size_t const note_count = array_size(note_frequencies);
constexpr double middle_c = note_frequencies[36];
constexpr double const middle_c = note_frequencies[36];
}