From b48c6b0fd6c266f722e58bb51e2f55e6c43ca43b Mon Sep 17 00:00:00 2001 From: James Crook Date: Sat, 4 Nov 2017 17:09:01 +0000 Subject: [PATCH] Clip (and track) colours now persists in .aup file. --- src/WaveClip.cpp | 9 +++++++++ src/WaveTrack.cpp | 9 +++++++-- src/effects/Effect.cpp | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index befca7a40..4a05ab0f7 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -1503,6 +1503,7 @@ bool WaveClip::HandleXMLTag(const wxChar *tag, const wxChar **attrs) if (!wxStrcmp(tag, wxT("waveclip"))) { double dblValue; + long longValue; while (*attrs) { const wxChar *attr = *attrs++; @@ -1519,6 +1520,13 @@ bool WaveClip::HandleXMLTag(const wxChar *tag, const wxChar **attrs) return false; SetOffset(dblValue); } + if (!wxStrcmp(attr, wxT("colorindex"))) + { + if (!XMLValueChecker::IsGoodString(strValue) || + !strValue.ToLong( &longValue)) + return false; + SetColourIndex(longValue); + } } return true; } @@ -1555,6 +1563,7 @@ void WaveClip::WriteXML(XMLWriter &xmlFile) const { xmlFile.StartTag(wxT("waveclip")); xmlFile.WriteAttr(wxT("offset"), mOffset, 8); + xmlFile.WriteAttr(wxT("colorindex"), mColourIndex ); mSequence->WriteXML(xmlFile); mEnvelope->WriteXML(xmlFile); diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index a93da472c..1c4ad2965 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -1765,7 +1765,11 @@ bool WaveTrack::HandleXMLTag(const wxChar *tag, const wxChar **attrs) else if (!wxStrcmp(attr, wxT("autosaveid")) && XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) mAutoSaveIdent = (int) nValue; - + else if (!wxStrcmp(attr, wxT("colorindex")) && + XMLValueChecker::IsGoodString(strValue) && + strValue.ToLong(&nValue)) + // Don't use SetWaveColorIndex as it sets the clips too. + mWaveColorIndex = nValue; } // while #ifdef EXPERIMENTAL_OUTPUT_DISPLAY VirtualStereoInit(); @@ -1846,6 +1850,7 @@ void WaveTrack::WriteXML(XMLWriter &xmlFile) const xmlFile.WriteAttr(wxT("rate"), mRate); xmlFile.WriteAttr(wxT("gain"), (double)mGain); xmlFile.WriteAttr(wxT("pan"), (double)mPan); + xmlFile.WriteAttr(wxT("colorindex"), mWaveColorIndex ); for (const auto &clip : mClips) { @@ -2273,7 +2278,7 @@ Sequence* WaveTrack::GetSequenceAtX(int xcoord) WaveClip* WaveTrack::CreateClip() { - mClips.push_back(make_movable(mDirManager, mFormat, mRate,0 /*colurindex*/)); + mClips.push_back(make_movable(mDirManager, mFormat, mRate, GetWaveColorIndex())); return mClips.back().get(); } diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index ecf65522e..961cc5567 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1523,6 +1523,7 @@ bool Effect::ProcessTrack(int count, auto chans = std::min(mNumAudioOut, mNumChannels); std::unique_ptr genLeft, genRight; + decltype(len) genLength = 0; bool isGenerator = GetType() == EffectTypeGenerate; bool isProcessor = GetType() == EffectTypeProcess; @@ -1543,9 +1544,12 @@ bool Effect::ProcessTrack(int count, // Create temporary tracks genLeft = mFactory->NewWaveTrack(left->GetSampleFormat(), left->GetRate()); + genLeft->SetWaveColorIndex( left->GetWaveColorIndex() ); + if (right) { genRight = mFactory->NewWaveTrack(right->GetSampleFormat(), right->GetRate()); + genRight->SetWaveColorIndex( right->GetWaveColorIndex() ); } }