From: <pst...@us...> - 2013-03-17 23:13:46
|
Revision: 967 http://sourceforge.net/p/jazzplusplus/code/967 Author: pstieber Date: 2013-03-17 23:13:43 +0000 (Sun, 17 Mar 2013) Log Message: ----------- Started updating and implementing the rhythm generator. Modified Paths: -------------- trunk/jazz/src/Globals.cpp trunk/jazz/src/Globals.h trunk/jazz/src/Rhythm.cpp trunk/jazz/src/Rhythm.h Modified: trunk/jazz/src/Globals.cpp =================================================================== --- trunk/jazz/src/Globals.cpp 2013-03-17 23:12:01 UTC (rev 966) +++ trunk/jazz/src/Globals.cpp 2013-03-17 23:13:43 UTC (rev 967) @@ -65,6 +65,8 @@ JZHarmonyBrowserInterface* gpHarmonyBrowser = 0; +JZRhythmGeneratorFrame* gpRhythmGeneratorFrame = 0; + const double gDegreesToRadians = 0.01745329251994330212; const double gRadiansToDegrees = 57.2957795130823; @@ -105,4 +107,3 @@ return TokenIndex; } - Modified: trunk/jazz/src/Globals.h =================================================================== --- trunk/jazz/src/Globals.h 2013-03-17 23:12:01 UTC (rev 966) +++ trunk/jazz/src/Globals.h 2013-03-17 23:13:43 UTC (rev 967) @@ -35,6 +35,7 @@ class JZPlayer; class JZHelp; class JZProject; +class JZRhythmGeneratorFrame; class JZTrackFrame; class JZTrackWindow; class JZHarmonyBrowserInterface; @@ -62,6 +63,7 @@ extern JZTrackFrame* gpTrackFrame; extern JZTrackWindow* gpTrackWindow; extern JZHarmonyBrowserInterface* gpHarmonyBrowser; +extern JZRhythmGeneratorFrame* gpRhythmGeneratorFrame; extern const double gDegreesToRadians; extern const double gRadiansToDegrees; Modified: trunk/jazz/src/Rhythm.cpp =================================================================== --- trunk/jazz/src/Rhythm.cpp 2013-03-17 23:12:01 UTC (rev 966) +++ trunk/jazz/src/Rhythm.cpp 2013-03-17 23:13:43 UTC (rev 967) @@ -41,6 +41,7 @@ #include <wx/checkbox.h> #include <wx/choicdlg.h> #include <wx/listbox.h> +#include <wx/menu.h> #include <wx/msgdlg.h> #include <wx/slider.h> #include <wx/toolbar.h> @@ -50,8 +51,6 @@ using namespace std; -JZRhythmWindow* rhythm_win = 0; - void tRhyGroup::write(ostream& Os) const { Os << listen << " "; @@ -1236,7 +1235,6 @@ delete instruments[i]; } delete mpToolBar; - rhythm_win = 0; } bool JZRhythmWindow::OnClose() @@ -1298,3 +1296,106 @@ return Is; } +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZRhythmGeneratorWindow::JZRhythmGeneratorWindow( + wxFrame* pParent, + const wxPoint& Position, + const wxSize& Size) + : wxWindow(pParent, wxID_ANY, Position, Size), + mRhythm(0), + mpLengthEdit(0), + mpVelocityEdit(0), + mpRhythmEdit(0) +{ + int x = 0; + int y = 0; + int Width, Height; + GetClientSize(&Width, &Height); + + mpLengthEdit = new JZArrayEdit( + pParent, + mRhythm.length, + x, + y + Height / 2, + Width / 2, + Height / 4 - 4); + mpLengthEdit->SetXMinMax(1, 8); + mpLengthEdit->SetLabel("length/interval"); + + mpVelocityEdit = new JZArrayEdit( + pParent, + mRhythm.veloc, + x + Width / 2, + y + Height / 2, + Width / 2, + Height / 4 - 4); + mpVelocityEdit->SetXMinMax(1, 127); + mpVelocityEdit->SetLabel("velocity"); + + mpRhythmEdit = new JZRhyArrayEdit( + pParent, + mRhythm.rhythm, + x, + y + 3 * Height / 4, + Width, + Height/ 4 - 4); + mpRhythmEdit->SetMeter( + mRhythm.steps_per_count, + mRhythm.count_per_bar, + mRhythm.n_bars); + mpRhythmEdit->SetLabel("rhythm"); +} + +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZRhythmGeneratorFrame::JZRhythmGeneratorFrame() + : wxFrame( + 0, + wxID_ANY, + "Rhythm Generator", + wxPoint( + gpConfig->GetValue(C_RhythmXpos), + gpConfig->GetValue(C_RhythmYpos)), + wxSize(640, 580)), + mpRhythmGeneratorWindow(0) +{ + wxMenu* pFileMenu = new wxMenu; + pFileMenu->Append(wxID_OPEN, "&Load..."); + pFileMenu->Append(wxID_SAVEAS, "Save &As..."); + pFileMenu->Append(wxID_CLOSE, "&Close"); + + wxMenuBar* pMenuBar = new wxMenuBar; + pMenuBar->Append(pFileMenu, "&File"); + + SetMenuBar(pMenuBar); + + int Width, Height; + GetClientSize(&Width, &Height); + mpRhythmGeneratorWindow = + new JZRhythmGeneratorWindow(this, wxPoint(0, 0), wxSize(Width, Height)); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZRhythmGeneratorFrame::~JZRhythmGeneratorFrame() +{ + delete mpRhythmGeneratorWindow; + + gpRhythmGeneratorFrame = 0; +} + +//***************************************************************************** +//***************************************************************************** +void CreateRhythmGenerator() +{ + if (!gpRhythmGeneratorFrame) + { + gpRhythmGeneratorFrame = new JZRhythmGeneratorFrame(); + } + ((JZRhythmGeneratorFrame*)gpRhythmGeneratorFrame)->Show(true); +} Modified: trunk/jazz/src/Rhythm.h =================================================================== --- trunk/jazz/src/Rhythm.h 2013-03-17 23:12:01 UTC (rev 966) +++ trunk/jazz/src/Rhythm.h 2013-03-17 23:13:43 UTC (rev 967) @@ -22,6 +22,7 @@ #pragma once +#include "Globals.h" #include "Random.h" #include "ToolBar.h" @@ -30,10 +31,10 @@ #include <iostream> -class JZTrack; +class JZBarInfo; class JZEventWindow; class JZSong; -class JZBarInfo; +class JZTrack; class wxButton; class wxCheckBox; class wxListBox; @@ -75,6 +76,7 @@ class JZRhythm { friend class JZRhythmWindow; + friend class JZRhythmGeneratorWindow; private: @@ -176,20 +178,20 @@ friend std::ostream& operator << (std::ostream& os, JZRhythmWindow const& a); friend std::istream& operator >> (std::istream& Is, JZRhythmWindow& a); - wxPanel *inst_panel; + wxPanel* inst_panel; #ifdef OBSOLETE wxText *label; #endif - wxSlider *steps_per_count; - wxSlider *count_per_bar; - wxSlider *n_bars; - wxListBox *instrument_list; - wxCheckBox *rand_checkbox; + wxSlider* steps_per_count; + wxSlider* count_per_bar; + wxSlider* n_bars; + wxListBox* instrument_list; + wxCheckBox* rand_checkbox; - wxPanel *group_panel; - wxListBox *group_list; - wxSlider *group_contrib; - wxSlider *group_listen; + wxPanel* group_panel; + wxListBox* group_list; + wxSlider* group_contrib; + wxSlider* group_listen; int act_group; JZArrayEdit *length_edit; @@ -240,7 +242,41 @@ void UpInstrument(); void DownInstrument(); void InitInstrumentList(); +}; +//***************************************************************************** +//***************************************************************************** +class JZRhythmGeneratorWindow : public wxWindow +{ + public: + + JZRhythmGeneratorWindow( + wxFrame* pParent, + const wxPoint& Position, + const wxSize& Size); + + private: + + JZRhythm mRhythm; + + JZArrayEdit* mpLengthEdit; + JZArrayEdit* mpVelocityEdit; + JZRhyArrayEdit* mpRhythmEdit; }; -extern JZRhythmWindow *rhythm_win; +//***************************************************************************** +//***************************************************************************** +class JZRhythmGeneratorFrame : public wxFrame +{ + public: + + JZRhythmGeneratorFrame(); + + ~JZRhythmGeneratorFrame(); + + private: + + JZRhythmGeneratorWindow* mpRhythmGeneratorWindow; +}; + +extern void CreateRhythmGenerator(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |