|
From: <pst...@us...> - 2013-04-07 08:08:44
|
Revision: 1007
http://sourceforge.net/p/jazzplusplus/code/1007
Author: pstieber
Date: 2013-04-07 08:08:41 +0000 (Sun, 07 Apr 2013)
Log Message:
-----------
1. Added code to the array control class.
2. Changed Min and Max in the JZRndArray class to GetMin and GetMax.
Modified Paths:
--------------
trunk/jazz/src/ArrayControl.cpp
trunk/jazz/src/ArrayControl.h
trunk/jazz/src/ControlEdit.cpp
trunk/jazz/src/Random.cpp
trunk/jazz/src/Random.h
trunk/jazz/src/Rhythm.cpp
trunk/jazz/src/Rhythm.h
trunk/jazz/src/SampleCommand.cpp
trunk/jazz/src/SampleFrame.h
trunk/jazz/src/Signal2.cpp
trunk/jazz/src/SliderWindow.cpp
Modified: trunk/jazz/src/ArrayControl.cpp
===================================================================
--- trunk/jazz/src/ArrayControl.cpp 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/ArrayControl.cpp 2013-04-07 08:08:41 UTC (rev 1007)
@@ -20,11 +20,27 @@
#include "ArrayControl.h"
+#include "Mapper.h"
#include "Random.h"
#include <wx/dcclient.h>
+#include <sstream>
+
+using namespace std;
+
+#define TICK_LINE 0
+
//*****************************************************************************
+//*****************************************************************************
+static string GetText(int YValue)
+{
+ ostringstream Oss;
+ Oss << YValue;
+ return Oss.str();
+}
+
+//*****************************************************************************
// Description:
// This is the array control class definition.
//*****************************************************************************
@@ -47,7 +63,17 @@
const wxValidator& Validator,
const wxString& Name)
: wxControl(),
- mpRandomArray(0)
+ mpRandomArray(0),
+ mStyleBits(ARED_GAP | ARED_XTICKS),
+ mEnabled(true),
+ mLabel(),
+ mX(0),
+ mY(0),
+ mYNull(0),
+ mWidth(0),
+ mHeight(0),
+ mXMin(0),
+ mXMax(RandomArray.Size())
{
mpRandomArray = new JZRndArray(RandomArray);
@@ -97,34 +123,353 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+void JZArrayControl::SetLabel(const string& Label)
+{
+ mLabel = Label;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZArrayControl::SetXMinMax(int XMin, int XMax)
+{
+ mXMin = XMin;
+ mXMax = XMax;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZArrayControl::SetMeter(int StepsPerCount, int CountPerBar, int BarCount)
+{
+// mStepsPerCount = StepsPerCount;
+// mCountPerBar = CountPerBar;
+// mpRandomArray->Resize(StepsPerCount * CountPerBar * BarCount);
+// SetXMinMax(1, StepsPerCount * CountPerBar * BarCount);
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZArrayControl::OnSize(wxSizeEvent& SizeEvent)
{
- int Width = SizeEvent.GetSize().GetWidth();
- int Height = SizeEvent.GetSize().GetHeight();
+ mWidth = SizeEvent.GetSize().GetWidth();
+ mHeight = SizeEvent.GetSize().GetHeight();
SizeEvent.Skip();
wxClientDC Dc(this);
+ Dc.SetFont(*wxSMALL_FONT);
+
int TextWidth, TextHeight;
Dc.GetTextExtent("123", &TextWidth, &TextHeight);
-#if 0
if (mStyleBits & ARED_XTICKS)
{
- Height -= TextHeight;
+ // Leave space for the bottom line.
+ mHeight -= TextHeight;
}
+
if (mStyleBits & (ARED_MINMAX | ARED_YTICKS))
{
- x = (int)(TextWidth + TICK_LINE);
- Width -= (int)(TextWidth + TICK_LINE);
+ // Leave space to display the minimum and maximum
+ mX = TextWidth + TICK_LINE;
+ mWidth -= TextWidth + TICK_LINE;
}
- ynul = y + height - Height * (nul - min) / (max - min);
-#endif
+
+ mYNull =
+ mY + mHeight -
+ mHeight * (mpRandomArray->GetNull() - mpRandomArray->GetMin()) /
+ (mpRandomArray->GetMax() - mpRandomArray->GetMin());
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void JZArrayControl::OnPaint(wxPaintEvent& Event)
{
+ wxPaintDC Dc(this);
+
+ int i;
+
+ // surrounding rectangle
+ Dc.Clear();
+ if (mEnabled)
+ {
+ Dc.SetBrush(*wxWHITE_BRUSH);
+ }
+ else
+ {
+ Dc.SetBrush(*wxGREY_BRUSH);
+ }
+
+ Dc.SetPen(*wxBLACK_PEN);
+ if (mWidth && mHeight)
+ {
+ Dc.DrawRectangle(0, 0, mWidth, mHeight);
+ }
+
+ // sliders
+ Dc.SetBrush(*wxBLACK_BRUSH);
+ for (i = 0; i < mpRandomArray->Size(); ++i)
+ {
+ DrawBar(Dc, i, true);
+ }
+
+ DrawXTicks(Dc);
+ DrawLabel(Dc);
+ DrawYTicks(Dc);
+ DrawNull(Dc);
+
+// if (mpDrawBars)
+ {
+// mpDrawBars->DrawBars(Dc);
+ }
}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZArrayControl::DrawBar(wxDC& Dc, int i, bool black)
+{
+ if (mStyleBits & ARED_LINES)
+ {
+ if (!black)
+ {
+ Dc.SetPen(*wxWHITE_PEN);
+ }
+
+ JZMapper XMap(0, mpRandomArray->Size(), 0, mWidth);
+ JZMapper
+ YMap(mpRandomArray->GetMin(), mpRandomArray->GetMax(), mHeight, 0);
+
+ int x1 = (int)XMap.XToY(i + 0.5);
+ int y1 = (int)YMap.XToY((*mpRandomArray)[i]);
+ if (i > 0)
+ {
+ // draw line to prev position
+ int x0 = (int)XMap.XToY(i - 0.5);
+ int y0 = (int)YMap.XToY((*mpRandomArray)[i - 1]);
+ Dc.DrawLine(x0, y0, x1, y1);
+ }
+ if (i < mpRandomArray->Size() - 1)
+ {
+ // draw line to next position
+ int x2 = (int)XMap.XToY(i + 1.5);
+ int y2 = (int)YMap.XToY((*mpRandomArray)[i + 1]);
+ Dc.DrawLine(x1, y1, x2, y2);
+ }
+
+ if (!black)
+ {
+ Dc.SetPen(*wxBLACK_PEN);
+ }
+ return;
+ }
+
+ int Gap = 0;
+ if (mStyleBits & ARED_GAP)
+ {
+ Gap = mWidth / mpRandomArray->Size() / 6;
+ if (!Gap && mWidth / mpRandomArray->Size() > 3)
+ {
+ Gap = 1;
+ }
+ }
+
+ int wbar = mWidth / mpRandomArray->Size() - 2 * Gap;
+ int xbar = mX + i * mWidth / mpRandomArray->Size() + Gap;
+ int hbar = mHeight * ((*mpRandomArray)[i] - mpRandomArray->GetNull()) /
+ (mpRandomArray->GetMax() - mpRandomArray->GetMin());
+ int ybar;
+
+ if (mStyleBits & ARED_BLOCKS)
+ {
+ /*
+ ybar = mYNull - hbar;
+ if (hbar < 0)
+ hbar = -hbar;
+ hbar = (hbar < 2) ? hbar : 2;
+ */
+ int hblk = 12;
+
+ ybar = mYNull - hbar - hblk/2;
+ hbar = hblk;
+ if (ybar < mY)
+ {
+ int d = mY - ybar;
+ ybar += d;
+ hbar -= d;
+ }
+ if (ybar + hbar > mHeight)
+ {
+ int d = (ybar + hbar) - mHeight;
+ hbar -= d;
+ }
+ if (hbar < 2)
+ hbar = 2;
+ }
+ else
+
+ if (hbar < 0)
+ {
+ ybar = mYNull;
+ hbar = -hbar;
+ }
+ else
+ ybar = mYNull - hbar;
+
+ if (ybar == mY)
+ {
+ ++ybar, --hbar;
+ }
+
+ if (!black)
+ {
+ Dc.SetBrush(*wxWHITE_BRUSH);
+ Dc.SetPen(*wxWHITE_PEN);
+ }
+ if (wbar && hbar)
+ {
+ Dc.DrawRectangle(xbar, ybar, wbar, hbar);
+ }
+ if (!black)
+ {
+ Dc.SetBrush(*wxBLACK_BRUSH);
+ Dc.SetPen(*wxBLACK_PEN);
+ }
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZArrayControl::DrawLabel(wxDC& Dc)
+{
+ Dc.SetFont(*wxSMALL_FONT);
+ if (!mLabel.empty())
+ {
+ Dc.DrawText(mLabel, 5, 2);
+ }
+ Dc.SetFont(*wxNORMAL_FONT);
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZArrayControl::DrawXTicks(wxDC& Dc)
+{
+ if (!(mStyleBits & ARED_XTICKS))
+ {
+ return;
+ }
+
+ Dc.SetFont(*wxSMALL_FONT);
+
+ // Compute tickmark x-distance.
+ int TextWidth, TextHeight;
+ Dc.GetTextExtent("-123", &TextWidth, &TextHeight);
+ int MaxLabels = (int)(mWidth / (TextWidth + TextWidth / 2));
+ if (MaxLabels > 0)
+ {
+ int Step = (mXMax - mXMin + 1) / MaxLabels;
+ if (Step <= 0)
+ {
+ Step = 1;
+ }
+ for (int Value = mXMin; Value <= mXMax; Value += Step)
+ {
+ string String = GetText(Value);
+ Dc.GetTextExtent(String, &TextWidth, &TextHeight);
+ int YPosition = mY + mHeight;
+ float XPosition = mX + mWidth * (Value - mXMin) / (mXMax - mXMin + 1);
+
+ // Center text.
+ XPosition -= TextWidth / 2.0f;
+
+ // Middle of bar.
+ XPosition += 0.5f * mWidth / mpRandomArray->Size();
+
+ Dc.DrawText(String, (int)XPosition, YPosition);
+ }
+ }
+
+ Dc.SetFont(*wxNORMAL_FONT);
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZArrayControl::DrawYTicks(wxDC& Dc)
+{
+ Dc.SetFont(*wxSMALL_FONT);
+
+ if (mStyleBits & ARED_YTICKS)
+ {
+ // Compute tickmark y-distance.
+ int TextWidth, TextHeight;
+ Dc.GetTextExtent("-123", &TextWidth, &TextHeight);
+ int MaxLabels = (int)(mHeight / (TextHeight + TextHeight / 2));
+ if (MaxLabels > 0)
+ {
+ int Step =
+ (mpRandomArray->GetMax() - mpRandomArray->GetMin()) / MaxLabels;
+ if (Step <= 0)
+ {
+ Step = 1;
+ }
+ for (
+ int Value = mpRandomArray->GetMin();
+ Value < mpRandomArray->GetMax();
+ Value += Step)
+ {
+ string String = GetText(Value);
+ Dc.GetTextExtent(String, &TextWidth, &TextHeight);
+ int YPosition =
+ mY + mHeight -
+ mHeight * (Value - mpRandomArray->GetMin()) /
+ (mpRandomArray->GetMax() - mpRandomArray->GetMin()) -
+ TextHeight / 2;
+ Dc.DrawText(String, mX - TextWidth - TICK_LINE, YPosition);
+ }
+ }
+ }
+ else if (mStyleBits & ARED_MINMAX)
+ {
+ // mMin/mMax
+ int TextWidth, TextHeight;
+ ostringstream Oss;
+
+ Oss << mpRandomArray->GetMax();
+ Dc.GetTextExtent(Oss.str(), &TextWidth, &TextHeight);
+ Dc.DrawText(Oss.str(), mX - TextWidth, mY);
+
+ Oss.str("");
+
+ Oss << mpRandomArray->GetMin();
+ Dc.GetTextExtent(Oss.str(), &TextWidth, &TextHeight);
+ Dc.DrawText(Oss.str(), mX - TextWidth, mY + mHeight - TextHeight);
+ }
+
+ Dc.SetFont(*wxNORMAL_FONT);
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZArrayControl::DrawNull(wxDC& Dc)
+{
+ Dc.SetPen(*wxCYAN_PEN);
+
+ // Draw y-null line.
+ if (
+ mpRandomArray->GetMin() < mpRandomArray->GetNull() &&
+ mpRandomArray->GetNull() < mpRandomArray->GetMax())
+ {
+ Dc.DrawLine(
+ mX,
+ mpRandomArray->GetNull(),
+ mX + mWidth,
+ mpRandomArray->GetNull());
+ }
+
+ // Draw x-null line.
+ if (mXMin < 0 && 0 < mXMax)
+ {
+ int x0 = mWidth * (0 - mXMin) / (mXMax - mXMin);
+ Dc.DrawLine(x0, mY, x0, mY + mHeight);
+ }
+
+ Dc.SetPen(*wxBLACK_PEN);
+}
Modified: trunk/jazz/src/ArrayControl.h
===================================================================
--- trunk/jazz/src/ArrayControl.h 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/ArrayControl.h 2013-04-07 08:08:41 UTC (rev 1007)
@@ -22,6 +22,8 @@
#include <wx/control.h>
+#include <string>
+
class JZRndArray;
//*****************************************************************************
@@ -52,15 +54,43 @@
const wxValidator& Validator = wxDefaultValidator,
const wxString& Name = wxT("arraycontrol"));
+ void SetLabel(const std::string& Label);
+
+ void SetXMinMax(int XMin, int XMax);
+
+ void SetMeter(int StepsPerCount, int CountPerBar, int BarCount);
+
private:
void OnSize(wxSizeEvent& Event);
void OnPaint(wxPaintEvent& Event);
+ void DrawBar(wxDC& Dc, int i, bool black);
+
+ void DrawLabel(wxDC& Dc);
+
+ void DrawXTicks(wxDC& Dc);
+
+ void DrawYTicks(wxDC& Dc);
+
+ void DrawNull(wxDC& Dc);
+
private:
JZRndArray* mpRandomArray;
+ long mStyleBits;
+
+ bool mEnabled;
+
+ std::string mLabel;
+
+ int mX, mY, mYNull;
+ int mWidth, mHeight;
+
+ // Array size is mapped to this range for x-tick marks.
+ int mXMin, mXMax;
+
DECLARE_EVENT_TABLE()
};
Modified: trunk/jazz/src/ControlEdit.cpp
===================================================================
--- trunk/jazz/src/ControlEdit.cpp 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/ControlEdit.cpp 2013-04-07 08:08:41 UTC (rev 1007)
@@ -101,7 +101,7 @@
// ctrlmode is used to distinguish between Apply and Edit.
edit = new JZArrayEdit(
- (wxFrame *)mpPianoWindow,
+ mpPianoWindow,
array,
wxPoint(x + dx, y),
wxSize(w - dx, h),
Modified: trunk/jazz/src/Random.cpp
===================================================================
--- trunk/jazz/src/Random.cpp 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/Random.cpp 2013-04-07 08:08:41 UTC (rev 1007)
@@ -227,7 +227,7 @@
void JZRndArray::SetDifference(JZRndArray& Other, int fuzz)
{
JZRndArray tmp(Other);
- tmp.SetInverse(tmp.Max());
+ tmp.SetInverse(tmp.GetMax());
SetIntersection(tmp, fuzz);
}
@@ -299,7 +299,7 @@
//*****************************************************************************
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-BEGIN_EVENT_TABLE(JZArrayEdit, wxScrolledWindow)
+BEGIN_EVENT_TABLE(JZArrayEdit, wxWindow)
EVT_SIZE(JZArrayEdit::OnSize)
EVT_MOUSE_EVENTS(JZArrayEdit::OnMouseEvent)
END_EVENT_TABLE()
@@ -307,12 +307,12 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
JZArrayEdit::JZArrayEdit(
- wxFrame* pFrame,
+ wxWindow* pParent,
JZRndArray& Array,
const wxPoint& Position,
const wxSize& Size,
int StyleBits)
- : wxScrolledWindow(pFrame, wxID_ANY, Position, Size),
+ : wxWindow(pParent, wxID_ANY, Position, Size),
mArray(Array),
mMin(Array.mMin),
mMax(Array.mMax),
@@ -861,7 +861,7 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
JZRhyArrayEdit::JZRhyArrayEdit(
- wxFrame* pParent,
+ wxWindow* pParent,
JZRndArray& Array,
const wxPoint& Position,
const wxSize& Size,
Modified: trunk/jazz/src/Random.h
===================================================================
--- trunk/jazz/src/Random.h 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/Random.h 2013-04-07 08:08:41 UTC (rev 1007)
@@ -22,7 +22,7 @@
#pragma once
-#include <wx/scrolwin.h>
+#include <wx/window.h>
#include <iostream>
#include <vector>
@@ -82,11 +82,11 @@
{
return mArray.size();
}
- int Min() const
+ int GetMin() const
{
return mMin;
}
- int Max() const
+ int GetMax() const
{
return mMax;
}
@@ -148,12 +148,12 @@
//*****************************************************************************
//*****************************************************************************
-class JZArrayEdit : public wxScrolledWindow
+class JZArrayEdit : public wxWindow
{
public:
JZArrayEdit(
- wxFrame* pParent,
+ wxWindow* pParent,
JZRndArray& Array,
const wxPoint& Position,
const wxSize& Size,
@@ -243,7 +243,7 @@
public:
JZRhyArrayEdit(
- wxFrame* pParent,
+ wxWindow* pParent,
JZRndArray& Array,
const wxPoint& Position,
const wxSize& Size,
Modified: trunk/jazz/src/Rhythm.cpp
===================================================================
--- trunk/jazz/src/Rhythm.cpp 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/Rhythm.cpp 2013-04-07 08:08:41 UTC (rev 1007)
@@ -22,6 +22,7 @@
#include "Rhythm.h"
+#include "ArrayControl.h"
#include "Command.h"
#include "EventWindow.h"
#include "FileSelector.h"
@@ -44,6 +45,7 @@
#include <wx/listbox.h>
#include <wx/menu.h>
#include <wx/msgdlg.h>
+#include <wx/sizer.h>
#include <wx/slider.h>
#include <wx/stattext.h>
#include <wx/toolbar.h>
@@ -302,14 +304,14 @@
// Initialize history with random values.
for (i = 0; i < Size; ++i)
{
- mHistoryArray[i] = mHistoryArray.Min();
+ mHistoryArray[i] = mHistoryArray.GetMin();
}
for (i = 0; i < Size; i++)
{
if (mRhythmArray.Random(i))
{
- mHistoryArray[i] = mHistoryArray.Max();
+ mHistoryArray[i] = mHistoryArray.GetMax();
i += mLengthArray.Random();
}
}
@@ -519,7 +521,7 @@
if ((!mRandomizeFlag && rrg[i] > 0) || rrg.Random(i))
{
// put event here
- mHistoryArray[i] = mRhythmArray.Max();
+ mHistoryArray[i] = mRhythmArray.GetMax();
short vel = 0;
if (mRandomizeFlag)
@@ -528,7 +530,7 @@
}
else
{
- vel = rrg[i] * 126 / rrg.Max() + 1;
+ vel = rrg[i] * 126 / rrg.GetMax() + 1;
}
short len = (mLengthArray.Random() + 1) * clocks_per_step;
GenerateEvent(pTrack, clock, vel, len - clocks_per_step/2);
@@ -556,7 +558,6 @@
gpConfig->GetValue(C_RhythmXpos),
gpConfig->GetValue(C_RhythmYpos)),
wxSize(640, 580)),
- mpInstrumentPanel(0),
mpStepsPerCountSlider(0),
mpCountsPerBarSlider(0),
mpBarCountSlider(0),
@@ -628,10 +629,10 @@
int y = 0;
int w, h;
GetClientSize(&w, &h);
- mpInstrumentPanel = new wxPanel(this, x, y, w/2, h/2, 0, "InstPanel");
+ wxPanel* pInstrumentPanel = new wxPanel(this, x, y, w/2, h/2, 0, "InstPanel");
mpStepsPerCountSlider = new wxSlider(
- mpInstrumentPanel,
+ pInstrumentPanel,
(wxFunction)ItemCallback,
"",
4,
@@ -641,11 +642,11 @@
10,
1,
wxFIXED_LENGTH);
- (void) new wxMessage(mpInstrumentPanel, "steps/count");
- mpInstrumentPanel->NewLine();
+ (void) new wxMessage(pInstrumentPanel, "steps/count");
+ pInstrumentPanel->NewLine();
mpCountsPerBarSlider = new wxSlider(
- mpInstrumentPanel,
+ pInstrumentPanel,
(wxFunction)ItemCallback,
"",
4,
@@ -655,11 +656,11 @@
10,
h / 12,
wxFIXED_LENGTH);
- (void) new wxMessage(mpInstrumentPanel, "count/bar");
- mpInstrumentPanel->NewLine();
+ (void) new wxMessage(pInstrumentPanel, "count/bar");
+ pInstrumentPanel->NewLine();
mpBarCountSlider = new wxSlider(
- mpInstrumentPanel,
+ pInstrumentPanel,
(wxFunction)ItemCallback,
"",
4,
@@ -669,12 +670,12 @@
10,
2 * h / 12,
wxFIXED_LENGTH);
- (void) new wxMessage(mpInstrumentPanel, "# bars");
- mpInstrumentPanel->NewLine();
+ (void) new wxMessage(pInstrumentPanel, "# bars");
+ pInstrumentPanel->NewLine();
- mpInstrumentPanel->SetLabelPosition(wxVERTICAL);
+ pInstrumentPanel->SetLabelPosition(wxVERTICAL);
mpInstrumentListBox = new wxListBox(
- mpInstrumentPanel,
+ pInstrumentPanel,
(wxFunction)SelectInstr,
"Instrument",
wxLB_SINGLE /* | wxLB_ALWAYS_SB */,
@@ -683,7 +684,7 @@
220,
80);
- mpInstrumentPanel->NewLine();
+ pInstrumentPanel->NewLine();
// Random array edits.
@@ -1377,7 +1378,7 @@
//*****************************************************************************
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-BEGIN_EVENT_TABLE(JZRhythmGeneratorWindow, wxWindow)
+BEGIN_EVENT_TABLE(JZRhythmGeneratorWindow, wxPanel)
END_EVENT_TABLE()
@@ -1387,10 +1388,9 @@
wxFrame* pParent,
const wxPoint& Position,
const wxSize& Size)
- : wxWindow(pParent, wxID_ANY, Position, Size),
+ : wxPanel(pParent, wxID_ANY, Position, Size),
mRhythm(0),
mInstruments(),
- mpInstrumentPanel(0),
mpStepsPerCountSlider(0),
mpCountsPerBarSlider(0),
mpBarCountSlider(0),
@@ -1410,11 +1410,11 @@
int Width, Height;
GetClientSize(&Width, &Height);
- mpInstrumentPanel =
+ wxPanel* pInstrumentPanel =
new wxPanel(this, wxID_ANY, wxPoint(x, y), wxSize(Width, Height / 2));
mpStepsPerCountSlider = new wxSlider(
- mpInstrumentPanel,
+ pInstrumentPanel,
IDC_SL_RHYTHM_STEPS_PER_COUNT,
4,
1,
@@ -1424,7 +1424,7 @@
wxSL_LABELS);
mpCountsPerBarSlider = new wxSlider(
- mpInstrumentPanel,
+ pInstrumentPanel,
IDC_SL_RHYTHM_COUNTS_PER_BAR,
4,
1,
@@ -1434,7 +1434,7 @@
wxSL_LABELS);
mpBarCountSlider = new wxSlider(
- mpInstrumentPanel,
+ pInstrumentPanel,
IDC_SL_RHYTHM_BAR_COUNT,
1,
1,
@@ -1444,13 +1444,13 @@
wxSL_LABELS);
wxStaticText* pStaticText = new wxStaticText(
- mpInstrumentPanel,
+ pInstrumentPanel,
wxID_ANY,
"Instrument",
wxPoint(10, 3 * Height / 12));
mpInstrumentListBox = new wxListBox(
- mpInstrumentPanel,
+ pInstrumentPanel,
IDC_LB_RHYTHM_INSTRUMENTS,
wxPoint(10, 4 * Height / 12),
wxSize(220, 80),
@@ -1458,7 +1458,7 @@
wxLB_SINGLE);
mpGroupContribSlider = new wxSlider(
- mpInstrumentPanel,
+ pInstrumentPanel,
IDC_SL_RHYTHM_GROUP_CONTRIB,
0,
0,
@@ -1468,7 +1468,7 @@
wxSL_LABELS);
mpGroupListenSlider = new wxSlider(
- mpInstrumentPanel,
+ pInstrumentPanel,
IDC_SL_RHYTHM_GROUP_LISTEN,
0,
-100,
@@ -1478,37 +1478,50 @@
wxSL_LABELS);
mpRandomCheckBox = new wxCheckBox(
- mpInstrumentPanel,
+ pInstrumentPanel,
IDC_CB_RHYTHM_RANDOMIZE,
"Randomize",
wxPoint(Width / 2, 4 * Height / 12));
- mpLengthEdit = new JZArrayEdit(
- pParent,
+ wxPanel* pPanel = new wxPanel(this);
+
+ mpLengthEdit = new JZArrayControl(
+ pPanel,
+ wxID_ANY,
mRhythm.mLengthArray,
- wxPoint(x, y + Height / 2),
- wxSize(Width / 2, Height / 4 - 4));
+ wxPoint(x, y),
+ wxSize(Width / 2, Height / 2 - 4));
mpLengthEdit->SetXMinMax(1, 8);
mpLengthEdit->SetLabel("length/interval");
- mpVelocityEdit = new JZArrayEdit(
- pParent,
+ mpVelocityEdit = new JZArrayControl(
+ pPanel,
+ wxID_ANY,
mRhythm.mVelocityArray,
- wxPoint(x + Width / 2, y + Height / 2),
- wxSize(Width / 2, Height / 4 - 4));
+ wxPoint(x + Width / 2, y),
+ wxSize(Width / 2, Height / 2 - 4));
mpVelocityEdit->SetXMinMax(1, 127);
mpVelocityEdit->SetLabel("velocity");
- mpRhythmEdit = new JZRhyArrayEdit(
- pParent,
+ mpRhythmEdit = new JZArrayControl(
+ pPanel,
+ wxID_ANY,
mRhythm.mRhythmArray,
- wxPoint(x, y + 3 * Height / 4),
- wxSize(Width, Height/ 4 - 4));
- mpRhythmEdit->SetMeter(
- mRhythm.mStepsPerCount,
- mRhythm.mCountPerBar,
- mRhythm.mBarCount);
+ wxPoint(x, y + Height / 2),
+ wxSize(Width, Height / 2 - 4));
+ mpRhythmEdit->SetXMinMax(1, 4);
+// mpRhythmEdit->SetMeter(
+// mRhythm.mStepsPerCount,
+// mRhythm.mCountPerBar,
+// mRhythm.mBarCount);
mpRhythmEdit->SetLabel("rhythm");
+
+ wxBoxSizer* pSizer = new wxBoxSizer(wxVERTICAL);
+
+ pSizer->Add(pInstrumentPanel, wxSizerFlags().Border().Expand());
+ pSizer->Add(pPanel, wxSizerFlags(1).Border().Expand());
+
+ SetSizer(pSizer);
}
//-----------------------------------------------------------------------------
@@ -1671,7 +1684,7 @@
Instrument2Win();
- Refresh(); //OnPaint();
+ Refresh();
}
//-----------------------------------------------------------------------------
Modified: trunk/jazz/src/Rhythm.h
===================================================================
--- trunk/jazz/src/Rhythm.h 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/Rhythm.h 2013-04-07 08:08:41 UTC (rev 1007)
@@ -26,10 +26,12 @@
#include "Random.h"
#include <wx/frame.h>
+#include <wx/panel.h>
#include <iosfwd>
#include <vector>
+class JZArrayControl;
class JZBarInfo;
class JZEventWindow;
class JZSong;
@@ -252,7 +254,7 @@
//*****************************************************************************
//*****************************************************************************
-class JZRhythmGeneratorWindow : public wxWindow
+class JZRhythmGeneratorWindow : public wxPanel
{
public:
@@ -281,8 +283,6 @@
std::vector<JZRhythm*> mInstruments;
- wxPanel* mpInstrumentPanel;
-
wxSlider* mpStepsPerCountSlider;
wxSlider* mpCountsPerBarSlider;
wxSlider* mpBarCountSlider;
@@ -294,9 +294,12 @@
int mActiveGroup;
wxCheckBox* mpRandomCheckBox;
- JZArrayEdit* mpLengthEdit;
- JZArrayEdit* mpVelocityEdit;
- JZRhyArrayEdit* mpRhythmEdit;
+// JZArrayEdit* mpLengthEdit;
+ JZArrayControl* mpLengthEdit;
+// JZArrayEdit* mpVelocityEdit;
+ JZArrayControl* mpVelocityEdit;
+// JZRhyArrayEdit* mpRhythmEdit;
+ JZArrayControl* mpRhythmEdit;
DECLARE_EVENT_TABLE()
};
Modified: trunk/jazz/src/SampleCommand.cpp
===================================================================
--- trunk/jazz/src/SampleCommand.cpp 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/SampleCommand.cpp 2013-04-07 08:08:41 UTC (rev 1007)
@@ -498,7 +498,7 @@
{
// add all the outputs
double y = x;
- JZMapper ymap(array.Min(), array.Max(), -1, 1);
+ JZMapper ymap(array.GetMin(), array.GetMax(), -1, 1);
for (int i = 0; i < nfilters; i++)
{
double amp = fabs(ymap.XToY(array[i]));
Modified: trunk/jazz/src/SampleFrame.h
===================================================================
--- trunk/jazz/src/SampleFrame.h 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/SampleFrame.h 2013-04-07 08:08:41 UTC (rev 1007)
@@ -14,6 +14,7 @@
class JZSampleWindow;
class JZSynthDlg;
class wxDialog;
+class wxPanel;
class wxScrollBar;
//*****************************************************************************
Modified: trunk/jazz/src/Signal2.cpp
===================================================================
--- trunk/jazz/src/Signal2.cpp 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/Signal2.cpp 2013-04-07 08:08:41 UTC (rev 1007)
@@ -168,7 +168,7 @@
const int N = wav.Size();
JZLineMap<float>xmap(0, N, 0, arr.Size() - 1);
- JZLineMap<float>ymap(arr.Min(), arr.Max(), -1, 1);
+ JZLineMap<float>ymap(arr.GetMin(), arr.GetMax(), -1, 1);
for (i = 0; i < N; i++)
/* PAT - Original line: wav[i] = ymap(arr[xmap(i)]); */
wav[i] = ymap(arr[xmap(i)]);
Modified: trunk/jazz/src/SliderWindow.cpp
===================================================================
--- trunk/jazz/src/SliderWindow.cpp 2013-04-07 06:02:14 UTC (rev 1006)
+++ trunk/jazz/src/SliderWindow.cpp 2013-04-07 08:08:41 UTC (rev 1007)
@@ -25,8 +25,11 @@
#include "Random.h"
#include "ToolBar.h"
+#include <wx/panel.h>
+
// These two lines are here to allow cout usage.
#include <iostream>
+
using namespace std;
JZSliderWindow::JZSliderWindow(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|