1 /*  SpiralSynth
2  *  Copyleft (C) 2000 David Griffiths <dave@pawfal.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 
19 #include "SequencerGUI.h"
20 
SequencerGUI(Sequencer * o)21 SequencerGUI::SequencerGUI(Sequencer *o)
22 {
23  int n=0;
24  for(int i=0; i<16; i++)
25 	for(int j=0; j<12; j++)
26 	{
27 		EventTable[i][j]=n++;
28 	}
29 
30 	m_seq=o;
31 }
32 
33 void SequencerGUI::CreateGUI(int xoff=0, int yoff=0, char *name="")
34 {
35 	 Fl_Group* o = GUISeqGroup = new Fl_Group(xoff, yoff, 380, 320, name);
36       o->type(1);
37 	  o->box(FL_UP_BOX);
38       o->labeltype(FL_ENGRAVED_LABEL);
39       o->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE);
40 	  o->user_data((void*)(this));
41 
42 	  for(int i=0; i<16; i++)
43 	  	for(int j=0; j<12; j++)
44 		{
45 		 Event[i][j] = new Fl_Button(50+xoff+(20*i), 20+yoff+(20*j), 19, 19);
46      	 Event[i][j]->type(1);
47       	 Event[i][j]->selection_color(SpiralInfo::GUI_COLOUR);
48 
49 		 switch(j)
50 		 {
51 		 	case 1:
52 			case 3:
53 			case 6:
54 			case 8:
55 			case 10:
56 				Event[i][j]->color(0);
57 				break;
58 			default:
59 				Event[i][j]->color(7);
60 				break;
61 		 }
62 
63 	  	 Event[i][j]->callback((Fl_Callback*)cb_Event,(void*)&EventTable[i][j]);
64 		}
65 
66 	 Speed = new Fl_Knob(12+xoff,  220+yoff, 30, 30, "Speed");
67      Speed->color(SpiralInfo::GUI_COLOUR);
68 	 Speed->type(1);
69      Speed->selection_color(0);
70      Speed->labelsize(10);
71      Speed->maximum(0.5);
72      Speed->step(0.01);
73      Speed->value(0.05);
74 	 Speed->callback((Fl_Callback*)cb_Speed);
75 
76 	 Play = new Fl_Button(10+xoff, 270+yoff, 50, 30, "Play");
77      Play->type(1);
78      Play->selection_color(SpiralInfo::GUI_COLOUR);
79 	 Play->callback((Fl_Callback*)cb_Play);
80 
81 	 Octave = new Fl_Knob(70+xoff,  270+yoff, 30, 30, "Octave");
82      Octave->color(SpiralInfo::GUI_COLOUR);
83 	 Octave->type(1);
84      Octave->selection_color(0);
85      Octave->labelsize(10);
86      Octave->maximum(5);
87      Octave->step(1);
88      Octave->value(3);
89 	 Octave->callback((Fl_Callback*)cb_Octave);
90 
91 	 Length = new Fl_Knob(110+xoff,  270+yoff, 30, 30, "Length");
92      Length->color(SpiralInfo::GUI_COLOUR);
93 	 Length->type(1);
94      Length->selection_color(0);
95      Length->labelsize(10);
96      Length->maximum(15);
97      Length->step(1);
98      Length->value(15);
99 	 Length->callback((Fl_Callback*)cb_Length);
100 
101      Arp = new Fl_Button(150+xoff, 270+yoff, 50, 30, "Arpeg");
102      Arp->type(1);
103      Arp->selection_color(SpiralInfo::GUI_COLOUR);
104 	 Arp->callback((Fl_Callback*)cb_Arp);
105 
106      ArpType = new Fl_Button(210+xoff, 270+yoff, 50, 30, "AType");
107      ArpType->type(1);
108      ArpType->selection_color(SpiralInfo::GUI_COLOUR);
109 	 ArpType->callback((Fl_Callback*)cb_ArpType);
110 
111 	 ArpNotes = new Fl_Knob(270+xoff,  270+yoff, 30, 30, "ArpNotes");
112      ArpNotes->color(SpiralInfo::GUI_COLOUR);
113 	 ArpNotes->type(1);
114      ArpNotes->selection_color(0);
115      ArpNotes->labelsize(10);
116      ArpNotes->maximum(5);
117      ArpNotes->step(1);
118      ArpNotes->value(2);
119 	 ArpNotes->callback((Fl_Callback*)cb_ArpNotes);
120 
121      o->end();
122 }
123 
124 //// Callbacks ////
125 
cb_Event_i(Fl_Button * o,void * v)126 inline void SequencerGUI::cb_Event_i(Fl_Button* o, void *v)
127 {
128 	if (o->value()) m_seq->SetEvent(*(int*)(v));
129 	else m_seq->UnSetEvent(*(int*)(v));
130 }
cb_Event(Fl_Button * o,void * v)131 void SequencerGUI::cb_Event(Fl_Button* o, void *v)
132 { ((SequencerGUI*)(o->parent()->user_data()))->cb_Event_i(o,v); }
133 
cb_Play_i(Fl_Button * o,void * v)134 inline void SequencerGUI::cb_Play_i(Fl_Button* o, void* v)
135 { m_seq->Play(o->value()); }
cb_Play(Fl_Button * o,void * v)136 void SequencerGUI::cb_Play(Fl_Button* o, void* v)
137 { ((SequencerGUI*)(o->parent()->user_data()))->cb_Play_i(o,v); }
138 
cb_Speed_i(Fl_Knob * o,void * v)139 inline void SequencerGUI::cb_Speed_i(Fl_Knob* o, void* v)
140 { m_seq->SetSpeed(o->value()); }
cb_Speed(Fl_Knob * o,void * v)141 void SequencerGUI::cb_Speed(Fl_Knob* o, void* v)
142 { ((SequencerGUI*)(o->parent()->user_data()))->cb_Speed_i(o,v); }
143 
cb_Octave_i(Fl_Knob * o,void * v)144 inline void SequencerGUI::cb_Octave_i(Fl_Knob* o, void* v)
145 { m_seq->SetOctave(o->value()); }
cb_Octave(Fl_Knob * o,void * v)146 void SequencerGUI::cb_Octave(Fl_Knob* o, void* v)
147 { ((SequencerGUI*)(o->parent()->user_data()))->cb_Octave_i(o,v); }
148 
cb_Length_i(Fl_Knob * o,void * v)149 inline void SequencerGUI::cb_Length_i(Fl_Knob* o, void* v)
150 { m_seq->SetLength(o->value()); }
cb_Length(Fl_Knob * o,void * v)151 void SequencerGUI::cb_Length(Fl_Knob* o, void* v)
152 { ((SequencerGUI*)(o->parent()->user_data()))->cb_Length_i(o,v); }
153 
cb_Arp_i(Fl_Button * o,void * v)154 inline void SequencerGUI::cb_Arp_i(Fl_Button* o, void* v)
155 { m_seq->SetArp(o->value()); }
cb_Arp(Fl_Button * o,void * v)156 void SequencerGUI::cb_Arp(Fl_Button* o, void* v)
157 { ((SequencerGUI*)(o->parent()->user_data()))->cb_Arp_i(o,v); }
158 
cb_ArpType_i(Fl_Button * o,void * v)159 inline void SequencerGUI::cb_ArpType_i(Fl_Button* o, void* v)
160 { m_seq->SetArpType(o->value()); }
cb_ArpType(Fl_Button * o,void * v)161 void SequencerGUI::cb_ArpType(Fl_Button* o, void* v)
162 { ((SequencerGUI*)(o->parent()->user_data()))->cb_ArpType_i(o,v); }
163 
cb_ArpNotes_i(Fl_Knob * o,void * v)164 inline void SequencerGUI::cb_ArpNotes_i(Fl_Knob* o, void* v)
165 { m_seq->SetArpNotes(o->value()); }
cb_ArpNotes(Fl_Knob * o,void * v)166 void SequencerGUI::cb_ArpNotes(Fl_Knob* o, void* v)
167 { ((SequencerGUI*)(o->parent()->user_data()))->cb_ArpNotes_i(o,v); }
168 
169