2 #include <Audio/AudioInterface.hpp>
3 #include <Audio/Settings/Model.hpp>
4 #include <Audio/Settings/View.hpp>
6 #include <score/tools/Bind.hpp>
8 #include <ossia/audio/dummy_protocol.hpp>
11 #include <QFormLayout>
19 SCORE_CONCRETE(
"13dabcc3-9cda-422f-a8c7-5fef5c220677")
22 bool available()
const noexcept
override {
return true; }
28 QString prettyName()
const override {
return QObject::tr(
"Dummy (No audio)"); };
29 std::shared_ptr<ossia::audio_engine> make_engine(
32 return std::make_shared<ossia::dummy_engine>(set.getRate(), set.getBufferSize());
35 static void updateLabel(QLabel& l,
int bs,
int rate)
37 l.setText(QString{
"%1 ms (%2 hz)"}
38 .arg(1e3 *
double(bs) / rate, 0,
'f', 3)
39 .arg(rate /
double(bs), 0,
'f', 3));
42 QWidget* make_settings(
46 auto w =
new QWidget{parent};
47 auto lay =
new QFormLayout{w};
49 auto timeLabel =
new QLabel;
50 updateLabel(*timeLabel, m.getBufferSize(), m.getRate());
52 lay->addRow(QObject::tr(
"Tick duration"), timeLabel);
53 auto buffer_sb =
new QSpinBox{};
55 buffer_sb->setObjectName(
"BufferSize");
56 lay->addRow(QObject::tr(
"Buffer size"), buffer_sb);
57 buffer_sb->setRange(1, 10000);
58 buffer_sb->setValue(m.getBufferSize());
61 auto rate_cb = addSampleRateWidget(*w, m, v);
62 auto update_label = [timeLabel, rate_cb, buffer_sb] {
63 updateLabel(*timeLabel, buffer_sb->value(), rate_cb->currentText().toInt());
66 buffer_sb, &QSpinBox::valueChanged, w, [buffer_sb, &v, update_label] {
67 v.BufferSizeChanged(buffer_sb->value());
71 rate_cb, &QComboBox::currentIndexChanged, &v, [&v, rate_cb, update_label] {
72 v.RateChanged(rate_cb->currentText().toInt());
76 con(m, &Audio::Settings::Model::BufferSizeChanged, timeLabel, update_label);
77 con(m, &Audio::Settings::Model::RateChanged, timeLabel, update_label);
Definition: AudioInterface.hpp:28
Definition: DummyInterface.hpp:18
Definition: score-plugin-audio/Audio/Settings/Model.hpp:22
Definition: score-plugin-audio/Audio/Settings/View.hpp:19
Definition: SettingsCommandDispatcher.hpp:10
Used to access all the application-wide state and structures.
Definition: ApplicationContext.hpp:24