~ubuntu-branches/ubuntu/quantal/freewheeling/quantal

« back to all changes in this revision

Viewing changes to src/fweelin_config.h

  • Committer: Bazaar Package Importer
  • Author(s): Paul Brossier
  • Date: 2005-08-06 15:11:54 UTC
  • Revision ID: james.westby@ubuntu.com-20050806151154-nvhhuxtyvgweh75u
Tags: upstream-0.5pre4
ImportĀ upstreamĀ versionĀ 0.5pre4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __FWEELIN_CONFIG_H
 
2
#define __FWEELIN_CONFIG_H
 
3
 
 
4
#include <SDL/SDL.h>
 
5
 
 
6
#include <libxml/xmlmemory.h>
 
7
#include <libxml/parser.h>
 
8
#include <libxml/tree.h>
 
9
 
 
10
#define MAX_PULSES 10 // Maximum number of time pulses
 
11
#define LAST_REC_COUNT 8 // Keep track of the last n indexes we recorded to
 
12
 
 
13
// Divisions are added in browsers wherever files are greater than
 
14
// FWEELIN_FILE_BROWSER_DIVISION_TIME seconds apart
 
15
#define FWEELIN_FILE_BROWSER_DIVISION_TIME 3600
 
16
 
 
17
#define FWEELIN_CONFIG_FILE ".fweelin.rc"
 
18
#define FWEELIN_CONFIG_HELP_TOKEN "HELP:"
 
19
 
 
20
#define FWEELIN_OUTPUT_STREAM_NAME "live"
 
21
#define FWEELIN_OUTPUT_TIMING_EXT  ".wav.usx"
 
22
#define FWEELIN_OUTPUT_LOOP_NAME   "loop"
 
23
#define FWEELIN_OUTPUT_SCENE_NAME  "scene"
 
24
#define FWEELIN_OUTPUT_AUDIO_EXT   ".ogg"
 
25
#define FWEELIN_OUTPUT_DATA_EXT    ".xml"
 
26
 
 
27
// Console sequence for error color
 
28
#define FWEELIN_ERROR_COLOR_ON "\033[31;1m"
 
29
#define FWEELIN_ERROR_COLOR_OFF "\033[0m"
 
30
 
 
31
#include "fweelin_datatypes.h"
 
32
#include "fweelin_audioio.h"
 
33
#include "fweelin_event.h"
 
34
#include "fweelin_videoio.h" // TTF_Font decl
 
35
 
 
36
class Event;
 
37
class KeyIO;
 
38
class MidiIO;
 
39
class CircularMap;
 
40
 
 
41
// ****************** CONFIG CLASSES
 
42
 
 
43
enum CfgTokenType {
 
44
  T_CFG_None,
 
45
  T_CFG_UserVariable,
 
46
  T_CFG_EventParameter,
 
47
  T_CFG_Static
 
48
};
 
49
 
 
50
// Config tokens can reference user variables (UserVariable)
 
51
// or input EventParameters (EventParameter)
 
52
// or static values
 
53
class CfgToken {
 
54
 public:
 
55
  CfgToken() : cvt(T_CFG_None), var(0) {};
 
56
 
 
57
  CfgTokenType cvt;
 
58
 
 
59
  // Dump CfgToken to stdout
 
60
  void Print();
 
61
 
 
62
  // Evaluate the current value of this token to dst
 
63
  // Using event ev as a reference for event parameter
 
64
  // If overwritetype is nonzero, sets dst to be of the appropriate data type
 
65
  // Otherwise, converts to existing type of dst 
 
66
  void Evaluate(UserVariable *dst, Event *ev, char overwritetype);
 
67
 
 
68
  // Reference a user defined variable
 
69
  UserVariable *var;
 
70
  // Reference an event parameter
 
71
  EventParameter evparam;
 
72
  // Or reference a static value
 
73
  UserVariable val;
 
74
};
 
75
 
 
76
// Simple algebra is possible in config file
 
77
// it allows, for example, a midi fader level to be divided into an appropriate
 
78
// amplitude.
 
79
// This is one math operation as part of an expression
 
