summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNil Geisweiller <a-lin@sourceforge.net>2007-01-23 19:26:57 +0000
committerNil Geisweiller <a-lin@sourceforge.net>2007-01-23 19:26:57 +0000
commita02fdf3b6a0040b729887aaeabb0dcac8549b4b5 (patch)
treedc258172af94f16005967eac05c5ef316126f7b7
parent19b563b5974f6bbd0c35caf36436c9de1d05b815 (diff)
see ChangeLog
-rw-r--r--muse/ChangeLog3
-rw-r--r--muse/muse/liste/CMakeLists.txt2
-rw-r--r--muse/muse/liste/ieventdialog.cpp362
-rw-r--r--muse/muse/liste/ieventdialog.h101
-rw-r--r--muse/muse/liste/partlistedit.cpp27
-rw-r--r--muse/muse/liste/partlistedit.h2
-rw-r--r--muse/plugins/pandelay/pandelaymodel.h1
-rw-r--r--muse/synti/deicsonze/deicsonze.cpp93
-rw-r--r--muse/synti/deicsonze/deicsonzegui.cpp2
9 files changed, 533 insertions, 60 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index 5b0e7fde..10b5b86c 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,6 @@
+23.01 (ng)
+ - added insert sysex event update I
+ - replaced bzip2 by Qt compression in deicsonze
19.01 (ng)
- fixed bug to prevent muse from halting when trying to load a non-ladpsa plugin (by Willy Foobar)
06.01 (ng)
diff --git a/muse/muse/liste/CMakeLists.txt b/muse/muse/liste/CMakeLists.txt
index 433713b8..3727383a 100644
--- a/muse/muse/liste/CMakeLists.txt
+++ b/muse/muse/liste/CMakeLists.txt
@@ -23,6 +23,7 @@ QT4_WRAP_CPP ( liste_mocs
ctrllistedit.h
tracklistedit.h
partlistedit.h
+ ieventdialog.h
)
QT4_WRAP_UI ( liste_ui_headers
@@ -36,6 +37,7 @@ add_library ( liste STATIC
ctrllistedit.cpp ctrllistedit.h
partlistedit.cpp partlistedit.h
tracklistedit.cpp tracklistedit.h
+ ieventdialog.cpp ieventdialog.h
${liste_mocs}
${liste_ui_headers}
)
diff --git a/muse/muse/liste/ieventdialog.cpp b/muse/muse/liste/ieventdialog.cpp
new file mode 100644
index 00000000..09256b20
--- /dev/null
+++ b/muse/muse/liste/ieventdialog.cpp
@@ -0,0 +1,362 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id:$
+//
+// Copyright (C) 2007 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#include <QColor>
+#include <QDialogButtonBox>
+#include "ieventdialog.h"
+
+InsertEventDialog::InsertEventDialog(const Pos& time,
+ QWidget* parent, Qt::WindowFlags f)
+ : QDialog(parent, f) {
+ setWindowTitle("Insert Event Dialog");
+
+ _selectedType = -1;
+
+
+ _lastDir = QDir::currentPath();
+
+ _mainLayout = new QGridLayout(parent);
+ //event type
+ QLabel* eventTypeLabel = new QLabel("Event Type", parent);
+ _mainLayout->addWidget(eventTypeLabel, 0, 0);
+ _eventTypeComboBox = new QComboBox(parent);
+ for(unsigned i = 0; i < IED_TypeCount; i++) {
+ _typeWidget.push_back(new QWidget(parent));
+ QGridLayout* tLayout = new QGridLayout(_typeWidget[i]);
+ if(i == IED_Note) {
+ _eventTypeComboBox->addItem(NoteSTR);
+ //TODO
+ QLabel* noteEventTODO =
+ new QLabel("TODO : Note event", _typeWidget[i]);
+ tLayout->addWidget(noteEventTODO, 0, 0, 1, 2);
+ }
+ else if(i == IED_ProgramChange) {
+ _eventTypeComboBox->addItem(ProgramChangeSTR);
+ //TODO
+ QLabel* programChangeEventTODO =
+ new QLabel("TODO : Program change event", _typeWidget[i]);
+ tLayout->addWidget(programChangeEventTODO, 0, 0, 1, 2);
+ }
+ else if(i == IED_ControlChange) {
+ _eventTypeComboBox->addItem(ControlChangeSTR);
+ //TODO
+ QLabel* controlChangeEventTODO =
+ new QLabel("TODO : Control change event", _typeWidget[i]);
+ tLayout->addWidget(controlChangeEventTODO, 0, 0, 1, 2);
+ }
+ else if(i == IED_Sysex) {
+ _eventTypeComboBox->addItem(SysexSTR);
+ //number of sysex
+ QLabel* numOfSysexLabel = new QLabel("Number of Sysex", _typeWidget[i]);
+ tLayout->addWidget(numOfSysexLabel, 0, 0);
+ _sysexCountSpinBox = new QSpinBox(_typeWidget[i]);
+ _sysexCountSpinBox->setMaximum(1024);
+ _sysexCountSpinBox->setMinimum(1);
+ _sysexCountSpinBox->setValue(1);
+ tLayout->addWidget(_sysexCountSpinBox, 0, 1);
+ //current sysex
+ QLabel* curSysexLabel = new QLabel("Current Sysex", _typeWidget[i]);
+ tLayout->addWidget(curSysexLabel, 1, 0);
+ _curSysexSpinBox = new QSpinBox(_typeWidget[i]);
+ _curSysexSpinBox->setMaximum(0);
+ _curSysexSpinBox->setMinimum(0);
+ _curSysexSpinBox->setValue(0);
+ tLayout->addWidget(_curSysexSpinBox, 1, 1);
+ //select from the instrument
+ QPushButton* selectButton = new QPushButton("Select from instrument",
+ _typeWidget[i]);
+ tLayout->addWidget(selectButton, 2, 0, 1, 2);
+ //load
+ _loadButton = new QPushButton("Load...", _typeWidget[i]);
+ tLayout->addWidget(_loadButton, 3, 0);
+ //save
+ _saveButton = new QPushButton("Save...", _typeWidget[i]);
+ tLayout->addWidget(_saveButton, 3, 1);
+ //length
+ QLabel* lengthLabel = new QLabel("Length", _typeWidget[i]);
+ tLayout->addWidget(lengthLabel, 4, 0);
+ _lengthIntLabel = new QLabel("0", _typeWidget[i]);
+ tLayout->addWidget(_lengthIntLabel, 4, 1);
+ //text edit
+ _sysexTextEdit = new QTextEdit(_typeWidget[i]);
+ _sysexCursorPos = 0;
+ QByteArray ba;
+ _dataSysex.push_back(QByteArray(ba));
+ _lengthIntLabel->setText(QString::number(sysexLength()));
+ _dataSysexStr.push_back(QString("F0 F7"));
+ tLayout->addWidget(_sysexTextEdit, 5, 0, 3, 2);
+ setSysexTextEdit();
+ QString HEX = "(?!F7)([A-F]|\\d){1,2}";
+ QString SRE = QString("^F0(\\s+)(") + HEX + QString("(\\s+))*F7$");
+ _hexRegExp = new QRegExp(SRE, Qt::CaseInsensitive);
+ }
+ tLayout->setMargin(0);
+ _typeWidget[i]->setLayout(tLayout);
+ _mainLayout->addWidget(_typeWidget[i], 2, 0, 1, 2);
+ }
+ _mainLayout->addWidget(_eventTypeComboBox, 0, 1);
+ //time
+ QLabel* timeLabel = new QLabel("Time", parent);
+ _mainLayout->addWidget(timeLabel, 1, 0);
+ _timePosEdit = new PosEdit(parent);
+ _timePosEdit->setValue(time);
+ _mainLayout->addWidget(_timePosEdit, 1, 1);
+ //Ok, cancel
+ QDialogButtonBox* OkCancelBox =
+ new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
+ Qt::Horizontal, parent);
+ _mainLayout->addWidget(OkCancelBox, 3, 0, 1, 2);
+
+ updateType(_eventTypeComboBox->currentIndex());
+
+ setLayout(_mainLayout);
+
+ //connection
+ connect(_sysexTextEdit, SIGNAL(textChanged()), this,
+ SLOT(updateSysexTextEdit()));
+ connect(_sysexTextEdit, SIGNAL(cursorPositionChanged()), this,
+ SLOT(updateSysexCursor()));
+ connect(_eventTypeComboBox, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(updateType(int)));
+ connect(_sysexCountSpinBox, SIGNAL(valueChanged(int)), this,
+ SLOT(updateSysexCount(int)));
+ connect(_curSysexSpinBox, SIGNAL(valueChanged(int)), this,
+ SLOT(updateCurSysexSpinBox(int)));
+ connect(_loadButton, SIGNAL(clicked()), this, SLOT(updateSysexLoad()));
+ connect(_saveButton, SIGNAL(clicked()), this, SLOT(updateSysexSave()));
+ connect(OkCancelBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(OkCancelBox, SIGNAL(rejected()), this, SLOT(reject()));
+}
+
+InsertEventDialog::~InsertEventDialog() {
+}
+
+EventList* InsertEventDialog::elResult() {
+ int curType = _eventTypeComboBox->currentIndex();
+ if(curType == IED_Note) {
+ //TODO
+ return NULL;
+ }
+ else if(curType == IED_ProgramChange) {
+ //TODO
+ return NULL;
+ }
+ else if(curType == IED_ControlChange) {
+ //TODO
+ return NULL;
+ }
+ else if(curType == IED_Sysex) {
+ EventList* res = new EventList;
+ for(unsigned i = 0; (int)i < _sysexCountSpinBox->value(); i++) {
+ Event evSysex(Sysex);
+ evSysex.setPos(_timePosEdit->pos());
+ evSysex.setData((const unsigned char*) _dataSysex[i].data(),
+ _dataSysex[i].size());
+ res->add(evSysex);
+ }
+ return res;
+ }
+ else return NULL;
+}
+
+int InsertEventDialog::sysexLength() {
+ return _dataSysex[_curSysexSpinBox->value()].size();
+}
+QString InsertEventDialog::ByteArray2Str(const QByteArray& ba) {
+ QString res = "F0 ";
+ for(int i = 0; i < ba.size(); i++) {
+ res += QString::number((unsigned char)ba.at(i), 16);
+ res += " ";
+ }
+ res += "F7";
+ return res.toUpper();
+}
+QByteArray InsertEventDialog::Str2ByteArray(const QString& s) {
+ QByteArray ba;
+ QString simpli = s.simplified();
+ QStringList sl = simpli.split(" ");
+ bool ok;
+ for(int i = 1; i < sl.size() - 1; i++) {//i=1 and until size-1 to skip F0, F7
+ ba.push_back(sl[i].toInt(&ok, 16));
+ }
+ return ba;
+}
+void InsertEventDialog::setSysexTextEdit() {
+ QString s = _dataSysexStr[_curSysexSpinBox->value()].toUpper();
+ _sysexTextEdit->blockSignals(true);
+ //print in gray F0
+ _sysexTextEdit->setTextColor(Qt::darkGray);
+ _sysexTextEdit->setPlainText(s.left(2));
+ //move cursor at the end
+ QTextCursor tc1(_sysexTextEdit->document());
+ tc1.movePosition(QTextCursor::End);
+ _sysexTextEdit->setTextCursor(tc1);
+ //print in black the core
+ _sysexTextEdit->setTextColor(Qt::black);
+ _sysexTextEdit->insertPlainText(s.mid(2, s.size()-4));
+ //move cursor at the end
+ QTextCursor tc2(_sysexTextEdit->document());
+ tc2.movePosition(QTextCursor::End);
+ _sysexTextEdit->setTextCursor(tc2);
+ //print in gray F7
+ _sysexTextEdit->setTextColor(Qt::darkGray);
+ _sysexTextEdit->insertPlainText(s.right(2));
+ //relocate cursor
+ QTextCursor tc(_sysexTextEdit->document());
+ tc.setPosition(_sysexCursorPos);
+ _sysexTextEdit->setTextCursor(tc);
+ //update length label
+ _lengthIntLabel->setText(QString::number(sysexLength()));
+
+ _sysexTextEdit->blockSignals(false);
+}
+
+//SLOTS
+void InsertEventDialog::updateSysexTextEdit() {
+ int cur = _curSysexSpinBox->value();
+ int curCursor = _sysexTextEdit->textCursor().position();
+ QString data = _sysexTextEdit->toPlainText();
+ bool correctInput = _hexRegExp->exactMatch(data);
+
+ if(correctInput) {
+ _dataSysexStr[cur] = data;
+ _sysexCursorPos = curCursor;
+ }
+
+ //display text, relocate cursor and update length
+ setSysexTextEdit();
+ //update _dataSysex
+ _dataSysex[cur] = Str2ByteArray(_dataSysexStr[cur]);
+}
+void InsertEventDialog::updateSysexCursor() {
+ if(_dataSysexStr[_curSysexSpinBox->value()]
+ == _sysexTextEdit->toPlainText()) //only if the text hasn't changed
+ _sysexCursorPos = _sysexTextEdit->textCursor().position();
+}
+void InsertEventDialog::updateSysexCount(int c) {
+ while((int)_dataSysexStr.size() < c) {
+ _dataSysexStr.push_back(QString("F0 F7"));
+ QByteArray ba;
+ _dataSysex.push_back(ba);
+ }
+ if(c <= _curSysexSpinBox->value()) _curSysexSpinBox->setValue(c-1);
+ _curSysexSpinBox->setMaximum(c-1);
+}
+void InsertEventDialog::updateCurSysexSpinBox(int /*c*/) {
+ setSysexTextEdit();
+}
+void InsertEventDialog::updateSysexLoad() {
+ QByteArray ba;
+ QString fileName =
+ QFileDialog::getOpenFileName(this,
+ tr("Load Sysex dialog"),
+ _lastDir,
+ QString("*.syx;; *"));
+ if(!fileName.isEmpty()) {
+ QFileInfo fi(fileName);
+ _lastDir = fi.path();
+
+ QFile f(fileName);
+ if(f.open(QIODevice::ReadOnly)) {
+ ba = f.readAll();
+ bool sysexStart = false;
+ int sysexCount = 0;
+ for(int i = 0; i < ba.size(); i++) {
+ if((unsigned char)ba.at(i) == 0xF0) {
+ sysexStart = true;
+ sysexCount++;
+ while((int)_dataSysex.size() < sysexCount) {
+ QByteArray tempba;
+ _dataSysex.push_back(tempba);
+ _dataSysexStr.push_back(QString(""));
+ }
+ _dataSysex[sysexCount-1].clear();
+ }
+ else if((unsigned char)ba.at(i) == 0xF7) {
+ QByteArray endba(_dataSysex[sysexCount-1]);
+ sysexStart = false;
+ _dataSysexStr[sysexCount-1] = ByteArray2Str(endba);
+ }
+ else if(sysexStart) _dataSysex[sysexCount-1].push_back(ba.at(i));
+ }
+ _sysexCountSpinBox->setValue(sysexCount);
+ _curSysexSpinBox->setValue(0);
+ updateCurSysexSpinBox(0);
+ //Message dialog
+ if(sysexCount > 0) {
+ QMessageBox::information(this, tr("Sysex loaded"),
+ tr("MusE has successfully detected"
+ " and loaded ") +
+ QString::number(sysexCount) +
+ tr(" sysex messages."));
+ }
+ else {
+ QMessageBox::information(this, tr("No sysex"),
+ tr("No sysex in this file"));
+ }
+ }
+ else {
+ QMessageBox::critical(0,
+ tr("Critical Error"),
+ tr("Cannot open file %1").arg(fileName));
+ }
+ }
+}
+void InsertEventDialog::updateSysexSave() {
+ QString filename =
+ QFileDialog::getSaveFileName(
+ this,
+ tr("Save Sysex Dialog"),
+ _lastDir,
+ QString("*"));
+ if(!filename.isEmpty()) {
+ QFileInfo fi(filename);
+ _lastDir = fi.path();
+ QFile f(filename);
+ if(f.open(QIODevice::WriteOnly)) {
+ for(unsigned i = 0; i < _dataSysex.size(); i++) {
+ qint64 wok;
+ wok = f.write(QByteArray(1, 0xF0));
+ wok = f.write(_dataSysex[i]);
+ wok = f.write(QByteArray(1, 0xF7));
+ if(wok == -1) {
+ QMessageBox::critical(0,
+ tr("Critical Error"),
+ tr("Cannot write the sysex number %1")
+ .arg(i));
+ }
+ }
+ }
+ else {
+ QMessageBox::critical(0,
+ tr("Critical Error"),
+ tr("Cannot save file %1").arg(filename));
+ }
+ }
+}
+void InsertEventDialog::updateType(int type) {
+ if(_selectedType != type) {
+ for(unsigned i = 0; i < IED_TypeCount; i++) {
+ if(type == (int)i) _typeWidget[i]->show();
+ else _typeWidget[i]->hide();
+ }
+ _selectedType = type;
+ }
+}
diff --git a/muse/muse/liste/ieventdialog.h b/muse/muse/liste/ieventdialog.h
new file mode 100644
index 00000000..27be67d1
--- /dev/null
+++ b/muse/muse/liste/ieventdialog.h
@@ -0,0 +1,101 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id:$
+//
+// Copyright (C) 2007 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#ifndef __IEVENTDIALOG_H__
+#define __IEVENTDIALOG_H__
+
+#include <QDialog>
+#include <vector>
+#include <QStringList>
+#include <QLineEdit>
+#include <QTextEdit>
+#include <QRegExp>
+#include <QDir>
+#include "awl/posedit.h"
+#include "midievent.h"
+#include "al/pos.h"
+#include "muse/event.h"
+
+class QDialog;
+using Awl::PosEdit;
+using AL::Pos;
+
+#define NoteSTR "Note"
+#define ProgramChangeSTR "Program change"
+#define ControlChangeSTR "Control change"
+#define SysexSTR "Sysex"
+
+class InsertEventDialog : public QDialog {
+ Q_OBJECT
+
+ QGridLayout* _mainLayout;
+ std::vector<QWidget*> _typeWidget;
+ int _selectedType;
+
+ QString _lastDir;
+
+ //event type
+ QComboBox* _eventTypeComboBox;
+
+ //time
+ PosEdit* _timePosEdit;
+
+ //Sysex
+ QSpinBox* _sysexCountSpinBox;
+ QSpinBox* _curSysexSpinBox;
+ QLabel* _lengthIntLabel;
+ QTextEdit* _sysexTextEdit;
+ QRegExp* _hexRegExp;
+ int _sysexCursorPos;
+ QPushButton* _loadButton;
+ QPushButton* _saveButton;
+ std::vector<QByteArray> _dataSysex;
+ std::vector<QString> _dataSysexStr;
+
+ enum {
+ IED_Note,
+ IED_ProgramChange,
+ IED_ControlChange,
+ IED_Sysex,
+ IED_TypeCount };
+
+ int sysexLength(); //return the length of the current sysex
+ QString ByteArray2Str(const QByteArray& ba); //add F0 and F7
+ QByteArray Str2ByteArray(const QString& s); //skip F0 and F7
+ void setSysexTextEdit(); //set the display of sysexTextEdit
+
+ public:
+ InsertEventDialog(const Pos& time,
+ QWidget* parent = 0, Qt::WindowFlags f = 0);
+ ~InsertEventDialog();
+
+ EventList* elResult();
+
+ private slots:
+ void updateSysexTextEdit();
+ void updateSysexCursor();
+ void updateSysexCount(int c);
+ void updateCurSysexSpinBox(int c);
+ void updateSysexLoad();
+ void updateSysexSave();
+ void updateType(int type);
+};
+
+#endif
diff --git a/muse/muse/liste/partlistedit.cpp b/muse/muse/liste/partlistedit.cpp
index 2551079f..5b0b39fa 100644
--- a/muse/muse/liste/partlistedit.cpp
+++ b/muse/muse/liste/partlistedit.cpp
@@ -47,7 +47,9 @@ PartListEditor::PartListEditor(ListEdit* e, QWidget* parent)
le.eventList->setItemDelegate(eventDelegate);
part = 0;
- }
+
+ connect(le.insertButton, SIGNAL(clicked()), SLOT(insertClicked()));
+ }
//---------------------------------------------------------
// getTrack
@@ -94,6 +96,29 @@ void PartListEditor::updateList()
}
//---------------------------------------------------------
+// insertClicked
+// insert one tick before current value
+//---------------------------------------------------------
+
+void PartListEditor::insertClicked()
+ {
+ AL::Pos time;
+
+ EventList* el;
+
+ InsertEventDialog dialog(time, this);
+ if(dialog.exec() == QDialog::Accepted) {
+ el = dialog.elResult();
+ if(el) {
+ for(iEvent ie = el->begin(); ie != el->end(); ie++) {
+ Event e = ie->second;
+ song->addEvent(e, part);
+ }
+ }
+ }
+ }
+
+//---------------------------------------------------------
// EventDelegate
//---------------------------------------------------------
diff --git a/muse/muse/liste/partlistedit.h b/muse/muse/liste/partlistedit.h
index 0ccbdcf5..a232fc64 100644
--- a/muse/muse/liste/partlistedit.h
+++ b/muse/muse/liste/partlistedit.h
@@ -22,6 +22,7 @@
#define __PARTLISTEDIT_H__
#include "al/pos.h"
+#include "ieventdialog.h"
#include "listedit.h"
#include "ui_partlistedit.h"
@@ -58,6 +59,7 @@ class PartListEditor : public ListWidget {
void updateList();
private slots:
+ void insertClicked();
public:
PartListEditor(ListEdit*, QWidget* parent = 0);
diff --git a/muse/plugins/pandelay/pandelaymodel.h b/muse/plugins/pandelay/pandelaymodel.h
index ed4255e2..66d68076 100644
--- a/muse/plugins/pandelay/pandelaymodel.h
+++ b/muse/plugins/pandelay/pandelaymodel.h
@@ -44,6 +44,7 @@ class PanDelayModel {
private:
int _samplerate;
+ //bool _beatFraction; //if true then the delay is calculated in beat fraction
float _delayTime;
float _feedback;
float _panLFOFreq;
diff --git a/muse/synti/deicsonze/deicsonze.cpp b/muse/synti/deicsonze/deicsonze.cpp
index 9cbf8ab0..0cc2b2ea 100644
--- a/muse/synti/deicsonze/deicsonze.cpp
+++ b/muse/synti/deicsonze/deicsonze.cpp
@@ -2243,30 +2243,26 @@ void DeicsOnze::writeConfiguration(AL::Xml* xml) {
// getInitData
//---------------------------------------------------------
void DeicsOnze::getInitData(int* length, const unsigned char** data) {
- FILE* tmp;
- char* comptmp;
- QString cmd="bzip2 > ";
- //compress the set
- comptmp=tempnam("/tmp", "DeicsOnze");
- cmd+=comptmp;
- tmp=popen(cmd.toAscii().data(), "w");
- QFile file;
- file.open(tmp, QIODevice::WriteOnly);
+ //write the set in a temporary file and in a QByteArray
+ QTemporaryFile file;
+ file.open();
AL::Xml* xml=new AL::Xml(&file);
xml->header();
_set->writeSet(xml, _saveOnlyUsed);
- file.close(); //flush
- pclose(tmp);
+ file.reset(); //seek the start of the file
+ QByteArray ba = file.readAll();
+ file.close();
+
+ //compress the QByteArray at default rate
+ QByteArray baComp = qCompress(ba);
//save the set
- FILE* comptmpf=fopen(comptmp, "r");
- fseek(comptmpf, 0, SEEK_END);
*length = NUM_CONFIGLENGTH
+ sizeof(float)*_pluginIReverb->plugin()->parameter()
+ sizeof(float)*_pluginIChorus->plugin()->parameter()
- + ftell(comptmpf);
- fseek(comptmpf, 0, SEEK_SET);
+ + baComp.size();
+
unsigned char* buffer = new unsigned char[*length];
//save init data
buffer[0]=SYSEX_INIT_DATA;
@@ -2369,15 +2365,13 @@ void DeicsOnze::getInitData(int* length, const unsigned char** data) {
buffer[NUM_DELAY_LFO_DEPTH] = (unsigned char)getDelayLFODepth();
//save set data
- for(int i = NUM_CONFIGLENGTH
- + sizeof(float)*_pluginIReverb->plugin()->parameter()
- + sizeof(float)*_pluginIChorus->plugin()->parameter();
- i < *length; i++) buffer[i]=(unsigned char)getc(comptmpf);
- fclose(comptmpf);
- QString rmcmd="rm ";
- rmcmd+=comptmp;
- system(rmcmd.toAscii().data());
- free(comptmp);
+ int offset =
+ NUM_CONFIGLENGTH
+ + sizeof(float)*_pluginIReverb->plugin()->parameter()
+ + sizeof(float)*_pluginIChorus->plugin()->parameter();
+ for(int i = offset; i < *length; i++)
+ buffer[i]=(unsigned char)baComp.at(i - offset);
+
*data=buffer;
}
//---------------------------------------------------------
@@ -2644,38 +2638,25 @@ void DeicsOnze::parseInitData(int length, const unsigned char* data) {
(const unsigned char*)dataDelayLFODepth, 2);
_gui->writeEvent(evSysexDelayLFODepth);
- //load set
- FILE* tmp;
- char* tmpname;
- char* uncompname;
- QString cmd="bunzip2 ";
-
- //get the bz2 part
- tmpname=tempnam("/tmp", "DEIBZ2");
- tmp=fopen(tmpname, "w");
- for(int i =
- NUM_CONFIGLENGTH
- + sizeof(float)*_pluginIReverb->plugin()->parameter()
- + sizeof(float)*_pluginIChorus->plugin()->parameter();
- i<length; i++) putc(data[i], tmp);
- fclose(tmp);
+ //load the set compressed
+ int offset =
+ NUM_CONFIGLENGTH
+ + sizeof(float)*_pluginIReverb->plugin()->parameter()
+ + sizeof(float)*_pluginIChorus->plugin()->parameter();
+ QByteArray baComp = QByteArray((const char*)&data[offset], length-offset);
//uncompress the set
- uncompname=tempnam("/tmp", "DEISET");
- cmd+=tmpname;
- cmd+=" -c > ";
- cmd+=uncompname;
- system(cmd.toAscii().data());
-
+ QByteArray baUncomp = qUncompress(baComp);
- //load the set
+ //save the set in a temporary file and
// read the XML file and create DOM tree
- //QString filename = (const char*) (data+2);
- QFile deicsonzeFile(uncompname);
- deicsonzeFile.open(QIODevice::ReadOnly);
+ QTemporaryFile file;
+ file.open();
+ file.write(baUncomp);
QDomDocument domTree;
- domTree.setContent(&deicsonzeFile);
- deicsonzeFile.close();
+ file.reset(); //seek the start of the file
+ domTree.setContent(&file);
+ file.close();
QDomNode node = domTree.documentElement();
while (!node.isNull()) {
@@ -2708,11 +2689,12 @@ void DeicsOnze::parseInitData(int length, const unsigned char* data) {
}
//send sysex to the gui to load the set (actually not because it doesn't
//work -the code is just zapped in the middle???-, so it is done above
- int dL=2+strlen(uncompname);
+ //int dL=2+baUncomp.size();
+ int dL = 2;
char dataSend[dL];
dataSend[0]=SYSEX_LOADSET;
dataSend[1]=data[NUM_SAVEONLYUSED];
- for(int i=2; i<dL; i++) dataSend[i]=uncompname[i-2];
+ //for(int i=2; i<dL; i++) dataSend[i]=baUncop.at(i-2);
MidiEvent evSysex(0,ME_SYSEX,(const unsigned char*)dataSend, dL);
_gui->writeEvent(evSysex);
@@ -2727,11 +2709,6 @@ void DeicsOnze::parseInitData(int length, const unsigned char* data) {
_gui->writeEvent(evProgSel);
}
- //delete the temporary file bz2
- QString rmfile;
- rmfile="rm ";
- rmfile+=tmpname;
- //system(rmfile.toAscii().data());
}
}
//---------------------------------------------------------
diff --git a/muse/synti/deicsonze/deicsonzegui.cpp b/muse/synti/deicsonze/deicsonzegui.cpp
index 636a2af2..b7119f43 100644
--- a/muse/synti/deicsonze/deicsonzegui.cpp
+++ b/muse/synti/deicsonze/deicsonzegui.cpp
@@ -44,7 +44,7 @@ DeicsOnzeGui::DeicsOnzeGui(DeicsOnze* deicsOnze)
{
setupUi(this);
_deicsOnze = deicsOnze;
- lastDir= "";
+ lastDir = QDir::currentPath();
_currentChannel = 0;