diff options
author | Werner Schweer <ws.seh.de> | 2007-04-19 10:38:02 +0000 |
---|---|---|
committer | Werner Schweer <ws.seh.de> | 2007-04-19 10:38:02 +0000 |
commit | fcc98151bee79745a49fb7d8cd7bc3a6bf40be30 (patch) | |
tree | d28e089f6ea67d7053ac4700219676382b9a78ab | |
parent | c6bcf4333aa1051272b65b0e0b222536736c344e (diff) |
fix buffer alignment for sse routines
-rw-r--r-- | muse/ChangeLog | 4 | ||||
-rw-r--r-- | muse/al/al.cpp | 1 | ||||
-rw-r--r-- | muse/al/al.h | 1 | ||||
-rw-r--r-- | muse/al/xml.cpp | 57 | ||||
-rw-r--r-- | muse/al/xml.h | 2 | ||||
-rw-r--r-- | muse/awl/ltest.cpp | 2 | ||||
-rw-r--r-- | muse/muse/audioinput.cpp | 2 | ||||
-rw-r--r-- | muse/muse/audiooutput.cpp | 2 | ||||
-rw-r--r-- | muse/muse/audiotrack.cpp | 2 | ||||
-rw-r--r-- | muse/muse/auxplugin.cpp | 6 | ||||
-rw-r--r-- | muse/muse/auxplugin.h | 3 | ||||
-rw-r--r-- | muse/muse/driver/dummyaudio.cpp | 7 | ||||
-rw-r--r-- | muse/muse/fifo.cpp | 8 | ||||
-rw-r--r-- | muse/muse/muse.cpp | 2 | ||||
-rw-r--r-- | muse/muse/pipeline.cpp | 40 | ||||
-rw-r--r-- | muse/muse/pipeline.h | 11 | ||||
-rw-r--r-- | muse/muse/song.cpp | 11 | ||||
-rw-r--r-- | muse/muse/song.h | 3 | ||||
-rw-r--r-- | muse/muse/songfile.cpp | 93 |
19 files changed, 223 insertions, 34 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog index 637980c3..f6be4d38 100644 --- a/muse/ChangeLog +++ b/muse/ChangeLog @@ -1,3 +1,7 @@ +19.04 (ws) + - framework for importing muse0.9 projectfiles + - align buffer in dummy audio driver so that the sse routines + do not choke; same for AuxPluginF, Pipeline, Fifo 18.04 (ws) - simplify mixer strip geometry manager - changed track list layout: track name now always uses one diff --git a/muse/al/al.cpp b/muse/al/al.cpp index af141170..50a2299d 100644 --- a/muse/al/al.cpp +++ b/muse/al/al.cpp @@ -24,5 +24,6 @@ namespace AL { int sampleRate = 44100; int mtcType = 0; int division = 384; + bool debugMsg = false; }; diff --git a/muse/al/al.h b/muse/al/al.h index 4f4e71a4..d88d7c0d 100644 --- a/muse/al/al.h +++ b/muse/al/al.h @@ -23,6 +23,7 @@ namespace AL { + extern bool debugMsg; extern int sampleRate; extern int mtcType; extern int division; diff --git a/muse/al/xml.cpp b/muse/al/xml.cpp index 329b6c0e..7ae40b3e 100644 --- a/muse/al/xml.cpp +++ b/muse/al/xml.cpp @@ -19,7 +19,7 @@ //============================================================================= #include "xml.h" - +#include "al.h" namespace AL { @@ -29,7 +29,7 @@ namespace AL { Xml::Xml() { - level = 0; + level = 0; } Xml::Xml(QIODevice* device) @@ -246,7 +246,7 @@ void readProperties(QObject* o, QDomNode node) if (idx == -1) { printf("MusE:%s: unknown tag %s\n", meta->className(), tag.toLatin1().data()); - return; + return; } QMetaProperty p = meta->property(idx); QVariant v; @@ -307,5 +307,56 @@ void Xml::dump(int len, const unsigned char* p) setIntegerBase(10); } +//--------------------------------------------------------- +// domError +//--------------------------------------------------------- + +void domError(QDomNode node) + { + QDomElement e = node.toElement(); + QString tag(e.tagName()); + QString s; + QDomNode dn(node); + while (!dn.parentNode().isNull()) { + dn = dn.parentNode(); + const QDomElement e = dn.toElement(); + const QString k(e.tagName()); + if (!s.isEmpty()) + s += ":"; + s += k; + } + fprintf(stderr, "%s: Unknown Node <%s>, type %d\n", + s.toLatin1().data(), tag.toLatin1().data(), node.nodeType()); + if (node.isText()) { + fprintf(stderr, " text node <%s>\n", node.toText().data().toLatin1().data()); + } + } + +//--------------------------------------------------------- +// domNotImplemented +//--------------------------------------------------------- + +void domNotImplemented(QDomNode node) + { + if (!AL::debugMsg) + return; + QDomElement e = node.toElement(); + QString tag(e.tagName()); + QString s; + QDomNode dn(node); + while (!dn.parentNode().isNull()) { + dn = dn.parentNode(); + const QDomElement e = dn.toElement(); + const QString k(e.tagName()); + if (!s.isEmpty()) + s += ":"; + s += k; + } + fprintf(stderr, "%s: Node not implemented: <%s>, type %d\n", + s.toLatin1().data(), tag.toLatin1().data(), node.nodeType()); + if (node.isText()) { + fprintf(stderr, " text node <%s>\n", node.toText().data().toLatin1().data()); + } + } } diff --git a/muse/al/xml.h b/muse/al/xml.h index 85a125b9..340d8190 100644 --- a/muse/al/xml.h +++ b/muse/al/xml.h @@ -61,6 +61,8 @@ class Xml : public QTextStream { extern QRect readGeometry(QDomNode); extern void readProperties(QObject* o, QDomNode node); +extern void domError(QDomNode node); +extern void domNotImplemented(QDomNode node); } #endif diff --git a/muse/awl/ltest.cpp b/muse/awl/ltest.cpp index f5b742e4..55fe1749 100644 --- a/muse/awl/ltest.cpp +++ b/muse/awl/ltest.cpp @@ -7,7 +7,7 @@ int main(int /*argc*/, char* /*argv*/[]) { - printf("Hello MusE\n"); + printf("Hello MusE\n"); new KnobPlugin; return 0; } diff --git a/muse/muse/audioinput.cpp b/muse/muse/audioinput.cpp index 7bd6d03a..829ebfb7 100644 --- a/muse/muse/audioinput.cpp +++ b/muse/muse/audioinput.cpp @@ -40,7 +40,7 @@ AudioInput::AudioInput() // the JACK supplied buffers for (int i = 0; i < MAX_CHANNELS; ++i) { if (buffer[i]) { - delete[] buffer[i]; + free(buffer[i]); buffer[i] = 0; } } diff --git a/muse/muse/audiooutput.cpp b/muse/muse/audiooutput.cpp index 6d58896c..330f0665 100644 --- a/muse/muse/audiooutput.cpp +++ b/muse/muse/audiooutput.cpp @@ -42,7 +42,7 @@ AudioOutput::AudioOutput() for (int i = 0; i < MAX_CHANNELS; ++i) { if (buffer[i]) { - delete[] buffer[i]; + free(buffer[i]); buffer[i] = 0; } } diff --git a/muse/muse/audiotrack.cpp b/muse/muse/audiotrack.cpp index ec866ac0..1d0940fd 100644 --- a/muse/muse/audiotrack.cpp +++ b/muse/muse/audiotrack.cpp @@ -79,7 +79,7 @@ AudioTrack::~AudioTrack() delete _postPipe; for (int i = 0; i < MAX_CHANNELS; ++i) { if (buffer[i]) - delete[] buffer[i]; + free(buffer[i]); } } diff --git a/muse/muse/auxplugin.cpp b/muse/muse/auxplugin.cpp index b3e244d3..ad203c84 100644 --- a/muse/muse/auxplugin.cpp +++ b/muse/muse/auxplugin.cpp @@ -108,9 +108,8 @@ double AuxPlugin::defaultValue(int idx) const AuxPluginIF::AuxPluginIF(PluginI* pi) : PluginIF(pi) { - _buffer = new float*[MAX_CHANNELS]; for (int i = 0; i < MAX_CHANNELS; ++i) - _buffer[i] = new float[segmentSize]; + posix_memalign((void**)(_buffer + i), 16, sizeof(float) * segmentSize); } //--------------------------------------------------------- @@ -121,9 +120,8 @@ AuxPluginIF::~AuxPluginIF() { for (int i = 0; i < MAX_CHANNELS; ++i) { if (_buffer[i]) - delete[] _buffer[i]; + free(_buffer[i]); } - delete[] _buffer; } //--------------------------------------------------------- diff --git a/muse/muse/auxplugin.h b/muse/muse/auxplugin.h index 3429e5e0..cb9c2e4e 100644 --- a/muse/muse/auxplugin.h +++ b/muse/muse/auxplugin.h @@ -21,6 +21,7 @@ #ifndef __AUXPLUGIN_H__ #define __AUXPLUGIN_H__ +#include "globaldefs.h" #include "plugin.h" //--------------------------------------------------------- @@ -60,7 +61,7 @@ class AuxPlugin : public Plugin { class AuxPluginIF : public PluginIF { double volume; double pan; - float** _buffer; // this buffer is filled by apply() + float* _buffer[MAX_CHANNELS]; // this buffer is filled by apply() // _volume and _pan is applied public: diff --git a/muse/muse/driver/dummyaudio.cpp b/muse/muse/driver/dummyaudio.cpp index 143b7918..b4bc73ff 100644 --- a/muse/muse/driver/dummyaudio.cpp +++ b/muse/muse/driver/dummyaudio.cpp @@ -33,8 +33,8 @@ static double startTime; //--------------------------------------------------------- class DummyAudio : public AudioDriver { + float* buffer; pthread_t dummyThread; - float buffer[dummyFrames]; std::vector<QString> oPorts; std::vector<QString> iPorts; int realTimePriority; @@ -48,8 +48,11 @@ class DummyAudio : public AudioDriver { state = Audio::STOP; seekflag = false; startTime = curTime(); + posix_memalign((void**)&buffer, 16, sizeof(float) * dummyFrames); + } + virtual ~DummyAudio() { + free(buffer); } - virtual ~DummyAudio() {} virtual bool init() { return true; } virtual void start(int); diff --git a/muse/muse/fifo.cpp b/muse/muse/fifo.cpp index 5c42a4f8..5b6e43cf 100644 --- a/muse/muse/fifo.cpp +++ b/muse/muse/fifo.cpp @@ -87,8 +87,8 @@ bool Fifo::put(int segs, unsigned long samples, float** src, unsigned pos) int n = segs * samples; if (b->maxSize < n) { if (b->buffer) - delete[] b->buffer; - b->buffer = new float[n]; + free(b->buffer); + posix_memalign((void**)&(b->buffer), 16, sizeof(float) * n); b->maxSize = n; } b->size = samples; @@ -166,8 +166,8 @@ bool Fifo::getWriteBuffer(int segs, unsigned long samples, float** buf, unsigned int n = segs * samples; if (b->maxSize < n) { if (b->buffer) - delete[] b->buffer; - b->buffer = new float[n]; + free(b->buffer); + posix_memalign((void**)&(b->buffer), 16, sizeof(float) * n); b->maxSize = n; } for (int i = 0; i < segs; ++i) diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp index 759f1354..90a1a4f7 100644 --- a/muse/muse/muse.cpp +++ b/muse/muse/muse.cpp @@ -25,6 +25,7 @@ #include "widgets/bigtime.h" #include "arranger/arranger.h" #include "midiedit/pianoroll.h" +#include "al/al.h" #include "al/xml.h" #include "al/dsp.h" #include "al/tempo.h" @@ -2832,6 +2833,7 @@ int main(int argc, char* argv[]) default: usage(argv[0], "bad argument"); return -1; } } + AL::debugMsg = debugMsg; if (midiOnly) { loadDSSI = false; loadPlugins = false; diff --git a/muse/muse/pipeline.cpp b/muse/muse/pipeline.cpp index 2c48d014..de42c867 100644 --- a/muse/muse/pipeline.cpp +++ b/muse/muse/pipeline.cpp @@ -23,6 +23,33 @@ #include "plugingui.h" //--------------------------------------------------------- +// Pipeline +//--------------------------------------------------------- + +Pipeline::Pipeline() + { + for (int i = 0; i < MAX_CHANNELS; ++i) + posix_memalign((void**)(buffer + i), 16, sizeof(float) * segmentSize); + } + +Pipeline::Pipeline(const Pipeline& p) + : QList<PluginI*>(p) + { + for (int i = 0; i < MAX_CHANNELS; ++i) + posix_memalign((void**)(buffer + i), 16, sizeof(float) * segmentSize); + } + +//--------------------------------------------------------- +// Pipeline +//--------------------------------------------------------- + +Pipeline::~Pipeline() + { + for (int i = 0; i < MAX_CHANNELS; ++i) + ::free(buffer[i]); + } + +//--------------------------------------------------------- // setChannels //--------------------------------------------------------- @@ -166,33 +193,28 @@ void Pipeline::apply(int ports, unsigned long nframes, float** buffer1) // prepare a second set of buffers in case a plugin is not // capable of inPlace processing - float* buffer2[ports]; - float data[nframes * ports]; - for (int i = 0; i < ports; ++i) - buffer2[i] = data + i * nframes; - bool swap = false; foreach (PluginI* p, *this) { if (p->on()) { if (p->inPlaceCapable()) { if (swap) - p->apply(nframes, ports, buffer2, buffer2); + p->apply(nframes, ports, buffer, buffer); else p->apply(nframes, ports, buffer1, buffer1); } else { if (swap) - p->apply(nframes, ports, buffer2, buffer1); + p->apply(nframes, ports, buffer, buffer1); else - p->apply(nframes, ports, buffer1, buffer2); + p->apply(nframes, ports, buffer1, buffer); swap = !swap; } } } if (swap) { for (int i = 0; i < ports; ++i) - memcpy(buffer1[i], buffer2[i], sizeof(float) * nframes); + memcpy(buffer1[i], buffer[i], sizeof(float) * nframes); } } diff --git a/muse/muse/pipeline.h b/muse/muse/pipeline.h index 4abf90fc..a6e34678 100644 --- a/muse/muse/pipeline.h +++ b/muse/muse/pipeline.h @@ -21,6 +21,8 @@ #ifndef __PIPELINE_H__ #define __PIPELINE_H__ +#include "globaldefs.h" + class PluginI; //--------------------------------------------------------- @@ -29,8 +31,15 @@ class PluginI; //--------------------------------------------------------- class Pipeline : public QList<PluginI*> { + float* buffer[MAX_CHANNELS]; + public: - Pipeline() {} + Pipeline(); + ~Pipeline(); + + Pipeline(const Pipeline&); + Pipeline& operator=(const Pipeline&); // disable copies + bool isOn(int idx) const; void setOn(int, bool); QString label(int idx) const; diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp index 01b09cb6..240d003e 100644 --- a/muse/muse/song.cpp +++ b/muse/muse/song.cpp @@ -1436,8 +1436,11 @@ bool Song::read(QFile* qf) int major=0, minor=0; sscanf(sversion.toLatin1().data(), "%d.%d", &major, &minor); int version = major << 8 + minor; +printf("read version %x\n", version); + if (version >= 0x201) + read30(node.firstChild()); if (version >= 0x200) - read20(node.firstChild()); + read20(node); else if (version == 0x100) read10(node.firstChild()); else @@ -1460,10 +1463,10 @@ void Song::read10(QDomNode) } //--------------------------------------------------------- -// read20 +// read30 //--------------------------------------------------------- -void Song::read20(QDomNode node) +void Song::read30(QDomNode node) { for (; !node.isNull(); node = node.nextSibling()) { QDomElement e = node.toElement(); @@ -1476,7 +1479,7 @@ void Song::read20(QDomNode node) else if (e.tagName() == "toplevels") muse->readToplevels(node.firstChild()); else - printf("MusE:read20(): unknown tag %s\n", e.tagName().toLatin1().data()); + printf("MusE:read30(): unknown tag %s\n", e.tagName().toLatin1().data()); } } diff --git a/muse/muse/song.h b/muse/muse/song.h index f18eaba9..c15ce236 100644 --- a/muse/muse/song.h +++ b/muse/muse/song.h @@ -403,7 +403,8 @@ class Song : public QObject { QDateTime createDate() const { return _createDate; } bool read(QFile* qf); - void read20(QDomNode node); + void read30(QDomNode node); // muse >= 1.0 + void read20(QDomNode node); // muse < 1.0 void read10(QDomNode); void updateCurrentMarker(); }; diff --git a/muse/muse/songfile.cpp b/muse/muse/songfile.cpp index 6d7ee4c2..f40ace80 100644 --- a/muse/muse/songfile.cpp +++ b/muse/muse/songfile.cpp @@ -39,6 +39,8 @@ #include "marker/markerview.h" #include "liste/listedit.h" +using namespace AL; + //--------------------------------------------------------- // readPart //--------------------------------------------------------- @@ -330,7 +332,7 @@ void MusE::write(Xml& xml) const { xml.header(); - xml.stag("muse version=\"2.1\""); + xml.stag("muse version=\"3.0\""); writeConfiguration(xml); song->write(xml); @@ -366,3 +368,92 @@ void MusE::write(Xml& xml) const xml.etag("muse"); } +//--------------------------------------------------------- +// read20 +// read old file versions (muse < 1.0) +//--------------------------------------------------------- + +void Song::read20(QDomNode node) + { + printf("Warning: importing old muse file version\n"); + + for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { + QDomElement e = n.toElement(); + if (e.isNull()) + continue; + QString t(e.tagName()); + if (t == "configuration") + readConfiguration(node.firstChild()); + else if (t == "song") { + for (QDomNode n1 = n.firstChild(); !n1.isNull(); n1 = n1.nextSibling()) { + QDomElement e = n1.toElement(); + if (e.isNull()) + continue; + QString t(e.tagName()); + if (t == "automation") + ; + else if (t == "cpos") + ; + else if (t == "rpos") + ; + else if (t == "lpos") + ; + else if (t == "master") + ; + else if (t == "loop") + ; + else if (t == "punchin") + ; + else if (t == "punchout") + ; + else if (t == "record") + ; + else if (t == "solo") + ; + else if (t == "type") + ; + else if (t == "recmode") + ; + else if (t == "cycle") + ; + else if (t == "click") + ; + else if (t == "quantize") + ; + else if (t == "len") + ; + else if (t == "follow") + ; + else if (t == "drummap") + ; + else if (t == "siglist") + ; + else if (t == "tempolist") + ; + else if (t == "Route") + ; + else if (t == "AudioAux") + ; + else if (t == "AudioInput") + ; + else if (t == "AudioGroup") + ; + else if (t == "AudioOutput") + ; + else if (t == "wavetrack") + ; + else if (t == "drumtrack") + ; + else if (t == "miditrack") + ; + else + domError(n1); + } + } + else if (t == "toplevels") { + } + else + domError(n); + } + } + |