author | waspe <waspe> | 2003-12-02 19:03:50 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-12-02 19:03:50 (UTC) |
commit | 64304e555fc3e06aa69fa2f4a514ee55b7aa98bc (patch) (side-by-side diff) | |
tree | 3ce47189f43f18cccd42d326cf52977b339c744d /noncore/multimedia/tonleiter | |
parent | 7b74f202db22d458c43b2063ae128bf79b0e9777 (diff) | |
download | opie-64304e555fc3e06aa69fa2f4a514ee55b7aa98bc.zip opie-64304e555fc3e06aa69fa2f4a514ee55b7aa98bc.tar.gz opie-64304e555fc3e06aa69fa2f4a514ee55b7aa98bc.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'noncore/multimedia/tonleiter') (more/less context) (ignore whitespace changes)
-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 @@ #include "editinst.h" +#include <qlabel.h> +#include <qpushbutton.h> + Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const char* name) :QDialog(parent,name,true,0),data(data) { setCaption("Tonleiter::"+tr("Instrument")); + QBoxLayout* masterlayout=new QBoxLayout(this,QBoxLayout::TopToBottom); + instid=data->getCurrentInstrumentID(); + stringlist.setAutoDelete(true); + + QBoxLayout* toplayout=new QBoxLayout(masterlayout,QBoxLayout::LeftToRight); + + //Name combo + Add + Delete + boxInst=new QComboBox(this,"boxInst"); + boxInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); + connect(boxInst,SIGNAL(activated(int)),this,SLOT(setCurrentInstrumetID(int))); + for(int i=0;i<data->noOfInstruments();i++) + { + Instrument inst=data->getInstrument(i); + QString name=inst.instName(); + if(name.isNull()) continue; + boxInst->insertItem(name,i); + } + boxInst->setCurrentItem(instid); + toplayout->addWidget(boxInst); + + QPushButton* addButton=new QPushButton(tr("Add"),this,"addButton"); + connect(addButton,SIGNAL(pressed()),this,SLOT(addInstrument())); + toplayout->addWidget(addButton); + + QPushButton* delButton=new QPushButton(tr("Delete"),this,"delButton"); + connect(delButton,SIGNAL(pressed()),this,SLOT(deleteInstrument())); + toplayout->addWidget(delButton); + + QPushButton* addhighButton=new QPushButton(tr("Add High String"),this,"addhighButton"); + masterlayout->addWidget(addhighButton); + + QScrollView* scrollview=new QScrollView(this); + scrollview->setVScrollBarMode(QScrollView::AlwaysOn); + scrollview->setHScrollBarMode(QScrollView::AlwaysOff); + stringwidget=new QVBox(scrollview->viewport()); + stringwidget->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum)); + stringwidget->setSpacing(10); + scrollview->addChild(stringwidget); + scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); + //scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding)); + masterlayout->addWidget(scrollview); + + loadInstrument(); + + QPushButton* addlowButton=new QPushButton(tr("Add Low String"),this,"addlowButton"); + masterlayout->addWidget(addlowButton); + + //make dialog fit the screen showMaximized(); } //**************************************************************************** Menu::InstEditDialog::~InstEditDialog() { } //**************************************************************************** +void Menu::InstEditDialog::setCurrentInstrumetID(int id) +{ + saveInstrument(); + instid=id; + data->setCurrentInstrumetID(id); + loadInstrument(); +} +//**************************************************************************** +void Menu::InstEditDialog::addInstrument() +{ +} +//**************************************************************************** +void Menu::InstEditDialog::deleteInstrument() +{ +} +//**************************************************************************** +void Menu::InstEditDialog::addLowString() +{ +} +//**************************************************************************** +void Menu::InstEditDialog::addHighString() +{ +} +//**************************************************************************** +void Menu::InstEditDialog::deleteString(int id) +{ +} +//**************************************************************************** +void Menu::InstEditDialog::saveInstrument() +{ + stringlist.clear(); +} +//**************************************************************************** +void Menu::InstEditDialog::loadInstrument() +{ + Instrument inst=data->getInstrument(instid); + for(uint s=0;s<inst.noOfStrings();s++) + { + stringlist.append(new EditStringWidget(inst.string(s),stringwidget)); + } +} +//**************************************************************************** //**************************************************************************** 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 @@ #ifndef TONLEITER_EDIT_INSTRUMENT_DIALOG_H #define TONLEITER_EDIT_INSTRUMENT_DIALOG_H #include <qdialog.h> +#include <qcombobox.h> +#include <qscrollview.h> +#include <qspinbox.h> +#include <qlayout.h> +#include <qlist.h> +#include <qvbox.h> -#include "tonleiterdata.h" + +#include "editstringwidget.h" using namespace Data; + namespace Menu { class InstEditDialog : public QDialog { Q_OBJECT private: TonleiterData* data; + int instid; + + QComboBox* boxInst; + QSpinBox* stringBox; + + QVBox* stringwidget; + + //this is a QPtrList !! + typedef QList<EditStringWidget> StringWidgetList; + StringWidgetList stringlist; public: InstEditDialog(TonleiterData* data,QWidget* parent,const char* name="InstEditDialog"); ~InstEditDialog(); + private slots: + void setCurrentInstrumetID(int id); + void addInstrument(); + void deleteInstrument(); + + void addLowString(); + void addHighString(); + void deleteString(int id); + private: + void saveInstrument(); + void loadInstrument(); }; }; #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 @@ #include "editscale.h" +#include <qlayout.h> +#include <qpushbutton.h> + Menu::ScaleEditDialog::ScaleEditDialog(TonleiterData* data,QWidget* parent,const char* name) :QDialog(parent,name,true,0),data(data) { setCaption("Tonleiter::"+tr("Scale")); + QBoxLayout* masterlayout=new QBoxLayout(this,QBoxLayout::TopToBottom); + + QBoxLayout* toplayout=new QBoxLayout(masterlayout,QBoxLayout::LeftToRight); + + boxScale=new QComboBox(this,"boxScale"); + for(int s=0;s<data->noOfScales();s++) + { + Scale scale=data->getScale(s); + QString name=scale.scaleName(); + if(name.isNull()) continue; + //boxScale->insertItem(name,s); + } + boxScale->setCurrentItem(data->getCurrentScaleID()); + boxScale->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); + connect(boxScale,SIGNAL(activated(int)),data,SLOT(setCurrentScaleID(int))); + toplayout->addWidget(boxScale); + + QPushButton* addButton=new QPushButton(tr("Add"),this,"addButton"); + connect(addButton,SIGNAL(pressed()),this,SLOT(addInstrument())); + toplayout->addWidget(addButton); + + QPushButton* delButton=new QPushButton(tr("Delete"),this,"delButton"); + connect(delButton,SIGNAL(pressed()),this,SLOT(deleteInstrument())); + toplayout->addWidget(delButton); + + pianoscale=new PianoScale(this); + masterlayout->addWidget(pianoscale); + + //make dialog fit the screen showMaximized(); } //**************************************************************************** Menu::ScaleEditDialog::~ScaleEditDialog() { } //**************************************************************************** //**************************************************************************** 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 @@ #ifndef TONLEITER_EDIT_SCALE_DIALOG_H #define TONLEITER_EDIT_SCALE_DIALOG_H #include <qdialog.h> +#include <qcombobox.h> #include "tonleiterdata.h" +#include "pianoscale.h" using namespace Data; namespace Menu { class ScaleEditDialog : public QDialog { Q_OBJECT private: TonleiterData* data; + QComboBox* boxScale; + PianoScale* pianoscale; public: ScaleEditDialog(TonleiterData* data,QWidget* parent,const char* name="ScaleEditDialog"); ~ScaleEditDialog(); }; }; #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 @@ +#include "editstringwidget.h" + +#include <qlabel.h> +#include <qlayout.h> + +using namespace Data; + +Menu::EditStringWidget::EditStringWidget(int note,QWidget* parent,const char* name,WFlags f) +:QFrame(parent,name,f) +{ + QBoxLayout* layout=new QBoxLayout(this,QBoxLayout::LeftToRight,10); + + boxNote=new QComboBox(this,"boxNote"); + boxNote->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); + //connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); + layout->addWidget(boxNote,1,1); + for(int a=0;a<12;a++) + boxNote->insertItem(Note::notenames[a],a); + boxNote->setCurrentItem(note-12*Note::getOctaveOfNote(note)); + layout->addWidget(boxNote); + + setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); + setFrameShape(QFrame::Panel); + setFrameShadow(QFrame::Sunken); + +} +//**************************************************************************** +Menu::EditStringWidget::~EditStringWidget() +{ +} +//**************************************************************************** +//**************************************************************************** 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 @@ +#ifndef TONLEITER_EDIT_STRING_WIDGT_H +#define TONLEITER_EDIT_STRING_WIDGT_H + +#include <qframe.h> +#include <qcombobox.h> +#include <qspinbox.h> + +#include "tonleiterdata.h" + +namespace Menu +{ + class EditStringWidget : public QFrame + { + Q_OBJECT + private: + QComboBox* boxNote; + public: + EditStringWidget(int note,QWidget* parent,const char* name=0,WFlags f=0); + ~EditStringWidget(); + }; +}; + +#endif //TONLEITER_EDIT_STRING_WIDGT_H + 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,70 +1,88 @@ #include "menuwidget.h" #include <qlabel.h> #include <qlayout.h> #include "editinst.h" #include "editscale.h" Menu::MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFlags f) :QWidget(parent,name,f),data(data) { QGridLayout* layout=new QGridLayout(this,3,3,10,-1,"menulayout"); + //Instrument QLabel* instLabel=new QLabel(tr("Instr."),this,"instLabel"); + instLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); layout->addWidget(instLabel,0,0); + boxInst=new QComboBox(this,"boxInst"); + boxInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); connect(boxInst,SIGNAL(activated(int)),data,SLOT(setCurrentInstrumetID(int))); layout->addWidget(boxInst,0,1); + editInst=new QPushButton(tr("Edit"),this,"editInst"); + editInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); connect(editInst,SIGNAL(pressed()),this,SLOT(editInstPressed())); layout->addWidget(editInst,0,2); + //Note QLabel* noteLabel=new QLabel(tr("Note"),this,"noteLabel"); + noteLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); layout->addWidget(noteLabel,1,0); + boxNote=new QComboBox(this,"boxNote"); + boxNote->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); layout->addWidget(boxNote,1,1); for(int a=0;a<12;a++) boxNote->insertItem(Note::notenames[a],a); boxNote->setCurrentItem(data->getCurrentBaseNote()); + noteCheck=new QCheckBox(tr("show"),this,"noteCheck"); + noteCheck->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); noteCheck->setChecked(data->isDrawNames()); connect(noteCheck,SIGNAL(toggled(bool)),data,SLOT(setDrawNames(bool))); layout->addWidget(noteCheck,1,2); + //Scale QLabel* scaleLabel=new QLabel(tr("Scale"),this,"scaleLabel"); + scaleLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); layout->addWidget(scaleLabel,2,0); + boxScale=new QComboBox(this,"boxScale"); + boxScale->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); connect(boxScale,SIGNAL(activated(int)),data,SLOT(setCurrentScaleID(int))); layout->addWidget(boxScale,2,1); + editScale=new QPushButton(tr("Edit"),this,"editScale"); + editScale->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); connect(editScale,SIGNAL(pressed()),this,SLOT(editScalePressed())); layout->addWidget(editScale,2,2); updateBoxes(); - + setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); } //**************************************************************************** Menu::MenuWidget::~MenuWidget() { } //**************************************************************************** void Menu::MenuWidget::editInstPressed() { InstEditDialog* instdialog=new InstEditDialog(data,this); instdialog->exec(); } //**************************************************************************** void Menu::MenuWidget::editScalePressed() { ScaleEditDialog* scaledialog=new ScaleEditDialog(data,this); scaledialog->exec(); } //**************************************************************************** void Menu::MenuWidget::updateBoxes() { boxInst->clear(); for(int i=0;i<data->noOfInstruments();i++) { 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 @@ +#include "pianoscale.h" + +#include <qpainter.h> + + +Menu::PianoScale::PianoScale(QWidget* parent,const char* name,WFlags f) +:QWidget(parent,name,f) +{ + QColor black(0,0,0); + QColor white(255,255,255); + QColor mark(255,0,0); + blackBrush=QBrush(black); + whiteBrush=QBrush(white); + markBrush=QBrush(mark); + blackPen=QPen(black); + whitePen=QPen(white); + setBackgroundColor(QColor(0,0,255)); +} +//**************************************************************************** +Menu::PianoScale::~ PianoScale() +{ +} +//**************************************************************************** +void Menu::PianoScale::paintEvent(QPaintEvent* pe) +{ + QPainter p(this); + QRect mysize=rect(); + + int pad=10; + int x0=pad; + int y0=pad; + int w0=mysize.width()-2*pad; + int h0=mysize.height()-2*pad; + + int keypad=2; + if(mysize.width()>mysize.height()) + { + int div=(int)(w0/14.0); + int halftonewidth=(int)(div/3.0); + int halftoneheight=(int)((h0-2*keypad)*0.66); + for(int a=0;a<14;a++) + { + int x=x0+a*div; + + p.setPen(blackPen); + p.setBrush(blackBrush); + p.drawRect(x,y0,div,h0); + + p.setPen(whitePen); + p.setBrush(whiteBrush); + p.drawRect(x+keypad,y0+keypad,div-2*keypad,h0-2*keypad); + + if(a==1 || a==2 || a==4 || a==5 || a==6 || a==8 || a==9 || a==11 || a==12 || a==13) + { + p.setPen(blackPen); + p.setBrush(blackBrush); + p.drawRect(x-halftonewidth,y0+keypad,2*halftonewidth,halftoneheight); + } + } + } + else + { + int div=(int)(w0/7.0); + int halfheight=(int)(h0/2.0); + int halftonewidth=(int)(div/3.0); + int halftoneheight=(int)((halfheight-2*keypad)*0.66); + for(int a=0;a<7;a++) + { + int x=x0+a*div; + + p.setPen(blackPen); + p.setBrush(blackBrush); + p.drawRect(x,y0,div,h0); + + p.setPen(whitePen); + p.setBrush(whiteBrush); + p.drawRect(x+keypad,y0+keypad,div-2*keypad,halfheight-2*keypad); + p.drawRect(x+keypad,y0+keypad+halfheight,div-2*keypad,halfheight-2*keypad); + + if(a==1 || a==2 || a==4 || a==5 || a==6) + { + p.setPen(blackPen); + p.setBrush(blackBrush); + p.drawRect(x-halftonewidth,y0+keypad,2*halftonewidth,halftoneheight); + p.drawRect(x-halftonewidth,y0+keypad+halfheight,2*halftonewidth,halftoneheight); + } + } + } +} +//**************************************************************************** +void Menu::PianoScale::mousePressEvent(QMouseEvent* me) +{ +} +//**************************************************************************** +//**************************************************************************** + 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 @@ +#ifndef TONLEITER_PIANO_SCALE_H +#define TONLEITER_PIANO_SCALE_H + +#include <qwidget.h> +#include <qpen.h> +#include <qbrush.h> + +namespace Menu +{ + class PianoScale : public QWidget + { + Q_OBJECT + private: + QBrush blackBrush; + QBrush whiteBrush; + QBrush markBrush; + QPen blackPen; + QPen whitePen; + public: + PianoScale(QWidget* parent,const char* name="PianoScale",WFlags f=0); + ~PianoScale(); + private: + void paintEvent(QPaintEvent* pe); + void mousePressEvent(QMouseEvent* me); + }; +}; + +#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 @@ TEMPLATE = app #CONFIG = qt warn_on debug CONFIG = qt warn_on release -HEADERS = mainwidget.h tonleiterdata.h tonleiterdatahelper.h fretboard.h menuwidget.h editinst.h editscale.h -SOURCES = mainwidget.cpp tonleiterdata.cpp tonleiterdatahelper.cpp fretboard.cpp menuwidget.cpp main.cpp editinst.cpp editscale.cpp +HEADERS = mainwidget.h tonleiterdata.h tonleiterdatahelper.h fretboard.h menuwidget.h editinst.h editstringwidget.h editscale.h pianoscale.h +SOURCES = mainwidget.cpp tonleiterdata.cpp tonleiterdatahelper.cpp fretboard.cpp menuwidget.cpp main.cpp editinst.cpp editstringwidget.cpp editscale.cpp pianoscale.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe INTERFACES = TARGET = tonleiter DESTDIR = $(OPIEDIR)/bin #TMAKE_CXXFLAGS += -DQT_QWS_VERCEL_IDR -DQWS -fno-exceptions -fno-rtti 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 @@ -50,49 +50,49 @@ void TonleiterData::setDrawNames(bool dn) emit dataChange(); } //**************************************************************************** void TonleiterData::loadData() { Config load("Tonleiter"); if(!load.isValid()) { //write some default values load.setGroup("General"); load.writeEntry("currentInstrumentID",1); load.writeEntry("currentNote",0); load.writeEntry("currentScaleID",1); load.writeEntry("drawnames",1); load.setGroup("Instrument"); load.writeEntry("Inst0","Thumb6;26;11;16;21;26;31;36;"); load.writeEntry("Inst1","Bass 4;12;16;21;26;31;"); load.writeEntry("noOfInstruments",2); load.setGroup("Scale"); load.writeEntry("Scale0","ionian;0;2;4;5;7;9;11;"); load.writeEntry("Scale1","aeolian;0;2;3;5;7;8;10;"); load.writeEntry("Scale2","dorian;0;2;3;5;7;9;10;"); load.writeEntry("Scale3","phrygian;0;1;3;5;7;8;10;"); load.writeEntry("Scale4","lydian;0;2;4;6;7;9;11;"); - load.writeEntry("Scale5","mixolyd.;0;2;4;5;7;9;10;"); + load.writeEntry("Scale5","mixolydian;0;2;4;5;7;9;10;"); load.writeEntry("noOfScales",6); } load.setGroup("General"); currentNote=load.readNumEntry("currentNote"); drawnames=load.readBoolEntry("drawnames"); currentInstrumentID=load.readNumEntry("currentInstrumentID"); currentScaleID=load.readNumEntry("currentScaleID"); load.setGroup("Instrument"); int noOfInstr=load.readNumEntry("noOfInstruments",0); for(int i=0;i<noOfInstr;i++) { QStringList instlist=load.readListEntry("Inst"+QString::number(i),';'); QValueList<int> strings; for(int st=2;st<(int)instlist.count();st++) strings.append(instlist[st].toInt()); instruments.append(Instrument(instlist[0],instlist[1].toInt(),strings)); } load.setGroup("Scale"); int scaleno=load.readNumEntry("noOfScales",0); for(int s=0;s<scaleno;s++) 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,26 +1,28 @@ #include "tonleiterdatahelper.h" +#include <math.h> + using namespace Data; int Note::getOctaveOfNote(int note) { int remain=note%12; return (note-remain)/12; } //**************************************************************************** QString Note::getNameOfNote(int note) { int octave=getOctaveOfNote(note); return notenames[note-12*octave]; } //**************************************************************************** int Note::getNoteFromName(QString name,int octave) { int notevalue=0; for(int a=0;a<12;a++) { if(name==notenames[a]) { notevalue=a; break; } @@ -55,49 +57,49 @@ Instrument::~Instrument() int Instrument::noOfStrings() { return (int)strings.count(); } //**************************************************************************** int Instrument::noOfFrets() { return frets; } //**************************************************************************** QString Instrument::instName() { return name; } //**************************************************************************** int Instrument::string(int id) { return strings[id]; } //**************************************************************************** int Instrument::noOfOctaves() { int lowest=strings[0]; int highest=strings[strings.count()-1]+frets; - return (int)((highest-lowest)/12.0); + return (int) ceil((highest-lowest)/12.0); } //**************************************************************************** //**************************************************************************** Scale::Scale() { name="UNDEFINED"; } //**************************************************************************** Scale::Scale(QString name,QValueList<int> halftones) :name(name),halftones(halftones) { } //**************************************************************************** Scale::~Scale() { } //**************************************************************************** int Scale::noOfHaltones() { return (int)halftones.count(); } //**************************************************************************** int Scale::getHalfTone(int id) { 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,35 +1,35 @@ #ifndef TONLEITER_DATA_HELPER_H #define TONLEITER_DATA_HELPER_H #include <qstring.h> #include <qvaluelist.h> namespace Data { namespace Note { - const QString notenames[]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"}; + const QString notenames[]={"A","Bb","B","C","C#","D","D#","E","F","F#","G","G#"}; int getOctaveOfNote(int note); QString getNameOfNote(int note); int getNoteFromName(QString name,int octave); int octaveOfBaseNote(int base,int note); }; class Instrument { private: QString name; int frets; QValueList<int> strings; public: Instrument(); Instrument(QString name,int frets,QValueList<int> strings); ~Instrument(); public: int noOfStrings(); int noOfFrets(); QString instName(); int string(int id); int noOfOctaves(); }; |