Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //header containing class and box creation function for chord shapes
- using namespace std;
- class Chord{
- private:
- string chordname;
- string description;
- vector<int> chordshape;
- string chordfilename;
- vector<int> chordfingers
- public:
- Chord(string chordname, string decription, int chordshape[6]);
- Chord(char* chordname, char* description, int chordshape[6]);
- Chord(string chordname, string description, int chordshape[6], string chordfilename);
- Chord(char* chordname, char* description, int chordshape[6], char* chordfilename);
- Chord(string chordname, string description, int chordshape[6], string chordfilename, int chordfingers[6]);
- Chord(char* chordname, char* description, int chordshape[6], char* chordfilename,int chordfingers[6]);
- string getname();
- string getdescription();
- void playchord();
- void displaychord();
- };
- extern void init_boxes();
- #include <string>
- #include <vector>
- #include <FL/Fl.H>
- #include <FL/Fl_Window.H>
- #include <FL/Fl_Button.H>
- #include <FL/Fl_Value_Output.H>
- #include <FL/Fl_Box.H>
- #include <FL/Fl_Counter.H>
- #include <FL/Fl_Output.H>
- #include <FL/Fl_JPEG_Image.H>
- using namespace std;
- #include "Chord.H"
- #include "sound.H"
- int coords[6][7][2]={{{122,152},{162,150},{232,148},{296,148},{352,146},{402,144},{448,144}}, //array of co-ordinates to possition the fret markers
- {{122,164},{162,164},{232,162},{296,162},{352,160},{402,160},{448,160}},
- {{122,178},{162,178},{232,178},{296,176},{352,176},{402,176},{448,176}},
- {{122,192},{162,192},{232,192},{296,190},{352,190},{402,190},{448,190}},
- {{122,206},{162,206},{232,206},{296,204},{352,204},{402,204},{448,204}},
- {{122,220},{162,220},{232,220},{296,218},{352,218},{402,218},{448,218}}};
- Fl_Box* boxes[6];
- int fad[6]={-1,-1,-1,-1,-1,-1};
- Chord::Chord(string chordname, string decription, int chordshape[6]){ //there are four class constructors which were all used at points
- //in development. There should be enough flexability in these four
- this->chordname=chordname; //to allow furture development if someone didn't want to add
- this->description=description; //sound, for example
- this->chordshape.assign(chordshape, chordshape+6);
- }
- Chord::Chord(char* chordname, char* description, int chordshape[6]){
- this->chordname=string(chordname);
- this->description=string(description);
- this->chordshape.assign(chordshape, chordshape+6);
- }
- Chord::Chord(string chordname, string description, int chordshape[6], string chordfilename=""){
- this->chordname=chordname;
- this->description=description;
- this->chordshape.assign(chordshape, chordshape+6);
- this->chordfilename=chordfilename;
- }
- Chord::Chord(char* chordname, char* description, int chordshape[6], char* chordfilename=0){
- this->chordname=string(chordname);
- this->description=string(description);
- this->chordshape.assign(chordshape, chordshape+6);
- this->chordfilename=chordfilename;
- }
- Chord::Chord(string chordname, string description, int chordshape[6], string chordfilename="", int chordfingers[6]=fad){
- this->chordname=chordname;
- this->description=description;
- this->chordshape.assign(chordshape,chordshape+6);
- this->chordfilename=chordfilename;
- this->chordfingers.assign(chordfingers, chordfingers+6);
- }
- Chord::Chord(char* chordname, char* description, int chordshape[6], char* chordfilename=0,int chordfingers[6]=fad){
- this->chordname=string(chordname);
- this->description=string(description);
- this->chordshape.assign(chordshape,chordshape+6);
- this->chordfilename=chordfilename;
- this->chordfingers.assign(chordfingers,chordfingers+6);
- }
- string Chord::getname(){ return chordname;}
- string Chord::getdescription(){ return description;}
- void init_boxes() {
- for(int i=0; i<=5; i++){
- boxes[i] = new Fl_Box(0,0,16,16);
- boxes[i]->box(FL_OVAL_BOX);
- boxes[i]->color(FL_RED);
- }
- }
- void Chord::displaychord(){ //this function moves the elements of the boxes object to the correct co-ordinates
- //as specified by the elements of the coords object given by the chordshape member of the Chord class
- for(int i=0; i<=5;i++){
- if (chordshape[i]==-1){
- boxes[i]->hide();
- }else{
- boxes[i]->show();
- int x = coords[i][chordshape[i]][0];
- int y = coords[i][chordshape[i]][1];
- //boxes[i]->label(addlabels);
- boxes[i]->position(x+10-(16*0.5),y+10-(16*0.5)+20);
- }
- }
- }
- void Chord::playchord(){ //sends the chord filename to the playsound function, which is containted in sound.cpp and sound.h
- playsound(chordfilename);
- }
Add Comment
Please, Sign In to add comment