2018-04-18 02:28:13 +00:00
|
|
|
//
|
|
|
|
// AudioToggle.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 17/04/2018.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2018 Thomas Harte. All rights reserved.
|
2018-04-18 02:28:13 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#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:
|
2022-07-14 20:39:26 +00:00
|
|
|
Toggle(Concurrency::TaskQueue<false> &audio_queue);
|
2018-04-18 02:28:13 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
void set_output(bool enabled);
|
2020-05-10 01:22:51 +00:00
|
|
|
bool get_output() const;
|
2018-04-18 02:28:13 +00:00
|
|
|
|
|
|
|
private:
|
2018-04-21 21:56:50 +00:00
|
|
|
// Accessed on the calling thread.
|
2018-04-18 02:28:13 +00:00
|
|
|
bool is_enabled_ = false;
|
2022-07-14 20:39:26 +00:00
|
|
|
Concurrency::TaskQueue<false> &audio_queue_;
|
2018-04-21 21:56:50 +00:00
|
|
|
|
|
|
|
// Accessed on the audio thread.
|
|
|
|
int16_t level_ = 0, volume_ = 0;
|
2018-04-18 02:28:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* AudioToggle_hpp */
|