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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
|
/* -*- 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 <[email protected]>,
Chris Cannam <[email protected]>,
Richard Bown <[email protected]>
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 "MIDIConfigurationPage.h"
#include "sound/Midi.h"
#include "sound/SoundDriver.h"
#include "document/ConfigGroups.h"
#include "base/MidiProgram.h"
#include "base/Studio.h"
#include "ConfigurationPage.h"
#include "document/RosegardenGUIDoc.h"
#include "gui/dialogs/ShowSequencerStatusDialog.h"
#include "gui/seqmanager/SequenceManager.h"
#include "gui/application/RosegardenApplication.h"
#include "gui/studio/StudioControl.h"
#include "sound/MappedEvent.h"
#include "TabbedConfigurationPage.h"
#include <kcombobox.h>
#include <kconfig.h>
#include <kfiledialog.h>
#include <tqcheckbox.h>
#include <tqcombobox.h>
#include <tqcstring.h>
#include <tqdatastream.h>
#include <tqframe.h>
#include <tqlabel.h>
#include <tqlineedit.h>
#include <tqobject.h>
#include <tqpushbutton.h>
#include <tqlayout.h>
#include <tqslider.h>
#include <tqspinbox.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqtabwidget.h>
#include <tqtooltip.h>
#include <tqwidget.h>
#include <tqcheckbox.h>
#include <tqhbox.h>
namespace Rosegarden
{
MIDIConfigurationPage::MIDIConfigurationPage(
RosegardenGUIDoc *doc,
KConfig *cfg,
TQWidget *tqparent,
const char *name):
TabbedConfigurationPage(cfg, tqparent, name),
m_midiPitchOctave(0)
{
// set the document in the super class
m_doc = doc;
// ---------------- General tab ------------------
//
TQFrame *frame = new TQFrame(m_tabWidget);
TQGridLayout *tqlayout = new TQGridLayout(frame, 9, 4, 10, 5);
int row = 0;
tqlayout->setRowSpacing(row, 15);
++row;
TQLabel *label = 0;
m_cfg->setGroup(GeneralOptionsConfigGroup);
tqlayout->addMultiCellWidget(new TQLabel(i18n("Base octave number for MIDI pitch display"),
frame), row, row, 0, 1);
m_midiPitchOctave = new TQSpinBox(frame);
m_midiPitchOctave->setMaxValue(10);
m_midiPitchOctave->setMinValue( -10);
m_midiPitchOctave->setValue(m_cfg->readNumEntry("midipitchoctave", -2));
tqlayout->addMultiCellWidget(m_midiPitchOctave, row, row, 2, 3);
++row;
tqlayout->setRowSpacing(row, 20);
++row;
m_cfg->setGroup(GeneralOptionsConfigGroup);
tqlayout->addMultiCellWidget(new TQLabel(i18n("Always use default studio when loading files"),
frame), row, row, 0, 1);
m_studio = new TQCheckBox(frame);
m_studio->setChecked(m_cfg->readBoolEntry("alwaysusedefaultstudio", false));
tqlayout->addWidget(m_studio, row, 2);
++row;
// Send Controllers
//
m_cfg->setGroup(SequencerOptionsConfigGroup);
label = new TQLabel(i18n("Send all MIDI Controllers at start of each playback"), frame);
TQString controllerTip = i18n("Rosegarden can send all MIDI Controllers (Pan, Reverb etc) to all MIDI devices every\ntime you hit play if you so wish. Please note that this option will usually incur a\ndelay at the start of playback due to the amount of data being transmitted.");
TQToolTip::add
(label, controllerTip);
tqlayout->addMultiCellWidget(label, row, row, 0, 1);
m_sendControllersAtPlay = new TQCheckBox(frame);
bool sendControllers = m_cfg->readBoolEntry("alwayssendcontrollers", false);
m_sendControllersAtPlay->setChecked(sendControllers);
TQToolTip::add
(m_sendControllersAtPlay, controllerTip);
tqlayout->addWidget(m_sendControllersAtPlay, row, 2);
++row;
// Timer selection
//
m_cfg->setGroup(SequencerOptionsConfigGroup);
label = new TQLabel(i18n("Sequencer timing source"), frame);
tqlayout->addMultiCellWidget(label, row, row, 0, 1);
m_timer = new KComboBox(frame);
tqlayout->addMultiCellWidget(m_timer, row, row, 2, 3);
TQStringList timers = m_doc->getTimers();
m_origTimer = m_doc->getCurrentTimer();
TQString currentTimer = m_cfg->readEntry("timer", m_origTimer);
for (unsigned int i = 0; i < timers.size(); ++i) {
m_timer->insertItem(timers[i]);
if (timers[i] == currentTimer)
m_timer->setCurrentItem(i);
}
++row;
tqlayout->setRowSpacing(row, 20);
++row;
m_cfg->setGroup(SequencerOptionsConfigGroup);
// SoundFont loading
//
TQLabel* lbl = new TQLabel(i18n("Load SoundFont to SoundBlaster card at startup"), frame);
TQString tooltip = i18n("Check this box to enable soundfont loading on EMU10K-based cards when Rosegarden is launched");
TQToolTip::add(lbl, tooltip);
tqlayout->addMultiCellWidget(lbl, row, row, 0, 1);
m_sfxLoadEnabled = new TQCheckBox(frame);
tqlayout->addWidget(m_sfxLoadEnabled, row, 2);
TQToolTip::add(m_sfxLoadEnabled, tooltip);
++row;
tqlayout->addWidget(new TQLabel(i18n("Path to 'asfxload' or 'sfxload' command"), frame), row, 0);
m_sfxLoadPath = new TQLineEdit(m_cfg->readEntry("sfxloadpath", "/bin/sfxload"), frame);
tqlayout->addMultiCellWidget(m_sfxLoadPath, row, row, 1, 2);
m_sfxLoadChoose = new TQPushButton("Choose...", frame);
tqlayout->addWidget(m_sfxLoadChoose, row, 3);
++row;
tqlayout->addWidget(new TQLabel(i18n("SoundFont"), frame), row, 0);
m_soundFontPath = new TQLineEdit(m_cfg->readEntry("soundfontpath", ""), frame);
tqlayout->addMultiCellWidget(m_soundFontPath, row, row, 1, 2);
m_soundFontChoose = new TQPushButton("Choose...", frame);
tqlayout->addWidget(m_soundFontChoose, row, 3);
++row;
bool sfxLoadEnabled = m_cfg->readBoolEntry("sfxloadenabled", false);
m_sfxLoadEnabled->setChecked(sfxLoadEnabled);
if (!sfxLoadEnabled) {
m_sfxLoadPath->setEnabled(false);
m_sfxLoadChoose->setEnabled(false);
m_soundFontPath->setEnabled(false);
m_soundFontChoose->setEnabled(false);
}
connect(m_sfxLoadEnabled, TQT_SIGNAL(toggled(bool)),
this, TQT_SLOT(slotSoundFontToggled(bool)));
connect(m_sfxLoadChoose, TQT_SIGNAL(clicked()),
this, TQT_SLOT(slotSfxLoadPathChoose()));
connect(m_soundFontChoose, TQT_SIGNAL(clicked()),
this, TQT_SLOT(slotSoundFontChoose()));
tqlayout->setRowStretch(row, 10);
addTab(frame, i18n("General"));
m_cfg->setGroup(SequencerOptionsConfigGroup);
// -------------- Synchronisation tab -----------------
//
frame = new TQFrame(m_tabWidget);
tqlayout = new TQGridLayout(frame, 7, 2, 10, 5);
row = 0;
tqlayout->setRowSpacing(row, 15);
++row;
// MIDI Clock and System Realtime Messages
//
label = new TQLabel(i18n("MIDI Clock and System messages"), frame);
tqlayout->addWidget(label, row, 0);
m_midiSync = new KComboBox(frame);
tqlayout->addWidget(m_midiSync, row, 1);
m_midiSync->insertItem(i18n("Off"));
m_midiSync->insertItem(i18n("Send MIDI Clock, Start and Stop"));
m_midiSync->insertItem(i18n("Accept Start, Stop and Continue"));
int midiClock = m_cfg->readNumEntry("midiclock", 0);
if (midiClock < 0 || midiClock > 2)
midiClock = 0;
m_midiSync->setCurrentItem(midiClock);
++row;
// MMC Transport
//
label = new TQLabel(i18n("MIDI Machine Control mode"), frame);
tqlayout->addWidget(label, row, 0);
m_mmcTransport = new KComboBox(frame);
tqlayout->addWidget(m_mmcTransport, row, 1); //, TQt::AlignHCenter);
m_mmcTransport->insertItem(i18n("Off"));
m_mmcTransport->insertItem(i18n("MMC Master"));
m_mmcTransport->insertItem(i18n("MMC Slave"));
int mmcMode = m_cfg->readNumEntry("mmcmode", 0);
if (mmcMode < 0 || mmcMode > 2)
mmcMode = 0;
m_mmcTransport->setCurrentItem(mmcMode);
++row;
// MTC transport
//
label = new TQLabel(i18n("MIDI Time Code mode"), frame);
tqlayout->addWidget(label, row, 0);
m_mtcTransport = new KComboBox(frame);
tqlayout->addWidget(m_mtcTransport, row, 1);
m_mtcTransport->insertItem(i18n("Off"));
m_mtcTransport->insertItem(i18n("MTC Master"));
m_mtcTransport->insertItem(i18n("MTC Slave"));
int mtcMode = m_cfg->readNumEntry("mtcmode", 0);
if (mtcMode < 0 || mtcMode > 2)
mtcMode = 0;
m_mtcTransport->setCurrentItem(mtcMode);
++row;
TQHBox *hbox = new TQHBox(frame);
hbox->setSpacing(5);
tqlayout->addMultiCellWidget(hbox, row, row, 0, 1);
label = new TQLabel(i18n("Automatically connect sync output to all devices in use"), hbox);
// tqlayout->addWidget(label, row, 0);
m_midiSyncAuto = new TQCheckBox(hbox);
// tqlayout->addWidget(m_midiSyncAuto, row, 1);
m_midiSyncAuto->setChecked(m_cfg->readBoolEntry("midisyncautoconnect", false));
++row;
tqlayout->setRowStretch(row, 10);
addTab(frame, i18n("MIDI Sync"));
}
void
MIDIConfigurationPage::slotSoundFontToggled(bool isChecked)
{
m_sfxLoadPath->setEnabled(isChecked);
m_sfxLoadChoose->setEnabled(isChecked);
m_soundFontPath->setEnabled(isChecked);
m_soundFontChoose->setEnabled(isChecked);
}
void
MIDIConfigurationPage::slotSfxLoadPathChoose()
{
TQString path = KFileDialog::getOpenFileName(":SFXLOAD", TQString(), this, i18n("sfxload path"));
m_sfxLoadPath->setText(path);
}
void
MIDIConfigurationPage::slotSoundFontChoose()
{
TQString path = KFileDialog::getOpenFileName(":SOUNDFONTS", "*.sb *.sf2 *.SF2 *.SB", this, i18n("Soundfont path"));
m_soundFontPath->setText(path);
}
void
MIDIConfigurationPage::apply()
{
m_cfg->setGroup(SequencerOptionsConfigGroup);
m_cfg->writeEntry("alwayssendcontrollers",
m_sendControllersAtPlay->isChecked());
m_cfg->writeEntry("sfxloadenabled", m_sfxLoadEnabled->isChecked());
m_cfg->writeEntry("sfxloadpath", m_sfxLoadPath->text());
m_cfg->writeEntry("soundfontpath", m_soundFontPath->text());
m_cfg->writeEntry("timer", m_timer->currentText());
if (m_timer->currentText() != m_origTimer) {
m_doc->setCurrentTimer(m_timer->currentText());
}
// Write the entries
//
m_cfg->writeEntry("mmcmode", m_mmcTransport->currentItem());
m_cfg->writeEntry("mtcmode", m_mtcTransport->currentItem());
m_cfg->writeEntry("midisyncautoconnect", m_midiSyncAuto->isChecked());
// Now send
//
MappedEvent mEmccValue(MidiInstrumentBase, // InstrumentId
MappedEvent::SystemMMCTransport,
MidiByte(m_mmcTransport->currentItem()));
StudioControl::sendMappedEvent(mEmccValue);
MappedEvent mEmtcValue(MidiInstrumentBase, // InstrumentId
MappedEvent::SystemMTCTransport,
MidiByte(m_mtcTransport->currentItem()));
StudioControl::sendMappedEvent(mEmtcValue);
MappedEvent mEmsaValue(MidiInstrumentBase, // InstrumentId
MappedEvent::SystemMIDISyncAuto,
MidiByte(m_midiSyncAuto->isChecked() ? 1 : 0));
StudioControl::sendMappedEvent(mEmsaValue);
// ------------- MIDI Clock and System messages ------------
//
int midiClock = m_midiSync->currentItem();
m_cfg->writeEntry("midiclock", midiClock);
// Now send it (OLD TQT_METHOD - to be removed)
//!!! No, don't remove -- this controls SPP as well doesn't it?
//
MappedEvent mEMIDIClock(MidiInstrumentBase, // InstrumentId
MappedEvent::SystemMIDIClock,
MidiByte(midiClock));
StudioControl::sendMappedEvent(mEMIDIClock);
// Now update the metronome mapped segment with new clock ticks
// if needed.
//
Studio &studio = m_doc->getStudio();
const MidiMetronome *metronome = studio.
getMetronomeFromDevice(studio.getMetronomeDevice());
if (metronome) {
InstrumentId instrument = metronome->getInstrument();
m_doc->getSequenceManager()->metronomeChanged(instrument, true);
}
m_cfg->setGroup(GeneralOptionsConfigGroup);
bool deftstudio = getUseDefaultStudio();
m_cfg->writeEntry("alwaysusedefaultstudio", deftstudio);
int octave = m_midiPitchOctave->value();
m_cfg->writeEntry("midipitchoctave", octave);
}
}
#include "MIDIConfigurationPage.moc"
|