33 explicit Buzzer(QGraphicsItem *parent =
nullptr);
48 void setAudio(
const QString ¬e)
override;
69 QAudioSink *m_sink =
nullptr;
Shared base class for audio output elements (AudioBox and Buzzer).
AudioOutputElement(ElementType type, QGraphicsItem *parent=nullptr, float initialVolume=kDefaultVolume)
double frequency() const override
Returns the tone frequency in Hz.
void applyMute() override
Applies the current m_muted state to the hardware backend.
void stopAudio() override
Stops hardware playback (called from stop() when m_hasOutputDevice is true).
Buzzer(QGraphicsItem *parent=nullptr)
Constructs a Buzzer element (default: 1047 Hz / C6).
void startAudio() override
Starts hardware playback (called from play() when m_hasOutputDevice is true).
void setFrequency(double freq) override
Sets the tone frequency in Hz.
void save(QDataStream &stream, SerializationOptions options) const override
Buzzer(const Buzzer &other)
Copy-constructs by delegating to the parent item constructor.
void setAudio(const QString ¬e) override
Sets the tone by note name (e.g. "C6") for backward compatibility.
static constexpr float kDefaultVolume
void load(QDataStream &stream, SerializationContext &context) override
static int noteToFrequency(const QString ¬e)
Maps a note name (e.g. "C6") to its frequency in Hz. Returns 1047 for unknown notes.
static constexpr double kDefaultFrequency
void applyVolume() override
Applies the current m_volume to the hardware backend.
Bundles all per-deserialization state so that load() overrides receive it through one explicit parame...
Options passed to GraphicElement::save() (and friends); the save-side counterpart of SerializationCon...