Guest User

Untitled

a guest
May 25th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. //header containing class and box creation function for chord shapes
  2.  
  3. using namespace std;
  4.  
  5. class Chord{
  6.  
  7. private:
  8.  
  9. string chordname;
  10.  
  11. string description;
  12.  
  13. vector<int> chordshape;
  14.  
  15. string chordfilename;
  16.  
  17. vector<int> chordfingers
  18.  
  19. public:
  20.  
  21. Chord(string chordname, string decription, int chordshape[6]);
  22.  
  23. Chord(char* chordname, char* description, int chordshape[6]);
  24.  
  25. Chord(string chordname, string description, int chordshape[6], string chordfilename);
  26.  
  27. Chord(char* chordname, char* description, int chordshape[6], char* chordfilename);
  28.  
  29. Chord(string chordname, string description, int chordshape[6], string chordfilename, int chordfingers[6]);
  30.  
  31. Chord(char* chordname, char* description, int chordshape[6], char* chordfilename,int chordfingers[6]);
  32.  
  33. string getname();
  34.  
  35. string getdescription();
  36.  
  37. void playchord();
  38.  
  39. void displaychord();
  40.  
  41. };
  42.  
  43.  
  44.  
  45. extern void init_boxes();
  46.  
  47.  
  48.  
  49.  
  50.  
  51. #include <string>
  52. #include <vector>
  53. #include <FL/Fl.H>
  54. #include <FL/Fl_Window.H>
  55. #include <FL/Fl_Button.H>
  56. #include <FL/Fl_Value_Output.H>
  57. #include <FL/Fl_Box.H>
  58. #include <FL/Fl_Counter.H>
  59. #include <FL/Fl_Output.H>
  60. #include <FL/Fl_JPEG_Image.H>
  61.  
  62. using namespace std;
  63.  
  64. #include "Chord.H"
  65. #include "sound.H"
  66.  
  67. 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
  68. {{122,164},{162,164},{232,162},{296,162},{352,160},{402,160},{448,160}},
  69. {{122,178},{162,178},{232,178},{296,176},{352,176},{402,176},{448,176}},
  70. {{122,192},{162,192},{232,192},{296,190},{352,190},{402,190},{448,190}},
  71. {{122,206},{162,206},{232,206},{296,204},{352,204},{402,204},{448,204}},
  72. {{122,220},{162,220},{232,220},{296,218},{352,218},{402,218},{448,218}}};
  73.  
  74. Fl_Box* boxes[6];
  75.  
  76. int fad[6]={-1,-1,-1,-1,-1,-1};
  77.  
  78. Chord::Chord(string chordname, string decription, int chordshape[6]){ //there are four class constructors which were all used at points
  79. //in development. There should be enough flexability in these four
  80. this->chordname=chordname; //to allow furture development if someone didn't want to add
  81. this->description=description; //sound, for example
  82. this->chordshape.assign(chordshape, chordshape+6);
  83.  
  84. }
  85.  
  86. Chord::Chord(char* chordname, char* description, int chordshape[6]){
  87.  
  88. this->chordname=string(chordname);
  89. this->description=string(description);
  90. this->chordshape.assign(chordshape, chordshape+6);
  91.  
  92. }
  93.  
  94. Chord::Chord(string chordname, string description, int chordshape[6], string chordfilename=""){
  95.  
  96. this->chordname=chordname;
  97. this->description=description;
  98. this->chordshape.assign(chordshape, chordshape+6);
  99. this->chordfilename=chordfilename;
  100.  
  101. }
  102.  
  103. Chord::Chord(char* chordname, char* description, int chordshape[6], char* chordfilename=0){
  104.  
  105. this->chordname=string(chordname);
  106. this->description=string(description);
  107. this->chordshape.assign(chordshape, chordshape+6);
  108. this->chordfilename=chordfilename;
  109. }
  110.  
  111. Chord::Chord(string chordname, string description, int chordshape[6], string chordfilename="", int chordfingers[6]=fad){
  112.  
  113. this->chordname=chordname;
  114. this->description=description;
  115. this->chordshape.assign(chordshape,chordshape+6);
  116. this->chordfilename=chordfilename;
  117. this->chordfingers.assign(chordfingers, chordfingers+6);
  118.  
  119. }
  120.  
  121. Chord::Chord(char* chordname, char* description, int chordshape[6], char* chordfilename=0,int chordfingers[6]=fad){
  122.  
  123. this->chordname=string(chordname);
  124. this->description=string(description);
  125. this->chordshape.assign(chordshape,chordshape+6);
  126. this->chordfilename=chordfilename;
  127. this->chordfingers.assign(chordfingers,chordfingers+6);
  128. }
  129.  
  130. string Chord::getname(){ return chordname;}
  131.  
  132. string Chord::getdescription(){ return description;}
  133.  
  134. void init_boxes() {
  135. for(int i=0; i<=5; i++){
  136.  
  137. boxes[i] = new Fl_Box(0,0,16,16);
  138. boxes[i]->box(FL_OVAL_BOX);
  139. boxes[i]->color(FL_RED);
  140.  
  141. }
  142. }
  143.  
  144. void Chord::displaychord(){ //this function moves the elements of the boxes object to the correct co-ordinates
  145. //as specified by the elements of the coords object given by the chordshape member of the Chord class
  146. for(int i=0; i<=5;i++){
  147.  
  148. if (chordshape[i]==-1){
  149.  
  150. boxes[i]->hide();
  151. }else{
  152.  
  153.  
  154. boxes[i]->show();
  155.  
  156. int x = coords[i][chordshape[i]][0];
  157. int y = coords[i][chordshape[i]][1];
  158.  
  159. //boxes[i]->label(addlabels);
  160.  
  161. boxes[i]->position(x+10-(16*0.5),y+10-(16*0.5)+20);
  162. }
  163. }
  164. }
  165.  
  166. void Chord::playchord(){ //sends the chord filename to the playsound function, which is containted in sound.cpp and sound.h
  167.  
  168. playsound(chordfilename);
  169.  
  170.  
  171. }
Add Comment
Please, Sign In to add comment