2 Epichord - a midi sequencer
3 Copyright (C) 2008 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
28 #include <fltk/TextDisplay.h>
29 #include <fltk/TextBuffer.h>
40 extern std::vector
<track
*> tracks
;
42 void load_text(fltk::TextDisplay
* o
, const char* filename
){
43 fltk::TextBuffer
* T
= new fltk::TextBuffer();
44 //printf("loading file %s\n",filename);
45 T
->loadfile(filename
);
50 void hsv_to_rgb(float h
, float s
, float v
, unsigned char* r
, unsigned char* g
, unsigned char* b
){
52 float lh
= h
- floor(h
/360);
61 G
= lh
*V
*S
/60 + V
*(1-S
);
65 R
= -(lh
-60)*V
*S
/60 + V
;
72 B
= (lh
-120)*V
*S
/60 + V
*(1-S
);
76 G
= -(lh
-180)*V
*S
/60 + V
;
80 R
= (lh
-240)*V
*S
/60 + V
*(1-S
);
87 B
= -(lh
-300)*V
*S
/60 + V
;
90 double Z
= sqrt(R
*R
+ G
*G
+ B
*B
);
96 *r
= (unsigned char)(255*R
);
97 *g
= (unsigned char)(255*G
);
98 *b
= (unsigned char)(255*B
);
103 int ypix2note(int ypix
, int black
){
104 int udy
= 900 - ypix
+ 1;
106 int note
= 2*white
- white
/7 - (white
+4)/7;
109 if(udy
%12<4 && white
%7!=0 && (white
+4)%7!=0){note
--;}
110 else if(udy
%12>8 && (white
+1)%7!=0 && (white
+5)%7!=0){note
++;}
116 int note2ypix(int note
, int* black
){
117 int key
= (note
+ (note
+7)/12 + note
/12)/2;
119 if((note
+ (note
+7)/12 + note
/12)%2 == 0){//white key
121 return 900 - key
*12 - 12;
125 return 900 - key
*12 - 12 - 3;
130 void unmodify_blocks(){
132 for(int i
=0; i
<tracks
.size(); i
++){
133 s
= tracks
[i
]->head
->next
;
141 int unmodify_and_unstick_tracks(){
142 for(int i
=0; i
<tracks
.size(); i
++){
143 if(tracks
[i
]->modified
){
145 tracks
[i
]->restate();
146 tracks
[i
]->modified
= 0;