1
//=========================================================
4
// $Id: fluidgui.cpp,v 1.1.1.1 2003/10/29 10:06:05 wschweer Exp $
6
// This is a simple GUI implemented with QT for
7
// fluid software synthesizer.
9
// (C) Copyright 2001 Werner Schweer (ws@seh.de)
10
//=========================================================
15
#include <qapplication.h>
19
#include <qlineedit.h>
20
#include <qtoolbutton.h>
21
#include <qpushbutton.h>
22
#include <qfiledialog.h>
23
#include <qmessagebox.h>
24
#include <qsocketnotifier.h>
27
The interface to the software synthesizer is implemented
28
as a pipe connected from stdout of this gui process to
29
MusE. MusE redirects the received input to the fluid software
30
synthesizer midi device.
32
In short communication to the synt takes place as
33
midi commands written to stdout.
35
All special handling of the synth is done via
39
//---------------------------------------------------------
41
//---------------------------------------------------------
44
: FLUIDGuiBase(0, "fluidgui", WType_TopLevel | WDestructiveClose)
46
QSocketNotifier* s = new QSocketNotifier(0, QSocketNotifier::Read);
47
connect(s, SIGNAL(activated(int)), SLOT(readStdin(int)));
49
connect(fdialogButton, SIGNAL(clicked()), SLOT(soundFontFileDialog()));
50
connect(loadButton, SIGNAL(clicked()), SLOT(loadFont()));
53
//---------------------------------------------------------
55
//---------------------------------------------------------
57
void FLUIDGui::readStdin(int fd)
60
int n = ::read(fd, buffer, 128);
61
printf("FLUID GUI: read %d Bytes from STDIN\n", n);
64
//---------------------------------------------------------
66
// sysex f0 7c 00 01 name f7
67
//---------------------------------------------------------
69
void FLUIDGui::loadFont()
71
if (!pathEntry->text().isEmpty()) {
72
QFileInfo fi(pathEntry->text());
74
QString s = QString("SoundFont ") + pathEntry->text() + QString(" does not exists");
75
QMessageBox::critical(this, tr("FLUID: open Soundfile"), s);
80
fputc(0x7c, stdout); // MusE soft synthesizer
81
fputc(0x00, stdout); // fluid
82
fputc(0x01, stdout); // load sound font
83
const char* path = pathEntry->text().latin1();
90
//---------------------------------------------------------
91
// soundFontFileDialog
92
//---------------------------------------------------------
94
void FLUIDGui::soundFontFileDialog()
96
QString s = QFileDialog::getOpenFileName(QString::null, QString("*.[Ss][Ff]2"), this);
98
pathEntry->setText(s);
102
//---------------------------------------------------------
104
//---------------------------------------------------------
106
void FLUIDGui::closeEvent(QCloseEvent* ce)
112
//---------------------------------------------------------
114
//---------------------------------------------------------
116
int main(int argc, char* argv[])
118
QApplication app(argc, argv, true);
119
QWidget* w = new FLUIDGui;
121
w->setCaption(QString(argv[1]));
123
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));