From: <pst...@us...> - 2008-04-08 14:03:48
|
Revision: 442 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=442&view=rev Author: pstieber Date: 2008-04-08 07:03:32 -0700 (Tue, 08 Apr 2008) Log Message: ----------- Added more menu update handlers. I don't have this quite right, but it's close. Modified Paths: -------------- trunk/jazz/src/Harmony.cpp trunk/jazz/src/Harmony.h Modified: trunk/jazz/src/Harmony.cpp =================================================================== --- trunk/jazz/src/Harmony.cpp 2008-04-08 04:34:59 UTC (rev 441) +++ trunk/jazz/src/Harmony.cpp 2008-04-08 14:03:32 UTC (rev 442) @@ -487,6 +487,17 @@ virtual ~HBCanvas(); + bool GetMark4Common() const; + bool GetMark3Common() const; + bool GetMark2Common() const; + bool GetMark1Common() const; + bool GetMarkBCommon() const; + bool GetMark0Common() const; + bool GetMark1Semi() const; + bool GetMark251() const; + bool GetMarkTritone() const; + bool GetMarkPiano() const; + virtual void OnDraw(wxDC& Dc); void DrawMarkers(wxDC& Dc, const HBContext& Context); @@ -601,9 +612,69 @@ inline bool HBCanvas::IsUsingHaunschildLayout() const { - return mHaunschildLayout; + return mHaunschildLayout; } +inline +bool HBCanvas::GetMark4Common() const +{ + return mMark4Common; +} + +inline +bool HBCanvas::GetMark3Common() const +{ + return mMark3Common; +} + +inline +bool HBCanvas::GetMark2Common() const +{ + return mMark2Common; +} + +inline +bool HBCanvas::GetMark1Common() const +{ + return mMark1Common; +} + +inline +bool HBCanvas::GetMarkBCommon() const +{ + return mMarkBCommon; +} + +inline +bool HBCanvas::GetMark0Common() const +{ + return mMark0Common; +} + +inline +bool HBCanvas::GetMark1Semi() const +{ + return mMark1Semi; +} + +inline +bool HBCanvas::GetMark251() const +{ + return mMark251; +} + +inline +bool HBCanvas::GetMarkTritone() const +{ + return mMarkTritone; +} + +inline +bool HBCanvas::GetMarkPiano() const +{ + return mMarkPiano; +} + //***************************************************************************** // Description: // This is the harmony browser match markers class definition. @@ -1866,11 +1937,21 @@ EVT_UPDATE_UI(MEN_IONSCALE, HBFrame::OnUpdateIonicScale) EVT_MENU(MEN_IONSCALE, HBFrame::OnToolBarSelect) + EVT_UPDATE_UI(MEN_EQ4, HBFrame::OnUpdateFourEqualNotes) EVT_MENU(MEN_EQ4, HBFrame::OnToolBarSelect) + + EVT_UPDATE_UI(MEN_EQ3, HBFrame::OnUpdateThreeEqualNotes) EVT_MENU(MEN_EQ3, HBFrame::OnToolBarSelect) + + EVT_UPDATE_UI(MEN_EQ2, HBFrame::OnUpdateTwoEqualNotes) EVT_MENU(MEN_EQ2, HBFrame::OnToolBarSelect) + + EVT_UPDATE_UI(MEN_EQ1, HBFrame::OnUpdateOneEqualNotes) EVT_MENU(MEN_EQ1, HBFrame::OnToolBarSelect) + + EVT_UPDATE_UI(MEN_EQ1, HBFrame::OnUpdateZeroEqualNotes) EVT_MENU(MEN_EQ0, HBFrame::OnToolBarSelect) + EVT_MENU(MEN_EQH, HBFrame::OnToolBarSelect) EVT_MENU(MEN_251, HBFrame::OnToolBarSelect) EVT_MENU(MEN_EQB, HBFrame::OnToolBarSelect) @@ -1933,22 +2014,76 @@ true); wxMenu* pScaleMenu = new wxMenu; - pScaleMenu->Append(MEN_MAJSCALE, "&Major", "Use Major Scales", true); - pScaleMenu->Append(MEN_HARSCALE, "&Harmonic Minor", "Use Harmonic Minor Scales", true); - pScaleMenu->Append(MEN_MELSCALE, "&Melodic Minor", "Use Melodic Minor Scales", true); - pScaleMenu->Append(MEN_IONSCALE, "&Ionic", "Use Ionic Scales", true); + pScaleMenu->Append( + MEN_MAJSCALE, + "&Major", + "Use Major Scales", + true); + pScaleMenu->Append( + MEN_HARSCALE, + "&Harmonic Minor", + "Use Harmonic Minor Scales", + true); + pScaleMenu->Append( + MEN_MELSCALE, + "&Melodic Minor", + "Use Melodic Minor Scales", + true); + pScaleMenu->Append( + MEN_IONSCALE, + "&Ionic", + "Use Ionic Scales", + true); wxMenu* pShowMenu = new wxMenu; - pShowMenu->Append(MEN_EQ4, "&4 equal notes"); - pShowMenu->Append(MEN_EQ3, "&3 equal notes"); - pShowMenu->Append(MEN_EQ2, "&2 equal notes"); - pShowMenu->Append(MEN_EQ1, "&1 equal note"); - pShowMenu->Append(MEN_EQ0, "&0 equal notes"); - pShowMenu->Append(MEN_EQH, "1/2 note &difference"); - pShowMenu->Append(MEN_251, "2-5-1 &move"); - pShowMenu->Append(MEN_EQB, "&Same bass note"); - pShowMenu->Append(MEN_TRITONE, "&Tritone substitute"); - pShowMenu->Append(MEN_PIANO, "Contains &Pianowin Buffer"); + pShowMenu->Append( + MEN_EQ4, + "&4 equal notes", + "Display Chords with 4 common notes", + true); + pShowMenu->Append( + MEN_EQ3, + "&3 equal notes", + "Display Chords with 3 common notes", + true); + pShowMenu->Append( + MEN_EQ2, + "&2 equal notes", + "Display Chords with 2 common notes", + true); + pShowMenu->Append( + MEN_EQ1, + "&1 equal note", + "Display Chords with 1 common notes", + true); + pShowMenu->Append( + MEN_EQ0, + "&0 equal notes", + "Display Chords with no common notes", + true); + pShowMenu->Append( + MEN_EQH, + "1/2 note &difference", + "Display Chords with a 1/2 note difference", + true); + pShowMenu->Append( + MEN_251, + "2-5-1 &move", + "Display Chords with a 2-5-1 move", + true); + pShowMenu->Append( + MEN_EQB, + "&Same bass note", + "Display Chords with the same bass note", + true); + pShowMenu->Append( + MEN_TRITONE, + "&Tritone substitute", + "Display Chords with that are tritone substitutes", + true); + pShowMenu->Append( + MEN_PIANO, + "Contains &Pianowin Buffer"); wxMenu* pActionMenu = new wxMenu; pActionMenu->Append(MEN_TRANSPOSE, "&Transpose"); @@ -2077,6 +2212,41 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +void HBFrame::OnUpdateFourEqualNotes(wxUpdateUIEvent& Event) +{ + Event.Check(mpHbWindow->GetMark4Common()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void HBFrame::OnUpdateThreeEqualNotes(wxUpdateUIEvent& Event) +{ + Event.Check(mpHbWindow->GetMark3Common()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void HBFrame::OnUpdateTwoEqualNotes(wxUpdateUIEvent& Event) +{ + Event.Check(mpHbWindow->GetMark2Common()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void HBFrame::OnUpdateOneEqualNotes(wxUpdateUIEvent& Event) +{ + Event.Check(mpHbWindow->GetMark1Common()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void HBFrame::OnUpdateZeroEqualNotes(wxUpdateUIEvent& Event) +{ + Event.Check(mpHbWindow->GetMark0Common()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void HBFrame::OnToolBarSelect(wxCommandEvent& Event) { mpHbWindow->MenuCommand( Modified: trunk/jazz/src/Harmony.h =================================================================== --- trunk/jazz/src/Harmony.h 2008-04-08 04:34:59 UTC (rev 441) +++ trunk/jazz/src/Harmony.h 2008-04-08 14:03:32 UTC (rev 442) @@ -91,6 +91,12 @@ void OnUpdateMelodicMinorScale(wxUpdateUIEvent& Event); void OnUpdateIonicScale(wxUpdateUIEvent& Event); + void OnUpdateFourEqualNotes(wxUpdateUIEvent& Event); + void OnUpdateThreeEqualNotes(wxUpdateUIEvent& Event); + void OnUpdateTwoEqualNotes(wxUpdateUIEvent& Event); + void OnUpdateOneEqualNotes(wxUpdateUIEvent& Event); + void OnUpdateZeroEqualNotes(wxUpdateUIEvent& Event); + void OnToolBarSelect(wxCommandEvent& Event); void OnFileLoad(wxCommandEvent& Event); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-08 17:25:58
|
Revision: 443 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=443&view=rev Author: pstieber Date: 2008-04-08 10:25:46 -0700 (Tue, 08 Apr 2008) Log Message: ----------- Converted some char* variables and functions to std::string. Modified Paths: -------------- trunk/jazz/src/Harmony.cpp trunk/jazz/src/HarmonyP.cpp trunk/jazz/src/HarmonyP.h Modified: trunk/jazz/src/Harmony.cpp =================================================================== --- trunk/jazz/src/Harmony.cpp 2008-04-08 14:03:32 UTC (rev 442) +++ trunk/jazz/src/Harmony.cpp 2008-04-08 17:25:46 UTC (rev 443) @@ -1057,12 +1057,12 @@ Rectangle.width, Rectangle.height); - const char* pName = Context.ChordName(); + string ChordName = Context.GetChordName(); int TextWidth, TextHeight; - Dc.GetTextExtent(pName, &TextWidth, &TextHeight); + Dc.GetTextExtent(ChordName.c_str(), &TextWidth, &TextHeight); Dc.DrawText( - pName, + ChordName.c_str(), Rectangle.x + (Rectangle.width - TextWidth) / 2, Rectangle.y + (Rectangle.height - TextHeight) / 2); } @@ -1110,7 +1110,7 @@ { JZRectangle Rectangle; ChordRect(Rectangle, Context); - Dc.DrawText(Context.ScaleName(), 5, Rectangle.y); + Dc.DrawText(Context.GetScaleName().c_str(), 5, Rectangle.y); } } @@ -1518,7 +1518,7 @@ struct tNamedChord { - const char* mpName; + const std::string mName; int bits; }; @@ -1542,7 +1542,7 @@ { " 75-", 0x451}, }; -tNamedChord scale_names[n_scale_names] = +tNamedChord mScaleNames[n_scale_names] = { { "***** major scales *****", 0x0}, { "maj I (ionic)", 0xab5}, @@ -1698,13 +1698,17 @@ scale_chk[i] = new wxCheckBox(this, wxID_ANY, " ", wxPoint(x, y+2*h));//(wxFunction)ScaleCheck, if (notename[i]) { - (void) new wxStaticText(this, wxID_ANY, (char *)notename[i], wxPoint(x, y+3*h)); + new wxStaticText(this, wxID_ANY, notename[i], wxPoint(x, y + 3 * h)); } - (void) new wxStaticText(this, wxID_ANY, (char *)HBChord::ScaleName(i + chord_key), wxPoint(x, y+0*h)); + new wxStaticText( + this, + wxID_ANY, + HBChord::ScaleName(i + chord_key), + wxPoint(x, y + 0 * h)); } y += 4*h; - // list boxes x y w h + // list boxes x y w h #ifdef OBSOLETE SetLabelPosition(wxVERTICAL); #endif @@ -1713,7 +1717,7 @@ for (i = 0; i < n_chord_names; i++) { - cnames[i] = (char *)chord_names[i].mpName; + cnames[i] = chord_names[i].mName; } chord_lst = new wxListBox(this, -1, wxPoint(10, y), wxSize(100, 200), n_chord_names, cnames, wxLB_SINGLE| wxLB_NEEDED_SB);//"Chords" @@ -1723,7 +1727,7 @@ wxString* snames = new wxString[n_scale_names]; for (i = 0; i < n_scale_names; i++) { - snames[i] = (char *)scale_names[i].mpName; + snames[i] = mScaleNames[i].mName; } scale_lst = new wxListBox( this, @@ -1755,9 +1759,9 @@ { // show single notes int i; - char buf[30]; - chord.Name(buf, ChordKey(0)); - chord_msg->SetLabel(buf); + string ChordName; + chord.CreateName(ChordName, ChordKey(0)); + chord_msg->SetLabel(ChordName.c_str()); for (i = 0; i < 12; i++) { chord_chk[i]->SetValue(0 != chord.Contains(ChordKey(i))); @@ -1784,11 +1788,11 @@ HBChord s = scale; s.Rotate(-ScaleKey()); i = chord_lst->GetSelection(); - if (i < 0 || s.Keys() != scale_names[i].bits) + if (i < 0 || s.Keys() != mScaleNames[i].bits) { for (i = 0; i < n_scale_names; i++) { - if (scale_names[i].bits == s.Keys()) + if (mScaleNames[i].bits == s.Keys()) { scale_lst->SetSelection(i); break; @@ -1863,7 +1867,6 @@ void HBContextDlg::OnChordCheck() { - char buf[30]; chord.Clear(); for (int i = 0; i < 12; i++) { @@ -1872,8 +1875,9 @@ chord += ChordKey(i); } } - chord.Name(buf, ChordKey()); - chord_msg->SetLabel(buf); + string ChordName; + chord.CreateName(ChordName, ChordKey()); + chord_msg->SetLabel(ChordName.c_str()); RestartPlayer(); } @@ -1910,7 +1914,7 @@ int i = scale_lst->GetSelection(); if (i >= 0) { - HBChord s(scale_names[i].bits); + HBChord s(mScaleNames[i].bits); s.Rotate(ScaleKey()); scale = s; ShowValues(); Modified: trunk/jazz/src/HarmonyP.cpp =================================================================== --- trunk/jazz/src/HarmonyP.cpp 2008-04-08 14:03:32 UTC (rev 442) +++ trunk/jazz/src/HarmonyP.cpp 2008-04-08 17:25:46 UTC (rev 443) @@ -25,13 +25,15 @@ #include <assert.h> #include <string.h> +#include <iostream> + using namespace std; // ======================================================================== // HBChord // ======================================================================== -const char *const HBChord::scale_names[2][12] = +const string const HBChord::mScaleNames[2][12] = { { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }, { "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B" } @@ -54,17 +56,18 @@ if (l >= 0) operator += (l); } -void HBChord::Name(char *buf, int key, int flat) +void HBChord::CreateName(string& ChordName, int key, int flat) { HBChord c = *this; - strcpy(buf, ScaleName(key, flat)); - int i = strlen(buf); - c.Rotate(-key); // transpose to C + ChordName = ScaleName(key, flat); - // special cases + // Transpose to C. + c.Rotate(-key); + + // Handle special cases. if (c == C0) { - strcat(buf, "o"); + ChordName.append("o"); return; } @@ -79,21 +82,24 @@ if (c.Contains(3)) { if (!c.Contains(4)) - buf[i++] = 'm'; + { + ChordName.append("m"); + } else + { sharp9 = true; + } } // 7 if (c.Contains(11)) { - buf[i++] = 'j'; - buf[i++] = '7'; + ChordName.append("j7"); seven = true; } else if (c.Contains(10)) { - buf[i++] = '7'; + ChordName.append("j"); seven = true; } @@ -102,32 +108,35 @@ { if (!c.Contains(4)) { - strcpy(buf + i, "sus4"); - i += 5; + ChordName.append("sus4"); } else + { nat11 = true; + } } // 5 if (c.Contains(7)) { if (c.Contains(6)) + { sharp11 = true; + } if (c.Contains(8)) + { flat13 = true; + } } else { if (c.Contains(6)) { - buf[i++] = '5'; - buf[i++] = '-'; + ChordName.append("5-"); } if (c.Contains(8)) { - buf[i++] = '5'; - buf[i++] = '+'; + ChordName.append("5+"); } } @@ -135,56 +144,49 @@ if (c.Contains(9)) { if (!seven) - buf[i++] = '6'; + { + ChordName.append("6"); + } else + { nat13 = true; + } } // 9 if (c.Contains(1)) { - buf[i++] = '9'; - buf[i++] = '-'; + ChordName.append("9-"); } if (c.Contains(2)) { - buf[i++] = '9'; + ChordName.append("5"); } if (sharp9) { - buf[i++] = '9'; - buf[i++] = '+'; + ChordName.append("9+"); } // 11 if (nat11) { - buf[i++] = '1'; - buf[i++] = '1'; - buf[i++] = ' '; + ChordName.append("11 "); } if (sharp11) { - buf[i++] = '1'; - buf[i++] = '1'; - buf[i++] = '+'; + ChordName.append("11+"); } // 13 if (flat13) { - buf[i++] = '1'; - buf[i++] = '3'; - buf[i++] = '-'; + ChordName.append("13-"); } if (nat13) { - buf[i++] = '1'; - buf[i++] = '3'; + ChordName.append("13"); } - - buf[i++] = 0; } @@ -332,22 +334,21 @@ Initialize(); } -const char * HBContext::ChordName() const +string HBContext::GetChordName() const { #if NAME_TABLE - // use table of chordnames (fast) - static char buf[20]; + // Use the table of chord names (fast). int chord_key = ChordKey(); - strcpy(buf, HBChord::ScaleName(chord_key, flat_keys[scale_nr])); - strcat(buf, chord_names[scale_type][chord_nr]); - return buf; // "Dm75-" + string ChordName = HBChord::ScaleName(chord_key, flat_keys[scale_nr]); + ChordName.append(chord_names[scale_type][chord_nr]); + return ChordName; #else - // compute chordname (slow, but flexible) - static char buf[20]; + // Compute the chord name (slow, but flexible). int chord_key = ChordKey(); HBChord chord = Chord(); - chord.Name(buf, chord_key, flat_keys[chord_key]); - return buf; + string ChordName; + chord.CreateName(ChordName, chord_key, flat_keys[chord_key]); + return ChordName; #endif } @@ -356,16 +357,16 @@ return chord_nr_names[chord_nr]; // "IV" } -const char * HBContext::ScaleName() const +const string& HBContext::GetScaleName() const { - static char buf[20]; + static string ScaleName; //strcpy(buf, scale_names[flat_keys[scale_nr]][scale_nr]); - strcpy(buf, HBChord::ScaleName(scale_nr, flat_keys[scale_nr])); + ScaleName = HBChord::ScaleName(scale_nr, flat_keys[scale_nr]); #if 0 strcat(buf, "/"); strcat(buf, scale_type_names[scale_type]); #endif - return buf; + return ScaleName; } const char * HBContext::ScaleTypeName() const @@ -698,7 +699,7 @@ gensc(chords); cout << "};\n\n"; - cout << "tNamedChord scale_names[n_scale_names] = {\n"; + cout << "tNamedChord mScaleNames[n_scale_names] = {\n"; gensc(scales); cout << "};\n\n"; Modified: trunk/jazz/src/HarmonyP.h =================================================================== --- trunk/jazz/src/HarmonyP.h 2008-04-08 14:03:32 UTC (rev 442) +++ trunk/jazz/src/HarmonyP.h 2008-04-08 17:25:46 UTC (rev 443) @@ -24,6 +24,7 @@ #define JZ_HARMONYP_H #include <iostream> +#include <string> // ------------------------------------------------------------------ // HBChord @@ -194,18 +195,19 @@ *this += key+1; } - void Name(char *buf, int key, int flat = 0); + void CreateName(std::string& CordName, int key, int flat = 0); - static const char * ScaleName(int key, int flat = 0) + static const std::string ScaleName(int key, int flat = 0) { - return scale_names[flat != 0][(key + 240) % 12]; + return mScaleNames[flat != 0][(key + 240) % 12]; } protected: int keys; private: - static const char * const scale_names[2][12]; + + static const std::string const mScaleNames[2][12]; }; inline std::ostream& operator << (std::ostream& os, HBChord const &a) @@ -323,16 +325,19 @@ seq_nr = n; } - const char* ChordName() const; // "Dm75-" + // For example "Dm75-" + std::string GetChordName() const; - const char* ChordNrName() const; // "IV" + // For example "IV" + const char* ChordNrName() const; const char* ContextName() const // "mixo#11" { return context_names[scale_type][chord_nr]; } - const char* ScaleName() const; // "C#" + // For example "C#" + const std::string& GetScaleName() const; const char* ScaleTypeName() const; // "major" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-08 21:09:10
|
Revision: 444 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=444&view=rev Author: pstieber Date: 2008-04-08 14:09:07 -0700 (Tue, 08 Apr 2008) Log Message: ----------- Fixed up guitar fret board drawing. Modified Paths: -------------- trunk/jazz/src/GuitarFrame.cpp trunk/jazz/src/GuitarWindow.cpp trunk/jazz/src/GuitarWindow.h Modified: trunk/jazz/src/GuitarFrame.cpp =================================================================== --- trunk/jazz/src/GuitarFrame.cpp 2008-04-08 17:25:46 UTC (rev 443) +++ trunk/jazz/src/GuitarFrame.cpp 2008-04-08 21:09:07 UTC (rev 444) @@ -61,7 +61,7 @@ wxID_ANY, "Guitar board", wxPoint(20, 20), - wxSize(600, 120), + wxSize(600, 150), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) { // set the frame icon Modified: trunk/jazz/src/GuitarWindow.cpp =================================================================== --- trunk/jazz/src/GuitarWindow.cpp 2008-04-08 17:25:46 UTC (rev 443) +++ trunk/jazz/src/GuitarWindow.cpp 2008-04-08 21:09:07 UTC (rev 444) @@ -25,6 +25,10 @@ #include "GuitarWindow.h" #include "GuitarFrame.h" +#include <string> + +using namespace std; + //***************************************************************************** // Description: // This is the guitar window definition. @@ -99,8 +103,10 @@ wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE), // mpGuitarFrame(pParent), // mpPianoWindow(pPianoWindow) + mMargin(2), mActivePitch(0), - mPlayPitch(0) + mPlayPitch(0), + mpFont(0) { mWidth = Size.GetWidth(); mHeight = Size.GetHeight(); @@ -117,11 +123,20 @@ mStringCount = 6; } mStringHeight = mHeight / (mStringCount + 1); - mFretWidth = mWidth / mFretCount; + mFretWidth = mWidth / mFretCount; + + mpFont = new wxFont(12, wxSWISS, wxNORMAL, wxNORMAL); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +JZGuitarWindow::~JZGuitarWindow() +{ + delete mpFont; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZGuitarWindow::ClearBuffer() { // piano->PasteBuffer.Clear(); @@ -145,6 +160,8 @@ wxClientDC Dc(this); PrepareDC(Dc); + Dc.SetFont(*mpFont); + Dc.SetTextBackground(GetForegroundColour()); ShowPitch(Dc, Pitch); } @@ -162,23 +179,14 @@ //----------------------------------------------------------------------------- void JZGuitarWindow::OnDraw(wxDC& Dc) { - Dc.SetFont(*wxSMALL_FONT); + Dc.SetFont(*mpFont); - //Dc.SetFont(wxNORMAL_FONT); - //mpFont = new wxFont(12, wxSWISS, wxNORMAL, wxNORMAL); - //Dc.SetFont(mpFont); - - mpFont = 0; - - Dc.GetTextExtent("xG#", &mTextWidth, &mTextHeight); - GetSize(&mWidth, &mHeight); Dc.Clear(); DrawBoard(Dc); DrawPitch(Dc, mActivePitch, true); -// DrawBuffer(Dc, piano->PasteBuffer, true); } //----------------------------------------------------------------------------- @@ -190,14 +198,14 @@ mStringHeight = mHeight / (mStringCount + 1); mFretWidth = mWidth / mFretCount; - // paint strings - for (i = 0; i < mStringCount; i++) + // Paint the guitar strings. + for (i = 0; i < mStringCount; ++i) { int y = mHeight * (i + 1) / (mStringCount + 1); Dc.DrawLine(0, y, mWidth, y); } - // paint frets + // Paint the guitar frets. int y1 = mHeight / (mStringCount + 1); int y2 = mHeight * (mStringCount) / (mStringCount + 1); int d1 = mHeight / 5; @@ -235,7 +243,7 @@ //----------------------------------------------------------------------------- void JZGuitarWindow::DrawPitch(wxDC& Dc, int Pitch, int String, bool Show) { - static const char* KeyNames[12] = + static const string KeyNames[12] = { "C", "C#", @@ -251,28 +259,45 @@ "B" }; - int x = (Pitch - mpPitches[String] - 1) * mWidth / mFretCount + mFretWidth / 3; + int x = + (Pitch - mpPitches[String] - 1) * mWidth / mFretCount + mFretWidth / 3; if (x < 0 || x > mWidth) { return; } - int y = mHeight * (String + 1) / (mStringCount + 1) - int(mTextHeight / 2); - int h = mTextHeight + 1; + int TextWidth, TextHeight; + Dc.GetTextExtent(KeyNames[Pitch % 12].c_str(), &TextWidth, &TextHeight); + int y = mHeight * (String + 1) / (mStringCount + 1) - int(TextHeight / 2); + + wxPen OldPen = Dc.GetPen(); Dc.SetPen(*wxTRANSPARENT_PEN); - Dc.SetBrush(*wxWHITE_BRUSH); - Dc.DrawRectangle(x, y, mTextWidth, h); + wxBrush OldBrush = Dc.GetBrush(); + wxBrush Brush(GetBackgroundColour()); + Dc.SetBrush(Brush); + Dc.DrawRectangle( + x - mMargin, + y - mMargin, + TextWidth + 2 * mMargin, + TextHeight + 2 * mMargin); Dc.SetPen(*wxBLACK_PEN); - Dc.SetBrush(*wxBLACK_BRUSH); + Dc.SetBrush(OldBrush); + if (Show) { - Dc.DrawText((char *)KeyNames[Pitch % 12], x, y); + // Draw the note name. + Dc.DrawText(KeyNames[Pitch % 12].c_str(), x, y); } else { - int YPosition = y + mTextHeight / 2; - Dc.DrawLine(x, YPosition, x + mTextWidth, YPosition); + // Draw the guitar string. + int YPosition = y + TextHeight / 2; + Dc.DrawLine( + x - mMargin, + YPosition, + x + TextWidth + 2 * mMargin, + YPosition); } } @@ -285,7 +310,6 @@ DrawPitch(Dc, mActivePitch, false); mActivePitch = Pitch; DrawPitch(Dc, mActivePitch, true); -// DrawBuffer(Dc, mpPianoWindow->PasteBuffer, true); } } @@ -330,6 +354,8 @@ int Pitch = Xy2Pitch(x, y); + Dc.SetFont(*mpFont); + Dc.SetTextBackground(GetForegroundColour()); ShowPitch(Dc, Pitch); } Modified: trunk/jazz/src/GuitarWindow.h =================================================================== --- trunk/jazz/src/GuitarWindow.h 2008-04-08 17:25:46 UTC (rev 443) +++ trunk/jazz/src/GuitarWindow.h 2008-04-08 21:09:07 UTC (rev 444) @@ -35,6 +35,8 @@ const wxPoint& Position, const wxSize& Size); + virtual ~JZGuitarWindow(); + virtual void OnDraw(wxDC& Dc); void ClearBuffer(); @@ -88,7 +90,7 @@ int mWidth, mHeight; int mStringHeight, mFretWidth; // rounded values - int mTextWidth, mTextHeight; + int mMargin; int mActivePitch; // mouse move int mPlayPitch; // sound int put_clock; // left up This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-08 21:14:39
|
Revision: 445 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=445&view=rev Author: pstieber Date: 2008-04-08 14:14:12 -0700 (Tue, 08 Apr 2008) Log Message: ----------- Made some cosmetic changes. Modified Paths: -------------- trunk/jazz/src/GuitarWindow.cpp trunk/jazz/src/GuitarWindow.h Modified: trunk/jazz/src/GuitarWindow.cpp =================================================================== --- trunk/jazz/src/GuitarWindow.cpp 2008-04-08 21:09:07 UTC (rev 444) +++ trunk/jazz/src/GuitarWindow.cpp 2008-04-08 21:14:12 UTC (rev 445) @@ -31,9 +31,8 @@ //***************************************************************************** // Description: -// This is the guitar window definition. +// This is the guitar window class definition. //***************************************************************************** - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- bool JZGuitarWindow::mChordMode = false; Modified: trunk/jazz/src/GuitarWindow.h =================================================================== --- trunk/jazz/src/GuitarWindow.h 2008-04-08 21:09:07 UTC (rev 444) +++ trunk/jazz/src/GuitarWindow.h 2008-04-08 21:14:12 UTC (rev 445) @@ -25,7 +25,10 @@ class JZGuitarFrame; -// define a scrollable canvas for drawing onto +//***************************************************************************** +// Description: +// This is the guitar window class declaration. +//***************************************************************************** class JZGuitarWindow : public wxScrolledWindow { public: @@ -100,6 +103,8 @@ DECLARE_EVENT_TABLE() }; +//***************************************************************************** +//***************************************************************************** //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- inline This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-09 22:10:32
|
Revision: 451 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=451&view=rev Author: pstieber Date: 2008-04-09 15:10:26 -0700 (Wed, 09 Apr 2008) Log Message: ----------- Added a wxWidgets event handler for "File | Close". Modified Paths: -------------- trunk/jazz/src/Harmony.cpp trunk/jazz/src/Harmony.h Modified: trunk/jazz/src/Harmony.cpp =================================================================== --- trunk/jazz/src/Harmony.cpp 2008-04-09 00:25:56 UTC (rev 450) +++ trunk/jazz/src/Harmony.cpp 2008-04-09 22:10:26 UTC (rev 451) @@ -1928,7 +1928,10 @@ //----------------------------------------------------------------------------- BEGIN_EVENT_TABLE(HBFrame, wxFrame) + EVT_CLOSE(HBFrame::OnClose) + EVT_MENU(wxID_CLOSE, HBFrame::OnCloseWindow) + EVT_UPDATE_UI(MEN_MAJSCALE, HBFrame::OnUpdateMajorScale) EVT_MENU(MEN_MAJSCALE, HBFrame::OnToolBarSelect) @@ -2132,13 +2135,6 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -bool HBFrame::OnClose() -{ - return true; -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- bool HBFrame::IsSequenceDefined() { return mpHbWindow->IsSequenceDefined(); @@ -2188,6 +2184,20 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +void HBFrame::OnClose(wxCloseEvent& Event) +{ + Event.Skip(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void HBFrame::OnCloseWindow(wxCommandEvent& Event) +{ + Close(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void HBFrame::OnUpdateMajorScale(wxUpdateUIEvent& Event) { Event.Check(HBCanvas::GetScaleType() == Major); Modified: trunk/jazz/src/Harmony.h =================================================================== --- trunk/jazz/src/Harmony.h 2008-04-09 00:25:56 UTC (rev 450) +++ trunk/jazz/src/Harmony.h 2008-04-09 22:10:26 UTC (rev 451) @@ -80,12 +80,14 @@ HBAnalyzer* GetAnalyzer(); - virtual bool OnClose(); - void TransposeSelection(); protected: + void OnClose(wxCloseEvent& Event); + + void OnCloseWindow(wxCommandEvent& Event); + void OnUpdateMajorScale(wxUpdateUIEvent& Event); void OnUpdateHarmonicMinorScale(wxUpdateUIEvent& Event); void OnUpdateMelodicMinorScale(wxUpdateUIEvent& Event); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-11 02:25:23
|
Revision: 452 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=452&view=rev Author: pstieber Date: 2008-04-10 19:25:18 -0700 (Thu, 10 Apr 2008) Log Message: ----------- Made some style and cosmetic changes. Modified Paths: -------------- trunk/jazz/src/AlsaDriver.cpp trunk/jazz/src/Configuration.cpp trunk/jazz/src/Configuration.h trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Globals.cpp trunk/jazz/src/Globals.h trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/Project.cpp trunk/jazz/src/Project.h trunk/jazz/src/Rhythm.cpp trunk/jazz/src/Track.cpp Modified: trunk/jazz/src/AlsaDriver.cpp =================================================================== --- trunk/jazz/src/AlsaDriver.cpp 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/AlsaDriver.cpp 2008-04-11 02:25:18 UTC (rev 452) @@ -134,8 +134,8 @@ pcm[PLAYBACK] = NULL; pcm[CAPTURE] = NULL; - dev[PLAYBACK] = gpConfig->StrValue(C_AlsaAudioOutputDevice); - dev[CAPTURE] = gpConfig->StrValue(C_AlsaAudioInputDevice); + dev[PLAYBACK] = gpConfig->GetStrValue(C_AlsaAudioOutputDevice); + dev[CAPTURE] = gpConfig->GetStrValue(C_AlsaAudioInputDevice); // FIXME mCanDuplex = 1; Modified: trunk/jazz/src/Configuration.cpp =================================================================== --- trunk/jazz/src/Configuration.cpp 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/Configuration.cpp 2008-04-11 02:25:18 UTC (rev 452) @@ -34,76 +34,92 @@ using namespace std; -tConfigEntry::tConfigEntry(const char* pName, int IntegerValue) - : Type(ConfigEntryTypeInt), - Name(0), - Value(IntegerValue), - StrValue(0) +//***************************************************************************** +// Description: +// This is the configuration entry class definition. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZConfigEntry::JZConfigEntry(const char* pName, int IntegerValue) + : mType(ConfigEntryTypeInt), + mName(0), + mValue(IntegerValue), + mStrValue(0) { if (pName) { - Name = new char [strlen(pName) + 1]; - strcpy(Name, pName); + mName = new char [strlen(pName) + 1]; + strcpy(mName, pName); } } -tConfigEntry::tConfigEntry(const char* pName, const char* pStringValue) - : Type(ConfigEntryTypeStr), - Name(0), - Value(0), - StrValue(0) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZConfigEntry::JZConfigEntry(const char* pName, const char* pStringValue) + : mType(ConfigEntryTypeStr), + mName(0), + mValue(0), + mStrValue(0) { if (pName) { - Name = new char [strlen(pName) + 1]; - strcpy(Name, pName); + mName = new char [strlen(pName) + 1]; + strcpy(mName, pName); } if (pStringValue) { - StrValue = new char[strlen(pStringValue) + 1]; - strcpy(StrValue, pStringValue); + mStrValue = new char[strlen(pStringValue) + 1]; + strcpy(mStrValue, pStringValue); } } -tConfigEntry::tConfigEntry(const char* pName, const string& StringValue) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZConfigEntry::JZConfigEntry(const char* pName, const string& StringValue) { if (pName) { - Name = new char [strlen(pName) + 1]; - strcpy(Name, pName); + mName = new char [strlen(pName) + 1]; + strcpy(mName, pName); } - StrValue = new char[strlen(StringValue.c_str()) + 1]; - strcpy(StrValue, StringValue.c_str()); + mStrValue = new char[strlen(StringValue.c_str()) + 1]; + strcpy(mStrValue, StringValue.c_str()); } -tConfigEntry::tConfigEntry(const char* pName) - : Type(ConfigEntryTypeEmpty), - Name(0), - Value(0), - StrValue(0) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZConfigEntry::JZConfigEntry(const char* pName) + : mType(ConfigEntryTypeEmpty), + mName(0), + mValue(0), + mStrValue(0) { if (pName) { - Name = new char [strlen(pName) + 1]; - strcpy(Name, pName); + mName = new char [strlen(pName) + 1]; + strcpy(mName, pName); } } -tConfigEntry::~tConfigEntry() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZConfigEntry::~JZConfigEntry() { - delete [] Name; - delete [] StrValue; + delete [] mName; + delete [] mStrValue; } -void tConfigEntry::SetStrValue(const char* pStringValue) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZConfigEntry::SetStrValue(const char* pStringValue) { - delete [] StrValue; + delete [] mStrValue; if (pStringValue) { - StrValue = new char[strlen(pStringValue) + 1]; - strcpy(StrValue, pStringValue); + mStrValue = new char[strlen(pStringValue) + 1]; + strcpy(mStrValue, pStringValue); } } @@ -113,7 +129,13 @@ -tConfig::tConfig() +//***************************************************************************** +// Description: +// This is the configuration class definition. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZConfiguration::JZConfiguration() : mFileName(), mDrumNames(), mDrumSets(), @@ -123,142 +145,158 @@ { for (int i = 0; i < NumConfigNames; ++i) { - Names[i] = 0; + mNames[i] = 0; } const char* pNoneString = "None"; // search for midi device - Names[C_Seq2Device] = new tConfigEntry(".device", -1); + mNames[C_Seq2Device] = new JZConfigEntry(".device", -1); // use /dev/music - Names[C_MidiDriver] = new tConfigEntry(".driver", 1); + mNames[C_MidiDriver] = new JZConfigEntry(".driver", 1); - // Enable audio at startup - Names[C_EnableAudio] = new tConfigEntry(".enable_audio", 1); + // Enable audio at startup. + mNames[C_EnableAudio] = new JZConfigEntry(".enable_audio", 1); - // Windows midi devices - Names[C_WinInputDevice] = new tConfigEntry(".win_input_device", -1); - Names[C_WinOutputDevice] = new tConfigEntry(".win_output_device", -1); + // Windows midi devices. + mNames[C_WinInputDevice] = new JZConfigEntry(".win_input_device", -1); + mNames[C_WinOutputDevice] = new JZConfigEntry(".win_output_device", -1); - // ALSA midi devices - Names[C_AlsaInputDevice] = new tConfigEntry(".alsa_input_device", -1); - Names[C_AlsaOutputDevice] = new tConfigEntry(".alsa_output_device", -1); + // ALSA midi devices. + mNames[C_AlsaInputDevice] = new JZConfigEntry(".alsa_input_device", -1); + mNames[C_AlsaOutputDevice] = new JZConfigEntry(".alsa_output_device", -1); - // ALSA audio devices - Names[C_AlsaAudioInputDevice] = new tConfigEntry(".alsa_audio_input_device", "hw:0,0"); - Names[C_AlsaAudioOutputDevice] = new tConfigEntry(".alsa_audio_output_device", "hw:0,0"); + // ALSA audio devices. + mNames[C_AlsaAudioInputDevice] = new JZConfigEntry( + ".alsa_audio_input_device", + "hw:0,0"); + mNames[C_AlsaAudioOutputDevice] = new JZConfigEntry( + ".alsa_audio_output_device", + "hw:0,0"); - // emulate midi thru - Names[C_SoftThru] = new tConfigEntry(".softthru", 1); + // Emulate MIDI thru. + mNames[C_SoftThru] = new JZConfigEntry(".softthru", 1); - // mpu401 hardware midi thru - Names[C_HardThru] = new tConfigEntry(".hardthru", 1); + // mpu401 hardware MIDI thru. + mNames[C_HardThru] = new JZConfigEntry(".hardthru", 1); - // midi clock source (0 = internal) - Names[C_ClockSource] = new tConfigEntry(".clocksource", 0); + // MIDI clock source (0 = internal). + mNames[C_ClockSource] = new JZConfigEntry(".clocksource", 0); - // send realtime midi messages to midi out - Names[C_RealTimeOut] = new tConfigEntry(".realtime_out", 0); + // Send realtime MIDI messages to MIDI out. + mNames[C_RealTimeOut] = new JZConfigEntry(".realtime_out", 0); - // use GS reverb macro - Names[C_UseReverbMacro] = new tConfigEntry(".use_reverb_macro", 1); + // Use the GS reverb macro. + mNames[C_UseReverbMacro] = new JZConfigEntry(".use_reverb_macro", 1); - // use GS chorus macro - Names[C_UseChorusMacro] = new tConfigEntry(".use_chorus_macro", 1); + // Use the GS chorus macro. + mNames[C_UseChorusMacro] = new JZConfigEntry(".use_chorus_macro", 1); - // Default drum channel is 10 - Names[C_DrumChannel] = new tConfigEntry(".drumchannel", 10); + // Default drum channel is 10. + mNames[C_DrumChannel] = new JZConfigEntry(".drumchannel", 10); - // Controller for bank select - Names[C_BankControlNumber] = new tConfigEntry(".bank_control_number", 0); + // Controller for bank select. + mNames[C_BankControlNumber] = new JZConfigEntry(".bank_control_number", 0); - // Controller2 for bank select with two commands - Names[C_BankControlNumber2] = new tConfigEntry(".bank_2nd_control_number", 32); + // Controller2 for bank select with two commands. + mNames[C_BankControlNumber2] = new JZConfigEntry( + ".bank_2nd_control_number", + 32); - // Max number of entries in bank table (two commands) - Names[C_MaxBankTableEntries] = new tConfigEntry(".max_bank_table_entries", 256); + // Maximum number of entries in bank table (two commands). + mNames[C_MaxBankTableEntries] = new JZConfigEntry( + ".max_bank_table_entries", + 256); - // Number of columns to draw in Parts dialogs - Names[C_PartsColumnsMax] = new tConfigEntry(".parts_columns_max", 4); + // Number of columns to draw in Parts dialogs. + mNames[C_PartsColumnsMax] = new JZConfigEntry(".parts_columns_max", 4); // Draw tracknames on the right too? - Names[C_PartsTracknamesRight] = new tConfigEntry( + mNames[C_PartsTracknamesRight] = new JZConfigEntry( ".parts_tracknames_right", 1); - // Maximum number of voice names in .jazz - Names[C_MaxVoiceNames] = new tConfigEntry(".max_voice_names", 317); + // Maximum number of voice names in .jazz. + mNames[C_MaxVoiceNames] = new JZConfigEntry(".max_voice_names", 317); // Use two-command bank select? - Names[C_UseTwoCommandBankSelect] = new tConfigEntry( + mNames[C_UseTwoCommandBankSelect] = new JZConfigEntry( ".use_two_command_bank_select", 0); - // Metronome settings - Names[C_MetroIsAccented] = new tConfigEntry(".metronome_is_accented", 1); - Names[C_MetroVelocity] = new tConfigEntry(".metronome_velocity", 127); - Names[C_MetroNormalClick] = new tConfigEntry(".metronome_normal_click", 37); - Names[C_MetroAccentedClick] = new tConfigEntry( + // Metronome settings. + mNames[C_MetroIsAccented] = new JZConfigEntry( + ".metronome_is_accented", + 1); + mNames[C_MetroVelocity] = new JZConfigEntry( + ".metronome_velocity", + 127); + mNames[C_MetroNormalClick] = new JZConfigEntry( + ".metronome_normal_click", + 37); + mNames[C_MetroAccentedClick] = new JZConfigEntry( ".metronome_accented_click", 36); // Window geometry settings. - Names[C_TrackWinXpos] = new tConfigEntry(".trackwin_xpos", 10); - Names[C_TrackWinYpos] = new tConfigEntry(".trackwin_ypos", 10); - Names[C_TrackWinWidth] = new tConfigEntry(".trackwin_width", 600); - Names[C_TrackWinHeight] = new tConfigEntry(".trackwin_height", 400); - Names[C_PianoWinXpos] = new tConfigEntry(".pianowin_xpos", 30); - Names[C_PianoWinYpos] = new tConfigEntry(".pianowin_ypos", 30); - Names[C_PianoWinWidth] = new tConfigEntry(".pianowin_width", 600); - Names[C_PianoWinHeight] = new tConfigEntry(".pianowin_height", 400); - Names[C_PartsDlgXpos] = new tConfigEntry(".partsdialog_xpos", 50); - Names[C_PartsDlgYpos] = new tConfigEntry(".partsdialog_ypos", 50); - Names[C_TrackDlgXpos] = new tConfigEntry(".trackdialog_xpos", 50); - Names[C_TrackDlgYpos] = new tConfigEntry(".trackdialog_ypos", 50); - Names[C_HarmonyXpos] = new tConfigEntry(".harmonybrowser_xpos", 100); - Names[C_HarmonyYpos] = new tConfigEntry(".harmonybrowser_ypos", 100); - Names[C_RhythmXpos] = new tConfigEntry(".randomrhythm_xpos", 150); - Names[C_RhythmYpos] = new tConfigEntry(".randomrhythm_ypos", 150); + mNames[C_TrackWinXpos] = new JZConfigEntry(".trackwin_xpos", 10); + mNames[C_TrackWinYpos] = new JZConfigEntry(".trackwin_ypos", 10); + mNames[C_TrackWinWidth] = new JZConfigEntry(".trackwin_width", 600); + mNames[C_TrackWinHeight] = new JZConfigEntry(".trackwin_height", 400); + mNames[C_PianoWinXpos] = new JZConfigEntry(".pianowin_xpos", 30); + mNames[C_PianoWinYpos] = new JZConfigEntry(".pianowin_ypos", 30); + mNames[C_PianoWinWidth] = new JZConfigEntry(".pianowin_width", 600); + mNames[C_PianoWinHeight] = new JZConfigEntry(".pianowin_height", 400); + mNames[C_PartsDlgXpos] = new JZConfigEntry(".partsdialog_xpos", 50); + mNames[C_PartsDlgYpos] = new JZConfigEntry(".partsdialog_ypos", 50); + mNames[C_TrackDlgXpos] = new JZConfigEntry(".trackdialog_xpos", 50); + mNames[C_TrackDlgYpos] = new JZConfigEntry(".trackdialog_ypos", 50); + mNames[C_HarmonyXpos] = new JZConfigEntry(".harmonybrowser_xpos", 100); + mNames[C_HarmonyYpos] = new JZConfigEntry(".harmonybrowser_ypos", 100); + mNames[C_RhythmXpos] = new JZConfigEntry(".randomrhythm_xpos", 150); + mNames[C_RhythmYpos] = new JZConfigEntry(".randomrhythm_ypos", 150); - // Show Dialog unless initialized - Names[C_SynthDialog] = new tConfigEntry(".synth_dialog", 1); + // Show dialog unless initialized. + mNames[C_SynthDialog] = new JZConfigEntry(".synth_dialog", 1); - // Default synthesizer type - Names[C_SynthType] = new tConfigEntry( + // Default synthesizer type. + mNames[C_SynthType] = new JZConfigEntry( ".synth_type", gSynthesizerTypes[SynthTypeGS].first.c_str()); - // Default synthesizer config file - Names[C_SynthConfig] = new tConfigEntry( + // Default synthesizer configuration file. + mNames[C_SynthConfig] = new JZConfigEntry( ".synth_config", gSynthesierTypeFiles[SynthTypeGS].first.c_str()); - // When to send synthesizer reset (0=never, 1=song start, 2=start play) - Names[C_SendSynthReset] = new tConfigEntry(".send_synth_reset", 1); + // When to send synthesizer reset (0 = never, 1 = song start, + // 2 = start play). + mNames[C_SendSynthReset] = new JZConfigEntry(".send_synth_reset", 1); - // Current include file - Names[C_Include] = new tConfigEntry(".include", ""); + // Current include file. + mNames[C_Include] = new JZConfigEntry(".include", ""); - // Entries with empty values - Names[C_BankTable] = new tConfigEntry(".bank_table"); - Names[C_VoiceNames] = new tConfigEntry(".voicenames"); - Names[C_DrumSets] = new tConfigEntry(".drumsets"); - Names[C_CtrlNames] = new tConfigEntry(".ctrlnames"); - Names[C_DrumNames] = new tConfigEntry(".drumnames"); + // Entries with empty values. + mNames[C_BankTable] = new JZConfigEntry(".bank_table"); + mNames[C_VoiceNames] = new JZConfigEntry(".voicenames"); + mNames[C_DrumSets] = new JZConfigEntry(".drumsets"); + mNames[C_CtrlNames] = new JZConfigEntry(".ctrlnames"); + mNames[C_DrumNames] = new JZConfigEntry(".drumnames"); - // The startup song - Names[C_StartUpSong] = new tConfigEntry(".startup_song", "jazz.mid"); - Names[C_OssBug1] = new tConfigEntry(".ossbug1", 0); - Names[C_OssBug2] = new tConfigEntry(".ossbug2", 0); - Names[C_DuplexAudio] = new tConfigEntry(".duplex_audio", 0); - Names[C_ThruInput] = new tConfigEntry(".thru_input", 0); - Names[C_ThruOutput] = new tConfigEntry(".thru_output", 0); + // The startup song. + mNames[C_StartUpSong] = new JZConfigEntry(".startup_song", "jazz.mid"); + mNames[C_OssBug1] = new JZConfigEntry(".ossbug1", 0); + mNames[C_OssBug2] = new JZConfigEntry(".ossbug2", 0); + mNames[C_DuplexAudio] = new JZConfigEntry(".duplex_audio", 0); + mNames[C_ThruInput] = new JZConfigEntry(".thru_input", 0); + mNames[C_ThruOutput] = new JZConfigEntry(".thru_output", 0); + // Enable/disable splash dialog. - Names[C_EnableWelcome] = new tConfigEntry(".enable_welcome", 1); + mNames[C_EnableWelcome] = new JZConfigEntry(".enable_welcome", 1); - // Other initialization + // Other initialization. for (int i = 0; i < 130; ++i) { @@ -280,48 +318,62 @@ mVoiceNames.push_back(make_pair("", 0)); } -tConfig::~tConfig() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZConfiguration::~JZConfiguration() { for (int i = 0; i < NumConfigNames; ++i) { - if (Names[i]) + if (mNames[i]) { - delete Names[i]; + delete mNames[i]; } } } -pair<string, int>& tConfig::DrumName(unsigned entry) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +const pair<string, int>& JZConfiguration::GetDrumName(unsigned entry) const { assert((entry >= 0) && (entry < mDrumNames.size())); return mDrumNames[entry]; } -pair<string, int>& tConfig::DrumSet(unsigned entry) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +const pair<string, int>& JZConfiguration::GetDrumSet(unsigned entry) const { assert((entry >= 0) && (entry < mDrumSets.size())); return mDrumSets[entry]; } -pair<string, int>& tConfig::VoiceName(unsigned entry) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +const pair<string, int>& JZConfiguration::GetVoiceName(unsigned entry) const { assert((entry >= 0) && (entry < mVoiceNames.size())); return mVoiceNames[entry]; } -pair<string, int>& tConfig::CtrlName(unsigned entry) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +const pair<string, int>& JZConfiguration::GetCtrlName(unsigned entry) const { assert((entry >= 0) && (entry < mCtrlNames.size())); return mCtrlNames[entry]; } -tDoubleCommand& tConfig::BankEntry(unsigned entry) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZDoubleCommand& JZConfiguration::BankEntry(unsigned entry) { assert((entry >= 0) && (entry < mBankTable.size())); return mBankTable[entry]; } -int tConfig::Check(const char* pName) const +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZConfiguration::Check(const char* pName) const { if (!pName || (pName[0] != '.')) { @@ -330,11 +382,11 @@ for (int i = 0; i < NumConfigNames; i++) { - if (!Names[i]) + if (!mNames[i]) { continue; } - if (!strncmp(pName, Names[i]->GetName(), strlen(Names[i]->GetName()))) + if (!strncmp(pName, mNames[i]->GetName(), strlen(mNames[i]->GetName()))) { // Found return i; @@ -349,7 +401,7 @@ // value has not been set by an earlier call to LoadConfig, attempt to find // the file using FindFile(). //----------------------------------------------------------------------------- -wxString tConfig::GetFileName() +wxString JZConfiguration::GetFileName() { if (!mFileName.empty()) { @@ -366,7 +418,9 @@ return mFileName; } -int tConfig::Load(char* buf) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZConfiguration::Load(char* buf) { int entry = Check(buf); @@ -375,17 +429,17 @@ char format[100]; int result = 1; - if (Names[entry]->GetType() == ConfigEntryTypeInt) + if (mNames[entry]->GetType() == ConfigEntryTypeInt) { - sprintf(format, "%s %%d", Names[entry]->GetName()); + sprintf(format, "%s %%d", mNames[entry]->GetName()); int Value; result = sscanf(buf, format, &Value); - Names[entry]->SetValue(Value); + mNames[entry]->SetValue(Value); } - else if (Names[entry]->GetType() == ConfigEntryTypeStr) + else if (mNames[entry]->GetType() == ConfigEntryTypeStr) { // allow whitespace inside entries like "C:\Program Files\JazzWare" - int ofs = strlen(Names[entry]->GetName()); + int ofs = strlen(mNames[entry]->GetName()); while (buf[ofs] == ' ' || buf[ofs] == '\t') // not \n ofs++; int end = strlen(buf) - 1; @@ -399,7 +453,7 @@ char* pStringValue = new char[size + 1]; memcpy(pStringValue, buf + ofs, size); pStringValue[size] = 0; - Names[entry]->SetStrValue(pStringValue); + mNames[entry]->SetStrValue(pStringValue); delete [] pStringValue; } else @@ -417,55 +471,67 @@ } } -const int& tConfig::GetValue(const char* pName) const +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +const int& JZConfiguration::GetValue(const char* pName) const { int i = Check(pName); assert(i >= 0); - return Names[i]->GetValue(); + return mNames[i]->GetValue(); } -const int& tConfig::GetValue(int Index) const +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +const int& JZConfiguration::GetValue(int Index) const { assert((Index >= 0) && (Index < NumConfigNames)); - return Names[Index]->GetValue(); + return mNames[Index]->GetValue(); } -bool tConfig::Get(int entry, char *value) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZConfiguration::Get(int entry, char *value) { - assert((entry >= 0) && (entry < NumConfigNames)); + assert((entry >= 0) && (entry < NumConfigNames)); - wxString FileName = GetFileName(); - if (FileName.IsEmpty()) - { - return false; - } + wxString FileName = GetFileName(); + if (FileName.IsEmpty()) + { + return false; + } - FILE *fd = fopen(FileName.c_str(), "r"); - const char* name = Name(entry); + FILE *fd = fopen(FileName.c_str(), "r"); + const char* name = GetName(entry); - int len = strlen(name); - char buf[1000]; - bool found = false; - while (!found && fgets(buf, sizeof(buf), fd) != NULL) - { - if (strncmp(buf, name, len) == 0) + int len = strlen(name); + char buf[1000]; + bool found = false; + while (!found && fgets(buf, sizeof(buf), fd) != NULL) + { + if (strncmp(buf, name, len) == 0) + { + while (isspace(buf[len])) { - while (isspace(buf[len])) - len++; - int end = strlen(buf) - 1; - while (end > 0 && isspace(buf[end])) - buf[end--] = 0; - strcpy(value, buf + len); - found = true; + len++; } - } - fclose(fd); - return found; + int end = strlen(buf) - 1; + while (end > 0 && isspace(buf[end])) + { + buf[end--] = 0; + } + strcpy(value, buf + len); + found = true; + } + } + fclose(fd); + return found; } -bool tConfig::Get(int entry, long &value) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZConfiguration::Get(int entry, long &value) { char buf[512]; if (Get(entry, buf)) @@ -482,7 +548,7 @@ // entries to there. If the name/value pair is found, replace it, otherwise // write it. Finally copy the temp file over the old configuration file. //----------------------------------------------------------------------------- -bool tConfig::Put(int Index, const char *value) +bool JZConfiguration::Put(int Index, const char *value) { assert((Index >= 0) && (Index < NumConfigNames)); @@ -502,7 +568,7 @@ } FILE* inp = fopen(FileName.c_str(), "r"); - const char* name = Name(Index); + const char* name = GetName(Index); int len = strlen(name); char buf[1000]; @@ -530,26 +596,32 @@ return true; } -bool tConfig::Put(int Index, long Value) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZConfiguration::Put(int Index, long Value) { ostringstream Oss; Oss << Value; return Put(Index, Oss.str().c_str()); } -bool tConfig::Put(int Index) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZConfiguration::Put(int Index) { assert((Index >= 0) && (Index < NumConfigNames)); - Names[Index]->SetValue(Index); - long LongValue = Names[Index]->GetValue(); + mNames[Index]->SetValue(Index); + long LongValue = mNames[Index]->GetValue(); return Put(Index, LongValue); } -bool tConfig::Put(int Index, int Value) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZConfiguration::Put(int Index, int Value) { assert((Index >= 0) && (Index < NumConfigNames)); - Names[Index]->SetValue(Value); - long LongValue = Names[Index]->GetValue(); + mNames[Index]->SetValue(Value); + long LongValue = mNames[Index]->GetValue(); return Put(Index, LongValue); } @@ -557,7 +629,7 @@ // Description: // Load the configuration from a file. This code supports file inclusion. //----------------------------------------------------------------------------- -void tConfig::LoadConfig(const wxString& FileName) +void JZConfiguration::LoadConfig(const wxString& FileName) { if (!::wxFileExists(FileName)) { @@ -590,7 +662,7 @@ } cout - << "tConfig::LoadConfig:" << '\n' + << "JZConfiguration::LoadConfig:" << '\n' << " \"" << mFileName << '"' << endl; @@ -642,7 +714,7 @@ if (mBankTable.empty()) { mBankTable.clear(); - tDoubleCommand DoubleCommand; + JZDoubleCommand DoubleCommand; for (i = 0; i <= GetValue(C_MaxBankTableEntries); ++i) { DoubleCommand.Command[0] = -1; @@ -677,7 +749,7 @@ case C_Include: { // include file - wxString pathname = FindFile(StrValue(entry)); + wxString pathname = FindFile(GetStrValue(entry)); cout << "include " << entry << endl; IncLevel++; assert(IncLevel < MaxIncs); Modified: trunk/jazz/src/Configuration.h =================================================================== --- trunk/jazz/src/Configuration.h 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/Configuration.h 2008-04-11 02:25:18 UTC (rev 452) @@ -26,13 +26,17 @@ #include <string> #include <vector> -class tDoubleCommand +//***************************************************************************** +//***************************************************************************** +class JZDoubleCommand { public: int Command[2]; }; -enum ConfigNames +//***************************************************************************** +//***************************************************************************** +enum TEConfigurationNames { C_Seq2Device = 0, C_MidiDriver, @@ -103,14 +107,18 @@ NumConfigNames }; -enum ConfigEntryType +//***************************************************************************** +//***************************************************************************** +enum TEConfigEntryType { ConfigEntryTypeInt = 0, ConfigEntryTypeStr, ConfigEntryTypeEmpty }; +//***************************************************************************** // values for C_MidiDriver +//***************************************************************************** enum TEMidiDriver { eMidiDriverJazz = 0, // C_DRV_JAZZ 0 @@ -120,113 +128,98 @@ //***************************************************************************** //***************************************************************************** -class tConfigEntry +class JZConfigEntry { public: - tConfigEntry(const char* pName, int IntegerValue); + JZConfigEntry(const char* pName, int IntegerValue); - tConfigEntry(const char* pName, const char* pStringValue); + JZConfigEntry(const char* pName, const char* pStringValue); - tConfigEntry(const char* pName, const std::string& StringValue); + JZConfigEntry(const char* pName, const std::string& StringValue); - tConfigEntry(const char* pName); + JZConfigEntry(const char* pName); - ~tConfigEntry(); + ~JZConfigEntry(); - ConfigEntryType GetType() const + TEConfigEntryType GetType() const { - return Type; + return mType; } const char* GetName() const { - return Name; + return mName; } const int& GetValue() const { - return Value; + return mValue; } void SetValue(const int& value) { - Value = value; + mValue = value; } const char* GetStrValue() const { - return StrValue; + return mStrValue; } void SetStrValue(const char* pStringValue); private: - ConfigEntryType Type; - char* Name; - int Value; - char* StrValue; + TEConfigEntryType mType; + char* mName; + int mValue; + char* mStrValue; }; //***************************************************************************** //***************************************************************************** -class tConfig +class JZConfiguration { public: - tConfig(); + JZConfiguration(); - ~tConfig(); + ~JZConfiguration(); void LoadConfig(const wxString& FileName); int Check(const char* pName) const; + int Load(char* buf); - std::pair<std::string, int>& DrumName(unsigned entry); - std::pair<std::string, int>& DrumSet(unsigned entry); - std::pair<std::string, int>& VoiceName(unsigned entry); - std::pair<std::string, int>& CtrlName(unsigned entry); - tDoubleCommand& BankEntry(unsigned entry); + const std::pair<std::string, int>& GetDrumName(unsigned entry) const; + const std::pair<std::string, int>& GetDrumSet(unsigned entry) const; + const std::pair<std::string, int>& GetVoiceName(unsigned entry) const; + const std::pair<std::string, int>& GetCtrlName(unsigned entry) const; - const char* Name(int entry) - { - assert((entry >= 0) && (entry < NumConfigNames)); - return Names[entry]->GetName(); - } + JZDoubleCommand& BankEntry(unsigned entry); - const char* StrValue(int entry) - { - assert((entry >= 0) && (entry < NumConfigNames)); - return Names[entry]->GetStrValue(); - } + const char* GetName(int entry) const; + const char* GetStrValue(int entry) const; + const int& GetValue(const char* pName) const; const int& GetValue(int Index) const; - bool Get(int entry, char *value); - bool Get(int entry, long &value); + bool Get(int entry, char* value); + bool Get(int entry, long& value); bool Put(int entry, const char *value); bool Put(int entry, long value); bool Put(int entry); bool Put(int entry, int value); - const std::vector<std::pair<std::string, int> >& GetDrumNames() - { - return mDrumNames; - } + const std::vector<std::pair<std::string, int> >& GetDrumNames() const; - const std::vector<std::pair<std::string, int> >& GetControlNames() - { - return mCtrlNames; - } + const std::vector<std::pair<std::string, int> >& GetControlNames() const; - const std::vector<std::pair<std::string, int> >& GetVoiceNames() - { - return mVoiceNames; - } + const std::vector<std::pair<std::string, int> >& GetVoiceNames() const; private: @@ -240,7 +233,7 @@ wxString mFileName; - tConfigEntry* Names[NumConfigNames]; + JZConfigEntry* mNames[NumConfigNames]; std::vector<std::pair<std::string, int> > mDrumNames; @@ -250,7 +243,56 @@ std::vector<std::pair<std::string, int> > mVoiceNames; - std::vector<tDoubleCommand> mBankTable; + std::vector<JZDoubleCommand> mBankTable; }; +//***************************************************************************** +// Description: +// These are the configuration class inline member functions. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +const char* JZConfiguration::GetName(int entry) const +{ + assert((entry >= 0) && (entry < NumConfigNames)); + return mNames[entry]->GetName(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +const char* JZConfiguration::GetStrValue(int entry) const +{ + assert((entry >= 0) && (entry < NumConfigNames)); + return mNames[entry]->GetStrValue(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +const std::vector<std::pair<std::string, int> >& +JZConfiguration::GetDrumNames() const +{ + return mDrumNames; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +const std::vector<std::pair<std::string, int> >& +JZConfiguration::GetControlNames() const +{ + return mCtrlNames; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +const std::vector<std::pair<std::string, int> >& +JZConfiguration::GetVoiceNames() const +{ + return mVoiceNames; +} + #endif // !defined(JZ_CONFIGURATION_H) Modified: trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp =================================================================== --- trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp 2008-04-11 02:25:18 UTC (rev 452) @@ -115,7 +115,7 @@ iPair != gSynthesizerTypes.end(); ++iPair, ++Index) { - if (strcmp(iPair->first.c_str(), gpConfig->StrValue(C_SynthType)) == 0) + if (strcmp(iPair->first.c_str(), gpConfig->GetStrValue(C_SynthType)) == 0) { mOldSynthTypeName = iPair->first; Selection = Index; Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/Dialogs.cpp 2008-04-11 02:25:18 UTC (rev 452) @@ -962,8 +962,8 @@ tControlDlg::tControlDlg(tControl *e, JZPianoWindow* w, JZTrack *t) - : tChEventDlg(e, w, t) - //, Choice("Controller", &gpConfig->CtrlName(0), &Control) + : tChEventDlg(e, w, t)//, +// Choice("Controller", &gpConfig->GetCtrlName(0), &Control) { Event = e; Value = e->Value; @@ -982,7 +982,7 @@ void tControlDlg::AddProperties() { // Add(Choice.mkFormItem(300, 300)); - //, Choice("Controller", &gpConfig->CtrlName(0), &Control) +// Choice("Controller", &gpConfig->GetCtrlName(0), &Control) sheet->AddProperty(new wxProperty( "Controller", tNamedValueListValue(&Control, gpConfig->GetControlNames()), @@ -1168,8 +1168,8 @@ tProgramDlg::tProgramDlg(tProgram *e, JZPianoWindow* w, JZTrack *t) : tEventDlg(e, w, t), - Program(e->Program + 1) - //, Choice("Program", &gpConfig->VoiceName(0), &Program) + Program(e->Program + 1)//, +// Choice("Program", &gpConfig->GetVoiceName(0), &Program) { Event = e; } Modified: trunk/jazz/src/Globals.cpp =================================================================== --- trunk/jazz/src/Globals.cpp 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/Globals.cpp 2008-04-11 02:25:18 UTC (rev 452) @@ -31,7 +31,7 @@ using namespace std; -tConfig* gpConfig = 0; +JZConfiguration* gpConfig = 0; JZSong* gpSong = 0; Modified: trunk/jazz/src/Globals.h =================================================================== --- trunk/jazz/src/Globals.h 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/Globals.h 2008-04-11 02:25:18 UTC (rev 452) @@ -29,7 +29,7 @@ // #define DEBUG(x) x #define DEBUG(x) -class tConfig; +class JZConfiguration; class JZSong; class JZSynth; class JZPlayer; @@ -45,7 +45,7 @@ eMaxTrackCount = 127 }; -extern tConfig* gpConfig; +extern JZConfiguration* gpConfig; extern JZSong* gpSong; extern JZSynth* gpSynth; extern JZPlayer* gpMidiPlayer; Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/PianoWindow.cpp 2008-04-11 02:25:18 UTC (rev 452) @@ -1220,7 +1220,7 @@ while (Pitch >= 0 && y < mEventsY + mEventsHeight) { Dc.DrawText( - gpConfig->DrumName(Pitch + 1).first.c_str(), + gpConfig->GetDrumName(Pitch + 1).first.c_str(), mCanvasX + mLittleBit, y); @@ -1235,7 +1235,7 @@ while (Pitch >= 0 && y < mEventsY + mEventsHeight) { Dc.DrawText( - gpConfig->CtrlName(Pitch + 1).first.c_str(), + gpConfig->GetCtrlName(Pitch + 1).first.c_str(), mCanvasX + mLittleBit, y); @@ -1249,7 +1249,7 @@ while (Pitch >= 0 && y < mEventsY + mEventsHeight) { Dc.DrawText( - gpConfig->VoiceName(Pitch + 1).first.c_str(), + gpConfig->GetVoiceName(Pitch + 1).first.c_str(), mCanvasX + mLittleBit, y); @@ -2522,7 +2522,7 @@ mpCtrlEdit = new tCtrlEdit( i - 1, this, - gpConfig->CtrlName(i).first.c_str(), + gpConfig->GetCtrlName(i).first.c_str(), mPianoWidth, 0, CtrlY(Height), Modified: trunk/jazz/src/Project.cpp =================================================================== --- trunk/jazz/src/Project.cpp 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/Project.cpp 2008-04-11 02:25:18 UTC (rev 452) @@ -134,7 +134,7 @@ gSynthesierTypeFiles.push_back(make_pair("other.jzi", SynthTypeOther)); } - mpConfig = new tConfig; + mpConfig = new JZConfiguration; gpConfig = mpConfig; ReadConfiguration(); @@ -143,9 +143,9 @@ mMetronomeInfo.ReadFromConfiguration(); - if (mpConfig->StrValue(C_SynthType)) + if (mpConfig->GetStrValue(C_SynthType)) { - mpSynth = NewSynth(mpConfig->StrValue(C_SynthType)); + mpSynth = NewSynth(mpConfig->GetStrValue(C_SynthType)); } else { @@ -316,7 +316,7 @@ } else { - StartUpSong = mpConfig->StrValue(C_StartUpSong); + StartUpSong = mpConfig->GetStrValue(C_StartUpSong); } FILE* pFd = fopen(StartUpSong.c_str(), "r"); @@ -393,20 +393,6 @@ << endl; mpConfig->LoadConfig(ConfFileNameAndPath); - - DEBUG( - if (BankTable != (tDoubleCommand *) NULL) - { - for (int i = 0; BankTable[i].Command[0] >= 0; i++) - { - cerr - << "Bank " << i << ": " - << BankTable[i].Command[0] - << ' ' << BankTable[i].Command[1] - << endl; - } - } - ) } else { Modified: trunk/jazz/src/Project.h =================================================================== --- trunk/jazz/src/Project.h 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/Project.h 2008-04-11 02:25:18 UTC (rev 452) @@ -171,7 +171,7 @@ static wxString mConfFileName; - tConfig* mpConfig; + JZConfiguration* mpConfig; JZPlayer* mpMidiPlayer; Modified: trunk/jazz/src/Rhythm.cpp =================================================================== --- trunk/jazz/src/Rhythm.cpp 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/Rhythm.cpp 2008-04-11 02:25:18 UTC (rev 452) @@ -891,8 +891,10 @@ { r->parm = SelectControllerDlg(); if (r->parm < 0) + { return; - r->SetLabel(gpConfig->CtrlName(r->parm).first.c_str()); + } + r->SetLabel(gpConfig->GetCtrlName(r->parm).first.c_str()); r->mode = MODE_CONTROL; r->n_keys = 0; } Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-04-09 22:10:26 UTC (rev 451) +++ trunk/jazz/src/Track.cpp 2008-04-11 02:25:18 UTC (rev 452) @@ -1703,7 +1703,7 @@ : wxForm(USED_WXFORM_BUTTONS), PatchChoice( "Patch", - t->IsDrumTrack() ? &gpConfig->DrumSet(0) : &gpConfig->VoiceName(0), + t->IsDrumTrack() ? &gpConfig->GetDrumSet(0) : &gpConfig->GetVoiceName(0), &PatchNr), DeviceChoice("Device", gpMidiPlayer->GetOutputDevices().AsNamedValue(), &Device) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-11 02:49:04
|
Revision: 453 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=453&view=rev Author: pstieber Date: 2008-04-10 19:49:02 -0700 (Thu, 10 Apr 2008) Log Message: ----------- Made some style and cosmetic changes. Modified Paths: -------------- trunk/jazz/src/Configuration.cpp trunk/jazz/src/Configuration.h Modified: trunk/jazz/src/Configuration.cpp =================================================================== --- trunk/jazz/src/Configuration.cpp 2008-04-11 02:25:18 UTC (rev 452) +++ trunk/jazz/src/Configuration.cpp 2008-04-11 02:49:02 UTC (rev 453) @@ -40,95 +40,80 @@ //***************************************************************************** //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -JZConfigEntry::JZConfigEntry(const char* pName, int IntegerValue) - : mType(ConfigEntryTypeInt), - mName(0), +JZConfigurationEntry::JZConfigurationEntry( + const char* pName, + int IntegerValue) + : mType(eConfigEntryTypeInt), + mName(), mValue(IntegerValue), - mStrValue(0) + mStrValue() { if (pName) { - mName = new char [strlen(pName) + 1]; - strcpy(mName, pName); + mName = pName; } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -JZConfigEntry::JZConfigEntry(const char* pName, const char* pStringValue) - : mType(ConfigEntryTypeStr), - mName(0), +JZConfigurationEntry::JZConfigurationEntry( + const char* pName, + const char* pStringValue) + : mType(eConfigEntryTypeStr), + mName(), mValue(0), - mStrValue(0) + mStrValue() { if (pName) { - mName = new char [strlen(pName) + 1]; - strcpy(mName, pName); + mName = pName; } if (pStringValue) { - mStrValue = new char[strlen(pStringValue) + 1]; - strcpy(mStrValue, pStringValue); + mStrValue = pStringValue; } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -JZConfigEntry::JZConfigEntry(const char* pName, const string& StringValue) +JZConfigurationEntry::JZConfigurationEntry( + const char* pName, + const string& StringValue) { if (pName) { - mName = new char [strlen(pName) + 1]; - strcpy(mName, pName); + mName = pName; } - mStrValue = new char[strlen(StringValue.c_str()) + 1]; - strcpy(mStrValue, StringValue.c_str()); + mStrValue = StringValue; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -JZConfigEntry::JZConfigEntry(const char* pName) - : mType(ConfigEntryTypeEmpty), - mName(0), +JZConfigurationEntry::JZConfigurationEntry(const char* pName) + : mType(eConfigEntryTypeEmpty), + mName(), mValue(0), - mStrValue(0) + mStrValue() { if (pName) { - mName = new char [strlen(pName) + 1]; - strcpy(mName, pName); + mName = pName; } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -JZConfigEntry::~JZConfigEntry() +void JZConfigurationEntry::SetStrValue(const char* pStringValue) { - delete [] mName; - delete [] mStrValue; -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -void JZConfigEntry::SetStrValue(const char* pStringValue) -{ - delete [] mStrValue; if (pStringValue) { - mStrValue = new char[strlen(pStringValue) + 1]; - strcpy(mStrValue, pStringValue); + mStrValue = pStringValue; } } - - - - - //***************************************************************************** // Description: // This is the configuration class definition. @@ -151,150 +136,198 @@ const char* pNoneString = "None"; // search for midi device - mNames[C_Seq2Device] = new JZConfigEntry(".device", -1); + mNames[C_Seq2Device] = new JZConfigurationEntry(".device", -1); // use /dev/music - mNames[C_MidiDriver] = new JZConfigEntry(".driver", 1); + mNames[C_MidiDriver] = new JZConfigurationEntry(".driver", 1); // Enable audio at startup. - mNames[C_EnableAudio] = new JZConfigEntry(".enable_audio", 1); + mNames[C_EnableAudio] = new JZConfigurationEntry(".enable_audio", 1); // Windows midi devices. - mNames[C_WinInputDevice] = new JZConfigEntry(".win_input_device", -1); - mNames[C_WinOutputDevice] = new JZConfigEntry(".win_output_device", -1); + mNames[C_WinInputDevice] = new JZConfigurationEntry( + ".win_input_device", + -1); + mNames[C_WinOutputDevice] = new JZConfigurationEntry( + ".win_output_device", + -1); // ALSA midi devices. - mNames[C_AlsaInputDevice] = new JZConfigEntry(".alsa_input_device", -1); - mNames[C_AlsaOutputDevice] = new JZConfigEntry(".alsa_output_device", -1); + mNames[C_AlsaInputDevice] = new JZConfigurationEntry( + ".alsa_input_device", + -1); + mNames[C_AlsaOutputDevice] = new JZConfigurationEntry( + ".alsa_output_device", + -1); // ALSA audio devices. - mNames[C_AlsaAudioInputDevice] = new JZConfigEntry( + mNames[C_AlsaAudioInputDevice] = new JZConfigurationEntry( ".alsa_audio_input_device", "hw:0,0"); - mNames[C_AlsaAudioOutputDevice] = new JZConfigEntry( + mNames[C_AlsaAudioOutputDevice] = new JZConfigurationEntry( ".alsa_audio_output_device", "hw:0,0"); // Emulate MIDI thru. - mNames[C_SoftThru] = new JZConfigEntry(".softthru", 1); + mNames[C_SoftThru] = new JZConfigurationEntry(".softthru", 1); // mpu401 hardware MIDI thru. - mNames[C_HardThru] = new JZConfigEntry(".hardthru", 1); + mNames[C_HardThru] = new JZConfigurationEntry(".hardthru", 1); // MIDI clock source (0 = internal). - mNames[C_ClockSource] = new JZConfigEntry(".clocksource", 0); + mNames[C_ClockSource] = new JZConfigurationEntry(".clocksource", 0); // Send realtime MIDI messages to MIDI out. - mNames[C_RealTimeOut] = new JZConfigEntry(".realtime_out", 0); + mNames[C_RealTimeOut] = new JZConfigurationEntry(".realtime_out", 0); // Use the GS reverb macro. - mNames[C_UseReverbMacro] = new JZConfigEntry(".use_reverb_macro", 1); + mNames[C_UseReverbMacro] = new JZConfigurationEntry(".use_reverb_macro", 1); // Use the GS chorus macro. - mNames[C_UseChorusMacro] = new JZConfigEntry(".use_chorus_macro", 1); + mNames[C_UseChorusMacro] = new JZConfigurationEntry(".use_chorus_macro", 1); // Default drum channel is 10. - mNames[C_DrumChannel] = new JZConfigEntry(".drumchannel", 10); + mNames[C_DrumChannel] = new JZConfigurationEntry(".drumchannel", 10); // Controller for bank select. - mNames[C_BankControlNumber] = new JZConfigEntry(".bank_control_number", 0); + mNames[C_BankControlNumber] = new JZConfigurationEntry( + ".bank_control_number", + 0); // Controller2 for bank select with two commands. - mNames[C_BankControlNumber2] = new JZConfigEntry( + mNames[C_BankControlNumber2] = new JZConfigurationEntry( ".bank_2nd_control_number", 32); // Maximum number of entries in bank table (two commands). - mNames[C_MaxBankTableEntries] = new JZConfigEntry( + mNames[C_MaxBankTableEntries] = new JZConfigurationEntry( ".max_bank_table_entries", 256); // Number of columns to draw in Parts dialogs. - mNames[C_PartsColumnsMax] = new JZConfigEntry(".parts_columns_max", 4); + mNames[C_PartsColumnsMax] = new JZConfigurationEntry( + ".parts_columns_max", + 4); // Draw tracknames on the right too? - mNames[C_PartsTracknamesRight] = new JZConfigEntry( + mNames[C_PartsTracknamesRight] = new JZConfigurationEntry( ".parts_tracknames_right", 1); // Maximum number of voice names in .jazz. - mNames[C_MaxVoiceNames] = new JZConfigEntry(".max_voice_names", 317); + mNames[C_MaxVoiceNames] = new JZConfigurationEntry(".max_voice_names", 317); // Use two-command bank select? - mNames[C_UseTwoCommandBankSelect] = new JZConfigEntry( + mNames[C_UseTwoCommandBankSelect] = new JZConfigurationEntry( ".use_two_command_bank_select", 0); // Metronome settings. - mNames[C_MetroIsAccented] = new JZConfigEntry( + mNames[C_MetroIsAccented] = new JZConfigurationEntry( ".metronome_is_accented", 1); - mNames[C_MetroVelocity] = new JZConfigEntry( + mNames[C_MetroVelocity] = new JZConfigurationEntry( ".metronome_velocity", 127); - mNames[C_MetroNormalClick] = new JZConfigEntry( + mNames[C_MetroNormalClick] = new JZConfigurationEntry( ".metronome_normal_click", 37); - mNames[C_MetroAccentedClick] = new JZConfigEntry( + mNames[C_MetroAccentedClick] = new JZConfigurationEntry( ".metronome_accented_click", 36); + //-------------------------- // Window geometry settings. - mNames[C_TrackWinXpos] = new JZConfigEntry(".trackwin_xpos", 10); - mNames[C_TrackWinYpos] = new JZConfigEntry(".trackwin_ypos", 10); - mNames[C_TrackWinWidth] = new JZConfigEntry(".trackwin_width", 600); - mNames[C_TrackWinHeight] = new JZConfigEntry(".trackwin_height", 400); - mNames[C_PianoWinXpos] = new JZConfigEntry(".pianowin_xpos", 30); - mNames[C_PianoWinYpos] = new JZConfigEntry(".pianowin_ypos", 30); - mNames[C_PianoWinWidth] = new JZConfigEntry(".pianowin_width", 600); - mNames[C_PianoWinHeight] = new JZConfigEntry(".pianowin_height", 400); - mNames[C_PartsDlgXpos] = new JZConfigEntry(".partsdialog_xpos", 50); - mNames[C_PartsDlgYpos] = new JZConfigEntry(".partsdialog_ypos", 50); - mNames[C_TrackDlgXpos] = new JZConfigEntry(".trackdialog_xpos", 50); - mNames[C_TrackDlgYpos] = new JZConfigEntry(".trackdialog_ypos", 50); - mNames[C_HarmonyXpos] = new JZConfigEntry(".harmonybrowser_xpos", 100); - mNames[C_HarmonyYpos] = new JZConfigEntry(".harmonybrowser_ypos", 100); - mNames[C_RhythmXpos] = new JZConfigEntry(".randomrhythm_xpos", 150); - mNames[C_RhythmYpos] = new JZConfigEntry(".randomrhythm_ypos", 150); + //-------------------------- + // Track window. + mNames[C_TrackWinXpos] = new JZConfigurationEntry( + ".trackwin_xpos", + 10); + mNames[C_TrackWinYpos] = new JZConfigurationEntry( + ".trackwin_ypos", + 10); + mNames[C_TrackWinWidth] = new JZConfigurationEntry( + ".trackwin_width", + 600); + mNames[C_TrackWinHeight] = new JZConfigurationEntry( + ".trackwin_height", + 400); + + // Piano window. + mNames[C_PianoWinXpos] = new JZConfigurationEntry( + ".pianowin_xpos", + 30); + mNames[C_PianoWinYpos] = new JZConfigurationEntry( + ".pianowin_ypos", + 30); + mNames[C_PianoWinWidth] = new JZConfigurationEntry( + ".pianowin_width", + 600); + mNames[C_PianoWinHeight] = new JZConfigurationEntry( + ".pianowin_height", + 400); + + // Parts dialog. + mNames[C_PartsDlgXpos] = new JZConfigurationEntry(".partsdialog_xpos", 50); + mNames[C_PartsDlgYpos] = new JZConfigurationEntry(".partsdialog_ypos", 50); + + // Track dialog. + mNames[C_TrackDlgXpos] = new JZConfigurationEntry(".trackdialog_xpos", 50); + mNames[C_TrackDlgYpos] = new JZConfigurationEntry(".trackdialog_ypos", 50); + + // Harmony browser. + mNames[C_HarmonyXpos] = new JZConfigurationEntry( + ".harmonybrowser_xpos", + 100); + mNames[C_HarmonyYpos] = new JZConfigurationEntry( + ".harmonybrowser_ypos", + 100); + + // Random rhythm. + mNames[C_RhythmXpos] = new JZConfigurationEntry(".randomrhythm_xpos", 150); + mNames[C_RhythmYpos] = new JZConfigurationEntry(".randomrhythm_ypos", 150); + // Show dialog unless initialized. - mNames[C_SynthDialog] = new JZConfigEntry(".synth_dialog", 1); + mNames[C_SynthDialog] = new JZConfigurationEntry(".synth_dialog", 1); // Default synthesizer type. - mNames[C_SynthType] = new JZConfigEntry( + mNames[C_SynthType] = new JZConfigurationEntry( ".synth_type", gSynthesizerTypes[SynthTypeGS].first.c_str()); // Default synthesizer configuration file. - mNames[C_SynthConfig] = new JZConfigEntry( + mNames[C_SynthConfig] = new JZConfigurationEntry( ".synth_config", gSynthesierTypeFiles[SynthTypeGS].first.c_str()); // When to send synthesizer reset (0 = never, 1 = song start, // 2 = start play). - mNames[C_SendSynthReset] = new JZConfigEntry(".send_synth_reset", 1); + mNames[C_SendSynthReset] = new JZConfigurationEntry(".send_synth_reset", 1); // Current include file. - mNames[C_Include] = new JZConfigEntry(".include", ""); + mNames[C_Include] = new JZConfigurationEntry(".include", ""); // Entries with empty values. - mNames[C_BankTable] = new JZConfigEntry(".bank_table"); - mNames[C_VoiceNames] = new JZConfigEntry(".voicenames"); - mNames[C_DrumSets] = new JZConfigEntry(".drumsets"); - mNames[C_CtrlNames] = new JZConfigEntry(".ctrlnames"); - mNames[C_DrumNames] = new JZConfigEntry(".drumnames"); + mNames[C_BankTable] = new JZConfigurationEntry(".bank_table"); + mNames[C_VoiceNames] = new JZConfigurationEntry(".voicenames"); + mNames[C_DrumSets] = new JZConfigurationEntry(".drumsets"); + mNames[C_CtrlNames] = new JZConfigurationEntry(".ctrlnames"); + mNames[C_DrumNames] = new JZConfigurationEntry(".drumnames"); // The startup song. - mNames[C_StartUpSong] = new JZConfigEntry(".startup_song", "jazz.mid"); + mNames[C_StartUpSong] = new JZConfigurationEntry( + ".startup_song", + "jazz.mid"); - mNames[C_OssBug1] = new JZConfigEntry(".ossbug1", 0); - mNames[C_OssBug2] = new JZConfigEntry(".ossbug2", 0); - mNames[C_DuplexAudio] = new JZConfigEntry(".duplex_audio", 0); - mNames[C_ThruInput] = new JZConfigEntry(".thru_input", 0); - mNames[C_ThruOutput] = new JZConfigEntry(".thru_output", 0); + mNames[C_OssBug1] = new JZConfigurationEntry(".ossbug1", 0); + mNames[C_OssBug2] = new JZConfigurationEntry(".ossbug2", 0); + mNames[C_DuplexAudio] = new JZConfigurationEntry(".duplex_audio", 0); + mNames[C_ThruInput] = new JZConfigurationEntry(".thru_input", 0); + mNames[C_ThruOutput] = new JZConfigurationEntry(".thru_output", 0); // Enable/disable splash dialog. - mNames[C_EnableWelcome] = new JZConfigEntry(".enable_welcome", 1); + mNames[C_EnableWelcome] = new JZConfigurationEntry(".enable_welcome", 1); // Other initialization. @@ -422,53 +455,58 @@ //----------------------------------------------------------------------------- int JZConfiguration::Load(char* buf) { - int entry = Check(buf); + int entry = Check(buf); - if (entry < 0) - return entry; + if (entry < 0) + { + return entry; + } - char format[100]; - int result = 1; - if (mNames[entry]->GetType() == ConfigEntryTypeInt) - { - sprintf(format, "%s %%d", mNames[entry]->GetName()); - int Value; - result = sscanf(buf, format, &Value); - mNames[entry]->SetValue(Value); - } - else if (mNames[entry]->GetType() == ConfigEntryTypeStr) - { - // allow whitespace inside entries like "C:\Program Files\JazzWare" - int ofs = strlen(mNames[entry]->GetName()); - while (buf[ofs] == ' ' || buf[ofs] == '\t') // not \n - ofs++; - int end = strlen(buf) - 1; - while (end > ofs) { - if (!isspace(buf[end])) - break; - end--; + char format[100]; + int result = 1; + if (mNames[entry]->GetType() == eConfigEntryTypeInt) + { + sprintf(format, "%s %%d", mNames[entry]->GetName()); + int Value; + result = sscanf(buf, format, &Value); + mNames[entry]->SetValue(Value); + } + else if (mNames[entry]->GetType() == eConfigEntryTypeStr) + { + // Allow whitespace inside entries like "C:\Program Files\JazzWare". + int ofs = strlen(mNames[entry]->GetName()); + while (buf[ofs] == ' ' || buf[ofs] == '\t') // not \n + { + ++ofs; + } + int end = strlen(buf) - 1; + while (end > ofs) + { + if (!isspace(buf[end])) + { + break; } - int size = end - ofs + 1; + --end; + } + int size = end - ofs + 1; - char* pStringValue = new char[size + 1]; - memcpy(pStringValue, buf + ofs, size); - pStringValue[size] = 0; - mNames[entry]->SetStrValue(pStringValue); - delete [] pStringValue; - } - else - { - result = 1; - } + char* pStringValue = new char[size + 1]; + memcpy(pStringValue, buf + ofs, size); + pStringValue[size] = 0; + mNames[entry]->SetStrValue(pStringValue); + delete [] pStringValue; + } + else + { + result = 1; + } - if (result <= 0) - { - return -1; - } - else - { - return entry; - } + if (result <= 0) + { + return -1; + } + + return entry; } //----------------------------------------------------------------------------- Modified: trunk/jazz/src/Configuration.h =================================================================== --- trunk/jazz/src/Configuration.h 2008-04-11 02:25:18 UTC (rev 452) +++ trunk/jazz/src/Configuration.h 2008-04-11 02:49:02 UTC (rev 453) @@ -111,9 +111,9 @@ //***************************************************************************** enum TEConfigEntryType { - ConfigEntryTypeInt = 0, - ConfigEntryTypeStr, - ConfigEntryTypeEmpty + eConfigEntryTypeInt = 0, + eConfigEntryTypeStr, + eConfigEntryTypeEmpty }; //***************************************************************************** @@ -127,58 +127,87 @@ }; //***************************************************************************** +// Description: +// This is the configuration entry class declaration. //***************************************************************************** -class JZConfigEntry +class JZConfigurationEntry { public: - JZConfigEntry(const char* pName, int IntegerValue); + JZConfigurationEntry(const char* pName, int IntegerValue); - JZConfigEntry(const char* pName, const char* pStringValue); + JZConfigurationEntry(const char* pName, const char* pStringValue); - JZConfigEntry(const char* pName, const std::string& StringValue); + JZConfigurationEntry(const char* pName, const std::string& StringValue); - JZConfigEntry(const char* pName); + JZConfigurationEntry(const char* pName); - ~JZConfigEntry(); + TEConfigEntryType GetType() const; - TEConfigEntryType GetType() const - { - return mType; - } + const char* GetName() const; - const char* GetName() const - { - return mName; - } + const int& GetValue() const; - const int& GetValue() const - { - return mValue; - } + void SetValue(const int& Value); - void SetValue(const int& value) - { - mValue = value; - } + const char* GetStrValue() const; - const char* GetStrValue() const - { - return mStrValue; - } - void SetStrValue(const char* pStringValue); private: TEConfigEntryType mType; - char* mName; + std::string mName; int mValue; - char* mStrValue; + std::string mStrValue; }; //***************************************************************************** +// Description: +// These are the configuration entry class inline member functions. //***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +TEConfigEntryType JZConfigurationEntry::GetType() const +{ + return mType; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +const char* JZConfigurationEntry::GetName() const +{ + return mName.c_str(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +const int& JZConfigurationEntry::GetValue() const +{ + return mValue; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +void JZConfigurationEntry::SetValue(const int& Value) +{ + mValue = Value; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +const char* JZConfigurationEntry::GetStrValue() const +{ + return mStrValue.c_str(); +} + +//***************************************************************************** +//***************************************************************************** class JZConfiguration { public: @@ -233,7 +262,7 @@ wxString mFileName; - JZConfigEntry* mNames[NumConfigNames]; + JZConfigurationEntry* mNames[NumConfigNames]; std::vector<std::pair<std::string, int> > mDrumNames; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-11 17:22:15
|
Revision: 456 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=456&view=rev Author: pstieber Date: 2008-04-11 10:22:07 -0700 (Fri, 11 Apr 2008) Log Message: ----------- Changed dev to mDeviceNames and converted them from const char* to std::string. Modified Paths: -------------- trunk/jazz/src/AlsaDriver.cpp trunk/jazz/src/AlsaDriver.h Modified: trunk/jazz/src/AlsaDriver.cpp =================================================================== --- trunk/jazz/src/AlsaDriver.cpp 2008-04-11 17:18:24 UTC (rev 455) +++ trunk/jazz/src/AlsaDriver.cpp 2008-04-11 17:22:07 UTC (rev 456) @@ -134,8 +134,8 @@ pcm[PLAYBACK] = NULL; pcm[CAPTURE] = NULL; - dev[PLAYBACK] = gpConfig->GetStrValue(C_AlsaAudioOutputDevice); - dev[CAPTURE] = gpConfig->GetStrValue(C_AlsaAudioInputDevice); + mDeviceNames[PLAYBACK] = gpConfig->GetStrValue(C_AlsaAudioOutputDevice); + mDeviceNames[CAPTURE] = gpConfig->GetStrValue(C_AlsaAudioInputDevice); // FIXME mCanDuplex = 1; @@ -202,7 +202,10 @@ recbuffers.ResetBufferSize(frag_byte_size[CAPTURE]); } - if (dev[CAPTURE] != dev[PLAYBACK] || mCanDuplex || running_mode == 0) + if ( + mDeviceNames[CAPTURE] != mDeviceNames[PLAYBACK] || + mCanDuplex || + running_mode == 0) { OpenDsp(PLAYBACK, 1); mSamples.ResetBufferSize(frag_byte_size[PLAYBACK]); @@ -266,7 +269,12 @@ snd_pcm_stream_t stream = (mode == PLAYBACK) ? SND_PCM_STREAM_PLAYBACK : SND_PCM_STREAM_CAPTURE; - if (snd_pcm_open(&pcm[mode], dev[mode], stream, SND_PCM_NONBLOCK) < 0) + if ( + snd_pcm_open( + &pcm[mode], + mDeviceNames[mode].c_str(), + stream, + SND_PCM_NONBLOCK) < 0) { perror("snd_pcm_open"); audio_enabled = 0; Modified: trunk/jazz/src/AlsaDriver.h =================================================================== --- trunk/jazz/src/AlsaDriver.h 2008-04-11 17:18:24 UTC (rev 455) +++ trunk/jazz/src/AlsaDriver.h 2008-04-11 17:22:07 UTC (rev 456) @@ -94,7 +94,7 @@ int audio_enabled; // 0 means midi only int card; // card number in config - const char *dev[2]; // device names + std::string mDeviceNames[2]; // device names long frag_size[2]; long frag_byte_size[2]; int frame_shift[2]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-11 17:26:45
|
Revision: 457 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=457&view=rev Author: pstieber Date: 2008-04-11 10:26:33 -0700 (Fri, 11 Apr 2008) Log Message: ----------- 1. Changed JZConfigurationEntry::GetStrValue to return a constant std::string reference instead of a constant character pointer. 2. Changed JZConfiguration::GetStrValue to return a constant std::string reference instead of a constant character pointer. 3. Changed some debug output when reading an included file. 4. Updated other code to deal with #2 above. 5. Fixed a comparison bug in NewSynth that resulted in the wrong synthesizer type being used. Modified Paths: -------------- trunk/jazz/src/Configuration.cpp trunk/jazz/src/Configuration.h trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp trunk/jazz/src/Project.cpp trunk/jazz/src/Synth.cpp trunk/jazz/src/Synth.h Modified: trunk/jazz/src/Configuration.cpp =================================================================== --- trunk/jazz/src/Configuration.cpp 2008-04-11 17:22:07 UTC (rev 456) +++ trunk/jazz/src/Configuration.cpp 2008-04-11 17:26:33 UTC (rev 457) @@ -785,17 +785,27 @@ case C_SynthConfig: case C_Include: { - // include file - wxString pathname = FindFile(GetStrValue(entry)); - cout << "include " << entry << endl; - if (pathname) + if (entry == C_SynthConfig) { - FileDescriptors.push(fopen(pathname, "r")); + cout << "Include synthesizer configuration file \""; } else { + cout << "Include file \""; + } + cout << GetStrValue(entry) << '"' << endl; + + // Get the name of the include file. + wxString IncludeFileName = FindFile(GetStrValue(entry)); + + if (IncludeFileName.empty()) + { FileDescriptors.push(NULL); } + else + { + FileDescriptors.push(fopen(IncludeFileName, "r")); + } if (FileDescriptors.top() == NULL) { Modified: trunk/jazz/src/Configuration.h =================================================================== --- trunk/jazz/src/Configuration.h 2008-04-11 17:22:07 UTC (rev 456) +++ trunk/jazz/src/Configuration.h 2008-04-11 17:26:33 UTC (rev 457) @@ -150,7 +150,7 @@ void SetValue(const int& Value); - const char* GetStrValue() const; + const std::string& GetStrValue() const; void SetStrValue(const char* pStringValue); @@ -201,9 +201,9 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- inline -const char* JZConfigurationEntry::GetStrValue() const +const std::string& JZConfigurationEntry::GetStrValue() const { - return mStrValue.c_str(); + return mStrValue; } //***************************************************************************** @@ -231,7 +231,7 @@ const char* GetName(int entry) const; - const char* GetStrValue(int entry) const; + const std::string& GetStrValue(int entry) const; const int& GetValue(const char* pName) const; const int& GetValue(int Index) const; @@ -291,7 +291,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- inline -const char* JZConfiguration::GetStrValue(int entry) const +const std::string& JZConfiguration::GetStrValue(int entry) const { assert((entry >= 0) && (entry < NumConfigNames)); return mNames[entry]->GetStrValue(); Modified: trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp =================================================================== --- trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp 2008-04-11 17:22:07 UTC (rev 456) +++ trunk/jazz/src/Dialogs/SynthesizerSettingsDialog.cpp 2008-04-11 17:26:33 UTC (rev 457) @@ -115,7 +115,7 @@ iPair != gSynthesizerTypes.end(); ++iPair, ++Index) { - if (strcmp(iPair->first.c_str(), gpConfig->GetStrValue(C_SynthType)) == 0) + if (iPair->first == gpConfig->GetStrValue(C_SynthType)) { mOldSynthTypeName = iPair->first; Selection = Index; Modified: trunk/jazz/src/Project.cpp =================================================================== --- trunk/jazz/src/Project.cpp 2008-04-11 17:22:07 UTC (rev 456) +++ trunk/jazz/src/Project.cpp 2008-04-11 17:26:33 UTC (rev 457) @@ -143,13 +143,13 @@ mMetronomeInfo.ReadFromConfiguration(); - if (mpConfig->GetStrValue(C_SynthType)) + if (mpConfig->GetStrValue(C_SynthType).empty()) { - mpSynth = NewSynth(mpConfig->GetStrValue(C_SynthType)); + mpSynth = NewSynth("GM"); } else { - mpSynth = NewSynth("GM"); + mpSynth = NewSynth(mpConfig->GetStrValue(C_SynthType)); } gpSynth = mpSynth; Modified: trunk/jazz/src/Synth.cpp =================================================================== --- trunk/jazz/src/Synth.cpp 2008-04-11 17:22:07 UTC (rev 456) +++ trunk/jazz/src/Synth.cpp 2008-04-11 17:26:33 UTC (rev 457) @@ -53,12 +53,12 @@ #define XG_NAT 0x43,0x10,0x4c #define XG_NAT_LEN 8 // no command ID or checksum for XG native! -JZSynth* NewSynth(const char* pType) +JZSynth* NewSynth(const string& Type) { int i; for (i = 0; i < NumSynthTypes; i++) { - if (gSynthesizerTypes[i].first != string(pType)) + if (gSynthesizerTypes[i].first == Type) { break; } Modified: trunk/jazz/src/Synth.h =================================================================== --- trunk/jazz/src/Synth.h 2008-04-11 17:22:07 UTC (rev 456) +++ trunk/jazz/src/Synth.h 2008-04-11 17:26:33 UTC (rev 457) @@ -364,7 +364,7 @@ }; -JZSynth* NewSynth(const char* pType); +JZSynth* NewSynth(const std::string& Type); class tGM : public JZSynth { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-13 00:19:03
|
Revision: 458 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=458&view=rev Author: pstieber Date: 2008-04-12 17:18:54 -0700 (Sat, 12 Apr 2008) Log Message: ----------- 1. Added code to allow the setting of the MIDI device in Windows. 2. Changed wx_msw macro to __WXMSW__. 3. Changed tWinMtcPlayer to JZWindowsMtcPlayer. 4. Changed tWinMidiPlayer to JZWindowsMidiPlayer. 5. Changed tWinPlayer to JZWindowsPlayer. 6. Changed tWinMtcPlayer to JZWindowsMtcPlayer. 7. Changed tWinIntPlayer to JZWindowsIntPlayer. 8. Changed tWinAudioPlayer to JZWindowsAudioPlayer. 9. Changed ID_SETTINGS_SYNTH to ID_SETTINGS_SYNTHESIZER. Modified Paths: -------------- trunk/jazz/src/Audio.h trunk/jazz/src/Dialogs/midiTiming.cpp trunk/jazz/src/Project.cpp trunk/jazz/src/Resources.h trunk/jazz/src/TrackFrame.cpp trunk/jazz/src/TrackFrame.h trunk/jazz/src/gui/trackwinEnum.h trunk/jazz/src/mswin/WindowsAudioInterface.cpp trunk/jazz/src/mswin/WindowsAudioInterface.h trunk/jazz/src/mswin/WindowsMidiInterface.h trunk/jazz/src/mswin/WindowsPlayer.cpp trunk/jazz/src/mswin/WindowsPlayer.h Modified: trunk/jazz/src/Audio.h =================================================================== --- trunk/jazz/src/Audio.h 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/Audio.h 2008-04-13 00:18:54 UTC (rev 458) @@ -177,7 +177,7 @@ class tAudioRecordBuffer { friend class tSampleSet; - friend class tWinAudioPlayer; + friend class JZWindowsAudioPlayer; public: @@ -224,7 +224,7 @@ friend class tSample; friend class tAudioGloblForm; friend class tSamplesDlg; - friend class tWinAudioPlayer; + friend class JZWindowsAudioPlayer; friend class tAudioPlayer; friend class tAlsaAudioPlayer; Modified: trunk/jazz/src/Dialogs/midiTiming.cpp =================================================================== --- trunk/jazz/src/Dialogs/midiTiming.cpp 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/Dialogs/midiTiming.cpp 2008-04-13 00:18:54 UTC (rev 458) @@ -55,13 +55,13 @@ void tTimingDlg::MtcInitRec() { -#ifdef wx_msw +#ifdef __WXMSW__ if (Config(C_ClockSource) != CsMtc) { delete Midi; Config(C_ClockSource) = CsMtc; ClkSrcListBox->SetStringSelection( ClkSrcArray[ Config(C_ClockSource) ] ); - Midi = new tWinMtcPlayer(EventWin->Song); + Midi = new JZWindowsMtcPlayer(EventWin->Song); if (!Midi->Installed()) { wxMessageBox("no midi driver installed", "Error", wxOK); @@ -130,7 +130,7 @@ if (i != Config(C_ClockSource)) { Config(C_ClockSource) = (tClockSource) i; -#ifdef wx_msw +#ifdef __WXMSW__ // Re-install the midi device delete Midi; @@ -138,10 +138,10 @@ switch (Config(C_ClockSource)) { case CsMidi: - Midi = new tWinMidiPlayer(EventWin->Song); + Midi = new JZWindowsMidiPlayer(EventWin->Song); break; case CsMtc: - Midi = new tWinMtcPlayer(EventWin->Song); + Midi = new JZWindowsMtcPlayer(EventWin->Song); break; case CsFsk: case CsInt: @@ -205,7 +205,7 @@ -1, -1); -#ifdef wx_msw +#ifdef __WXMSW__ ClkSrcListBox->Append( ClkSrcArray[CsInt] ); ClkSrcListBox->Append( ClkSrcArray[CsMidi] ); ClkSrcListBox->Append( ClkSrcArray[CsMtc] ); @@ -240,7 +240,7 @@ panel->NewLine(); -#ifdef wx_msw +#ifdef __WXMSW__ (void) new wxMessage( panel, "Record MTC offset: " ); (void) new tMidiButton( this, panel, (wxFunction) MtcRecFunc, "Start" ); panel->NewLine(); Modified: trunk/jazz/src/Project.cpp =================================================================== --- trunk/jazz/src/Project.cpp 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/Project.cpp 2008-04-13 00:18:54 UTC (rev 458) @@ -255,20 +255,20 @@ switch (mpConfig->GetValue(C_ClockSource)) { case CsMidi: - mpMidiPlayer = new tWinMidiPlayer(this); + mpMidiPlayer = new JZWindowsMidiPlayer(this); break; case CsMtc: - mpMidiPlayer = new tWinMtcPlayer(this); + mpMidiPlayer = new JZWindowsMtcPlayer(this); break; case CsFsk: case CsInt: default: - mpMidiPlayer = new tWinAudioPlayer(this); + mpMidiPlayer = new JZWindowsAudioPlayer(this); if (!mpMidiPlayer->Installed()) { mpMidiPlayer->ShowError(); delete mpMidiPlayer; - mpMidiPlayer = new tWinIntPlayer(this); + mpMidiPlayer = new JZWindowsIntPlayer(this); } break; } Modified: trunk/jazz/src/Resources.h =================================================================== --- trunk/jazz/src/Resources.h 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/Resources.h 2008-04-13 00:18:54 UTC (rev 458) @@ -34,7 +34,8 @@ #define ID_EXPORT_SELECTION_AS_MIDI wxID_HIGHEST + 2 #define ID_SETTINGS_METRONOME wxID_HIGHEST + 10 -#define ID_SETTINGS_SYNTH wxID_HIGHEST + 11 +#define ID_SETTINGS_SYNTHESIZER wxID_HIGHEST + 11 +#define ID_SETTINGS_MIDI_DEVICE wxID_HIGHEST + 12 #define ID_TRIM wxID_HIGHEST + 30 #define ID_QUANTIZE wxID_HIGHEST + 31 Modified: trunk/jazz/src/TrackFrame.cpp =================================================================== --- trunk/jazz/src/TrackFrame.cpp 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/TrackFrame.cpp 2008-04-13 00:18:54 UTC (rev 458) @@ -39,6 +39,10 @@ #include "Dialogs/SynthesizerSettingsDialog.h" #include "AboutDialog.h" +#ifdef __WXMSW__ +#include "mswin/WindowsPlayer.h" +#endif + // These are the tool bar icons. #include "Bitmaps/open.xpm" #include "Bitmaps/save.xpm" @@ -93,8 +97,10 @@ EVT_MENU(ID_SETTINGS_METRONOME, JZTrackFrame::OnSettingsMetronome) - EVT_MENU(ID_SETTINGS_SYNTH, JZTrackFrame::OnSettingsSynthesizerType) + EVT_MENU(ID_SETTINGS_SYNTHESIZER, JZTrackFrame::OnSettingsSynthesizerType) + EVT_MENU(ID_SETTINGS_MIDI_DEVICE, JZTrackFrame::OnSettingsMidiDevice) + EVT_MENU(wxID_HELP_CONTENTS, JZTrackFrame::OnHelpContents) EVT_MENU(wxID_ABOUT, JZTrackFrame::OnHelpAbout) @@ -334,19 +340,21 @@ pSettingMenu->Append(MEN_TIMING, "&Timing..."); pSettingMenu->Append(MEN_MIDI_THRU, "&Midi Thru..."); #endif - pSettingMenu->Append(ID_SETTINGS_SYNTH, "&Synthesizer Type..."); + pSettingMenu->Append(ID_SETTINGS_SYNTHESIZER, "&Synthesizer Type..."); -#if 0 #ifdef __WXMSW__ - pSettingMenu->Append(MEN_DEVICE, "&Midi Device..."); + pSettingMenu->Append(ID_SETTINGS_MIDI_DEVICE, "&Midi Device..."); #else if ( gpConfig->GetValue(C_MidiDriver) == eMidiDriverOss || gpConfig->GetValue(C_MidiDriver) == eMidiDriverAlsa) { - pSettingMenu->Append(MEN_DEVICE, "&Midi Device..."); + pSettingMenu->Append(ID_SETTINGS_MIDI_DEVICE, "&Midi Device..."); } #endif + +#if 0 + save_settings_menu = new wxMenu; save_settings_menu->Append( MEN_SAVE_THRU, "&Midi Thru" ); save_settings_menu->Append( MEN_SAVE_TIM, "&Timing" ); @@ -567,6 +575,41 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +void JZTrackFrame::OnSettingsMidiDevice(wxCommandEvent& Event) +{ + long InputDevice, OutputDevice; +#ifdef __WXMSW__ + gpConfig->Get(C_WinInputDevice, InputDevice); + gpConfig->Get(C_WinOutputDevice, OutputDevice); + JZWindowsPlayer::SettingsDlg(InputDevice, OutputDevice); + ::wxMessageBox( + "Restart Jazz++ to activate changes in device settings", + "Info", + wxOK); +#else +/* + if (gpConfig->GetValue(C_MidiDriver) == eMidiDriverOss) + { + int Device = mpMidiPlayer->FindMidiDevice(); + if (Device >= 0) + { + SaveMidiDeviceSettings(Device); + ::wxMessageBox( + "Restart Jazz++ to activate changes in device settings", + "Info", + wxOK); + } + else + { + ::wxMessageBox("No midi device found", "Info", wxOK); + } + } +*/ +#endif +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZTrackFrame::OnHelpContents(wxCommandEvent& Event) { ::wxGetApp().DisplayHelpContents(); Modified: trunk/jazz/src/TrackFrame.h =================================================================== --- trunk/jazz/src/TrackFrame.h 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/TrackFrame.h 2008-04-13 00:18:54 UTC (rev 458) @@ -88,6 +88,8 @@ void OnSettingsSynthesizerType(wxCommandEvent& Event); + void OnSettingsMidiDevice(wxCommandEvent& Event); + void OnHelpContents(wxCommandEvent& Event); void OnHelpAbout(wxCommandEvent& Event); Modified: trunk/jazz/src/gui/trackwinEnum.h =================================================================== --- trunk/jazz/src/gui/trackwinEnum.h 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/gui/trackwinEnum.h 2008-04-13 00:18:54 UTC (rev 458) @@ -84,7 +84,6 @@ MEN_SUB_CC1=61, MEN_SUB_CC2=62, MEN_CLEANUP=63, - MEN_DEVICE=64, MEN_SAVE_SET=65, MEN_MIDI_THRU=66, MEN_COPYRIGHT=67, Modified: trunk/jazz/src/mswin/WindowsAudioInterface.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsAudioInterface.cpp 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/mswin/WindowsAudioInterface.cpp 2008-04-13 00:18:54 UTC (rev 458) @@ -50,7 +50,7 @@ public: - tAudioListener(tWinAudioPlayer* pPlayer, int key) + tAudioListener(JZWindowsAudioPlayer* pPlayer, int key) : wxTimer(), mpPlayer(pPlayer), mCount(0), @@ -74,7 +74,7 @@ } tAudioListener( - tWinAudioPlayer* pPlayer, + JZWindowsAudioPlayer* pPlayer, tSample& spl, long fr_smpl, long to_smpl) @@ -133,7 +133,7 @@ private: - tWinAudioPlayer* mpPlayer; + JZWindowsAudioPlayer* mpPlayer; long mCount; @@ -144,8 +144,8 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -tWinAudioPlayer::tWinAudioPlayer(JZSong* pSong) - : tWinIntPlayer(pSong), +JZWindowsAudioPlayer::JZWindowsAudioPlayer(JZSong* pSong) + : JZWindowsIntPlayer(pSong), mErrorCode(NoError), mCanDuplex(false), mCanSynchronize(true), @@ -197,7 +197,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -tWinAudioPlayer::~tWinAudioPlayer() +JZWindowsAudioPlayer::~JZWindowsAudioPlayer() { delete mpListener; delete AudioBuffer; @@ -211,7 +211,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinAudioPlayer::ShowError() +void JZWindowsAudioPlayer::ShowError() { const char* pMessage = 0; switch (mErrorCode) @@ -249,14 +249,14 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tWinAudioPlayer::LoadSamples(const char *filename) +int JZWindowsAudioPlayer::LoadSamples(const char *filename) { return mSamples.Load(filename); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tWinAudioPlayer::OpenDsp() +int JZWindowsAudioPlayer::OpenDsp() { int i; MMRESULT res; @@ -369,7 +369,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tWinAudioPlayer::CloseDsp() +int JZWindowsAudioPlayer::CloseDsp() { // todo: close the device immediately if open @@ -441,13 +441,13 @@ { if (wMsg == MM_WOM_DONE || wMsg == MM_WIM_DATA) { - ((tWinAudioPlayer *)dwUser)->AudioCallback(wMsg); + ((JZWindowsAudioPlayer *)dwUser)->AudioCallback(wMsg); } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinAudioPlayer::AudioCallback(UINT wMsg) +void JZWindowsAudioPlayer::AudioCallback(UINT wMsg) { // async called by driver when the driver has processed a buffer completely EnterCriticalSection(&mutex); @@ -468,7 +468,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinAudioPlayer::StartAudio() +void JZWindowsAudioPlayer::StartAudio() { // async called by driver to start audio in sync with midi if (hout_open) @@ -487,7 +487,7 @@ // Description: // Send the sample set to driver. //----------------------------------------------------------------------------- -void tWinAudioPlayer::WriteBuffers() +void JZWindowsAudioPlayer::WriteBuffers() { if (audio_enabled && hout_open) { @@ -514,7 +514,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinAudioPlayer::Notify() +void JZWindowsAudioPlayer::Notify() { if (audio_enabled) { @@ -599,15 +599,15 @@ LeaveCriticalSection(&mutex); } // if (audio_enabled) - tWinIntPlayer::Notify(); + JZWindowsIntPlayer::Notify(); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinAudioPlayer::StartPlay(long Clock, long LoopClock, int Continue) +void JZWindowsAudioPlayer::StartPlay(long Clock, long LoopClock, int Continue) { mSamples.StartPlay(Clock); - tWinIntPlayer::StartPlay(Clock, LoopClock, Continue); + JZWindowsIntPlayer::StartPlay(Clock, LoopClock, Continue); if (!audio_enabled) return; @@ -625,9 +625,9 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinAudioPlayer::StopPlay() +void JZWindowsAudioPlayer::StopPlay() { - tWinIntPlayer::StopPlay(); + JZWindowsIntPlayer::StopPlay(); CloseDsp(); mSamples.StopPlay(); if (RecordMode()) @@ -646,7 +646,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinAudioPlayer::ListenAudio(int key, int start_stop_mode) +void JZWindowsAudioPlayer::ListenAudio(int key, int start_stop_mode) { if (!audio_enabled) { @@ -677,7 +677,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinAudioPlayer::ListenAudio(tSample &spl, long fr_smpl, long to_smpl) +void JZWindowsAudioPlayer::ListenAudio(tSample &spl, long fr_smpl, long to_smpl) { if (!audio_enabled) return; @@ -694,7 +694,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -long tWinAudioPlayer::GetListenerPlayPosition() +long JZWindowsAudioPlayer::GetListenerPlayPosition() { if (!mpListener) { @@ -705,7 +705,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tWinAudioPlayer::RecordMode() const +int JZWindowsAudioPlayer::RecordMode() const { return rec_info != 0 && rec_info->mpTrack->GetAudioMode(); } Modified: trunk/jazz/src/mswin/WindowsAudioInterface.h =================================================================== --- trunk/jazz/src/mswin/WindowsAudioInterface.h 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/mswin/WindowsAudioInterface.h 2008-04-13 00:18:54 UTC (rev 458) @@ -29,10 +29,11 @@ #include "Audio.h" #include "WindowsMidiInterface.h" - class tSample; -class tWinAudioPlayer : public tWinIntPlayer +//***************************************************************************** +//***************************************************************************** +class JZWindowsAudioPlayer : public JZWindowsIntPlayer { friend class tAudioListener; @@ -51,9 +52,9 @@ ErrCapSync }; - tWinAudioPlayer(JZSong* pSong); + JZWindowsAudioPlayer(JZSong* pSong); - virtual ~tWinAudioPlayer(); + virtual ~JZWindowsAudioPlayer(); int LoadSamples(const char *filename); @@ -67,7 +68,7 @@ virtual int Installed() { - return installed && tWinIntPlayer::Installed(); + return installed && JZWindowsIntPlayer::Installed(); } virtual int GetAudioEnabled() const @@ -134,8 +135,8 @@ int CloseDsp(); // 0 = ok int installed; - int audio_enabled; // 0 means midi only - long blocks_played; // # of blocks written to device + int audio_enabled; // 0 means midi only + long blocks_played; // # of blocks written to device int play_buffers_needed; // driver requests more output buffers long start_clock; // when did play start Modified: trunk/jazz/src/mswin/WindowsMidiInterface.h =================================================================== --- trunk/jazz/src/mswin/WindowsMidiInterface.h 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/mswin/WindowsMidiInterface.h 2008-04-13 00:18:54 UTC (rev 458) @@ -48,7 +48,7 @@ ); } -class tWinAudioPlayer; +class JZWindowsAudioPlayer; // pseudo data word of struct midi_event, values must be less // than 128 to be distinguished from a midi status @@ -348,7 +348,7 @@ tMidiQueue play_buffer; tMidiQueue thru_buffer; - tWinAudioPlayer* audio_player; + JZWindowsAudioPlayer* audio_player; long time_correction; tWinSysexBufferArray* isx_buffers; Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-04-13 00:18:54 UTC (rev 458) @@ -45,7 +45,7 @@ //***************************************************************************** //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -tWinPlayer::tWinPlayer(JZSong* pSong) +JZWindowsPlayer::JZWindowsPlayer(JZSong* pSong) : JZPlayer(pSong) { poll_millisec = 25; @@ -161,14 +161,14 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tWinPlayer::Installed() +int JZWindowsPlayer::Installed() { return timer_installed && state->hout; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -tWinPlayer::~tWinPlayer() +JZWindowsPlayer::~JZWindowsPlayer() { if (state->hinp) { @@ -193,14 +193,14 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::SetSoftThru(int on, int InputDevice, int OutputDevice) +void JZWindowsPlayer::SetSoftThru(int on, int InputDevice, int OutputDevice) { state->soft_thru = on; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -JZEvent *tWinPlayer::Dword2Event(DWORD dw) +JZEvent *JZWindowsPlayer::Dword2Event(DWORD dw) { union { @@ -250,7 +250,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -DWORD tWinPlayer::Event2Dword(JZEvent *e) +DWORD JZWindowsPlayer::Event2Dword(JZEvent *e) { union { @@ -355,7 +355,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -long tWinPlayer::Clock2Time(long clock) +long JZWindowsPlayer::Clock2Time(long clock) { if (clock < state->start_clock) return state->start_time; @@ -365,7 +365,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -long tWinPlayer::Time2Clock(long time) +long JZWindowsPlayer::Time2Clock(long time) { if (time < state->start_time) return state->start_clock; @@ -376,7 +376,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::SetTempo(long bpm, long clock) +void JZWindowsPlayer::SetTempo(long bpm, long clock) { long t1 = Clock2Time(clock); state->ticks_per_minute = (long)bpm * (long)Song->TicksPerQuarter; @@ -386,7 +386,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -long tWinPlayer::RealTimeClock2Time(long clock) +long JZWindowsPlayer::RealTimeClock2Time(long clock) { if (clock < state->start_clock) return real_start_time; @@ -395,7 +395,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -long tWinPlayer::Time2RealTimeClock(long time) +long JZWindowsPlayer::Time2RealTimeClock(long time) { if (time < real_start_time) return state->start_clock; @@ -404,7 +404,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::SetRealTimeTempo(long bpm, long clock) +void JZWindowsPlayer::SetRealTimeTempo(long bpm, long clock) { long t1 = RealTimeClock2Time(clock); real_ticks_per_minute = (long)bpm * (long)Song->TicksPerQuarter; @@ -414,7 +414,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tWinPlayer::OutSysex(JZEvent *e, DWORD time) +int JZWindowsPlayer::OutSysex(JZEvent *e, DWORD time) { tSysEx *sx = e->IsSysEx(); if (sx == 0) @@ -433,7 +433,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tWinPlayer::OutEvent(JZEvent *e) +int JZWindowsPlayer::OutEvent(JZEvent *e) { DWORD d = Event2Dword(e); if (d) @@ -449,7 +449,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -int tWinMidiPlayer::OutEvent(JZEvent *e) +int JZWindowsMidiPlayer::OutEvent(JZEvent *e) { DWORD d = Event2Dword(e); if (d) @@ -466,7 +466,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::OutNow(JZEvent* pEvent) +void JZWindowsPlayer::OutNow(JZEvent* pEvent) { DWORD d = Event2Dword(pEvent); if (d) @@ -503,7 +503,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::OutNow(tParam *r) +void JZWindowsPlayer::OutNow(tParam *r) { OutNow(&r->Msb); OutNow(&r->Lsb); @@ -512,7 +512,9 @@ OutNow(&r->ResetLsb); } -void tWinPlayer::FillMidiClocks(long to) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZWindowsPlayer::FillMidiClocks(long to) { while (midiClockOut <= to) { @@ -525,7 +527,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::OutBreak(long clock) +void JZWindowsPlayer::OutBreak(long clock) { if (gpConfig->GetValue(C_RealTimeOut)) { @@ -540,7 +542,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinMidiPlayer::OutBreak(long clock) +void JZWindowsMidiPlayer::OutBreak(long clock) { if (gpConfig->GetValue(C_RealTimeOut)) { @@ -555,7 +557,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::OutBreak() +void JZWindowsPlayer::OutBreak() { OutBreak(OutClock); } @@ -587,7 +589,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::StartPlay(long Clock, long LoopClock, int Continue) +void JZWindowsPlayer::StartPlay(long Clock, long LoopClock, int Continue) { state->play_buffer.clear(); state->recd_buffer.clear(); @@ -696,7 +698,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::StopPlay() +void JZWindowsPlayer::StopPlay() { wxBeginBusyCursor(); state->playing = FALSE; @@ -750,7 +752,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::FlushToDevice() +void JZWindowsPlayer::FlushToDevice() // try to send all events up to OutClock to device { if (gpConfig->GetValue(C_RealTimeOut)) @@ -763,7 +765,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::FlushToDevice(long clock) +void JZWindowsPlayer::FlushToDevice(long clock) { tEventIterator Iterator(&mPlayBuffer); JZEvent* pEvent = Iterator.Range(0, clock); @@ -782,7 +784,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -long tWinIntPlayer::GetRealTimeClock() +long JZWindowsIntPlayer::GetRealTimeClock() { while (!state->recd_buffer.empty()) { @@ -826,7 +828,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -long tWinMidiPlayer::GetRealTimeClock() +long JZWindowsMidiPlayer::GetRealTimeClock() { long clock; @@ -880,7 +882,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -long tWinMtcPlayer::GetRealTimeClock() +long JZWindowsMtcPlayer::GetRealTimeClock() { long clock; @@ -960,7 +962,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinMtcPlayer::InitMtcRec() +void JZWindowsMtcPlayer::InitMtcRec() { state->doing_mtc_rec = TRUE; StartPlay( 0, 0, 0 ); @@ -968,7 +970,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -tMtcTime* tWinMtcPlayer::FreezeMtcRec() +tMtcTime* JZWindowsMtcPlayer::FreezeMtcRec() { StopPlay(); state->doing_mtc_rec = FALSE; @@ -979,7 +981,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tWinPlayer::SettingsDlg(long& InputDevice, long& OutputDevice) +void JZWindowsPlayer::SettingsDlg(long& InputDevice, long& OutputDevice) { vector<pair<string, int> > MidiDevices; Modified: trunk/jazz/src/mswin/WindowsPlayer.h =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.h 2008-04-11 17:26:33 UTC (rev 457) +++ trunk/jazz/src/mswin/WindowsPlayer.h 2008-04-13 00:18:54 UTC (rev 458) @@ -34,14 +34,14 @@ //***************************************************************************** //***************************************************************************** -class tWinPlayer : public JZPlayer +class JZWindowsPlayer : public JZPlayer { public: - tWinPlayer(JZSong* pSong); + JZWindowsPlayer(JZSong* pSong); int Installed(); - virtual ~tWinPlayer(); + virtual ~JZWindowsPlayer(); virtual int OutEvent(JZEvent* e); virtual int OutSysex(JZEvent* e, DWORD time); void OutNow(JZEvent *e); @@ -98,12 +98,12 @@ //***************************************************************************** //***************************************************************************** -class tWinIntPlayer : public tWinPlayer +class JZWindowsIntPlayer : public JZWindowsPlayer { public: - tWinIntPlayer(JZSong* pSong) - : tWinPlayer(pSong) + JZWindowsIntPlayer(JZSong* pSong) + : JZWindowsPlayer(pSong) { } @@ -112,27 +112,27 @@ //***************************************************************************** //***************************************************************************** -class tWinMidiPlayer : public tWinPlayer +class JZWindowsMidiPlayer : public JZWindowsPlayer { public: - tWinMidiPlayer(JZSong* pSong) - : tWinPlayer(pSong) + JZWindowsMidiPlayer(JZSong* pSong) + : JZWindowsPlayer(pSong) { } virtual long GetRealTimeClock(); - virtual int OutEvent(JZEvent *e); + virtual int OutEvent(JZEvent* pEvent); virtual void OutBreak(long clock); }; //***************************************************************************** //***************************************************************************** -class tWinMtcPlayer : public tWinPlayer +class JZWindowsMtcPlayer : public JZWindowsPlayer { public: - tWinMtcPlayer(JZSong* pSong) - : tWinPlayer(pSong) + JZWindowsMtcPlayer(JZSong* pSong) + : JZWindowsPlayer(pSong) { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-14 17:18:29
|
Revision: 461 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=461&view=rev Author: pstieber Date: 2008-04-14 10:18:22 -0700 (Mon, 14 Apr 2008) Log Message: ----------- Fixed OnPaint versions, and commented out an unused variable. Modified Paths: -------------- trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/PianoWindow.h Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2008-04-14 16:55:24 UTC (rev 460) +++ trunk/jazz/src/PianoWindow.cpp 2008-04-14 17:18:22 UTC (rev 461) @@ -1922,7 +1922,7 @@ { if (mPlayClock != Clock) { - int OldPlayClock = mPlayClock; +// int OldPlayClock = mPlayClock; mPlayClock = Clock; // wxRect InvalidateRect; // InvalidateRect.x = Clock2x(OldPlayClock) - 1; Modified: trunk/jazz/src/PianoWindow.h =================================================================== --- trunk/jazz/src/PianoWindow.h 2008-04-14 16:55:24 UTC (rev 460) +++ trunk/jazz/src/PianoWindow.h 2008-04-14 17:18:22 UTC (rev 461) @@ -265,7 +265,7 @@ void OnDraw(wxDC& Dc); - void OnPaint(wxMouseEvent& Event); + void OnPaint(wxPaintEvent& Event); void OnMouseEvent(wxMouseEvent& Event); @@ -283,8 +283,6 @@ bool OnCharHook(wxKeyEvent& Event); - void OnPaint(wxPaintEvent& Event); - void OnChar(wxKeyEvent& Event); bool OnKeyEvent(wxKeyEvent& Event); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-19 23:20:22
|
Revision: 464 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=464&view=rev Author: pstieber Date: 2008-04-19 16:20:18 -0700 (Sat, 19 Apr 2008) Log Message: ----------- Added a string utility function that tokenizes a std::string based on the passed delimiters. Added Paths: ----------- trunk/jazz/src/StringUtilities.cpp trunk/jazz/src/StringUtilities.h Added: trunk/jazz/src/StringUtilities.cpp =================================================================== --- trunk/jazz/src/StringUtilities.cpp (rev 0) +++ trunk/jazz/src/StringUtilities.cpp 2008-04-19 23:20:18 UTC (rev 464) @@ -0,0 +1,63 @@ +//***************************************************************************** +// The JAZZ++ Midi Sequencer +// +// Copyright (C) 2008 Peter J. Stieber, all rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//***************************************************************************** + +#include "StringUtilities.h" + +using namespace std; + +//----------------------------------------------------------------------------- +// Decsription: +// This function tokenizes the input string. +//----------------------------------------------------------------------------- +unsigned TNStringUtilities::Tokenize( + const string& Delimiters, + const string& InputString, + vector<string>& Tokens) +{ + // make sure the vector of tokens is empty. + Tokens.clear(); + + string::size_type Begin, End; + + // Initialize the token index. + unsigned TokenIndex = 0; + + // Search the beginning of the string for the first token. + Begin = InputString.find_first_not_of(Delimiters); + + // While at the beginning of a word found. + while (Begin != string::npos) + { + // Search for the end of the actual token. + End = InputString.find_first_of(Delimiters, Begin); + + if (End == string::npos) + { + End = InputString.length(); + } + + Tokens.push_back(InputString.substr(Begin, End - Begin)); + + ++TokenIndex; + + Begin = InputString.find_first_not_of(Delimiters, End); + } + return TokenIndex; +} Property changes on: trunk/jazz/src/StringUtilities.cpp ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/jazz/src/StringUtilities.h =================================================================== --- trunk/jazz/src/StringUtilities.h (rev 0) +++ trunk/jazz/src/StringUtilities.h 2008-04-19 23:20:18 UTC (rev 464) @@ -0,0 +1,41 @@ +//***************************************************************************** +// The JAZZ++ Midi Sequencer +// +// Copyright (C) 2008 Peter J. Stieber, all rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//***************************************************************************** + +#ifndef TRC_STRINGUTILITIES_H +#define TRC_STRINGUTILITIES_H + +#include <string> +#include <vector> + +namespace TNStringUtilities +{ + +//----------------------------------------------------------------------------- +// Decsription: +// This function tokenizes the input string. +//----------------------------------------------------------------------------- +unsigned Tokenize( + const std::string& Delimiters, + const std::string& InputString, + std::vector<std::string>& Tokens); + +}; + +#endif // !defined(TRC_STRINGUTILITIES_H) Property changes on: trunk/jazz/src/StringUtilities.h ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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] |
From: <pst...@us...> - 2008-04-21 03:14:46
|
Revision: 469 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=469&view=rev Author: pstieber Date: 2008-04-20 20:14:43 -0700 (Sun, 20 Apr 2008) Log Message: ----------- Updated the Linux specific modules for the latest changes. Modified Paths: -------------- trunk/jazz/src/AlsaDriver.cpp trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/AudioDriver.cpp trunk/jazz/src/Player.cpp Modified: trunk/jazz/src/AlsaDriver.cpp =================================================================== --- trunk/jazz/src/AlsaDriver.cpp 2008-04-20 00:33:04 UTC (rev 468) +++ trunk/jazz/src/AlsaDriver.cpp 2008-04-21 03:14:43 UTC (rev 469) @@ -187,7 +187,7 @@ return; } - long ticks_per_minute = Song->TicksPerQuarter * Song->Speed(); + long ticks_per_minute = Song->GetTicksPerQuarter() * Song->Speed(); mSamples.ResetBuffers(AudioBuffer, clock, ticks_per_minute); last_scount = 0; cur_pos = 0; @@ -522,8 +522,8 @@ if (pcm[PLAYBACK]) { snd_pcm_drop(pcm[PLAYBACK]); - //long ticks_per_minute = Song->TicksPerQuarter * Song->Speed(); - //mSamples.ResetBuffers(AudioBuffer, clock, ticks_per_minute); +// long ticks_per_minute = Song->GetTicksPerQuarter() * Song->Speed(); +// mSamples.ResetBuffers(AudioBuffer, clock, ticks_per_minute); } audio_clock_offset = clock; cur_pos = 0; Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-04-20 00:33:04 UTC (rev 468) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-04-21 03:14:43 UTC (rev 469) @@ -322,8 +322,8 @@ tKeyOn *k = e->IsKeyOn(); set_event_header(&ev, e->GetClock(), SND_SEQ_EVENT_NOTEON); ev.data.note.channel = k->Channel; - ev.data.note.note = k->Key; - ev.data.note.velocity = k->Veloc; + ev.data.note.note = k->mKey; + ev.data.note.velocity = k->mVelocity; rc = write(&ev, now); } break; @@ -592,7 +592,7 @@ //----------------------------------------------------------------------------- int tAlsaPlayer::start_timer(long clock) { - int time_base = Song->TicksPerQuarter; + int time_base = Song->GetTicksPerQuarter(); int cur_speed = Song->GetTrack(0)->GetCurrentSpeed(clock); init_queue_tempo(time_base, cur_speed); start_queue_timer(clock); Modified: trunk/jazz/src/AudioDriver.cpp =================================================================== --- trunk/jazz/src/AudioDriver.cpp 2008-04-20 00:33:04 UTC (rev 468) +++ trunk/jazz/src/AudioDriver.cpp 2008-04-21 03:14:43 UTC (rev 469) @@ -193,7 +193,7 @@ return; } - long ticks_per_minute = Song->TicksPerQuarter * Song->Speed(); + long ticks_per_minute = Song->GetTicksPerQuarter() * Song->Speed(); mSamples.ResetBuffers(AudioBuffer, start_clock, ticks_per_minute); if (PlaybackMode()) { Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-04-20 00:33:04 UTC (rev 468) +++ trunk/jazz/src/Player.cpp 2008-04-21 03:14:43 UTC (rev 469) @@ -1568,16 +1568,24 @@ { case StatKeyOn: { - tKeyOn *k = e->IsKeyOn(); - SEQ_START_NOTE(mididev, k->Channel, k->Key, k->Veloc); + tKeyOn* pKeyOn = e->IsKeyOn(); + SEQ_START_NOTE( + mididev, + pKeyOn->Channel, + pKeyOn->mKey, + pKeyOn->mVelocity); if (now) seqbuf_flush_last_event(); } break; case StatKeyOff: { - tKeyOff *k = e->IsKeyOff(); - SEQ_STOP_NOTE(mididev, k->Channel, k->Key, k->OffVeloc); + tKeyOff* pKeyOff = e->IsKeyOff(); + SEQ_STOP_NOTE( + mididev, + pKeyOff->Channel, + pKeyOff->Key, + pKeyOff->OffVeloc); if (now) seqbuf_flush_last_event(); } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-22 04:38:41
|
Revision: 474 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=474&view=rev Author: pstieber Date: 2008-04-21 21:38:39 -0700 (Mon, 21 Apr 2008) Log Message: ----------- 1. Added a drum set container accessor to the configuration class. 2. Added more code to the track dialog. 3. Changed tMetaEvent::Data to mpData. 4. Made cosmetic changes to the synthesizer class. Modified Paths: -------------- trunk/jazz/src/Configuration.h trunk/jazz/src/Dialogs/TrackDialog.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Events.h trunk/jazz/src/Synth.cpp trunk/jazz/src/Track.cpp trunk/jazz/src/Track.h trunk/jazz/src/TrackWindow.cpp trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/Configuration.h =================================================================== --- trunk/jazz/src/Configuration.h 2008-04-21 13:49:25 UTC (rev 473) +++ trunk/jazz/src/Configuration.h 2008-04-22 04:38:39 UTC (rev 474) @@ -244,6 +244,8 @@ bool Put(int entry); bool Put(int entry, int value); + const std::vector<std::pair<std::string, int> >& GetDrumSets() const; + const std::vector<std::pair<std::string, int> >& GetDrumNames() const; const std::vector<std::pair<std::string, int> >& GetControlNames() const; @@ -301,6 +303,15 @@ //----------------------------------------------------------------------------- inline const std::vector<std::pair<std::string, int> >& +JZConfiguration::GetDrumSets() const +{ + return mDrumSets; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +inline +const std::vector<std::pair<std::string, int> >& JZConfiguration::GetDrumNames() const { return mDrumNames; Modified: trunk/jazz/src/Dialogs/TrackDialog.cpp =================================================================== --- trunk/jazz/src/Dialogs/TrackDialog.cpp 2008-04-21 13:49:25 UTC (rev 473) +++ trunk/jazz/src/Dialogs/TrackDialog.cpp 2008-04-22 04:38:39 UTC (rev 474) @@ -38,20 +38,20 @@ mpTrackNameEdit = new wxTextCtrl(this, wxID_ANY); mpPatchListBox = new wxListBox(this, wxID_ANY); - if (Track.IsDrumTrack()) + if (mTrack.IsDrumTrack()) { - const vector<pair<string, int> >& DrumNames = gpConfig->GetDrumNames(); + const vector<pair<string, int> >& DrumSets = gpConfig->GetDrumSets(); for ( - vector<pair<string, int> >::const_iterator iDrumName = - DrumNames.begin(); - iDrumName != DrumNames.end(); - ++iDrumName) + vector<pair<string, int> >::const_iterator iDrumSet = + DrumSets.begin(); + iDrumSet != DrumSets.end(); + ++iDrumSet) { - const string& DrumName = iDrumName->first; + const string& DrumSet = iDrumSet->first; - if (!DrumName.empty()) + if (!DrumSet.empty()) { - mpPatchListBox->Append(DrumName.c_str()); + mpPatchListBox->Append(DrumSet.c_str()); } } } @@ -84,15 +84,15 @@ new wxStaticText(this, wxID_ANY, "Track Name:"), 0, wxALL, - 2); - pTopSizer->Add(mpTrackNameEdit, 0, wxGROW | wxALL, 2); + 4); + pTopSizer->Add(mpTrackNameEdit, 0, wxGROW | wxALL, 4); pTopSizer->Add( new wxStaticText(this, wxID_ANY, "Patch:"), 0, wxALL, - 2); - pTopSizer->Add(mpPatchListBox, 0, wxGROW | wxALL, 2); + 4); + pTopSizer->Add(mpPatchListBox, 0, wxGROW | wxALL, 4); wxBoxSizer* pButtonSizer = new wxBoxSizer(wxHORIZONTAL); pButtonSizer->Add(pOkButton, 0, wxALL, 5); @@ -114,6 +114,9 @@ { mpTrackNameEdit->ChangeValue(mTrack.GetName()); + int PatchIndex = mTrack.GetPatch() + (mTrack.GetBank() << 8); + mpPatchListBox->SetSelection(PatchIndex); + return true; } @@ -121,5 +124,17 @@ //----------------------------------------------------------------------------- bool JZTrackDialog::TransferDataFromWindow() { + wxString Trackname = mpTrackNameEdit->GetValue(); + mTrack.SetName(Trackname.c_str()); + + int Selection = mpPatchListBox->GetSelection(); + if (Selection != wxNOT_FOUND) + { + int Patch = Selection & 0x000000ff;; + int Bank = (Selection & 0x0000ff00) >> 8; + mTrack.SetPatch(Patch); + mTrack.SetBank(Bank); + } + return true; } Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2008-04-21 13:49:25 UTC (rev 473) +++ trunk/jazz/src/Dialogs.cpp 2008-04-22 04:38:39 UTC (rev 474) @@ -1152,8 +1152,8 @@ for (int i = 0; i < s->Length; i++) { - sprintf( hexbyte, "%02x ", s->Data[i] ); - strcat( str, hexbyte ); + sprintf(hexbyte, "%02x ", s->mpData[i]); + strcat(str, hexbyte); } } @@ -1245,7 +1245,7 @@ ostringstream Oss; Oss << "First data byte is at offset " - << uptr - Event->IsSysEx()->Data + 1 << ", value " + << uptr - Event->IsSysEx()->mpData + 1 << ", value " << setw(2) << hex << static_cast<int>(*uptr) << dec << " (" << static_cast<int>(*uptr) << " decimal)"; sheet->AddProperty(new wxProperty( Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-04-21 13:49:25 UTC (rev 473) +++ trunk/jazz/src/Events.h 2008-04-22 04:38:39 UTC (rev 474) @@ -861,27 +861,32 @@ { public: - unsigned char* Data; + unsigned char* mpData; unsigned short Length; - tMetaEvent(int clk, unsigned char sta, unsigned char *dat, unsigned short len) + tMetaEvent( + int clk, + unsigned char sta, + unsigned char* dat, + unsigned short len) : JZEvent(clk, sta) { Length = len; - Data = new unsigned char [len + 1]; + mpData = new unsigned char [len + 1]; if (dat) - memcpy(Data, dat, len); - Data[len] = 0; + memcpy(mpData, dat, len); + mpData[len] = 0; } virtual ~tMetaEvent() { - delete [] Data; + delete [] mpData; } virtual int Write(JZWriteBase &io) { - edb(); return io.Write(this, Data, Length); + edb(); + return io.Write(this, mpData, Length); } virtual tMetaEvent* IsMetaEvent() @@ -893,7 +898,7 @@ virtual JZEvent* Copy() const { edb(); - return new tMetaEvent(mClock, Stat, Data, Length); + return new tMetaEvent(mClock, Stat, mpData, Length); } }; @@ -910,44 +915,50 @@ : tMetaEvent(clk, StatJazzMeta, dat, len) { } - tJazzMeta() : tMetaEvent(0, StatJazzMeta, 0, DATALEN) { - memset(Data, 0, DATALEN); - memcpy(Data, "JAZ2", 4); - Data[4] = 1; // version or so + tJazzMeta() + : tMetaEvent(0, StatJazzMeta, 0, DATALEN) + { + memset(mpData, 0, DATALEN); + memcpy(mpData, "JAZ2", 4); + mpData[4] = 1; // version or so } - char GetAudioMode() const { - return Data[5]; + char GetAudioMode() const + { + return mpData[5]; } - void SetAudioMode(char c) { - Data[5] = c; + void SetAudioMode(char c) + { + mpData[5] = c; } - char GetTrackState() const { - return Data[6]; + char GetTrackState() const + { + return mpData[6]; } - void SetTrackState(char c) { - Data[6] = c; + void SetTrackState(char c) + { + mpData[6] = c; } - // Data[7] is unused + // mpData[7] is unused unsigned char GetTrackDevice() const { - return Data[8]; + return mpData[8]; } void SetTrackDevice(unsigned char x) { - Data[8] = x; + mpData[8] = x; } unsigned char GetIntroLength() const { - return Data[9]; + return mpData[9]; } void SetIntroLength(unsigned char x) { - Data[9] = x; + mpData[9] = x; } virtual tJazzMeta* IsJazzMeta() @@ -959,7 +970,7 @@ virtual JZEvent* Copy() const { edb(); - return new tJazzMeta(mClock, Data, Length); + return new tJazzMeta(mClock, mpData, Length); } }; @@ -982,7 +993,7 @@ virtual JZEvent* Copy() const { edb(); - return new tSysEx(mClock, Data, Length); + return new tSysEx(mClock, mpData, Length); } // todo @@ -1007,7 +1018,7 @@ virtual JZEvent* Copy() const { edb(); - return new tSongPtr(mClock, Data, Length); + return new tSongPtr(mClock, mpData, Length); } }; @@ -1033,7 +1044,7 @@ virtual JZEvent* Copy() const { edb(); - return new tMidiClock(mClock, Data, Length); + return new tMidiClock(mClock, mpData, Length); } }; @@ -1057,7 +1068,7 @@ virtual JZEvent* Copy() const { edb(); - return new tStartPlay(mClock, Data, Length); + return new tStartPlay(mClock, mpData, Length); } }; @@ -1083,7 +1094,7 @@ virtual JZEvent* Copy() const { edb(); - return new tContPlay(mClock, Data, Length); + return new tContPlay(mClock, mpData, Length); } }; @@ -1110,7 +1121,7 @@ virtual JZEvent* Copy() const { edb(); - return new tStopPlay(mClock, Data, Length); + return new tStopPlay(mClock, mpData, Length); } }; @@ -1134,12 +1145,12 @@ virtual JZEvent* Copy() const { edb(); - return new tText(mClock, Data, Length); + return new tText(mClock, mpData, Length); } virtual unsigned char* GetText() { - return Data; + return mpData; } }; @@ -1163,7 +1174,7 @@ virtual JZEvent* Copy() const { edb(); - return new tCopyright(mClock, Data, Length); + return new tCopyright(mClock, mpData, Length); } }; @@ -1181,7 +1192,7 @@ // clip to 16 chars if (len > 16) { - Data[16] = 0; + mpData[16] = 0; Length = 16; } #endif @@ -1197,7 +1208,7 @@ virtual JZEvent* Copy() const { edb(); - return new tTrackName(mClock, Data, Length); + return new tTrackName(mClock, mpData, Length); } }; @@ -1221,7 +1232,7 @@ virtual JZEvent* Copy() const { edb(); - return new tMarker(mClock, Data, Length); + return new tMarker(mClock, mpData, Length); } }; @@ -1278,16 +1289,16 @@ virtual int Write(JZWriteBase &io) { - Data = new unsigned char [Length + 1]; - int* dat = (int *)Data; + mpData = new unsigned char [Length + 1]; + int* dat = (int *)mpData; dat[0] = track; dat[1] = transpose; dat[2] = eventlength; Length = sizeof(int) * 3; edb(); - Data[Length] = 0; - return io.Write(this, Data, Length); + mpData[Length] = 0; + return io.Write(this, mpData, Length); } virtual tPlayTrack* IsPlayTrack() @@ -1388,7 +1399,7 @@ virtual JZEvent* Copy() const { edb(); - return new tMtcOffset(mClock, Data, Length); + return new tMtcOffset(mClock, mpData, Length); } }; Modified: trunk/jazz/src/Synth.cpp =================================================================== --- trunk/jazz/src/Synth.cpp 2008-04-21 13:49:25 UTC (rev 473) +++ trunk/jazz/src/Synth.cpp 2008-04-22 04:38:39 UTC (rev 474) @@ -25,7 +25,6 @@ #include "Synth.h" #include "Track.h" -//#include "util.h" #include "Player.h" #include "JazzPlusPlusApplication.h" //#include "eventwin.h" @@ -340,37 +339,37 @@ gs_dt1[4] = 0x40; gs_dt1[5] = 0x20; - for ( i = 0; i < 11; i++ ) + for (i = 0; i < 11; i++) { gs_dt1[6] = 0x00 + i; SXDECL(SX_GS_ModPitch + i, GS_DT1_LEN, gs_dt1); } - for ( i = 0; i < 11; i++ ) + for (i = 0; i < 11; i++) { gs_dt1[6] = 0x10 + i; SXDECL(SX_GS_BendPitch + i, GS_DT1_LEN, gs_dt1); } - for ( i = 0; i < 11; i++ ) + for (i = 0; i < 11; i++) { gs_dt1[6] = 0x20 + i; SXDECL(SX_GS_CafPitch + i, GS_DT1_LEN, gs_dt1); } - for ( i = 0; i < 11; i++ ) + for (i = 0; i < 11; i++) { gs_dt1[6] = 0x30 + i; SXDECL(SX_GS_PafPitch + i, GS_DT1_LEN, gs_dt1); } - for ( i = 0; i < 11; i++ ) + for (i = 0; i < 11; i++) { gs_dt1[6] = 0x40 + i; SXDECL(SX_GS_CC1Pitch + i, GS_DT1_LEN, gs_dt1); } - for ( i = 0; i < 11; i++ ) + for (i = 0; i < 11; i++) { gs_dt1[6] = 0x50 + i; SXDECL(SX_GS_CC2Pitch + i, GS_DT1_LEN, gs_dt1); @@ -378,19 +377,44 @@ gs_dt1[4] = 0x40; gs_dt1[5] = 0x01; - for ( i = 0; i < 7; i++ ) + for (i = 0; i < 7; i++) { gs_dt1[6] = 0x30 + i; SXDECL(SX_GS_ReverbMacro + i, GS_DT1_LEN, gs_dt1); } - for ( i = 0; i < 8; i++ ) + for (i = 0; i < 8; i++) { gs_dt1[6] = 0x38 + i; SXDECL(SX_GS_ChorusMacro + i, GS_DT1_LEN, gs_dt1); } - const unsigned char gs_partial_reserve[] = {GS_DT1,0x40,0x01,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf7}; + const unsigned char gs_partial_reserve[] = + { + GS_DT1, + 0x40, + 0x01, + 0x10, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0xf7 + }; + SXDECL(SX_GS_PartialReserve, GS_DT1_LEN, gs_partial_reserve); gs_dt1[4] = 0x40; @@ -413,8 +437,6 @@ gs_dt1[6] = 0x20; SXDECL(SX_GS_CC2CtrlNo, GS_DT1_LEN, gs_dt1); - - // XG native const unsigned char xg_on[] = {XG_NAT,0x00,0x00,0x7e,0x00,0xf7}; SXDECL(SX_XG_ON, XG_NAT_LEN, xg_on); @@ -422,13 +444,13 @@ // XG native multipart unsigned char xg_multi[] = {XG_NAT,0x08,0x00,0x00,0x00,0x7f}; - for ( i = 0; i < 12; i++ ) + for (i = 0; i < 12; i++) { xg_multi[5] = 0x1d + i; SXDECL(SX_XG_ModPitch + i, XG_NAT_LEN, xg_multi); } - for ( i = 0; i < 26; i++ ) + for (i = 0; i < 26; i++) { xg_multi[5] = 0x4d + i; SXDECL(SX_XG_CafPitch + i, XG_NAT_LEN, xg_multi); @@ -470,11 +492,11 @@ if (!s) return SX_NONE; - switch (s->Data[0]) + switch (s->mpData[0]) { case 0x7e: // GM ON ? - if (!memcmp(sxdata[SX_GM_ON], s->Data, s->Length)) + if (!memcmp(sxdata[SX_GM_ON], s->mpData, s->Length)) { return SX_GM_ON; } @@ -486,7 +508,7 @@ case 0x7f: // GM MasterVol ? - if (!memcmp(sxdata[SX_GM_MasterVol],s->Data,4)) + if (!memcmp(sxdata[SX_GM_MasterVol], s->mpData, 4)) { return SX_GM_MasterVol; } @@ -500,11 +522,11 @@ // Roland! // GS DT1? - if ((s->Data[2] == 0x42) && (s->Data[3] == 0x12)) + if ((s->mpData[2] == 0x42) && (s->mpData[3] == 0x12)) { - register unsigned char a1 = s->Data[4]; - register unsigned char a2 = s->Data[5]; - register unsigned char a3 = s->Data[6]; + register unsigned char a1 = s->mpData[4]; + register unsigned char a2 = s->mpData[5]; + register unsigned char a3 = s->mpData[6]; if (a1 == 0x40) { @@ -536,7 +558,7 @@ else if (a3 == 0x10) return SX_GS_PartialReserve; } - else if ( (a2 & 0xf0) == 0x10 ) + else if ((a2 & 0xf0) == 0x10) { // 0x40 0x1n 0x?? switch (a3) @@ -556,7 +578,7 @@ break; } } - else if ( (a2 & 0xf0) == 0x20 ) + else if ((a2 & 0xf0) == 0x20) { // 0x40 0x2n 0x?? if (a3 <= 0x0a) @@ -575,11 +597,11 @@ } // end a1 == 0x40 } // end GS DT1 - if ((s->Data[3] == 0x12) && (s->Length >= 10)) + if ((s->mpData[3] == 0x12) && (s->Length >= 10)) { return SX_ROLAND_DT1; } - else if ((s->Data[3] == 0x11) && (s->Length >= 12)) + else if ((s->mpData[3] == 0x11) && (s->Length >= 12)) { return SX_ROLAND_RQ1; } @@ -593,11 +615,11 @@ case 0x43: // Yamaha! // XG Native? - if (((s->Data[1] & 0xf0) == 0x10) && (s->Data[2] == 0x4c)) + if (((s->mpData[1] & 0xf0) == 0x10) && (s->mpData[2] == 0x4c)) { - register unsigned char a1 = s->Data[3]; - register unsigned char a2 = s->Data[4]; - register unsigned char a3 = s->Data[5]; + register unsigned char a1 = s->mpData[3]; + register unsigned char a2 = s->mpData[4]; + register unsigned char a3 = s->mpData[5]; // Multipart? if (a1 == 0x08) @@ -648,11 +670,11 @@ } } - if (s->Data[2] == 0x4c) + if (s->mpData[2] == 0x4c) { return SX_XG_NATIVE; } - else if (s->Data[2] == 0x49) + else if (s->mpData[2] == 0x49) { return SX_MU80_NATIVE; } @@ -679,38 +701,38 @@ return 0; } - switch (s->Data[0]) + switch (s->mpData[0]) { case 0x7f: // GM MasterVol? - if (!memcmp(sxdata[SX_GM_MasterVol],s->Data,4)) + if (!memcmp(sxdata[SX_GM_MasterVol], s->mpData,4)) { - return &s->Data[4]; + return &s->mpData[4]; } break; case 0x41: // Roland! // GS DT1? - if ((s->Data[2] == 0x42) && (s->Data[3] == 0x12) && (s->Length >= 10)) + if ((s->mpData[2] == 0x42) && (s->mpData[3] == 0x12) && (s->Length >= 10)) { - return &s->Data[7]; + return &s->mpData[7]; } // other DT1 or RQ1 ? else if ( - ((s->Data[3] == 0x12) && (s->Length >= 10)) || - ((s->Data[3] == 0x11) && (s->Length >= 12))) + ((s->mpData[3] == 0x12) && (s->Length >= 10)) || + ((s->mpData[3] == 0x11) && (s->Length >= 12))) { - return &s->Data[7]; + return &s->mpData[7]; } break; case 0x43: // Yamaha! // XG Native? - if (((s->Data[1] & 0xf0) == 0x10) && (s->Data[2] == 0x4c)) + if (((s->mpData[1] & 0xf0) == 0x10) && (s->mpData[2] == 0x4c)) { - return &s->Data[6]; + return &s->mpData[6]; } break; default: @@ -730,17 +752,21 @@ return 0; } - switch (s->Data[0]) + switch (s->mpData[0]) { case 0x41: // Roland! // GS DT1 + address 0x40? - if ((s->Data[2] == 0x42) && (s->Data[3] == 0x12) && - (s->Data[4] == 0x40)) + if ( + (s->mpData[2] == 0x42) && + (s->mpData[3] == 0x12) && + (s->mpData[4] == 0x40)) { - if ( ((s->Data[5] & 0xf0) == 0x10 ) || ((s->Data[5] & 0xf0) == 0x20 ) ) + if ( + ((s->mpData[5] & 0xf0) == 0x10) || + ((s->mpData[5] & 0xf0) == 0x20)) { - return &s->Data[5]; + return &s->mpData[5]; } } break; @@ -748,9 +774,12 @@ case 0x43: // Yamaha! // XG Native multipart? - if (((s->Data[1] & 0xf0) == 0x10) && (s->Data[2] == 0x4c) && (s->Data[3] == 0x08)) + if ( + ((s->mpData[1] & 0xf0) == 0x10) && + (s->mpData[2] == 0x4c) && + (s->mpData[3] == 0x08)) { - return &s->Data[4]; + return &s->mpData[4]; } break; default: @@ -763,16 +792,16 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tSynthSysex::FixCheckSum( tSysEx *s ) +void tSynthSysex::FixCheckSum(tSysEx* s) { if ( - (s->Data[0] == 0x41) && - (((s->Data[3] == 0x12) && (s->Length >= 10)) || - ((s->Data[3] == 0x11) && (s->Length >= 12)))) + (s->mpData[0] == 0x41) && + (((s->mpData[3] == 0x12) && (s->Length >= 10)) || + ((s->mpData[3] == 0x11) && (s->Length >= 12)))) { // Roland RQ1 or DT1 int len = s->Length; - unsigned char *sx = s->Data; + unsigned char *sx = s->mpData; unsigned char sum = 0x00; for (int i = 4; i < (len-2); i++) @@ -793,7 +822,11 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -tSysEx* tSynthSysex::operator()(long clk, int id, int datalen, unsigned char val[]) +tSysEx* tSynthSysex::operator()( + long clk, + int id, + int datalen, + unsigned char val[]) { return (*this)(clk, id, -1, datalen, val); } @@ -807,18 +840,18 @@ int datalen, unsigned char val[]) { - assert( (id > SX_NONE) && (id < NumSysexIds) ); - assert( datalen > 0 ); + assert((id > SX_NONE) && (id < NumSysexIds)); + assert(datalen > 0); int i; for (i = 0; i < datalen; i++) { - assert( val[i] < 128 ); + assert(val[i] < 128); } int len = sxlen[id] + datalen - 1; unsigned char* sx = new unsigned char[len]; - memcpy( sx, sxdata[id], sxlen[id] ); + memcpy(sx, sxdata[id], sxlen[id]); tSysEx* s = 0; if (id == SX_GM_MasterVol) @@ -829,7 +862,7 @@ else sx[4] = 0; sx[5] = val[0]; // MSB - s = new tSysEx( clk, sx, len ); + s = new tSysEx(clk, sx, len); } else if ((id > SX_GS_ON) && (id < SX_XG_ON)) { @@ -839,7 +872,7 @@ if (channel >= 0) { - sx[5] = sx[5] | sysex_channel( channel ); + sx[5] = sx[5] | sysex_channel(channel); } unsigned char sum = 0x00; @@ -847,20 +880,22 @@ sum += sx[i]; sx[len - 2] = (0x80 - (sum & 0x7f)) & 0x7f; sx[len-1] = 0xf7; - s = new tSysEx( clk, sx, len ); + s = new tSysEx(clk, sx, len); } else if (id > SX_XG_ON) { // XG Native for (i = 0; i < datalen; i++) + { sx[i+6] = val[i]; + } if (channel >= 0) { sx[4] = channel - 1; } sx[len-1] = 0xf7; - s = new tSysEx( clk, sx, len ); + s = new tSysEx(clk, sx, len); } delete sx; @@ -868,194 +903,194 @@ } -JZEvent* tGS::MasterVolSX( long clk, unsigned char vol ) +JZEvent* tGS::MasterVolSX(long clk, unsigned char vol) { - return Sysex( clk, SX_GS_MasterVol, vol ); + return Sysex(clk, SX_GS_MasterVol, vol); } -JZEvent* tGS::MasterPanSX( long clk, unsigned char pan ) +JZEvent* tGS::MasterPanSX(long clk, unsigned char pan) { - return Sysex( clk, SX_GS_MasterPan, pan ); + return Sysex(clk, SX_GS_MasterPan, pan); } -JZEvent* tGS::ModSX( int index, long clk, int cha, unsigned char val ) +JZEvent* tGS::ModSX(int index, long clk, int cha, unsigned char val) { - return Sysex( clk, SX_GS_ModPitch + index, cha, 1, &val ); + return Sysex(clk, SX_GS_ModPitch + index, cha, 1, &val); } -JZEvent* tGS::BendSX( int index, long clk, int cha, unsigned char val ) +JZEvent* tGS::BendSX(int index, long clk, int cha, unsigned char val) { - return Sysex( clk, SX_GS_BendPitch + index, cha, 1, &val ); + return Sysex(clk, SX_GS_BendPitch + index, cha, 1, &val); } -JZEvent* tGS::CafSX( int index, long clk, int cha, unsigned char val ) +JZEvent* tGS::CafSX(int index, long clk, int cha, unsigned char val) { - return Sysex( clk, SX_GS_CafPitch + index, cha, 1, &val ); + return Sysex(clk, SX_GS_CafPitch + index, cha, 1, &val); } -JZEvent* tGS::PafSX( int index, long clk, int cha, unsigned char val ) +JZEvent* tGS::PafSX(int index, long clk, int cha, unsigned char val) { - return Sysex( clk, SX_GS_PafPitch + index, cha, 1, &val ); + return Sysex(clk, SX_GS_PafPitch + index, cha, 1, &val); } -JZEvent* tGS::CC1SX( int index, long clk, int cha, unsigned char val ) +JZEvent* tGS::CC1SX(int index, long clk, int cha, unsigned char val) { - return Sysex( clk, SX_GS_CC1Pitch + index, cha, 1, &val ); + return Sysex(clk, SX_GS_CC1Pitch + index, cha, 1, &val); } -JZEvent* tGS::CC2SX( int index, long clk, int cha, unsigned char val ) +JZEvent* tGS::CC2SX(int index, long clk, int cha, unsigned char val) { - return Sysex( clk, SX_GS_CC2Pitch + index, cha, 1, &val ); + return Sysex(clk, SX_GS_CC2Pitch + index, cha, 1, &val); } -JZEvent* tGS::PartialReserveSX( long clk, int cha, unsigned char *valptr ) +JZEvent* tGS::PartialReserveSX(long clk, int cha, unsigned char *valptr) { - return Sysex( clk, SX_GS_PartialReserve, 16, valptr ); + return Sysex(clk, SX_GS_PartialReserve, 16, valptr); } -JZEvent* tGS::RxChannelSX( long clk, int cha, unsigned char val ) +JZEvent* tGS::RxChannelSX(long clk, int cha, unsigned char val) { - return Sysex( clk, SX_GS_RxChannel, cha, 1, &val ); + return Sysex(clk, SX_GS_RxChannel, cha, 1, &val); } -JZEvent* tGS::UseForRhythmSX( long clk, int cha, unsigned char val ) +JZEvent* tGS::UseForRhythmSX(long clk, int cha, unsigned char val) { - return Sysex( clk, SX_GS_UseForRhythm, cha, 1, &val ); + return Sysex(clk, SX_GS_UseForRhythm, cha, 1, &val); } -JZEvent* tGS::ControllerNumberSX( int ctrlno, long clk, int cha, unsigned char val ) +JZEvent* tGS::ControllerNumberSX(int ctrlno, long clk, int cha, unsigned char val) { - if (ctrlno == 1) - return Sysex( clk, SX_GS_CC1CtrlNo, cha, 1, &val ); - else if (ctrlno == 2) - return Sysex( clk, SX_GS_CC2CtrlNo, cha, 1, &val ); - else - return 0; + if (ctrlno == 1) + return Sysex(clk, SX_GS_CC1CtrlNo, cha, 1, &val); + else if (ctrlno == 2) + return Sysex(clk, SX_GS_CC2CtrlNo, cha, 1, &val); + else + return 0; } -JZEvent* tGS::ReverbMacroSX( long clk, unsigned char val, unsigned char lsb ) +JZEvent* tGS::ReverbMacroSX(long clk, unsigned char val, unsigned char lsb) { - return Sysex( clk, SX_GS_ReverbMacro, val ); + return Sysex(clk, SX_GS_ReverbMacro, val); } -JZEvent* tGS::ReverbParamSX( int index, long clk, unsigned char val ) +JZEvent* tGS::ReverbParamSX(int index, long clk, unsigned char val) { - return Sysex( clk, SX_GS_RevCharacter + index, val ); + return Sysex(clk, SX_GS_RevCharacter + index, val); } -JZEvent* tGS::ChorusMacroSX( long clk, unsigned char val, unsigned char lsb ) +JZEvent* tGS::ChorusMacroSX(long clk, unsigned char val, unsigned char lsb) { - return Sysex( clk, SX_GS_ChorusMacro, val ); + return Sysex(clk, SX_GS_ChorusMacro, val); } -JZEvent* tGS::ChorusParamSX( int index, long clk, unsigned char val ) +JZEvent* tGS::ChorusParamSX(int index, long clk, unsigned char val) { - return Sysex( clk, SX_GS_ChoPreLpf + index, val ); + return Sysex(clk, SX_GS_ChoPreLpf + index, val); } // XG: -JZEvent* tXG::ModSX( int index, long clk, int cha, unsigned char val ) +JZEvent* tXG::ModSX(int index, long clk, int cha, unsigned char val) { if ((index >= 0) && (index <= 2)) - return Sysex( clk, SX_XG_ModPitch + index, cha, 1, &val ); + return Sysex(clk, SX_XG_ModPitch + index, cha, 1, &val); else if ((index >= 4) && (index <=6)) - return Sysex( clk, SX_XG_ModPitch + index - 1, cha, 1, &val ); + return Sysex(clk, SX_XG_ModPitch + index - 1, cha, 1, &val); else return 0; } -JZEvent* tXG::BendSX( int index, long clk, int cha, unsigned char val ) +JZEvent* tXG::BendSX(int index, long clk, int cha, unsigned char val) { if ((index >= 0) && (index <= 2)) - return Sysex( clk, SX_XG_BendPitch + index, cha, 1, &val ); + return Sysex(clk, SX_XG_BendPitch + index, cha, 1, &val); else if ((index >= 4) && (index <=6)) - return Sysex( clk, SX_XG_BendPitch + index - 1, cha, 1, &val ); + return Sysex(clk, SX_XG_BendPitch + index - 1, cha, 1, &val); else return 0; } -JZEvent* tXG::CafSX( int index, long clk, int cha, unsigned char val ) +JZEvent* tXG::CafSX(int index, long clk, int cha, unsigned char val) { if ((index >= 0) && (index <= 2)) - return Sysex( clk, SX_XG_CafPitch + index, cha, 1, &val ); + return Sysex(clk, SX_XG_CafPitch + index, cha, 1, &val); else if ((index >= 4) && (index <= 6)) - return Sysex( clk, SX_XG_CafPitch + index - 1, cha, 1, &val ); + return Sysex(clk, SX_XG_CafPitch + index - 1, cha, 1, &val); else return 0; } -JZEvent* tXG::PafSX( int index, long clk, int cha, unsigned char val ) +JZEvent* tXG::PafSX(int index, long clk, int cha, unsigned char val) { if ((index >= 0) && (index <= 2)) - return Sysex( clk, SX_XG_PafPitch + index, cha, 1, &val ); + return Sysex(clk, SX_XG_PafPitch + index, cha, 1, &val); else if ((index >= 4) && (index <= 6)) - return Sysex( clk, SX_XG_PafPitch + index - 1, cha, 1, &val ); + return Sysex(clk, SX_XG_PafPitch + index - 1, cha, 1, &val); else return 0; } -JZEvent* tXG::CC1SX( int index, long clk, int cha, unsigned char val ) +JZEvent* tXG::CC1SX(int index, long clk, int cha, unsigned char val) { if ((index >= 0) && (index <= 2)) - return Sysex( clk, SX_XG_CC1Pitch + index, cha, 1, &val ); + return Sysex(clk, SX_XG_CC1Pitch + index, cha, 1, &val); else if ((index >= 4) && (index <= 6)) - return Sysex( clk, SX_XG_CC1Pitch + index - 1, cha, 1, &val ); + return Sysex(clk, SX_XG_CC1Pitch + index - 1, cha, 1, &val); else return 0; } -JZEvent* tXG::CC2SX( int index, long clk, int cha, unsigned char val ) +JZEvent* tXG::CC2SX(int index, long clk, int cha, unsigned char val) { if ((index >= 0) && (index <= 2)) - return Sysex( clk, SX_XG_CC2Pitch + index, cha, 1, &val ); + return Sysex(clk, SX_XG_CC2Pitch + index, cha, 1, &val); else if ((index >= 4) && (index <= 6)) - return Sysex( clk, SX_XG_CC2Pitch + index - 1, cha, 1, &val ); + return Sysex(clk, SX_XG_CC2Pitch + index - 1, cha, 1, &val); else return 0; } -JZEvent* tXG::RxChannelSX( long clk, int cha, unsigned char val ) +JZEvent* tXG::RxChannelSX(long clk, int cha, unsigned char val) { - return Sysex( clk, SX_XG_RxChannel, cha, 1, &val ); + return Sysex(clk, SX_XG_RxChannel, cha, 1, &val); } -JZEvent* tXG::UseForRhythmSX( long clk, int cha, unsigned char val ) +JZEvent* tXG::UseForRhythmSX(long clk, int cha, unsigned char val) { - return Sysex( clk, SX_XG_UseForRhythm, cha, 1, &val ); + return Sysex(clk, SX_XG_UseForRhythm, cha, 1, &val); } -JZEvent* tXG::ControllerNumberSX( int ctrlno, long clk, int cha, unsigned char val ) +JZEvent* tXG::ControllerNumberSX(int ctrlno, long clk, int cha, unsigned char val) { if (ctrlno == 1) - return Sysex( clk, SX_XG_CC1CtrlNo, cha, 1, &val ); + return Sysex(clk, SX_XG_CC1CtrlNo, cha, 1, &val); else if (ctrlno == 2) - return Sysex( clk, SX_XG_CC2CtrlNo, cha, 1, &val ); + return Sysex(clk, SX_XG_CC2CtrlNo, cha, 1, &val); else return 0; } -JZEvent* tXG::ReverbMacroSX( long clk, unsigned char val, unsigned char lsb ) +JZEvent* tXG::ReverbMacroSX(long clk, unsigned char val, unsigned char lsb) { unsigned char valp[2]; valp[0] = val; valp[1] = lsb; - return Sysex( clk, SX_XG_ReverbMacro, 2, valp ); + return Sysex(clk, SX_XG_ReverbMacro, 2, valp); } -JZEvent* tXG::ChorusMacroSX( long clk, unsigned char val, unsigned char lsb ) +JZEvent* tXG::ChorusMacroSX(long clk, unsigned char val, unsigned char lsb) { - unsigned char valp[2]; - valp[0] = val; - valp[1] = lsb; + unsigned char valp[2]; + valp[0] = val; + valp[1] = lsb; - return Sysex( clk, SX_XG_ChorusMacro, 2, valp ); + return Sysex(clk, SX_XG_ChorusMacro, 2, valp); } -JZEvent* tXG::EqualizerMacroSX( long clk, unsigned char val ) +JZEvent* tXG::EqualizerMacroSX(long clk, unsigned char val) { - return Sysex( clk, SX_XG_EqualizerMacro, val ); + return Sysex(clk, SX_XG_EqualizerMacro, val); } Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-04-21 13:49:25 UTC (rev 473) +++ trunk/jazz/src/Track.cpp 2008-04-22 04:38:39 UTC (rev 474) @@ -92,7 +92,7 @@ tMtcTime::tMtcTime(tMtcOffset *s) { - type = (tMtcType) ((s->Data[0] & 0x60) >> 5); + type = (tMtcType) ((s->mpData[0] & 0x60) >> 5); if (type < Mtc24) { type = Mtc24; @@ -101,10 +101,10 @@ { type = Mtc30Ndf; } - hour = s->Data[0] & 0x1f; - min = s->Data[1]; - sec = s->Data[2]; - fm = s->Data[3]; + hour = s->mpData[0] & 0x1f; + min = s->mpData[1]; + sec = s->mpData[2]; + fm = s->mpData[3]; } tMtcTime::tMtcTime(int millisec, tMtcType t) @@ -2085,7 +2085,7 @@ { if (Copyright) { - return (const char *)Copyright->Data; + return (const char *)Copyright->mpData; } return ""; } @@ -2116,22 +2116,22 @@ { if (mName) { - return (const char*)mName->Data; + return (const char*)mName->mpData; } return ""; } -void JZTrack::SetName(char *str) +void JZTrack::SetName(const char* pTrackName) { if (mName) { Kill(mName); } - if (strlen(str)) + if (strlen(pTrackName)) { - Put(new tTrackName(0, (unsigned char *)str, strlen(str))); + Put(new tTrackName(0, (unsigned char *)pTrackName, strlen(pTrackName))); } Cleanup(); } Modified: trunk/jazz/src/Track.h =================================================================== --- trunk/jazz/src/Track.h 2008-04-21 13:49:25 UTC (rev 473) +++ trunk/jazz/src/Track.h 2008-04-22 04:38:39 UTC (rev 474) @@ -452,7 +452,7 @@ void Cleanup(); const char* GetName(); - void SetName(char *Name); + void SetName(const char *Name); const char* GetCopyright(); void SetCopyright(char *Copyright); Modified: trunk/jazz/src/TrackWindow.cpp =================================================================== --- trunk/jazz/src/TrackWindow.cpp 2008-04-21 13:49:25 UTC (rev 473) +++ trunk/jazz/src/TrackWindow.cpp 2008-04-22 04:38:39 UTC (rev 474) @@ -352,6 +352,7 @@ if (pTrack) { pTrack->Dialog(this); + Refresh(false); } } else if ( Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-04-21 13:49:25 UTC (rev 473) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-04-22 04:38:39 UTC (rev 474) @@ -426,7 +426,7 @@ state->sysex_found = TRUE; tWinSysexBuffer *buf = state->osx_buffers->AllocBuffer(); - buf->PrepareOut(state->hout, sx->Data, sx->Length - 1); + buf->PrepareOut(state->hout, sx->mpData, sx->Length - 1); state->play_buffer.put(SYSEX_EVENT, time); state->play_buffer.put((DWORD)buf, time); return 0; @@ -487,7 +487,7 @@ if (s->Length + 1 < maxSysLen) { pSysBuf[0] = 0xf0; - memcpy(pSysBuf + 1, s->Data, s->Length); + memcpy(pSysBuf + 1, s->mpData, s->Length); pSysHdr->lpData = (LPSTR)pSysBuf; pSysHdr->dwBufferLength = s->Length + 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-22 21:35:25
|
Revision: 475 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=475&view=rev Author: pstieber Date: 2008-04-22 14:35:23 -0700 (Tue, 22 Apr 2008) Log Message: ----------- Updated Linux specific code for the recent event code change. Modified Paths: -------------- trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/Player.cpp Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-04-22 04:38:39 UTC (rev 474) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-04-22 21:35:23 UTC (rev 475) @@ -407,7 +407,7 @@ // prepend 0xf0 char *buf = new char[s->Length + 1]; buf[0] = 0xF0; - memcpy(buf + 1, s->Data, s->Length); + memcpy(buf + 1, s->mpData, s->Length); set_event_header(&ev, e->GetClock(), s->Length + 1, buf); rc = write(&ev, now); delete [] buf; Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-04-22 04:38:39 UTC (rev 474) +++ trunk/jazz/src/Player.cpp 2008-04-22 21:35:23 UTC (rev 475) @@ -1660,7 +1660,7 @@ sysex->device_no = mididev; sysex->len = s->Length + 1; sysex->data[0] = 0xf0; - memcpy(sysex->data + 1, s->Data, s->Length); + memcpy(sysex->data + 1, s->mpData, s->Length); SEQ_WRPATCH(sysex, sizeof(*sysex) + sysex->len - 1); delete [] (char *)sysex; @@ -1678,7 +1678,7 @@ SEQ_SYSEX(mididev, (unsigned char *)buf, N); i = 0; } - buf[i++] = sx->Data[j]; + buf[i++] = sx->mpData[j]; } if (i > 0) { SEQ_SYSEX(mididev, (unsigned char *)buf, i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-27 22:23:49
|
Revision: 476 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=476&view=rev Author: pstieber Date: 2008-04-27 15:23:47 -0700 (Sun, 27 Apr 2008) Log Message: ----------- 1. Renamed the tControl data members Control to mControl and Value to mValue. 2. Changed various local variable names (ctrl, copy, c, and k) to indicate they are control pointers (pControl and pControlCopy). 3. Added member functions to the track class to increase and decrease the volume (DecreaseVolume and IncreaseVolume). 4. Renamed a local event pointer e to pEvent. 5. Added code to the track window to increase or decrease the volume by clicking the left (increase) or right (decrease) mouse button in the patch column. 6. Changed the logic to ToggleTrackState could be removed from the track window. 7. Fixed a typo in a comment in the track window header. Modified Paths: -------------- trunk/jazz/src/Command.cpp trunk/jazz/src/ControlEdit.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Events.h trunk/jazz/src/Track.cpp trunk/jazz/src/Track.h trunk/jazz/src/TrackWindow.cpp trunk/jazz/src/TrackWindow.h trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/Command.cpp =================================================================== --- trunk/jazz/src/Command.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/Command.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -750,15 +750,15 @@ void tCmdSearchReplace::ExecuteEvent(JZTrack* pTrack, JZEvent* pEvent) { - tControl *ctrl; - if ((ctrl = pEvent->IsControl()) != 0) + tControl* pControl = pEvent->IsControl(); + if (pControl) { - if (ctrl->Control == fr) + if (pControl->mControl == fr) { - tControl *copy = (tControl *)ctrl->Copy(); - copy->Control = to; - pTrack->Kill(ctrl); - pTrack->Put(copy); + tControl* pControlCopy = (tControl *)pControl->Copy(); + pControlCopy->mControl = to; + pTrack->Kill(pControl); + pTrack->Put(pControlCopy); } } } Modified: trunk/jazz/src/ControlEdit.cpp =================================================================== --- trunk/jazz/src/ControlEdit.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/ControlEdit.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -314,10 +314,10 @@ { if (IsCtrlEdit(pEvent)) { - if (Clock2Val(pEvent->GetClock()) != pEvent->IsControl()->Value) + if (Clock2Val(pEvent->GetClock()) != pEvent->IsControl()->mValue) { pControlCopy = pEvent->Copy()->IsControl(); - pControlCopy->Value = Clock2Val(pEvent->GetClock()); + pControlCopy->mValue = Clock2Val(pEvent->GetClock()); track->Kill(pEvent); track->Put(pControlCopy); } @@ -470,13 +470,13 @@ int tCtrlEdit::IsCtrlEdit(JZEvent* pEvent) { - tControl *c = pEvent->IsControl(); - return (c && c->Control == ctrl_num); + tControl* pControl = pEvent->IsControl(); + return (pControl && pControl->mControl == ctrl_num); } int tCtrlEdit::GetValue(JZEvent* pEvent) { - return pEvent->IsControl()->Value; + return pEvent->IsControl()->mValue; } JZEvent * tCtrlEdit::NewEvent(long clock, int val) Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/Dialogs.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -853,16 +853,16 @@ // Choice("Controller", &gpConfig->GetCtrlName(0), &Control) { Event = e; - Value = e->Value; - Control = e->Control + 1; + Value = e->mValue; + Control = e->mControl + 1; } bool tControlDlg::OnClose() { - ((tControl *)Copy)->Value = Value; + ((tControl *)Copy)->mValue = Value; // Choice.GetValue(); - ((tControl *)Copy)->Control = Control - 1; + ((tControl *)Copy)->mControl = Control - 1; return tChEventDlg::OnClose(); } Modified: trunk/jazz/src/Events.h =================================================================== --- trunk/jazz/src/Events.h 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/Events.h 2008-04-27 22:23:47 UTC (rev 476) @@ -739,20 +739,20 @@ { public: - unsigned char Control; - unsigned char Value; + unsigned char mControl; + unsigned char mValue; tControl(int clk, int cha, unsigned char ctl, unsigned char val) : tChannelEvent(clk, StatControl, cha) { - Control = ctl; - Value = val; + mControl = ctl; + mValue = val; } virtual int Write(JZWriteBase &io) { edb(); - return io.Write(this, Control, Value); + return io.Write(this, mControl, mValue); } virtual tControl* IsControl() @@ -770,19 +770,19 @@ virtual int GetValue() const { edb(); - return Control; + return mControl; } virtual int GetPitch() const { edb(); - return Control; + return mControl; } virtual void SetPitch(int p) { edb(); - Control = p; + mControl = p; } virtual const wxPen* GetPen() const Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/Track.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -246,14 +246,14 @@ } tDrumInstrumentParameter::tDrumInstrumentParameter(tNrpn *par) - : pitch(par->Lsb.Value), + : pitch(par->Lsb.mValue), next(0) { for (int i = drumPitchIndex; i < numDrumParameters; i++) { param[i] = 0; } - param[drumParam2Index(par->Msb.Value)] = par; + param[drumParam2Index(par->Msb.mValue)] = par; } tNrpn *tDrumInstrumentParameter::Get(int index) @@ -264,7 +264,7 @@ void tDrumInstrumentParameter::Put(tNrpn *par) { - param[par->Lsb.Value] = par; + param[par->Lsb.mValue] = par; } tDrumInstrumentParameter *tDrumInstrumentParameter::Next() @@ -304,7 +304,7 @@ void tDrumInstrumentParameterList::PutParam(tNrpn *par) { - tDrumInstrumentParameter *ptr = GetElem(par->Lsb.Value); + tDrumInstrumentParameter* ptr = GetElem(par->Lsb.mValue); if (!ptr) { ptr = new tDrumInstrumentParameter(par); @@ -313,7 +313,7 @@ } else { - ptr->param[drumParam2Index(par->Msb.Value)] = par; + ptr->param[drumParam2Index(par->Msb.mValue)] = par; } } @@ -731,7 +731,7 @@ void tEventArray::Cleanup(bool dont_delete_killed_events) { JZEvent *e; - tControl *c; + tControl* pControl; tSysEx *s; int i; @@ -845,32 +845,32 @@ { MtcOffset = e->IsMtcOffset(); } - if ((c = e->IsControl()) != 0) + if ((pControl = e->IsControl()) != 0) { - switch (c->Control) + switch (pControl->mControl) { case 0x07: if (!Volume) { - Volume = c; + Volume = pControl; } break; case 0x0a: if (!Pan) { - Pan = c; + Pan = pControl; } break; case 0x5b: if (!Reverb) { - Reverb = c; + Reverb = pControl; } break; case 0x5d: if (!Chorus) { - Chorus = c; + Chorus = pControl; } break; } @@ -1380,7 +1380,7 @@ WrittenBefore = 0; if (e->IsControl()) { - switch (e->IsControl()->Control) + switch (e->IsControl()->mControl) { // Don't write these again if present as events // and clock == 0 (should not happen) @@ -1451,22 +1451,22 @@ } if (e->IsControl()) { - switch (e->IsControl()->Control) + switch (e->IsControl()->mControl) { // Grab Rpn/Nrpn/Bank from file and save them, don't put // them into event-array case 0x63: case 0x65: - Msb = e->IsControl()->Value; // Rpn/Nrpn Msb + Msb = e->IsControl()->mValue; // Rpn/Nrpn Msb SpecialEvent = 1; break; case 0x62: case 0x64: - Lsb = e->IsControl()->Value; // Rpn/Nrpn Lsb + Lsb = e->IsControl()->mValue; // Rpn/Nrpn Lsb SpecialEvent = 1; break; case 0x06: - Data = e->IsControl()->Value; // Rpn/Nrpn Data + Data = e->IsControl()->mValue; // Rpn/Nrpn Data SpecialEvent = 1; cha = e->IsControl()->Channel; switch (Msb) @@ -2142,7 +2142,7 @@ { if (Volume) { - return Volume->Value + 1; + return Volume->mValue + 1; } return 0; } @@ -2155,20 +2155,58 @@ } if (Value > 0) { - JZEvent *e = new tControl(0, Channel - 1, 0x07, Value - 1); - Put(e); - gpMidiPlayer->OutNow(this, e); + JZEvent* pEvent = new tControl(0, Channel - 1, 0x07, Value - 1); + Put(pEvent); + gpMidiPlayer->OutNow(this, pEvent); } Cleanup(); } +bool JZTrack::DecreaseVolume() +{ + if (Volume && Volume->mValue > 0) + { + Kill(Volume); + + --Volume->mValue; + + JZEvent* pEvent = new tControl(0, Channel - 1, 0x07, Volume->mValue); + Put(pEvent); + gpMidiPlayer->OutNow(this, pEvent); + + Cleanup(); + + return true; + } + return false; +} + +bool JZTrack::IncreaseVolume() +{ + if (Volume && Volume->mValue < 127) + { + Kill(Volume); + + ++Volume->mValue; + + JZEvent* pEvent = new tControl(0, Channel - 1, 0x07, Volume->mValue); + Put(pEvent); + gpMidiPlayer->OutNow(this, pEvent); + + Cleanup(); + + return true; + } + return false; +} + // ------------------------ Pan ------------------------------ int JZTrack::GetPan() { if (Pan) { - return Pan->Value + 1; + return Pan->mValue + 1; } return 0; } @@ -2194,7 +2232,7 @@ { if (Reverb) { - return Reverb->Value + 1; + return Reverb->mValue + 1; } return 0; } @@ -2220,7 +2258,7 @@ { if (Chorus) { - return Chorus->Value + 1; + return Chorus->mValue + 1; } return 0; } @@ -2250,7 +2288,7 @@ if (mpBank) { DEBUG(fprintf(stderr,"Bank %d selected.\n\n",mpBank->Value);) - return mpBank->Value; + return mpBank->mValue; } else { @@ -2263,8 +2301,8 @@ for (int i=0; gpConfig->BankEntry(i).Command[0]>=0; i++) { if ( - gpConfig->BankEntry(i).Command[0] == mpBank->Value && - gpConfig->BankEntry(i).Command[1] == mpBank2->Value) + gpConfig->BankEntry(i).Command[0] == mpBank->mValue && + gpConfig->BankEntry(i).Command[1] == mpBank2->mValue) { DEBUG(fprintf(stderr,"Bank %d selected.\n\n",i);) return i; Modified: trunk/jazz/src/Track.h =================================================================== --- trunk/jazz/src/Track.h 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/Track.h 2008-04-27 22:23:47 UTC (rev 476) @@ -72,7 +72,7 @@ virtual void SetCha( unsigned char cha ); virtual int GetVal() { - return( DataMsb.Value ); + return DataMsb.mValue; } tControl Msb; @@ -472,6 +472,8 @@ int GetVolume(); void SetVolume(int Volume); + bool DecreaseVolume(); + bool IncreaseVolume(); int GetPan(); void SetPan(int Pan); @@ -575,8 +577,6 @@ tMtcTime* GetMtcOffset(); void SetMtcOffset( tMtcTime* mtc ); - - }; Modified: trunk/jazz/src/TrackWindow.cpp =================================================================== --- trunk/jazz/src/TrackWindow.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/TrackWindow.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -142,7 +142,8 @@ Dc.GetTextExtent("999", &Width, &Height); mPatchWidth = Width + 2 * mLittleBit; - mLeftInfoWidth = mNumberWidth + mTrackNameWidth + mStateWidth + mPatchWidth + 1; + mLeftInfoWidth = + mNumberWidth + mTrackNameWidth + mStateWidth + mPatchWidth + 1; //DEBUG cout //DEBUG << ' ' << mNumberWidth @@ -280,10 +281,10 @@ // Check to see if the mouse was clicked in the top header. if (Point.y < mTopInfoHeight) { - // Check to see if the mouse was clicked inside of the number mode - // indicator. - if (Point.x < mNumberWidth && Point.y < mTopInfoHeight) + if (Point.x < mNumberWidth) { + // The point is inside of the number mode indicator, so toggle the first + // column between track index and MIDI channel. if (mNumberMode == eNmTrackNr) { mNumberMode = eNmMidiChannel; @@ -295,11 +296,13 @@ Refresh(false); } } - // Check to see if the mouse was clicked inside of the track name header. else if ( Point.x >= mTrackNameX && Point.x < mTrackNameX + mTrackNameWidth) { + // The point is inside of the track name header. This cell indicates + // the song tempo. + // Bump up the speed value one tick. int SpeedBpm = gpProject->GetTrack(0)->GetDefaultSpeed(); ++SpeedBpm; @@ -309,9 +312,10 @@ } Refresh(false); } - // Check to see if the mouse was clicked inside of the patch header. else if (Point.x >= mPatchX && Point.x < mPatchX + mPatchWidth) { + // The point is inside the patch header. + // Toggle the patch type. switch (mCounterMode) { @@ -338,29 +342,46 @@ Refresh(false); } } - else if (Point.x >= mStateX && Point.x < mStateX + mStateWidth) + else { - ToggleTrackState(Point); - } - // Check to see if the mouse was clicked inside of a track name. - else if ( - Point.x >= mTrackNameX && - Point.x < mTrackNameX + mTrackNameWidth) - { - // Edit the track settings. + // The point is not in the top header row. + + // Get the track associated with the y position. JZTrack* pTrack = y2Track(Point.y); if (pTrack) { - pTrack->Dialog(this); - Refresh(false); + if (Point.x < mNumberWidth) + { + // The point is inside the number field. + } + else if ( + Point.x >= mTrackNameX && + Point.x < mTrackNameX + mTrackNameWidth) + { + // The point is inside of a track name column. Edit the track + // settings. + pTrack->Dialog(this); + Refresh(false); + } + else if (Point.x >= mStateX && Point.x < mStateX + mStateWidth) + { + // The point is inside the track name field. Toggle the track state. + pTrack->ToggleState(1); + Refresh(false); + } + else if (Point.x >= mPatchX && Point.x < mPatchX + mPatchWidth) + { + IncreaseTrackNumberField(pTrack); + } + else if ( + Point.x >= mEventsX && Point.x < mEventsX + mEventsWidth && + Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight) + { + // The point is in event area. + SnapSelectionStop(Event); + } } } - else if ( - Point.x >= mEventsX && Point.x < mEventsX + mEventsWidth && - Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight) - { - SnapSelectionStop(Event); - } } //----------------------------------------------------------------------------- @@ -369,29 +390,103 @@ { wxPoint Point = Event.GetPosition(); - if ( - Point.x >= mTrackNameX && Point.x < mTrackNameX + mTrackNameWidth && - Point.y < mTopInfoHeight) + if (Point.y < mTopInfoHeight) { - // Knock down the speed value one tick. - int SpeedBpm = gpProject->GetTrack(0)->GetDefaultSpeed(); - --SpeedBpm; - if (SpeedBpm > 0 && SpeedBpm < 300) + // The point is inside the top header line. + + if (Point.x >= mTrackNameX && Point.x < mTrackNameX + mTrackNameWidth) { - gpProject->GetTrack(0)->SetDefaultSpeed(SpeedBpm); + // The point is inside the track name field. + int SpeedBpm = gpProject->GetTrack(0)->GetDefaultSpeed(); + + // Knock down the speed value one tick. + --SpeedBpm; + + if (SpeedBpm > 0 && SpeedBpm < 300) + { + gpProject->GetTrack(0)->SetDefaultSpeed(SpeedBpm); + } + Refresh(false); } + } + else + { + // The point is below the top header line. + + // Get the track associated with the y position. + JZTrack* pTrack = y2Track(Point.y); + if (pTrack) + { + if (Point.x < mNumberWidth) + { + // The point is inside the number field. + } + else if (Point.x >= mStateX && Point.x < mStateX + mStateWidth) + { + // The point is inside the track name field. + } + else if (Point.x >= mPatchX && Point.x < mPatchX + mPatchWidth) + { + DecreaseTrackNumberField(pTrack); + } + } + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZTrackWindow::IncreaseTrackNumberField(JZTrack* pTrack) +{ + bool UpdateFlag = false; + + switch (mCounterMode) + { + case eCmProgram: + break; + case eCmBank: + break; + case eCmVolume: + UpdateFlag = pTrack->IncreaseVolume(); + break; + case eCmPan: + break; + case eCmReverb: + break; + case eCmChorus: + default: + break; + } + if (UpdateFlag) + { Refresh(false); } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZTrackWindow::ToggleTrackState(const wxPoint& Point) +void JZTrackWindow::DecreaseTrackNumberField(JZTrack* pTrack) { - JZTrack* pTrack = y2Track(Point.y); - if (pTrack) + bool UpdateFlag = false; + + switch (mCounterMode) { - pTrack->ToggleState(1); + case eCmProgram: + break; + case eCmBank: + break; + case eCmVolume: + UpdateFlag = pTrack->DecreaseVolume(); + break; + case eCmPan: + break; + case eCmReverb: + break; + case eCmChorus: + default: + break; + } + if (UpdateFlag) + { Refresh(false); } } Modified: trunk/jazz/src/TrackWindow.h =================================================================== --- trunk/jazz/src/TrackWindow.h 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/TrackWindow.h 2008-04-27 22:23:47 UTC (rev 476) @@ -104,8 +104,10 @@ void VerticalScroll(wxScrollWinEvent& Event); - void ToggleTrackState(const wxPoint& Point); + void IncreaseTrackNumberField(JZTrack* pTrack); + void DecreaseTrackNumberField(JZTrack* pTrack); + virtual void OnDraw(wxDC& Dc); void Draw(wxDC& Dc); @@ -157,7 +159,7 @@ int mPlayClock; bool mUseColors; - // The values indicate the staring postions and widths of the track fields + // The values indicate the starting postions and widths of the track fields // on the left hand side of the screen. Note that the position of the // first field displayed is always 0, so it doesn't need to be recorded. int mNumberWidth; Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-04-22 21:35:23 UTC (rev 475) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-04-27 22:23:47 UTC (rev 476) @@ -299,10 +299,10 @@ case StatControl: { - tControl *k = e->IsControl(); - u.c[0] = 0xB0 | k->Channel; - u.c[1] = k->Control; - u.c[2] = k->Value; + tControl* pControl = e->IsControl(); + u.c[0] = 0xB0 | pControl->Channel; + u.c[1] = pControl->mControl; + u.c[2] = pControl->mValue; } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-28 01:27:15
|
Revision: 477 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=477&view=rev Author: pstieber Date: 2008-04-27 18:27:11 -0700 (Sun, 27 Apr 2008) Log Message: ----------- Changed the way the knob control works. The control is no longer angle based, but captures the mouse. Left-dragging up or down changes the value, left/right double-click increases/decreases the value, and the mouse wheel also increases/decreases the value. Modified Paths: -------------- trunk/jazz/src/Knob.cpp trunk/jazz/src/Knob.h Modified: trunk/jazz/src/Knob.cpp =================================================================== --- trunk/jazz/src/Knob.cpp 2008-04-27 22:23:47 UTC (rev 476) +++ trunk/jazz/src/Knob.cpp 2008-04-28 01:27:11 UTC (rev 477) @@ -78,16 +78,31 @@ EVT_SIZE(JZKnob::OnSize) EVT_ERASE_BACKGROUND(JZKnob::OnEraseBackground) EVT_PAINT(JZKnob::OnPaint) - EVT_LEFT_DOWN(JZKnob::OnMouse) - EVT_LEFT_UP(JZKnob::OnMouse) - EVT_MOTION(JZKnob::OnMouse) - EVT_MOUSEWHEEL(JZKnob::OnMouse) + EVT_LEFT_DOWN(JZKnob::OnLeftButtonDown) + EVT_RIGHT_DOWN(JZKnob::OnRightButtonDown) + EVT_MOTION(JZKnob::OnMouseMove) + EVT_LEFT_UP(JZKnob::OnLeftButtonUp) + EVT_LEFT_DCLICK(JZKnob::OnLeftButtonDoubleClick) + EVT_RIGHT_DCLICK(JZKnob::OnRightButtonDoubleClick) + EVT_MOUSEWHEEL(JZKnob::OnMouseWheel) END_EVENT_TABLE() //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +int JZKnob::mSensitivity = 4; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- JZKnob::JZKnob() - : wxControl() + : wxControl(), + mMinValue(0), + mMaxValue(100), + mSetting(50), + mRange(300), + mMaxAngle(300), + mBuffer(), + mDragging(false), + mLastPoint() { } @@ -106,7 +121,15 @@ long WindowStyle, const wxValidator& Validator, const wxString& Name) - : wxControl() + : wxControl(), + mMinValue(0), + mMaxValue(100), + mSetting(50), + mRange(300), + mMaxAngle(300), + mBuffer(), + mDragging(false), + mLastPoint() { Create( pParent, @@ -209,6 +232,15 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +void JZKnob::GetCenter(int& x, int& y) const +{ + wxSize Size = GetSize(); + x = Size.x / 2; + y = Size.y / 2; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZKnob::OnSize(wxSizeEvent& Event) { int Width, Height; @@ -247,7 +279,8 @@ wxBufferedDC Dc(&PaintDc, mBuffer); - Dc.SetBackground(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))); + Dc.SetBackground( + wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE))); Dc.Clear(); @@ -284,87 +317,96 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZKnob::OnMouse(wxMouseEvent& Event) +void JZKnob::OnLeftButtonDown(wxMouseEvent& Event) { - wxEventType ScrollEvent = wxEVT_NULL; + SetFocus(); - if (Event.Moving()) - { - Event.Skip(); - return; - } + mLastPoint = Event.GetPosition(); - if (Event.GetWheelRotation() < 0) - { - SetValueWithEvent(GetValue() - 1); - Event.Skip(); - return; - } + SetCursor(wxCursor(wxCURSOR_SIZENS)); - if (Event.GetWheelRotation() > 0) - { - SetValueWithEvent(GetValue() + 1); - Event.Skip(); - return; - } + CaptureMouse(); - int XCenter, YCenter; - GetCenter(XCenter, YCenter); + mDragging = true; +} - double DeltaX = Event.m_x - XCenter; - double DeltaY = YCenter - Event.m_y; - if (DeltaX == 0.0 && DeltaY == 0.0) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZKnob::OnRightButtonDown(wxMouseEvent& Event) +{ + SetFocus(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZKnob::OnMouseMove(wxMouseEvent& Event) +{ + if (mDragging) { - return; - } + wxPoint Point = Event.GetPosition(); - double Theta = atan2(DeltaY, DeltaX) * gRadiansToDegrees; - if (Theta < 0.0) - { - Theta += 360.0; + int Delta = (mLastPoint.y - Point.y) / mSensitivity; + + if (Delta) + { + int PriorValue = GetValue(); + SetValueWithEvent(PriorValue + Delta); + if (PriorValue != GetValue()) + { + mLastPoint = Point; + } + } } +} - double DeltaTheta = Theta - mMaxAngle; - if (DeltaTheta < 0.0) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZKnob::OnLeftButtonUp(wxMouseEvent& Event) +{ + if (HasCapture()) { - DeltaTheta += 360; + ReleaseMouse(); } - if (DeltaTheta > mRange) - { - return; - } - int NewValue = int( - mMaxValue - (DeltaTheta / mRange) * (mMaxValue - mMinValue)); - SetValueWithEvent(NewValue); - if (Event.Dragging() || Event.ButtonUp()) - { - if (Event.ButtonUp()) - { - ScrollEvent = wxEVT_SCROLL_THUMBRELEASE; - } - else - { - ScrollEvent = wxEVT_SCROLL_THUMBTRACK; - } + SetCursor(wxCursor(wxCURSOR_ARROW)); - wxScrollEvent ScrollEvent(wxEVT_SCROLL_CHANGED, m_windowId); - ScrollEvent.SetPosition(NewValue); - ScrollEvent.SetEventObject(this); - GetEventHandler()->ProcessEvent(ScrollEvent); + mDragging = false; - wxCommandEvent CommandEvent(wxEVT_COMMAND_SLIDER_UPDATED, m_windowId); - CommandEvent.SetInt(NewValue); - CommandEvent.SetEventObject(this); - GetEventHandler()->ProcessEvent(CommandEvent); + wxPoint Point = Event.GetPosition(); + + int Delta = (mLastPoint.y - Point.y) / mSensitivity; + if (Delta) + { + SetValueWithEvent(GetValue() + Delta); } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void JZKnob::GetCenter(int& x, int& y) const +void JZKnob::OnLeftButtonDoubleClick(wxMouseEvent& Event) { - wxSize Size = GetSize(); - x = Size.x / 2; - y = Size.y / 2; + SetValueWithEvent(GetValue() + 1); } + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZKnob::OnRightButtonDoubleClick(wxMouseEvent& Event) +{ + SetValueWithEvent(GetValue() - 1); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZKnob::OnMouseWheel(wxMouseEvent& Event) +{ + int WheelRotation = Event.GetWheelRotation(); + + if (WheelRotation < 0) + { + SetValueWithEvent(GetValue() - 1); + } + else if (WheelRotation > 0) + { + SetValueWithEvent(GetValue() + 1); + } +} Modified: trunk/jazz/src/Knob.h =================================================================== --- trunk/jazz/src/Knob.h 2008-04-27 22:23:47 UTC (rev 476) +++ trunk/jazz/src/Knob.h 2008-04-28 01:27:11 UTC (rev 477) @@ -145,22 +145,40 @@ void OnPaint(wxPaintEvent& Event); - void OnMouse(wxMouseEvent& Event); + void OnLeftButtonDown(wxMouseEvent& Event); + void OnRightButtonDown(wxMouseEvent& Event); + + void OnMouseMove(wxMouseEvent& Event); + + void OnLeftButtonUp(wxMouseEvent& Event); + + void OnLeftButtonDoubleClick(wxMouseEvent& Event); + + void OnRightButtonDoubleClick(wxMouseEvent& Event); + + void OnMouseWheel(wxMouseEvent& Event); + private: + static int mSensitivity; + int mMinValue; int mMaxValue; int mSetting; + unsigned int mRange; + unsigned int mMaxAngle; - unsigned int mRange; - wxBitmap mBuffer; + bool mDragging; + + wxPoint mLastPoint; + DECLARE_EVENT_TABLE() }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-04-28 06:01:02
|
Revision: 479 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=479&view=rev Author: pstieber Date: 2008-04-27 23:00:52 -0700 (Sun, 27 Apr 2008) Log Message: ----------- 1. Prefixed some data members with m. 2. Made some of the JZTrack data members private and added IsEditing. 3. Made some cosmetic indentation changes. Modified Paths: -------------- trunk/jazz/src/Player.cpp trunk/jazz/src/Track.cpp trunk/jazz/src/Track.h trunk/jazz/src/TrackWindow.cpp trunk/jazz/src/mswin/WindowsPlayer.cpp Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-04-28 01:30:56 UTC (rev 478) +++ trunk/jazz/src/Player.cpp 2008-04-28 06:00:52 UTC (rev 479) @@ -648,11 +648,11 @@ void JZPlayer::OutNow(JZTrack *t, tParam *r) { - OutNow(t, &r->Msb); - OutNow(t, &r->Lsb); - OutNow(t, &r->DataMsb); - OutNow(t, &r->ResetMsb); - OutNow(t, &r->ResetLsb); + OutNow(t, &r->mMsb); + OutNow(t, &r->mLsb); + OutNow(t, &r->mDataMsb); + OutNow(t, &r->mResetMsb); + OutNow(t, &r->mResetLsb); } // ---------------------------------------------------------------------------------------------- Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2008-04-28 01:30:56 UTC (rev 478) +++ trunk/jazz/src/Track.cpp 2008-04-28 06:00:52 UTC (rev 479) @@ -37,20 +37,20 @@ int tParam::Write(JZWriteBase& Io) { - return Msb.Write(Io) + Lsb.Write(Io) + DataMsb.Write(Io); + return mMsb.Write(Io) + mLsb.Write(Io) + mDataMsb.Write(Io); } void tParam::SetCha(unsigned char cha) { - Msb.Channel = cha; - Lsb.Channel = cha; - DataMsb.Channel = cha; + mMsb.Channel = cha; + mLsb.Channel = cha; + mDataMsb.Channel = cha; #ifdef OBSOLETE - ResetMb.Channel = cha; //???? JAVE commented out this while porting + mResetMb.Channel = cha; //???? JAVE commented out this while porting #endif // OBSOLETE - ResetLsb.Channel = cha; + mResetLsb.Channel = cha; } /* @@ -246,14 +246,14 @@ } tDrumInstrumentParameter::tDrumInstrumentParameter(tNrpn *par) - : pitch(par->Lsb.mValue), - next(0) + : mPitch(par->mLsb.mValue), + mpNext(0) { for (int i = drumPitchIndex; i < numDrumParameters; i++) { param[i] = 0; } - param[drumParam2Index(par->Msb.mValue)] = par; + param[drumParam2Index(par->mMsb.mValue)] = par; } tNrpn *tDrumInstrumentParameter::Get(int index) @@ -264,17 +264,17 @@ void tDrumInstrumentParameter::Put(tNrpn *par) { - param[par->Lsb.mValue] = par; + param[par->mLsb.mValue] = par; } tDrumInstrumentParameter *tDrumInstrumentParameter::Next() { - return next; + return mpNext; } int tDrumInstrumentParameter::Pitch() { - return pitch; + return mPitch; } tDrumInstrumentParameter @@ -283,11 +283,11 @@ tDrumInstrumentParameter *ptr = list; while (ptr) { - if (ptr->pitch == pit) + if (ptr->mPitch == pit) { break; } - ptr = ptr->next; + ptr = ptr->mpNext; } return ptr; } @@ -304,16 +304,16 @@ void tDrumInstrumentParameterList::PutParam(tNrpn *par) { - tDrumInstrumentParameter* ptr = GetElem(par->Lsb.mValue); + tDrumInstrumentParameter* ptr = GetElem(par->mLsb.mValue); if (!ptr) { ptr = new tDrumInstrumentParameter(par); - ptr ->next = list; + ptr->mpNext = list; list = ptr; } else { - ptr->param[drumParam2Index(par->Msb.mValue)] = par; + ptr->param[drumParam2Index(par->mMsb.mValue)] = par; } } @@ -344,21 +344,21 @@ tDrumInstrumentParameter *prev = 0; while (ptr) { - if (ptr->pitch == pit) + if (ptr->mPitch == pit) { if (prev) { - prev->next = ptr->next; + prev->mpNext = ptr->mpNext; } else { - list = ptr->next; + list = ptr->mpNext; } delete ptr; break; } prev = ptr; - ptr = ptr->next; + ptr = ptr->mpNext; } } @@ -372,10 +372,10 @@ { if (cur) { - tDrumInstrumentParameter *ptr = GetElem(cur->pitch); + tDrumInstrumentParameter *ptr = GetElem(cur->mPitch); if (ptr) { - return ptr->next; + return ptr->mpNext; } else { @@ -393,7 +393,7 @@ tDrumInstrumentParameter *ptr = list; while (ptr) { - list = ptr->next; + list = ptr->mpNext; delete ptr; ptr = list; } @@ -1714,7 +1714,7 @@ void tTrackDlg::OnCancel() { - trk->DialogBox = 0; + trk->mpDialog = 0; TrackWin->Redraw(); wxForm::OnCancel(); } @@ -1726,8 +1726,8 @@ void tTrackDlg::OnOk() { - trk->DialogBox->GetPosition(&Config(C_TrackDlgXpos), &Config(C_TrackDlgYpos)); - trk->DialogBox = 0; + trk->mpDialog->GetPosition(&Config(C_TrackDlgXpos), &Config(C_TrackDlgYpos)); + trk->mpDialog = 0; trk->SetAudioMode(AudioMode); if (ClearTrack) @@ -1907,7 +1907,7 @@ JZTrackDialog TrackDialog(*this, pParent); TrackDialog.ShowModal(); #ifdef OBSOLETE - DialogBox = new wxDialogBox( + mpDialog = new wxDialogBox( pParent, "Track Settings", modal, @@ -1916,26 +1916,47 @@ #endif // OBSOLETE } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZTrack::IsEditing() const +{ + if (mpDialog) + { + return (mpDialog->GetHandle() != 0); + } + return false; +} -// *********************************************************************** -// JZTrack -// *********************************************************************** +//***************************************************************************** +// Description: +// This is the track class definition. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZTrack::mChanged = false; - -bool JZTrack::changed = false; - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- JZTrack::JZTrack() - : tEventArray() + : tEventArray(), + mUndoIndex(0), + mRedoCount(0), + mUndoCount(0), + mpDialog(0) { - iUndo = 0; - nRedo = 0; - nUndo = 0; - DialogBox = 0; ForceChannel = 1; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZTrack::~JZTrack() +{ + Clear(); +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- bool JZTrack::IsDrumTrack() { return Channel == gpConfig->GetValue(C_DrumChannel); @@ -1999,9 +2020,9 @@ void JZTrack::Undo() { - if (nUndo > 0) + if (mUndoCount > 0) { - tUndoBuffer *undo = &UndoBuffers[iUndo]; + tUndoBuffer *undo = &mUndoBuffers[mUndoIndex]; for (int i = undo->nEvents - 1; i >= 0; i--) { JZEvent *e = undo->Events[i]; @@ -2019,19 +2040,19 @@ } tEventArray::Cleanup(TRUE); - iUndo = (iUndo - 1 + MaxUndo) % MaxUndo; - nUndo--; - nRedo++; + mUndoIndex = (mUndoIndex - 1 + MaxUndo) % MaxUndo; + --mUndoCount; + ++mRedoCount; } } void JZTrack::Redo() { - if (nRedo > 0) + if (mRedoCount > 0) { - iUndo = (iUndo + 1) % MaxUndo; + mUndoIndex = (mUndoIndex + 1) % MaxUndo; - tUndoBuffer *undo = &UndoBuffers[iUndo]; + tUndoBuffer *undo = &mUndoBuffers[mUndoIndex]; for (int i = 0; i < undo->nEvents; i++) { JZEvent *e = undo->Events[i]; @@ -2049,23 +2070,23 @@ } tEventArray::Cleanup(TRUE); - nRedo--; - nUndo++; + --mRedoCount; + ++mUndoCount; } } void JZTrack::NewUndoBuffer() { - nRedo = 0; - nUndo++; - if (nUndo > MaxUndo) + mRedoCount = 0; + ++mUndoCount; + if (mUndoCount > MaxUndo) { - nUndo = MaxUndo; + mUndoCount = MaxUndo; } - iUndo = (iUndo + 1) % MaxUndo; - UndoBuffers[iUndo].Clear(); + mUndoIndex = (mUndoIndex + 1) % MaxUndo; + mUndoBuffers[mUndoIndex].Clear(); }; @@ -2073,7 +2094,7 @@ { for (int i = 0; i < MaxUndo; i++) { - UndoBuffers[i].Clear(); + mUndoBuffers[i].Clear(); } State = tsPlay; tEventArray::Clear(); @@ -2372,7 +2393,7 @@ mpBank2->Control, mpBank2->Value); ) - changed = true; + mChanged = true; } } @@ -2398,7 +2419,7 @@ { mPatch = new tProgram(0, Channel - 1, PatchNr - 1); gpMidiPlayer->OutNow(this, mPatch); - changed = true; + mChanged = true; } } @@ -2425,7 +2446,7 @@ { VibRate = new tNrpn(0, Channel - 1, 0x01, 0x08, Value - 1); gpMidiPlayer->OutNow(this, VibRate); - changed = true; + mChanged = true; } } @@ -2451,7 +2472,7 @@ { VibDepth = new tNrpn(0, Channel - 1, 0x01, 0x09, Value - 1); gpMidiPlayer->OutNow(this, VibDepth); - changed = true; + mChanged = true; } } @@ -2478,7 +2499,7 @@ { VibDelay = new tNrpn(0, Channel - 1, 0x01, 0x0a, Value - 1); gpMidiPlayer->OutNow(this, VibDelay); - changed = true; + mChanged = true; } } @@ -2505,7 +2526,7 @@ { Cutoff = new tNrpn(0, Channel - 1, 0x01, 0x20, Value - 1); gpMidiPlayer->OutNow(this, Cutoff); - changed = true; + mChanged = true; } } @@ -2532,7 +2553,7 @@ { Resonance = new tNrpn(0, Channel - 1, 0x01, 0x21, Value - 1); gpMidiPlayer->OutNow(this, Resonance); - changed = true; + mChanged = true; } } @@ -2559,7 +2580,7 @@ { EnvAttack = new tNrpn(0, Channel - 1, 0x01, 0x63, Value - 1); gpMidiPlayer->OutNow(this, EnvAttack); - changed = true; + mChanged = true; } } @@ -2586,7 +2607,7 @@ { EnvDecay = new tNrpn(0, Channel - 1, 0x01, 0x64, Value - 1); gpMidiPlayer->OutNow(this, EnvDecay); - changed = true; + mChanged = true; } } @@ -2613,7 +2634,7 @@ { EnvRelease = new tNrpn(0, Channel - 1, 0x01, 0x66, Value - 1); gpMidiPlayer->OutNow(this, EnvRelease); - changed = true; + mChanged = true; } } @@ -2640,7 +2661,7 @@ DrumParams.PutParam( new tNrpn(0, Channel - 1, drumIndex2Param(index), pitch, Value - 1)); gpMidiPlayer->OutNow(this, DrumParams.GetParam(pitch, index)); - changed = true; + mChanged = true; } } @@ -2666,8 +2687,8 @@ if (Value > 0) { BendPitchSens = new tRpn(0, Channel - 1, 0x00, 0x00, Value - 1); - gpMidiPlayer->OutNow(this, BendPitchSens); - changed = true; + gpMidiPlayer->OutNow(this, BendPitchSens); + mChanged = true; } } Modified: trunk/jazz/src/Track.h =================================================================== --- trunk/jazz/src/Track.h 2008-04-28 01:30:56 UTC (rev 478) +++ trunk/jazz/src/Track.h 2008-04-28 06:00:52 UTC (rev 479) @@ -36,14 +36,41 @@ #define tsSolo 2 // Mixer-defs -enum { MxVol = 0, MxPan, MxRev, MxCho, MxParams }; +enum +{ + MxVol = 0, + MxPan, + MxRev, + MxCho, + MxParams +}; - // Param (Nrpn / Rpn) things -enum { NrpnVibRate = 0, NrpnVibDepth, NrpnVibDelay, NrpnVibParams }; -enum { NrpnCutoff = 0, NrpnResonance, NrpnSoundParams }; -enum { NrpnEnvAttack = 0, NrpnEnvDecay, NrpnEnvRelease, NrpnEnvParams }; +enum +{ + NrpnVibRate = 0, + NrpnVibDepth, + NrpnVibDelay, + NrpnVibParams +}; +enum +{ + NrpnCutoff = 0, + NrpnResonance, + NrpnSoundParams +}; + +enum +{ + NrpnEnvAttack = 0, + NrpnEnvDecay, + NrpnEnvRelease, + NrpnEnvParams +}; + +//***************************************************************************** +//***************************************************************************** class tParam { public: @@ -56,11 +83,11 @@ unsigned char id2, unsigned char lsb, unsigned char msbval) - : Msb( clk, cha, id1, msb ), - Lsb( clk, cha, id2, lsb ), - DataMsb( clk, cha, 0x06, msbval ), - ResetMsb( clk, cha, id1, 0x7f ), - ResetLsb( clk, cha, id2, 0x7f ) + : mMsb(clk, cha, id1, msb), + mLsb(clk, cha, id2, lsb), + mDataMsb(clk, cha, 0x06, msbval), + mResetMsb(clk, cha, id1, 0x7f), + mResetLsb(clk, cha, id2, 0x7f) { } @@ -69,19 +96,23 @@ } virtual int Write(JZWriteBase& Io); - virtual void SetCha( unsigned char cha ); + + virtual void SetCha(unsigned char cha); + virtual int GetVal() { - return DataMsb.mValue; + return mDataMsb.mValue; } - tControl Msb; - tControl Lsb; - tControl DataMsb; - tControl ResetMsb; - tControl ResetLsb; + tControl mMsb; + tControl mLsb; + tControl mDataMsb; + tControl mResetMsb; + tControl mResetLsb; }; +//***************************************************************************** +//***************************************************************************** class tNrpn : public tParam { public: @@ -97,6 +128,8 @@ } }; +//***************************************************************************** +//***************************************************************************** class tRpn : public tParam { public: @@ -123,56 +156,133 @@ enum ModulationSysexParameter { - mspModPitchControl = 0, mspModTvfCut, mspModAmpl, mspModLfo1Rate, - mspModLfo1Pitch, mspModLfo1Tvf, mspModLfo1Tva, mspModLfo2Rate, - mspModLfo2Pitch, mspModLfo2Tvf, mspModLfo2Tva, mspModulationSysexParameters + mspModPitchControl = 0, + mspModTvfCut, + mspModAmpl, + mspModLfo1Rate, + mspModLfo1Pitch, + mspModLfo1Tvf, + mspModLfo1Tva, + mspModLfo2Rate, + mspModLfo2Pitch, + mspModLfo2Tvf, + mspModLfo2Tva, + mspModulationSysexParameters }; -enum BenderSysexParameter { - bspBendPitchControl = 0, bspBendTvfCut, bspBendAmpl, bspBendLfo1Rate, - bspBendLfo1Pitch, bspBendLfo1Tvf, bspBendLfo1Tva, bspBendLfo2Rate, - bspBendLfo2Pitch, bspBendLfo2Tvf, bspBendLfo2Tva, bspBenderSysexParameters +enum BenderSysexParameter +{ + bspBendPitchControl = 0, + bspBendTvfCut, + bspBendAmpl, + bspBendLfo1Rate, + bspBendLfo1Pitch, + bspBendLfo1Tvf, + bspBendLfo1Tva, + bspBendLfo2Rate, + bspBendLfo2Pitch, + bspBendLfo2Tvf, + bspBendLfo2Tva, + bspBenderSysexParameters }; -enum CAfSysexParameter { - cspCAfPitchControl = 0, cspCAfTvfCut, cspCAfAmpl, cspCAfLfo1Rate, - cspCAfLfo1Pitch, cspCAfLfo1Tvf, cspCAfLfo1Tva, cspCAfLfo2Rate, - cspCAfLfo2Pitch, cspCAfLfo2Tvf, cspCAfLfo2Tva, cspCAfSysexParameters +enum CAfSysexParameter +{ + cspCAfPitchControl = 0, + cspCAfTvfCut, + cspCAfAmpl, + cspCAfLfo1Rate, + cspCAfLfo1Pitch, + cspCAfLfo1Tvf, + cspCAfLfo1Tva, + cspCAfLfo2Rate, + cspCAfLfo2Pitch, + cspCAfLfo2Tvf, + cspCAfLfo2Tva, + cspCAfSysexParameters }; -enum PAfSysexParameter { - pspPAfPitchControl = 0, pspPAfTvfCut, pspPAfAmpl, pspPAfLfo1Rate, - pspPAfLfo1Pitch, pspPAfLfo1Tvf, pspPAfLfo1Tva, pspPAfLfo2Rate, - pspPAfLfo2Pitch, pspPAfLfo2Tvf, pspPAfLfo2Tva, pspPAfSysexParameters +enum PAfSysexParameter +{ + pspPAfPitchControl = 0, + pspPAfTvfCut, + pspPAfAmpl, + pspPAfLfo1Rate, + pspPAfLfo1Pitch, + pspPAfLfo1Tvf, + pspPAfLfo1Tva, + pspPAfLfo2Rate, + pspPAfLfo2Pitch, + pspPAfLfo2Tvf, + pspPAfLfo2Tva, + pspPAfSysexParameters }; -enum CC1SysexParameter { - cspCC1PitchControl = 0, cspCC1TvfCut, cspCC1Ampl, cspCC1Lfo1Rate, - cspCC1Lfo1Pitch, cspCC1Lfo1Tvf, cspCC1Lfo1Tva, cspCC1Lfo2Rate, - cspCC1Lfo2Pitch, cspCC1Lfo2Tvf, cspCC1Lfo2Tva, cspCC1SysexParameters +enum CC1SysexParameter +{ + cspCC1PitchControl = 0, + cspCC1TvfCut, + cspCC1Ampl, + cspCC1Lfo1Rate, + cspCC1Lfo1Pitch, + cspCC1Lfo1Tvf, + cspCC1Lfo1Tva, + cspCC1Lfo2Rate, + cspCC1Lfo2Pitch, + cspCC1Lfo2Tvf, + cspCC1Lfo2Tva, + cspCC1SysexParameters }; -enum CC2SysexParameter { - cspCC2PitchControl = 0, cspCC2TvfCut, cspCC2Ampl, cspCC2Lfo1Rate, - cspCC2Lfo1Pitch, cspCC2Lfo1Tvf, cspCC2Lfo1Tva, cspCC2Lfo2Rate, - cspCC2Lfo2Pitch, cspCC2Lfo2Tvf, cspCC2Lfo2Tva, cspCC2SysexParameters +enum CC2SysexParameter +{ + cspCC2PitchControl = 0, + cspCC2TvfCut, + cspCC2Ampl, + cspCC2Lfo1Rate, + cspCC2Lfo1Pitch, + cspCC2Lfo1Tvf, + cspCC2Lfo1Tva, + cspCC2Lfo2Rate, + cspCC2Lfo2Pitch, + cspCC2Lfo2Tvf, + cspCC2Lfo2Tva, + cspCC2SysexParameters }; -enum ReverbSysexParameter { - rspRevCharacter = 0, rspRevPreLpf, rspRevLevel, rspRevTime, - rspRevDelayFeedback, rspRevSendChorus, rspReverbSysexParameters +enum ReverbSysexParameter +{ + rspRevCharacter = 0, + rspRevPreLpf, + rspRevLevel, + rspRevTime, + rspRevDelayFeedback, + rspRevSendChorus, + rspReverbSysexParameters }; -enum ChorusSysexParameter { - cspChoPreLpf = 0, cspChoLevel, cspChoFeedback, cspChoDelay, - cspChoRate, cspChoDepth, cspChoSendReverb, cspChorusSysexParameters +enum ChorusSysexParameter +{ + cspChoPreLpf = 0, + cspChoLevel, + cspChoFeedback, + cspChoDelay, + cspChoRate, + cspChoDepth, + cspChoSendReverb, + cspChorusSysexParameters }; -enum ModeSysexParameter { - mspRxChannel = 0x02, mspRxCAf = 0x04, mspRxPAf = 0x07, mspUseForRhythm = 0x15 +enum ModeSysexParameter +{ + mspRxChannel = 0x02, + mspRxCAf = 0x04, + mspRxPAf = 0x07, + mspUseForRhythm = 0x15 }; -enum DrumInstrumentParameter { +enum DrumInstrumentParameter +{ drumPitch = 0x18, drumTva = 0x1a, drumPan = 0x1c, @@ -180,7 +290,8 @@ drumChorus = 0x1e }; -enum DrumInstrumentParameterIndex { +enum DrumInstrumentParameterIndex +{ drumPitchIndex = 0, drumTvaIndex, drumPanIndex, @@ -189,34 +300,42 @@ numDrumParameters }; -int drumParam2Index( int par ); -int drumIndex2Param( int index ); +int drumParam2Index(int par); +int drumIndex2Param(int index); class tDrumInstrumentParameterList; +//***************************************************************************** +//***************************************************************************** class tDrumInstrumentParameter { - friend class tDrumInstrumentParameterList; - private: - int pitch; - tNrpn *param[numDrumParameters]; - tDrumInstrumentParameter *next; public: + tDrumInstrumentParameter( tNrpn *par ); tNrpn *Get( int index ); void Put( tNrpn *par ); tDrumInstrumentParameter *Next(); int Pitch(); + + private: + + int mPitch; + tNrpn* param[numDrumParameters]; + tDrumInstrumentParameter* mpNext; }; +//***************************************************************************** +//***************************************************************************** class tDrumInstrumentParameterList { - private: - tDrumInstrumentParameter *list; public: - tDrumInstrumentParameterList() : list(0) {} + + tDrumInstrumentParameterList() + : list(0) + { + } tDrumInstrumentParameter *GetElem( int pit ); tNrpn *GetParam( int pit, int index ); void PutParam( tNrpn *par ); @@ -225,14 +344,30 @@ tDrumInstrumentParameter *NextElem( tDrumInstrumentParameter *cur ); void DelElem( int pit ); void Clear(); - int IsEmpty() { return( list == 0 ); } + int IsEmpty() + { + return( list == 0 ); + } + + private: + + tDrumInstrumentParameter* list; }; -enum tMtcType { Mtc24 = 0, Mtc25, Mtc30Df, Mtc30Ndf }; +enum tMtcType +{ + Mtc24 = 0, + Mtc25, + Mtc30Df, + Mtc30Ndf +}; +//***************************************************************************** +//***************************************************************************** class tMtcTime { public: + tMtcType type; int hour; int min; @@ -249,6 +384,8 @@ }; +//***************************************************************************** +//***************************************************************************** class tSimpleEventArray : public wxObject { public: @@ -282,6 +419,8 @@ }; +//***************************************************************************** +//***************************************************************************** class tUndoBuffer : public tSimpleEventArray { friend class JZTrack; @@ -289,10 +428,11 @@ public: virtual void Clear(); - void Put(JZEvent *e, int killed) + + void Put(JZEvent* pEvent, int killed) { bits.set(nEvents, killed); - tSimpleEventArray::Put(e); + tSimpleEventArray::Put(pEvent); } private: @@ -301,6 +441,8 @@ }; +//***************************************************************************** +//***************************************************************************** class tEventArray : public tSimpleEventArray { friend class tEventIterator; @@ -402,41 +544,42 @@ }; - #define MaxUndo 20 +//***************************************************************************** +// Description: +// This is the track class declaration. +//***************************************************************************** class JZTrack : public tEventArray { public: - static bool changed; + static bool mChanged; JZTrack(); - ~JZTrack() { Clear(); } + virtual ~JZTrack(); + bool IsDrumTrack(); - int iUndo; // index to actual undo buffer - int nRedo; // current number of possible redo's - int nUndo; // current number of possible undo's - tUndoBuffer UndoBuffers[MaxUndo]; + public: - wxDialog *DialogBox; + void Dialog(JZTrackWindow* pParent); - void Dialog(JZTrackWindow *parent); + bool IsEditing() const; - void Put(JZEvent *e) + void Put(JZEvent* pEvent) { - changed = true; - tEventArray::Put(e); - UndoBuffers[iUndo].Put(e, 0); + mChanged = true; + tEventArray::Put(pEvent); + mUndoBuffers[mUndoIndex].Put(pEvent, 0); } - void Kill(JZEvent *e) + void Kill(JZEvent* pEvent) { - changed = true; - e->Kill(); - UndoBuffers[iUndo].Put(e, 1); + mChanged = true; + pEvent->Kill(); + mUndoBuffers[mUndoIndex].Put(pEvent, 1); } void Merge(tEventArray *other); @@ -508,7 +651,7 @@ int GetEnvRelease(); void SetEnvRelease(int EnvRelease); - int GetDrumParam( int pitch, int index ); + int GetDrumParam(int pitch, int index); void SetDrumParam(int pitch, int index, int Value); int GetBendPitchSens(); @@ -577,95 +720,111 @@ tMtcTime* GetMtcOffset(); void SetMtcOffset( tMtcTime* mtc ); + + private: + + // Index in the actual undo buffer. + int mUndoIndex; + + // Current number of possible redo's. + int mRedoCount; + + // Current number of possible undo's. + int mUndoCount; + + tUndoBuffer mUndoBuffers[MaxUndo]; + + wxDialog* mpDialog; }; -// *********************************************************************** -// tEventIterator -// ********************************************************************* - +//***************************************************************************** +// Description: +// This is the event iterator class declaration. +//***************************************************************************** class tEventIterator { - const tSimpleEventArray* Track; - int Start, Stop, Actual; - public: - tEventIterator(const tSimpleEventArray* t) + tEventIterator(const tSimpleEventArray* pTrack) { - Track = t; - Start = 0; - Stop = Track->nEvents; - Actual = Start; + mpTrack = pTrack; + mStart = 0; + mStop = mpTrack->nEvents; + mActual = mStart; } - - JZEvent *GreaterEqual(int Clock) + JZEvent* GreaterEqual(int Clock) { - int lo = Start; - int hi = Stop; - int clk = 0; - while (lo < hi) + int Lo = mStart; + int Hi = mStop; + int TestClock = 0; + while (Lo < Hi) { - Actual = (hi + lo) / 2; - clk = Track->Events[Actual]->GetClock(); - if (clk < Clock) + mActual = (Hi + Lo) / 2; + TestClock = mpTrack->Events[mActual]->GetClock(); + if (TestClock < Clock) { - lo = Actual + 1; + Lo = mActual + 1; } else { - hi = Actual; + Hi = mActual; } } - if (Actual < Stop-1 && clk < Clock) + if (mActual < mStop - 1 && TestClock < Clock) { - clk = Track->Events[++Actual]->GetClock(); + TestClock = mpTrack->Events[++mActual]->GetClock(); } - if (Actual < Stop && clk >= Clock) + if (mActual < mStop && TestClock >= Clock) { - return Track->Events[Actual]; + return mpTrack->Events[mActual]; } return 0; } - - JZEvent *First(int Clock = 0) + JZEvent* First(int Clock = 0) { - Actual = Start; + mActual = mStart; return GreaterEqual(Clock); } - - JZEvent *Range(int frClock, unsigned toClock) + JZEvent* Range(int FromClock, unsigned ToClock) { - Start = Actual = 0; - Stop = Track->nEvents; + mStart = mActual = 0; + mStop = mpTrack->nEvents; - if (!GreaterEqual(frClock)) + if (!GreaterEqual(FromClock)) + { return 0; - Start = Actual; - if (GreaterEqual(toClock)) - Stop = Actual; - Actual = Start; - return (Actual < Stop ? Track->Events[Actual] : 0); + } + mStart = mActual; + if (GreaterEqual(ToClock)) + { + mStop = mActual; + } + mActual = mStart; + return (mActual < mStop ? mpTrack->Events[mActual] : 0); } - - JZEvent *Next() + JZEvent* Next() { - if (Actual < Stop) + if (mActual < mStop) { - ++Actual; + ++mActual; } - return (Actual < Stop ? Track->Events[Actual] : 0); + return (mActual < mStop ? mpTrack->Events[mActual] : 0); } int EventsLeft() { - return Stop - Actual; + return mStop - mActual; } + private: + + const tSimpleEventArray* mpTrack; + int mStart, mStop, mActual; }; #endif // !defined(JZ_TRACK_H) Modified: trunk/jazz/src/TrackWindow.cpp =================================================================== --- trunk/jazz/src/TrackWindow.cpp 2008-04-28 01:30:56 UTC (rev 478) +++ trunk/jazz/src/TrackWindow.cpp 2008-04-28 06:00:52 UTC (rev 479) @@ -685,14 +685,28 @@ mEventsHeight); // Draw the track name. - if (pTrack->DialogBox) + if (pTrack->IsEditing()) { // Show the button pressed when the dialog box is open. - LineText(LocalDc, mTrackNameX, y, mTrackNameWidth, pTrack->GetName(), -1, true); + LineText( + LocalDc, + mTrackNameX, + y, + mTrackNameWidth, + pTrack->GetName(), + -1, + true); } else { - LineText(LocalDc, mTrackNameX, y, mTrackNameWidth, pTrack->GetName(), -1, false); + LineText( + LocalDc, + mTrackNameX, + y, + mTrackNameWidth, + pTrack->GetName(), + -1, + false); } // Draw the track status. Modified: trunk/jazz/src/mswin/WindowsPlayer.cpp =================================================================== --- trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-04-28 01:30:56 UTC (rev 478) +++ trunk/jazz/src/mswin/WindowsPlayer.cpp 2008-04-28 06:00:52 UTC (rev 479) @@ -506,11 +506,11 @@ //----------------------------------------------------------------------------- void JZWindowsPlayer::OutNow(tParam *r) { - OutNow(&r->Msb); - OutNow(&r->Lsb); - OutNow(&r->DataMsb); - OutNow(&r->ResetMsb); - OutNow(&r->ResetLsb); + OutNow(&r->mMsb); + OutNow(&r->mLsb); + OutNow(&r->mDataMsb); + OutNow(&r->mResetMsb); + OutNow(&r->mResetLsb); } //----------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-04 04:43:52
|
Revision: 483 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=483&view=rev Author: pstieber Date: 2008-05-03 21:43:51 -0700 (Sat, 03 May 2008) Log Message: ----------- Updated to get selection working in the track window in a very basic way. This is a WIP and hasn't benn fully integrated with the new scrolling code. Modified Paths: -------------- trunk/jazz/src/EventWindow.cpp trunk/jazz/src/EventWindow.h trunk/jazz/src/MouseAction.cpp trunk/jazz/src/MouseAction.h trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/PianoWindow.h trunk/jazz/src/SampleWindow.cpp trunk/jazz/src/TrackWindow.cpp trunk/jazz/src/TrackWindow.h Modified: trunk/jazz/src/EventWindow.cpp =================================================================== --- trunk/jazz/src/EventWindow.cpp 2008-05-04 04:35:13 UTC (rev 482) +++ trunk/jazz/src/EventWindow.cpp 2008-05-04 04:43:51 UTC (rev 483) @@ -33,7 +33,6 @@ using namespace std; - //***************************************************************************** // Description: // This is the event window class definition. @@ -79,7 +78,7 @@ mScrolledX(0), mScrolledY(0) { - mpSnapSel = new tSnapSelection(this); + mpSnapSel = new JZSnapSelection(this); mpFilter = new JZFilter(mpSong); @@ -106,7 +105,7 @@ //----------------------------------------------------------------------------- int JZEventWindow::EventsSelected(const wxString& Message) const { - if (!mpSnapSel->Selected) + if (!mpSnapSel->IsSelected()) { wxMessageBox(Message, "Error", wxOK); return 0; @@ -401,7 +400,6 @@ mpFilter = new JZFilter(Song); } - JZEventFrame::~JZEventFrame() { delete SnapSel; @@ -421,18 +419,17 @@ } } - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::CreateMenu() { } -/** - -create the canvas component(used for differently dependingon the subclass) -size it to the client area of the frame(frame size minus toolbar and menus ) -*/ +//----------------------------------------------------------------------------- +// create the canvas component(used for differently dependingon the subclass) +// size it to the client area of the frame(frame size minus toolbar and menus ) +//----------------------------------------------------------------------------- //void JZEventFrame::CreateCanvas() //{ // cout << "CreateCanvas" << endl; @@ -451,8 +448,9 @@ Setup(); } - +//----------------------------------------------------------------------------- // Initialize the constants used in drawing. +//----------------------------------------------------------------------------- void JZEventFrame::Setup() { /* @@ -478,11 +476,10 @@ */ } - -/** -this onsize handler is supposed to take care of handling of the resizing the two subwindows sizes to -they dont overlap -*/ +//----------------------------------------------------------------------------- +// this onsize handler is supposed to take care of handling of the resizing +// the two subwindows sizes to they dont overlap +//----------------------------------------------------------------------------- void JZEventFrame::OnSize(wxSizeEvent& Event) { // wxFrame::OnSize(Event); @@ -535,11 +532,8 @@ return OnKeyEvent(e); } -// ******************************************************************* -// Coord-Functions -// ******************************************************************* - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int JZEventFrame::y2yLine(int y, int up) { if (up) @@ -552,6 +546,8 @@ return y; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int JZEventFrame::y2Line(int y, int up) { if (up) @@ -562,13 +558,16 @@ return y / mTrackHeight; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int JZEventFrame::Line2y(int Line) { return Line * mTrackHeight + mTopInfoHeight; } /* +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::LineText(wxDC *dc, int x, int y, int w, const char *str, int h, bool down) { if (h <= 0) @@ -618,10 +617,8 @@ } */ -// ******************************************************************* -// Painting behavior -// ******************************************************************* - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::Redraw() { // wxDC* dc=new wxClientDC(this); @@ -631,29 +628,26 @@ // //the problem is that onpaint no longer tkes no argument, and is supposed to be called from the framework only, so it should be split // delete dc; - - // mpEventWindow->Refresh(); - } -// ****************************************************************** -// Mouse -// ****************************************************************** - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- bool JZEventFrame::OnKeyEvent(wxKeyEvent &e) { return false; } -/** seems to handle the "selection" rectangle. normally called from the base class onmouseevent handler */ +//----------------------------------------------------------------------------- +// seems to handle the "selection" rectangle. normally called from the base +// class onmouseevent handler +//----------------------------------------------------------------------------- int JZEventFrame::OnMouseEvent(wxMouseEvent &e) { // cout <<"JZEventFrame::OnMouseEvent"<<endl; if (!MouseAction) { // create SnapSel? - int x; int y; e.GetPosition(&x, &y); @@ -664,7 +658,8 @@ { SnapSelStart(e); - if (SnapSel->Selected){ + if (SnapSel->IsSelected()) + { Refresh(); //redraw the whole window instead(inefficient, we should rather invalidate a rect) } SnapSel->Event(e); @@ -673,7 +668,6 @@ } } } - else { // MouseAction active @@ -696,38 +690,36 @@ return 0; } -// ****************************************************************** -// dummies -// ****************************************************************** - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- bool JZEventFrame::OnClose() { return FALSE; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::OnMenuCommand(int) { } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::SnapSelStart(wxMouseEvent& MouseEvent) { } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::SnapSelStop(wxMouseEvent& MouseEvent) { } //----------------------------------------------------------------------------- -// PlayPosition //----------------------------------------------------------------------------- - -// ************************************************************************** -// EventsSelected -// ************************************************************************** - -int JZEventFrame::EventsSelected(const char *msg) +int JZEventFrame::EventsSelected(const char* msg) { - if (!SnapSel->Selected) + if (!SnapSel->IsSelected()) { if (msg == 0) { @@ -739,158 +731,104 @@ return 1; } -// ************************************************************************** -// Quantize -// ************************************************************************** - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::MenQuantize() { - - if (!EventsSelected()) return; // wxDialogBox *panel = new wxDialogBox(this, "Quantize", FALSE ); tQuantizeDlg * dlg = new tQuantizeDlg(this, mpFilter); dlg->Create(); - - } -// ************************************************************************** -// Cleanup -// ************************************************************************** - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::MenCleanup() { - - if (!EventsSelected()) return; tCleanupDlg * dlg = new tCleanupDlg(this, mpFilter); dlg->Create(); - } - -// ************************************************************************** -// SearchReplace -// ************************************************************************** - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::MenSearchReplace() { - - if (!EventsSelected()) return; tSearchReplaceDlg * dlg = new tSearchReplaceDlg(this, mpFilter); dlg->Create(); - - } - -// ************************************************************************** -// SetChannel -// ************************************************************************** - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::MenSetChannel() { - - if (!EventsSelected()) return; tSetChannelDlg * dlg = new tSetChannelDlg(mpFilter); dlg->Create(); - } - -// ************************************************************************** -// Transpose -// ************************************************************************** - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::MenTranspose() { - - if (!EventsSelected()) return; tTransposeDlg * dlg = new tTransposeDlg(this, mpFilter); dlg->Create(); - - } -/**show the "shift events" dialog */ - +//----------------------------------------------------------------------------- +// show the "shift events" dialog +//----------------------------------------------------------------------------- void JZEventFrame::MenShift(int Unit) { if (EventsSelected()) { - tShiftDlg * dlg = new tShiftDlg(this, mpFilter, Unit); dlg->Create(); } - - } - -// ******************************************************************************** -// Delete -// ******************************************************************************** - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::MenDelete() { - - if (!EventsSelected()) return; tDeleteDlg * dlg = new tDeleteDlg(this, mpFilter); dlg->Create(); } -// ******************************************************************************** -// Velocity -// ******************************************************************************** - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::MenVelocity() { - if (!EventsSelected()) return; tVelocityDlg * dlg = new tVelocityDlg(mpFilter); dlg->Create(); } -// ******************************************************************************** -// Length -// ******************************************************************************** - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZEventFrame::MenLength() { - - if (!EventsSelected()) return; tLengthDlg * dlg = new tLengthDlg(this, mpFilter); dlg->Create(); - } - -// ******************************************************************************** +//----------------------------------------------------------------------------- // convert to modulation -// ******************************************************************************** - - +//----------------------------------------------------------------------------- void JZEventFrame::MenConvertToModulation() { - - if (!EventsSelected()) return; tCmdConvertToModulation cmd(mpFilter); @@ -898,30 +836,23 @@ Redraw(); } - - - - -// ****************************************************************** +//***************************************************************************** // MeterChange Dialog -// ****************************************************************** - - +//***************************************************************************** class tMeterChangeDlg : public tPropertyListDlg { -public: - JZEventFrame *EventWin; - static int Numerator; - static int Denomiator; - static int BarNr; - tMeterChangeDlg(JZEventFrame *w); - void AddProperties(); - virtual bool OnClose(); - virtual void OnCancel(); - virtual void OnHelp(); + public: + JZEventFrame *EventWin; + static int Numerator; + static int Denomiator; + static int BarNr; + tMeterChangeDlg(JZEventFrame *w); + void AddProperties(); + virtual bool OnClose(); + virtual void OnCancel(); + virtual void OnHelp(); }; - int tMeterChangeDlg::Numerator = 4; int tMeterChangeDlg::Denomiator = 4; int tMeterChangeDlg::BarNr = 1; @@ -932,14 +863,12 @@ EventWin = w; } - void tMeterChangeDlg::OnCancel() { EventWin->mpSettingsDialog = 0; //wxForm::OnCancel(); } - bool tMeterChangeDlg::OnClose() { BarNr += EventWin->Song->GetIntroLength(); @@ -955,7 +884,6 @@ gpHelpInstance->ShowTopic("Meterchange"); } - void tMeterChangeDlg::AddProperties() { // Add(wxMakeFormShort("BarNr:", &BarNr, wxFORM_DEFAULT, 0,0,0,100)); @@ -980,8 +908,6 @@ "integer"));//JAVE should be a integer list instead FIXME } - - void JZEventFrame::MenMeterChange() { tMeterChangeDlg *dlg; Modified: trunk/jazz/src/EventWindow.h =================================================================== --- trunk/jazz/src/EventWindow.h 2008-05-04 04:35:13 UTC (rev 482) +++ trunk/jazz/src/EventWindow.h 2008-05-04 04:43:51 UTC (rev 483) @@ -40,7 +40,7 @@ { public: - tSnapSelection* mpSnapSel; + JZSnapSelection* mpSnapSel; JZFilter* mpFilter; @@ -182,7 +182,7 @@ int FromLine, ToLine; // Mousehandling - tSnapSelection *SnapSel; + JZSnapSelection *SnapSel; tMouseAction *MouseAction; virtual void SnapSelStart(wxMouseEvent &e); virtual void SnapSelStop(wxMouseEvent &e); Modified: trunk/jazz/src/MouseAction.cpp =================================================================== --- trunk/jazz/src/MouseAction.cpp 2008-05-04 04:35:13 UTC (rev 482) +++ trunk/jazz/src/MouseAction.cpp 2008-05-04 04:43:51 UTC (rev 483) @@ -67,335 +67,389 @@ actions[i] = code; } -int tMouseMapper::Action(wxMouseEvent &e) +int tMouseMapper::Action(wxMouseEvent& Event) { - if (!e.ButtonDown()) + if (!Event.ButtonDown()) + { return 0; + } - if (left_action > 0 && e.LeftDown() &&!e.ShiftDown() && !e.ControlDown()) + if ( + left_action > 0 && + Event.LeftDown() && + !Event.ShiftDown() && + !Event.ControlDown()) + { return left_action; + } int i = 0; // left down - if (e.MiddleDown()) + if (Event.MiddleDown()) + { i = 1; - else - if (e.RightDown()) + } + else if (Event.RightDown()) + { i = 2; + } - if (e.ShiftDown()) + if (Event.ShiftDown()) + { i += 3; - if (e.ControlDown()) + } + if (Event.ControlDown()) + { i += 6; + } return actions[i]; } -////////////////////////////////////////////////////////// -//tSelection implementation - -tSelection::tSelection(wxWindow* pWindow) - : win(pWindow), +//***************************************************************************** +// Description: +// This is the selection class definition. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZSelection::JZSelection(wxWindow* pWindow) + : mActive(false), + mSelected(false), + mRectangle(), + mpWindow(pWindow), mpBackgroundBrush(0) { - Active = 0; - Selected = false; - mpBackgroundBrush = new wxBrush(wxColor(192, 192, 192), wxSOLID); +// mpBackgroundBrush = new wxBrush(wxColor(192, 192, 192), wxSOLID); + mpBackgroundBrush = new wxBrush(wxColor(100, 100, 100), wxSOLID); } -tSelection::~tSelection() +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZSelection::~JZSelection() { delete mpBackgroundBrush; } -int tSelection::Event(wxMouseEvent &e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZSelection::Event(wxMouseEvent& Event) { - if (e.ButtonDown()) - return ButtonDown(e); - else if (e.ButtonUp()) - return ButtonUp(e); - else if (e.Dragging()) - return Dragging(e); + if (Event.ButtonDown()) + { + return ButtonDown(Event); + } + else if (Event.ButtonUp()) + { + return ButtonUp(Event); + } + else if (Event.Dragging()) + { + return Dragging(Event); + } return 0; } -int tSelection::ButtonDown(wxMouseEvent &e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZSelection::ButtonDown(wxMouseEvent& Event) { - if (!Active) + if (!mActive) { -#ifdef __WXMSW__ -//OBSOLETE Canvas->CaptureMouse(); -#endif - Active = 1; -// wxDC *dc = new wxPaintDC(win);//Canvas->GetDC(); -// Dc.SetBrush(*mpBackgroundBrush); -// Dc.SetLogicalFunction(wxXOR); - if (Selected && e.ShiftDown()) + mActive = true; + if (mSelected && Event.ShiftDown()) { // Continue selection - JZRectangle rr = r; - rr.SetNormal(); -// if (rr.width && rr.height) -// Dc.DrawRectangle(rr.x, rr.y, rr.width, rr.height); - Dragging(e); + JZRectangle Rectangle = mRectangle; + Rectangle.SetNormal(); + Dragging(Event); } else { - Selected = false; - int x, y; - //e.Position(&x, &y); - wxDC *dc = new wxClientDC(win);//Canvas->GetDC(); - wxPoint point=e.GetLogicalPosition(*dc); - delete dc; - x=point.x;y=point.y; + mSelected = false; + int x = Event.GetX(); + int y = Event.GetY(); Snap(x, y, 0); - r.x = x; - r.y = y; - r.width = 1; - r.height = 1; -// Dc.DrawRectangle(r.x, r.y, r.width, r.height); - //Dragging(e); + mRectangle.x = x; + mRectangle.y = y; + mRectangle.width = 1; + mRectangle.height = 1; } -// Dc.SetLogicalFunction(wxCOPY); } - win->Refresh(); //invalidate return 0; } - -int tSelection::Dragging(wxMouseEvent &e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZSelection::Dragging(wxMouseEvent& Event) { - if (!Active) - ButtonDown(e); + if (!mActive) + { + ButtonDown(Event); + } - if (Active) + if (mActive) { - int x, y; - JZRectangle r1, r2; //r1=previous rect, r2=new rect - - wxDC *dc = new wxClientDC(win); - wxPoint point=e.GetLogicalPosition(*dc); - delete dc; - - x=point.x; - y=point.y; - if ((short)x < 0) + int x = Event.GetX(); + int y = Event.GetY(); + if (x < 0) + { x = 0; - if ((short)y < 0) + } + if (y < 0) + { y = 0; + } Snap(x, y, 1); - r1 = r; - r1.SetNormal(); - - r.width = x - r.x; - r.height = y - r.y; - - r2 = r; - r2.SetNormal(); - - win->Refresh(TRUE, &r1); - win->Refresh(TRUE, &r2); + mRectangle.width = x - mRectangle.x; + mRectangle.height = y - mRectangle.y; } - //invalidate both old and new rect return 0; } - -int tSelection::ButtonUp(wxMouseEvent &e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int JZSelection::ButtonUp(wxMouseEvent& Event) { - if (Active) + if (mActive) { -#ifdef __WXMSW__ -//OBSOLETE Canvas->ReleaseMouse(); -#endif - Active = 0; - r.SetNormal(); -// wxDC *dc = new wxPaintDC(win);//Canvas->GetDC(); + mActive = false; + mRectangle.SetNormal(); -// Dc.SetLogicalFunction(wxXOR); -// if (r.width && r.height) -// Dc.DrawRectangle(r.x, r.y, r.width, r.height); -// Dc.SetLogicalFunction(wxCOPY); - Selected = (r.width > 3 && r.height > 3); //its selected only if larger than 3x3 pixels + // Only select if the rectangle is larger than 3x3 pixels. + mSelected = (mRectangle.width > 3 && mRectangle.height > 3); return 1; } - win->Refresh(); + + mpWindow->Refresh(); return 0; } +//----------------------------------------------------------------------------- // Description: // Draw the selected rectangle, normally called from OnDraw // in the parent window. -void tSelection::Draw(wxDC& Dc) +//----------------------------------------------------------------------------- +void JZSelection::Draw(wxDC& Dc, int ScrolledX, int ScrolledY) { -// cout -// << "tSelection::Draw ---------------------------------------------------" -// << endl; - // Dc.DrawRectangle(100,100,100,100); -// if (Selected) //we cant check for "selected" here, because... -// { +// if (mSelected) + { + JZRectangle Rectangle = mRectangle; - JZRectangle rr = r; - - Dc.DestroyClippingRegion(); - Dc.SetLogicalFunction(wxXOR); Dc.SetBrush(*mpBackgroundBrush); - rr.SetNormal(); - if (rr.width && rr.height) + Rectangle.SetNormal(); + if (Rectangle.width && Rectangle.height) { - Dc.DrawRectangle(rr.x, rr.y, rr.width, rr.height); + Dc.DrawRectangle( + Rectangle.x - ScrolledX, + Rectangle.y - ScrolledY, + Rectangle.width, + Rectangle.height); } Dc.SetLogicalFunction(wxCOPY); -// } + } } -// Draw, but use clipping to redruce drawing -void tSelection::Draw(wxDC& Dc, int x, int y, int w, int h) +//----------------------------------------------------------------------------- +// Description: +// Draw, but use clipping to redruce drawing. +//----------------------------------------------------------------------------- +void JZSelection::Draw( + wxDC& Dc, + int ScrolledX, + int ScrolledY, + int ClipX, + int ClipY, + int ClipWidth, + int ClipHeight) { -// if (Selected) -// { - Dc.SetClippingRegion(x, y, w, h); - Draw(Dc); +// if (mSelected) + { + Dc.SetClippingRegion(ClipX, ClipY, ClipWidth, ClipHeight); + Draw(Dc, ScrolledX, ScrolledY); Dc.DestroyClippingRegion(); - // } + } } +//----------------------------------------------------------------------------- // I think this one is meant to select a rectangle and repaint it. // It did this by drawing directly in the device context. This is bad, so I // tried changing it to invalidation instead. -void tSelection::Select(JZRectangle &rr, int x, int y, int w, int h) +//----------------------------------------------------------------------------- +void JZSelection::Select(JZRectangle& Rectangle, int x, int y, int w, int h) { // clear old rectangle // Draw(x, y, w, h); // make new one - r = rr; - Selected = true; + mRectangle = Rectangle; + mSelected = true; // Draw(x, y, w, h); - win->Refresh(); //inefficient because should invvalidate only the rectangle + + // Inefficient because should invalidate only the rectangle. + mpWindow->Refresh(); } -void tSelection::Select(JZRectangle &rr) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZSelection::Select(JZRectangle& Rectangle) { - Select(rr, 0,0,3000,3000); + Select(Rectangle, 0, 0, 3000, 3000); } -// *********************************************************************** -// tSnapSelection -// *********************************************************************** +//***************************************************************************** +// Description: +// This is the snap selection class definition. +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZSnapSelection::JZSnapSelection(wxWindow* pWindow) + : JZSelection(pWindow), + mXCoordinates(), + mYCoordinates(), + mXMin(0), + mXMax(0), + mXStep(0), + mYMin(0), + mYMax(0), + mYStep(0) +{ +} - - - -static void SnapVec(int &x, int *Coords, int nCoords, int up) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZSnapSelection::Snap(int& x, int& y, bool drag) { - int i; - for (i = 0; i < nCoords; i++) + if (!mXCoordinates.empty()) { - if (Coords[i] > x) - { - if (up || i == 0) - x = Coords[i]; - else - x = Coords[i-1]; - return; - } + SnapToVector(x, mXCoordinates, drag); } - x = Coords[nCoords - 1]; -} + else if (mXStep) + { + SnapMod(x, mXMin, mXMax, mXStep, drag); + } - -static void SnapMod(int &x, int Min, int Max, int Step, int up) -{ - if (x <= Min) + if (!mYCoordinates.empty()) { - x = Min; - return; + SnapToVector(y, mYCoordinates, drag); } - if (x >= Max) + else if (mYStep) { - x = Max; - return; + SnapMod(y, mYMin, mYMax, mYStep, drag); } - x -= (x - Min) % Step; - if (up) - x += Step; } - - -void tSnapSelection::Snap(float &fx, float &fy, int drag) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZSnapSelection::SetXSnap(int XCount, int* pXVector) { - int x = (int)fx; - int y = (int)fy; - if (xCoords) - SnapVec(x, xCoords, nxCoords, drag); - else if (xStep) - SnapMod(x, xMin, xMax, xStep, drag); - - if (yCoords) - SnapVec(y, yCoords, nyCoords, drag); - else if (yStep) - SnapMod(y, yMin, yMax, yStep, drag); - fx = x; - fy = y; + mXCoordinates.clear(); + for (int i = 0; i < XCount; ++i) + { + mXCoordinates.push_back(pXVector[i]); + } + mXStep = 0; } - -tSnapSelection::tSnapSelection(wxWindow *c) - : tSelection(c) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZSnapSelection::SetYSnap(int YCount, int* pYVector) { - xCoords = 0; - yCoords = 0; - xStep = yStep = 0; + mYCoordinates.clear(); + for (int i = 0; i < YCount; ++i) + { + mXCoordinates.push_back(pYVector[i]); + } + mYStep = 0; } -void tSnapSelection::SetXSnap(int nx, int *cx) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZSnapSelection::SetXSnap(int XMin, int XMax, int XStep) { - xCoords = cx; - nxCoords = nx; - xStep = 0; + mXMin = XMin; + mXMax = XMax; + mXStep = XStep; + mXCoordinates.clear(); } -void tSnapSelection::SetYSnap(int ny, int *cy) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZSnapSelection::SetYSnap(int YMin, int YMax, int YStep) { - yCoords = cy; - nyCoords = ny; - yStep = 0; + mYMin = YMin; + mYMax = YMax; + mYStep = YStep; + mYCoordinates.clear(); } -void tSnapSelection::SetXSnap(int xmin, int xmax, int xstep) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZSnapSelection::SnapToVector( + int& Coordinate, + vector<int> Vector, + bool Up) { - xMin = xmin; - xMax = xmax; - xStep = xstep; - xCoords = 0; + for (unsigned i = 0; i < Vector.size(); ++i) + { + if (Vector[i] > Coordinate) + { + if (Up || i == 0) + { + Coordinate = Vector[i]; + } + else + { + Coordinate = Vector[i - 1]; + } + return; + } + } + Coordinate = Vector[Vector.size() - 1]; } -void tSnapSelection::SetYSnap(int ymin, int ymax, int ystep) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZSnapSelection::SnapMod( + int& Coordinate, + int Min, + int Max, + int Step, + bool Up) { - yMin = ymin; - yMax = ymax; - yStep = ystep; - yCoords = 0; + if (Coordinate <= Min) + { + Coordinate = Min; + return; + } + if (Coordinate >= Max) + { + Coordinate = Max; + return; + } + Coordinate -= (Coordinate - Min) % Step; + if (Up) + { + Coordinate += Step; + } } // ************************************************************************* // tMouseCounter // ************************************************************************* - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tMouseCounter::tMouseCounter( tButtonLabelInterface* wwin, - JZRectangle* rr, + JZRectangle* Rectangle, int val, int min, int max, int wait) { win = wwin; - r = *rr; + r = *Rectangle; Value = val; Min = min; Max = max; @@ -403,45 +457,59 @@ Wait = wait; } - -int tMouseCounter::LeftDown(wxMouseEvent &e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int tMouseCounter::LeftDown(wxMouseEvent& Event) { - Delta = e.ShiftDown() ? 10 : 1; + Delta = Event.ShiftDown() ? 10 : 1; Start(Timeout); if (Wait) + { ShowValue(TRUE); + } else + { Notify(); + } return 0; } -int tMouseCounter::LeftUp(wxMouseEvent &e) +int tMouseCounter::LeftUp(wxMouseEvent& Event) { Stop(); ShowValue(FALSE); return 1; } -int tMouseCounter::RightDown(wxMouseEvent &e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int tMouseCounter::RightDown(wxMouseEvent& Event) { - Delta = e.ShiftDown() ? -10 : -1; + Delta = Event.ShiftDown() ? -10 : -1; Start(Timeout); if (Wait) + { ShowValue(TRUE); + } else + { Notify(); + } return 0; + } - -int tMouseCounter::RightUp(wxMouseEvent &e) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +int tMouseCounter::RightUp(wxMouseEvent& Event) { Stop(); ShowValue(FALSE); return 1; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tMouseCounter::Notify() { Value += Delta; @@ -458,7 +526,8 @@ } } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tMouseCounter::ShowValue(bool down) { char buf[20]; @@ -485,7 +554,7 @@ //Frame->SetStatusText("Click Destination point"); } -int tMarkDestin::ButtonDown(wxMouseEvent &e) +int tMarkDestin::ButtonDown(wxMouseEvent& Event) { wxCursor c = wxCursor(wxCURSOR_ARROW); Canvas->SetCursor(c); @@ -493,7 +562,7 @@ //converts physical coords to logical(scrolled) coords wxClientDC* scrolledDC=new wxClientDC(Canvas); Canvas->PrepareDC(*scrolledDC); - wxPoint point=e.GetLogicalPosition(*scrolledDC); + wxPoint point = Event.GetLogicalPosition(*scrolledDC); delete scrolledDC; x=point.x; @@ -502,17 +571,17 @@ return 1; } -int tMarkDestin::RightDown(wxMouseEvent &e) +int tMarkDestin::RightDown(wxMouseEvent& Event) { - ButtonDown(e); + ButtonDown(Event); Aborted = 1; //Frame->SetStatusText("Operation aborted"); return 1; } -int tMarkDestin::LeftDown(wxMouseEvent &e) +int tMarkDestin::LeftDown(wxMouseEvent& Event) { - ButtonDown(e); + ButtonDown(Event); Aborted = 0; //Frame->SetStatusText(""); return 1; Modified: trunk/jazz/src/MouseAction.h =================================================================== --- trunk/jazz/src/MouseAction.h 2008-05-04 04:35:13 UTC (rev 482) +++ trunk/jazz/src/MouseAction.h 2008-05-04 04:43:51 UTC (rev 483) @@ -29,6 +29,8 @@ #include "Rectangle.h" +#include <vector> + class JZEventWindow; enum TEMousePlayMode @@ -140,56 +142,125 @@ //***************************************************************************** // Description: -// Selection - draw a rectangle with the mouse, selecting events -// This class needs to draw in the window, thus it needs access to the -// device context of the window. This was by storing a wxCanvas pointer -// in wxwin168, but wxCanvas is gone in wxwin2. +// This is the selection class declaration. This class selects events using +// the mouse and draws indicating the selected events. //***************************************************************************** -class tSelection : public tMouseAction +class JZSelection : public tMouseAction { public: - tSelection(wxWindow* w);//wxCanvas *canvas); - virtual ~tSelection(); + JZSelection(wxWindow* pWindow); - int Active; - virtual void Snap(int &x, int &y, int drag) {} - JZRectangle r; - bool Selected; // r is valid - virtual int Dragging(wxMouseEvent &); - virtual int Event(wxMouseEvent &e); - virtual int ButtonDown(wxMouseEvent &); - virtual int ButtonUp(wxMouseEvent &); - virtual void Draw(wxDC& Dc); - virtual void Draw(wxDC& Dc, int x, int y, int w, int h); // clipping - // may not be called while dragging - void Select(JZRectangle &rr, int x, int y, int w, int h); - void Select(JZRectangle &rr); + virtual ~JZSelection(); + virtual bool IsActive() const + { + return mActive; + } + + virtual bool IsSelected() const + { + return mSelected; + } + + virtual void SetSelected(bool Selected) + { + mSelected = Selected; + } + + virtual const JZRectangle& GetRectangle() const + { + return mRectangle; + } + + virtual void SetRectangle(const JZRectangle& Rectangle) + { + mRectangle = Rectangle; + } + + virtual void Snap(int& x, int& y, bool drag) + { + } + + virtual int Dragging(wxMouseEvent& Event); + + virtual int Event(wxMouseEvent& Event); + + virtual int ButtonDown(wxMouseEvent& Event); + + virtual int ButtonUp(wxMouseEvent& Event); + + virtual void Draw(wxDC& Dc, int ScrolledX, int ScrolledY); + + // Drawing with clipping. + virtual void Draw( + wxDC& Dc, + int ScrolledX, + int ScrolledY, + int ClipX, + int ClipY, + int ClipWidth, + int ClipHeight); + + // May not be called while dragging. + void Select(JZRectangle& rr, int x, int y, int w, int h); + + void Select(JZRectangle& Rectangle); + private: - wxWindow* win; + bool mActive; - // wxCanvas *Canvas; + // The following indicates if the rectangle is valid. + bool mSelected; + JZRectangle mRectangle; + + wxWindow* mpWindow; + wxBrush* mpBackgroundBrush; }; //***************************************************************************** +// Description: +// This is the snap selection class declaration. //***************************************************************************** -class tSnapSelection : public tSelection +class JZSnapSelection : public JZSelection { public: - tSnapSelection(wxWindow *c); - virtual void Snap(float &x, float &y, int up); - void SetXSnap(int ny, int *cx); - void SetYSnap(int ny, int *cy); - void SetXSnap(int xMin, int xMax, int xStep); - void SetYSnap(int yMin, int yMax, int yStep); + JZSnapSelection(wxWindow* pWindow); + + virtual void Snap(int& x, int& y, bool Up); + + void SetXSnap(int XCount, int* pXVector); + + void SetYSnap(int YCount, int* pYVector); + + void SetXSnap(int XMin, int XMax, int XStep); + + void SetYSnap(int YMin, int YMax, int YStep); + + private: + + static void SnapToVector( + int& Coordinate, + std::vector<int> Vector, + bool Up); + + static void SnapMod( + int& Coordinate, + int Min, + int Max, + int Step, + bool Up); + protected: - int *xCoords, nxCoords; - int *yCoords, nyCoords; - int xMin, xMax, xStep, yMin, yMax, yStep; + + std::vector<int> mXCoordinates; + + std::vector<int> mYCoordinates; + + int mXMin, mXMax, mXStep, mYMin, mYMax, mYStep; }; Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2008-05-04 04:35:13 UTC (rev 482) +++ trunk/jazz/src/PianoWindow.cpp 2008-05-04 04:43:51 UTC (rev 483) @@ -997,7 +997,14 @@ DrawPlayPosition(LocalDc); // Draw the selection box. - mpSnapSel->Draw(LocalDc, mEventsX, mEventsY, mEventsWidth, mEventsHeight); + mpSnapSel->Draw( + LocalDc, + mScrolledX, + mScrolledY, + mEventsX, + mEventsY, + mEventsWidth, + mEventsHeight); Dc.Blit( 0, @@ -1022,7 +1029,10 @@ //----------------------------------------------------------------------------- void JZPianoWindow::DrawPlayPosition(wxDC& Dc) { - if (!mpSnapSel->Active && mPlayClock >= mFromClock && mPlayClock < mToClock) + if ( + !mpSnapSel->IsActive() && + mPlayClock >= mFromClock && + mPlayClock < mToClock) { Dc.SetBrush(*wxBLACK_BRUSH); Dc.SetPen(*wxBLACK_PEN); @@ -1639,7 +1649,7 @@ int Clock, LoopClock; if (action == MA_CYCLE) { - if (mpSnapSel->Selected) + if (mpSnapSel->IsSelected()) { Clock = mpFilter->FromClock; LoopClock = mpFilter->ToClock; @@ -1805,10 +1815,11 @@ //----------------------------------------------------------------------------- void JZPianoWindow::SnapSelStop(wxMouseEvent& Event) { - if (mpSnapSel->Selected) + if (mpSnapSel->IsSelected()) { - int fr = y2Pitch((mpSnapSel->r.y + mpSnapSel->r.height - 1)); - int to = y2Pitch(mpSnapSel->r.y + 1); + int fr = y2Pitch( + mpSnapSel->GetRectangle().y + mpSnapSel->GetRectangle().height - 1); + int to = y2Pitch(mpSnapSel->GetRectangle().y + 1); mpFilter->FltEvents[FltKeyOn].Selected = mVisibleKeyOn; mpFilter->FltEvents[FltKeyOn].FromValue = fr; @@ -1847,13 +1858,16 @@ mpFilter->FromTrack = mTrackIndex; mpFilter->ToTrack = mTrackIndex; - mpFilter->FromClock = SnapClock(x2Clock(mpSnapSel->r.x + 1)); - mpFilter->ToClock = SnapClock(x2Clock((mpSnapSel->r.x + mpSnapSel->r.width + 1))); + mpFilter->FromClock = SnapClock(x2Clock(mpSnapSel->GetRectangle().x + 1)); + mpFilter->ToClock = SnapClock(x2Clock( + mpSnapSel->GetRectangle().x + mpSnapSel->GetRectangle().width + 1)); } // SN++ Veloc- oder Aftertouch-Editor updaten if (mpCtrlEdit) + { mpCtrlEdit->UpDate(); + } } //----------------------------------------------------------------------------- @@ -1905,7 +1919,7 @@ int scroll_clock = (mFromClock + 5 * mToClock) / 6; if ( - !mpSnapSel->Active && + !mpSnapSel->IsActive() && (Clock > scroll_clock || Clock < mFromClock) && Clock >= 0) { // Avoid permenent redraws when end of scroll range is reached. @@ -1920,7 +1934,7 @@ SetXScrollPosition(x); } - if (!mpSnapSel->Active) // sets clipping + if (!mpSnapSel->IsActive()) // sets clipping { if (mPlayClock != Clock) { @@ -1947,7 +1961,7 @@ //----------------------------------------------------------------------------- int JZPianoWindow::EventsSelected(const char *msg) { - if (!mpSnapSel->Selected) + if (!mpSnapSel->IsSelected()) { if (msg == 0) msg = "please select some events first"; @@ -2010,7 +2024,7 @@ { SnapSelStart(Event); - if (mpSnapSel->Selected) + if (mpSnapSel->IsSelected()) { // Redraw the whole window instead (inefficient, we should rather // invalidate a rect). Modified: trunk/jazz/src/PianoWindow.h =================================================================== --- trunk/jazz/src/PianoWindow.h 2008-05-04 04:35:13 UTC (rev 482) +++ trunk/jazz/src/PianoWindow.h 2008-05-04 04:43:51 UTC (rev 483) @@ -34,7 +34,6 @@ class JZEvent; class JZFilter; class tCtrlEditBase; -class tSnapSelection; //***************************************************************************** //***************************************************************************** Modified: trunk/jazz/src/SampleWindow.cpp =================================================================== --- trunk/jazz/src/SampleWindow.cpp 2008-05-04 04:35:13 UTC (rev 482) +++ trunk/jazz/src/SampleWindow.cpp 2008-05-04 04:43:51 UTC (rev 483) @@ -153,7 +153,7 @@ int paint_offset; int paint_length; - tSnapSelection snapsel; + JZSnapSelection snapsel; // sel_fr == 0: no selection and no insertion point // sel_fr > 0 && sel_fr == sel_to: insertion point // sel_fr > 0 && sel_fr < sel_to: selected range @@ -323,48 +323,59 @@ { mouse_up_sets_insertion_point = 0; mouse_down = TRUE; - if (snapsel.Selected) + if (snapsel.IsSelected()) { - snapsel.Draw(*pDc); - snapsel.Selected = 0; + snapsel.Draw(*pDc, 0, 0); + snapsel.SetSelected(false); } else if (inspt.IsVisible()) + { inspt.Draw(); + } else + { mouse_up_sets_insertion_point = 1; + } snapsel.Event(e); } else if (e.LeftUp()) { mouse_down = FALSE; snapsel.Event(e); - if (snapsel.Selected) + if (snapsel.IsSelected()) { - snapsel.Draw(*pDc); - sel_fr = Pixel2Sample(snapsel.r.x); - sel_to = Pixel2Sample(snapsel.r.x + snapsel.r.width); + snapsel.Draw(*pDc, 0, 0); + sel_fr = Pixel2Sample( + snapsel.GetRectangle().x); + sel_to = Pixel2Sample( + snapsel.GetRectangle().x + snapsel.GetRectangle().width); } - else if (mouse_up_sets_insertion_point) { + else if (mouse_up_sets_insertion_point) + { int x, y; e.GetPosition(&x, &y); sel_fr = sel_to = Pixel2Sample(x); inspt.Draw(x); } else + { sel_fr = sel_to = -1; + } } else if (e.Dragging() && mouse_down) + { snapsel.Event(e); + } } void tSampleCnvs::ClearSelection() { - if (snapsel.Selected) + if (snapsel.IsSelected()) { wxDC* pDc = new wxClientDC(this); - snapsel.Draw(*pDc); - snapsel.Selected = 0; + snapsel.Draw(*pDc, 0, 0); + snapsel.SetSelected(false); } else if (inspt.IsVisible()) { @@ -395,10 +406,10 @@ GetClientSize(&cw, &ch); r.SetY(0); r.SetHeight(ch); - snapsel.r = r; - snapsel.Selected = TRUE; + snapsel.SetRectangle(r); + snapsel.SetSelected(true); wxDC* pDc = new wxClientDC(this); - snapsel.Draw(*pDc); + snapsel.Draw(*pDc, 0, 0); } @@ -452,16 +463,16 @@ DrawTicks(x, y, w); } - if (snapsel.Selected) + if (snapsel.IsSelected()) { JZRectangle r; r.SetX(Sample2Pixel(sel_fr)); r.SetWidth(Sample2Pixel(sel_to) - r.x); r.SetY(0); r.SetHeight(ch); - snapsel.r = r; + snapsel.SetRectangle(r); wxDC* pDc = new wxClientDC(this); - snapsel.Draw(*pDc); + snapsel.Draw(*pDc, 0, 0); } else if (sel_fr > 0) { Modified: trunk/jazz/src/TrackWindow.cpp =================================================================== --- trunk/jazz/src/TrackWindow.cpp 2008-05-04 04:35:13 UTC (rev 482) +++ trunk/jazz/src/TrackWindow.cpp 2008-05-04 04:43:51 UTC (rev 483) @@ -50,6 +50,8 @@ EVT_LEFT_DOWN(JZTrackWindow::OnLeftButtonDown) + EVT_MOTION(JZTrackWindow::OnMouseMove) + EVT_LEFT_UP(JZTrackWindow::OnLeftButtonUp) EVT_RIGHT_UP(JZTrackWindow::OnRightButtonUp) @@ -166,7 +168,7 @@ int scroll_clock = (mFromClock + 5 * mToClock) / 6; if ( - !mpSnapSel->Active && + !mpSnapSel->IsActive() && (Clock > scroll_clock || Clock < mFromClock) && Clock >= 0) { // Avoid permanent redraws when end of scroll range is reached. @@ -181,7 +183,7 @@ SetXScrollPosition(x); } - if (!mpSnapSel->Active) // sets clipping + if (!mpSnapSel->IsActive()) // sets clipping { if (mPlayClock != Clock) { @@ -269,11 +271,24 @@ Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight) { SnapSelectionStart(Event); + mpSnapSel->ButtonDown(Event); } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +void JZTrackWindow::OnMouseMove(wxMouseEvent& Event) +{ + if (Event.LeftIsDown()) + { + mpSnapSel->Dragging(Event); +// SnapSelectionStop(Event); + Refresh(false); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZTrackWindow::OnLeftButtonUp(wxMouseEvent& Event) { wxPoint Point = Event.GetPosition(); @@ -377,6 +392,8 @@ Point.x >= mEventsX && Point.x < mEventsX + mEventsWidth && Point.y >= mEventsY && Point.y < mEventsY + mEventsHeight) { + mpSnapSel->ButtonUp(Event); + // The point is in event area. SnapSelectionStop(Event); } @@ -633,9 +650,16 @@ LocalDc.SetPen(*wxBLACK_PEN); ostringstream Oss; Oss << BarInfo.GetBarIndex() + 1 - Intro; - LocalDc.DrawText(Oss.str().c_str(), x + mLittleBit, mEventsY - mTrackHeight); + LocalDc.DrawText( + Oss.str().c_str(), + x + mLittleBit, + mEventsY - mTrackHeight); LocalDc.SetPen(*wxGREY_PEN); - LocalDc.DrawLine(x, mEventsY + 1 - mTrackHeight, x, mEventsY + mEventsHeight); + LocalDc.DrawLine( + x, + mEventsY + 1 - mTrackHeight, + x, + mEventsY + mEventsHeight); } else { @@ -741,7 +765,14 @@ DrawPlayPosition(LocalDc); // Draw the selection box. - mpSnapSel->Draw(LocalDc, mEventsX, mEventsY, mEventsWidth, mEventsHeight); + mpSnapSel->Draw( + LocalDc, + mScrolledX, + mScrolledY, + mEventsX, + mEventsY, + mEventsWidth, + mEventsHeight); Dc.Blit( 0, @@ -839,7 +870,10 @@ //----------------------------------------------------------------------------- void JZTrackWindow::DrawPlayPosition(wxDC& Dc) { - if (!mpSnapSel->Active && mPlayClock >= mFromClock && mPlayClock < mToClock) + if ( + !mpSnapSel->IsActive() && + mPlayClock >= mFromClock && + mPlayClock < mToClock) { Dc.SetBrush(*wxBLACK_BRUSH); Dc.SetPen(*wxBLACK_PEN); @@ -1179,7 +1213,7 @@ //----------------------------------------------------------------------------- int JZTrackWindow::EventsSelected(const wxString& Message) { - if (!mpSnapSel->Selected) + if (!mpSnapSel->IsSelected()) { wxMessageBox(Message, "Error", wxOK); return 0; @@ -1227,14 +1261,16 @@ Event.GetPosition(&x, &y); gpProject->SetPlayPosition(x2BarClock(x)); gpProject->Mute((Event.RightDown() != 0)); - if (mpSnapSel->Selected && (Event.ShiftDown() || Event.MiddleDown())) + if ( + mpSnapSel->IsSelected() && + (Event.ShiftDown() || Event.MiddleDown())) { gpProject->SetLoop(true); } else { gpProject->SetLoop(false); - mPreviouslyRecording = mpSnapSel->Selected; + mPreviouslyRecording = mpSnapSel->IsSelected(); } break; @@ -1281,7 +1317,7 @@ bool record = gpProject->mRecord; // Is it possible to record? - if (record && mpSnapSel->Selected) + if (record && mpSnapSel->IsSelected()) { pRecInfo->mTrackIndex = mpFilter->FromTrack; @@ -1315,7 +1351,7 @@ // Is it possible to loop? int loop_clock = 0; - if (loop && mpSnapSel->Selected) + if (loop && mpSnapSel->IsSelected()) { mPreviousClock = mpFilter->FromClock; loop_clock = mpFilter->ToClock; @@ -1390,14 +1426,15 @@ //----------------------------------------------------------------------------- void JZTrackWindow::SnapSelectionStop(wxMouseEvent& Event) { - if (mpSnapSel->Selected) + if (mpSnapSel->IsSelected()) { - mpFilter->FromTrack = y2TrackIndex(mpSnapSel->r.y); - mpFilter->ToTrack = y2TrackIndex( - mpSnapSel->r.y + mpSnapSel->r.GetHeight() - 1); - mpFilter->FromClock = x2BarClock(mpSnapSel->r.x + 1); + mpFilter->FromTrack = y2TrackIndex(mpSnapSel->GetRectangle().y); + mpFilter->ToTrack = y2TrackIndex( + mpSnapSel->GetRectangle().y + + mpSnapSel->GetRectangle().GetHeight() - 1); + mpFilter->FromClock = x2BarClock(mpSnapSel->GetRectangle().x + 1); mpFilter->ToClock = x2BarClock( - mpSnapSel->r.x + mpSnapSel->r.GetWidth() + 1); + mpSnapSel->GetRectangle().x + mpSnapSel->GetRectangle().GetWidth() + 1); // NextWin->NewPosition(mpFilter->FromTrack, mpFilter->FromClock); } } Modified: trunk/jazz/src/TrackWindow.h =================================================================== --- trunk/jazz/src/TrackWindow.h 2008-05-04 04:35:13 UTC (rev 482) +++ trunk/jazz/src/TrackWindow.h 2008-05-04 04:43:51 UTC (rev 483) @@ -30,7 +30,6 @@ class JZSong; class JZTrack; class JZFilter; -class tSnapSelection; class wxFont; enum TECounterModes @@ -94,6 +93,8 @@ void OnLeftButtonDown(wxMouseEvent& Event); + void OnMouseMove(wxMouseEvent& Event); + void OnLeftButtonUp(wxMouseEvent& Event); void OnRightButtonUp(wxMouseEvent& Event); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-04 04:57:35
|
Revision: 484 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=484&view=rev Author: pstieber Date: 2008-05-03 21:57:33 -0700 (Sat, 03 May 2008) Log Message: ----------- Changed direct snap selection member access to IsSelected. Modified Paths: -------------- trunk/jazz/src/ControlEdit.cpp trunk/jazz/src/Harmony.cpp Modified: trunk/jazz/src/ControlEdit.cpp =================================================================== --- trunk/jazz/src/ControlEdit.cpp 2008-05-04 04:43:51 UTC (rev 483) +++ trunk/jazz/src/ControlEdit.cpp 2008-05-04 04:57:33 UTC (rev 484) @@ -509,7 +509,7 @@ { // SN++ Falls im PianoWin Events selektiert sind, werden nur diese // Events geaendert - if (!mpPianoWindow->mpSnapSel->Selected) + if (!mpPianoWindow->mpSnapSel->IsSelected()) { return (pEvent->IsKeyOn() != 0); } @@ -540,7 +540,7 @@ tEventIterator iter(track); - if (mpPianoWindow->mpSnapSel->Selected) + if (mpPianoWindow->mpSnapSel->IsSelected()) { from_clk = mpPianoWindow->GetFilter()->FromClock; to_clk = mpPianoWindow->GetFilter()->ToClock; @@ -558,7 +558,7 @@ // SN++ Falls im PianoWin Events selektiert sind, werden nur diese // Events geaendert if ( - !mpPianoWindow->mpSnapSel->Selected || + !mpPianoWindow->mpSnapSel->IsSelected() || mpPianoWindow->GetFilter()->IsSelected(pEvent)) { @@ -610,7 +610,7 @@ // SN++ Falls im PianoWin Events selektiert sind, werden nur diese // Events geaendert - if (!mpPianoWindow->mpSnapSel->Selected) + if (!mpPianoWindow->mpSnapSel->IsSelected()) { return pEvent->IsKeyPressure() != 0; } @@ -643,7 +643,7 @@ JZEvent* pEvent; // SN++ Apply works only if some events are selected !! - if (!mpPianoWindow->mpSnapSel->Selected) + if (!mpPianoWindow->mpSnapSel->IsSelected()) { OnRevert(); return; @@ -654,7 +654,7 @@ tEventIterator iter(track); - if (mpPianoWindow->mpSnapSel->Selected) + if (mpPianoWindow->mpSnapSel->IsSelected()) { from_clk = mpPianoWindow->GetFilter()->FromClock; to_clk = mpPianoWindow->GetFilter()->ToClock; @@ -676,7 +676,7 @@ while (pEvent) { if ( - !mpPianoWindow->mpSnapSel->Selected || + !mpPianoWindow->mpSnapSel->IsSelected() || mpPianoWindow->GetFilter()->IsSelected(pEvent)) { k = pEvent->IsKeyPressure(); @@ -696,7 +696,7 @@ while (pEvent) { if ( - !mpPianoWindow->mpSnapSel->Selected || + !mpPianoWindow->mpSnapSel->IsSelected() || mpPianoWindow->GetFilter()->IsSelected(pEvent)) { keyon = pEvent->IsKeyOn(); @@ -740,7 +740,7 @@ while (pEvent) { if ( - !mpPianoWindow->mpSnapSel->Selected || + !mpPianoWindow->mpSnapSel->IsSelected() || mpPianoWindow->GetFilter()->IsSelected(pEvent)) { if (pEvent->IsKeyPressure()) Modified: trunk/jazz/src/Harmony.cpp =================================================================== --- trunk/jazz/src/Harmony.cpp 2008-05-04 04:43:51 UTC (rev 483) +++ trunk/jazz/src/Harmony.cpp 2008-05-04 04:57:33 UTC (rev 484) @@ -1489,7 +1489,7 @@ //----------------------------------------------------------------------------- HBAnalyzer * HBCanvas::GetAnalyzer() { - if (mSequenceCount > 0 && gpTrackWindow->mpSnapSel->Selected) + if (mSequenceCount > 0 && gpTrackWindow->mpSnapSel->IsSelected()) { HBAnalyzer *analyzer = new HBAnalyzer(mSequence, mSequenceCount); analyzer->Init(gpTrackWindow->mpFilter, transpose_res); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-05 03:51:01
|
Revision: 485 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=485&view=rev Author: pstieber Date: 2008-05-04 20:50:58 -0700 (Sun, 04 May 2008) Log Message: ----------- Wrapped literal title argument to wxDialog with wxString() to force construction of this type. I didn't have to do this in Windows or on Linux because I compiled wxWidgets with std::string compatability. I thought I did the same on the Mac, but I may have made a mistake. Modified Paths: -------------- trunk/jazz/src/Audio.cpp trunk/jazz/src/GuitarSettingsDialog.cpp trunk/jazz/src/Harmony.cpp Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2008-05-04 04:57:33 UTC (rev 484) +++ trunk/jazz/src/Audio.cpp 2008-05-05 03:50:58 UTC (rev 485) @@ -956,7 +956,7 @@ int tSamplesDlg::current = 0; tSamplesDlg::tSamplesDlg(wxWindow* pParent, tSampleSet &s) - : wxDialog(pParent, wxID_ANY, "Sample Settings"), + : wxDialog(pParent, wxID_ANY, wxString("Sample Settings")), set(s) { if (path == 0) Modified: trunk/jazz/src/GuitarSettingsDialog.cpp =================================================================== --- trunk/jazz/src/GuitarSettingsDialog.cpp 2008-05-04 04:57:33 UTC (rev 484) +++ trunk/jazz/src/GuitarSettingsDialog.cpp 2008-05-05 03:50:58 UTC (rev 485) @@ -32,7 +32,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- JZGuitarSettingsDialog::JZGuitarSettingsDialog(wxWindow* pParent) - : wxDialog(pParent, wxID_ANY, "Guitar Settings"), + : wxDialog(pParent, wxID_ANY, wxString("Guitar Settings")), mpChordModeCheckBox(0), mpBassGuitarCheckBox(0), mpShowOctavesCheckBox(0)//, Modified: trunk/jazz/src/Harmony.cpp =================================================================== --- trunk/jazz/src/Harmony.cpp 2008-05-04 04:57:33 UTC (rev 484) +++ trunk/jazz/src/Harmony.cpp 2008-05-05 03:50:58 UTC (rev 485) @@ -1638,7 +1638,7 @@ HBContextDlg::HBContextDlg(HBCanvas *c, wxFrame *parent, HBContext *pct) - : wxDialog(parent, wxID_ANY, "Edit chord/scale" ) + : wxDialog(parent, wxID_ANY, wxString("Edit chord/scale")) { int i; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-10 16:38:41
|
Revision: 498 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=498&view=rev Author: pstieber Date: 2008-05-10 09:38:38 -0700 (Sat, 10 May 2008) Log Message: ----------- 1. Started adding some audio menus. 2. Started cleaning up Audio.cpp. Modified Paths: -------------- trunk/jazz/src/Audio.cpp trunk/jazz/src/Player.h trunk/jazz/src/Resources.h trunk/jazz/src/TrackFrame.cpp Modified: trunk/jazz/src/Audio.cpp =================================================================== --- trunk/jazz/src/Audio.cpp 2008-05-10 16:09:29 UTC (rev 497) +++ trunk/jazz/src/Audio.cpp 2008-05-10 16:38:38 UTC (rev 498) @@ -37,6 +37,7 @@ #include "FileSelector.h" #include "StringReadWrite.h" #include "Help.h" +#include "Resources.h" #include <iostream> #include <fstream> @@ -51,21 +52,22 @@ #define db(a) cout << #a << " = " << a << endl -// ----------------------------------------------------------- +//***************************************************************************** +//***************************************************************************** +class tSampleVoice +{ + // Activated on note on. Copies data from a tSample object to the output + // buffer as needed by the driver. - -class tSampleVoice { - /* - * activated on note on. Copies data from a tSample Object to the - * output buffer as needed by the driver. - */ - public: - tSampleVoice(tSampleSet &s) : set(s) { + tSampleVoice(tSampleSet &s) + : set(s) + { } - void Start(tSample *s, long c) { + void Start(tSample *s, long c) + { spl = s; clock = c; first = 1; @@ -74,7 +76,8 @@ prev = 0; } - void AddBuffer(short *b, long buffer_clock, unsigned int bufsize) { + void AddBuffer(short *b, long buffer_clock, unsigned int bufsize) + { // everything done? if (length <= 0) @@ -113,28 +116,33 @@ length -= count; b += offset; while (count--) + { *b++ += *data++; + } } - - - void AddListen(short *b, long fr_smpl, long to_smpl, unsigned int bufsize) { - - // everything done? + void AddListen(short *b, long fr_smpl, long to_smpl, unsigned int bufsize) + { + // Is everything done? if (length <= 0) + { return; + } - if (first) { + if (first) + { if (to_smpl > 0 && to_smpl < length) + { length = to_smpl; + } if (fr_smpl > 0 && fr_smpl < length) { data += fr_smpl; length -= fr_smpl; } - first = FALSE; + first = false; if (length <= 0) { return; @@ -143,7 +151,9 @@ int count = bufsize; if (count > length) + { count = length; + } // update length and copy data length -= count; @@ -153,23 +163,25 @@ } } - - int Finished() { + int Finished() + { return length <= 0; } private: - tSampleSet &set; - long clock; - tSample *spl; - short *data; - int first; - long length; - short prev; + tSampleSet& set; + long clock; + tSample* spl; + short* data; + int first; + long length; + short prev; }; -// ------------------------------------------------------------ - +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tSampleSet::tSampleSet(long tpm) : mDefaultFileName("noname.spl"), mRecordFileName("noname.wav") @@ -179,7 +191,9 @@ ticks_per_minute = tpm; for (i = 0; i < BUFCOUNT; i++) + { buffers[i] = new tAudioBuffer(0); + } adjust_audio_length = 1; has_changed = false; @@ -189,7 +203,8 @@ softsync = 1; dirty = 0; - for (i = 0; i < MAXSMPL; i++) { + for (i = 0; i < MAXSMPL; i++) + { samples[i] = new tSample(*this); samplewin[i] = 0; } @@ -198,26 +213,34 @@ bits = 16; // dont change!! for (i = 0; i < MAXPOLY; i++) + { voices[i] = new tSampleVoice(*this); + } num_voices = 0; - } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tSampleSet::~tSampleSet() { int i; - for (i = 0; i < MAXSMPL; i++) { + for (i = 0; i < MAXSMPL; i++) + { delete samples[i]; delete samplewin[i]; } for (i = 0; i < MAXPOLY; i++) + { delete voices[i]; + } for (i = 0; i < BUFCOUNT; i++) + { delete buffers[i]; + } } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::Edit(int key) { if (samplewin[key] == 0) @@ -226,11 +249,12 @@ samplewin[key] = new tSampleWin(gpTrackWindow, &samplewin[key], *spl); } - samplewin[key]->Show(TRUE); + samplewin[key]->Show(true); samplewin[key]->Redraw(); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::LoadDefaultSettings() { wxString FileName = FindFile("jazz.spl"); @@ -240,12 +264,14 @@ } } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSampleSet::Load(const wxString& FileName) { int version; // enable audio when loading a sample set - gpMidiPlayer->SetAudioEnabled(TRUE); + gpMidiPlayer->SetAudioEnabled(true); wxBeginBusyCursor(); for (int i = 0; i < MAXSMPL; i++) @@ -313,6 +339,8 @@ return 0; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::ReloadSamples() { for (int i = 0; i < MAXSMPL; i++) @@ -320,12 +348,14 @@ dirty = 0; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSampleSet::Save(const wxString& FileName) { ofstream os(FileName.c_str()); os << 1 << " " << speed << " " << channels << " " << softsync << endl; - for (int i = 0; i < MAXSMPL; i++) { + for (int i = 0; i < MAXSMPL; i++) + { tSample *spl = samples[i]; const char *fname = spl->GetFilename(); const char *label = spl->GetLabel(); @@ -344,14 +374,19 @@ return 0; } - -const char *tSampleSet::GetSampleName(int i) { +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +const char* tSampleSet::GetSampleName(int i) +{ if (0 <= i && i < MAXSMPL) + { return samples[i]->GetLabel(); + } return ""; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSampleSet::ResetBuffers(tEventArray *evnt_arr, long clock, long tpm) { int i; @@ -359,7 +394,9 @@ full_buffers.Clear(); driv_buffers.Clear(); for (i = 0; i < BUFCOUNT; i++) + { free_buffers.Put(buffers[i]); + } buffers_written = 0; events = evnt_arr; @@ -372,10 +409,12 @@ return 0; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSampleSet::ResetBufferSize(unsigned int bufsize) { - if (bufsize == 0 || bufsize > BUFBYTES || (bufsize & 1)) { + if (bufsize == 0 || bufsize > BUFBYTES || (bufsize & 1)) + { cerr << "invalid buffer size " << bufsize << '\n'; return 1; } @@ -384,7 +423,8 @@ return 0; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSampleSet::FillBuffers(long last_clock) { // check if last_clock is bigger than free buffer space @@ -413,7 +453,6 @@ return 0; } - // iterate the events and add sounding voices while (event_index < events->nEvents) { @@ -468,9 +507,10 @@ return nfree; } - +//----------------------------------------------------------------------------- // returns the number of buffers containing sound. Fills as many // buffers as possible, the last buffers may contain silence only. +//----------------------------------------------------------------------------- int tSampleSet::PrepareListen(tSample *spl, long fr_smpl, long to_smpl) { listen_sample = spl; @@ -481,10 +521,12 @@ int nfree = free_buffers.Count(); int sound_buffers = 0; - for (int i = 0; i < nfree; i++) { + for (int i = 0; i < nfree; i++) + { tAudioBuffer *buf = free_buffers.Get(); buf->Clear(); - if (!voices[0]->Finished()) { + if (!voices[0]->Finished()) + { voices[0]->AddListen(buf->Data(), fr_smpl, to_smpl, bufshorts); sound_buffers++; } @@ -494,14 +536,16 @@ return sound_buffers; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSampleSet::PrepareListen(int key, long fr_smpl, long to_smpl) { tSample *spl = samples[key]; return PrepareListen(spl, fr_smpl, to_smpl); } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSampleSet::ContinueListen() { int nfree = free_buffers.Count(); @@ -511,7 +555,8 @@ { tAudioBuffer *buf = free_buffers.Get(); buf->Clear(); - if (!voices[0]->Finished()) { + if (!voices[0]->Finished()) + { voices[0]->AddListen(buf->Data(), -1, -1, bufshorts); sound_buffers++; } @@ -521,8 +566,8 @@ return sound_buffers; } - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::AdjustAudioLength(JZTrack *t, long tpm) { if (!t->GetAudioMode() || !adjust_audio_length) @@ -548,14 +593,15 @@ } } - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::StartPlay(long clock) { ReloadSamples(); // touch all playback sample data, so they may get swapped into memory - for (int i = 0; i < MAXSMPL; i++) { + for (int i = 0; i < MAXSMPL; i++) + { tSample *spl = samples[i]; spl->GotoRAM(); } @@ -563,16 +609,17 @@ is_playing = 1; } - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::StopPlay() { is_playing = 0; } -// ****************************************************************** -// GUI -// ****************************************************************** - +//***************************************************************************** +// Description: +// This is the sample dialog. +//***************************************************************************** class tSamplesDlg : public wxDialog { friend class tSampleSet; @@ -635,7 +682,14 @@ ossbug2 = gpConfig->GetValue(C_OssBug2); duplex_audio = gpConfig->GetValue(C_DuplexAudio); - static const char *speedtxt[] = { "8000", "11025", "22050", "44100", 0 }; + static const char *speedtxt[] = + { + "8000", + "11025", + "22050", + "44100", + 0 + }; speed = set.GetSpeed(); speedstr = 0; for (int i = 0; speedtxt[i]; i++) @@ -722,7 +776,8 @@ wxEndBusyCursor(); wxForm::OnOk(); } - void OnCancel() { + void OnCancel() + { set.glb_dialog = 0; wxForm::OnCancel(); } @@ -742,25 +797,30 @@ #endif // OBSOLETE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::GlobalSettingsDlg() { - if (spl_dialog) { - spl_dialog->Show(TRUE); + if (spl_dialog) + { + spl_dialog->Show(true); return; } if (glb_dialog == 0) { #ifdef OBSOLETE - glb_dialog = new wxDialogBox(gpTrackWindow, "Audio Settings", FALSE ); + glb_dialog = new wxDialogBox(gpTrackWindow, "Audio Settings", false); tAudioGloblForm *form = new tAudioGloblForm(*this); form->AssociatePanel(glb_dialog); glb_dialog->Fit(); #endif // OBSOLETE } - glb_dialog->Show(TRUE); + glb_dialog->Show(true); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::SaveRecordingDlg(long frc, long toc, tAudioRecordBuffer &buf) { if (frc >= toc) @@ -796,24 +856,27 @@ } } - - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::AddNote(const char *fname, long frc, long toc) { int i; tSample *spl; // see if fname is already present in sample list - for (i = 0; i < MAXSMPL; i++) { + for (i = 0; i < MAXSMPL; i++) + { spl = samples[i]; if (strcmp(spl->GetFilename(), fname) == 0) break; } // if no entry is there, add an entry - if (i >= MAXSMPL) { + if (i >= MAXSMPL) + { // start somewhere near the top of the list - for (i = 15; i < MAXSMPL; i++) { + for (i = 15; i < MAXSMPL; i++) + { spl = samples[i]; if (spl->GetFilename()[0] == 0) break; @@ -840,7 +903,8 @@ #endif tEventIterator iter(info->mpTrack); JZEvent *e = iter.Range(frc, toc); - while (e != 0) { + while (e != 0) + { track->Kill(e); e = iter.Next(); } @@ -859,9 +923,13 @@ gpTrackWindow->Update(); } - - -void tSampleSet::SaveWave(const char *fname, long frc, long toc, tAudioRecordBuffer &buf) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void tSampleSet::SaveWave( + const char *fname, + long frc, + long toc, + tAudioRecordBuffer &buf) { WaveHeader wh; wh.main_chunk = RIFF; @@ -913,7 +981,8 @@ // very slow, but works! ofstream slow("t2.wav", ios::out | ios::bin | ios::trunc); slow.write((char *)&wh, sizeof(wh)); - for (long i = start_index; i < end_index; i++) { + for (long i = start_index; i < end_index; i++) + { int bi = i / bufsize; int di = i % bufsize; slow.write((char *)&buf.buffers[bi]->data[di], sizeof(short)); @@ -927,20 +996,27 @@ DEFINE_ARRAY(tAudioBufferArray, tAudioBuffer *) +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tAudioRecordBuffer::Clear() { int n = buffers.GetSize(); - for (int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) + { delete buffers[i]; buffers[i] = 0; } num_buffers = 0; } -tAudioBuffer * tAudioRecordBuffer::RequestBuffer() { +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +tAudioBuffer * tAudioRecordBuffer::RequestBuffer() +{ if (buffers[num_buffers] == 0) buffers[num_buffers] = new tAudioBuffer(0); - if (buffers[num_buffers] == 0) { + if (buffers[num_buffers] == 0) + { Clear(); fprintf(stderr, "memory exhausted!\n"); } @@ -952,9 +1028,13 @@ // ----------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- char * tSamplesDlg::path = 0; int tSamplesDlg::current = 0; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tSamplesDlg::tSamplesDlg(wxWindow* pParent, tSampleSet &s) : wxDialog(pParent, wxID_ANY, wxString("Sample Settings")), set(s) @@ -964,7 +1044,9 @@ names = new char * [tSampleSet::MAXSMPL]; for (int i = 0; i < tSampleSet::MAXSMPL; i++) + { names[i] = ListEntry(i); + } // buttons #ifdef OBSOLETE @@ -1003,10 +1085,12 @@ #endif // OBSOLETE Fit(); Sample2Win(current); - list->SetSelection(current, TRUE); - Show(TRUE); + list->SetSelection(current, true); + Show(true); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- char *tSamplesDlg::ListEntry(int i) { char buf[500]; @@ -1016,6 +1100,8 @@ return copystring(buf); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSamplesDlg::Sample2Win(int i) { tSample *spl = set.samples[i]; @@ -1028,6 +1114,8 @@ #endif } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSamplesDlg::Win2Sample(int i) { tSample *spl = set.samples[i]; @@ -1040,16 +1128,20 @@ #endif } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSamplesDlg::SetCurrentListEntry(int i) { if (i >= 0) { current = i; list->SetString(current, ListEntry(current)); - list->SetSelection(current, TRUE); + list->SetSelection(current, true); } } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- tSamplesDlg::~tSamplesDlg() { for (int i = 0; i < tSampleSet::MAXSMPL; i++) @@ -1057,6 +1149,8 @@ delete [] names; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSamplesDlg::OnCloseButton() { if (set.is_playing) @@ -1070,6 +1164,8 @@ Destroy(); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSamplesDlg::OnAddButton() { wxString fname = file_selector(path, "Load Sample", false, false, "*.wav"); @@ -1084,6 +1180,8 @@ } } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSamplesDlg::OnEditButton() { wxBeginBusyCursor(); @@ -1096,10 +1194,14 @@ set.Edit(current); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSamplesDlg::OnPlayButton() { if (set.is_playing) + { return; + } if (gpMidiPlayer->IsListening()) { gpMidiPlayer->ListenAudio(-1); @@ -1114,6 +1216,8 @@ wxEndBusyCursor(); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSamplesDlg::OnClrButton() { tSample *spl = set.samples[current]; @@ -1122,16 +1226,21 @@ Sample2Win(current); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSamplesDlg::OnHelpButton() { gpHelpInstance->ShowTopic("Sample Settings"); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSamplesDlg::OnListClick() { Win2Sample(current); int i = list->GetSelection(); - if (i >= 0) { + if (i >= 0) + { current = i; SetCurrentListEntry(i); Sample2Win(current); @@ -1170,17 +1279,22 @@ } #endif // OBSOLETE +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::SamplesDlg() { - if (glb_dialog) { - glb_dialog->Show(TRUE); + if (glb_dialog) + { + glb_dialog->Show(true); return; } if (spl_dialog == 0) spl_dialog = new tSamplesDlg(gpTrackWindow, *this); - spl_dialog->Show(TRUE); + spl_dialog->Show(true); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void tSampleSet::RefreshDialogs() { if (spl_dialog) @@ -1191,12 +1305,13 @@ // -------------------------------- menu --------------------------- // ----------------------------------------------------------------- - +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- int tSampleSet::OnMenuCommand(int id) { switch (id) { - case MEN_AUDIO_LOAD: + case ID_AUDIO_LOAD: { wxString fname = file_selector( mDefaultFileName, @@ -1211,7 +1326,7 @@ return 1; } - case MEN_AUDIO_SAVE_AS: + case ID_AUDIO_SAVE_AS: { wxString fname = file_selector( mDefaultFileName, @@ -1226,25 +1341,25 @@ return 1; } - case MEN_AUDIO_SAVE: + case ID_AUDIO_SAVE: { if (mDefaultFileName == "noname.spl") { - return OnMenuCommand(MEN_AUDIO_SAVE_AS); + return OnMenuCommand(ID_AUDIO_SAVE_AS); } Save(mDefaultFileName); return 1; } - case MEN_AUDIO_GLOBAL: + case ID_AUDIO_GLOBAL: GlobalSettingsDlg(); break; - case MEN_AUDIO_SAMPLES: + case ID_AUDIO_SAMPLES: SamplesDlg(); return 1; - case MEN_AUDIO_NEW: + case ID_AUDIO_NEW: if (spl_dialog == 0 && glb_dialog == 0) { if (wxMessageBox("Clear Sample Set?", "Confirm", wxYES_NO) == wxNO) @@ -1261,6 +1376,3 @@ } return 0; } - - - Modified: trunk/jazz/src/Player.h =================================================================== --- trunk/jazz/src/Player.h 2008-05-10 16:09:29 UTC (rev 497) +++ trunk/jazz/src/Player.h 2008-05-10 16:38:38 UTC (rev 498) @@ -39,15 +39,6 @@ class JZRecordingInfo; -// audio-menu -#define MEN_AUDIO_LOAD 200 -#define MEN_AUDIO_SAVE 201 -#define MEN_AUDIO_GLOBAL 202 -#define MEN_AUDIO_SAMPLES 203 -#define MEN_AUDIO_NEW 204 -#define MEN_AUDIO_SAVE_AS 205 - - class tPlayLoop { public: Modified: trunk/jazz/src/Resources.h =================================================================== --- trunk/jazz/src/Resources.h 2008-05-10 16:09:29 UTC (rev 497) +++ trunk/jazz/src/Resources.h 2008-05-10 16:38:38 UTC (rev 498) @@ -37,6 +37,13 @@ #define ID_SETTINGS_SYNTHESIZER wxID_HIGHEST + 11 #define ID_SETTINGS_MIDI_DEVICE wxID_HIGHEST + 12 +#define ID_AUDIO_GLOBAL wxID_HIGHEST + 20 +#define ID_AUDIO_SAMPLES wxID_HIGHEST + 21 +#define ID_AUDIO_LOAD wxID_HIGHEST + 22 +#define ID_AUDIO_SAVE wxID_HIGHEST + 23 +#define ID_AUDIO_SAVE_AS wxID_HIGHEST + 24 +#define ID_AUDIO_NEW wxID_HIGHEST + 25 + #define ID_TRIM wxID_HIGHEST + 30 #define ID_QUANTIZE wxID_HIGHEST + 31 #define ID_SHIFT_LEFT wxID_HIGHEST + 32 Modified: trunk/jazz/src/TrackFrame.cpp =================================================================== --- trunk/jazz/src/TrackFrame.cpp 2008-05-10 16:09:29 UTC (rev 497) +++ trunk/jazz/src/TrackFrame.cpp 2008-05-10 16:38:38 UTC (rev 498) @@ -378,17 +378,16 @@ pMenuBar->Append(pSettingMenu, "&Settings"); -#if 0 - audio_menu = new wxMenu; - audio_menu->Append(MEN_AUDIO_GLOBAL, "&Global Settings..."); - audio_menu->Append(MEN_AUDIO_SAMPLES, "Sample Se&ttings... "); - audio_menu->Append(MEN_AUDIO_LOAD, "&Load Set..."); - audio_menu->Append(MEN_AUDIO_SAVE, "&Save Set"); - audio_menu->Append(MEN_AUDIO_SAVE_AS, "Save Set &As"); - audio_menu->Append(MEN_AUDIO_NEW, "&New Set"); - pMenuBar->Append(audio_menu, "&Audio"); -#endif + wxMenu* pAudioMenu = new wxMenu; + pAudioMenu->Append(ID_AUDIO_GLOBAL, "&Global Settings..."); + pAudioMenu->Append(ID_AUDIO_SAMPLES, "Sample Se&ttings... "); + pAudioMenu->Append(ID_AUDIO_LOAD, "&Load Set..."); + pAudioMenu->Append(ID_AUDIO_SAVE, "&Save Set"); + pAudioMenu->Append(ID_AUDIO_SAVE_AS, "Save Set &As"); + pAudioMenu->Append(ID_AUDIO_NEW, "&New Set"); + pMenuBar->Append(pAudioMenu, "&Audio"); + pMenuBar->Append(mpHelpMenu , "&Help"); SetMenuBar(pMenuBar); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-14 01:52:53
|
Revision: 521 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=521&view=rev Author: pstieber Date: 2008-05-13 18:52:51 -0700 (Tue, 13 May 2008) Log Message: ----------- 1. Added some debug output. 2. Changed tAlsaDriverList::print to tAlsaDriverList::AsciiWrite and changed the argument from const char* to sconst std::string&. 3. Cleaned up the tDeviceList code now that it is using an STL container. Modified Paths: -------------- trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/AlsaPlayer.h trunk/jazz/src/Player.cpp trunk/jazz/src/Player.h Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-05-13 23:25:49 UTC (rev 520) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-05-14 01:52:51 UTC (rev 521) @@ -99,6 +99,12 @@ // scan input addressess scan_clients(iaddr, SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ); + cout << "Input device count: " << iaddr.GetCount() << endl; + if (iaddr.GetCount()) + { + iaddr.AsciiWrite("Input Devices"); + } + // scan output addresses scan_clients(oaddr, SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE); @@ -212,7 +218,7 @@ //----------------------------------------------------------------------------- void tAlsaPlayer::subscribe_inp(int inp) { - snd_seq_port_subscribe_t *subs; + snd_seq_port_subscribe_t* subs; snd_seq_port_subscribe_alloca(&subs); snd_seq_port_subscribe_set_time_update(subs, 1); snd_seq_port_subscribe_set_queue(subs, queue); @@ -970,9 +976,9 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -void tAlsaDeviceList::print(const char *msg) +void tAlsaDeviceList::AsciiWrite(const string& Message) { - cout << msg << endl; + cout << Message << endl; int i = 0; for ( vector<snd_seq_addr_t>::const_iterator iSound = addr.begin(); Modified: trunk/jazz/src/AlsaPlayer.h =================================================================== --- trunk/jazz/src/AlsaPlayer.h 2008-05-13 23:25:49 UTC (rev 520) +++ trunk/jazz/src/AlsaPlayer.h 2008-05-14 01:52:51 UTC (rev 521) @@ -28,12 +28,14 @@ #include <alsa/asoundlib.h> +#include <string> + class tAlsaDeviceList : public tDeviceList { public: unsigned add(const char* pName, const snd_seq_addr_t& a); snd_seq_addr_t& operator[](unsigned i); - void print(const char *msg); + void AsciiWrite(const std::string& Message); private: std::vector<snd_seq_addr_t> addr; }; Modified: trunk/jazz/src/Player.cpp =================================================================== --- trunk/jazz/src/Player.cpp 2008-05-13 23:25:49 UTC (rev 520) +++ trunk/jazz/src/Player.cpp 2008-05-14 01:52:51 UTC (rev 521) @@ -77,40 +77,12 @@ tDeviceList::tDeviceList() : mDeviceNames() { -// count = 0; -// for (int i = 0; i < eMaximumDeviceCount; i++) -// names[i] = 0; } -tDeviceList::tDeviceList(const char* pName) -{ - mDeviceNames.push_back(pName); -// count = 1; -// for (int i = 0; i < eMaximumDeviceCount; i++) -// names[i] = 0; -// names[0] = copystring(name); -} - tDeviceList::~tDeviceList() { -// for (int i = 0; i < count; i++) -// delete [] names[i]; } -//tNamedValue *tDeviceList::AsNamedValue() -//{ -// tNamedValue *nv = new tNamedValue[count + 1]; -// for (int i = 0; i < count; i++) -// { -// nv[i].Name = copystring(names[i]); -// nv[i].Value = i; -// } -// nv[count].Name = 0; -// nv[count].Value = 0; -// return nv; -//} - - // ------------------------- tPlayLoop -------------------------- tPlayLoop::tPlayLoop() Modified: trunk/jazz/src/Player.h =================================================================== --- trunk/jazz/src/Player.h 2008-05-13 23:25:49 UTC (rev 520) +++ trunk/jazz/src/Player.h 2008-05-14 01:52:51 UTC (rev 521) @@ -83,15 +83,8 @@ { public: - enum - { - eMaximumDeviceCount = 10 - }; - tDeviceList(); - tDeviceList(const char* pName); - virtual ~tDeviceList(); unsigned GetCount() const @@ -113,26 +106,15 @@ { mDeviceNames.push_back(pName); return mDeviceNames.size(); -// if (count < eMaximumDeviceCount) -// { -// names[count] = copystring(name); -// return count++; -// } -// return eMaximumDeviceCount; } void Clear() { mDeviceNames.clear(); -// count = 0; } -// tNamedValue* AsNamedValue(); - protected: -// int count; -// char *names[eMaximumDeviceCount]; std::vector<std::string> mDeviceNames; private: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pst...@us...> - 2008-05-14 04:35:12
|
Revision: 522 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=522&view=rev Author: pstieber Date: 2008-05-13 21:35:10 -0700 (Tue, 13 May 2008) Log Message: ----------- Added checks for valid device indices. Modified Paths: -------------- trunk/jazz/src/AlsaPlayer.cpp trunk/jazz/src/AlsaPlayer.h Modified: trunk/jazz/src/AlsaPlayer.cpp =================================================================== --- trunk/jazz/src/AlsaPlayer.cpp 2008-05-14 01:52:51 UTC (rev 521) +++ trunk/jazz/src/AlsaPlayer.cpp 2008-05-14 04:35:10 UTC (rev 522) @@ -108,30 +108,67 @@ // scan output addresses scan_clients(oaddr, SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE); - inp_dev = gpConfig->GetValue(C_AlsaInputDevice); - if (inp_dev < 0) + mInputDeviceIndex = gpConfig->GetValue(C_AlsaInputDevice); + if (mInputDeviceIndex < 0) { - cout << "invalid input device, so selecting one" << endl; - inp_dev = select_list(iaddr, "Input Device", inp_dev); - cout << "Input device is: " << inp_dev << endl; - gpConfig->Put(C_AlsaInputDevice, inp_dev); + cout << "INFO: input device is -1, so selecting one." << endl; + mInputDeviceIndex = select_list( + iaddr, + "Input Device", + mInputDeviceIndex); + cout << "Input device is: " << mInputDeviceIndex << endl; + gpConfig->Put(C_AlsaInputDevice, mInputDeviceIndex); } - outp_dev = gpConfig->GetValue(C_AlsaOutputDevice); - if (outp_dev < 0) + else if (static_cast<unsigned>(mInputDeviceIndex) > iaddr.GetCount()) { - cout << "invalid output device, so selecting one" << endl; - outp_dev = select_list(oaddr, "Output Device", outp_dev); + cout << "INFO: output device is out of range, so selecting one." << endl; + mInputDeviceIndex = select_list( + iaddr, + "Output Device", + mInputDeviceIndex); } - if (inp_dev >= 0) + mOutputDeviceIndex = gpConfig->GetValue(C_AlsaOutputDevice); + if (mOutputDeviceIndex < 0) { - subscribe_inp(inp_dev); + cout << "INFO: output device is -1, so selecting one." << endl; + mOutputDeviceIndex = select_list( + oaddr, + "Output Device", + mOutputDeviceIndex); } - if (outp_dev >= 0) + else if (static_cast<unsigned>(mOutputDeviceIndex) > oaddr.GetCount()) { - subscribe_out(outp_dev); + cout << "INFO: output device is out of range, so selecting one." << endl; + mOutputDeviceIndex = select_list( + oaddr, + "Output Device", + mOutputDeviceIndex); } + if (mInputDeviceIndex >= 0) + { + if (static_cast<unsigned>(mInputDeviceIndex) < iaddr.GetCount()) + { + subscribe_inp(mInputDeviceIndex); + } + else + { + cout << "WARNING: The input device index is out of range!" << endl; + } + } + if (mOutputDeviceIndex >= 0) + { + if (static_cast<unsigned>(mOutputDeviceIndex) < iaddr.GetCount()) + { + subscribe_out(mOutputDeviceIndex); + } + else + { + cout << "WARNING: The output device index is out of range!" << endl; + } + } + set_pool_sizes(); snd_seq_set_output_buffer_size(handle, 65536); @@ -909,26 +946,32 @@ //----------------------------------------------------------------------------- int tAlsaPlayer::FindMidiDevice() { - if (inp_dev != -1) + if (mInputDeviceIndex != -1) { - unsubscribe_inp(inp_dev); + unsubscribe_inp(mInputDeviceIndex); } - inp_dev = select_list(iaddr, "Input MIDI device", inp_dev); - gpConfig->Put(C_AlsaInputDevice, inp_dev); - if (inp_dev != -1) + mInputDeviceIndex = select_list( + iaddr, + "Input MIDI device", + mInputDeviceIndex); + gpConfig->Put(C_AlsaInputDevice, mInputDeviceIndex); + if (mInputDeviceIndex != -1) { - subscribe_inp(inp_dev); + subscribe_inp(mInputDeviceIndex); } - if (outp_dev != -1) + if (mOutputDeviceIndex != -1) { - unsubscribe_out(outp_dev); + unsubscribe_out(mOutputDeviceIndex); } - outp_dev = select_list(oaddr, "Output MIDI device", outp_dev); - gpConfig->Put(C_AlsaOutputDevice, outp_dev); - if (outp_dev != -1) + mOutputDeviceIndex = select_list( + oaddr, + "Output MIDI device", + mOutputDeviceIndex); + gpConfig->Put(C_AlsaOutputDevice, mOutputDeviceIndex); + if (mOutputDeviceIndex != -1) { - subscribe_out(outp_dev); + subscribe_out(mOutputDeviceIndex); } return 0; } Modified: trunk/jazz/src/AlsaPlayer.h =================================================================== --- trunk/jazz/src/AlsaPlayer.h 2008-05-14 01:52:51 UTC (rev 521) +++ trunk/jazz/src/AlsaPlayer.h 2008-05-14 04:35:10 UTC (rev 522) @@ -75,7 +75,7 @@ int client; // me snd_seq_addr_t self; // my address int queue; // queue - int inp_dev, outp_dev; // input/output device index + int mInputDeviceIndex, mOutputDeviceIndex; int sync_in, sync_in_dev, sync_in_mtcType; int sync_out, sync_out_dev, sync_out_mtcType; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |