author | waspe <waspe> | 2003-12-02 19:03:50 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-12-02 19:03:50 (UTC) |
commit | 64304e555fc3e06aa69fa2f4a514ee55b7aa98bc (patch) (unidiff) | |
tree | 3ce47189f43f18cccd42d326cf52977b339c744d | |
parent | 7b74f202db22d458c43b2063ae128bf79b0e9777 (diff) | |
download | opie-64304e555fc3e06aa69fa2f4a514ee55b7aa98bc.zip opie-64304e555fc3e06aa69fa2f4a514ee55b7aa98bc.tar.gz opie-64304e555fc3e06aa69fa2f4a514ee55b7aa98bc.tar.bz2 |
*** empty log message ***
-rw-r--r-- | noncore/multimedia/tonleiter/editinst.cpp | 93 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/editinst.h | 31 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/editscale.cpp | 32 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/editscale.h | 4 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/editstringwidget.cpp | 32 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/editstringwidget.h | 24 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/menuwidget.cpp | 20 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/pianoscale.cpp | 96 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/pianoscale.h | 28 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiter.pro | 4 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdata.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdatahelper.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/tonleiter/tonleiterdatahelper.h | 2 |
13 files changed, 365 insertions, 7 deletions
diff --git a/noncore/multimedia/tonleiter/editinst.cpp b/noncore/multimedia/tonleiter/editinst.cpp index 1eba4dc..120c3ac 100644 --- a/noncore/multimedia/tonleiter/editinst.cpp +++ b/noncore/multimedia/tonleiter/editinst.cpp | |||
@@ -1,14 +1,107 @@ | |||
1 | #include "editinst.h" | 1 | #include "editinst.h" |
2 | 2 | ||
3 | #include <qlabel.h> | ||
4 | #include <qpushbutton.h> | ||
5 | |||
3 | Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const char* name) | 6 | Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const char* name) |
4 | :QDialog(parent,name,true,0),data(data) | 7 | :QDialog(parent,name,true,0),data(data) |
5 | { | 8 | { |
6 | setCaption("Tonleiter::"+tr("Instrument")); | 9 | setCaption("Tonleiter::"+tr("Instrument")); |
10 | QBoxLayout* masterlayout=new QBoxLayout(this,QBoxLayout::TopToBottom); | ||
11 | instid=data->getCurrentInstrumentID(); | ||
12 | stringlist.setAutoDelete(true); | ||
13 | |||
14 | QBoxLayout* toplayout=new QBoxLayout(masterlayout,QBoxLayout::LeftToRight); | ||
15 | |||
16 | //Name combo + Add + Delete | ||
17 | boxInst=new QComboBox(this,"boxInst"); | ||
18 | boxInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
19 | connect(boxInst,SIGNAL(activated(int)),this,SLOT(setCurrentInstrumetID(int))); | ||
20 | for(int i=0;i<data->noOfInstruments();i++) | ||
21 | { | ||
22 | Instrument inst=data->getInstrument(i); | ||
23 | QString name=inst.instName(); | ||
24 | if(name.isNull()) continue; | ||
25 | boxInst->insertItem(name,i); | ||
26 | } | ||
27 | boxInst->setCurrentItem(instid); | ||
28 | toplayout->addWidget(boxInst); | ||
29 | |||
30 | QPushButton* addButton=new QPushButton(tr("Add"),this,"addButton"); | ||
31 | connect(addButton,SIGNAL(pressed()),this,SLOT(addInstrument())); | ||
32 | toplayout->addWidget(addButton); | ||
33 | |||
34 | QPushButton* delButton=new QPushButton(tr("Delete"),this,"delButton"); | ||
35 | connect(delButton,SIGNAL(pressed()),this,SLOT(deleteInstrument())); | ||
36 | toplayout->addWidget(delButton); | ||
37 | |||
38 | QPushButton* addhighButton=new QPushButton(tr("Add High String"),this,"addhighButton"); | ||
39 | masterlayout->addWidget(addhighButton); | ||
40 | |||
41 | QScrollView* scrollview=new QScrollView(this); | ||
42 | scrollview->setVScrollBarMode(QScrollView::AlwaysOn); | ||
43 | scrollview->setHScrollBarMode(QScrollView::AlwaysOff); | ||
44 | stringwidget=new QVBox(scrollview->viewport()); | ||
45 | stringwidget->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum)); | ||
46 | stringwidget->setSpacing(10); | ||
47 | scrollview->addChild(stringwidget); | ||
48 | scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
49 | //scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding)); | ||
50 | masterlayout->addWidget(scrollview); | ||
51 | |||
52 | loadInstrument(); | ||
53 | |||
54 | QPushButton* addlowButton=new QPushButton(tr("Add Low String"),this,"addlowButton"); | ||
55 | masterlayout->addWidget(addlowButton); | ||
56 | |||
57 | //make dialog fit the screen | ||
7 | showMaximized(); | 58 | showMaximized(); |
8 | } | 59 | } |
9 | //**************************************************************************** | 60 | //**************************************************************************** |
10 | Menu::InstEditDialog::~InstEditDialog() | 61 | Menu::InstEditDialog::~InstEditDialog() |
11 | { | 62 | { |
12 | } | 63 | } |
13 | //**************************************************************************** | 64 | //**************************************************************************** |
65 | void Menu::InstEditDialog::setCurrentInstrumetID(int id) | ||
66 | { | ||
67 | saveInstrument(); | ||
68 | instid=id; | ||
69 | data->setCurrentInstrumetID(id); | ||
70 | loadInstrument(); | ||
71 | } | ||
72 | //**************************************************************************** | ||
73 | void Menu::InstEditDialog::addInstrument() | ||
74 | { | ||
75 | } | ||
76 | //**************************************************************************** | ||
77 | void Menu::InstEditDialog::deleteInstrument() | ||
78 | { | ||
79 | } | ||
80 | //**************************************************************************** | ||
81 | void Menu::InstEditDialog::addLowString() | ||
82 | { | ||
83 | } | ||
84 | //**************************************************************************** | ||
85 | void Menu::InstEditDialog::addHighString() | ||
86 | { | ||
87 | } | ||
88 | //**************************************************************************** | ||
89 | void Menu::InstEditDialog::deleteString(int id) | ||
90 | { | ||
91 | } | ||
92 | //**************************************************************************** | ||
93 | void Menu::InstEditDialog::saveInstrument() | ||
94 | { | ||
95 | stringlist.clear(); | ||
96 | } | ||
97 | //**************************************************************************** | ||
98 | void Menu::InstEditDialog::loadInstrument() | ||
99 | { | ||
100 | Instrument inst=data->getInstrument(instid); | ||
101 | for(uint s=0;s<inst.noOfStrings();s++) | ||
102 | { | ||
103 | stringlist.append(new EditStringWidget(inst.string(s),stringwidget)); | ||
104 | } | ||
105 | } | ||
106 | //**************************************************************************** | ||
14 | //**************************************************************************** | 107 | //**************************************************************************** |
diff --git a/noncore/multimedia/tonleiter/editinst.h b/noncore/multimedia/tonleiter/editinst.h index e7eba15..948a2de 100644 --- a/noncore/multimedia/tonleiter/editinst.h +++ b/noncore/multimedia/tonleiter/editinst.h | |||
@@ -1,23 +1,52 @@ | |||
1 | #ifndef TONLEITER_EDIT_INSTRUMENT_DIALOG_H | 1 | #ifndef TONLEITER_EDIT_INSTRUMENT_DIALOG_H |
2 | #define TONLEITER_EDIT_INSTRUMENT_DIALOG_H | 2 | #define TONLEITER_EDIT_INSTRUMENT_DIALOG_H |
3 | 3 | ||
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | #include <qcombobox.h> | ||
6 | #include <qscrollview.h> | ||
7 | #include <qspinbox.h> | ||
8 | #include <qlayout.h> | ||
9 | #include <qlist.h> | ||
10 | #include <qvbox.h> | ||
5 | 11 | ||
6 | #include "tonleiterdata.h" | 12 | |
13 | #include "editstringwidget.h" | ||
7 | 14 | ||
8 | using namespace Data; | 15 | using namespace Data; |
9 | 16 | ||
17 | |||
10 | namespace Menu | 18 | namespace Menu |
11 | { | 19 | { |
12 | class InstEditDialog : public QDialog | 20 | class InstEditDialog : public QDialog |
13 | { | 21 | { |
14 | Q_OBJECT | 22 | Q_OBJECT |
15 | private: | 23 | private: |
16 | TonleiterData* data; | 24 | TonleiterData* data; |
25 | int instid; | ||
26 | |||
27 | QComboBox* boxInst; | ||
28 | QSpinBox* stringBox; | ||
29 | |||
30 | QVBox* stringwidget; | ||
31 | |||
32 | //this is a QPtrList !! | ||
33 | typedef QList<EditStringWidget> StringWidgetList; | ||
34 | StringWidgetList stringlist; | ||
17 | public: | 35 | public: |
18 | InstEditDialog(TonleiterData* data,QWidget* parent,const char* name="InstEditDialog"); | 36 | InstEditDialog(TonleiterData* data,QWidget* parent,const char* name="InstEditDialog"); |
19 | ~InstEditDialog(); | 37 | ~InstEditDialog(); |
38 | private slots: | ||
39 | void setCurrentInstrumetID(int id); | ||
40 | void addInstrument(); | ||
41 | void deleteInstrument(); | ||
42 | |||
43 | void addLowString(); | ||
44 | void addHighString(); | ||
45 | void deleteString(int id); | ||
46 | private: | ||
47 | void saveInstrument(); | ||
48 | void loadInstrument(); | ||
20 | }; | 49 | }; |
21 | }; | 50 | }; |
22 | 51 | ||
23 | #endif //TONLEITER_EDIT_INSTRUMENT_DIALOG_H | 52 | #endif //TONLEITER_EDIT_INSTRUMENT_DIALOG_H |
diff --git a/noncore/multimedia/tonleiter/editscale.cpp b/noncore/multimedia/tonleiter/editscale.cpp index 593a150..0be0058 100644 --- a/noncore/multimedia/tonleiter/editscale.cpp +++ b/noncore/multimedia/tonleiter/editscale.cpp | |||
@@ -1,14 +1,46 @@ | |||
1 | #include "editscale.h" | 1 | #include "editscale.h" |
2 | 2 | ||
3 | #include <qlayout.h> | ||
4 | #include <qpushbutton.h> | ||
5 | |||
3 | Menu::ScaleEditDialog::ScaleEditDialog(TonleiterData* data,QWidget* parent,const char* name) | 6 | Menu::ScaleEditDialog::ScaleEditDialog(TonleiterData* data,QWidget* parent,const char* name) |
4 | :QDialog(parent,name,true,0),data(data) | 7 | :QDialog(parent,name,true,0),data(data) |
5 | { | 8 | { |
6 | setCaption("Tonleiter::"+tr("Scale")); | 9 | setCaption("Tonleiter::"+tr("Scale")); |
10 | QBoxLayout* masterlayout=new QBoxLayout(this,QBoxLayout::TopToBottom); | ||
11 | |||
12 | QBoxLayout* toplayout=new QBoxLayout(masterlayout,QBoxLayout::LeftToRight); | ||
13 | |||
14 | boxScale=new QComboBox(this,"boxScale"); | ||
15 | for(int s=0;s<data->noOfScales();s++) | ||
16 | { | ||
17 | Scale scale=data->getScale(s); | ||
18 | QString name=scale.scaleName(); | ||
19 | if(name.isNull()) continue; | ||
20 | //boxScale->insertItem(name,s); | ||
21 | } | ||
22 | boxScale->setCurrentItem(data->getCurrentScaleID()); | ||
23 | boxScale->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
24 | connect(boxScale,SIGNAL(activated(int)),data,SLOT(setCurrentScaleID(int))); | ||
25 | toplayout->addWidget(boxScale); | ||
26 | |||
27 | QPushButton* addButton=new QPushButton(tr("Add"),this,"addButton"); | ||
28 | connect(addButton,SIGNAL(pressed()),this,SLOT(addInstrument())); | ||
29 | toplayout->addWidget(addButton); | ||
30 | |||
31 | QPushButton* delButton=new QPushButton(tr("Delete"),this,"delButton"); | ||
32 | connect(delButton,SIGNAL(pressed()),this,SLOT(deleteInstrument())); | ||
33 | toplayout->addWidget(delButton); | ||
34 | |||
35 | pianoscale=new PianoScale(this); | ||
36 | masterlayout->addWidget(pianoscale); | ||
37 | |||
38 | //make dialog fit the screen | ||
7 | showMaximized(); | 39 | showMaximized(); |
8 | } | 40 | } |
9 | //**************************************************************************** | 41 | //**************************************************************************** |
10 | Menu::ScaleEditDialog::~ScaleEditDialog() | 42 | Menu::ScaleEditDialog::~ScaleEditDialog() |
11 | { | 43 | { |
12 | } | 44 | } |
13 | //**************************************************************************** | 45 | //**************************************************************************** |
14 | //**************************************************************************** | 46 | //**************************************************************************** |
diff --git a/noncore/multimedia/tonleiter/editscale.h b/noncore/multimedia/tonleiter/editscale.h index 0e5eb1c..1121c1f 100644 --- a/noncore/multimedia/tonleiter/editscale.h +++ b/noncore/multimedia/tonleiter/editscale.h | |||
@@ -1,23 +1,27 @@ | |||
1 | #ifndef TONLEITER_EDIT_SCALE_DIALOG_H | 1 | #ifndef TONLEITER_EDIT_SCALE_DIALOG_H |
2 | #define TONLEITER_EDIT_SCALE_DIALOG_H | 2 | #define TONLEITER_EDIT_SCALE_DIALOG_H |
3 | 3 | ||
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | #include <qcombobox.h> | ||
5 | 6 | ||
6 | #include "tonleiterdata.h" | 7 | #include "tonleiterdata.h" |
8 | #include "pianoscale.h" | ||
7 | 9 | ||
8 | using namespace Data; | 10 | using namespace Data; |
9 | 11 | ||
10 | namespace Menu | 12 | namespace Menu |
11 | { | 13 | { |
12 | class ScaleEditDialog : public QDialog | 14 | class ScaleEditDialog : public QDialog |
13 | { | 15 | { |
14 | Q_OBJECT | 16 | Q_OBJECT |
15 | private: | 17 | private: |
16 | TonleiterData* data; | 18 | TonleiterData* data; |
19 | QComboBox* boxScale; | ||
20 | PianoScale* pianoscale; | ||
17 | public: | 21 | public: |
18 | ScaleEditDialog(TonleiterData* data,QWidget* parent,const char* name="ScaleEditDialog"); | 22 | ScaleEditDialog(TonleiterData* data,QWidget* parent,const char* name="ScaleEditDialog"); |
19 | ~ScaleEditDialog(); | 23 | ~ScaleEditDialog(); |
20 | }; | 24 | }; |
21 | }; | 25 | }; |
22 | 26 | ||
23 | #endif //TONLEITER_EDIT_SCALE_DIALOG_H | 27 | #endif //TONLEITER_EDIT_SCALE_DIALOG_H |
diff --git a/noncore/multimedia/tonleiter/editstringwidget.cpp b/noncore/multimedia/tonleiter/editstringwidget.cpp new file mode 100644 index 0000000..d22bbc5 --- a/dev/null +++ b/noncore/multimedia/tonleiter/editstringwidget.cpp | |||
@@ -0,0 +1,32 @@ | |||
1 | #include "editstringwidget.h" | ||
2 | |||
3 | #include <qlabel.h> | ||
4 | #include <qlayout.h> | ||
5 | |||
6 | using namespace Data; | ||
7 | |||
8 | Menu::EditStringWidget::EditStringWidget(int note,QWidget* parent,const char* name,WFlags f) | ||
9 | :QFrame(parent,name,f) | ||
10 | { | ||
11 | QBoxLayout* layout=new QBoxLayout(this,QBoxLayout::LeftToRight,10); | ||
12 | |||
13 | boxNote=new QComboBox(this,"boxNote"); | ||
14 | boxNote->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
15 | //connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); | ||
16 | layout->addWidget(boxNote,1,1); | ||
17 | for(int a=0;a<12;a++) | ||
18 | boxNote->insertItem(Note::notenames[a],a); | ||
19 | boxNote->setCurrentItem(note-12*Note::getOctaveOfNote(note)); | ||
20 | layout->addWidget(boxNote); | ||
21 | |||
22 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
23 | setFrameShape(QFrame::Panel); | ||
24 | setFrameShadow(QFrame::Sunken); | ||
25 | |||
26 | } | ||
27 | //**************************************************************************** | ||
28 | Menu::EditStringWidget::~EditStringWidget() | ||
29 | { | ||
30 | } | ||
31 | //**************************************************************************** | ||
32 | //**************************************************************************** | ||
diff --git a/noncore/multimedia/tonleiter/editstringwidget.h b/noncore/multimedia/tonleiter/editstringwidget.h new file mode 100644 index 0000000..ba105a9 --- a/dev/null +++ b/noncore/multimedia/tonleiter/editstringwidget.h | |||
@@ -0,0 +1,24 @@ | |||
1 | #ifndef TONLEITER_EDIT_STRING_WIDGT_H | ||
2 | #define TONLEITER_EDIT_STRING_WIDGT_H | ||
3 | |||
4 | #include <qframe.h> | ||
5 | #include <qcombobox.h> | ||
6 | #include <qspinbox.h> | ||
7 | |||
8 | #include "tonleiterdata.h" | ||
9 | |||
10 | namespace Menu | ||
11 | { | ||
12 | class EditStringWidget : public QFrame | ||
13 | { | ||
14 | Q_OBJECT | ||
15 | private: | ||
16 | QComboBox* boxNote; | ||
17 | public: | ||
18 | EditStringWidget(int note,QWidget* parent,const char* name=0,WFlags f=0); | ||
19 | ~EditStringWidget(); | ||
20 | }; | ||
21 | }; | ||
22 | |||
23 | #endif //TONLEITER_EDIT_STRING_WIDGT_H | ||
24 | |||
diff --git a/noncore/multimedia/tonleiter/menuwidget.cpp b/noncore/multimedia/tonleiter/menuwidget.cpp index 1e3742c..56a2f8a 100644 --- a/noncore/multimedia/tonleiter/menuwidget.cpp +++ b/noncore/multimedia/tonleiter/menuwidget.cpp | |||
@@ -1,89 +1,107 @@ | |||
1 | #include "menuwidget.h" | 1 | #include "menuwidget.h" |
2 | 2 | ||
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qlayout.h> | 4 | #include <qlayout.h> |
5 | 5 | ||
6 | #include "editinst.h" | 6 | #include "editinst.h" |
7 | #include "editscale.h" | 7 | #include "editscale.h" |
8 | 8 | ||
9 | Menu::MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFlags f) | 9 | Menu::MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFlags f) |
10 | :QWidget(parent,name,f),data(data) | 10 | :QWidget(parent,name,f),data(data) |
11 | { | 11 | { |
12 | QGridLayout* layout=new QGridLayout(this,3,3,10,-1,"menulayout"); | 12 | QGridLayout* layout=new QGridLayout(this,3,3,10,-1,"menulayout"); |
13 | 13 | ||
14 | //Instrument | ||
14 | QLabel* instLabel=new QLabel(tr("Instr."),this,"instLabel"); | 15 | QLabel* instLabel=new QLabel(tr("Instr."),this,"instLabel"); |
16 | instLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
15 | layout->addWidget(instLabel,0,0); | 17 | layout->addWidget(instLabel,0,0); |
18 | |||
16 | boxInst=new QComboBox(this,"boxInst"); | 19 | boxInst=new QComboBox(this,"boxInst"); |
20 | boxInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
17 | connect(boxInst,SIGNAL(activated(int)),data,SLOT(setCurrentInstrumetID(int))); | 21 | connect(boxInst,SIGNAL(activated(int)),data,SLOT(setCurrentInstrumetID(int))); |
18 | layout->addWidget(boxInst,0,1); | 22 | layout->addWidget(boxInst,0,1); |
23 | |||
19 | editInst=new QPushButton(tr("Edit"),this,"editInst"); | 24 | editInst=new QPushButton(tr("Edit"),this,"editInst"); |
25 | editInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
20 | connect(editInst,SIGNAL(pressed()),this,SLOT(editInstPressed())); | 26 | connect(editInst,SIGNAL(pressed()),this,SLOT(editInstPressed())); |
21 | layout->addWidget(editInst,0,2); | 27 | layout->addWidget(editInst,0,2); |
22 | 28 | ||
29 | //Note | ||
23 | QLabel* noteLabel=new QLabel(tr("Note"),this,"noteLabel"); | 30 | QLabel* noteLabel=new QLabel(tr("Note"),this,"noteLabel"); |
31 | noteLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
24 | layout->addWidget(noteLabel,1,0); | 32 | layout->addWidget(noteLabel,1,0); |
33 | |||
25 | boxNote=new QComboBox(this,"boxNote"); | 34 | boxNote=new QComboBox(this,"boxNote"); |
35 | boxNote->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
26 | connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); | 36 | connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); |
27 | layout->addWidget(boxNote,1,1); | 37 | layout->addWidget(boxNote,1,1); |
28 | for(int a=0;a<12;a++) | 38 | for(int a=0;a<12;a++) |
29 | boxNote->insertItem(Note::notenames[a],a); | 39 | boxNote->insertItem(Note::notenames[a],a); |
30 | boxNote->setCurrentItem(data->getCurrentBaseNote()); | 40 | boxNote->setCurrentItem(data->getCurrentBaseNote()); |
41 | |||
31 | noteCheck=new QCheckBox(tr("show"),this,"noteCheck"); | 42 | noteCheck=new QCheckBox(tr("show"),this,"noteCheck"); |
43 | noteCheck->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
32 | noteCheck->setChecked(data->isDrawNames()); | 44 | noteCheck->setChecked(data->isDrawNames()); |
33 | connect(noteCheck,SIGNAL(toggled(bool)),data,SLOT(setDrawNames(bool))); | 45 | connect(noteCheck,SIGNAL(toggled(bool)),data,SLOT(setDrawNames(bool))); |
34 | layout->addWidget(noteCheck,1,2); | 46 | layout->addWidget(noteCheck,1,2); |
35 | 47 | ||
48 | //Scale | ||
36 | QLabel* scaleLabel=new QLabel(tr("Scale"),this,"scaleLabel"); | 49 | QLabel* scaleLabel=new QLabel(tr("Scale"),this,"scaleLabel"); |
50 | scaleLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
37 | layout->addWidget(scaleLabel,2,0); | 51 | layout->addWidget(scaleLabel,2,0); |
52 | |||
38 | boxScale=new QComboBox(this,"boxScale"); | 53 | boxScale=new QComboBox(this,"boxScale"); |
54 | boxScale->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
39 | connect(boxScale,SIGNAL(activated(int)),data,SLOT(setCurrentScaleID(int))); | 55 | connect(boxScale,SIGNAL(activated(int)),data,SLOT(setCurrentScaleID(int))); |
40 | layout->addWidget(boxScale,2,1); | 56 | layout->addWidget(boxScale,2,1); |
57 | |||
41 | editScale=new QPushButton(tr("Edit"),this,"editScale"); | 58 | editScale=new QPushButton(tr("Edit"),this,"editScale"); |
59 | editScale->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | ||
42 | connect(editScale,SIGNAL(pressed()),this,SLOT(editScalePressed())); | 60 | connect(editScale,SIGNAL(pressed()),this,SLOT(editScalePressed())); |
43 | layout->addWidget(editScale,2,2); | 61 | layout->addWidget(editScale,2,2); |
44 | 62 | ||
45 | updateBoxes(); | 63 | updateBoxes(); |
46 | 64 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | |
47 | } | 65 | } |
48 | //**************************************************************************** | 66 | //**************************************************************************** |
49 | Menu::MenuWidget::~MenuWidget() | 67 | Menu::MenuWidget::~MenuWidget() |
50 | { | 68 | { |
51 | } | 69 | } |
52 | //**************************************************************************** | 70 | //**************************************************************************** |
53 | void Menu::MenuWidget::editInstPressed() | 71 | void Menu::MenuWidget::editInstPressed() |
54 | { | 72 | { |
55 | InstEditDialog* instdialog=new InstEditDialog(data,this); | 73 | InstEditDialog* instdialog=new InstEditDialog(data,this); |
56 | instdialog->exec(); | 74 | instdialog->exec(); |
57 | } | 75 | } |
58 | //**************************************************************************** | 76 | //**************************************************************************** |
59 | void Menu::MenuWidget::editScalePressed() | 77 | void Menu::MenuWidget::editScalePressed() |
60 | { | 78 | { |
61 | ScaleEditDialog* scaledialog=new ScaleEditDialog(data,this); | 79 | ScaleEditDialog* scaledialog=new ScaleEditDialog(data,this); |
62 | scaledialog->exec(); | 80 | scaledialog->exec(); |
63 | } | 81 | } |
64 | //**************************************************************************** | 82 | //**************************************************************************** |
65 | void Menu::MenuWidget::updateBoxes() | 83 | void Menu::MenuWidget::updateBoxes() |
66 | { | 84 | { |
67 | boxInst->clear(); | 85 | boxInst->clear(); |
68 | 86 | ||
69 | for(int i=0;i<data->noOfInstruments();i++) | 87 | for(int i=0;i<data->noOfInstruments();i++) |
70 | { | 88 | { |
71 | Instrument inst=data->getInstrument(i); | 89 | Instrument inst=data->getInstrument(i); |
72 | QString name=inst.instName(); | 90 | QString name=inst.instName(); |
73 | if(name.isNull()) continue; | 91 | if(name.isNull()) continue; |
74 | boxInst->insertItem(name,i); | 92 | boxInst->insertItem(name,i); |
75 | } | 93 | } |
76 | boxInst->setCurrentItem(data->getCurrentInstrumentID()); | 94 | boxInst->setCurrentItem(data->getCurrentInstrumentID()); |
77 | 95 | ||
78 | boxScale->clear(); | 96 | boxScale->clear(); |
79 | for(int s=0;s<data->noOfScales();s++) | 97 | for(int s=0;s<data->noOfScales();s++) |
80 | { | 98 | { |
81 | Scale scale=data->getScale(s); | 99 | Scale scale=data->getScale(s); |
82 | QString name=scale.scaleName(); | 100 | QString name=scale.scaleName(); |
83 | if(name.isNull()) continue; | 101 | if(name.isNull()) continue; |
84 | boxScale->insertItem(name,s); | 102 | boxScale->insertItem(name,s); |
85 | } | 103 | } |
86 | boxScale->setCurrentItem(data->getCurrentScaleID()); | 104 | boxScale->setCurrentItem(data->getCurrentScaleID()); |
87 | } | 105 | } |
88 | //**************************************************************************** | 106 | //**************************************************************************** |
89 | //**************************************************************************** | 107 | //**************************************************************************** |
diff --git a/noncore/multimedia/tonleiter/pianoscale.cpp b/noncore/multimedia/tonleiter/pianoscale.cpp new file mode 100644 index 0000000..3d5add2 --- a/dev/null +++ b/noncore/multimedia/tonleiter/pianoscale.cpp | |||
@@ -0,0 +1,96 @@ | |||
1 | #include "pianoscale.h" | ||
2 | |||
3 | #include <qpainter.h> | ||
4 | |||
5 | |||
6 | Menu::PianoScale::PianoScale(QWidget* parent,const char* name,WFlags f) | ||
7 | :QWidget(parent,name,f) | ||
8 | { | ||
9 | QColor black(0,0,0); | ||
10 | QColor white(255,255,255); | ||
11 | QColor mark(255,0,0); | ||
12 | blackBrush=QBrush(black); | ||
13 | whiteBrush=QBrush(white); | ||
14 | markBrush=QBrush(mark); | ||
15 | blackPen=QPen(black); | ||
16 | whitePen=QPen(white); | ||
17 | setBackgroundColor(QColor(0,0,255)); | ||
18 | } | ||
19 | //**************************************************************************** | ||
20 | Menu::PianoScale::~ PianoScale() | ||
21 | { | ||
22 | } | ||
23 | //**************************************************************************** | ||
24 | void Menu::PianoScale::paintEvent(QPaintEvent* pe) | ||
25 | { | ||
26 | QPainter p(this); | ||
27 | QRect mysize=rect(); | ||
28 | |||
29 | int pad=10; | ||
30 | int x0=pad; | ||
31 | int y0=pad; | ||
32 | int w0=mysize.width()-2*pad; | ||
33 | int h0=mysize.height()-2*pad; | ||
34 | |||
35 | int keypad=2; | ||
36 | if(mysize.width()>mysize.height()) | ||
37 | { | ||
38 | int div=(int)(w0/14.0); | ||
39 | int halftonewidth=(int)(div/3.0); | ||
40 | int halftoneheight=(int)((h0-2*keypad)*0.66); | ||
41 | for(int a=0;a<14;a++) | ||
42 | { | ||
43 | int x=x0+a*div; | ||
44 | |||
45 | p.setPen(blackPen); | ||
46 | p.setBrush(blackBrush); | ||
47 | p.drawRect(x,y0,div,h0); | ||
48 | |||
49 | p.setPen(whitePen); | ||
50 | p.setBrush(whiteBrush); | ||
51 | p.drawRect(x+keypad,y0+keypad,div-2*keypad,h0-2*keypad); | ||
52 | |||
53 | if(a==1 || a==2 || a==4 || a==5 || a==6 || a==8 || a==9 || a==11 || a==12 || a==13) | ||
54 | { | ||
55 | p.setPen(blackPen); | ||
56 | p.setBrush(blackBrush); | ||
57 | p.drawRect(x-halftonewidth,y0+keypad,2*halftonewidth,halftoneheight); | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | else | ||
62 | { | ||
63 | int div=(int)(w0/7.0); | ||
64 | int halfheight=(int)(h0/2.0); | ||
65 | int halftonewidth=(int)(div/3.0); | ||
66 | int halftoneheight=(int)((halfheight-2*keypad)*0.66); | ||
67 | for(int a=0;a<7;a++) | ||
68 | { | ||
69 | int x=x0+a*div; | ||
70 | |||
71 | p.setPen(blackPen); | ||
72 | p.setBrush(blackBrush); | ||
73 | p.drawRect(x,y0,div,h0); | ||
74 | |||
75 | p.setPen(whitePen); | ||
76 | p.setBrush(whiteBrush); | ||
77 | p.drawRect(x+keypad,y0+keypad,div-2*keypad,halfheight-2*keypad); | ||
78 | p.drawRect(x+keypad,y0+keypad+halfheight,div-2*keypad,halfheight-2*keypad); | ||
79 | |||
80 | if(a==1 || a==2 || a==4 || a==5 || a==6) | ||
81 | { | ||
82 | p.setPen(blackPen); | ||
83 | p.setBrush(blackBrush); | ||
84 | p.drawRect(x-halftonewidth,y0+keypad,2*halftonewidth,halftoneheight); | ||
85 | p.drawRect(x-halftonewidth,y0+keypad+halfheight,2*halftonewidth,halftoneheight); | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | //**************************************************************************** | ||
91 | void Menu::PianoScale::mousePressEvent(QMouseEvent* me) | ||
92 | { | ||
93 | } | ||
94 | //**************************************************************************** | ||
95 | //**************************************************************************** | ||
96 | |||
diff --git a/noncore/multimedia/tonleiter/pianoscale.h b/noncore/multimedia/tonleiter/pianoscale.h new file mode 100644 index 0000000..63995b0 --- a/dev/null +++ b/noncore/multimedia/tonleiter/pianoscale.h | |||
@@ -0,0 +1,28 @@ | |||
1 | #ifndef TONLEITER_PIANO_SCALE_H | ||
2 | #define TONLEITER_PIANO_SCALE_H | ||
3 | |||
4 | #include <qwidget.h> | ||
5 | #include <qpen.h> | ||
6 | #include <qbrush.h> | ||
7 | |||
8 | namespace Menu | ||
9 | { | ||
10 | class PianoScale : public QWidget | ||
11 | { | ||
12 | Q_OBJECT | ||
13 | private: | ||
14 | QBrush blackBrush; | ||
15 | QBrush whiteBrush; | ||
16 | QBrush markBrush; | ||
17 | QPen blackPen; | ||
18 | QPen whitePen; | ||
19 | public: | ||
20 | PianoScale(QWidget* parent,const char* name="PianoScale",WFlags f=0); | ||
21 | ~PianoScale(); | ||
22 | private: | ||
23 | void paintEvent(QPaintEvent* pe); | ||
24 | void mousePressEvent(QMouseEvent* me); | ||
25 | }; | ||
26 | }; | ||
27 | |||
28 | #endif //TONLEITER_PIANO_SCALE_H | ||
diff --git a/noncore/multimedia/tonleiter/tonleiter.pro b/noncore/multimedia/tonleiter/tonleiter.pro index 2b0a798..c52ca19 100644 --- a/noncore/multimedia/tonleiter/tonleiter.pro +++ b/noncore/multimedia/tonleiter/tonleiter.pro | |||
@@ -1,13 +1,13 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | #CONFIG = qt warn_on debug | 2 | #CONFIG = qt warn_on debug |
3 | CONFIG = qt warn_on release | 3 | CONFIG = qt warn_on release |
4 | HEADERS = mainwidget.h tonleiterdata.h tonleiterdatahelper.h fretboard.h menuwidget.h editinst.h editscale.h | 4 | HEADERS = mainwidget.h tonleiterdata.h tonleiterdatahelper.h fretboard.h menuwidget.h editinst.h editstringwidget.h editscale.h pianoscale.h |
5 | SOURCES = mainwidget.cpp tonleiterdata.cpp tonleiterdatahelper.cpp fretboard.cpp menuwidget.cpp main.cpp editinst.cpp editscale.cpp | 5 | SOURCES = mainwidget.cpp tonleiterdata.cpp tonleiterdatahelper.cpp fretboard.cpp menuwidget.cpp main.cpp editinst.cpp editstringwidget.cpp editscale.cpp pianoscale.cpp |
6 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
7 | DEPENDPATH += $(OPIEDIR)/include | 7 | DEPENDPATH += $(OPIEDIR)/include |
8 | LIBS += -lqpe | 8 | LIBS += -lqpe |
9 | INTERFACES = | 9 | INTERFACES = |
10 | TARGET = tonleiter | 10 | TARGET = tonleiter |
11 | DESTDIR = $(OPIEDIR)/bin | 11 | DESTDIR = $(OPIEDIR)/bin |
12 | #TMAKE_CXXFLAGS += -DQT_QWS_VERCEL_IDR -DQWS -fno-exceptions -fno-rtti | 12 | #TMAKE_CXXFLAGS += -DQT_QWS_VERCEL_IDR -DQWS -fno-exceptions -fno-rtti |
13 | include ( $(OPIEDIR)/include.pro ) | 13 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/multimedia/tonleiter/tonleiterdata.cpp b/noncore/multimedia/tonleiter/tonleiterdata.cpp index 946d4e3..bf7b32c 100644 --- a/noncore/multimedia/tonleiter/tonleiterdata.cpp +++ b/noncore/multimedia/tonleiter/tonleiterdata.cpp | |||
@@ -26,97 +26,97 @@ void TonleiterData::setCurrentInstrumetID(int id) | |||
26 | } | 26 | } |
27 | } | 27 | } |
28 | //**************************************************************************** | 28 | //**************************************************************************** |
29 | void TonleiterData::setCurrentScaleID(int id) | 29 | void TonleiterData::setCurrentScaleID(int id) |
30 | { | 30 | { |
31 | if(id>=0 && id<noOfScales()) | 31 | if(id>=0 && id<noOfScales()) |
32 | { | 32 | { |
33 | currentScaleID=id; | 33 | currentScaleID=id; |
34 | emit dataChange(); | 34 | emit dataChange(); |
35 | } | 35 | } |
36 | } | 36 | } |
37 | //**************************************************************************** | 37 | //**************************************************************************** |
38 | void TonleiterData::setCurrentNote(int id) | 38 | void TonleiterData::setCurrentNote(int id) |
39 | { | 39 | { |
40 | if(id>=0 && id<12) | 40 | if(id>=0 && id<12) |
41 | { | 41 | { |
42 | currentNote=id; | 42 | currentNote=id; |
43 | emit dataChange(); | 43 | emit dataChange(); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | //**************************************************************************** | 46 | //**************************************************************************** |
47 | void TonleiterData::setDrawNames(bool dn) | 47 | void TonleiterData::setDrawNames(bool dn) |
48 | { | 48 | { |
49 | drawnames=dn; | 49 | drawnames=dn; |
50 | emit dataChange(); | 50 | emit dataChange(); |
51 | } | 51 | } |
52 | //**************************************************************************** | 52 | //**************************************************************************** |
53 | void TonleiterData::loadData() | 53 | void TonleiterData::loadData() |
54 | { | 54 | { |
55 | Config load("Tonleiter"); | 55 | Config load("Tonleiter"); |
56 | if(!load.isValid()) | 56 | if(!load.isValid()) |
57 | { | 57 | { |
58 | //write some default values | 58 | //write some default values |
59 | load.setGroup("General"); | 59 | load.setGroup("General"); |
60 | load.writeEntry("currentInstrumentID",1); | 60 | load.writeEntry("currentInstrumentID",1); |
61 | load.writeEntry("currentNote",0); | 61 | load.writeEntry("currentNote",0); |
62 | load.writeEntry("currentScaleID",1); | 62 | load.writeEntry("currentScaleID",1); |
63 | load.writeEntry("drawnames",1); | 63 | load.writeEntry("drawnames",1); |
64 | load.setGroup("Instrument"); | 64 | load.setGroup("Instrument"); |
65 | load.writeEntry("Inst0","Thumb6;26;11;16;21;26;31;36;"); | 65 | load.writeEntry("Inst0","Thumb6;26;11;16;21;26;31;36;"); |
66 | load.writeEntry("Inst1","Bass 4;12;16;21;26;31;"); | 66 | load.writeEntry("Inst1","Bass 4;12;16;21;26;31;"); |
67 | load.writeEntry("noOfInstruments",2); | 67 | load.writeEntry("noOfInstruments",2); |
68 | load.setGroup("Scale"); | 68 | load.setGroup("Scale"); |
69 | load.writeEntry("Scale0","ionian;0;2;4;5;7;9;11;"); | 69 | load.writeEntry("Scale0","ionian;0;2;4;5;7;9;11;"); |
70 | load.writeEntry("Scale1","aeolian;0;2;3;5;7;8;10;"); | 70 | load.writeEntry("Scale1","aeolian;0;2;3;5;7;8;10;"); |
71 | load.writeEntry("Scale2","dorian;0;2;3;5;7;9;10;"); | 71 | load.writeEntry("Scale2","dorian;0;2;3;5;7;9;10;"); |
72 | load.writeEntry("Scale3","phrygian;0;1;3;5;7;8;10;"); | 72 | load.writeEntry("Scale3","phrygian;0;1;3;5;7;8;10;"); |
73 | load.writeEntry("Scale4","lydian;0;2;4;6;7;9;11;"); | 73 | load.writeEntry("Scale4","lydian;0;2;4;6;7;9;11;"); |
74 | load.writeEntry("Scale5","mixolyd.;0;2;4;5;7;9;10;"); | 74 | load.writeEntry("Scale5","mixolydian;0;2;4;5;7;9;10;"); |
75 | load.writeEntry("noOfScales",6); | 75 | load.writeEntry("noOfScales",6); |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | load.setGroup("General"); | 79 | load.setGroup("General"); |
80 | currentNote=load.readNumEntry("currentNote"); | 80 | currentNote=load.readNumEntry("currentNote"); |
81 | drawnames=load.readBoolEntry("drawnames"); | 81 | drawnames=load.readBoolEntry("drawnames"); |
82 | currentInstrumentID=load.readNumEntry("currentInstrumentID"); | 82 | currentInstrumentID=load.readNumEntry("currentInstrumentID"); |
83 | currentScaleID=load.readNumEntry("currentScaleID"); | 83 | currentScaleID=load.readNumEntry("currentScaleID"); |
84 | 84 | ||
85 | load.setGroup("Instrument"); | 85 | load.setGroup("Instrument"); |
86 | int noOfInstr=load.readNumEntry("noOfInstruments",0); | 86 | int noOfInstr=load.readNumEntry("noOfInstruments",0); |
87 | for(int i=0;i<noOfInstr;i++) | 87 | for(int i=0;i<noOfInstr;i++) |
88 | { | 88 | { |
89 | QStringList instlist=load.readListEntry("Inst"+QString::number(i),';'); | 89 | QStringList instlist=load.readListEntry("Inst"+QString::number(i),';'); |
90 | QValueList<int> strings; | 90 | QValueList<int> strings; |
91 | for(int st=2;st<(int)instlist.count();st++) | 91 | for(int st=2;st<(int)instlist.count();st++) |
92 | strings.append(instlist[st].toInt()); | 92 | strings.append(instlist[st].toInt()); |
93 | instruments.append(Instrument(instlist[0],instlist[1].toInt(),strings)); | 93 | instruments.append(Instrument(instlist[0],instlist[1].toInt(),strings)); |
94 | } | 94 | } |
95 | 95 | ||
96 | load.setGroup("Scale"); | 96 | load.setGroup("Scale"); |
97 | int scaleno=load.readNumEntry("noOfScales",0); | 97 | int scaleno=load.readNumEntry("noOfScales",0); |
98 | for(int s=0;s<scaleno;s++) | 98 | for(int s=0;s<scaleno;s++) |
99 | { | 99 | { |
100 | QStringList scalelist=load.readListEntry("Scale"+QString::number(s),';'); | 100 | QStringList scalelist=load.readListEntry("Scale"+QString::number(s),';'); |
101 | QValueList<int> halftones; | 101 | QValueList<int> halftones; |
102 | for(int ht=1;ht<(int)scalelist.count();ht++) | 102 | for(int ht=1;ht<(int)scalelist.count();ht++) |
103 | halftones.append(scalelist[ht].toInt()); | 103 | halftones.append(scalelist[ht].toInt()); |
104 | scales.append(Scale(scalelist[0],halftones)); | 104 | scales.append(Scale(scalelist[0],halftones)); |
105 | } | 105 | } |
106 | 106 | ||
107 | } | 107 | } |
108 | //**************************************************************************** | 108 | //**************************************************************************** |
109 | void TonleiterData::saveData() | 109 | void TonleiterData::saveData() |
110 | { | 110 | { |
111 | Config save("Tonleiter"); | 111 | Config save("Tonleiter"); |
112 | save.setGroup("General"); | 112 | save.setGroup("General"); |
113 | save.writeEntry("currentNote",currentNote); | 113 | save.writeEntry("currentNote",currentNote); |
114 | save.writeEntry("drawnames",drawnames); | 114 | save.writeEntry("drawnames",drawnames); |
115 | save.writeEntry("currentInstrumentID",currentInstrumentID); | 115 | save.writeEntry("currentInstrumentID",currentInstrumentID); |
116 | save.writeEntry("currentScaleID",currentScaleID); | 116 | save.writeEntry("currentScaleID",currentScaleID); |
117 | 117 | ||
118 | save.setGroup("Instrument"); | 118 | save.setGroup("Instrument"); |
119 | save.writeEntry("noOfInstruments",noOfInstruments()); | 119 | save.writeEntry("noOfInstruments",noOfInstruments()); |
120 | for(int i=0;i<noOfInstruments();i++) | 120 | for(int i=0;i<noOfInstruments();i++) |
121 | { | 121 | { |
122 | QStringList instlist; | 122 | QStringList instlist; |
diff --git a/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp b/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp index 5714cea..156dba5 100644 --- a/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp +++ b/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp | |||
@@ -1,127 +1,129 @@ | |||
1 | #include "tonleiterdatahelper.h" | 1 | #include "tonleiterdatahelper.h" |
2 | 2 | ||
3 | #include <math.h> | ||
4 | |||
3 | using namespace Data; | 5 | using namespace Data; |
4 | 6 | ||
5 | int Note::getOctaveOfNote(int note) | 7 | int Note::getOctaveOfNote(int note) |
6 | { | 8 | { |
7 | int remain=note%12; | 9 | int remain=note%12; |
8 | return (note-remain)/12; | 10 | return (note-remain)/12; |
9 | } | 11 | } |
10 | //**************************************************************************** | 12 | //**************************************************************************** |
11 | QString Note::getNameOfNote(int note) | 13 | QString Note::getNameOfNote(int note) |
12 | { | 14 | { |
13 | int octave=getOctaveOfNote(note); | 15 | int octave=getOctaveOfNote(note); |
14 | return notenames[note-12*octave]; | 16 | return notenames[note-12*octave]; |
15 | } | 17 | } |
16 | //**************************************************************************** | 18 | //**************************************************************************** |
17 | int Note::getNoteFromName(QString name,int octave) | 19 | int Note::getNoteFromName(QString name,int octave) |
18 | { | 20 | { |
19 | int notevalue=0; | 21 | int notevalue=0; |
20 | for(int a=0;a<12;a++) | 22 | for(int a=0;a<12;a++) |
21 | { | 23 | { |
22 | if(name==notenames[a]) | 24 | if(name==notenames[a]) |
23 | { | 25 | { |
24 | notevalue=a; | 26 | notevalue=a; |
25 | break; | 27 | break; |
26 | } | 28 | } |
27 | } | 29 | } |
28 | return notevalue+12*octave; | 30 | return notevalue+12*octave; |
29 | } | 31 | } |
30 | //**************************************************************************** | 32 | //**************************************************************************** |
31 | int Note::octaveOfBaseNote(int base,int note) | 33 | int Note::octaveOfBaseNote(int base,int note) |
32 | { | 34 | { |
33 | int normnote = (note>=base) ? note-base : (12-base)+note; | 35 | int normnote = (note>=base) ? note-base : (12-base)+note; |
34 | int octave=getOctaveOfNote(normnote); | 36 | int octave=getOctaveOfNote(normnote); |
35 | //qDebug("note %d of %d base is norm %d -> ocatve %d",note,base,normnote,octave); | 37 | //qDebug("note %d of %d base is norm %d -> ocatve %d",note,base,normnote,octave); |
36 | return octave; | 38 | return octave; |
37 | } | 39 | } |
38 | //**************************************************************************** | 40 | //**************************************************************************** |
39 | //**************************************************************************** | 41 | //**************************************************************************** |
40 | Instrument::Instrument() | 42 | Instrument::Instrument() |
41 | { | 43 | { |
42 | name="UNDEFINED"; | 44 | name="UNDEFINED"; |
43 | frets=0; | 45 | frets=0; |
44 | } | 46 | } |
45 | //**************************************************************************** | 47 | //**************************************************************************** |
46 | Instrument::Instrument(QString name,int frets,QValueList<int> strings) | 48 | Instrument::Instrument(QString name,int frets,QValueList<int> strings) |
47 | :name(name),frets(frets),strings(strings) | 49 | :name(name),frets(frets),strings(strings) |
48 | { | 50 | { |
49 | } | 51 | } |
50 | //**************************************************************************** | 52 | //**************************************************************************** |
51 | Instrument::~Instrument() | 53 | Instrument::~Instrument() |
52 | { | 54 | { |
53 | } | 55 | } |
54 | //**************************************************************************** | 56 | //**************************************************************************** |
55 | int Instrument::noOfStrings() | 57 | int Instrument::noOfStrings() |
56 | { | 58 | { |
57 | return (int)strings.count(); | 59 | return (int)strings.count(); |
58 | } | 60 | } |
59 | //**************************************************************************** | 61 | //**************************************************************************** |
60 | int Instrument::noOfFrets() | 62 | int Instrument::noOfFrets() |
61 | { | 63 | { |
62 | return frets; | 64 | return frets; |
63 | } | 65 | } |
64 | //**************************************************************************** | 66 | //**************************************************************************** |
65 | QString Instrument::instName() | 67 | QString Instrument::instName() |
66 | { | 68 | { |
67 | return name; | 69 | return name; |
68 | } | 70 | } |
69 | //**************************************************************************** | 71 | //**************************************************************************** |
70 | int Instrument::string(int id) | 72 | int Instrument::string(int id) |
71 | { | 73 | { |
72 | return strings[id]; | 74 | return strings[id]; |
73 | } | 75 | } |
74 | //**************************************************************************** | 76 | //**************************************************************************** |
75 | int Instrument::noOfOctaves() | 77 | int Instrument::noOfOctaves() |
76 | { | 78 | { |
77 | int lowest=strings[0]; | 79 | int lowest=strings[0]; |
78 | int highest=strings[strings.count()-1]+frets; | 80 | int highest=strings[strings.count()-1]+frets; |
79 | return (int)((highest-lowest)/12.0); | 81 | return (int) ceil((highest-lowest)/12.0); |
80 | } | 82 | } |
81 | //**************************************************************************** | 83 | //**************************************************************************** |
82 | //**************************************************************************** | 84 | //**************************************************************************** |
83 | Scale::Scale() | 85 | Scale::Scale() |
84 | { | 86 | { |
85 | name="UNDEFINED"; | 87 | name="UNDEFINED"; |
86 | } | 88 | } |
87 | //**************************************************************************** | 89 | //**************************************************************************** |
88 | Scale::Scale(QString name,QValueList<int> halftones) | 90 | Scale::Scale(QString name,QValueList<int> halftones) |
89 | :name(name),halftones(halftones) | 91 | :name(name),halftones(halftones) |
90 | { | 92 | { |
91 | } | 93 | } |
92 | //**************************************************************************** | 94 | //**************************************************************************** |
93 | Scale::~Scale() | 95 | Scale::~Scale() |
94 | { | 96 | { |
95 | } | 97 | } |
96 | //**************************************************************************** | 98 | //**************************************************************************** |
97 | int Scale::noOfHaltones() | 99 | int Scale::noOfHaltones() |
98 | { | 100 | { |
99 | return (int)halftones.count(); | 101 | return (int)halftones.count(); |
100 | } | 102 | } |
101 | //**************************************************************************** | 103 | //**************************************************************************** |
102 | int Scale::getHalfTone(int id) | 104 | int Scale::getHalfTone(int id) |
103 | { | 105 | { |
104 | if(id>=0 && id<noOfHaltones()) | 106 | if(id>=0 && id<noOfHaltones()) |
105 | return halftones[id]; | 107 | return halftones[id]; |
106 | else | 108 | else |
107 | return 0; | 109 | return 0; |
108 | } | 110 | } |
109 | //**************************************************************************** | 111 | //**************************************************************************** |
110 | QString Scale::scaleName() | 112 | QString Scale::scaleName() |
111 | { | 113 | { |
112 | return name; | 114 | return name; |
113 | } | 115 | } |
114 | //**************************************************************************** | 116 | //**************************************************************************** |
115 | bool Scale::noteInScale(int base,int note) | 117 | bool Scale::noteInScale(int base,int note) |
116 | { | 118 | { |
117 | int octave=Note::getOctaveOfNote(note); | 119 | int octave=Note::getOctaveOfNote(note); |
118 | note-=12*octave; | 120 | note-=12*octave; |
119 | int normnote = (note>=base) ? note-base : (12-base)+note; | 121 | int normnote = (note>=base) ? note-base : (12-base)+note; |
120 | 122 | ||
121 | if(halftones.contains(normnote)>0) | 123 | if(halftones.contains(normnote)>0) |
122 | { | 124 | { |
123 | //qDebug("OK : base : %d, note %d -> norm %d",base,note,normnote); | 125 | //qDebug("OK : base : %d, note %d -> norm %d",base,note,normnote); |
124 | return true; | 126 | return true; |
125 | } | 127 | } |
126 | else | 128 | else |
127 | { | 129 | { |
diff --git a/noncore/multimedia/tonleiter/tonleiterdatahelper.h b/noncore/multimedia/tonleiter/tonleiterdatahelper.h index b79162a..e4153d7 100644 --- a/noncore/multimedia/tonleiter/tonleiterdatahelper.h +++ b/noncore/multimedia/tonleiter/tonleiterdatahelper.h | |||
@@ -1,55 +1,55 @@ | |||
1 | #ifndef TONLEITER_DATA_HELPER_H | 1 | #ifndef TONLEITER_DATA_HELPER_H |
2 | #define TONLEITER_DATA_HELPER_H | 2 | #define TONLEITER_DATA_HELPER_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qvaluelist.h> | 5 | #include <qvaluelist.h> |
6 | 6 | ||
7 | namespace Data | 7 | namespace Data |
8 | { | 8 | { |
9 | namespace Note | 9 | namespace Note |
10 | { | 10 | { |
11 | const QString notenames[]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"}; | 11 | const QString notenames[]={"A","Bb","B","C","C#","D","D#","E","F","F#","G","G#"}; |
12 | 12 | ||
13 | int getOctaveOfNote(int note); | 13 | int getOctaveOfNote(int note); |
14 | QString getNameOfNote(int note); | 14 | QString getNameOfNote(int note); |
15 | int getNoteFromName(QString name,int octave); | 15 | int getNoteFromName(QString name,int octave); |
16 | int octaveOfBaseNote(int base,int note); | 16 | int octaveOfBaseNote(int base,int note); |
17 | }; | 17 | }; |
18 | 18 | ||
19 | class Instrument | 19 | class Instrument |
20 | { | 20 | { |
21 | private: | 21 | private: |
22 | QString name; | 22 | QString name; |
23 | int frets; | 23 | int frets; |
24 | QValueList<int> strings; | 24 | QValueList<int> strings; |
25 | public: | 25 | public: |
26 | Instrument(); | 26 | Instrument(); |
27 | Instrument(QString name,int frets,QValueList<int> strings); | 27 | Instrument(QString name,int frets,QValueList<int> strings); |
28 | ~Instrument(); | 28 | ~Instrument(); |
29 | public: | 29 | public: |
30 | int noOfStrings(); | 30 | int noOfStrings(); |
31 | int noOfFrets(); | 31 | int noOfFrets(); |
32 | QString instName(); | 32 | QString instName(); |
33 | int string(int id); | 33 | int string(int id); |
34 | int noOfOctaves(); | 34 | int noOfOctaves(); |
35 | }; | 35 | }; |
36 | 36 | ||
37 | class Scale | 37 | class Scale |
38 | { | 38 | { |
39 | private: | 39 | private: |
40 | QValueList<int> halftones; | 40 | QValueList<int> halftones; |
41 | QString name; | 41 | QString name; |
42 | public: | 42 | public: |
43 | Scale(); | 43 | Scale(); |
44 | Scale(QString name,QValueList<int> halftones); | 44 | Scale(QString name,QValueList<int> halftones); |
45 | ~Scale(); | 45 | ~Scale(); |
46 | public: | 46 | public: |
47 | int noOfHaltones(); | 47 | int noOfHaltones(); |
48 | int getHalfTone(int id); | 48 | int getHalfTone(int id); |
49 | QString scaleName(); | 49 | QString scaleName(); |
50 | bool noteInScale(int base,int note); | 50 | bool noteInScale(int base,int note); |
51 | }; | 51 | }; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | #endif //TONLEITER_DATA_HELPER_H | 54 | #endif //TONLEITER_DATA_HELPER_H |
55 | 55 | ||