From: <pst...@us...> - 2008-04-20 00:00:33
|
Revision: 467 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=467&view=rev Author: pstieber Date: 2008-04-19 17:00:32 -0700 (Sat, 19 Apr 2008) Log Message: ----------- 1. Removed the old key on dialog implementation (tKeyOnDlg) and replaced its use with JZKeyOnDialog. 2. Encapsulated the following members of JZBarInfo by making them private, renaming them, and adding accessors: BarNr -> mBarIndex Clock -> mClock CountsPerBar -> mCountsPerBar TicksPerQuarter -> mTicksPerQuarter TicksPerBar -> mTicksPerBar Iterator -> mIterator e -> mpEvent 3. Encapsulated the following members of JZSong by making them private, renaming them, and adding accessors: MaxQuarters -> mMaxQuarters TicksPerQuarter -> mTicksPerQuarter intro_length -> mIntroLength 4. Changed JZSong::Clock2String to ClockToString and changed it to fill a std::string instead of a char*. 5. Changed JZSong::String2Clock to StringToClockand changed it to process a std::string instead of a char*. 6. Capitalized the LAST_CLOCK and KILLED_CLOCK macros. 7. Made the edb, Copy, BarInfo, GetValue, GetEventlength, GetLength, GetPitch, GetPen, and GetBrush constant in JZEvent. 8. Prefixed the tKeyOn event members with m. 9. Changed tKeyDlg to JZKeyDialog. 10. Changed Key2Str to KeyToString and Str2Key to StringToKey and changed the functions to use std::string instead of char*. 11. Started fixing up the rhythm class. 12. Changed some tSysEx pointer arguments to constant in the synthesizer class. 13. Changed JZTrack::GetLastClock to const. 14. Changed the simple event array member of the event iterator class to constant. 15. Made cosmetic indentation changes. Modified Paths: -------------- trunk/jazz/src/Audio.cpp trunk/jazz/src/ClockDialog.cpp trunk/jazz/src/Command.cpp trunk/jazz/src/Command.h trunk/jazz/src/ControlEdit.cpp trunk/jazz/src/Dialogs/KeyOnDialog.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/EventWindow.cpp trunk/jazz/src/Events.cpp trunk/jazz/src/Events.h trunk/jazz/src/Harmony.cpp trunk/jazz/src/HarmonyBrowserAnalyzer.cpp trunk/jazz/src/KeyDialog.cpp trunk/jazz/src/KeyDialog.h trunk/jazz/src/KeyStringConverters.cpp trunk/jazz/src/KeyStringConverters.h trunk/jazz/src/MeasureChoice.cpp trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/Player.cpp trunk/jazz/src/Player.h trunk/jazz/src/Resources.h trunk/jazz/src/Rhythm.cpp trunk/jazz/src/Rhythm.h trunk/jazz/src/SampleWindow.cpp trunk/jazz/src/Song.cpp trunk/jazz/src/Song.h trunk/jazz/src/Synth.cpp trunk/jazz/src/Synth.h trunk/jazz/src/Track.cpp trunk/jazz/src/Track.h trunk/jazz/src/TrackFrame.cpp trunk/jazz/src/TrackWindow.cpp trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2008-04-19 23:22:59 UTC (rev 466) +++ trunk/jazz/src/Audio.cpp 2008-04-20 00:00:32 UTC (rev 467) @@ -424,10 +424,10 @@ } event_index++; - tKeyOn *k = e->IsKeyOn(); - if (k && num_voices < MAXPOLY) + tKeyOn* pKeyOn = e->IsKeyOn(); + if (pKeyOn && num_voices < MAXPOLY) { - voices[num_voices++]->Start(samples[k->Key], k->GetClock()); + voices[num_voices++]->Start(samples[pKeyOn->mKey], pKeyOn->GetClock()); } } @@ -532,12 +532,17 @@ tEventIterator it(t); JZEvent *e = it.First(); - while (e) { - tKeyOn *k = e->IsKeyOn(); - if (k) { - k->Length = (int)Samples2Ticks(samples[k->Key]->GetLength()); - if (k->Length < 15) // invisble? - k->Length = 15; + while (e) + { + tKeyOn* pKeyOn = e->IsKeyOn(); + if (pKeyOn) + { + pKeyOn->mLength = + (int)Samples2Ticks(samples[pKeyOn->mKey]->GetLength()); + if (pKeyOn->mLength < 15) // invisble? + { + pKeyOn->mLength = 15; + } } e = it.Next(); } @@ -840,13 +845,13 @@ e = iter.Next(); } // add a noteon - tKeyOn *k = new tKeyOn( + tKeyOn* pKeyOn = new tKeyOn( frc, track->Channel - 1, key, 64, (unsigned short)(toc - frc)); - track->Put(k); + track->Put(pKeyOn); track->Cleanup(); // repaint trackwin @@ -1006,7 +1011,7 @@ { char buf[500]; sprintf(buf, "%d ", i+1); - //Key2Str(i, buf + strlen(buf)); +// KeyToString(i, buf + strlen(buf)); sprintf(buf + strlen(buf), set.samples[i]->GetLabel()); return copystring(buf); } Modified: trunk/jazz/src/ClockDialog.cpp =================================================================== --- trunk/jazz/src/ClockDialog.cpp 2008-04-19 23:22:59 UTC (rev 466) +++ trunk/jazz/src/ClockDialog.cpp 2008-04-20 00:00:32 UTC (rev 467) @@ -28,6 +28,10 @@ #include "DeprecatedStringUtils.h" #include "DeprecatedWx/proplist.h" +#include <string> + +using namespace std; + //***************************************************************************** // Description: // This is the clock dialog class declaration. @@ -36,9 +40,9 @@ //----------------------------------------------------------------------------- JZClockDialog::JZClockDialog(JZSong* pSong, const char* pTitle, int Clock) { - char Buffer[500]; - pSong->Clock2String(Clock, Buffer); - mpString = copystring(Buffer); + string ClockString; + pSong->ClockToString(Clock, ClockString); + mpString = copystring(ClockString.c_str()); mpTitle = pTitle; mpSong = pSong; } @@ -64,5 +68,5 @@ //----------------------------------------------------------------------------- int JZClockDialog::GetClock() { - return mpSong->String2Clock(mpString); + return mpSong->StringToClock(mpString); } Modified: trunk/jazz/src/Command.cpp =================================================================== --- trunk/jazz/src/Command.cpp 2008-04-19 23:22:59 UTC (rev 466) +++ trunk/jazz/src/Command.cpp 2008-04-20 00:00:32 UTC (rev 467) @@ -137,10 +137,10 @@ //----------------------------------------------------------------------------- void tSelectedKeys::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tKeyOn* pKey = pEvent->IsKeyOn(); - if (pKey) + tKeyOn* pKeyOn = pEvent->IsKeyOn(); + if (pKeyOn) { - Keys[pKey->Key] += pKey->Length; + Keys[pKeyOn->mKey] += pKeyOn->mLength; } } @@ -150,12 +150,14 @@ // 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 *f) +void tScale::Init(int ScaleNr, JZFilter* pFilter) { int i; for (i = 0; i < 12; i++) + { ScaleKeys[i] = 0; + } if (ScaleNr == gScaleChromatic) { @@ -166,7 +168,7 @@ else if (ScaleNr == gScaleSelected) { int found = 0; - tSelectedKeys cmd(f); + tSelectedKeys cmd(pFilter); cmd.Execute(0); for (i = 0; i < 128; i++) { @@ -190,7 +192,7 @@ } -int tScale::Analyze(JZFilter *f) +int tScale::Analyze(JZFilter* pFilter) { long keys[12]; for (int i = 0; i < 12; i++) @@ -198,7 +200,7 @@ keys[i] = 0; } - tSelectedKeys cmd(f); + tSelectedKeys cmd(pFilter); cmd.Execute(0); for (int i = 0; i < 128; i++) { @@ -289,26 +291,26 @@ // tCmdShift // *********************************************************************** -tCmdShift::tCmdShift(JZFilter *f, long dclk) - : tCommand(f) +tCmdShift::tCmdShift(JZFilter* pFilter, long dclk) + : tCommand(pFilter) { DeltaClock = dclk; } -void tCmdShift::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdShift::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - JZEvent *c = e->Copy(); - t->Kill(e); + JZEvent* c = pEvent->Copy(); + pTrack->Kill(pEvent); c->SetClock(c->GetClock() + DeltaClock); - t->Put(c); + pTrack->Put(c); } // ************************************************************************ // tCmdErase // ************************************************************************ -tCmdErase::tCmdErase(JZFilter *f, int lvsp) - : tCommand(f) +tCmdErase::tCmdErase(JZFilter* pFilter, int lvsp) + : tCommand(pFilter) { LeaveSpace = lvsp; } @@ -318,26 +320,26 @@ tCommand::Execute(NewUndo); if (!LeaveSpace) { - JZFilter f(mpFilter); - f.FromClock = mpFilter->ToClock; - f.ToClock = mpSong->GetLastClock() + 1; + JZFilter Filter(mpFilter); + Filter.FromClock = mpFilter->ToClock; + Filter.ToClock = mpSong->GetLastClock() + 1; long DeltaClock = mpFilter->FromClock - mpFilter->ToClock; - tCmdShift shift(&f, DeltaClock); + tCmdShift shift(&Filter, DeltaClock); shift.Execute(0); } } -void tCmdErase::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdErase::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - t->Kill(e); + pTrack->Kill(pEvent); } // ************************************************************************ // tCmdQuantize // ************************************************************************ -tCmdQuantize::tCmdQuantize(JZFilter *f, long clks, int grov, int dly) - : tCommand(f) +tCmdQuantize::tCmdQuantize(JZFilter* pFilter, long clks, int grov, int dly) + : tCommand(pFilter) { QntClocks = clks; Groove = grov; @@ -357,22 +359,22 @@ return Clock > minclk ? Clock : minclk; } -void tCmdQuantize::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdQuantize::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tKeyOn *k; - if ((k = e->IsKeyOn()) != 0) + tKeyOn* pKeyOn; + if ((pKeyOn = pEvent->IsKeyOn()) != 0) { - k = (tKeyOn *)e->Copy(); + pKeyOn = (tKeyOn *)pEvent->Copy(); if (NoteStart) { - k->SetClock(Quantize(k->GetClock(), 0)); + pKeyOn->SetClock(Quantize(pKeyOn->GetClock(), 0)); } if (NoteLength) { - k->Length = Quantize(k->Length, 2); + pKeyOn->mLength = Quantize(pKeyOn->mLength, 2); } - t->Kill(e); - t->Put(k); + pTrack->Kill(pEvent); + pTrack->Put(pKeyOn); } } @@ -380,35 +382,37 @@ // tCmdTranspose // ************************************************************************ -tCmdTranspose::tCmdTranspose(JZFilter *f, int notes, int ScaleNr, int fit) - : tCommand(f) +tCmdTranspose::tCmdTranspose(JZFilter* pFilter, int notes, int ScaleNr, int fit) + : tCommand(pFilter) { Scale.Init(ScaleNr, mpFilter); Notes = notes; FitIntoScale = fit; } -void tCmdTranspose::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdTranspose::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tKeyOn *k; - if (e->IsKeyOn()) + tKeyOn* pKeyOn; + if (pEvent->IsKeyOn()) { - k = (tKeyOn *)e->Copy(); + pKeyOn = (tKeyOn *)pEvent->Copy(); if (FitIntoScale) { - k->Key += Notes; - k->Key = Scale.FitInto(k->Key); + pKeyOn->mKey += Notes; + pKeyOn->mKey = Scale.FitInto(pKeyOn->mKey); } else if (Notes) - k->Key = Scale.Transpose(k->Key, Notes); - t->Kill(e); - t->Put(k); + { + pKeyOn->mKey = Scale.Transpose(pKeyOn->mKey, Notes); + } + pTrack->Kill(pEvent); + pTrack->Put(pKeyOn); } // SN++ Aftertouch tKeyPressure *a; - if (e->IsKeyPressure()) + if (pEvent->IsKeyPressure()) { - a = (tKeyPressure *)e->Copy(); + a = (tKeyPressure *)pEvent->Copy(); if (FitIntoScale) { a->Key += Notes; @@ -416,8 +420,8 @@ } else if (Notes) a->Key = Scale.Transpose(a->Key, Notes); - t->Kill(e); - t->Put(a); + pTrack->Kill(pEvent); + pTrack->Put(a); } // } @@ -426,22 +430,22 @@ // tCmdSetChannel // ************************************************************************ -tCmdSetChannel::tCmdSetChannel(JZFilter *f, int chan) - : tCommand(f) +tCmdSetChannel::tCmdSetChannel(JZFilter* pFilter, int chan) + : tCommand(pFilter) { NewChannel = chan; } -void tCmdSetChannel::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdSetChannel::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tChannelEvent *c; + tChannelEvent* c; - if ((c = e->IsChannelEvent()) != 0) + if ((c = pEvent->IsChannelEvent()) != 0) { - c = (tChannelEvent *)e->Copy(); + c = (tChannelEvent *)pEvent->Copy(); c->Channel = NewChannel; - t->Kill(e); - t->Put(c); + pTrack->Kill(pEvent); + pTrack->Put(c); } } @@ -449,34 +453,40 @@ // tCmdVelocity // ************************************************************************ -tCmdVelocity::tCmdVelocity(JZFilter *f, int from, int to, int m) - : tCommand(f) +tCmdVelocity::tCmdVelocity(JZFilter* pFilter, int from, int to, int m) + : tCommand(pFilter) { FromValue = from; ToValue = to; Mode = m; } -void tCmdVelocity::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdVelocity::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tKeyOn *k; + tKeyOn* pKeyOn; - if (e->IsKeyOn() != 0) + if (pEvent->IsKeyOn() != 0) { - k = (tKeyOn *)e->Copy(); + pKeyOn = (tKeyOn *)pEvent->Copy(); long val = 0; if (ToValue <= 0) val = FromValue; else - val = Interpolate(k->GetClock(), FromValue, ToValue); - switch (Mode) { - case 0: break; - case 1: val = k->Veloc + val; break; - case 2: val = k->Veloc - val; break; + val = Interpolate(pKeyOn->GetClock(), FromValue, ToValue); + switch (Mode) + { + case 0: + break; + case 1: + val = pKeyOn->mVelocity + val; + break; + case 2: + val = pKeyOn->mVelocity - val; + break; } - k->Veloc = val < 1 ? 1 : (val > 127 ? 127 : val); - t->Kill(e); - t->Put(k); + pKeyOn->mVelocity = val < 1 ? 1 : (val > 127 ? 127 : val); + pTrack->Kill(pEvent); + pTrack->Put(pKeyOn); } } @@ -484,35 +494,41 @@ // tCmdLength // ************************************************************************ -tCmdLength::tCmdLength(JZFilter *f, int from, int to, int m) - : tCommand(f) +tCmdLength::tCmdLength(JZFilter* pFilter, int from, int to, int m) + : tCommand(pFilter) { FromValue = from; ToValue = to; Mode = m; } -void tCmdLength::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdLength::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tKeyOn *k; + tKeyOn* pKeyOn; - if (e->IsKeyOn() != 0) + if (pEvent->IsKeyOn() != 0) { - k = (tKeyOn *)e->Copy(); + pKeyOn = (tKeyOn *)pEvent->Copy(); long val = 0; if (ToValue <= 0) val = FromValue; else - val = Interpolate(k->GetClock(), FromValue, ToValue); - switch (Mode) { - case 0: break; - case 1: val = k->Length + val; break; - case 2: val = k->Length - val; break; + val = Interpolate(pKeyOn->GetClock(), FromValue, ToValue); + switch (Mode) + { + case 0: + break; + case 1: + val = pKeyOn->mLength + val; + break; + case 2: + val = pKeyOn->mLength - val; + break; } - k->Length = val < 1 ? 1 : val; - t->Kill(e); - t->Put(k); + pKeyOn->mLength = val < 1 ? 1 : val; + pTrack->Kill(pEvent); + pTrack->Put(pKeyOn); } } @@ -524,8 +540,8 @@ // by factor "scale" from starting point "startClock" // ************************************************************************ -tCmdSeqLength::tCmdSeqLength(JZFilter *f, double scale) - : tCommand(f) +tCmdSeqLength::tCmdSeqLength(JZFilter* pFilter, double scale) + : tCommand(pFilter) { this->scale=scale; this->startClock=-1000; @@ -533,21 +549,22 @@ /** move an event according to startclock and scale */ -void tCmdSeqLength::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdSeqLength::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { // Make a copy of the current event. - JZEvent *k; - k = (tKeyOn *)e->Copy(); + JZEvent* k; + k = (tKeyOn *)pEvent->Copy(); //little hack, if clock is -1000 it means set startclock from the first event. - if(startClock==-1000){ - startClock=k->GetClock(); + if(startClock==-1000) + { + startClock = k->GetClock(); } //calculate the new start clock, move the new event and kill the old one - k->SetClock((long int)(((k->GetClock()-startClock)*scale) + startClock ) ); - t->Kill(e); - t->Put(k); + k->SetClock((long int)(((k->GetClock() - startClock) * scale) + startClock)); + pTrack->Kill(pEvent); + pTrack->Put(k); } @@ -558,20 +575,20 @@ // to a pitch bend/volume control sequence instead // ************************************************************************ -tCmdConvertToModulation::tCmdConvertToModulation(JZFilter *f) - : tCommand(f) +tCmdConvertToModulation::tCmdConvertToModulation(JZFilter* pFilter) + : tCommand(pFilter) { } //need to override executetrack, since we have begin/end behaviour in this filter -void tCmdConvertToModulation::ExecuteTrack(JZTrack *t) +void tCmdConvertToModulation::ExecuteTrack(JZTrack* pTrack) { //JAVE:iterate over all events, make a long event from start until stop of the sequence, //convert all note-on messages to a pitch bend/volume controller pair, velocity -> volume //make a volume off controller at the end of the current event - tEventIterator Iterator(t); - JZEvent *e = Iterator.Range(mpFilter->FromClock, mpFilter->ToClock); + tEventIterator Iterator(pTrack); + JZEvent* pEvent = Iterator.Range(mpFilter->FromClock, mpFilter->ToClock); long startclock=-1; long endclock=-1; unsigned char channel=0; @@ -595,42 +612,49 @@ long startvelocity=0; long startkey=0; - while (e) + while (pEvent) { - if (mpFilter->IsSelected(e) && e->IsKeyOn()) + if (mpFilter->IsSelected(pEvent) && pEvent->IsKeyOn()) + { + if (startclock == -1) { - if (startclock == -1) - { - startclock=e->IsKeyOn()->GetClock(); - startvelocity=e->IsKeyOn()->Veloc; - channel=e->IsKeyOn()->Channel; - startkey=e->IsKeyOn()->Key; - previouspitch=e->GetPitch(); - } - pitchdiff=e->GetPitch()-previouspitch; + startclock = pEvent->IsKeyOn()->GetClock(); + startvelocity = pEvent->IsKeyOn()->mVelocity; + channel = pEvent->IsKeyOn()->Channel; + startkey = pEvent->IsKeyOn()->mKey; + previouspitch = pEvent->GetPitch(); + } + pitchdiff = pEvent->GetPitch()-previouspitch; - tPitch* pitchmodulation=0; - pitchmodulation = new tPitch(e->GetClock(), channel, pitchsteparray[pitchdiff+4]); + tPitch* pitchmodulation=0; + pitchmodulation = new tPitch( + pEvent->GetClock(), + channel, + pitchsteparray[pitchdiff + 4]); - t->Put(pitchmodulation); + pTrack->Put(pitchmodulation); + pTrack->Kill(pEvent); //remove the old event - t->Kill(e); //remove the old event + pTrack->Put(new tControl(pEvent->GetClock(), channel, 0x07, pEvent->IsKeyOn()->mVelocity)); + pTrack->Put(new tControl(pEvent->GetClock() + pEvent->IsKeyOn()->mLength, channel, 0x07, 0)); - t->Put(new tControl(e->GetClock(), channel, 0x07, e->IsKeyOn()->Veloc)); - t->Put(new tControl(e->GetClock()+e->IsKeyOn()->Length, channel, 0x07,0)); - - lastlength=e->IsKeyOn()->Length; - endclock=e->GetClock(); - previouspitch=e->GetPitch(); - } - //ExecuteEvent(t, e); - e = Iterator.Next(); + lastlength = pEvent->IsKeyOn()->mLength; + endclock = pEvent->GetClock(); + previouspitch = pEvent->GetPitch(); + } + //ExecuteEvent(pTrack, pEvent); + pEvent = Iterator.Next(); } //now insert the new long event - tKeyOn* longevent = new tKeyOn(startclock, channel, startkey, startvelocity, endclock-startclock+lastlength ); - t->Put(longevent); - t->Cleanup(); + tKeyOn* longevent = new tKeyOn( + startclock, + channel, + startkey, + startvelocity, + endclock - startclock + lastlength); + pTrack->Put(longevent); + pTrack->Cleanup(); } // ************************************************************************ @@ -638,27 +662,31 @@ // JAVE this is a simple midi delay line // ************************************************************************ -tCmdMidiDelay::tCmdMidiDelay(JZFilter *f, double scale, long clockDelay, int repeat) - : tCommand(f) +tCmdMidiDelay::tCmdMidiDelay( + JZFilter* pFilter, + double scale, + long clockDelay, + int repeat) + : tCommand(pFilter) { this->scale=scale; this->clockDelay=clockDelay; this->repeat=repeat; } -void tCmdMidiDelay::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdMidiDelay::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tKeyOn *k; + tKeyOn* pKeyOn; for (int i = 1; i < repeat; ++i) { - if (e->IsKeyOn()) + if (pEvent->IsKeyOn()) { - //only echo note events - k = (tKeyOn *)e->Copy(); - k->SetClock(k->GetClock()+ clockDelay * i); - k->Veloc = (unsigned char)(pow(scale, i) * k->Veloc); - t->Put(k); + // only echo note events + pKeyOn = (tKeyOn *)pEvent->Copy(); + pKeyOn->SetClock(pKeyOn->GetClock()+ clockDelay * i); + pKeyOn->mVelocity = (unsigned char)(pow(scale, i) * pKeyOn->mVelocity); + pTrack->Put(pKeyOn); } } } @@ -669,40 +697,42 @@ // tCmdCleanup // ************************************************************************ -tCmdCleanup::tCmdCleanup(JZFilter *f, long clks, int so) - : tCommand(f) +tCmdCleanup::tCmdCleanup(JZFilter* pFilter, long clks, int so) + : tCommand(pFilter) { lengthLimit = clks; shortenOverlaps = so; } -void tCmdCleanup::ExecuteTrack(JZTrack *t) +void tCmdCleanup::ExecuteTrack(JZTrack* pTrack) { memset(prev_note, 0, sizeof(prev_note)); - tCommand::ExecuteTrack(t); + tCommand::ExecuteTrack(pTrack); } -void tCmdCleanup::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdCleanup::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tKeyOn *k; - if ((k = e->IsKeyOn()) != 0) + tKeyOn* pKeyOn; + if ((pKeyOn = pEvent->IsKeyOn()) != 0) { - if (k->Length < lengthLimit) { + if (pKeyOn->mLength < lengthLimit) + { // remove short notes - t->Kill(e); + pTrack->Kill(pEvent); } - else if (shortenOverlaps) { + else if (shortenOverlaps) + { // shorten length of overlapping notes - tKeyOn *p = prev_note[k->Channel][k->Key]; - if (p && p->GetClock() + p->Length >= k->GetClock()) + tKeyOn *p = prev_note[pKeyOn->Channel][pKeyOn->mKey]; + if (p && p->GetClock() + p->mLength >= pKeyOn->GetClock()) { - p->Length = k->GetClock() - p->GetClock() - 1; - if (p->Length < lengthLimit) + p->mLength = pKeyOn->GetClock() - p->GetClock() - 1; + if (p->mLength < lengthLimit) { - t->Kill(p); + pTrack->Kill(p); } } - prev_note[k->Channel][k->Key] = k; + prev_note[pKeyOn->Channel][pKeyOn->mKey] = pKeyOn; } } } @@ -711,24 +741,24 @@ // tCmdSearchReplace // ************************************************************************ -tCmdSearchReplace::tCmdSearchReplace(JZFilter *f, short sf, short st) - : tCommand(f) +tCmdSearchReplace::tCmdSearchReplace(JZFilter* pFilter, short sf, short st) + : tCommand(pFilter) { fr = sf; to = st; } -void tCmdSearchReplace::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdSearchReplace::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { tControl *ctrl; - if ((ctrl = e->IsControl()) != 0) + if ((ctrl = pEvent->IsControl()) != 0) { if (ctrl->Control == fr) { tControl *copy = (tControl *)ctrl->Copy(); copy->Control = to; - t->Kill(ctrl); - t->Put(copy); + pTrack->Kill(ctrl); + pTrack->Put(copy); } } } @@ -756,8 +786,8 @@ -tCmdCopy::tCmdCopy(JZFilter *f, long dt, long dc) - : tCommand(f) +tCmdCopy::tCmdCopy(JZFilter* pFilter, long dt, long dc) + : tCommand(pFilter) { DestTrack = dt; DestClock = dc; @@ -808,24 +838,24 @@ { tEventIterator Iterator(s); long DeltaClock = StartClock - mpFilter->FromClock; - JZEvent *e = Iterator.Range(mpFilter->FromClock, mpFilter->ToClock); - while (e) + JZEvent* pEvent = Iterator.Range(mpFilter->FromClock, mpFilter->ToClock); + while (pEvent) { - long NewClock = e->GetClock() + DeltaClock; + long NewClock = pEvent->GetClock() + DeltaClock; if (NewClock >= StopClock) break; - if (mpFilter->IsSelected(e)) + if (mpFilter->IsSelected(pEvent)) { - JZEvent* cpy = e->Copy(); + JZEvent* cpy = pEvent->Copy(); cpy->SetClock(NewClock); tmp.Put(cpy); } - e = Iterator.Next(); - if (!e) + pEvent = Iterator.Next(); + if (!pEvent) { - e = Iterator.First(); + pEvent = Iterator.First(); DeltaClock += mpFilter->ToClock - mpFilter->FromClock; } } @@ -836,18 +866,18 @@ if (InsertSpace && d->GetLastClock() > StartClock) { tEventIterator Iterator(d); - JZEvent *e = Iterator.Range(StartClock, d->GetLastClock() + 1); + JZEvent* pEvent = Iterator.Range(StartClock, d->GetLastClock() + 1); long DeltaClock = StopClock - StartClock; - while (e) + while (pEvent) { - if (mpFilter->IsSelected(e)) + if (mpFilter->IsSelected(pEvent)) { - JZEvent *c = e->Copy(); + JZEvent* c = pEvent->Copy(); c->SetClock(c->GetClock() + DeltaClock); - d->Kill(e); + d->Kill(pEvent); d->Put(c); } - e = Iterator.Next(); + pEvent = Iterator.Next(); } d->Cleanup(); } @@ -857,12 +887,14 @@ if (EraseSource) { tEventIterator Iterator(s); - JZEvent *e = Iterator.Range(mpFilter->FromClock, mpFilter->ToClock); - while (e) + JZEvent* pEvent = Iterator.Range(mpFilter->FromClock, mpFilter->ToClock); + while (pEvent) { - if (mpFilter->IsSelected(e)) - s->Kill(e); - e = Iterator.Next(); + if (mpFilter->IsSelected(pEvent)) + { + s->Kill(pEvent); + } + pEvent = Iterator.Next(); } s->Cleanup(); } @@ -872,12 +904,14 @@ if (EraseDestin) { tEventIterator Iterator(d); - JZEvent *e = Iterator.Range(StartClock, StopClock); - while (e) + JZEvent* pEvent = Iterator.Range(StartClock, StopClock); + while (pEvent) { - if (mpFilter->IsSelected(e)) - d->Kill(e); - e = Iterator.Next(); + if (mpFilter->IsSelected(pEvent)) + { + d->Kill(pEvent); + } + pEvent = Iterator.Next(); } d->Cleanup(); } @@ -893,19 +927,20 @@ // tCmdExchLeftRight // ************************************************************************ -tCmdExchLeftRight::tCmdExchLeftRight(JZFilter *f) - : tCommand(f) +tCmdExchLeftRight::tCmdExchLeftRight(JZFilter* pFilter) + : tCommand(pFilter) { } -void tCmdExchLeftRight::ExecuteEvent(JZTrack *t, JZEvent *e) +void tCmdExchLeftRight::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - if (e->IsKeyOn()) + if (pEvent->IsKeyOn()) { - tKeyOn *k = (tKeyOn *)e->Copy(); - k->SetClock(mpFilter->FromClock + mpFilter->ToClock - k->GetClock()); - t->Kill(e); - t->Put(k); + tKeyOn* pKeyOn = (tKeyOn *)pEvent->Copy(); + pKeyOn->SetClock( + mpFilter->FromClock + mpFilter->ToClock - pKeyOn->GetClock()); + pTrack->Kill(pEvent); + pTrack->Put(pKeyOn); } } @@ -914,176 +949,226 @@ // tCmdExchUpDown // ************************************************************************ -tCmdExchUpDown::tCmdExchUpDown(JZFilter *f) - : tCommand(f) +tCmdExchUpDown::tCmdExchUpDown(JZFilter* pFilter) + : tCommand(pFilter) { } -void tCmdExchUpDown::ExecuteTrack(JZTrack *t) +void tCmdExchUpDown::ExecuteTrack(JZTrack* pTrack) { int i; int Keys[128]; - JZEvent *e; + JZEvent* pEvent; // find all Key's selected for (i = 0; i < 128; i++) + { Keys[i] = 0; + } - tEventIterator Iterator(t); - e = Iterator.Range(mpFilter->FromClock, mpFilter->ToClock); - while (e) + tEventIterator Iterator(pTrack); + pEvent = Iterator.Range(mpFilter->FromClock, mpFilter->ToClock); + while (pEvent) { - if (mpFilter->IsSelected(e) && e->IsKeyOn()) + if (mpFilter->IsSelected(pEvent) && pEvent->IsKeyOn()) { - tKeyOn *k = (tKeyOn *)e; - Keys[k->Key] = 1; + tKeyOn* pKeyOn = (tKeyOn *)pEvent; + Keys[pKeyOn->mKey] = 1; } - e = Iterator.Next(); + pEvent = Iterator.Next(); } // reverse Key's - e = Iterator.Range(mpFilter->FromClock, mpFilter->ToClock); - while(e) + pEvent = Iterator.Range(mpFilter->FromClock, mpFilter->ToClock); + while (pEvent) { - if (mpFilter->IsSelected(e) && e->IsKeyOn()) + if (mpFilter->IsSelected(pEvent) && pEvent->IsKeyOn()) { - tKeyOn *k = (tKeyOn *)e->Copy(); + tKeyOn* pKeyOn = (tKeyOn *)pEvent->Copy(); int n_th = 0; + // the n'th key from bottom .. - for (i = 0; i <= k->Key; i++) + for (i = 0; i <= pKeyOn->mKey; i++) + { n_th += Keys[i]; + } + // .. becomes the n'th key from top for (i = 127; i > 0 && n_th; --i) + { n_th -= Keys[i]; - k->Key = i + 1; + } - t->Kill(e); - t->Put(k); + pKeyOn->mKey = i + 1; + + pTrack->Kill(pEvent); + pTrack->Put(pKeyOn); } - e = Iterator.Next(); + pEvent = Iterator.Next(); } - t->Cleanup(); + pTrack->Cleanup(); } -// ************************************************************************ -// tCmdMapper -// ************************************************************************ - -//enum prop { veloc, length, key, rhythm, random, pan, modul, cc1, cc2, pitch, clock }; -tCmdMapper::tCmdMapper(JZFilter *f, prop src, prop dst, JZRndArray &arr, int nb, int ad) - : tCommand(f), - array(arr) +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +tCmdMapper::tCmdMapper( + JZFilter* pFilter, + prop Source, + prop Destination, + JZRndArray& RandomArray, + int BarCount, + bool Add) + : tCommand(pFilter), + mBarCount(BarCount), + mStartBar(0), + mAdd(Add), + mSource(Source), + mDestination(Destination), + mpBarInfo(0), + mRandomArray(RandomArray) { - n_bars = nb; - source = src; - destin = dst; - add = ad; - binfo = new JZBarInfo(mpSong); - binfo->SetClock(mpFilter->FromClock); - start_bar = binfo->BarNr; + mpBarInfo = new JZBarInfo(*mpSong); + mpBarInfo->SetClock(mpFilter->FromClock); + mStartBar = mpBarInfo->GetBarIndex(); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tCmdMapper::~tCmdMapper() { - delete binfo; + delete mpBarInfo; } -void tCmdMapper::ExecuteEvent(JZTrack *t, JZEvent *e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void tCmdMapper::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tKeyOn *k = e->IsKeyOn(); - if (k) + tKeyOn* pKeyOn = pEvent->IsKeyOn(); + if (pKeyOn) { int sval = 0; - switch (source) + switch (mSource) { case veloc: - sval = array[(int)k->Veloc]; + sval = mRandomArray[(int)pKeyOn->mVelocity]; break; case length: - sval = array[(int)k->Length]; + sval = mRandomArray[(int)pKeyOn->mLength]; break; case key: - sval = array[(int)k->Key]; + sval = mRandomArray[(int)pKeyOn->mKey]; break; - case rhythm: { - binfo->SetClock(k->GetClock()); -// long sng_tpb = binfo->TicksPerBar; - long arr_tpb = array.Size() / n_bars; - long arr_bar = (binfo->BarNr - start_bar) % n_bars; - long i = arr_tpb * arr_bar + arr_tpb * (k->GetClock() - binfo->Clock) / binfo->TicksPerBar; -// printf("sng_tpb %ld, arr_tpb %ld, k->GetClock() %ld, binfo->Clock %ld,\n arr.Size() %ld, n_bars %ld, i %ld\n", -// sng_tpb, arr_tpb, k->GetClock(), binfo->Clock, array.Size(), n_bars, i); -// fflush(stdout); - sval = array[(int)i]; + case rhythm: + { + mpBarInfo->SetClock(pKeyOn->GetClock()); + long arr_tpb = mRandomArray.Size() / mBarCount; + long arr_bar = (mpBarInfo->GetBarIndex() - mStartBar) % mBarCount; + long i = arr_tpb * arr_bar + arr_tpb * + (pKeyOn->GetClock() - mpBarInfo->GetClock()) / mpBarInfo->GetTicksPerBar(); +// cout +// << "mpBarInfo->GetTicksPerBar() " << mpBarInfo->GetTicksPerBar() +// << ", arr_tpb " << arr_tpb +// << ", pKeyOn->GetClock() " << pKeyOn->GetClock() +// << ", mpBarInfo->GetClock() " << mpBarInfo->GetClock() +// << '\n' +// << "mRandomArray.Size() " << mRandomArray.Size() +// << ", mBarCount " << mBarCount +// << ", i " << i +// << endl; + sval = mRandomArray[(int)i]; } break; case random: - sval = array.Random(); - if (add) - sval -= array.Size()/2; + sval = mRandomArray.Random(); + if (mAdd) + { + sval -= mRandomArray.Size()/2; + } break; default: break; } - switch (destin) + switch (mDestination) { - case veloc: { - if (add) - sval = k->Veloc + sval; + case veloc: + { + if (mAdd) + { + sval = pKeyOn->mVelocity + sval; + } if (sval > 127) + { sval = 127; + } if (sval < 1) + { sval = 1; - tKeyOn *c = (tKeyOn *)k->Copy(); - t->Kill(k); - c->Veloc = sval; - t->Put(c); + } + tKeyOn* pKeyOnCopy = (tKeyOn *)pKeyOn->Copy(); + pTrack->Kill(pKeyOn); + pKeyOnCopy->mVelocity = sval; + pTrack->Put(pKeyOnCopy); } break; - case key: { - if (add) - sval = k->Key + sval; + case key: + { + if (mAdd) + { + sval = pKeyOn->mKey + sval; + } if (sval > 127) + { sval = 127; + } if (sval < 1) + { sval = 1; - tKeyOn *c = (tKeyOn *)k->Copy(); - t->Kill(k); - c->Key = sval; - t->Put(c); + } + tKeyOn* pKeyOnCopy = (tKeyOn *)pKeyOn->Copy(); + pTrack->Kill(pKeyOn); + pKeyOnCopy->mKey = sval; + pTrack->Put(pKeyOnCopy); } break; - case length: { - if (add) - sval = k->Length + sval; + case length: + { + if (mAdd) + { + sval = pKeyOn->mLength + sval; + } if (sval < 1) + { sval = 1; - tKeyOn *c = (tKeyOn *)k->Copy(); - t->Kill(k); - c->Length = sval; - t->Put(c); + } + tKeyOn* pKeyOnCopy = (tKeyOn *)pKeyOn->Copy(); + pTrack->Kill(pKeyOn); + pKeyOnCopy->mLength = sval; + pTrack->Put(pKeyOnCopy); } break; - case clock: { - tKeyOn *c = (tKeyOn *)k->Copy(); - c->SetClock(c->GetClock() + sval); - if (c->GetClock() < 0) + case clock: + { + tKeyOn* pKeyOnCopy = (tKeyOn *)pKeyOn->Copy(); + pKeyOnCopy->SetClock(pKeyOnCopy->GetClock() + sval); + if (pKeyOnCopy->GetClock() < 0) { - c->SetClock(0); + pKeyOnCopy->SetClock(0); } - t->Kill(k); - t->Put(c); + pTrack->Kill(pKeyOn); + pTrack->Put(pKeyOnCopy); } break; @@ -1097,4 +1182,3 @@ } } } - Modified: trunk/jazz/src/Command.h =================================================================== --- trunk/jazz/src/Command.h 2008-04-19 23:22:59 UTC (rev 466) +++ trunk/jazz/src/Command.h 2008-04-20 00:00:32 UTC (rev 467) @@ -35,7 +35,7 @@ class tScale { public: - void Init(int ScaleNr, JZFilter *f = 0); + void Init(int ScaleNr, JZFilter* pFilter = 0); int ScaleKeys[12]; int Member(int Key) @@ -47,7 +47,7 @@ int Prev(int Key); int Transpose(int Key, int Steps); int FitInto(int Key); - static int Analyze(JZFilter *f); // returns ScaleNr + static int Analyze(JZFilter* pFilter); // returns ScaleNr }; @@ -79,8 +79,8 @@ { long DeltaClock; public: - tCmdShift(JZFilter *f, long DeltaClock); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + tCmdShift(JZFilter* pFilter, long DeltaClock); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; @@ -88,17 +88,17 @@ { public: int LeaveSpace; - tCmdErase(JZFilter *f, int LeaveSpace = 1); + tCmdErase(JZFilter* pFilter, int LeaveSpace = 1); virtual void Execute(int NewUndo = 1); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; class tCmdVelocity : public tCommand { public: int FromValue, ToValue, Mode; - tCmdVelocity(JZFilter *f, int From, int To, int Mode); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + tCmdVelocity(JZFilter* pFilter, int From, int To, int Mode); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; @@ -106,8 +106,8 @@ { public: int FromValue, ToValue, Mode; - tCmdLength(JZFilter *f, int From, int To, int Mode); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + tCmdLength(JZFilter* pFilter, int From, int To, int Mode); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; @@ -116,8 +116,8 @@ public: double scale; long startClock; - tCmdSeqLength(JZFilter *f, double scale); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + tCmdSeqLength(JZFilter* pFilter, double scale); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; @@ -129,16 +129,20 @@ long clockDelay; int repeat; - tCmdMidiDelay(JZFilter *f, double scale, long clockDelay, int repeat); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + tCmdMidiDelay( + JZFilter* pFilter, + double scale, + long clockDelay, + int repeat); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; class tCmdConvertToModulation : public tCommand { public: - tCmdConvertToModulation(JZFilter *f); - virtual void ExecuteTrack(JZTrack *t); + tCmdConvertToModulation(JZFilter* pFilter); + virtual void ExecuteTrack(JZTrack* pTrack); }; @@ -151,9 +155,9 @@ int shortenOverlaps; tKeyOn *prev_note[16][128]; public: - tCmdCleanup(JZFilter *f, long limitClocks, int shortenOverlaps); - virtual void ExecuteTrack(JZTrack *t); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + tCmdCleanup(JZFilter* pFilter, long limitClocks, int shortenOverlaps); + virtual void ExecuteTrack(JZTrack* pTrack); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; @@ -161,8 +165,8 @@ { short fr, to; public: - tCmdSearchReplace(JZFilter *f, short fr, short to); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + tCmdSearchReplace(JZFilter* pFilter, short fr, short to); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; @@ -171,12 +175,12 @@ long Quantize(long Clock, int islen); public: long QntClocks; - int NoteStart; // yes - int NoteLength; // no + int NoteStart; // yes + int NoteLength; // no int Delay; // zero - int Groove; // zero - tCmdQuantize(JZFilter *f, long QntClocks, int groove, int delay); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + int Groove; // zero + tCmdQuantize(JZFilter* pFilter, long QntClocks, int groove, int delay); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; @@ -186,8 +190,12 @@ int Notes; int FitIntoScale; tScale Scale; - tCmdTranspose(JZFilter *f, int Notes, int ScaleNr = 0, int FitIntoScale = 0); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + tCmdTranspose( + JZFilter* pFilter, + int Notes, + int ScaleNr = 0, + int FitIntoScale = 0); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; @@ -195,8 +203,8 @@ { public: int NewChannel; // 0 - tCmdSetChannel(JZFilter *f, int NewChannel); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + tCmdSetChannel(JZFilter* pFilter, int NewChannel); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; @@ -206,7 +214,7 @@ tCmdCopyToBuffer(JZFilter* pFilter, tEventArray *Buffer); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); private: @@ -226,8 +234,8 @@ int InsertSpace; // no long RepeatClock; // -1L - tCmdCopy(JZFilter *f, long DestTrack, long DestClock); - virtual void ExecuteTrack(JZTrack *t); + tCmdCopy(JZFilter* pFilter, long DestTrack, long DestClock); + virtual void ExecuteTrack(JZTrack* pTrack); }; @@ -235,32 +243,56 @@ class tCmdExchLeftRight : public tCommand { public: - tCmdExchLeftRight(JZFilter *f); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + tCmdExchLeftRight(JZFilter* pFilter); + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); }; class tCmdExchUpDown : public tCommand { public: - tCmdExchUpDown(JZFilter *f); - virtual void ExecuteTrack(JZTrack *t); + tCmdExchUpDown(JZFilter* pFilter); + virtual void ExecuteTrack(JZTrack* pTrack); }; class tCmdMapper : public tCommand { public: - enum prop { veloc, length, key, rhythm, random, pan, modul, cc1, cc2, pitch, clock }; - tCmdMapper(JZFilter *f, prop src, prop dst, JZRndArray &array, int nbars, int add); - ~tCmdMapper(); - virtual void ExecuteEvent(JZTrack *t, JZEvent *e); + + enum prop + { + veloc, + length, + key, + rhythm, + random, + pan, + modul, + cc1, + cc2, + pitch, + clock + }; + + tCmdMapper( + JZFilter* pFilter, + prop Destination, + prop dst, + JZRndArray& RandomArray, + int BarCount, + bool Add); + + virtual ~tCmdMapper(); + + virtual void ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent); + private: - int n_bars; - int start_bar; - int add; - prop source; - prop destin; - JZBarInfo *binfo; - JZRndArray &array; + int mBarCount; + int mStartBar; + bool mAdd; + prop mSource; + prop mDestination; + JZBarInfo* mpBarInfo; + JZRndArray& mRandomArray; }; #endif // !defined(JZ_COMMAND_H) Modified: trunk/jazz/src/ControlEdit.cpp =================================================================== --- trunk/jazz/src/ControlEdit.cpp 2008-04-19 23:22:59 UTC (rev 466) +++ trunk/jazz/src/ControlEdit.cpp 2008-04-20 00:00:32 UTC (rev 467) @@ -77,17 +77,20 @@ wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); - if (!ctrlmode) { - topsizer->Add(new wxButton(panel, -1, "Apply")) ; + if (!ctrlmode) + { + topsizer->Add(new wxButton(panel, wxID_ANY, "Apply")) ; //(wxFunction)Apply, - topsizer->Add(new wxButton(panel, -1, "Revert")) ; + topsizer->Add(new wxButton(panel, wxID_ANY, "Revert")) ; //(wxFunction)Revert, //(void)new wxButton(panel, (wxFunction)Bars, "Bars"); - } else { - topsizer->Add(new wxButton(panel, -1, "Create")); // create new events (wxFunction)Apply, - topsizer->Add(new wxButton(panel, -1, "Change")); // change existing events (wxFunction)Edit, - topsizer->Add(new wxButton(panel, -1, "Revert")); //(wxFunction)Revert, + } + else + { + topsizer->Add(new wxButton(panel, wxID_ANY, "Create")); // create new events (wxFunction)Apply, + topsizer->Add(new wxButton(panel, wxID_ANY,"Change")); // change existing events (wxFunction)Edit, + topsizer->Add(new wxButton(panel, wxID_ANY, "Revert")); //(wxFunction)Revert, //(void)new wxButton(panel, (wxFunction)Bars, "Bars"); } ctrlmode = 0; @@ -115,7 +118,10 @@ // SN++ void tCtrlEditBase::UpDate() { - if (!selectable) return; + if (!selectable) + { + return; + } OnRevert(); } // @@ -157,16 +163,21 @@ { long i = Clock2i(clock); if (i >= i_max-1) - /* PAT - The following ifdef was removed due to changes in gcc 3.x. If it - needs to be put back for compatibility purposes, it will need to return - in an alternate form. */ - /*#ifdef FOR_MSW*/ - return array[(int)(i_max-1)]; + { + //* PAT - The following ifdef was removed due to changes in gcc 3.x. If + // it needs to be put back for compatibility purposes, it will need to + // return in an alternate form. +// #ifdef FOR_MSW + return array[(int)(i_max - 1)]; + } return array[(int)i]; - /*#else - return array[i_max-1]; - return array[i]; - #endif*/ +//#else +// { +// return array[i_max-1]; +// } +// return array[i]; +//#endif + #if 0 long v1 = array[i]; long v2 = array[i+1]; @@ -186,28 +197,30 @@ if (sticky && !selectable) { - JZEvent *e = iter.Range(0, from_clock); - while (e) + JZEvent* pEvent = iter.Range(0, from_clock); + while (pEvent) { - if (IsCtrlEdit(e)) + if (IsCtrlEdit(pEvent)) { - val = GetValue(e); + val = GetValue(pEvent); } - e = iter.Next(); + pEvent = iter.Next(); } } - JZEvent *e = iter.Range(from_clock, to_clock); + JZEvent* pEvent = iter.Range(from_clock, to_clock); for (i = 0; i < array.Size(); i++) + { array[i] = val; + } i = 0; - while (e) + while (pEvent) { - if (IsCtrlEdit(e)) + if (IsCtrlEdit(pEvent)) { - int k = Clock2i(e->GetClock()); + int k = Clock2i(pEvent->GetClock()); if (sticky) { while (i < k) @@ -215,14 +228,18 @@ array[i++] = val; } } - val = GetValue(e); + val = GetValue(pEvent); array[k] = val; } - e = iter.Next(); + pEvent = iter.Next(); } if (sticky && !selectable) + { while (i < array.Size()) + { array[i++] = val; + } + } edit->Refresh(); } @@ -243,30 +260,32 @@ // delete old events, but skip clock 0 to preserve track defaults: // (dirty but might work...) tEventIterator iter(track); - JZEvent *e = iter.Range(std::max(1L, from_clock), to_clock); + JZEvent* pEvent = iter.Range(std::max(1L, from_clock), to_clock); int old_val = Missing(); // SN++ events nur im apply-mode loeschen! if (!ctrlmode) { - while (e) + while (pEvent) { - if (IsCtrlEdit(e)) - track->Kill(e); - e = iter.Next(); + if (IsCtrlEdit(pEvent)) + { + track->Kill(pEvent); + } + pEvent = iter.Next(); } // find any previous events if (sticky) { - e = iter.Range(0, from_clock - 1); - while (e) + pEvent = iter.Range(0, from_clock - 1); + while (pEvent) { - if (IsCtrlEdit(e)) + if (IsCtrlEdit(pEvent)) { - old_val = GetValue(e); + old_val = GetValue(pEvent); } - e = iter.Next(); + pEvent = iter.Next(); } } @@ -279,8 +298,8 @@ if (old_val != new_val) { - e = NewEvent(clock, new_val); - track->Put(e); + pEvent = NewEvent(clock, new_val); + track->Put(pEvent); old_val = new_val; } } @@ -290,20 +309,20 @@ // edit mode: Erzeugt keine neuen Events sondern aendert den Wert // bestehender Events. // SN++ - tControl *cpy; - while (e) + tControl* pControlCopy; + while (pEvent) { - if(IsCtrlEdit(e)) + if (IsCtrlEdit(pEvent)) { - if (Clock2Val(e->GetClock()) != e->IsControl()->Value) + if (Clock2Val(pEvent->GetClock()) != pEvent->IsControl()->Value) { - cpy = e->Copy()->IsControl(); - cpy->Value = Clock2Val(e->GetClock()); - track->Kill(e); - track->Put(cpy); + pControlCopy = pEvent->Copy()->IsControl(); + pControlCopy->Value = Clock2Val(pEvent->GetClock()); + track->Kill(pEvent); + track->Put(pControlCopy); } } - e = iter.Next(); + pEvent = iter.Next(); } } @@ -359,25 +378,27 @@ // av: called by tArrayEdit::OnPaint void tCtrlEditBase::DrawBars(wxDC* dc) { - JZBarInfo BarInfo(mpPianoWindow->GetSong()); + JZBarInfo BarInfo(*mpPianoWindow->GetSong()); BarInfo.SetClock(from_clock); long gclk,x; int ii; if (bars_state > 0) { - gclk = BarInfo.Clock; + gclk = BarInfo.GetClock(); while (gclk < to_clock) { - gclk = BarInfo.Clock; + gclk = BarInfo.GetClock(); x = mpPianoWindow->Clock2x(gclk-from_clock); edit->DrawBarLine(dc, x - x_off); if (bars_state == 2) - for (ii = 0; ii < BarInfo.CountsPerBar; ii++) + { + for (ii = 0; ii < BarInfo.GetCountsPerBar(); ++ii) { - gclk += BarInfo.TicksPerBar / BarInfo.CountsPerBar; + gclk += BarInfo.GetTicksPerBar() / BarInfo.GetCountsPerBar(); x = mpPianoWindow->Clock2x(gclk-from_clock); edit->DrawBarLine(dc, x - x_off); } + } BarInfo.Next(); } } @@ -403,14 +424,14 @@ return 0; } -int tPitchEdit::IsCtrlEdit(JZEvent *e) +int tPitchEdit::IsCtrlEdit(JZEvent* pEvent) { - return e->IsPitch() != 0; + return pEvent->IsPitch() != 0; } -int tPitchEdit::GetValue(JZEvent *e) +int tPitchEdit::GetValue(JZEvent* pEvent) { - return e->IsPitch()->Value; + return pEvent->IsPitch()->Value; } JZEvent * tPitchEdit::NewEvent(long clock, int val) @@ -440,21 +461,22 @@ int tCtrlEdit::Missing() { - if (ctrl_num == 10) + { return 64; + } return 0; } -int tCtrlEdit::IsCtrlEdit(JZEvent *e) +int tCtrlEdit::IsCtrlEdit(JZEvent* pEvent) { - tControl *c = e->IsControl(); + tControl *c = pEvent->IsControl(); return (c && c->Control == ctrl_num); } -int tCtrlEdit::GetValue(JZEvent *e) +int tCtrlEdit::GetValue(JZEvent* pEvent) { - return e->IsControl()->Value; + return pEvent->IsControl()->Value; } JZEvent * tCtrlEdit::NewEvent(long clock, int val) @@ -483,30 +505,30 @@ return 1; } -int tVelocEdit::IsCtrlEdit(JZEvent *e) +int tVelocEdit::IsCtrlEdit(JZEvent* pEvent) { // SN++ Falls im PianoWin Events selektiert sind, werden nur diese // Events geaendert if (!mpPianoWindow->mpSnapSel->Selected) { - return (e->IsKeyOn() != 0); + return (pEvent->IsKeyOn() != 0); } else { - if (e->IsKeyOn()) + if (pEvent->IsKeyOn()) { return ( - mpPianoWindow->GetFilter()->IsSelected(e) && - (e->GetClock() >= mpPianoWindow->GetFilter()->FromClock && - e->GetClock() <= mpPianoWindow->GetFilter()->ToClock)); + mpPianoWindow->GetFilter()->IsSelected(pEvent) && + (pEvent->GetClock() >= mpPianoWindow->GetFilter()->FromClock && + pEvent->GetClock() <= mpPianoWindow->GetFilter()->ToClock)); } } return 0; } -int tVelocEdit::GetValue(JZEvent *e) +int tVelocEdit::GetValue(JZEvent* pEvent) { - return e->IsKeyOn()->Veloc; + return pEvent->IsKeyOn()->mVelocity; } void tVelocEdit::OnApply() @@ -522,31 +544,36 @@ { from_clk = mpPianoWindow->GetFilter()->FromClock; to_clk = mpPianoWindow->GetFilter()->ToClock; - } else { + } + else + { from_clk = from_clock; to_clk = to_clock; } - JZEvent *e = iter.Range(from_clk, to_clk); + JZEvent* pEvent = iter.Range(from_clk, to_clk); - while (e) { + while (pEvent) + { // SN++ Falls im PianoWin Events selektiert sind, werden nur diese // Events geaendert - if (!mpPianoWindow->mpSnapSel->Selected || mpPianoWindow->GetFilter()->IsSelected(e) ) - { - - tKeyOn *k = e->IsKeyOn(); - if (k) + if ( + !mpPianoWindow->mpSnapSel->Selected || + mpPianoWindow->GetFilter()->IsSelected(pEvent)) { - tKeyOn *cpy = k->Copy()->IsKeyOn(); - int i = Clock2i(cpy->GetClock()); - cpy->Veloc = array[i]; - track->Kill(k); - track->Put(cpy); + tKeyOn* pKeyOn = pEvent->IsKeyOn(); + if (pKeyOn) + { + tKeyOn* pKeyOnCopy = pKeyOn->Copy()->IsKeyOn(); + + int i = Clock2i(pKeyOnCopy->GetClock()); + pKeyOnCopy->mVelocity = array[i]; + track->Kill(pKeyOn); + track->Put(pKeyOnCopy); + } } - } - e = iter.Next(); + pEvent = iter.Next(); } track->Cleanup(); wxEndBusyCursor(); @@ -578,28 +605,34 @@ return 0; } -int tPolyAfterEdit::IsCtrlEdit(JZEvent *e) +int tPolyAfterEdit::IsCtrlEdit(JZEvent* pEvent) { // SN++ Falls im PianoWin Events selektiert sind, werden nur diese // Events geaendert if (!mpPianoWindow->mpSnapSel->Selected) - return e->IsKeyPressure() != 0; + { + return pEvent->IsKeyPressure() != 0; + } else - if (e->IsKeyPressure()) - { - return ( - mpPianoWindow->GetFilter()->IsSelected(e) && - (e->GetClock() >= mpPianoWindow->GetFilter()->FromClock && - e->GetClock() <= mpPianoWindow->GetFilter()->ToClock)); - } + { + if (pEvent->IsKeyPressure()) + { + return ( + mpPianoWindow->GetFilter()->IsSelected(pEvent) && + (pEvent->GetClock() >= mpPianoWindow->GetFilter()->FromClock && + pEvent->GetClock() <= mpPianoWindow->GetFilter()->ToClock)); + } + } return 0; } -int tPolyAfterEdit::GetValue(JZEvent *e) +int tPolyAfterEdit::GetValue(JZEvent* pEvent) { - if (e->IsKeyPressure()) - return e->IsKeyPressure()->Value; + if (pEvent->IsKeyPressure()) + { + return pEvent->IsKeyPressure()->Value; + } return -1; } @@ -607,7 +640,7 @@ void tPolyAfterEdit::OnApply() { static long from_clk, to_clk; - JZEvent *e; + JZEvent* pEvent; // SN++ Apply works only if some events are selected !! if (!mpPianoWindow->mpSnapSel->Selected) @@ -634,36 +667,44 @@ tKeyPressure *k; tKeyOn *keyon; - if (!ctrlmode) { // OnApply - // SN++ Alle selektierten AfterTouch events loeschen - e = iter.Range(from_clk, to_clk); - while (e) { - if (!mpPianoWindow->mpSnapSel->Selected || mpPianoWindow->GetFilter()->IsSelected(e) ) + if (!ctrlmode) + { + // OnApply + + // SN++ Alle selektierten AfterTouch events loeschen + pEvent = iter.Range(from_clk, to_clk); + while (pEvent) + { + if ( + !mpPianoWindow->mpSnapSel->Selected || + mpPianoWindow->GetFilter()->IsSelected(pEvent)) { - k = e->IsKeyPressure(); + k = pEvent->IsKeyPressure(); if (k) { track->Kill(k); } } - e = iter.Next(); + pEvent = iter.Next(); } // SN++ Neue Aftertouch's von KeyOn bis KeyLength einfuehgen; long key_end(-1), key_clk(-1); int key_val = -1; int key_cha(-1); JZEvent *after; - e = iter.Range(from_clk, to_clk); - while (e) + pEvent = iter.Range(from_clk, to_clk); + while (pEvent) { - if (!mpPianoWindow->mpSnapSel->Selected || mpPianoWindow->GetFilter()->IsSelected(e) ) + if ( + !mpPianoWindow->mpSnapSel->Selected || + mpPianoWindow->GetFilter()->IsSelected(pEvent)) { - keyon = e->IsKeyOn(); + keyon = pEvent->IsKeyOn(); if (keyon) { key_clk = keyon->GetClock() + 1; - key_end = keyon->GetClock() + keyon->Length; - key_val = keyon->Key; + key_end = keyon->GetClock() + keyon->mLength; + key_val = keyon->mKey; key_cha = keyon->Channel; } if (key_val>0) @@ -685,7 +726,7 @@ key_val = -1; } } - e = iter.Next(); + pEvent = iter.Next(); } } else @@ -694,24 +735,26 @@ // edit mode: Erzeugt keine neuen Events sondern aendert den Wert // bestehender Events. // SN++ - e = iter.Range(from_clk, to_clk); - tKeyPressure *cpy; - while (e) + pEvent = iter.Range(from_clk, to_clk); + tKeyPressure* pKeyPressureCopy; + while (pEvent) { - if (!mpPianoWindow->mpSnapSel->Selected || mpPianoWindow->GetFilter()->IsSelected(e)) + if ( + !mpPianoWindow->mpSnapSel->Selected || + mpPianoWindow->GetFilter()->IsSelected(pEvent)) { - if(e->IsKeyPressure()) + if (pEvent->IsKeyPressure()) { - if (Clock2Val(e->GetClock()) != e->IsKeyPressure()->Value) + if (Clock2Val(pEvent->GetClock()) != pEvent->IsKeyPressure()->Value) { - cpy = e->Copy()->IsKeyPressure(); - cpy->Value = Clock2Val(e->GetClock()); - track->Kill(e); - track->Put(cpy); + pKeyPressureCopy = pEvent->Copy()->IsKeyPressure(); + pKeyPressureCopy->Value = Clock2Val(pEvent->GetClock()); + track->Kill(pEvent); + track->Put(pKeyPressureCopy); } } } - e = iter.Next(); + pEvent = iter.Next(); } } @@ -742,14 +785,14 @@ return 0; } -int tChannelAfterEdit::IsCtrlEdit(JZEvent *e) +int tChannelAfterEdit::IsCtrlEdit(JZEvent* pEvent) { - return e->IsChnPressure() != 0; + return pEvent->IsChnPressure() != 0; } -int tChannelAfterEdit::GetValue(JZEvent *e) +int tChannelAfterEdit::GetValue(JZEvent* pEvent) { - return e->IsChnPressure()->Value; + return pEvent->IsChnPressure()->Value; } @@ -772,32 +815,32 @@ // delete old events, but skip clock 0 to preserve track defaults: // (dirty but might work...) tEventIterator iter(track); - JZEvent *e = iter.Range(std::max(1L, from_clock), to_clock); + JZEvent* pEvent = iter.Range(std::max(1L, from_clock), to_clock); int old_val = Missing(); // SN++ events nur im apply-mode loeschen! if (!ctrlmode) { - while (e) + while (pEvent) { - if (IsCtrlEdit(e)) + if (IsCtrlEdit(pEvent)) { - track->Kill(e); + track->Kill(pEvent); } - e = iter.Next(); + pEvent = iter.Next(); } // find any previous events if (sticky) { - e = iter.Range(0, from_clock - 1); - while (e) + pEvent = iter.Range(0, from_clock - 1); + while (pEvent) { - if (IsCtrlEdit(e)) + if (IsCtrlEdit(pEvent)) { - old_val = GetValue(e); + old_val = GetValue(pEvent); } - e = iter.Next(); + pEvent = iter.Next(); } } @@ -810,8 +853,8 @@ if (old_val != new_val) { - e = NewEvent(clock, new_val); - track->Put(e); + pEvent = NewEvent(clock, new_val); + track->Put(pEvent); old_val = new_val; } } @@ -821,20 +864,20 @@ // edit mode: Erzeugt keine neuen Events sondern aendert den Wert // bestehender Events. // SN++ - tChnPressure *cpy; - while (e) + tChnPressure* pChnPressureCopy; + while (pEvent) { - if(IsCtrlEdit(e)) + if (IsCtrlEdit(pEvent)) { - if (Clock2Val(e->GetClock()) != GetValue(e)) + if (Clock2Val(pEvent->GetClock()) != GetValue(pEvent)) { - cpy = e->Copy()->IsChnPressure(); - cpy->Value = Clock2Val(e->GetClock()); - track->Kill(e); - track->Put(cpy); + pChnPressureCopy = pEvent->Copy()->IsChnPressure(); + pChnPressureCopy->Value = Clock2Val(pEvent->GetClock()); + track->Kill(pEvent); + track->Put(pChnPressureCopy); } } - e = iter.Next(); + pEvent = iter.Next(); } } @@ -867,14 +910,14 @@ return track->GetDefaultSpeed(); } -int tTempoEdit::IsCtrlEdit(JZEvent *e) +int tTempoEdit::IsCtrlEdit(JZEvent* pEvent) { - return e->IsSetTempo() != 0; + return pEvent->IsSetTempo() != 0; } -int tTempoEdit::GetValue(JZEvent *e) +int tTempoEdit::GetValue(JZEvent* pEvent) { - return e->IsSetTempo()->GetBPM(); + return pEvent->IsSetTempo()->GetBPM(); } JZEvent * tTempoEdit::NewEvent(long clock, int val) Modified: trunk/jazz/src/Dialogs/KeyOnDialog.cpp =============================================================... [truncated message content] |