1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00
CLK/Components/AudioToggle/AudioToggle.hpp

44 lines
1.0 KiB
C++
Raw Normal View History

//
// AudioToggle.hpp
// Clock Signal
//
// Created by Thomas Harte on 17/04/2018.
// Copyright 2018 Thomas Harte. All rights reserved.
//
#ifndef AudioToggle_hpp
#define AudioToggle_hpp
#include "../../Outputs/Speaker/Implementation/SampleSource.hpp"
#include "../../Concurrency/AsyncTaskQueue.hpp"
namespace Audio {
/*!
Provides a sample source that can programmatically be set to one of two values.
*/
class Toggle: public Outputs::Speaker::SampleSource {
public:
Toggle(Concurrency::DeferringAsyncTaskQueue &audio_queue);
void get_samples(std::size_t number_of_samples, std::int16_t *target);
void set_sample_volume_range(std::int16_t range);
void skip_samples(const std::size_t number_of_samples);
static constexpr bool get_is_stereo() { return false; }
void set_output(bool enabled);
bool get_output();
private:
2018-04-21 21:56:50 +00:00
// Accessed on the calling thread.
bool is_enabled_ = false;
Concurrency::DeferringAsyncTaskQueue &audio_queue_;
2018-04-21 21:56:50 +00:00
// Accessed on the audio thread.
int16_t level_ = 0, volume_ = 0;
};
}
#endif /* AudioToggle_hpp */