80
class CfgMathOperation {
 
81
 public:
 
82
  CfgMathOperation() : next(0) {};
 
83
 
 
84
  // Symbols for different math operators (div, mul, add, sub, etc..)
 
85
  const static char operators[];
 
86
  // Number of different math operators
 
87
  const static int numops;
 
88
  
 
89
  char otype; // One of the above operator types
 
90
  CfgToken operand;
 
91
 
 
92
  CfgMathOperation *next;
 
93
};
 
94
 
 
95
// A complete expression of config tokens modified by math operations
 
96
class ParsedExpression {
 
97
 public:
 
98
  ParsedExpression() : ops(0) {};
 
99
  ~ParsedExpression() {
 
100
    // Erase math ops
 
101
    CfgMathOperation *cur = ops;
 
102
    while (cur != 0) {
 
103
      CfgMathOperation *tmp = cur->next;
 
104
      delete cur;
 
105
      cur = tmp;
 
106
    }
 
107
  };
 
108
 
 
109
  // Evaluate this expression
 
110
  UserVariable Evaluate(Event *input);
 
111
 
 
112
  // Returns nonzero if this expression contains only static tokens
 
113
  // and no user variables and no input parameters
 
114
  char IsStatic();
 
115
 
 
116
  // Dump expression to stdout
 
117
  void Print();
 
118
 
 
119
  CfgToken start; // Starting token of expression
 
120
  CfgMathOperation *ops; // Optional sequence of math ops to perform on 'val'
 
121
};
 
122
 
 
123
// DynamicToken is an expression and a config token, 
 
124
// used in a few places:
 
125
// 
 
126
// 1) To evaluate an expression and assign the result to an output event 
 
127
//    parameter (wrapped in CfgToken)
 
128
// 2) To evaluate an expression and compare the result to an input event 
 
129
//    parameter (wrapped in CfgToken)
 
130
// 2) To evaluate an expression and compare the result to a user variable
 
131
//    (wrapped in CfgToken)
 
132
class DynamicToken {
 
133
 public:
 
134
  DynamicToken() : exp(0), next(0) {};
 
135
  ~DynamicToken() { 
 
136
    if (exp != 0) 
 
137
      delete exp;
 
138
  };
 
139
 
 
140
  CfgToken token; // Variable/parameter to compare or assign to
 
141
  ParsedExpression *exp;   // Expression to evaluate
 
142
  DynamicToken *next;
 
143
};
 
144
 
 
145
// Binding between a freewheeling event and some input action
 
146
// controls basic user interface
 
147
class EventBinding {
 
148
 public:
 
149
  EventBinding(char all = 0) : 
 
150
    boundproto(0), heldprereq(0), all(all), echo(0), 
 
151
    tokenconds(0), paramsets(0), continued(0), next(0) {};
 
152
  virtual ~EventBinding();
 
153
 
 
154
  Event *boundproto; // Prototype instance of the output event
 
155
 
 
156
  // We can specify that for the event to be triggered, a set of
 
157
  // keyboard keys must be held down.
 
158
  SDLKeyList *heldprereq; // These keys must be held
 
159
  char all; // Nonzero if all keys must be held, zero if any one is enough
 
160
 
 
161
  // Nonzero if input events should be rebroadcast even
 
162
  // if they are consumed in this binding
 
163
  char echo;
 
164
 
 
165
  // ** Conditions
 
166
 
 
167
  // List of dynamic token conditions
 
168
  // (for example, MIDI channel on input must match given expression)
 
169
  DynamicToken *tokenconds;
 
170
 
 
171
  // ** Parameter mappings
 
172
 
 
173
  // List of dynamic parameter assignments for output events
 
174
  // (for example, when triggering from MIDI keyboard: loop # = notenum + 12)
 
175
  DynamicToken *paramsets;
 
176
 
 
177
  // Continued is nonzero if the next binding should always be triggered
 
178
  // when this binding is triggered- so the next binding is a 
 
179
  // continuation of this binding
 
180
  char continued;
 
181
 
 
182
  EventBinding *next;
 
183
};
 
