From: <pst...@us...> - 2009-01-20 03:46:34
|
Revision: 691 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=691&view=rev Author: pstieber Date: 2009-01-20 03:46:28 +0000 (Tue, 20 Jan 2009) Log Message: ----------- 1. Added class and function comment headers. 2. Used pre increment instead of post increment for loop variables. 3. Made some style changes (e -> pEvent...). 4. Translated some German. Modified Paths: -------------- trunk/jazz/src/Command.cpp trunk/jazz/src/Command.h Modified: trunk/jazz/src/Command.cpp =================================================================== --- trunk/jazz/src/Command.cpp 2009-01-20 03:39:55 UTC (rev 690) +++ trunk/jazz/src/Command.cpp 2009-01-20 03:46:28 UTC (rev 691) @@ -75,8 +75,9 @@ void tCommand::ExecuteTrack(JZTrack* pTrack) { tEventIterator Iterator(pTrack); - JZEvent* pEvent = - Iterator.Range(mpFilter->GetFromClock(), mpFilter->GetToClock()); + JZEvent* pEvent = Iterator.Range( + mpFilter->GetFromClock(), + mpFilter->GetToClock()); while (pEvent) { if (mpFilter->IsSelected(pEvent)) @@ -147,64 +148,71 @@ //***************************************************************************** // tScale //***************************************************************************** - // c d e f g a b +//----------------------------------------------------------------------------- +// Description: +// This is a C-major scale. +// c d e f g a b +//----------------------------------------------------------------------------- static const int CMajor[12] = { 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 }; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tScale::Init(int ScaleNr, JZFilter* pFilter) { - int i; - - for (i = 0; i < 12; i++) + for (int i = 0; i < 12; ++i) { ScaleKeys[i] = 0; } if (ScaleNr == gScaleChromatic) { - for (i = 0; i < 12; i++) + for (int i = 0; i < 12; ++i) + { ScaleKeys[i] = 1; + } } - else if (ScaleNr == gScaleSelected) { - int found = 0; + bool Found = false; tSelectedKeys cmd(pFilter); cmd.Execute(0); - for (i = 0; i < 128; i++) + for (int i = 0; i < 128; ++i) { if (cmd.Keys[i]) { ScaleKeys[ i % 12 ] = 1; - found = 1; + Found = true; } } - if (!found) + if (!Found) { ScaleKeys[0] = 1; // avoid loop in Member() } } - else { - for (i = 0; i < 12; i++) + for (int i = 0; i < 12; ++i) + { ScaleKeys[ (i + ScaleNr) % 12 ] = CMajor[i]; + } } } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tScale::Analyze(JZFilter* pFilter) { - long keys[12]; - for (int i = 0; i < 12; i++) + long Keys[12]; + for (int i = 0; i < 12; ++i) { - keys[i] = 0; + Keys[i] = 0; } tSelectedKeys cmd(pFilter); cmd.Execute(0); - for (int i = 0; i < 128; i++) + for (int i = 0; i < 128; ++i) { - keys[i % 12] += cmd.Keys[i]; + Keys[i % 12] += cmd.Keys[i]; } long Min = std::numeric_limits<long>::max(); @@ -218,7 +226,7 @@ { if (Scale.ScaleKeys[i] == 0) { - Error += keys[i]; + Error += Keys[i]; } } if (Error < Min) @@ -231,78 +239,91 @@ return ScaleIndex; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tScale::Next(int Key) { do - ++ Key; - while (!Member(Key)); + { + ++Key; + } while (!Member(Key)); return Key; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tScale::Prev(int Key) { do - -- Key; - while (!Member(Key)); + { + --Key; + } while (!Member(Key)); return Key; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tScale::Transpose(int Key, int Steps) { int Offset = 0; while (!Member(Key)) { - ++ Key; - ++ Offset; + ++Key; + ++Offset; } while (Steps > 0) { Key = Next(Key); - -- Steps; + --Steps; } while (Steps < 0) { Key = Prev(Key); - ++ Steps; + ++Steps; } return Key - Offset; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tScale::FitInto(int Key) { int Offset = 0; while (!Member(Key)) { - ++ Offset; + ++Offset; if (Offset & 1) + { Key += Offset; + } else + { Key -= Offset; + } } return Key; } -// *********************************************************************** +//***************************************************************************** // tCmdShift -// *********************************************************************** - -tCmdShift::tCmdShift(JZFilter* pFilter, long dclk) - : tCommand(pFilter) +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +tCmdShift::tCmdShift(JZFilter* pFilter, long DeltaClock) + : tCommand(pFilter), + mDeltaClock(DeltaClock) { - DeltaClock = dclk; } void tCmdShift::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - JZEvent* c = pEvent->Copy(); + JZEvent* pEventCopy = pEvent->Copy(); pTrack->Kill(pEvent); - c->SetClock(c->GetClock() + DeltaClock); - pTrack->Put(c); + pEventCopy->SetClock(pEventCopy->GetClock() + mDeltaClock); + pTrack->Put(pEventCopy); } // ************************************************************************ @@ -694,7 +715,7 @@ { if (pEvent->IsKeyOn()) { - // only echo note events + // Only echo note events. pKeyOn = (tKeyOn *)pEvent->Copy(); pKeyOn->SetClock(pKeyOn->GetClock()+ clockDelay * i); pKeyOn->SetVelocity( @@ -853,9 +874,9 @@ if (s && d) { - // Events nach tmp kopieren tEventArray tmp; { + // Events after temporary copy. tEventIterator Iterator(s); long DeltaClock = StartClock - mpFilter->GetFromClock(); JZEvent* pEvent = @@ -882,8 +903,6 @@ } } - // ggf Freien Platz einfuegen - if (InsertSpace && d->GetLastClock() > StartClock) { tEventIterator Iterator(d); @@ -903,10 +922,9 @@ d->Cleanup(); } - // ggf Quelle loeschen - if (EraseSource) { + // Delete source. tEventIterator Iterator(s); JZEvent* pEvent = Iterator.Range(mpFilter->GetFromClock(), mpFilter->GetToClock()); while (pEvent) @@ -920,10 +938,9 @@ s->Cleanup(); } - // ggf Ziel loeschen - if (EraseDestin) { + // Delete destination. tEventIterator Iterator(d); JZEvent* pEvent = Iterator.Range(StartClock, StopClock); while (pEvent) @@ -937,7 +954,7 @@ d->Cleanup(); } - // tmp und Zieltrack zusammenmischen, aufraeumen + // tmp track and target mix, aufraeumen d->Merge(&tmp); d->Cleanup(); Modified: trunk/jazz/src/Command.h =================================================================== --- trunk/jazz/src/Command.h 2009-01-20 03:39:55 UTC (rev 690) +++ trunk/jazz/src/Command.h 2009-01-20 03:46:28 UTC (rev 691) @@ -32,6 +32,8 @@ class JZBarInfo; class tKeyOn; +//***************************************************************************** +//***************************************************************************** class tScale { public: @@ -50,7 +52,8 @@ static int Analyze(JZFilter* pFilter); // returns ScaleNr }; - +//***************************************************************************** +//***************************************************************************** class tCommand { public: @@ -74,16 +77,22 @@ bool mReverse; }; - +//***************************************************************************** +//***************************************************************************** class tCmdShift : public tCommand { - long DeltaClock; public: + tCmdShift(JZFilter* pFilter, long DeltaClock); virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); + + private: + + long mDeltaClock; }; - +//***************************************************************************** +//***************************************************************************** class tCmdErase : public tCommand { public: @@ -93,6 +102,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; +//***************************************************************************** +//***************************************************************************** class tCmdVelocity : public tCommand { public: @@ -101,7 +112,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; - +//***************************************************************************** +//***************************************************************************** class tCmdLength : public tCommand { public: @@ -110,7 +122,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; - +//***************************************************************************** +//***************************************************************************** class tCmdSeqLength : public tCommand { public: @@ -120,8 +133,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; - - +//***************************************************************************** +//***************************************************************************** class tCmdMidiDelay : public tCommand { public: @@ -137,6 +150,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; +//***************************************************************************** +//***************************************************************************** class tCmdConvertToModulation : public tCommand { public: @@ -145,10 +160,8 @@ virtual void ExecuteTrack(JZTrack* pTrack); }; - - - - +//***************************************************************************** +//***************************************************************************** class tCmdCleanup : public tCommand { long lengthLimit; @@ -160,7 +173,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; - +//***************************************************************************** +//***************************************************************************** class tCmdSearchReplace : public tCommand { short fr, to; @@ -169,7 +183,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; - +//***************************************************************************** +//***************************************************************************** class tCmdQuantize : public tCommand { long Quantize(long Clock, int islen); @@ -183,7 +198,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; - +//***************************************************************************** +//***************************************************************************** class tCmdTranspose : public tCommand { public: @@ -198,7 +214,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; - +//***************************************************************************** +//***************************************************************************** class tCmdSetChannel : public tCommand { public: @@ -207,7 +224,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; - +//***************************************************************************** +//***************************************************************************** class tCmdCopyToBuffer : public tCommand { public: @@ -221,8 +239,8 @@ tEventArray* mpBuffer; }; - - +//***************************************************************************** +//***************************************************************************** class tCmdCopy : public tCommand { public: @@ -238,8 +256,8 @@ virtual void ExecuteTrack(JZTrack* pTrack); }; - - +//***************************************************************************** +//***************************************************************************** class tCmdExchLeftRight : public tCommand { public: @@ -247,6 +265,8 @@ virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; +//***************************************************************************** +//***************************************************************************** class tCmdExchUpDown : public tCommand { public: @@ -254,6 +274,8 @@ virtual void ExecuteTrack(JZTrack* pTrack); }; +//***************************************************************************** +//***************************************************************************** class tCmdMapper : public tCommand { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |