summaryrefslogtreecommitdiff
path: root/attic/muse_qt4_evolution/synti/zynaddsubfx/UI/MicrotonalUI.fl
blob: 750e7b51fb711568eb7c3fb9c5e5f8fca2b4c004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# data file for the Fltk User Interface Designer (fluid)
version 1.0106 
header_name {.h} 
code_name {.cc}
decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {} 

decl {//License: GNU GPL version 2} {} 

decl {\#include <stdlib.h>} {public
} 

decl {\#include <stdio.h>} {public
} 

decl {\#include <string.h>} {public
} 

decl {\#include <FL/Fl_File_Chooser.H>} {public
} 

decl {\#include <FL/fl_ask.H>} {public
} 

decl {\#include "../Misc/Microtonal.h"} {public
} 

class MicrotonalUI {} {
  Function {make_window()} {} {
    Fl_Window microtonaluiwindow {
      label Scales
      xywh {99 164 405 450} type Double hide
    } {
      Fl_Group {} {
        tooltip {Center where the note's freqs. are turned upside-down} xywh {249 2 155 45} box ENGRAVED_FRAME
      } {
        Fl_Check_Button {} {
          label {Invert keys}
          callback {microtonal->Pinvertupdown=(int) o->value();
if (microtonal->Pinvertupdown==0) centerinvertcounter->deactivate();
   else centerinvertcounter->activate();}
          tooltip {Turn upside-down the note frequencies} xywh {254 13 55 30} down_box DOWN_BOX labelfont 1 labelsize 12 align 148
          code0 {o->value(microtonal->Pinvertupdown);}
        }
        Fl_Counter centerinvertcounter {
          label Center
          callback {microtonal->Pinvertupdowncenter=(int) o->value();}
          xywh {319 13 80 20} labelfont 1 labelsize 12 align 130 minimum 0 maximum 127 step 1 textfont 1
          code0 {o->lstep(microtonal->getoctavesize());}
          code1 {o->value(microtonal->Pinvertupdowncenter);}
          code2 {if (microtonal->Pinvertupdown==0) o->deactivate();}
        }
      }
      Fl_Group microtonalgroup {selected
        xywh {3 49 402 398} box ENGRAVED_FRAME
        code0 {if (microtonal->Penabled==0) o->deactivate();}
      } {
        Fl_Button applybutton {
          label Retune
          callback {apply();}
          tooltip {Retune the synth accorging to the inputs from "Tunnings" and "Keyboard Mappings"} xywh {8 413 107 28} box THIN_UP_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 18
        }
        Fl_Value_Output octavesizeoutput {
          label {nts./oct.}
          callback {o->value(microtonal->getoctavesize());}
          tooltip {Notes/Octave} xywh {150 423 35 17} labelsize 10 align 5 maximum 500 step 1 value 12 textfont 1
          code0 {o->value(microtonal->getoctavesize());}
        }
        Fl_Input nameinput {
          label {Name:}
          callback {snprintf((char *)microtonal->Pname,MICROTONAL_MAX_NAME_LEN,"%s",o->value());}
          xywh {8 64 285 25} labelfont 1 labelsize 12 align 5
          code0 {o->insert((char *)microtonal->Pname);}
        }
        Fl_Input tuningsinput {
          label {Tunings:}
          xywh {8 144 182 264} type Multiline labelfont 1 labelsize 12 align 5 when 2
          code0 {updateTuningsInput();}
        }
        Fl_Input commentinput {
          label {Comment:}
          callback {snprintf((char *)microtonal->Pcomment,MICROTONAL_MAX_NAME_LEN,"%s",o->value());}
          xywh {8 104 391 25} labelfont 1 labelsize 12 align 5
          code0 {o->insert((char *)microtonal->Pcomment);}
        }
        Fl_Counter {} {
          label Shift
          callback {microtonal->Pscaleshift=(int) o->value()+64;}
          xywh {313 69 70 20} type Simple labelsize 12 align 1 minimum -63 maximum 64 step 1 textfont 1
          code0 {o->value(microtonal->Pscaleshift-64);}
        }
        Fl_Button {} {
          label {Import .SCL file}
          callback {const char *filename;
filename=fl_file_chooser("Open:","(*.scl)",NULL,0);
if (filename==NULL) return;
int result=microtonal->loadscl(filename);
if (result==0) {
       updateTuningsInput();
       nameinput->cut(0,nameinput->maximum_size());
       nameinput->insert((char *)microtonal->Pname);
       nameinput->position(0);
       commentinput->cut(0,commentinput->maximum_size());
       commentinput->insert((char *)microtonal->Pname);
       commentinput->position(0);
       tuningsinput->position(0);
       octavesizeoutput->do_callback();
     } else {
	fl_alert("Error: Could not load the file.");   
     };}
          tooltip {Inport Scala .scl file (tunnings)} xywh {243 411 84 15} box THIN_UP_BOX labelfont 1 labelsize 10
        }
        Fl_Group keymappinggroup {
          label {Keyboard Mapping} open
          xywh {193 144 206 264} box ENGRAVED_BOX labelfont 1 labelsize 12
        } {
          Fl_Input mappinginput {
            xywh {250 147 146 258} type Multiline labelfont 1 labelsize 12 align 5 when 2
            code0 {updateMappingInput();}
          }
          Fl_Counter firstnotecounter {
            label {First note}
            callback {microtonal->Pfirstkey=(int) o->value();}
            tooltip {First MIDI note number} xywh {199 195 42 18} type Simple labelsize 10 align 5 minimum 0 maximum 127 step 1 textfont 1 textsize 12
            code0 {o->value(microtonal->Pfirstkey);}
          }
          Fl_Counter lastnotecounter {
            label {Last note}
            callback {microtonal->Plastkey=(int) o->value();}
            tooltip {Last MIDI note number} xywh {199 225 42 18} type Simple labelsize 10 align 5 minimum 0 maximum 127 step 1 value 127 textfont 1 textsize 12
            code0 {o->value(microtonal->Plastkey);}
          }
          Fl_Counter middlenotecounter {
            label {Midle note}
            callback {microtonal->Pmiddlenote=(int) o->value();}
            tooltip {Midle note (where scale degree 0 is mapped to)} xywh {199 267 42 18} type Simple labelsize 10 align 5 minimum 0 maximum 127 step 1 value 60 textfont 1 textsize 12
            code0 {o->value(microtonal->Pmiddlenote);}
          }
          Fl_Value_Output mapsizeoutput {
            label {Map Size}
            callback {o->value(microtonal->Pmapsize);}
            xywh {201 382 44 20} labelsize 10 align 5 maximum 500 step 1 value 12 textfont 1
            code0 {o->value(microtonal->Pmapsize);}
          }
        }
        Fl_Check_Button mappingenabledbutton {
          label ON
          callback {int x=(int) o->value();
microtonal->Pmappingenabled=x;
if (x==0) keymappinggroup->deactivate();
 else keymappinggroup->activate();
o->show();}
          tooltip {Enable the Mapping (otherwise the mapping is linear)} xywh {198 150 48 21} box FLAT_BOX down_box DOWN_BOX labelfont 1
          code0 {o->value(microtonal->Pmappingenabled);}
          code1 {if (microtonal->Pmappingenabled==0) keymappinggroup->deactivate();}
        }
        Fl_Button {} {
          label {Import .kbm file}
          callback {const char *filename;
filename=fl_file_chooser("Open:","(*.kbm)",NULL,0);
if (filename==NULL) return;
int result=microtonal->loadkbm(filename);
if (result==0) {
       updateMappingInput();
       mappinginput->position(0);
       mapsizeoutput->do_callback();
       firstnotecounter->value(microtonal->Pfirstkey);
       lastnotecounter->value(microtonal->Plastkey);
       middlenotecounter->value(microtonal->Pmiddlenote);
       mapsizeoutput->do_callback();
       mappingenabledbutton->value(microtonal->Pmappingenabled);
       mappingenabledbutton->do_callback();
       afreqinput->value(microtonal->PAfreq);
       anotecounter->value(microtonal->PAnote);
       anotecounter->do_callback();
     } else {
	fl_alert("Error: Could not load the file.");   
     };}
          tooltip {Inport Scala .kbm file (keyboard mapping)} xywh {243 428 84 16} box THIN_UP_BOX labelfont 1 labelsize 10
        }
      }
      Fl_Group {} {
        xywh {108 2 140 45} box ENGRAVED_FRAME
      } {
        Fl_Counter anotecounter {
          label {"A" Note}
          callback {microtonal->PAnote=(int) o->value();
if (microtonal->getnotefreq(microtonal->PAnote,0)<0.0) o->textcolor(FL_RED);
 else o->textcolor(FL_BLACK);

o->redraw();}
          tooltip {The "A" note (the reference note for which freq. ("A" freq) is given)} xywh {173 17 65 20} labelfont 1 labelsize 10 align 129 minimum 0 maximum 127 step 1 value 69 textfont 1 textsize 11
          code0 {o->lstep(12);}
          code1 {o->value(microtonal->PAnote);}
        }
        Fl_Value_Input afreqinput {
          label {"A" Freq.}
          callback {microtonal->PAfreq=o->value();}
          tooltip {The freq. of "A" note (default=440.0)} xywh {118 17 45 20} labelfont 1 labelsize 10 align 1 minimum 1 maximum 20000 step 0.001 value 440 textfont 1 textsize 11
          code0 {o->value(microtonal->PAfreq);}
        }
      }
      Fl_Button {} {
        label Close
        callback {microtonaluiwindow->hide();}
        xywh {333 413 67 28} box THIN_UP_BOX
      }
      Fl_Check_Button {} {
        label {Enable Microtonal}
        callback {microtonal->Penabled=(int) o->value();
if (microtonal->Penabled==0) microtonalgroup->deactivate();
   else microtonalgroup->activate();}
        xywh {3 3 102 45} box PLASTIC_UP_BOX down_box DOWN_BOX labelfont 1 labelsize 12 align 148
        code0 {o->value(microtonal->Penabled);}
      }
    }
  }
  Function {updateTuningsInput()} {} {
    code {char *tmpbuf=new char[100];

tuningsinput->cut(0,tuningsinput->maximum_size());

for (int i=0;i<microtonal->getoctavesize();i++){
   if (i!=0) tuningsinput->insert("\\n");
   microtonal->tuningtoline(i,tmpbuf,100);
   tuningsinput->insert(tmpbuf);
};

delete(tmpbuf);} {}
  }
  Function {updateMappingInput()} {} {
    code {char *tmpbuf=new char[100];

mappinginput->cut(0,tuningsinput->maximum_size());

for (int i=0;i<microtonal->Pmapsize;i++){
   if (i!=0) mappinginput->insert("\\n");
   if ((microtonal->Pmapping[i])==-1)
        snprintf(tmpbuf,100,"x");
   else snprintf(tmpbuf,100,"%d",microtonal->Pmapping[i]);
   mappinginput->insert(tmpbuf);
};

delete(tmpbuf);} {}
  }
  Function {MicrotonalUI(Microtonal *microtonal_)} {} {
    code {microtonal=microtonal_;

make_window();} {}
  }
  Function {~MicrotonalUI()} {} {
    code {microtonaluiwindow->hide();
delete(microtonaluiwindow);} {}
  }
  Function {show()} {} {
    code {microtonaluiwindow->show();} {}
  }
  Function {apply()} {} {
    code {int err=microtonal->texttotunings(tuningsinput->value());
if (err>=0) fl_alert("Parse Error: The input may contain only numbers (like 232.59)\\n or divisions (like 121/64).");
if (err==-2) fl_alert("Parse Error: The input is empty.");
octavesizeoutput->do_callback();

microtonal->texttomapping(mappinginput->value());
mapsizeoutput->do_callback();
anotecounter->do_callback();

//applybutton->color(FL_GRAY);} {}
  }
  decl {Microtonal *microtonal;} {}
}