184
 
 
185
class InputMatrix : public EventProducer, public EventListener {
 
186
 public:
 
187
 
 
188
  InputMatrix(Fweelin *app);
 
189
  virtual ~InputMatrix();
 
190
  
 
191
  // Sets the given variable to the given value- string is interpreted
 
192
  // based on variable type
 
193
  void SetVariable (UserVariable *var, char *value);
 
194
 
 
195
  // Called during configuration to create user defined variables
 
196
  void CreateVariable (xmlNode *declare);
 
197
 
 
198
  // Called during configuration to bind input controllers to events
 
199
  void CreateBinding (xmlNode *binding);
 
200
 
 
201
  // Are the conditions in the EventBinding bind matched by the
 
202
  // given input event and user variables?
 
203
  char CheckConditions(Event *input, EventBinding *bind);
 
204
 
 
205
  // Receive input events
 
206
  void ReceiveEvent(Event *ev, EventProducer *from);
 
207
 
 
208
  // Start function, called shortly before Fweelin begins running
 
209
  void Start();
 
210
 
 
211
  // *********** User defined variables
 
212
 
 
213
  UserVariable *vars;
 
214
 
 
215
  Fweelin *app;
 
216
 
 
217
  // Parses a given expression string, extracting tokens
 
218
  // for example: 'VAR_curnote+12' references variable VAR_curnote and
 
219
  // creates 1 math operation +12
 
220
  // The expression may also reference parameters in event 'ref'
 
221
  // and these references will be extracted
 
222
  ParsedExpression *ParseExpression(char *str, Event *ref, 
 
223
                                    char enable_keynames = 0);
 
224
 
 
225
 private:
 
226
 
 
227
  // Removes leading and trailing spaces from string str
 
228
  // Modifies the end of string str and returns a pointer to the new 
 
229
  // beginning after spaces
 
230
  char *RemoveSpaces (char *str);
 
231
 
 
232
  // Adds one key to the given list based on the keysym name
 
233
  // Returns the new first pointer
 
234
  SDLKeyList *AddOneKey (SDLKeyList *first, char *str);
 
235
 
 
236
  // Extracts named keys from the given string and returns a list
 
237
  // of the keysyms (named keys are separated by ,)
 
238
  SDLKeyList *ExtractKeys (char *str);
 
239
 
 
240
  // Parses the given token (no math ops!) into dst
 
241
  // Correctly identifies when variables or event parameters are referenced
 
242
  void ParseToken(char *str, CfgToken *dst, Event *ref, 
 
243
                  char enable_keynames = 0);
 
244
 
 
245
  // Stores in ptr the value val given that ptr is of type dtype
 
246
  void StoreParameter(char *ptr, CoreDataType dtype, UserVariable *val);
 
247
 
 
248
  // Using the eventbinding's parametersets as a template, dynamically
 
249
  // sets parameters in the output event
 
250
  void SetDynamicParameters(Event *input, Event *output, EventBinding *bind);
 
251
 
 
252
  // Scans in the given binding for settings for output event parameters
 
253
  // and sets us up to handle those
 
254
  void CreateParameterSets (EventBinding *bind, xmlNode *binding, 
 
255
                            Event *input, int contnum);
 
256
 
 
257
  // Scans in the given binding for conditions on input event parameters 
 
258
  // or user variables, and sets us up to handle those
 
259
  // Returns the hash index for this binding, based on an indexed parameter,
 
260
  // or 0 if this binding is not indexed
 
261
  int CreateConditions (EventBinding *bind, xmlNode *binding, 
 
262
                        Event *input, int paramidx);
 
263
 
 
264
  // Traverses through the list of event bindings beginning at 'start'
 
265
  // looking for a binding that matches current user variables and input
 
266
  // event 'ev'
 
267
  EventBinding *MatchBinding(Event *ev, EventBinding *start);
 
268
 
 
269
  // *********** Event Bindings
 
270
 
 
271
  // Bindings that trigger on input events- for each input event type,
 
272
  // a hashtable of bindings along an indexed parameter
 
273
  EventBinding ***input_bind;
 
274
};
 
275
 
 
276
class FloLayoutElementGeometry {
 
277
 public:  
 
278
  FloLayoutElementGeometry() : next(0) {};
 
279
 
 
280
  // Draw this element to the given screen-
 
281
  // implementation given in videoio.cc
 
282
  virtual void Draw(SDL_Surface *screen, SDL_Color clr) = 0;
 
283
 
 
284
  // Next geo
 
285
  FloLayoutElementGeometry *next;
 
286
};
 
287
 
 
288
class FloLayoutBox : public FloLayoutElementGeometry {
 
289
 public:
 
290
 
 
291
  // Draw this element to the given screen-
 
292
  // implementation given in videoio.cc
 
293
  virtual void Draw(SDL_Surface *screen, SDL_Color clr);
 
294
  
 
295
  // Outlines along borders?
 
296
  char lineleft, linetop, lineright, linebottom;
 
297
  // Coordinates of box
 
298
  int left, top, right, bottom;
 
299
};
 
300
 
 
301
class FloLayoutElement {
 
302
 public:  
 
303
  FloLayoutElement() : id(0), name(0), nxpos(0), nypos(0), bx(0.0), by(0.0), 
 
304
    loopmap(0), loopx(0), loopy(0), loopsize(0), geo(0), next(0) {};
 
305
  ~FloLayoutElement() {
 
306
    if (name != 0)
 
307
      delete[] name;
 
308
    // Erase geometries
 
309
    FloLayoutElementGeometry *cur = geo;
 
310
    while (cur != 0) {
 
311
      FloLayoutElementGeometry *tmp = cur->next;
 
312
      delete cur;
 
313
      cur = tmp;
 
314
    }
 
315
  };
 
316
 
 
317
  int id; // Id of element
 
318
  char *name; // Name of element
 
319
  int nxpos, nypos; // Location to print name label
 
320
  float bx, by; // Base position for element
 
321
 
 
322
  // Generated map that will take a flat scope and project it onto the right
 
323
  // size circle-- see videoio
 
324
  CircularMap *loopmap; 
 
325
 
 
326
  int loopx, loopy, // Position of loop graphic for the element
 
327
    loopsize; // Size of loop graphic (diameter)
 
328
 
 
329
  // Geo describes how to draw this interface element
 
330
  FloLayoutElementGeometry *geo;
 
331
 
 
332
  // Next element 
 
333
  FloLayoutElement *next;
 
334
};
 
335
 
 
336
// The user can define the onscreen layout for loops-- see config file!
 
337
class FloLayout {
 
338
 public:
 
339
  FloLayout() : id(0), xpos(0), ypos(0), loopids(0,0),
 
340
    name(0), nxpos(0), nypos(0), elems(0), show(1), showlabel(1),
 
341
    showelabel(1), next(0) {};
 
342
  ~FloLayout() {
 
343
    if (name != 0)
 
344
      delete[] name;
 
345
    // Erase elements
 
346
    FloLayoutElement *cur = elems;
 
347
    while (cur != 0) {
 
348
      FloLayoutElement *tmp = cur->next;
 
349
      delete cur;
 
350
      cur = tmp;
 
351
    }
 
352
  };
 
353
  
 
354
  int id, // User refers to a layout by ID
 
355
    xpos, ypos; // Base location on screen for this layout
 
356
  Range loopids; // Range of loopids that map to interface elements
 
357
  char *name; // ex PC Keyboard, MIDI Footpedal
 
358
  int nxpos, nypos; // Location to print name label
 
359
 
 
360
  FloLayoutElement *elems; // Elements that make up this layout
 
361
 
 
362
  char show, // Layout shown onscreen?
 
363
    showlabel, // Name of layout shown onscreen?
 
364
    showelabel; // Element names in layout shown onscreen?
 
365
 
 
366
  // Next layout
 
367
  FloLayout *next;
 
368
};
 
369
 
 
370
// List of strings- optional two strings per listitem
 
371
// Second string is assumed to be substring of first string
 
372
// Only first string is deleted at destructor
 
373
class FloStringList {
 
374
 public:
 
375
  FloStringList(char *str, char *str2 = 0) : str(str), str2(str2),
 
376
    next(0) {};
 
377
  ~FloStringList() {
 
378
    if (str != 0)
 
379
      delete[] str;
 
380
  };
 
381
 
 
382
  char *str, *str2;
 
383
  FloStringList *next;
 
384
};
 
385
 
 
386
// List of fonts used in video- video handles the loading and unloading,
 
387
// but config sets up these structures to know which fonts and sizes to load
 
