mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:37:44 +00:00
Piano: Add Play/Pause, Forward and Back buttons
Piano now has a toolbar allowing the playback to be paused, or to be stepped forward or back a note.
This commit is contained in:
parent
54c005754a
commit
74f1f2b5e2
10 changed files with 234 additions and 69 deletions
38
Userland/Applications/Piano/AudioPlayerLoop.h
Normal file
38
Userland/Applications/Piano/AudioPlayerLoop.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2021, kleines Filmröllchen <malu.bertsch@gmail.com>
|
||||
* Copyright (c) 2021, JJ Roberts-White <computerfido@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Music.h"
|
||||
#include <LibAudio/ClientConnection.h>
|
||||
#include <LibAudio/WavWriter.h>
|
||||
#include <LibCore/Object.h>
|
||||
|
||||
class TrackManager;
|
||||
|
||||
// Wrapper class accepting custom events to advance the track playing and forward audio data to the system.
|
||||
// This does not run on a separate thread, preventing IPC multithreading madness.
|
||||
class AudioPlayerLoop : public Core::Object {
|
||||
C_OBJECT(AudioPlayerLoop)
|
||||
public:
|
||||
AudioPlayerLoop(TrackManager& track_manager, bool& need_to_write_wav, Audio::WavWriter& wav_writer);
|
||||
|
||||
void enqueue_audio();
|
||||
|
||||
void toggle_paused();
|
||||
bool is_playing() { return m_should_play_audio; }
|
||||
|
||||
private:
|
||||
TrackManager& m_track_manager;
|
||||
Array<Sample, sample_count> m_buffer;
|
||||
RefPtr<Audio::ClientConnection> m_audio_client;
|
||||
|
||||
bool m_should_play_audio = true;
|
||||
|
||||
bool& m_need_to_write_wav;
|
||||
Audio::WavWriter& m_wav_writer;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue