summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2010-02-05 06:59:19 +0000
committerTim E. Real <termtech@rogers.com>2010-02-05 06:59:19 +0000
commit256e4a6194d21e106cd34d0aff81c8e6e56b5f72 (patch)
treeac5baed039d7e14a70b05febd07b01b0621ae3df
parent4cdcffed8c4ea184ff3ed6bbdec668782712fa65 (diff)
See ChangeLog
-rw-r--r--muse/ChangeLog8
-rw-r--r--muse/muse/arranger/pcanvas.cpp2
-rw-r--r--muse/muse/audioconvert.cpp89
-rw-r--r--muse/muse/audioconvert.h32
-rw-r--r--muse/muse/driver/dummyaudio.cpp2
-rw-r--r--muse/muse/event.cpp25
-rw-r--r--muse/muse/event.h12
-rw-r--r--muse/muse/eventbase.h10
-rw-r--r--muse/muse/liste/listedit.cpp66
-rw-r--r--muse/muse/midi.cpp5
-rw-r--r--muse/muse/midieditor.cpp4
-rw-r--r--muse/muse/part.h5
-rw-r--r--muse/muse/songfile.cpp45
-rw-r--r--muse/muse/waveevent.cpp23
-rw-r--r--muse/muse/waveevent.h5
-rw-r--r--muse/muse/wavetrack.cpp4
16 files changed, 245 insertions, 92 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index f0831447..9451c5ac 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,11 @@
+05.02.2010
+ * Fixed: Top level windows: Do not open if there are no parts. Case: bogus -1 top-level part index stored in med file. (T356)
+ - Changed MusE::readToplevels() and stuff in listedit.cpp
+ - Was causing crash of list editor upon loading a song saved with the list editor open.
+ Somehow a bogus -1 top-level part index can make it in to the .med file. Checking this...
+ * Changed: Preparations for audio processors: Moved stuff out of class Event and into class WavePart. (T356)
+ - WavePart needs a converter map to lookup events in the part's (shared) event list, in case clones exist !
+ Ughh, it's going to be tough to ensure the map is always correct because an event cannot tell what part owns it...
04.02.2010
* Improved: Grid handling in arranger improved, it should now be actually usable (rj)
01.02.2010
diff --git a/muse/muse/arranger/pcanvas.cpp b/muse/muse/arranger/pcanvas.cpp
index a6994601..4cb3db1a 100644
--- a/muse/muse/arranger/pcanvas.cpp
+++ b/muse/muse/arranger/pcanvas.cpp
@@ -2547,7 +2547,7 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect)
//--------------------------------
// vertical lines
//-------------------------------
- printf("raster=%d\n", *_raster);
+ //printf("raster=%d\n", *_raster);
if (config.canvasShowGrid) {
int bar, beat;
unsigned tick;
diff --git a/muse/muse/audioconvert.cpp b/muse/muse/audioconvert.cpp
index 0c8fa657..878bc8e7 100644
--- a/muse/muse/audioconvert.cpp
+++ b/muse/muse/audioconvert.cpp
@@ -13,6 +13,7 @@
#include "wave.h"
#include "globals.h"
#include "audioconvert.h"
+#include "eventbase.h"
//#define AUDIOCONVERT_DEBUG
//#define AUDIOCONVERT_DEBUG_PRC
@@ -21,25 +22,44 @@
// AudioConvertMap
//---------------------------------------------------------
-/*
-void AudioConvertMap::remapEvents(const EventList*)
+void AudioConvertMap::remapEvents(const EventList* el)
{
}
-iAudioConvertMap AudioConvertMap::addEventBase(const EventBase*)
+iAudioConvertMap AudioConvertMap::addEvent(EventBase* eb)
{
-
+ iAudioConvertMap iacm = getConverter(eb);
+ if(iacm == end())
+ {
+ AudioConverter* cv = 0;
+ if(!eb->sndFile().isNull())
+ cv = new SRCAudioConverter(eb->sndFile().channels(), SRC_SINC_MEDIUM_QUALITY);
+
+ // Use insert with hint for speed.
+ return insert(iacm, std::pair<EventBase*, AudioConverter*> (eb, cv));
+ }
+ else
+ // Adopt a policy of returning an already existing item to enforce no-duplicates.
+ return iacm;
}
-AudioConverter* AudioConvertMap::findConverter(const EventBase* eb)
+void AudioConvertMap::removeEvent(EventBase* eb)
{
iAudioConvertMap iacm = find(eb);
if(iacm != end())
- return iacm->second;
- return 0;
+ {
+ AudioConverter* cv = iacm->second;
+ if(cv)
+ delete cv;
+ erase(iacm);
+ }
+}
+
+iAudioConvertMap AudioConvertMap::getConverter(EventBase* eb)
+{
+ return find(eb);
}
-*/
//---------------------------------------------------------
// AudioConverter
@@ -52,6 +72,7 @@ AudioConverter::AudioConverter()
#endif
_refCount = 1;
+ _sfCurFrame = 0;
}
AudioConverter::~AudioConverter()
@@ -90,10 +111,11 @@ AudioConverter* AudioConverter::release(AudioConverter* cv)
return cv;
}
-off_t AudioConverter::readAudio(SndFileR& f, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
+//off_t AudioConverter::readAudio(SndFileR& f, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
+off_t AudioConverter::readAudio(SndFileR& f, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
{
if(f.isNull())
- return sfCurFrame;
+ return _sfCurFrame;
// Added by Tim. p3.3.17
//#ifdef AUDIOCONVERT_DEBUG_PRC
@@ -109,8 +131,8 @@ off_t AudioConverter::readAudio(SndFileR& f, off_t sfCurFrame, unsigned offset,
if(!resample)
{
// Sample rates are the same. Just a regular seek + read, no conversion.
- sfCurFrame = f.seek(frame, 0);
- return sfCurFrame + f.read(channel, buffer, n, overwrite);
+ _sfCurFrame = f.seek(frame, 0);
+ return _sfCurFrame + f.read(channel, buffer, n, overwrite);
}
// Is a 'transport' seek requested? (Not to be requested with every read! Should only be for 'first read' seeks, or positional 'transport' seeks.)
@@ -124,7 +146,7 @@ off_t AudioConverter::readAudio(SndFileR& f, off_t sfCurFrame, unsigned offset,
//long inSize = long((double)frames * _src_ratio) + 1 // From MusE-2 file converter.
off_t newfr = (off_t)floor(((double)frame * srcratio)); // From simplesynth.
- sfCurFrame = f.seek(newfr, 0);
+ _sfCurFrame = f.seek(newfr, 0);
// Added by Tim. p3.3.17
//#ifdef AUDIOCONVERT_DEBUG_PRC
@@ -145,7 +167,7 @@ off_t AudioConverter::readAudio(SndFileR& f, off_t sfCurFrame, unsigned offset,
// Sample rates are different. We can't just tell seek to go to an absolute calculated position,
// since the last position can vary - it might not be what the calculated position is.
// We must use the last position left by SRC conversion, ie. let the file position progress on its own.
- sfCurFrame = f.seek(sfCurFrame, 0);
+ _sfCurFrame = f.seek(_sfCurFrame, 0);
}
/*
@@ -157,7 +179,8 @@ off_t AudioConverter::readAudio(SndFileR& f, off_t sfCurFrame, unsigned offset,
//sfCurFrame = process(f, sfCurFrame, offset, &outbuffer[0], channel, n);
// sfCurFrame = process(f, sfCurFrame, outbuffer, channel, n);
- sfCurFrame = process(f, sfCurFrame, buffer, channel, n, overwrite);
+ //sfCurFrame = process(f, sfCurFrame, buffer, channel, n, overwrite);
+ _sfCurFrame = process(f, buffer, channel, n, overwrite);
/*
float* poutbuf = &outbuffer[0];
@@ -218,7 +241,7 @@ off_t AudioConverter::readAudio(SndFileR& f, off_t sfCurFrame, unsigned offset,
}
*/
- return sfCurFrame;
+ return _sfCurFrame;
}
//---------------------------------------------------------
@@ -286,13 +309,14 @@ void SRCAudioConverter::reset()
return;
}
-off_t SRCAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer, int channel, int n, bool overwrite)
+//off_t SRCAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer, int channel, int n, bool overwrite)
+off_t SRCAudioConverter::process(SndFileR& f, float** buffer, int channel, int n, bool overwrite)
{
//return src_process(_src_state, sd);
if(f.isNull())
//return;
- return sfCurFrame;
+ return _sfCurFrame;
// Added by Tim. p3.3.17
//#ifdef AUDIOCONVERT_DEBUG_PRC
@@ -310,7 +334,7 @@ off_t SRCAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer,
#ifdef AUDIOCONVERT_DEBUG
printf("SRCAudioConverter::process Error: sampleRate or file samplerate is zero!\n");
#endif
- return sfCurFrame;
+ return _sfCurFrame;
}
SRC_DATA srcdata;
@@ -372,7 +396,7 @@ off_t SRCAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer,
if(srcerr != 0)
{
printf("\nSRCAudioConverter::process SampleRate converter process failed: %s\n", src_strerror(srcerr));
- return sfCurFrame += rn;
+ return _sfCurFrame += rn;
}
totalOutFrames += srcdata.output_frames_gen;
@@ -399,10 +423,10 @@ off_t SRCAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer,
#ifdef AUDIOCONVERT_DEBUG_PRC
printf("SRCAudioConverter::process Seek-back by:%d\n", seekn);
#endif
- sfCurFrame = f.seek(-seekn, SEEK_CUR);
+ _sfCurFrame = f.seek(-seekn, SEEK_CUR);
}
else
- sfCurFrame += rn;
+ _sfCurFrame += rn;
if(totalOutFrames == n)
{
@@ -434,7 +458,7 @@ off_t SRCAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer,
}
else
{
- sfCurFrame += rn;
+ _sfCurFrame += rn;
#ifdef AUDIOCONVERT_DEBUG
printf("SRCAudioConverter::process %s rn:%zd != inFrames:%ld output_frames_gen:%ld outFrames:%ld srcdata.input_frames_used:%ld\n",
f.name().latin1(), rn, inFrames, srcdata.output_frames_gen, outFrames, srcdata.input_frames_used);
@@ -523,7 +547,7 @@ off_t SRCAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer,
#endif
}
- return sfCurFrame;
+ return _sfCurFrame;
}
#ifdef RUBBERBAND_SUPPORT
@@ -581,13 +605,14 @@ void RubberBandAudioConverter::reset()
/////////////////////////////////
// TODO: Not finished yet..
////////////////////////////////
-off_t RubberBandAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer, int channel, int n, bool overwrite)
+//off_t RubberBandAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer, int channel, int n, bool overwrite)
+off_t RubberBandAudioConverter::process(SndFileR& f, float** buffer, int channel, int n, bool overwrite)
{
//return src_process(_src_state, sd);
if(f.isNull())
//return;
- return sfCurFrame;
+ return _sfCurFrame;
// Added by Tim. p3.3.17
//#ifdef AUDIOCONVERT_DEBUG_PRC
@@ -605,7 +630,7 @@ off_t RubberBandAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** b
#ifdef AUDIOCONVERT_DEBUG
printf("RubberBandAudioConverter::process Error: sampleRate or file samplerate is zero!\n");
#endif
- return sfCurFrame;
+ return _sfCurFrame;
}
// SRC_DATA srcdata;
@@ -704,7 +729,7 @@ off_t RubberBandAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** b
if(srcerr != 0)
{
printf("\RubberBandAudioConverter::process SampleRate converter process failed: %s\n", src_strerror(srcerr));
- return sfCurFrame += rn;
+ return _sfCurFrame += rn;
}
totalOutFrames += srcdata.output_frames_gen;
@@ -731,10 +756,10 @@ off_t RubberBandAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** b
#ifdef AUDIOCONVERT_DEBUG_PRC
printf("RubberBandAudioConverter::process Seek-back by:%d\n", seekn);
#endif
- sfCurFrame = f.seek(-seekn, SEEK_CUR);
+ _sfCurFrame = f.seek(-seekn, SEEK_CUR);
}
else
- sfCurFrame += rn;
+ _sfCurFrame += rn;
if(totalOutFrames == n)
{
@@ -766,7 +791,7 @@ off_t RubberBandAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** b
}
else
{
- sfCurFrame += rn;
+ _sfCurFrame += rn;
#ifdef AUDIOCONVERT_DEBUG
printf("RubberBandAudioConverter::process %s rn:%zd != inFrames:%ld output_frames_gen:%ld outFrames:%ld srcdata.input_frames_used:%ld\n",
f.name().latin1(), rn, inFrames, srcdata.output_frames_gen, outFrames, srcdata.input_frames_used);
@@ -855,7 +880,7 @@ off_t RubberBandAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** b
#endif
}
- return sfCurFrame;
+ return _sfCurFrame;
}
#endif // RUBBERBAND_SUPPORT
diff --git a/muse/muse/audioconvert.h b/muse/muse/audioconvert.h
index 4c69d679..039af912 100644
--- a/muse/muse/audioconvert.h
+++ b/muse/muse/audioconvert.h
@@ -11,7 +11,7 @@
#ifndef __AUDIOCONVERT_H__
#define __AUDIOCONVERT_H__
-//#include <map>
+#include <map>
#ifdef RUBBERBAND_SUPPORT
#include <RubberBandStretcher.h>
@@ -21,8 +21,8 @@
#include <sys/types.h>
//#include "eventbase.h"
-//class EventBase;
-//class EventList;
+class EventBase;
+class EventList;
class SndFileR;
@@ -32,7 +32,9 @@ class SndFileR;
class AudioConverter
{
+ protected:
int _refCount;
+ off_t _sfCurFrame;
public:
AudioConverter();
@@ -41,13 +43,17 @@ class AudioConverter
AudioConverter* reference();
static AudioConverter* release(AudioConverter* cv);
- off_t readAudio(SndFileR& /*sf*/, off_t /*sfCurFrame*/, unsigned /*offset*/, float** /*buffer*/,
+ //off_t readAudio(SndFileR& /*sf*/, off_t /*sfCurFrame*/, unsigned /*offset*/, float** /*buffer*/,
+ // int /*channels*/, int /*frames*/, bool /*doSeek*/, bool /*overwrite*/);
+ off_t readAudio(SndFileR& /*sf*/, unsigned /*offset*/, float** /*buffer*/,
int /*channels*/, int /*frames*/, bool /*doSeek*/, bool /*overwrite*/);
virtual bool isValid() = 0;
virtual void reset() = 0;
virtual void setChannels(int ch) = 0;
- virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
+ //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
+ // int /*channels*/, int /*frames*/, bool /*overwrite*/) = 0; // Interleaved buffer if stereo.
+ virtual off_t process(SndFileR& /*sf*/, float** /*buffer*/,
int /*channels*/, int /*frames*/, bool /*overwrite*/) = 0; // Interleaved buffer if stereo.
};
@@ -68,7 +74,9 @@ class SRCAudioConverter : public AudioConverter
virtual bool isValid() { return _src_state != 0; }
virtual void reset();
virtual void setChannels(int ch);
- virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
+ //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
+ // int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
+ virtual off_t process(SndFileR& /*sf*/, float** /*buffer*/,
int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
};
@@ -91,7 +99,9 @@ class RubberBandAudioConverter : public AudioConverter
virtual bool isValid() { return _rbs != 0; }
virtual void reset();
virtual void setChannels(int ch);
- virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
+ //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
+ // int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
+ virtual off_t process(SndFileR& /*sf*/, float** /*buffer*/,
int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
};
@@ -101,7 +111,6 @@ class RubberBandAudioConverter : public AudioConverter
// AudioConvertMap
//---------------------------------------------------------
-/*
typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> >::iterator iAudioConvertMap;
typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> >::const_iterator ciAudioConvertMap;
@@ -110,10 +119,11 @@ class AudioConvertMap : public std::map<EventBase*, AudioConverter*, std::less<E
{
public:
void remapEvents(const EventList*);
- iAudioConvertMap addEventBase(const EventBase*);
- AudioConverter* findConverter(const EventBase*);
+ iAudioConvertMap addEvent(EventBase*);
+ void removeEvent(EventBase*);
+ //AudioConverter* getConverter(const EventBase*);
+ iAudioConvertMap getConverter(EventBase*);
};
-*/
#endif
diff --git a/muse/muse/driver/dummyaudio.cpp b/muse/muse/driver/dummyaudio.cpp
index 89fbc064..bd95647d 100644
--- a/muse/muse/driver/dummyaudio.cpp
+++ b/muse/muse/driver/dummyaudio.cpp
@@ -168,7 +168,7 @@ class DummyAudioDevice : public AudioDevice {
virtual void setFreewheel(bool) {}
void setRealTime() { realtimeFlag = true; }
- virtual bool putEvent(int port, const MidiPlayEvent&) { };
+ virtual bool putEvent(int /*port*/, const MidiPlayEvent&) { return true;};
};
DummyAudioDevice* dummyAudio = 0;
diff --git a/muse/muse/event.cpp b/muse/muse/event.cpp
index 61868f1d..5d16fde9 100644
--- a/muse/muse/event.cpp
+++ b/muse/muse/event.cpp
@@ -8,7 +8,7 @@
#include <stdio.h>
// #include <memory.h>
-#include "audioconvert.h"
+//#include "audioconvert.h"
#include "event.h"
#include "eventbase.h"
#include "waveevent.h"
@@ -80,13 +80,13 @@ Event Event::clone()
Event::Event()
{
ev = 0;
- _sfCurFrame = 0;
- _audConv = 0;
+ //_sfCurFrame = 0;
+ //_audConv = 0;
}
Event::Event(EventType t) {
- _sfCurFrame = 0;
- _audConv = 0;
+ //_sfCurFrame = 0;
+ //_audConv = 0;
if (t == Wave)
ev = new WaveEventBase(t);
@@ -95,8 +95,8 @@ Event::Event(EventType t) {
++(ev->refCount);
}
Event::Event(const Event& e) {
- _sfCurFrame = 0;
- _audConv = 0;
+ //_sfCurFrame = 0;
+ //_audConv = 0;
ev = e.ev;
if(ev)
@@ -109,8 +109,8 @@ Event::Event(const Event& e) {
#endif
}
Event::Event(EventBase* eb) {
- _sfCurFrame = 0;
- _audConv = 0;
+ //_sfCurFrame = 0;
+ //_audConv = 0;
ev = eb;
++(ev->refCount);
@@ -303,12 +303,15 @@ void Event::setSndFile(SndFileR& sf)
}
//void Event::read(unsigned offset, float** bpp, int channels, int nn, bool overwrite)
-void Event::readAudio(unsigned offset, float** bpp, int channels, int nn, bool doSeek, bool overwrite)
+//void Event::readAudio(unsigned offset, float** bpp, int channels, int nn, bool doSeek, bool overwrite)
+// p3.3.33
+void Event::readAudio(WavePart* part, unsigned offset, float** bpp, int channels, int nn, bool doSeek, bool overwrite)
{
//ev->read(offset, bpp, channels, nn, overwrite);
//ev->readAudio(offset, bpp, channels, nn, doSeek, overwrite);
//_sfCurFrame = ev->readAudio(_src_state, _sfCurFrame, offset, bpp, channels, nn, doSeek, overwrite);
- _sfCurFrame = ev->readAudio(_audConv, _sfCurFrame, offset, bpp, channels, nn, doSeek, overwrite);
+ // p3.3.33
+ ev->readAudio(part, offset, bpp, channels, nn, doSeek, overwrite);
}
void Event::setTick(unsigned val) { ev->setTick(val); }
unsigned Event::tick() const { return ev->tick(); }
diff --git a/muse/muse/event.h b/muse/muse/event.h
index 37d3c963..0b0a2fbd 100644
--- a/muse/muse/event.h
+++ b/muse/muse/event.h
@@ -22,7 +22,8 @@ enum EventType { Note, Controller, Sysex, PAfter, CAfter, Meta, Wave };
class Xml;
class EventBase;
-class AudioConverter;
+//class AudioConverter;
+class WavePart;
//---------------------------------------------------------
// Event
@@ -31,8 +32,8 @@ class AudioConverter;
class Event {
EventBase* ev;
- off_t _sfCurFrame;
- AudioConverter* _audConv;
+ //off_t _sfCurFrame;
+ //AudioConverter* _audConv;
public:
//Event() { ev = 0; }
@@ -94,8 +95,11 @@ class Event {
//AudioConverter* audioConverter() { return _audConv;}
SndFileR sndFile() const;
virtual void setSndFile(SndFileR& sf);
+
//virtual void read(unsigned offset, float** bpp, int channels, int nn, bool overwrite = true);
- virtual void readAudio(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+ //virtual void readAudio(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+ virtual void readAudio(WavePart* /*part*/, unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+
void setTick(unsigned val);
unsigned tick() const;
unsigned frame() const;
diff --git a/muse/muse/eventbase.h b/muse/muse/eventbase.h
index 4a49b6f8..6684bf57 100644
--- a/muse/muse/eventbase.h
+++ b/muse/muse/eventbase.h
@@ -13,8 +13,10 @@
#include <sys/types.h>
#include "pos.h"
+#include "event.h"
-class AudioConverter;
+//class AudioConverter;
+class WavePart;
//---------------------------------------------------------
// EventBase
@@ -86,8 +88,10 @@ class EventBase : public PosLen {
//virtual void readAudio(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) {}
//virtual off_t readAudio(SRC_STATE* /*src_state*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
// float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) { return 0; }
- virtual off_t readAudio(AudioConverter* /*audConv*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
- float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) { return 0; }
+ //virtual off_t readAudio(AudioConverter* /*audConv*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
+ // float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) { return 0; }
+ virtual void readAudio(WavePart* /*part*/, unsigned /*offset*/,
+ float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) { }
};
#endif
diff --git a/muse/muse/liste/listedit.cpp b/muse/muse/liste/listedit.cpp
index eef15b43..b0506dc9 100644
--- a/muse/muse/liste/listedit.cpp
+++ b/muse/muse/liste/listedit.cpp
@@ -227,10 +227,23 @@ void ListEdit::songChanged(int type)
}
}
}
- if (curPart == 0)
- curPart = (MidiPart*)(parts()->begin()->second);
- curTrack = curPart->track();
+
+ // p3.3.34
+ //if (curPart == 0)
+ // curPart = (MidiPart*)(parts()->begin()->second);
+ //curTrack = curPart->track();
+ if(!curPart)
+ {
+ if(!parts()->empty())
+ {
+ curPart = (MidiPart*)(parts()->begin()->second);
+ if(curPart)
+ curTrack = curPart->track();
+ else
+ curPart = 0;
+ }
}
+ }
}
//---------------------------------------------------------
@@ -495,8 +508,27 @@ ListEdit::ListEdit(PartList* pl)
connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
songChanged(-1);
- curPart = (MidiPart*)(pl->begin()->second);
- curPartId = curPart->sn();
+ // p3.3.34
+ // Was crashing because of -1 stored, because there was an invalid
+ // part pointer stored.
+ //curPart = (MidiPart*)(pl->begin()->second);
+ if(pl->empty())
+ {
+ curPart = 0;
+ curPartId = -1;
+ }
+ else
+ {
+ curPart = (MidiPart*)pl->begin()->second;
+ if(curPart)
+ curPartId = curPart->sn();
+ else
+ {
+ curPart = 0;
+ curPartId = -1;
+ }
+ }
+
initShortcuts();
}
@@ -515,6 +547,10 @@ ListEdit::~ListEdit()
void ListEdit::editInsertNote()
{
+ // p3.3.34
+ if(!curPart)
+ return;
+
Event event = EditNoteDialog::getEvent(curPart->tick(), Event(), this);
if (!event.empty()) {
//No events before beginning of part + take Part offset into consideration
@@ -536,6 +572,10 @@ void ListEdit::editInsertNote()
void ListEdit::editInsertSysEx()
{
+ // p3.3.34
+ if(!curPart)
+ return;
+
Event event = EditSysexDialog::getEvent(curPart->tick(), Event(), this);
if (!event.empty()) {
//No events before beginning of part + take Part offset into consideration
@@ -557,6 +597,10 @@ void ListEdit::editInsertSysEx()
void ListEdit::editInsertCtrl()
{
+ // p3.3.34
+ if(!curPart)
+ return;
+
Event event = EditCtrlDialog::getEvent(curPart->tick(), Event(), curPart, this);
if (!event.empty()) {
//No events before beginning of part + take Part offset into consideration
@@ -578,6 +622,10 @@ void ListEdit::editInsertCtrl()
void ListEdit::editInsertMeta()
{
+ // p3.3.34
+ if(!curPart)
+ return;
+
Event event = EditMetaDialog::getEvent(curPart->tick(), Event(), this);
if (!event.empty()) {
//No events before beginning of part + take Part offset into consideration
@@ -599,6 +647,10 @@ void ListEdit::editInsertMeta()
void ListEdit::editInsertCAfter()
{
+ // p3.3.34
+ if(!curPart)
+ return;
+
Event event = EditCAfterDialog::getEvent(curPart->tick(), Event(), this);
if (!event.empty()) {
//No events before beginning of part + take Part offset into consideration
@@ -620,6 +672,10 @@ void ListEdit::editInsertCAfter()
void ListEdit::editInsertPAfter()
{
+ // p3.3.34
+ if(!curPart)
+ return;
+
Event ev;
Event event = EditPAfterDialog::getEvent(curPart->tick(), ev, this);
if (!event.empty()) {
diff --git a/muse/muse/midi.cpp b/muse/muse/midi.cpp
index d330f51e..4efd3ece 100644
--- a/muse/muse/midi.cpp
+++ b/muse/muse/midi.cpp
@@ -1103,7 +1103,10 @@ void Audio::processMidi()
// 384/24=16 for a division of 16 sub-frames (16 MusE 'ticks').
// That is what we'll use if syncing externally.
//unsigned time = event.time() + segmentSize*(segmentCount-1);
- unsigned time = event.time() + (extsync ? config.division/24 : segmentSize*(segmentCount-1));
+ //unsigned time = event.time() + (extsync ? config.division/24 : segmentSize*(segmentCount-1));
+ // p3.3.34
+ // Oops, use the current tick.
+ unsigned time = extsync ? curTickPos : (event.time() + segmentSize*(segmentCount-1));
event.setTime(time);
// dont't echo controller changes back to software
diff --git a/muse/muse/midieditor.cpp b/muse/muse/midieditor.cpp
index 08951b17..dc4f0c19 100644
--- a/muse/muse/midieditor.cpp
+++ b/muse/muse/midieditor.cpp
@@ -131,6 +131,10 @@ void MidiEditor::writePartList(int level, Xml& xml) const
Track* track = part->track();
int trkIdx = song->tracks()->index(track);
int partIdx = track->parts()->index(part);
+
+ if((trkIdx == -1) || (partIdx == -1))
+ printf("MidiEditor::writePartList error: trkIdx:%d partIdx:%d\n", trkIdx, partIdx);
+
xml.put(level, "<part>%d:%d</part>", trkIdx, partIdx);
}
}
diff --git a/muse/muse/part.h b/muse/muse/part.h
index 911c8806..b2a18851 100644
--- a/muse/muse/part.h
+++ b/muse/muse/part.h
@@ -17,13 +17,14 @@
#include <uuid/uuid.h>
#include "event.h"
+#include "audioconvert.h"
class Track;
class MidiTrack;
class WaveTrack;
class Xml;
class Part;
-class AudioConvertMap;
+//class AudioConvertMap;
// typedef std::multimap<unsigned, Event*, std::less<unsigned> >::iterator iEvent;
@@ -123,7 +124,7 @@ class MidiPart : public Part {
class WavePart : public Part {
// p3.3.31
- //AudioConvertMap _converters;
+ AudioConvertMap _converters;
public:
WavePart(WaveTrack* t);
diff --git a/muse/muse/songfile.cpp b/muse/muse/songfile.cpp
index 4ff4fbcc..2e4a5395 100644
--- a/muse/muse/songfile.cpp
+++ b/muse/muse/songfile.cpp
@@ -990,19 +990,37 @@ void MusE::readToplevels(Xml& xml)
pl->add(part);
}
else if (tag == "pianoroll") {
- startPianoroll(pl);
- toplevels.back().cobject()->readStatus(xml);
- pl = new PartList;
+ // p3.3.34
+ // Do not open if there are no parts.
+ // Had bogus '-1' part index for list edit in med file,
+ // causing list edit to segfault on song load.
+ // Somehow that -1 was put there on write, because the
+ // current part didn't exist anymore, so no index number
+ // could be found for it on write. Watching... may be fixed.
+ // But for now be safe for all the top levels...
+ if(!pl->empty())
+ {
+
+ startPianoroll(pl);
+ toplevels.back().cobject()->readStatus(xml);
+ pl = new PartList;
+ }
}
else if (tag == "drumedit") {
- startDrumEditor(pl);
- toplevels.back().cobject()->readStatus(xml);
- pl = new PartList;
+ if(!pl->empty())
+ {
+ startDrumEditor(pl);
+ toplevels.back().cobject()->readStatus(xml);
+ pl = new PartList;
+ }
}
else if (tag == "listeditor") {
- startListEditor(pl);
- toplevels.back().cobject()->readStatus(xml);
- pl = new PartList;
+ if(!pl->empty())
+ {
+ startListEditor(pl);
+ toplevels.back().cobject()->readStatus(xml);
+ pl = new PartList;
+ }
}
else if (tag == "master") {
startMasterEditor();
@@ -1017,9 +1035,12 @@ void MusE::readToplevels(Xml& xml)
toplevels.back().cobject()->readStatus(xml);
}
else if (tag == "waveedit") {
- startWaveEditor(pl);
- toplevels.back().cobject()->readStatus(xml);
- pl = new PartList;
+ if(!pl->empty())
+ {
+ startWaveEditor(pl);
+ toplevels.back().cobject()->readStatus(xml);
+ pl = new PartList;
+ }
}
else if (tag == "cliplist") {
startClipList();
diff --git a/muse/muse/waveevent.cpp b/muse/muse/waveevent.cpp
index a7a707c8..411f2c44 100644
--- a/muse/muse/waveevent.cpp
+++ b/muse/muse/waveevent.cpp
@@ -149,7 +149,9 @@ void WaveEventBase::write(int level, Xml& xml, const Pos& offset, bool forcePath
//void WaveEventBase::read(unsigned offset, float** buffer, int channel, int n, bool overwrite)
//void WaveEventBase::readAudio(unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
//off_t WaveEventBase::readAudio(SRC_STATE* src_state, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
-off_t WaveEventBase::readAudio(AudioConverter* audConv, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
+//off_t WaveEventBase::readAudio(AudioConverter* audConv, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
+// p3.3.33
+void WaveEventBase::readAudio(WavePart* part, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
{
// Added by Tim. p3.3.17
#ifdef WAVEEVENT_DEBUG_PRC
@@ -159,6 +161,8 @@ off_t WaveEventBase::readAudio(AudioConverter* audConv, off_t sfCurFrame, unsign
// Changed by Tim. p3.3.18
#ifdef USE_SAMPLERATE
+ // TODO:
+ >>>>>>>>>>>+++++++++++++++++++++++++++++
// If we have a valid audio converter then use it to do the processing. Otherwise just a normal seek + read.
if(audConv)
//sfCurFrame = audConv->process(f, sfCurFrame, offset + _spos, buffer, channel, n, doSeek, overwrite);
@@ -171,7 +175,8 @@ off_t WaveEventBase::readAudio(AudioConverter* audConv, off_t sfCurFrame, unsign
sfCurFrame += f.read(channel, buffer, n, overwrite);
}
}
- return sfCurFrame;
+ //return sfCurFrame;
+ return;
/*
unsigned fsrate = f.samplerate();
@@ -428,12 +433,16 @@ off_t WaveEventBase::readAudio(AudioConverter* audConv, off_t sfCurFrame, unsign
#else
if(f.isNull())
- //return;
- return sfCurFrame;
+ return;
+ //return sfCurFrame;
- sfCurFrame = f.seek(offset + _spos, 0);
- sfCurFrame += f.read(channel, buffer, n, overwrite);
- return sfCurFrame;
+ //sfCurFrame = f.seek(offset + _spos, 0);
+ //sfCurFrame += f.read(channel, buffer, n, overwrite);
+ f.seek(offset + _spos, 0);
+ f.read(channel, buffer, n, overwrite);
+
+ //return sfCurFrame;
+ return;
#endif
}
diff --git a/muse/muse/waveevent.h b/muse/muse/waveevent.h
index c68a3923..4ea4918b 100644
--- a/muse/muse/waveevent.h
+++ b/muse/muse/waveevent.h
@@ -15,6 +15,7 @@
#include "eventbase.h"
class AudioConverter;
+class WavePart;
//---------------------------------------------------------
// WaveEvent
@@ -53,7 +54,9 @@ class WaveEventBase : public EventBase {
//virtual void readAudio(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
//virtual off_t readAudio(SRC_STATE* /*src_state*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
// float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
- virtual off_t readAudio(AudioConverter* /*audConv*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
+ //virtual off_t readAudio(AudioConverter* /*audConv*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
+ // float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+ virtual void readAudio(WavePart* /*part*/, unsigned /*offset*/,
float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
};
diff --git a/muse/muse/wavetrack.cpp b/muse/muse/wavetrack.cpp
index 5a0907bb..fbf7b965 100644
--- a/muse/muse/wavetrack.cpp
+++ b/muse/muse/wavetrack.cpp
@@ -93,7 +93,9 @@ void WaveTrack::fetchData(unsigned pos, unsigned samples, float** bp, bool doSee
// Since the buffers are cleared above, just read and add (don't overwrite) the samples.
//event.read(srcOffset, bpp, channels(), nn);
//event.read(srcOffset, bpp, channels(), nn, false);
- event.readAudio(srcOffset, bpp, channels(), nn, doSeek, false);
+ //event.readAudio(srcOffset, bpp, channels(), nn, doSeek, false);
+ // p3.3.33
+ event.readAudio(part, srcOffset, bpp, channels(), nn, doSeek, false);
}
}