388
class FloFont {
 
389
 public:
 
390
  FloFont() : name(0), filename(0), font(0), size(0), next(0) {};
 
391
  ~FloFont() {
 
392
    if (filename != 0)
 
393
      delete[] filename;
 
394
    if (name != 0)
 
395
      delete[] name;
 
396
  };
 
397
 
 
398
  char *name, *filename;
 
399
  TTF_Font *font;
 
400
  int size;
 
401
  FloFont *next;
 
402
};
 
403
 
 
404
enum FloDisplayType {
 
405
  FD_Unknown,
 
406
  FD_Browser
 
407
};
 
408
 
 
409
// List of variable displays used in video
 
410
// There are different types of displays, this is a base class
 
411
class FloDisplay {
 
412
 public:
 
413
  FloDisplay() : id(-1), exp(0), font(0), title(0), xpos(0), ypos(0), show(1),
 
414
    next(0) {};
 
415
  virtual ~FloDisplay() {
 
416
    if (title != 0)
 
417
      delete[] title;
 
418
    if (exp != 0)
 
419
      delete exp;
 
420
  };
 
421
 
 
422
  // Draw this display to the given screen-
 
423
  // implementation given in videoio.cc
 
424
  virtual void Draw(SDL_Surface *screen) = 0;
 
425
 
 
426
  virtual FloDisplayType GetFloDisplayType() { return FD_Unknown; };
 
427
 
 
428
  int id;                // Way to refer to this display from events
 
429
 
 
430
  ParsedExpression *exp; // Expression which evaluates to a value to display
 
431
  FloFont *font;         // Font for text
 
432
  char *title;           // Title to be displayed
 
433
  int xpos, ypos;        // Onscreen location for display
 
434
  char show;             // Show (nonzero) or hide (zero) display
 
435
 
 
436
  FloDisplay *next;
 
437
};
 
438
 
 
439
// Text display shows the value of expression 'exp' as onscreen text
 
440
class FloDisplayText : public FloDisplay 
 
441
{
 
442
 public:
 
443
 
 
444
  virtual void Draw(SDL_Surface *screen);
 
445
};
 
446
 
 
447
// Switch display shows the title in different color depending on the value of
 
448
// expression 'exp'
 
449
class FloDisplaySwitch : public FloDisplay 
 
450
{
 
451
 public:
 
452
 
 
453
  virtual void Draw(SDL_Surface *screen);
 
454
};
 
455
 
 
456
// Circle switch display shows a circle which changes color and optionally
 
457
// flashes depending on the value of expression 'exp'
 
458
class FloDisplayCircleSwitch : public FloDisplay 
 
459
{
 
460
 public:
 
461
  FloDisplayCircleSwitch() : rad1(0), rad0(0), flash(0), prevnonz(0), 
 
462
    nonztime(0.) {};
 
463
 
 
464
  virtual void Draw(SDL_Surface *screen);
 
465
 
 
466
  int rad1, rad0; // Radii of circle when switch is on or off
 
467
 
 
468
  // For flashing
 
469
  char flash,  // Flash or solid colors?
 
470
    prevnonz;  // Previous character value of expression (for nonzero test)
 
471
  double nonztime; // System time at which the expression last became nonzero
 
472
};
 
473
 
 
474
enum CfgOrientation {
 
475
  O_Horizontal,
 
476
  O_Vertical
 
477
};
 
478
 
 
479
// Bar display shows the value of expression 'exp' as a bar
 
480
class FloDisplayBar : public FloDisplay 
 
481
{
 
482
 public:
 
483
  FloDisplayBar() : orient(O_Vertical), barscale(1.0), thickness(10) {};
 
484
 
 
485
  virtual void Draw(SDL_Surface *screen);
 
486
 
 
487
  CfgOrientation orient; // Orientation of bar
 
488
  float barscale; // Scaling factor for size of bar
 
489
  int thickness;  // Thickness of bar
 
490
};
 
491
 
 
492
// Bar-switch display shows the value of expression 'exp' as a bar and changes the color of the bar
 
493
// depending on the value of expression 'switchexp'
 
494
class FloDisplayBarSwitch : public FloDisplayBar
 
495
{
 
496
 public:
 
497
  FloDisplayBarSwitch() : switchexp(0), color(1), calibrate(0),
 
498
    cval(0.0) {};
 
499
  virtual ~FloDisplayBarSwitch() {
 
500
    if (switchexp != 0)
 
501
      delete switchexp;
 
502
  };
 
503
 
 
504
  virtual void Draw(SDL_Surface *screen);
 
505
 
 
506
  ParsedExpression *switchexp; // Expression which evaluates to a value. Nonzero values cause the bar 
 
507
                               // to appear bright, zero values cause a dim, faded bar
 
508
  
 
509
  int color; // Color of bar-switch (index of hardcoded color)
 
510
  char calibrate; // Nonzero shows calibration value on barswitch
 
511
  float cval; // Calibration value
 
512
};
 
513
 
 
514
// FluidSynth config
 
515
#include "fweelin_fluidsynth.h"
 
516
 
 
517
#if USE_FLUIDSYNTH
 
518
 
 
519
class FluidSynthParam {
 
520
 public:
 
521
  FluidSynthParam(char *name) : next(0) {
 
522
    this->name = new char[strlen(name)+1];
 
523
    strcpy(this->name,name);
 
524
  };
 
525
  virtual ~FluidSynthParam() { delete[] name; };
 
526
 
 
527
  // Send this parameter into the given settings
 
528
  virtual void Send(fluid_settings_t *settings) = 0;
 
529
 
 
530
  char *name;
 
531
  FluidSynthParam *next;
 
532
};
 
533
 
 
534
class FluidSynthParam_Num : public FluidSynthParam {
 
535
 public:
 
536
 
 
537
  FluidSynthParam_Num(char *name, double val) :
 
538
    FluidSynthParam(name), val(val) {};
 
539
 
 
540
  virtual void Send(fluid_settings_t *settings);
 
541
 
 
542
  double val;
 
543
};
 
544
 
 
545
class FluidSynthParam_Int : public FluidSynthParam {
 
546
 public:
 
547
 
 
548
  FluidSynthParam_Int(char *name, int val) :
 
549
    FluidSynthParam(name), val(val) {};
 
550
 
 
551
  virtual void Send(fluid_settings_t *settings);
 
552
 
 
553
  int val;
 
554
};
 
555
 
 
556
class FluidSynthParam_Str : public FluidSynthParam {
 
557
 public:
 
558
 
 
559
  FluidSynthParam_Str(char *name, char *val) :
 
560
    FluidSynthParam(name) {
 
561
    this->val = new char[strlen(val)+1];
 
562
    strcpy(this->val,val);
 
563
  };
 
564
  virtual ~FluidSynthParam_Str() { delete[] val; };
 
565
 
 
566
  virtual void Send(fluid_settings_t *settings);
 
567
 
 
568
  char *val;
 
569
};
 
570
 
 
571
class FluidSynthSoundFont {
 
572
 public:
 
573
  FluidSynthSoundFont(char *name) : next(0) {
 
574
    if (strchr(name,'/') != 0) {
 
575
      // Path specified
 
576
      this->name = new char[strlen(name)+1];
 
577
      strcpy(this->name,name);
 
578
    } else {
 
579
      // Path not specified, use default
 
580
      this->name = new char[strlen(FWEELIN_DATADIR)+1+strlen(name)+1];
 
581
      sprintf(this->name,"%s/%s",FWEELIN_DATADIR,name);
 
582
    }
 
583
  };
 
584
  ~FluidSynthSoundFont() { delete[] name; };
 
585
 
 
586
  char *name;
 
587
  FluidSynthSoundFont *next;
 
588
};
 
589
#endif
 
590
 
 
591
// Fweelin configuration
 
592
class FloConfig {
 
593
 public:
 
594
  FloConfig(Fweelin *app);
 
595
  ~FloConfig();
 
596
 
 
597
  // Parse configuration file, setup config
 
598
  void Parse();
 
599
 
 
600
  // Start function, called shortly before Fweelin begins running
 
601
  void Start() { im.Start(); };
 
602
 
 
603
  // Configure bindings between events and their triggers
 
604
  void ConfigureEventBindings(xmlDocPtr doc, xmlNode *events);
 
605
 
 
606
  void ConfigureElement(xmlDocPtr doc, xmlNode *elemn, 
 
607
                        FloLayoutElement *elem, float xscale, float yscale);
 
608
  void ConfigureLayout(xmlDocPtr doc, xmlNode *layn, 
 
609
                       FloLayout *lay, float xscale, float yscale);
 
610
  void ConfigureVideo(xmlDocPtr doc, xmlNode *vid);
 
611
  void ConfigureGeneral(xmlDocPtr doc, xmlNode *gen);
 
612
  
 
613
  // Is node 'n' a comment with help information? If so, add to our
 
614
  // internal help list
 
615
  void CheckForHelp(xmlNode *n);
 
616
 
 
617
  // Creates an empty variable based on the given name. The config file
 
618
  // can then refer to the variable
 
619
  UserVariable *AddEmptyVariable(char *name);
 
620
 
 
621
  // Makes the given variable into a system variable by linking it to
 
622
  // the pointer
 
623
  void LinkSystemVariable(char *name, CoreDataType type, char *ptr);
 
624
 
 
625
  // Input matrix- stores and handles all bindings between inputs and events
 
626
  inline InputMatrix *GetInputMatrix() { return &im; };
 
627
  InputMatrix im;
 
628
 
 
629
  // Extracts a comma separated array of floats from the given string-
 
630
  // returns size of array in 'size'
 
631
  float *ExtractArray(char *n, int *size);
 
632
 
 
633
  // Library path
 
634
  inline char *GetLibraryPath() { 
 
635
    if (librarypath != 0)
 
636
      return librarypath; 
 
637
    else {
 
638
      printf("CORE: ERROR: Library path not set in configuration!\n");
 
639
      exit(1);
 
640
    }
 
641
  };
 
642
  char *librarypath;
 
643
 
 
644
  // Number of MIDI out ports
 
645
  inline int GetNumMIDIOuts() { return midiouts; };
 
646
  int midiouts;
 
647
 
 
648
  // Is input/output #n stereo?
 
649
  inline char IsStereoInput(int n) { return ms_inputs[n]; };
 
650
  inline char IsStereoOutput(int n) { return IsStereoMaster(); };
 
651
  char *ms_inputs; // Zero or nonzero for each input- is this input stereo?
 
652
 
 
653
  // Is FreeWheeling running in stereo or completely in mono?
 
654
  char IsStereoMaster();
 
655
 
 
656
  // Number of external audio inputs into FreeWheeling (specified in config file)
 
657
  // AudioIO may add its own inputs internal to FreeWheeling 
 
658
  // (for example, softsynth)
 
659
  inline int GetExtAudioIns() { return extaudioins; };
 
660
  int extaudioins;
 
661
  
 
662
  // Maximum play volume
 
663
  inline float GetMaxPlayVol() { return maxplayvol; };
 
664
  float maxplayvol;
 
665
 
 
666
  // Maximum limiter gain
 
667
  inline float GetMaxLimiterGain() { return maxlimitergain; };
 
668
  float maxlimitergain;
 
669
 
 
670
  // Limiter threshhold
 
671
  inline float GetLimiterThreshhold() { return limiterthreshhold; };
 
672
  float limiterthreshhold;
 
673
 
 
674
  // Limiter release rate
 
675
  inline float GetLimiterReleaseRate() { return limiterreleaserate; };
 
676
  float limiterreleaserate;
 
677
 
 
678
  // Number of triggers (loop ids)
 
679
  inline int GetNumTriggers() { return num_triggers; };
 
680
  int num_triggers;
 
681
 
 
682
  // Video screen size
 
683
  inline int *GetVSize() { return vsize; };
 
684
  inline float XCvtf(float x) { return (x*vsize[0]); };
 
685
  inline float YCvtf(float y) { return (y*vsize[1]); };
 
686
  inline int XCvt(float x) { return (int) (x*vsize[0]); };
 
687
  inline int YCvt(float y) { return (int) (y*vsize[1]); };
 
688
  int vsize[2];
 
689
 
 
690
  // # of samples in visual oscilloscope buffer
 
691
  nframes_t scope_sample_len;
 
692
  inline nframes_t GetScopeSampleLen() { return scope_sample_len; };
 
693
 
 
694
  // Macro to check whether debug info is on
 
695
#define CRITTERS (app->getCFG()->IsDebugInfo())
 
696
  // Return nonzero if debug info to be shown
 
697
  char IsDebugInfo() { return showdebug; };
 
698
  // Show debugging info?
 
699
  char showdebug;
 
700
 
 
701
  // Graphical layouts
 
702
  FloLayout *GetLayouts() { return layouts; };
 
703
  FloLayout *layouts;
 
704
 
 
705
  // Graphical fonts
 
706
  // Returns the named font from our list of fonts
 
707
  FloFont *GetFont (char *name) {
 
708
    FloFont *cur = fonts;
 
709
    while (cur != 0 && strcmp(cur->name,name))
 
710
      cur = cur->next;
 
711
    return cur;
 
712
  };
 
713
  FloFont *GetFonts() { return fonts; };
 
714
  FloFont *fonts;
 
715
 
 
716
  // Graphical displays
 
717
  inline FloDisplay *GetDisplays() { return displays; };
 
718
  inline FloDisplay *GetDisplayById(int id) {
 
719
    FloDisplay *cur = displays;
 
720
    while (cur != 0) {
 
721
      if (cur->id == id)
 
722
        return cur;
 
723
      cur = cur->next;
 
724
    }
 
725
    return 0;
 
726
  };
 
727
  FloDisplay *displays;
 
728
 
 
729
  // Help text
 
730
  int GetNumHelpLines() {
 
731
    FloStringList *cur = help;
 
732
    int cnt = 0;
 
733
    while (cur != 0) {
 
734
      cnt++;
 
735
      cur = cur->next;
 
736
    }
 
737
 
 
738
    return cnt;
 
739
  };
 
740
  char *GetHelpLine(int idx, int col) {
 
741
    FloStringList *cur = help;
 
742
    int cnt = 0;
 
743
    while (cur != 0 && cnt != idx) {
 
744
      cnt++;
 
745
      cur = cur->next;
 
746
    }
 
747
    
 
748
    if (cur == 0)
 
749
      return 0;
 
750
    else
 
751
      return (col == 0 ? cur->str : cur->str2);
 
752
  };
 
753
  FloStringList *help;
 
754
 
 
755
#if USE_FLUIDSYNTH
 
756
  // FluidSynth config
 
757
  int fsinterp;
 
758
  int GetFluidInterpolation() { return fsinterp; };
 
759
  int fschannel;
 
760
  int GetFluidChannel() { return fschannel; };
 
761
  char fsstereo;
 
762
  char GetFluidStereo() { return fsstereo; };
 
763
  FluidSynthParam *fsparam;
 
764
  FluidSynthParam *GetFluidParam() { return fsparam; };
 
765
  void AddFluidParam(FluidSynthParam *nw) {
 
766
    if (fsparam == 0)
 
767
      fsparam = nw;
 
768
    else {
 
769
      FluidSynthParam *cur = fsparam;
 
770
      while (cur->next != 0)
 
771
        cur = cur->next;
 
772
      cur->next = nw;
 
773
    }
 
774
  };
 
775
  FluidSynthSoundFont *fsfont;
 
776
  void AddFluidFont(FluidSynthSoundFont *nw) {
 
777
    if (fsfont == 0)
 
778
      fsfont = nw;
 
779
    else {
 
780
      FluidSynthSoundFont *cur = fsfont;
 
781
      while (cur->next != 0)
 
782
        cur = cur->next;
 
783
      cur->next = nw;
 
784
    }
 
785
  };
 
786
  FluidSynthSoundFont *GetFluidFont() { return fsfont; };
 
787
#endif
 
788
 
 
789
  // Pitch transpose on outgoing MIDI events
 
790
  signed int transpose;
 
791
 
 
792
  // Chunksize for peaks & avgs display of loops
 
793
  // (bigger # means shorter displays)
 
794
  nframes_t loop_peaksavgs_chunksize;
 
795
 
 
796
  int status_report;
 
797
#define FS_REPORT_BLOCKMANAGER 1
 
798
  
 
799
  // Seconds of fixed audio history 
 
800
  const static float AUDIO_MEMORY_LEN;
 
801
  // # of audio blocks to preallocate
 
802
  const static int NUM_PREALLOCATED_AUDIO_BLOCKS;
 
803
 
 
804
};
 
805
 
 
806
#endif