1
//=========================================================
4
// $Id: synthconfig.cpp,v 1.3 2002/02/08 09:56:29 muse Exp $
6
// (C) Copyright 2001 Werner Schweer (ws@seh.de)
7
//=========================================================
10
#include <qlistview.h>
11
#include <qpushbutton.h>
12
#include "synthconfig.h"
16
#include "driver/mididev.h"
19
#include "midithread.h"
20
#include "audiothread.h"
22
//---------------------------------------------------------
23
// configSoftSynthesizer
24
//---------------------------------------------------------
26
void MusE::configSoftSynthesizer()
28
if (!softSynthesizerConfig)
29
softSynthesizerConfig = new SynthesizerConfig();
30
softSynthesizerConfig->show();
33
//---------------------------------------------------------
35
//---------------------------------------------------------
37
SynthesizerConfig::SynthesizerConfig()
38
: SynthConfigBase(0, "synthiTable")
42
connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
43
connect(addInstance, SIGNAL(clicked()), SLOT(addInstanceClicked()));
44
connect(removeInstance, SIGNAL(clicked()), SLOT(removeInstanceClicked()));
47
//---------------------------------------------------------
49
//---------------------------------------------------------
51
void SynthesizerConfig::songChanged(int)
54
for (int i = 0; i < nsynthis; ++i) {
55
if (synthis[i] == 0) //DEBUG
57
QString s = synthis[i]->baseName();
58
QListViewItem* item = new QListViewItem(synthList);
60
s.setNum(synthis[i]->instances());
62
item->setText(2, synthis[i]->label());
64
instanceList->clear();
65
for (iSynthI si = synthiInstances.begin(); si != synthiInstances.end(); ++si) {
66
QListViewItem* iitem = new QListViewItem(instanceList);
67
iitem->setText(0, (*si)->iname());
70
(*si)->mess()->alsaClient(),
71
(*si)->mess()->alsaPort());
72
iitem->setText(1, port);
76
//---------------------------------------------------------
78
//---------------------------------------------------------
80
void SynthesizerConfig::addInstanceClicked()
82
QListViewItem* item = synthList->selectedItem();
85
SynthI* si = song->createSynthI(item->text(2));
86
audioThread->msgAddSynthI(si);
87
midiThread->msgAddSynthI(si);
89
QString name(si->iname());
90
QListViewItem* iitem = new QListViewItem(instanceList);
91
iitem->setText(0, name);
93
port.sprintf("%d:%d", si->mess()->alsaClient(), si->mess()->alsaPort());
95
iitem->setText(1, port);
97
song->updateAudioMixer();
100
inst.setNum(si->synth()->instances());
101
item->setText(1, inst);
104
//---------------------------------------------------------
105
// removeInstanceClicked
106
//---------------------------------------------------------
108
void SynthesizerConfig::removeInstanceClicked()
110
QListViewItem* item = instanceList->selectedItem();
114
for (ii = synthiInstances.begin(); ii != synthiInstances.end(); ++ii) {
115
if ((*ii)->iname() == item->text(0))
118
if (ii == synthiInstances.end()) {
119
printf("synthesizerConfig::removeInstanceClicked(): synthi not found\n");
123
for (port = 0; port < MIDI_PORTS; ++port) {
124
if (midiPorts[port].instrument() == *ii)
127
if (port != MIDI_PORTS) {
128
// synthi is attached
129
midiThread->setMidiDevice(&midiPorts[port], 0);
130
midiPorts[port].setInstrument(genericMidiInstrument);
132
for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i) {
134
if (d->name() == (*ii)->iname()) {
135
printf("midi device %s found\n", d->name().latin1());
140
audioThread->msgRemoveSynthI(*ii);
141
song->updateAudioMixer();