1
1
// synthv1widget_jack.cpp
3
3
/****************************************************************************
4
Copyright (C) 2012, rncbc aka Rui Nuno Capela. All rights reserved.
4
Copyright (C) 2012-2013, rncbc aka Rui Nuno Capela. All rights reserved.
6
6
This program is free software; you can redistribute it and/or
7
7
modify it under the terms of the GNU General Public License
58
62
synthv1widget_jack::synthv1widget_jack ( synthv1_jack *pSynth )
59
63
: synthv1widget(), m_pSynth(pSynth)
65
, m_pNsmClient(NULL), m_bNsmDirty(false)
69
// Check whether to participate into a NSM session...
70
const QString& nsm_url
71
= QString::fromLatin1(::getenv("NSM_URL"));
72
if (!nsm_url.isEmpty()) {
73
m_pNsmClient = new synthv1_nsm(nsm_url);
74
QObject::connect(m_pNsmClient,
77
QObject::connect(m_pNsmClient,
80
QObject::connect(m_pNsmClient,
83
QObject::connect(m_pNsmClient,
86
m_pNsmClient->announce(SYNTHV1_TITLE, ":switch:dirty:optional-gui:");
91
m_pSynth->open(SYNTHV1_TITLE);
61
93
#ifdef CONFIG_JACK_SESSION
62
94
// JACK session event callback...
63
95
if (::jack_set_session_callback) {
132
165
#endif // CONFIG_JACK_SESSION
170
void synthv1widget_jack::openSession (void)
172
if (m_pNsmClient == NULL)
175
if (!m_pNsmClient->is_active())
179
qDebug("synthv1widget_jack::openSession()");
182
m_pSynth->deactivate();
185
const QString& path_name = m_pNsmClient->path_name();
186
const QString& display_name = m_pNsmClient->display_name();
187
const QString& client_id = m_pNsmClient->client_id();
189
const QDir dir(path_name);
191
dir.mkpath(path_name);
193
const QFileInfo fi(path_name, display_name + '.' + SYNTHV1_TITLE);
195
loadPreset(fi.absoluteFilePath());
197
m_pSynth->open(client_id.toUtf8().constData());
198
m_pSynth->activate();
202
m_pNsmClient->open_reply();
203
m_pNsmClient->dirty(false);
205
m_pNsmClient->visible(QWidget::isVisible());
208
void synthv1widget_jack::saveSession (void)
210
if (m_pNsmClient == NULL)
213
if (!m_pNsmClient->is_active())
217
qDebug("synthv1widget_jack::saveSession()");
221
const QString& path_name = m_pNsmClient->path_name();
222
const QString& display_name = m_pNsmClient->display_name();
223
// const QString& client_id = m_pNsmClient->client_id();
224
const QFileInfo fi(path_name, display_name + '.' + SYNTHV1_TITLE);
225
savePreset(fi.absoluteFilePath());
229
m_pNsmClient->save_reply();
230
m_pNsmClient->dirty(false);
234
void synthv1widget_jack::showSession (void)
236
if (m_pNsmClient == NULL)
239
if (!m_pNsmClient->is_active())
243
qDebug("synthv1widget_jack::showSession()");
248
QWidget::activateWindow();
251
void synthv1widget_jack::hideSession (void)
253
if (m_pNsmClient == NULL)
256
if (!m_pNsmClient->is_active())
260
qDebug("synthv1widget_jack::hideSession()");
270
// Param port method.
136
271
void synthv1widget_jack::updateParam (
137
272
synthv1::ParamIndex index, float fValue ) const
280
// Dirty flag method.
281
void synthv1widget_jack::updateDirtyPreset ( bool bDirtyPreset )
283
synthv1widget::updateDirtyPreset(bDirtyPreset);
286
if (m_pNsmClient && m_pNsmClient->is_active()) {
287
if (!m_bNsmDirty/* && bDirtyPreset*/) {
288
m_pNsmClient->dirty(true);
145
296
// Application close.
146
297
void synthv1widget_jack::closeEvent ( QCloseEvent *pCloseEvent )
300
if (m_pNsmClient && m_pNsmClient->is_active())
301
synthv1widget::updateDirtyPreset(false);
148
304
// Let's be sure about that...
149
305
if (queryClose()) {
150
306
pCloseEvent->accept();
316
// Optional GUI handlers.
317
void synthv1widget_jack::showEvent ( QShowEvent *pShowEvent )
319
QWidget::showEvent(pShowEvent);
322
m_pNsmClient->visible(true);
325
void synthv1widget_jack::hideEvent ( QHideEvent *pHideEvent )
328
m_pNsmClient->visible(false);
330
QWidget::hideEvent(pHideEvent);
158
336
//-------------------------------------------------------------------------