2018-04-18 02:28:13 +00:00
|
|
|
//
|
|
|
|
// AudioToggle.cpp
|
|
|
|
// 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
|
|
|
//
|
|
|
|
|
|
|
|
#include "AudioToggle.hpp"
|
|
|
|
|
|
|
|
using namespace Audio;
|
|
|
|
|
|
|
|
Audio::Toggle::Toggle(Concurrency::DeferringAsyncTaskQueue &audio_queue) :
|
|
|
|
audio_queue_(audio_queue) {}
|
|
|
|
|
|
|
|
void Toggle::get_samples(std::size_t number_of_samples, std::int16_t *target) {
|
|
|
|
for(std::size_t sample = 0; sample < number_of_samples; ++sample) {
|
|
|
|
target[sample] = level_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toggle::set_sample_volume_range(std::int16_t range) {
|
|
|
|
volume_ = range;
|
|
|
|
}
|
|
|
|
|
2020-05-30 04:37:06 +00:00
|
|
|
void Toggle::skip_samples(std::size_t) {}
|
2018-04-18 02:28:13 +00:00
|
|
|
|
|
|
|
void Toggle::set_output(bool enabled) {
|
|
|
|
if(is_enabled_ == enabled) return;
|
|
|
|
is_enabled_ = enabled;
|
2020-02-15 04:39:08 +00:00
|
|
|
audio_queue_.defer([this, enabled] {
|
2018-04-18 02:28:13 +00:00
|
|
|
level_ = enabled ? volume_ : 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-05-10 01:22:51 +00:00
|
|
|
bool Toggle::get_output() const {
|
2018-04-18 02:28:13 +00:00
|
|
|
return is_enabled_;
|
|
|
|
}
|