1
//=========================================================
4
// $Id: iiwugui.cpp,v 1.2 2002/02/01 17:55:39 bob Exp $
6
// This is a simple GUI implemented with QT for
7
// iiwu 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 iiwu 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
: IIWUGuiBase(0, "iiwugui", 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 IIWUGui::readStdin(int fd)
60
int n = ::read(fd, buffer, 128);
61
printf("IIWU GUI: read %d Bytes from STDIN\n", n);
64
//---------------------------------------------------------
66
// sysex f0 7c 00 01 name f7
67
//---------------------------------------------------------
69
void IIWUGui::loadFont()
71
if (!pathEntry->text().isEmpty()) {
72
QFileInfo fi(pathEntry->text());
74
QString s = "SoundFont " + pathEntry->text() + " does not exists";
75
QMessageBox::critical(this, "IIWU: open Soundfile", s);
80
fputc(0x7c, stdout); // MusE soft synthesizer
81
fputc(0x00, stdout); // iiwu
82
fputc(0x01, stdout); // load sound font
83
const char* path = pathEntry->text().latin1();
90
//---------------------------------------------------------
91
// soundFontFileDialog
92
//---------------------------------------------------------
94
void IIWUGui::soundFontFileDialog()
96
QString s = QFileDialog::getOpenFileName(QString::null, "*.[Ss][Ff]2", this);
98
pathEntry->setText(s);
102
//---------------------------------------------------------
104
//---------------------------------------------------------
106
void IIWUGui::closeEvent(QCloseEvent* ce)
112
//---------------------------------------------------------
114
//---------------------------------------------------------
116
int main(int argc, char* argv[])
118
QApplication app(argc, argv, true);
119
QWidget* w = new IIWUGui;
121
w->setCaption(argv[1]);
123
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));