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>
41 extern std::vector
<track
*> tracks
;
43 void load_text(fltk::TextDisplay
* o
, const char* filename
){
44 fltk::TextBuffer
* T
= new fltk::TextBuffer();
45 //printf("loading file %s\n",filename);
46 T
->loadfile(filename
);
51 void hsv_to_rgb(float h
, float s
, float v
, unsigned char* r
, unsigned char* g
, unsigned char* b
){
53 float lh
= h
- 360*floor(h
/360);
62 G
= lh
*V
*S
/60 + V
*(1-S
);
66 R
= -(lh
-60)*V
*S
/60 + V
;
73 B
= (lh
-120)*V
*S
/60 + V
*(1-S
);
77 G
= -(lh
-180)*V
*S
/60 + V
;
81 R
= (lh
-240)*V
*S
/60 + V
*(1-S
);
88 B
= -(lh
-300)*V
*S
/60 + V
;
91 *r
= (unsigned char)(255*R
);
92 *g
= (unsigned char)(255*G
);
93 *b
= (unsigned char)(255*B
);
98 int ypix2note(int ypix
, int black
){
99 int udy
= 900 - ypix
+ 1;
101 int note
= 2*white
- white
/7 - (white
+4)/7;
104 if(udy
%12<4 && white
%7!=0 && (white
+4)%7!=0){note
--;}
105 else if(udy
%12>8 && (white
+1)%7!=0 && (white
+5)%7!=0){note
++;}
111 int note2ypix(int note
, int* black
){
112 int key
= (note
+ (note
+7)/12 + note
/12)/2;
114 if((note
+ (note
+7)/12 + note
/12)%2 == 0){//white key
116 return 900 - key
*12 - 12;
120 return 900 - key
*12 - 12 - 3;
125 void unmodify_blocks(){
127 for(int i
=0; i
<tracks
.size(); i
++){
128 s
= tracks
[i
]->head
->next
;
136 int unmodify_and_unstick_tracks(){
137 for(int i
=0; i
<tracks
.size(); i
++){
138 if(tracks
[i
]->modified
){
140 tracks
[i
]->restate();
141 tracks
[i
]->modified
= 0;
147 float randf(float l
, float r
){
157 float M
= (rand()*1.0)/RAND_MAX
;
158 float ans
= M
*(R
-L
) + L
;