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

LibDSP: Refactor OOP non-functionally

* Don't inherit from Core::Object everywhere, that's overkill. Use
  RefCounted instead.
* Change some constructor visibilites to facilitate the above.
* default-implement all virtual destructors if possible.
* Drive-by include hygiene.
This commit is contained in:
kleines Filmröllchen 2022-05-11 21:37:55 +02:00 committed by Linus Groh
parent 3cfa9b63b5
commit 4a6ebb8beb
9 changed files with 48 additions and 46 deletions

View file

@ -1,20 +1,19 @@
/*
* Copyright (c) 2021, kleines Filmröllchen <filmroellchen@serenityos.org>
* Copyright (c) 2021-2022, kleines Filmröllchen <filmroellchen@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Music.h"
#include <AK/RefCounted.h>
#include <AK/Types.h>
#include <LibCore/Object.h>
#include <LibDSP/Music.h>
namespace LibDSP {
// The DAW-wide timekeeper and synchronizer
class Transport final : public Core::Object {
C_OBJECT(Transport)
class Transport final : public RefCounted<Transport> {
public:
constexpr u32& time() { return m_time; }
constexpr u16 beats_per_minute() const { return m_beats_per_minute; }
@ -24,7 +23,6 @@ public:
constexpr double ms_sample_rate() const { return m_sample_rate / 1000.; }
constexpr double current_measure() const { return m_time / samples_per_measure(); }
private:
Transport(u16 beats_per_minute, u8 beats_per_measure, u32 sample_rate)
: m_beats_per_minute(beats_per_minute)
, m_beats_per_measure(beats_per_measure)
@ -36,6 +34,7 @@ private:
{
}
private:
// FIXME: You can't make more than 24h of (48kHz) music with this.
// But do you want to, really? :^)
u32 m_time { 0 };