1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
Rosegarden
A MIDI and audio sequencer and musical notation editor.
This program is Copyright 2000-2008
Guillaume Laurent <glaurent@telegraph-road.org>,
Chris Cannam <cannam@all-day-breakfast.com>,
Richard Bown <richard.bown@ferventsoftware.com>
The moral rights of Guillaume Laurent, Chris Cannam, and Richard
Bown to claim authorship of this work have been asserted.
Other copyrights also apply to some parts of this work. Please
see the AUTHORS file and individual file headers for details.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version. See the file
COPYING included with this distribution for more information.
*/
#include "LatencyConfigurationPage.h"
#include <qlayout.h>
#include "document/ConfigGroups.h"
#include "ConfigurationPage.h"
#include "document/RosegardenGUIDoc.h"
#include "TabbedConfigurationPage.h"
#include <kconfig.h>
#include <qframe.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qslider.h>
#include <qstring.h>
#include <qtabwidget.h>
#include <qwidget.h>
namespace Rosegarden
{
LatencyConfigurationPage::LatencyConfigurationPage(RosegardenGUIDoc *doc,
KConfig *cfg,
QWidget *parent,
const char *name)
: TabbedConfigurationPage(doc, cfg, parent, name)
{
// Configuration &config = doc->getConfiguration();
m_cfg->setGroup(LatencyOptionsConfigGroup);
#ifdef NOT_DEFINED
#ifdef HAVE_LIBJACK
frame = new QFrame(m_tabWidget, i18n("JACK latency"));
layout = new QGridLayout(frame, 6, 5, 10, 10);
layout->addMultiCellWidget(new QLabel(i18n("Use the \"Fetch JACK latencies\" button to discover the latency values set at\nthe sequencer. It's recommended that you use the returned values but it's also\npossible to override them manually using the sliders. Note that if you change\nyour JACK server parameters you should always fetch the latency values again.\nThe latency values will be stored by Rosegarden for use next time."), frame),
0, 0,
0, 3);
layout->addWidget(new QLabel(i18n("JACK playback latency (in ms)"), frame), 1, 0);
layout->addWidget(new QLabel(i18n("JACK record latency (in ms)"), frame), 3, 0);
m_fetchLatencyValues = new QPushButton(i18n("Fetch JACK latencies"),
frame);
layout->addWidget(m_fetchLatencyValues, 1, 3);
connect(m_fetchLatencyValues, SIGNAL(released()),
SLOT(slotFetchLatencyValues()));
int jackPlaybackValue = (m_cfg->readLongNumEntry(
"jackplaybacklatencyusec", 0) / 1000) +
(m_cfg->readLongNumEntry(
"jackplaybacklatencysec", 0) * 1000);
m_jackPlayback = new QSlider(Horizontal, frame);
m_jackPlayback->setTickmarks(QSlider::Below);
layout->addMultiCellWidget(m_jackPlayback, 3, 3, 2, 3);
QLabel *jackPlaybackLabel = new QLabel(QString("%1").arg(jackPlaybackValue),
frame);
layout->addWidget(jackPlaybackLabel, 2, 2, Qt::AlignHCenter);
connect(m_jackPlayback, SIGNAL(valueChanged(int)),
jackPlaybackLabel, SLOT(setNum(int)));
m_jackPlayback->setMinValue(0);
layout->addWidget(new QLabel("0", frame), 3, 1, Qt::AlignRight);
m_jackPlayback->setMaxValue(500);
layout->addWidget(new QLabel("500", frame), 3, 4, Qt::AlignLeft);
m_jackPlayback->setValue(jackPlaybackValue);
int jackRecordValue = (m_cfg->readLongNumEntry(
"jackrecordlatencyusec", 0) / 1000) +
(m_cfg->readLongNumEntry(
"jackrecordlatencysec", 0) * 1000);
m_jackRecord = new QSlider(Horizontal, frame);
m_jackRecord->setTickmarks(QSlider::Below);
layout->addMultiCellWidget(m_jackRecord, 5, 5, 2, 3);
QLabel *jackRecordLabel = new QLabel(QString("%1").arg(jackRecordValue),
frame);
layout->addWidget(jackRecordLabel, 4, 2, Qt::AlignHCenter);
connect(m_jackRecord, SIGNAL(valueChanged(int)),
jackRecordLabel, SLOT(setNum(int)));
m_jackRecord->setMinValue(0);
layout->addWidget(new QLabel("0", frame), 5, 1, Qt::AlignRight);
m_jackRecord->setMaxValue(500);
m_jackRecord->setValue(jackRecordValue);
layout->addWidget(new QLabel("500", frame), 5, 4, Qt::AlignLeft);
addTab(frame, i18n("JACK Latency"));
#endif // HAVE_LIBJACK
#endif // NOT_DEFINED
}
void LatencyConfigurationPage::apply()
{
m_cfg->setGroup(LatencyOptionsConfigGroup);
#ifdef HAVE_LIBJACK
int jackPlayback = getJACKPlaybackValue();
m_cfg->writeEntry("jackplaybacklatencysec", jackPlayback / 1000);
m_cfg->writeEntry("jackplaybacklatencyusec", jackPlayback * 1000);
int jackRecord = getJACKRecordValue();
m_cfg->writeEntry("jackrecordlatencysec", jackRecord / 1000);
m_cfg->writeEntry("jackrecordlatencyusec", jackRecord * 1000);
#endif // HAVE_LIBJACK
}
void LatencyConfigurationPage::slotFetchLatencyValues()
{
int jackPlaybackValue = m_doc->getAudioPlayLatency().msec() +
m_doc->getAudioPlayLatency().sec * 1000;
m_jackPlayback->setValue(jackPlaybackValue);
int jackRecordValue = m_doc->getAudioRecordLatency().msec() +
m_doc->getAudioRecordLatency().sec * 1000;
m_jackRecord->setValue(jackRecordValue);
}
}
#include "LatencyConfigurationPage.moc"
|