+ Fl_Color => 0xrrggbbii
+ | | | |
+ | | | +--- index between 0 and 255
+ | | +----- blue color component (8 bit)
+ | +------- green component (8 bit)
+ +--------- red component (8 bit)
+
+
+ A color can have either an index or an rgb value. Colors with rgb set
+ and an index >0 are reserved for special use.
+
*/
-enum Fl_Color { // standard colors
- // These are used as default colors in widgets and altered as necessary
- FL_FOREGROUND_COLOR = 0, ///< the default foreground color (0) used for labels and text
- FL_BACKGROUND2_COLOR = 7, ///< the default background color for text, list, and valuator widgets
- FL_INACTIVE_COLOR = 8, ///< the inactive foreground color
- FL_SELECTION_COLOR = 15, ///< the default selection/highlight color
+typedef unsigned int Fl_Color;
+
+// Standard colors. These are used as default colors in widgets and altered as necessary
+const Fl_Color FL_FOREGROUND_COLOR = 0; ///< the default foreground color (0) used for labels and text
+const Fl_Color FL_BACKGROUND2_COLOR = 7; ///< the default background color for text, list, and valuator widgets
+const Fl_Color FL_INACTIVE_COLOR = 8; ///< the inactive foreground color
+const Fl_Color FL_SELECTION_COLOR = 15; ///< the default selection/highlight color
// boxtypes generally limit themselves to these colors so
// the whole ramp is not allocated:
- FL_GRAY0 = 32, // 'A'
- FL_DARK3 = 39, // 'H'
- FL_DARK2 = 45, // 'N'
- FL_DARK1 = 47, // 'P'
- FL_BACKGROUND_COLOR = 49, // 'R' default background color
- FL_LIGHT1 = 50, // 'S'
- FL_LIGHT2 = 52, // 'U'
- FL_LIGHT3 = 54, // 'W'
+const Fl_Color FL_GRAY0 = 32; // 'A'
+const Fl_Color FL_DARK3 = 39; // 'H'
+const Fl_Color FL_DARK2 = 45; // 'N'
+const Fl_Color FL_DARK1 = 47; // 'P'
+const Fl_Color FL_BACKGROUND_COLOR = 49; // 'R' default background color
+const Fl_Color FL_LIGHT1 = 50; // 'S'
+const Fl_Color FL_LIGHT2 = 52; // 'U'
+const Fl_Color FL_LIGHT3 = 54; // 'W'
// FLTK provides a 5x8x5 color cube that is used with colormap visuals
- FL_BLACK = 56,
- FL_RED = 88,
- FL_GREEN = 63,
- FL_YELLOW = 95,
- FL_BLUE = 216,
- FL_MAGENTA = 248,
- FL_CYAN = 223,
- FL_DARK_RED = 72,
+const Fl_Color FL_BLACK = 56;
+const Fl_Color FL_RED = 88;
+const Fl_Color FL_GREEN = 63;
+const Fl_Color FL_YELLOW = 95;
+const Fl_Color FL_BLUE = 216;
+const Fl_Color FL_MAGENTA = 248;
+const Fl_Color FL_CYAN = 223;
+const Fl_Color FL_DARK_RED = 72;
- FL_DARK_GREEN = 60,
- FL_DARK_YELLOW = 76,
- FL_DARK_BLUE = 136,
- FL_DARK_MAGENTA = 152,
- FL_DARK_CYAN = 140,
+const Fl_Color FL_DARK_GREEN = 60;
+const Fl_Color FL_DARK_YELLOW = 76;
+const Fl_Color FL_DARK_BLUE = 136;
+const Fl_Color FL_DARK_MAGENTA = 152;
+const Fl_Color FL_DARK_CYAN = 140;
- FL_WHITE = 255
-};
+const Fl_Color FL_WHITE = 255;
-#define FL_FREE_COLOR (Fl_Color)16
-#define FL_NUM_FREE_COLOR 16
-#define FL_GRAY_RAMP (Fl_Color)32
-#define FL_NUM_GRAY 24
-#define FL_GRAY FL_BACKGROUND_COLOR
-#define FL_COLOR_CUBE (Fl_Color)56
-#define FL_NUM_RED 5
-#define FL_NUM_GREEN 8
-#define FL_NUM_BLUE 5
+
+#define FL_FREE_COLOR (Fl_Color)16
+#define FL_NUM_FREE_COLOR 16
+#define FL_GRAY_RAMP (Fl_Color)32
+#define FL_NUM_GRAY 24
+#define FL_GRAY FL_BACKGROUND_COLOR
+#define FL_COLOR_CUBE (Fl_Color)56
+#define FL_NUM_RED 5
+#define FL_NUM_GREEN 8
+#define FL_NUM_BLUE 5
FL_EXPORT Fl_Color fl_inactive(Fl_Color c);
+
FL_EXPORT Fl_Color fl_contrast(Fl_Color fg, Fl_Color bg);
+
FL_EXPORT Fl_Color fl_color_average(Fl_Color c1, Fl_Color c2, float weight);
+
inline Fl_Color fl_lighter(Fl_Color c) { return fl_color_average(c, FL_WHITE, .67f); }
+
inline Fl_Color fl_darker(Fl_Color c) { return fl_color_average(c, FL_BLACK, .67f); }
+
/** return 24-bit color value closest to \p r, \p g, \p b. */
inline Fl_Color fl_rgb_color(uchar r, uchar g, uchar b) {
if (!r && !g && !b) return FL_BLACK;
else return (Fl_Color)(((((r << 8) | g) << 8) | b) << 8);
}
+
/** return 24-bit color value closest to \p grayscale */
inline Fl_Color fl_rgb_color(uchar g) {
if (!g) return FL_BLACK;
else return (Fl_Color)(((((g << 8) | g) << 8) | g) << 8);
}
+
inline Fl_Color fl_gray_ramp(int i) {return (Fl_Color)(i+FL_GRAY_RAMP);}
+
inline Fl_Color fl_color_cube(int r, int g, int b) {
return (Fl_Color)((b*FL_NUM_RED + r) * FL_NUM_GREEN + g + FL_COLOR_CUBE);}
@@ -857,5 +886,5 @@ enum Fl_Damage {
#endif
//
-// End of "$Id: Enumerations.H 6735 2009-04-01 22:11:57Z engelsman $".
+// End of "$Id: Enumerations.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl.H b/plugins/zynaddsubfx/fltk/FL/Fl.H
index d9f8e77e1..700f51936 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl.H 6771 2009-04-19 12:47:36Z matt $"
+// "$Id: Fl.H 6903 2009-09-27 11:09:03Z matt $"
//
// Main header file for the Fast Light Tool Kit (FLTK).
//
@@ -489,18 +489,25 @@ public:
static int event_state() {return e_state;}
/** See int event_state() */
static int event_state(int i) {return e_state&i;}
- /** Gets which key on the keyboard was last pushed.
- \retval 0 if the last event was not a key press or release.
- \see int event_key(int) */
+ /**
+ Gets which key on the keyboard was last pushed.
+
+ The returned integer 'key code' is not necessarily a text
+ equivalent for the keystroke. For instance: if someone presses '5' on the
+ numeric keypad with numlock on, Fl::event_key() may return the 'key code'
+ for this key, and NOT the character '5'. To always get the '5', use Fl::event_text() instead.
+
+ \returns an integer 'key code', or 0 if the last event was not a key press or release.
+ \see int event_key(int), event_text(), compose(int&).
+ */
static int event_key() {return e_keysym;}
/**
Returns the keycode of the last key event, regardless of the NumLock state.
-
+
If NumLock is deactivated, FLTK translates events from the
numeric keypad into the corresponding arrow key events.
event_key() returns the translated key code, whereas
- event_original_key() returns the keycode before
- NumLock translation.
+ event_original_key() returns the keycode before NumLock translation.
*/
static int event_original_key(){return e_original_keysym;}
/**
@@ -548,7 +555,20 @@ public:
slower than Fl::event_key(int). \see event_key(int)
*/
static int get_key(int key); // platform dependent
- /** Returns the text associated with the current FL_PASTE or FL_DND_RELEASE event. */
+ /**
+ Returns the text associated with the current event, including FL_PASTE or FL_DND_RELEASE events.
+ This can be used in response to FL_KEYUP, FL_KEYDOWN, FL_PASTE, FL_DND_RELEASE.
+
+ When responding to FL_KEYUP/FL_KEYDOWN, use this function instead of Fl::event_key()
+ to get the text equivalent of keystrokes suitable for inserting into strings
+ and text widgets.
+
+ The returned string is guaranteed to be be NULL terminated.
+ However, see Fl::event_length() for the actual length of the string,
+ in case the string itself contains NULLs that are part of the text data.
+
+ \returns A NULL terminated text string equivalent of the last keystroke.
+ */
static const char* event_text() {return e_text;}
/**
Returns the length of the text in Fl::event_text(). There
@@ -568,7 +588,7 @@ public:
static void compose_reset() {compose_state = 0;}
static int event_inside(int,int,int,int);
static int event_inside(const Fl_Widget*);
- static int test_shortcut(int);
+ static int test_shortcut(Fl_Shortcut);
// event destinations:
static int handle(int, Fl_Window*);
@@ -660,7 +680,7 @@ public:
8-bit RGB color. The color is not allocated until fl_color(i) is used.
*/
static void set_color(Fl_Color, unsigned); // platform dependent
- static unsigned get_color(Fl_Color);
+ static Fl_Color get_color(Fl_Color);
static void get_color(Fl_Color, uchar&, uchar&, uchar&);
/**
Frees the specified color from the colormap, if applicable.
@@ -1022,5 +1042,5 @@ public:
#endif // !Fl_H
//
-// End of "$Id: Fl.H 6771 2009-04-19 12:47:36Z matt $".
+// End of "$Id: Fl.H 6903 2009-09-27 11:09:03Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Browser.H b/plugins/zynaddsubfx/fltk/FL/Fl_Browser.H
index d8f920d4e..a2f8b00ce 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Browser.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Browser.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Browser.H 6726 2009-03-27 16:52:31Z greg.ercolano $"
+// "$Id: Fl_Browser.H 6850 2009-09-07 02:25:51Z greg.ercolano $"
//
// Browser header file for the Fast Light Tool Kit (FLTK).
//
@@ -36,6 +36,7 @@
#define Fl_Browser_H
#include "Fl_Browser_.H"
+#include "Fl_Image.H"
struct FL_BLINE;
@@ -306,6 +307,11 @@ public:
else Fl_Browser_::display(find_line(line));
}
+ // icon support
+ void icon(int line, Fl_Image* icon);
+ Fl_Image* icon(int line) const;
+ void remove_icon(int line);
+
/** For back compatibility only. */
void replace(int a, const char* b) { text(a, b); }
void display(int line, int val=1);
@@ -314,5 +320,5 @@ public:
#endif
//
-// End of "$Id: Fl_Browser.H 6726 2009-03-27 16:52:31Z greg.ercolano $".
+// End of "$Id: Fl_Browser.H 6850 2009-09-07 02:25:51Z greg.ercolano $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Browser_.H b/plugins/zynaddsubfx/fltk/FL/Fl_Browser_.H
index 3d89a8ec9..4068ae48b 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Browser_.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Browser_.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Browser_.H 6737 2009-04-02 06:44:34Z greg.ercolano $"
+// "$Id: Fl_Browser_.H 6902 2009-09-27 11:06:56Z matt $"
//
// Common browser header file for the Fast Light Tool Kit (FLTK).
//
@@ -74,7 +74,7 @@ class FL_EXPORT Fl_Browser_ : public Fl_Group {
uchar has_scrollbar_; // which scrollbars are enabled
Fl_Font textfont_;
Fl_Fontsize textsize_;
- unsigned textcolor_;
+ Fl_Color textcolor_;
void* top_; // which item scrolling position is in
void* selection_; // which is selected (except for FL_MULTI_BROWSER)
void *redraw1,*redraw2; // minimal update pointers
@@ -297,11 +297,11 @@ public:
/**
Gets the default text color for the lines in the browser.
*/
- Fl_Color textcolor() const { return (Fl_Color)textcolor_; }
+ Fl_Color textcolor() const { return textcolor_; }
/**
Sets the default text color for the lines in the browser to color \p col.
*/
- void textcolor(unsigned col) { textcolor_ = col; }
+ void textcolor(Fl_Color col) { textcolor_ = col; }
/**
Gets the current size of the scrollbars' troughs, in pixels.
@@ -374,5 +374,5 @@ public:
#endif
//
-// End of "$Id: Fl_Browser_.H 6737 2009-04-02 06:44:34Z greg.ercolano $".
+// End of "$Id: Fl_Browser_.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Button.H b/plugins/zynaddsubfx/fltk/FL/Fl_Button.H
index d71c06672..73d6e4b0d 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Button.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Button.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Button.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Button.H 6878 2009-09-17 22:12:24Z matt $"
//
// Button header file for the Fast Light Tool Kit (FLTK).
//
@@ -45,7 +45,7 @@
#define FL_HIDDEN_BUTTON 3 ///< for Forms compatibility
#ifndef FL_DOXYGEN
-extern FL_EXPORT int fl_old_shortcut(const char*);
+extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
#endif
/**
@@ -172,5 +172,5 @@ public:
#endif
//
-// End of "$Id: Fl_Button.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Button.H 6878 2009-09-17 22:12:24Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Chart.H b/plugins/zynaddsubfx/fltk/FL/Fl_Chart.H
index 29b68ed44..e94c1a02a 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Chart.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Chart.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Chart.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Chart.H 6902 2009-09-27 11:06:56Z matt $"
//
// Forms chart header file for the Fast Light Tool Kit (FLTK).
//
@@ -87,7 +87,7 @@ class FL_EXPORT Fl_Chart : public Fl_Widget {
uchar autosize_;
Fl_Font textfont_;
Fl_Fontsize textsize_;
- unsigned textcolor_;
+ Fl_Color textcolor_;
protected:
void draw();
public:
@@ -136,9 +136,9 @@ public:
void textsize(Fl_Fontsize s) {textsize_ = s;}
/** Gets the chart's text color */
- Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
+ Fl_Color textcolor() const {return textcolor_;}
/** gets the chart's text color to \p n. */
- void textcolor(unsigned n) {textcolor_ = n;}
+ void textcolor(Fl_Color n) {textcolor_ = n;}
/**
Get whether the chart will automatically adjust the bounds of the chart.
@@ -156,5 +156,5 @@ public:
#endif
//
-// End of "$Id: Fl_Chart.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Chart.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Clock.H b/plugins/zynaddsubfx/fltk/FL/Fl_Clock.H
index afaa2f446..c4cf6c21b 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Clock.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Clock.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Clock.H 6754 2009-04-12 11:32:22Z AlbrechtS $"
+// "$Id: Fl_Clock.H 6812 2009-07-01 07:27:25Z AlbrechtS $"
//
// Clock header file for the Fast Light Tool Kit (FLTK).
//
@@ -133,5 +133,5 @@ public:
#endif
//
-// End of "$Id: Fl_Clock.H 6754 2009-04-12 11:32:22Z AlbrechtS $".
+// End of "$Id: Fl_Clock.H 6812 2009-07-01 07:27:25Z AlbrechtS $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Counter.H b/plugins/zynaddsubfx/fltk/FL/Fl_Counter.H
index e52c092c5..24930779a 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Counter.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Counter.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Counter.H 6716 2009-03-24 01:40:44Z fabien $"
+// "$Id: Fl_Counter.H 6902 2009-09-27 11:06:56Z matt $"
//
// Counter header file for the Fast Light Tool Kit (FLTK).
//
@@ -58,7 +58,7 @@ class FL_EXPORT Fl_Counter : public Fl_Valuator {
Fl_Font textfont_;
Fl_Fontsize textsize_;
- unsigned textcolor_;
+ Fl_Color textcolor_;
double lstep_;
uchar mouseobj;
static void repeat_callback(void *);
@@ -111,14 +111,14 @@ public:
void textsize(Fl_Fontsize s) {textsize_ = s;}
/** Gets the font color */
- Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
+ Fl_Color textcolor() const {return textcolor_;}
/** Sets the font color to \p s */
- void textcolor(unsigned s) {textcolor_ = s;}
+ void textcolor(Fl_Color s) {textcolor_ = s;}
};
#endif
//
-// End of "$Id: Fl_Counter.H 6716 2009-03-24 01:40:44Z fabien $".
+// End of "$Id: Fl_Counter.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Group.H b/plugins/zynaddsubfx/fltk/FL/Fl_Group.H
index 2db9d7992..5ba61ad25 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Group.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Group.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Group.H 6716 2009-03-24 01:40:44Z fabien $"
+// "$Id: Fl_Group.H 6907 2009-09-28 14:34:52Z matt $"
//
// Group header file for the Fast Light Tool Kit (FLTK).
//
@@ -58,8 +58,6 @@ class FL_EXPORT Fl_Group : public Fl_Widget {
Fl_Group& operator=(const Fl_Group&);
protected:
- enum { CLIP_CHILDREN = 2048 };
-
void draw();
void draw_child(Fl_Widget& widget) const;
void draw_children();
@@ -176,7 +174,7 @@ public:
\see void Fl_Group::clip_children(int c)
*/
- int clip_children() { return (flags() & CLIP_CHILDREN) != 0; }
+ unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; }
// back compatibility functions:
@@ -224,5 +222,5 @@ public:
#endif
//
-// End of "$Id: Fl_Group.H 6716 2009-03-24 01:40:44Z fabien $".
+// End of "$Id: Fl_Group.H 6907 2009-09-28 14:34:52Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Input_.H b/plugins/zynaddsubfx/fltk/FL/Fl_Input_.H
index 7217bb660..26dab7d1a 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Input_.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Input_.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Input_.H 6777 2009-04-23 15:32:19Z matt $"
+// "$Id: Fl_Input_.H 6902 2009-09-27 11:06:56Z matt $"
//
// Input base class header file for the Fast Light Tool Kit (FLTK).
//
@@ -120,7 +120,7 @@ class FL_EXPORT Fl_Input_ : public Fl_Widget {
\p mark_, no text is selected */
int mark_;
- /** \internal Offset to text origin within wdget bounds */
+ /** \internal Offset to text origin within widget bounds */
int xscroll_, yscroll_;
/** \internal Minimal update pointer. Display requirs redraw from here to the end
@@ -143,10 +143,10 @@ class FL_EXPORT Fl_Input_ : public Fl_Widget {
Fl_Fontsize textsize_;
/** \internal color of the entire text */
- unsigned textcolor_;
+ Fl_Color textcolor_;
/** \internal color of the text cursor */
- unsigned cursor_color_;
+ Fl_Color cursor_color_;
/** \internal Horizontal cursor position in pixels while movin up or down. */
static double up_down_pos;
@@ -206,6 +206,7 @@ protected:
/** \internal Vertical offset of text to top edge of widget. */
int yscroll() const {return yscroll_;}
+ void yscroll(int y) { yscroll_ = y; damage(FL_DAMAGE_EXPOSE);}
/* Return the number of lines displayed on a single page. */
int linesPerPage();
@@ -396,23 +397,23 @@ public:
/** Gets the color of the text in the input field.
\return the text color
- \see textcolor(unsigned) */
- Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
+ \see textcolor(Fl_Color) */
+ Fl_Color textcolor() const {return textcolor_;}
/** Sets the color of the text in the input field.
The text color defaults to \c FL_FOREGROUND_COLOR.
\param [in] n new text color
\see textcolor() */
- void textcolor(unsigned n) {textcolor_ = n;}
+ void textcolor(Fl_Color n) {textcolor_ = n;}
/** Gets the color of the cursor.
\return the current cursor color */
- Fl_Color cursor_color() const {return (Fl_Color)cursor_color_;}
+ Fl_Color cursor_color() const {return cursor_color_;}
/** Sets the color of the cursor.
The default color for the cursor is \c FL_BLACK.
\param [in] n the new cursor color */
- void cursor_color(unsigned n) {cursor_color_ = n;}
+ void cursor_color(Fl_Color n) {cursor_color_ = n;}
/** Gets the input field type.
\return the current input type */
@@ -450,5 +451,5 @@ public:
#endif
//
-// End of "$Id: Fl_Input_.H 6777 2009-04-23 15:32:19Z matt $".
+// End of "$Id: Fl_Input_.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Menu_.H b/plugins/zynaddsubfx/fltk/FL/Fl_Menu_.H
index 41bcd5c14..89ced65f6 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Menu_.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Menu_.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu_.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Menu_.H 6902 2009-09-27 11:06:56Z matt $"
//
// Menu base class header file for the Fast Light Tool Kit (FLTK).
//
@@ -56,7 +56,7 @@ protected:
uchar down_box_;
Fl_Font textfont_;
Fl_Fontsize textsize_;
- unsigned textcolor_;
+ Fl_Color textcolor_;
public:
Fl_Menu_(int,int,int,int,const char * =0);
@@ -119,9 +119,9 @@ public:
/** Sets the font size of menu item labels. */
void textsize(Fl_Fontsize c) {textsize_=c;}
/** Get the current color of menu item labels. */
- Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
+ Fl_Color textcolor() const {return textcolor_;}
/** Sets the current color of menu item labels. */
- void textcolor(unsigned c) {textcolor_=c;}
+ void textcolor(Fl_Color c) {textcolor_=c;}
/**
This box type is used to surround the currently-selected items in the
@@ -142,5 +142,5 @@ public:
#endif
//
-// End of "$Id: Fl_Menu_.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Menu_.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Menu_Item.H b/plugins/zynaddsubfx/fltk/FL/Fl_Menu_Item.H
index b4052b8c8..be81b8cc0 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Menu_Item.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Menu_Item.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu_Item.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Menu_Item.H 6902 2009-09-27 11:06:56Z matt $"
//
// Menu item header file for the Fast Light Tool Kit (FLTK).
//
@@ -36,18 +36,18 @@
# endif
enum { // values for flags:
- FL_MENU_INACTIVE = 1,
- FL_MENU_TOGGLE= 2,
- FL_MENU_VALUE = 4,
- FL_MENU_RADIO = 8,
- FL_MENU_INVISIBLE = 0x10,
- FL_SUBMENU_POINTER = 0x20,
- FL_SUBMENU = 0x40,
- FL_MENU_DIVIDER = 0x80,
- FL_MENU_HORIZONTAL = 0x100
+ FL_MENU_INACTIVE = 1, ///< Deactivate menu item (gray out)
+ FL_MENU_TOGGLE= 2, ///< Item is a checkbox toggle (shows checkbox for on/off state)
+ FL_MENU_VALUE = 4, ///< The on/off state for checkbox/radio buttons (if set, state is 'on')
+ FL_MENU_RADIO = 8, ///< Item is a radio button (one checkbox of many can be on)
+ FL_MENU_INVISIBLE = 0x10, ///< Item will not show up (shortcut will work)
+ FL_SUBMENU_POINTER = 0x20, ///< Indicates user_data() is a pointer to another menu array
+ FL_SUBMENU = 0x40, ///< This item is a submenu to other items
+ FL_MENU_DIVIDER = 0x80, ///< Creates divider line below this item. Also ends a group of radio buttons.
+ FL_MENU_HORIZONTAL = 0x100 ///< ??? -- reserved
};
-extern FL_EXPORT int fl_old_shortcut(const char*);
+extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
class Fl_Menu_;
@@ -68,15 +68,15 @@ class Fl_Menu_;
};
enum { // values for flags:
- FL_MENU_INACTIVE = 1,
- FL_MENU_TOGGLE = 2,
- FL_MENU_VALUE = 4,
- FL_MENU_RADIO = 8,
- FL_MENU_INVISIBLE = 0x10,
- FL_SUBMENU_POINTER = 0x20,
- FL_SUBMENU = 0x40,
- FL_MENU_DIVIDER = 0x80,
- FL_MENU_HORIZONTAL = 0x100
+ FL_MENU_INACTIVE = 1, // Deactivate menu item (gray out)
+ FL_MENU_TOGGLE = 2, // Item is a checkbox toggle (shows checkbox for on/off state)
+ FL_MENU_VALUE = 4, // The on/off state for checkbox/radio buttons (if set, state is 'on')
+ FL_MENU_RADIO = 8, // Item is a radio button (one checkbox of many can be on)
+ FL_MENU_INVISIBLE = 0x10, // Item will not show up (shortcut will work)
+ FL_SUBMENU_POINTER = 0x20, // Indicates user_data() is a pointer to another menu array
+ FL_SUBMENU = 0x40, // This item is a submenu to other items
+ FL_MENU_DIVIDER = 0x80, // Creates divider line below this item. Also ends a group of radio buttons.
+ FL_MENU_HORIZONTAL = 0x100 // ??? -- reserved
};
\endcode
Typically menu items are statically defined; for example:
@@ -124,7 +124,7 @@ struct FL_EXPORT Fl_Menu_Item {
uchar labeltype_; ///< how the menu item text looks like
Fl_Font labelfont_; ///< which font for this menu item text
Fl_Fontsize labelsize_; ///< size of menu item text
- unsigned labelcolor_; ///< menu item text color
+ Fl_Color labelcolor_; ///< menu item text color
// advance N items, skipping submenus:
const Fl_Menu_Item *next(int=1) const;
@@ -181,10 +181,10 @@ struct FL_EXPORT Fl_Menu_Item {
color is not black fltk will not use overlay bitplanes to draw
the menu - this is so that images put in the menu draw correctly.
*/
- Fl_Color labelcolor() const {return (Fl_Color)labelcolor_;}
+ Fl_Color labelcolor() const {return labelcolor_;}
/** See Fl_Color Fl_Menu_Item::labelcolor() const */
- void labelcolor(unsigned a) {labelcolor_ = a;}
+ void labelcolor(Fl_Color a) {labelcolor_ = a;}
/**
Fonts are identified by small 8-bit indexes into a table. See the
enumeration list for predefined fonts. The default value is a
@@ -414,5 +414,5 @@ enum { // back-compatibility enum:
#endif
//
-// End of "$Id: Fl_Menu_Item.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Menu_Item.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Menu_Window.H b/plugins/zynaddsubfx/fltk/FL/Fl_Menu_Window.H
index e2e77f1ea..217e224af 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Menu_Window.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Menu_Window.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu_Window.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Menu_Window.H 6909 2009-09-28 14:41:43Z matt $"
//
// Menu window header file for the Fast Light Tool Kit (FLTK).
//
@@ -40,14 +40,13 @@
redraw.
*/
class FL_EXPORT Fl_Menu_Window : public Fl_Single_Window {
- enum {NO_OVERLAY = 128};
public:
void show();
void erase();
void flush();
void hide();
/** Tells if hardware overlay mode is set */
- int overlay() {return !(flags()&NO_OVERLAY);}
+ unsigned int overlay() {return !(flags()&NO_OVERLAY);}
/** Tells FLTK to use hardware overlay planes if they are available. */
void set_overlay() {clear_flag(NO_OVERLAY);}
/** Tells FLTK to use normal drawing planes instead of overlay planes.
@@ -65,5 +64,5 @@ public:
#endif
//
-// End of "$Id: Fl_Menu_Window.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Menu_Window.H 6909 2009-09-28 14:41:43Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Multiline_Input.H b/plugins/zynaddsubfx/fltk/FL/Fl_Multiline_Input.H
index feec46498..5f46624be 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Multiline_Input.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Multiline_Input.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Multiline_Input.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Multiline_Input.H 6889 2009-09-19 22:09:00Z greg.ercolano $"
//
// Multiline input header file for the Fast Light Tool Kit (FLTK).
//
@@ -38,11 +38,15 @@
This input field displays '\n' characters as new lines rather than ^J,
and accepts the Return, Tab, and up and down arrow keys. This is for
editing multiline text.
-
This is far from the nirvana of text editors, and is probably only
- good for small bits of text, 10 lines at most. I think FLTK can be
- used to write a powerful text editor, but it is not going to be a
- built-in feature. Powerful text editors in a toolkit are a big source
- of bloat.
+
+ This is far from the nirvana of text editors, and is probably only
+ good for small bits of text, 10 lines at most. Note that this widget
+ does not support scrollbars or per-character color control.
+
+ If you are presenting large amounts of text and need scrollbars
+ or full color control of characters, you probably want Fl_Text_Editor
+ instead.
+
*/
class Fl_Multiline_Input : public Fl_Input {
public:
@@ -58,5 +62,5 @@ public:
#endif
//
-// End of "$Id: Fl_Multiline_Input.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Multiline_Input.H 6889 2009-09-19 22:09:00Z greg.ercolano $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Multiline_Output.H b/plugins/zynaddsubfx/fltk/FL/Fl_Multiline_Output.H
index 0dbcb06dc..f0edf63d0 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Multiline_Output.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Multiline_Output.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Multiline_Output.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Multiline_Output.H 6889 2009-09-19 22:09:00Z greg.ercolano $"
//
// Multi line output header file for the Fast Light Tool Kit (FLTK).
//
@@ -37,6 +37,14 @@
This widget is a subclass of Fl_Output that displays multiple
lines of text. It also displays tab characters as whitespace to the
next column.
+
+ Note that this widget does not support scrollbars, or per-character
+ color control.
+
+ If you are presenting large amounts of read-only text
+ and need scrollbars, or full color control of characters,
+ then use Fl_Text_Display. If you want to display HTML text,
+ use Fl_Help_View.
*/
class Fl_Multiline_Output : public Fl_Output {
public:
@@ -52,5 +60,5 @@ public:
#endif
//
-// End of "$Id: Fl_Multiline_Output.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Multiline_Output.H 6889 2009-09-19 22:09:00Z greg.ercolano $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Output.H b/plugins/zynaddsubfx/fltk/FL/Fl_Output.H
index 0d02d82d5..58b33378f 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Output.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Output.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Output.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Output.H 6898 2009-09-23 20:43:27Z matt $"
//
// Output header file for the Fast Light Tool Kit (FLTK).
//
@@ -42,7 +42,8 @@
\image latex text.eps "Fl_Output" width=8cm
There is a single subclass,
Fl_Multiline_Output, which allows you to display multiple lines of
- text.
+ text. Fl_Multiline_Output does not provide scroll bars. If a more
+ complete text editing widget is needed, use Fl_Text_Display instead.
The text may contain any characters except \\0, and will correctly
display anything, using ^X notation for unprintable control characters
and \\nnn notation for unprintable characters with the high bit set. It
@@ -63,5 +64,5 @@ public:
#endif
//
-// End of "$Id: Fl_Output.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Output.H 6898 2009-09-23 20:43:27Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Scroll.H b/plugins/zynaddsubfx/fltk/FL/Fl_Scroll.H
index e36be6d23..a8bbdb480 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Scroll.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Scroll.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Scroll.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Scroll.H 6828 2009-07-12 00:15:06Z greg.ercolano $"
//
// Scroll header file for the Fast Light Tool Kit (FLTK).
//
@@ -193,5 +193,5 @@ public:
#endif
//
-// End of "$Id: Fl_Scroll.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Scroll.H 6828 2009-07-12 00:15:06Z greg.ercolano $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Text_Buffer.H b/plugins/zynaddsubfx/fltk/FL/Fl_Text_Buffer.H
index 7efca467c..a4d85139c 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Text_Buffer.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Text_Buffer.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Text_Buffer.H 6618 2009-01-01 21:54:10Z matt $"
+// "$Id: Fl_Text_Buffer.H 6822 2009-07-04 00:24:26Z fabien $"
//
// Header file for Fl_Text_Buffer class.
//
@@ -322,5 +322,5 @@ class FL_EXPORT Fl_Text_Buffer {
#endif
//
-// End of "$Id: Fl_Text_Buffer.H 6618 2009-01-01 21:54:10Z matt $".
+// End of "$Id: Fl_Text_Buffer.H 6822 2009-07-04 00:24:26Z fabien $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Text_Display.H b/plugins/zynaddsubfx/fltk/FL/Fl_Text_Display.H
index 2986b1cd7..495737718 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Text_Display.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Text_Display.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Text_Display.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Text_Display.H 6902 2009-09-27 11:06:56Z matt $"
//
// Header file for Fl_Text_Display class.
//
@@ -165,9 +165,9 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group {
/** Sets the default size of text in the widget. */
void textsize(Fl_Fontsize s) {textsize_ = s;}
/** Gets the default color of text in the widget. */
- Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
+ Fl_Color textcolor() const {return textcolor_;}
/** Sets the default color of text in the widget. */
- void textcolor(unsigned n) {textcolor_ = n;}
+ void textcolor(Fl_Color n) {textcolor_ = n;}
int wrapped_column(int row, int column) const;
int wrapped_row(int row) const;
@@ -327,7 +327,7 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group {
Fl_Font textfont_;
Fl_Fontsize textsize_;
- unsigned textcolor_;
+ Fl_Color textcolor_;
// The following are not presently used from the original NEdit code,
// but are being put here so that future versions of Fl_Text_Display
@@ -340,5 +340,5 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group {
#endif
//
-// End of "$Id: Fl_Text_Display.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Text_Display.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Text_Editor.H b/plugins/zynaddsubfx/fltk/FL/Fl_Text_Editor.H
index 85f3611db..be3b718a3 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Text_Editor.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Text_Editor.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Text_Editor.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Text_Editor.H 6893 2009-09-20 19:24:24Z greg.ercolano $"
//
// Header file for Fl_Text_Editor class.
//
@@ -103,6 +103,8 @@ class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display {
static int kf_shift_move(int c, Fl_Text_Editor* e);
static int kf_ctrl_move(int c, Fl_Text_Editor* e);
static int kf_c_s_move(int c, Fl_Text_Editor* e);
+ static int kf_meta_move(int c, Fl_Text_Editor* e);
+ static int kf_m_s_move(int c, Fl_Text_Editor* e);
static int kf_home(int, Fl_Text_Editor* e);
static int kf_end(int c, Fl_Text_Editor* e);
static int kf_left(int c, Fl_Text_Editor* e);
@@ -134,6 +136,6 @@ class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display {
#endif
//
-// End of "$Id: Fl_Text_Editor.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Text_Editor.H 6893 2009-09-20 19:24:24Z greg.ercolano $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Tooltip.H b/plugins/zynaddsubfx/fltk/FL/Fl_Tooltip.H
index 033e83f2b..c5ec20641 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Tooltip.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Tooltip.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Tooltip.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Tooltip.H 6902 2009-09-27 11:06:56Z matt $"
//
// Tooltip header file for the Fast Light Tool Kit (FLTK).
//
@@ -76,13 +76,13 @@ public:
/** Sets the size of the tooltip text. */
static void size(Fl_Fontsize s) { size_ = s; }
/** Gets the background color for tooltips. The default background color is a pale yellow. */
- static Fl_Color color() { return (Fl_Color)color_; }
+ static Fl_Color color() { return color_; }
/** Sets the background color for tooltips. The default background color is a pale yellow. */
- static void color(unsigned c) { color_ = c; }
+ static void color(Fl_Color c) { color_ = c; }
/** Gets the color of the text in the tooltip. The default is black. */
- static Fl_Color textcolor() { return (Fl_Color)textcolor_; }
+ static Fl_Color textcolor() { return textcolor_; }
/** Sets the color of the text in the tooltip. The default is black. */
- static void textcolor(unsigned c) { textcolor_ = c; }
+ static void textcolor(Fl_Color c) { textcolor_ = c; }
// These should not be public, but Fl_Widget::tooltip() needs them...
// fabien: made it private with only a friend function access
@@ -95,8 +95,8 @@ private:
static float delay_; //!< delay before a tooltip is shown
static float hoverdelay_; //!< delay between tooltips
static int enabled_;
- static unsigned color_;
- static unsigned textcolor_;
+ static Fl_Color color_;
+ static Fl_Color textcolor_;
static Fl_Font font_;
static Fl_Fontsize size_;
static Fl_Widget* widget_; //!< Keeps track of the current target widget
@@ -105,5 +105,5 @@ private:
#endif
//
-// End of "$Id: Fl_Tooltip.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Tooltip.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Value_Input.H b/plugins/zynaddsubfx/fltk/FL/Fl_Value_Input.H
index 52d9f31d1..4ed1b1011 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Value_Input.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Value_Input.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Value_Input.H 6664 2009-02-18 09:27:54Z AlbrechtS $"
+// "$Id: Fl_Value_Input.H 6902 2009-09-27 11:06:56Z matt $"
//
// Value input header file for the Fast Light Tool Kit (FLTK).
//
@@ -120,16 +120,16 @@ public:
/** Gets the color of the text in the value box. */
Fl_Color textcolor() const {return input.textcolor();}
/** Sets the color of the text in the value box.*/
- void textcolor(unsigned n) {input.textcolor(n);}
+ void textcolor(Fl_Color n) {input.textcolor(n);}
/** Gets the color of the text cursor. The text cursor is black by default. */
Fl_Color cursor_color() const {return input.cursor_color();}
/** Sets the color of the text cursor. The text cursor is black by default. */
- void cursor_color(unsigned n) {input.cursor_color(n);}
+ void cursor_color(Fl_Color n) {input.cursor_color(n);}
};
#endif
//
-// End of "$Id: Fl_Value_Input.H 6664 2009-02-18 09:27:54Z AlbrechtS $".
+// End of "$Id: Fl_Value_Input.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Value_Output.H b/plugins/zynaddsubfx/fltk/FL/Fl_Value_Output.H
index 1654219c6..5dda0ca89 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Value_Output.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Value_Output.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Value_Output.H 6664 2009-02-18 09:27:54Z AlbrechtS $"
+// "$Id: Fl_Value_Output.H 6902 2009-09-27 11:06:56Z matt $"
//
// Value output header file for the Fast Light Tool Kit (FLTK).
//
@@ -51,7 +51,7 @@ class FL_EXPORT Fl_Value_Output : public Fl_Valuator {
Fl_Font textfont_;
Fl_Fontsize textsize_;
uchar soft_;
- unsigned textcolor_;
+ Fl_Color textcolor_;
protected:
void draw();
@@ -83,13 +83,13 @@ public:
Fl_Fontsize textsize() const {return textsize_;}
void textsize(Fl_Fontsize s) {textsize_ = s;}
/** Sets the color of the text in the value box. */
- Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
+ Fl_Color textcolor() const {return textcolor_;}
/** Gets the color of the text in the value box. */
- void textcolor(unsigned s) {textcolor_ = s;}
+ void textcolor(Fl_Color s) {textcolor_ = s;}
};
#endif
//
-// End of "$Id: Fl_Value_Output.H 6664 2009-02-18 09:27:54Z AlbrechtS $".
+// End of "$Id: Fl_Value_Output.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Value_Slider.H b/plugins/zynaddsubfx/fltk/FL/Fl_Value_Slider.H
index c2b5afe50..ec886428a 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Value_Slider.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Value_Slider.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Value_Slider.H 6664 2009-02-18 09:27:54Z AlbrechtS $"
+// "$Id: Fl_Value_Slider.H 6902 2009-09-27 11:06:56Z matt $"
//
// Value slider header file for the Fast Light Tool Kit (FLTK).
//
@@ -42,7 +42,7 @@
class FL_EXPORT Fl_Value_Slider : public Fl_Slider {
Fl_Font textfont_;
Fl_Fontsize textsize_;
- unsigned textcolor_;
+ Fl_Color textcolor_;
protected:
void draw();
public:
@@ -57,13 +57,13 @@ public:
/** Sets the size of the text in the value box. */
void textsize(Fl_Fontsize s) {textsize_ = s;}
/** Gets the color of the text in the value box. */
- Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
+ Fl_Color textcolor() const {return textcolor_;}
/** Sets the color of the text in the value box. */
- void textcolor(unsigned s) {textcolor_ = s;}
+ void textcolor(Fl_Color s) {textcolor_ = s;}
};
#endif
//
-// End of "$Id: Fl_Value_Slider.H 6664 2009-02-18 09:27:54Z AlbrechtS $".
+// End of "$Id: Fl_Value_Slider.H 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Widget.H b/plugins/zynaddsubfx/fltk/FL/Fl_Widget.H
index 426156137..f36ca38c7 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Widget.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Widget.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Widget.H 6753 2009-04-12 09:40:59Z AlbrechtS $"
+// "$Id: Fl_Widget.H 6912 2009-10-02 19:08:55Z matt $"
//
// Widget header file for the Fast Light Tool Kit (FLTK).
//
@@ -69,7 +69,7 @@ struct FL_EXPORT Fl_Label {
/** size of label font */
Fl_Fontsize size;
/** text color */
- unsigned color;
+ Fl_Color color;
/** Draws the label aligned to the given box */
void draw(int,int,int,int, Fl_Align) const ;
void measure(int &w, int &h) const ;
@@ -96,9 +96,9 @@ class FL_EXPORT Fl_Widget {
void* user_data_;
int x_,y_,w_,h_;
Fl_Label label_;
- int flags_;
- unsigned color_;
- unsigned color2_;
+ unsigned int flags_;
+ Fl_Color color_;
+ Fl_Color color2_;
uchar type_;
uchar damage_;
uchar box_;
@@ -135,23 +135,37 @@ protected:
/** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */
void h(int v) {h_ = v;}
/** Gets the widget flags mask */
- int flags() const {return flags_;}
+ unsigned int flags() const {return flags_;}
/** Sets a flag in the flags mask */
- void set_flag(int c) {flags_ |= c;}
+ void set_flag(unsigned int c) {flags_ |= c;}
/** Clears a flag in the flags mask */
- void clear_flag(int c) {flags_ &= ~c;}
+ void clear_flag(unsigned int c) {flags_ &= ~c;}
/** flags possible values enumeration.
See activate(), output(), visible(), changed(), set_visible_focus()
*/
enum {
- INACTIVE=1, ///< the widget can't receive focus, and is disabled but potentially visible
- INVISIBLE=2, ///< the widget is not drawn but can receive events
- OUTPUT=4, ///< for output only
- SHORTCUT_LABEL=64, ///< the label contains a shortcut we need to draw
- CHANGED=128, ///< the widget value changed
- VISIBLE_FOCUS=512, ///< accepts keyboard focus navigation if the widget can have the focus
- COPIED_LABEL=1024 ///< the widget label is internally copied, its destruction is handled by the widget
- };
+ INACTIVE = 1<<0, ///< the widget can't receive focus, and is disabled but potentially visible
+ INVISIBLE = 1<<1, ///< the widget is not drawn but can receive events
+ OUTPUT = 1<<2, ///< for output only
+ NOBORDER = 1<<3, ///< don't draw a decoration (Fl_Window)
+ FORCE_POSITION = 1<<4, ///< don't let the window manager position the window (Fl_Window)
+ NON_MODAL = 1<<5, ///< thisis a hovering toolbar window (Fl_Window)
+ SHORTCUT_LABEL = 1<<6, ///< the label contains a shortcut we need to draw
+ CHANGED = 1<<7, ///< the widget value changed
+ OVERRIDE = 1<<8, ///< position window on top (Fl_Window)
+ VISIBLE_FOCUS = 1<<9, ///< accepts keyboard focus navigation if the widget can have the focus
+ COPIED_LABEL = 1<<10, ///< the widget label is internally copied, its destruction is handled by the widget
+ CLIP_CHILDREN = 1<<11, ///< all drawing within this widget will be clipped (Fl_Group)
+ MENU_WINDOW = 1<<12, ///< a temporary popup window, dismissed by clicking outside (Fl_Window)
+ TOOLTIP_WINDOW = 1<<13, ///< a temporary popup, transparent to events, and dismissed easily (Fl_Window)
+ MODAL = 1<<14, ///< a window blocking input to all other winows (Fl_Window)
+ NO_OVERLAY = 1<<15, ///< window not using a hardware overlay plane (Fl_Menu_Window)
+ GROUP_RELATIVE = 1<<16, ///< position this idget relative to the parent group, not to the window
+ // (space for more flags)
+ USERFLAG3 = 1<<29, ///< reserved for 3rd party extensions
+ USERFLAG2 = 1<<30, ///< reserved for 3rd party extensions
+ USERFLAG1 = 1<<31 ///< reserved for 3rd party extensions
+ };
void draw_box() const;
void draw_box(Fl_Boxtype t, Fl_Color c) const;
void draw_box(Fl_Boxtype t, int x,int y,int w,int h, Fl_Color c) const;
@@ -343,9 +357,9 @@ public:
/** Gets the background color of the widget.
\return current background color
- \see color(unsigned), color(unsigned, unsigned)
+ \see color(Fl_Color), color(Fl_Color, Fl_Color)
*/
- Fl_Color color() const {return (Fl_Color)color_;}
+ Fl_Color color() const {return color_;}
/** Sets the background color of the widget.
The color is passed to the box routine. The color is either an index into
@@ -355,25 +369,25 @@ public:
The default for most widgets is FL_BACKGROUND_COLOR. Use Fl::set_color()
to redefine colors in the color map.
\param[in] bg background color
- \see color(), color(unsigned, unsigned), selection_color(unsigned)
+ \see color(), color(Fl_Color, Fl_Color), selection_color(Fl_Color)
*/
- void color(unsigned bg) {color_ = bg;}
+ void color(Fl_Color bg) {color_ = bg;}
/** Gets the selection color.
\return the current selection color
- \see selection_color(unsigned), color(unsigned, unsigned)
+ \see selection_color(Fl_Color), color(Fl_Color, Fl_Color)
*/
- Fl_Color selection_color() const {return (Fl_Color)color2_;}
+ Fl_Color selection_color() const {return color2_;}
/** Sets the selection color.
The selection color is defined for Forms compatibility and is usually
used to color the widget when it is selected, although some widgets
use this color for other purposes. You can set both colors at once
- with color(unsigned bg, unsigned sel).
+ with color(Fl_Color bg, Fl_Color sel).
\param[in] a the new selection color
- \see selection_color(), color(unsigned, unsigned)
+ \see selection_color(), color(Fl_Color, Fl_Color)
*/
- void selection_color(unsigned a) {color2_ = a;}
+ void selection_color(Fl_Color a) {color2_ = a;}
/** Sets the background and selection color of the widget.
@@ -382,7 +396,7 @@ public:
\param[in] sel selection color
\see color(unsigned), selection_color(unsigned)
*/
- void color(unsigned bg, unsigned sel) {color_=bg; color2_=sel;}
+ void color(Fl_Color bg, Fl_Color sel) {color_=bg; color2_=sel;}
/** Gets the current label text.
\return a pointer to the current label text
@@ -439,13 +453,13 @@ public:
The default color is FL_FOREGROUND_COLOR.
\return the current label color
*/
- Fl_Color labelcolor() const {return (Fl_Color)label_.color;}
+ Fl_Color labelcolor() const {return label_.color;}
/** Sets the label color.
The default color is FL_FOREGROUND_COLOR.
\param[in] c the new label color
*/
- void labelcolor(unsigned c) {label_.color=c;}
+ void labelcolor(Fl_Color c) {label_.color=c;}
/** Gets the font to use.
Fonts are identified by indexes into a table. The default value
@@ -633,7 +647,7 @@ public:
\retval 0 if the widget is not drawn and hence invisible.
\see show(), hide(), visible_r()
*/
- int visible() const {return !(flags_&INVISIBLE);}
+ unsigned int visible() const {return !(flags_&INVISIBLE);}
/** Returns whether a widget and all its parents are visible.
\retval 0 if the widget or any of its parents are invisible.
@@ -678,7 +692,7 @@ public:
\retval 0 if the widget is inactive
\see active_r(), activate(), deactivate()
*/
- int active() const {return !(flags_&INACTIVE);}
+ unsigned int active() const {return !(flags_&INACTIVE);}
/** Returns whether the widget and all of its parents are active.
\retval 0 if this or any of the parent widgets are inactive
@@ -717,7 +731,7 @@ public:
\retval 0 if the widget is used for input and output
\see set_output(), clear_output()
*/
- int output() const {return (flags_&OUTPUT);}
+ unsigned int output() const {return (flags_&OUTPUT);}
/** Sets a widget to output only.
\see output(), clear_output()
@@ -734,7 +748,7 @@ public:
&& visible()) but is faster.
\retval 0 if the widget takes no events
*/
- int takesevents() const {return !(flags_&(INACTIVE|INVISIBLE|OUTPUT));}
+ unsigned int takesevents() const {return !(flags_&(INACTIVE|INVISIBLE|OUTPUT));}
/**
Checks if the widget value changed since the last callback.
@@ -751,7 +765,7 @@ public:
\retval 0 if the value did not change
\see set_changed(), clear_changed()
*/
- int changed() const {return flags_&CHANGED;}
+ unsigned int changed() const {return flags_&CHANGED;}
/** Marks the value of the widget as changed.
\see changed(), clear_changed()
@@ -796,7 +810,7 @@ public:
\retval 0 if this widget has no visible focus.
\see visible_focus(int), set_visible_focus(), clear_visible_focus()
*/
- int visible_focus() { return flags_ & VISIBLE_FOCUS; }
+ unsigned int visible_focus() { return flags_ & VISIBLE_FOCUS; }
/** Sets the default callback for all widgets.
Sets the default callback, which puts a pointer to the widget on the queue
@@ -828,7 +842,7 @@ public:
/** Internal use only. */
int test_shortcut();
/** Internal use only. */
- static char label_shortcut(const char *t);
+ static Fl_Shortcut label_shortcut(const char *t);
/** Internal use only. */
static int test_shortcut(const char*);
@@ -866,9 +880,16 @@ public:
*/
uchar damage() const {return damage_;}
- /** Clears the damage flags.
+ /** Clears or sets the damage flags.
Damage flags are cleared when parts of the widget drawing is repaired.
- \param[in] c bitmask of flags to clear
+
+ The optional argument \p c specifies the bits that are set
+ after the call (default: 0) and \b not the bits that are cleared!
+
+ \note Therefore it is possible to set damage bits with this method, but
+ this should be avoided. Use damage(uchar) instead.
+
+ \param[in] c new bitmask of damage flags (default: 0)
\see damage(uchar), damage()
*/
void clear_damage(uchar c = 0) {damage_ = c;}
@@ -923,5 +944,5 @@ public:
#endif
//
-// End of "$Id: Fl_Widget.H 6753 2009-04-12 09:40:59Z AlbrechtS $".
+// End of "$Id: Fl_Widget.H 6912 2009-10-02 19:08:55Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Window.H b/plugins/zynaddsubfx/fltk/FL/Fl_Window.H
index a55521db5..952a52793 100644
--- a/plugins/zynaddsubfx/fltk/FL/Fl_Window.H
+++ b/plugins/zynaddsubfx/fltk/FL/Fl_Window.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Window.H 6614 2009-01-01 16:11:32Z matt $"
+// "$Id: Fl_Window.H 6907 2009-09-28 14:34:52Z matt $"
//
// Window header file for the Fast Light Tool Kit (FLTK).
//
@@ -69,16 +69,6 @@ class FL_EXPORT Fl_Window : public Fl_Group {
Fl_Cursor cursor_default;
Fl_Color cursor_fg, cursor_bg;
void size_range_();
- // values for flags():
- enum {
- FL_MODAL = 64,
- FL_NOBORDER = 8,
- FL_FORCE_POSITION = 16,
- FL_NON_MODAL = 32,
- FL_OVERRIDE = 256,
- FL_MENU_WINDOW = 4096,
- FL_TOOLTIP_WINDOW = 8192
- };
void _Fl_Window(); // constructor innards
// unimplemented copy ctor and assignment operator
@@ -167,13 +157,13 @@ public:
Fast inline function to turn the border
off. It only works before show() is called.
*/
- void clear_border() {set_flag(FL_NOBORDER);}
+ void clear_border() {set_flag(NOBORDER);}
/** See int Fl_Window::border(int) */
- int border() const {return !(flags() & FL_NOBORDER);}
- /** Activate the flags FL_NOBORDER|FL_OVERRIDE */
- void set_override() {set_flag(FL_NOBORDER|FL_OVERRIDE);}
+ unsigned int border() const {return !(flags() & NOBORDER);}
+ /** Activate the flags NOBORDER|FL_OVERRIDE */
+ void set_override() {set_flag(NOBORDER|OVERRIDE);}
/** Returns non zero if FL_OVERRIDE flag is set, 0 otherwise. */
- int override() const { return flags()&FL_OVERRIDE; }
+ unsigned int override() const { return flags()&OVERRIDE; }
/**
A "modal" window, when shown(), will prevent any events from
being delivered to other windows in the same program, and will also
@@ -183,18 +173,18 @@ public:
which window (if any) is modal by calling
Fl::modal().
*/
- void set_modal() {set_flag(FL_MODAL);}
+ void set_modal() {set_flag(MODAL);}
/** Returns true if this window is modal. */
- int modal() const {return flags() & FL_MODAL;}
+ unsigned int modal() const {return flags() & MODAL;}
/**
A "non-modal" window (terminology borrowed from Microsoft Windows)
acts like a modal() one in that it remains on top, but it has
no effect on event delivery. There are three states for a
window: modal, non-modal, and normal.
*/
- void set_non_modal() {set_flag(FL_NON_MODAL);}
+ void set_non_modal() {set_flag(NON_MODAL);}
/** Returns true if this window is modal or non-modal. */
- int non_modal() const {return flags() & (FL_NON_MODAL|FL_MODAL);}
+ unsigned int non_modal() const {return flags() & (NON_MODAL|MODAL);}
/**
Marks the window as a menu window.
@@ -209,10 +199,10 @@ public:
This must be called before the window is shown and cannot be changed
later.
*/
- void set_menu_window() {set_flag(FL_MENU_WINDOW);}
+ void set_menu_window() {set_flag(MENU_WINDOW);}
/** Returns true if this window is a menu window. */
- int menu_window() const {return flags() & FL_MENU_WINDOW;}
+ unsigned int menu_window() const {return flags() & MENU_WINDOW;}
/**
Marks the window as a tooltip window.
@@ -230,10 +220,10 @@ public:
\note Since Fl_Tooltip_Window is derived from Fl_Menu_Window, this
also \b clears the menu_window() state.
*/
- void set_tooltip_window() { set_flag(FL_TOOLTIP_WINDOW);
- clear_flag(FL_MENU_WINDOW); }
+ void set_tooltip_window() { set_flag(TOOLTIP_WINDOW);
+ clear_flag(MENU_WINDOW); }
/** Returns true if this window is a tooltip window. */
- int tooltip_window() const {return flags() & FL_TOOLTIP_WINDOW;}
+ unsigned int tooltip_window() const {return flags() & TOOLTIP_WINDOW;}
/**
Position the window so that the mouse is pointing at the
@@ -252,7 +242,7 @@ public:
so that the next time show() is called the window manager is
free to position the window.
*/
- void free_position() {clear_flag(FL_FORCE_POSITION);}
+ void free_position() {clear_flag(FORCE_POSITION);}
/**
Set the allowable range the user can resize this window to. This only
works for top-level windows.
@@ -410,5 +400,5 @@ public:
#endif
//
-// End of "$Id: Fl_Window.H 6614 2009-01-01 16:11:32Z matt $".
+// End of "$Id: Fl_Window.H 6907 2009-09-28 14:34:52Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/fl_draw.H b/plugins/zynaddsubfx/fltk/FL/fl_draw.H
index fab90b477..69ecaf49c 100644
--- a/plugins/zynaddsubfx/fltk/FL/fl_draw.H
+++ b/plugins/zynaddsubfx/fltk/FL/fl_draw.H
@@ -1,5 +1,5 @@
//
-// "$Id: fl_draw.H 6779 2009-04-24 09:28:30Z yuri $"
+// "$Id: fl_draw.H 6878 2009-09-17 22:12:24Z matt $"
//
// Portable drawing function header file for the Fast Light Tool Kit (FLTK).
//
@@ -203,14 +203,7 @@ inline Fl_Fontsize fl_size() {return fl_size_;}
You can also use the value of \p size passed to fl_font()
*/
FL_EXPORT int fl_height(); // using "size" should work ok
-/**
- Dummy passthru function called only in Fl_Text_Display that simply returns
- the font height as given by the \p size parameter in the same call!
-
- \todo Is fl_height(int, int size) required for Fl_Text_Dispay?
- Why not use \p size parameter directly?
-*/
-inline int fl_height(int, int size) {return size;}
+FL_EXPORT int fl_height(int font, int size);
/**
Returns the recommended distance above the bottom of a fl_height() tall box to
draw the text at so it looks centered vertically in that box.
@@ -448,8 +441,8 @@ FL_EXPORT int fl_measure_pixmap(const char* const* cdata, int &w, int &h);
// other:
FL_EXPORT void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
void (*draw_area)(void*, int,int,int,int), void* data);
-FL_EXPORT const char* fl_shortcut_label(int shortcut);
-FL_EXPORT const char* fl_shortcut_label(int shortcuti, const char **eom);
+FL_EXPORT const char* fl_shortcut_label(Fl_Shortcut shortcut);
+FL_EXPORT const char* fl_shortcut_label(Fl_Shortcut shortcut, const char **eom);
FL_EXPORT void fl_overlay_rect(int x,int y,int w,int h);
FL_EXPORT void fl_overlay_clear();
FL_EXPORT void fl_cursor(Fl_Cursor, Fl_Color fg=FL_BLACK, Fl_Color bg=FL_WHITE);
@@ -475,5 +468,5 @@ FL_EXPORT int fl_add_symbol(const char* name, void (*drawit)(Fl_Color), int scal
#endif
//
-// End of "$Id: fl_draw.H 6779 2009-04-24 09:28:30Z yuri $".
+// End of "$Id: fl_draw.H 6878 2009-09-17 22:12:24Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/FL/fl_types.h b/plugins/zynaddsubfx/fltk/FL/fl_types.h
index e676a621e..d87cd7387 100644
--- a/plugins/zynaddsubfx/fltk/FL/fl_types.h
+++ b/plugins/zynaddsubfx/fltk/FL/fl_types.h
@@ -52,6 +52,9 @@ typedef char *Fl_String;
typedef const char *Fl_CString;
/** 24-bit Unicode character + 8-bit indicator for keyboard flags */
+typedef unsigned int Fl_Shortcut;
+
+/** 24-bit Unicode character - upper 8-bits are unused */
typedef unsigned int Fl_Char;
/*@}*/ /* group: Miscellaneous */
diff --git a/plugins/zynaddsubfx/fltk/README.123 b/plugins/zynaddsubfx/fltk/README.123
new file mode 100644
index 000000000..1ab0c4f47
--- /dev/null
+++ b/plugins/zynaddsubfx/fltk/README.123
@@ -0,0 +1,686 @@
+
+ R E A D M E . 1 2 3
+ =====================
+
+This file listst the differences between FLTK 1 and FLTK 2 with annotations
+for a possible implementation of FLTK 3. The all new and improved FLTK 3
+needs to be compatible with 1 and 2. It must have a moder API, plenty of
+widgets, lots of options, customization at run-time, but still be easily
+portable, fast, and of course light.
+
+FLTK 1 has become a nice starting point for the first steps in GUI
+programming. It runs on al major platform (and on many minor ones
+as well), is small, compact, and easy to use. FLTK 2 was the
+attempt to continue the success of FLTK 1 with a much cleaber API
+and many important details improved. Unfortunately many users never
+made the jump to FLTK 2 and so it not only ended in a crawling slow
+branch, it also became instable and at last unmaintainable.
+
+FLTK 3 sets out to surprise FLTK 1 users and satisfy FLTK 2 junkies.
+It will basically be the improved FLTK 2 API combined with the quite
+stable innards of FLTK 1. As an extra bonus, FLTK 3 will be compatible
+to 1 and 2. Just prepend your code with the "coding_style" instruction
+and FLTK 3 will do the rest. It is even possible to intermix F1 and
+F2 coding styles at any place.
+
+Nice challange, eh? So let's get going:
+
+
+ The Big Differences
+---------------------
+
+FLTK 2 is based on FLTK 1 in many ways, and while the FLTK 1 API was based
+on the Forms Library, FLTK 2 is Bill's take on how FLTK 1 should have been.
+This chapter outlines the biggest differences between version.
+
+(1) Coordinate System: FLTK 1 child coordinates are always relative to the
+window, not as most would expect to the parent. FLTK 2 does the logical
+thing and uses group-relative origins. This is somewhat difficult to port
+if we want to stay downward compatible. Fl_Widget will need an additional
+flag indicating absolute or relative coordinates.
+
+(2) Pulldown Menus: The developers of the Forms Library did not implement
+the idea of hierarchies all the way through. Pulldown menus, which are
+hierarchical by nature, were instead implemented as a list with lots of
+tricks and cludges to make them usable. FLTK 2 went half way by using the
+existing Windget/Group relation to create menus, however, menu items are
+still specialized widgets. For FLTK 3, I would like to allow any widget
+inside a pulldown menu.
+
+(3) Browsers and Tree Views: Browsers in FLTK1 are implemented even worse
+than Pulldown Menus. FLTK 2 solved the issues in a similar way, and here
+again, I prefer the FLTK 2 way very mch, but also would like to extend
+functionality to allow arbitrary widgets as list items. A Tree-like
+widget comes free with the FLTK 2 concept. FLTK 1 has no such thing and
+even Fluid had to hack the library badly to generate a tree view.
+
+(4) Namespaces: this is a minr issue that I include for completeness. FLTK 2
+introduces the ftk namespace, renaming all widgets. FLTK 3 will use the
+FLTK 2 naming scheme and map FLTK 1 class names using typedefs. This is, as
+most things in programming are, a compromise. The "coding_style" function
+must be used to switch between FLTK 1 and FLTK 2 code. No worries though,
+it's easy and straight forward.
+
+(5) Layout: FLTK 1 uses a top-down approach for widget layout in which the
+parent widget decides about the childs size "resize(x, y, w, h)". In FLTK 2
+any widget can call "layout()" which will query children for their preffered
+size and propagate the information up. This is a great concept that FLTK 3
+should adapt, plus it is compatible.
+
+(6) Ractangle: FLTK 2's base class is fltk::Rectangle. This is nice and
+easy to implement. The API is pretty much the same in both versions.
+
+(7) Styles: FLTK 2 uses a minimal number of styles to define the basic
+(and often repeated) parameters of every widget. API's are similar though,
+so this is luckily another pretty straight-forward upgrade.
+
+
+ Comparison Chart by Class
+---------------------------
+
+This chart contains a list of all classes in FLTK 1 and 2, how they
+correspond, and how they could be implemented in FLTK 3.
+
+1: class Fl
+2: namespace fltk
+*: this is a pretty straight-forward mapping of functions. The actual work
+ lies in finding and listing all global functions and adapting those.
+
+1: class Fl_Adjuster
+2: class Adjuster
+*: should map easily
+
+1:
+2: class AlignGroup
+*: undocumented in FLTK 2. Minimal code. Can be transfered easily.
+
+1:
+2: class AnsiWidget
+*: There is no equvalet in FLTK 1, but the widget may be easily ported.
+
+1:
+2: class AssociationFunctor
+*: Associations are a new and rarly used concept in FLTK 2. We need to
+ decide if these should be moved into FLTK 3
+
+1:
+2: class AssociationType
+*: Associations are a new and rarly used concept in FLTK 2. We need to
+ decide if these should be moved into FLTK 3
+
+1:
+2: class BarGroup
+*: undocumented in FLTK 2. Minimal code. Can be transfered easily.
+
+1: class Fl_BMP_Image
+2: class bmpImage
+*: should map easily
+
+1: class Fl_Bitmap
+2:
+
+1: class Fl_Box
+2: class Widget
+*: This actually maps pretty much exactly to fltk::Widget. FLTK 2 provides
+ a bunch of other box-like classes which have some predefined properties,
+ however this is the best match for FLTK 1. fltk::InvisibleBox can be used
+ as well.
+
+1: class Fl_Browser
+2: class Browser
+
+1: class Fl_Browser_
+2:
+
+1: class Fl_Button
+2: class Button
+*: should map easily
+
+1: class Fl_Cairo_State
+2:
+
+1: class Fl_Cairo_Window
+2:
+
+1: class Fl_Chart
+2:
+
+1: class Fl_Check_Browser
+2:
+
+1: class Fl_Check_Button
+2: class CheckButton
+*: should map easily
+
+1: class Fl_Choice
+2: class Choice
+*: should map easily
+
+1: class Fl_Clock
+2: class Clock
+*: should map easily
+
+1: class Fl_Clock_Output
+2: class ClockOutput
+*: should map easily
+
+1: class Fl_Color_Chooser
+2: class ColorChooser
+*: should map easily
+
+1:
+2: class ComboBrowser
+
+1:
+2: class ComboWindow
+
+1:
+2: class CycleButton
+
+1: class Fl_Counter
+2:
+
+1: class Fl_Dial
+2: class Dial
+*: should map easily
+
+1:
+2: class Divider
+
+1: class Fl_Double_Window
+2: class DoubleBufferWindow
+*: should map easily
+
+1: class Fl_End
+2:
+
+1:
+2: class EngravedLabel
+
+1: class Fl_File_Browser
+2: class FileBrowser
+*: should map easily
+
+1: class Fl_File_Chooser
+2: class FileChooser
+*: should map easily
+
+1: class Fl_File_Icon
+2: class FileIcon
+*: should map easily
+
+1: class Fl_File_Input
+2: class FileInput
+*: should map easily
+
+1: class Fl_Fill_Dial
+2: class FillDial
+*: should map easily
+
+1: class Fl_Fill_Slider
+2: class FillSlider
+*: should map easily
+
+1:
+2: class FlatBox
+
+1: class Fl_Float_Input
+2: class FloatInput
+*: should map easily
+
+1: class Fl_FormsBitmap
+2:
+
+1: class Fl_FormsPixmap
+2:
+
+1: class Fl_FormsText
+2: class Fl_FormsText
+*: should map easily
+
+1:
+2: class FrameBox
+
+1: class Fl_Free
+2:
+
+1: class Fl_GIF_Image
+2: class gifImage
+*: should map easily
+
+1: class Fl_Gl_Choice
+2: class GlChoice
+*: should map easily
+
+1: class Fl_Gl_Window
+2: class GlWindow
+*: should map easily
+
+1:
+2: class GlOverlay
+
+1: class Fl_Glut_Window
+2: class GlutWindow
+
+1: class Fl_Group
+2: class Group
+*: should map easily, must manage coordinate systems
+
+1:
+2: class GSave
+
+1:
+2: class Guard
+
+1: class Fl_Help_Dialog
+2: class HelpDialog
+*: should map easily
+
+1: class Fl_Help_View
+2: class HelpView
+*: should map easily
+
+1:
+2: class HighlightBox
+
+1:
+2: class HighlightButton
+
+1: class Fl_Hold_Browser
+2:
+
+1: class Fl_Hor_Fill_Slider
+2:
+
+1: class Fl_Hor_Nice_Slider
+2:
+
+1: class Fl_Hor_Slider
+2:
+
+1: class Fl_Hor_Value_Slider
+2:
+
+1: class Fl_Image
+2: class Image
+*: should map easily
+
+1: class Fl_Input
+2: class Input
+*: should map easily
+
+1: class Fl_Input_
+2:
+
+1:
+2: class InputBrowser
+
+1: class Fl_Input_Choice
+2: class ComboBox
+*: should map easily
+
+1: class Fl_Int_Input
+2: class IntInput
+*: should map easily
+
+1:
+2: class InvisibleBox
+
+1:
+2: class Item
+
+1:
+2: class ItemGroup
+
+1: class Fl_JPEG_Image
+2: class jpegImage
+*: should map easily
+
+1:
+2: class LabelType
+
+1: class Fl_Light_Button
+2: class LightButton
+*: should map easily
+
+1: class Fl_Line_Dial
+2: class LineDial
+*: should map easily
+
+1:
+2: class List
+
+1: class Fl_Menu_
+2: class Menu
+
+1: class Fl_Menu_Bar
+2: class MenuBar
+
+1: class Fl_Menu_Button
+2: class PopupMenu
+
+1:
+2: class MenuSection
+
+1: class Fl_Menu_Window
+2: class MenuWindow
+
+1:
+2: class Monitor
+
+1: class Fl_Multi_Browser
+2: class MultiBrowser
+
+1:
+2: class MultiImage
+
+1: class Fl_Multiline_Input
+2: class MultiLineInput
+*: should map easily
+
+1: class Fl_Multiline_Output
+2: class MultiLineOutput
+*: should map easily
+
+1:
+2: class Mutex
+
+1: class Fl_Nice_Slider
+2:
+
+1:
+2: class NumericInput
+
+1: class Fl_Output
+2: class Output
+*: should map easily
+
+1: class Fl_Overlay_Window
+2:
+
+1: class Fl_PNG_Image
+2: class pngImage
+*: should map easily
+
+1: class Fl_PNM_Image
+2: class pnmImage
+*: should map easily
+
+1: class Fl_Pack
+2: class PackedGroup
+*: should map easily, FLTK 2 has soem additional functionaity
+
+1: class Fl_Pixmap
+2:
+
+1: class Fl_Positioner
+2:
+
+1: class Fl_Preferences
+2: class Preferences
+*: should map easily
+
+1: class Fl_Progress
+2: class ProgressBar
+*: should map easily
+
+1: class Fl_RGB_Image
+2: class rgbImage
+*: should map easily
+
+1: class Fl_Radio_Button
+2: class RadioButton
+*: should map easily
+
+1:
+2: class RadioItem
+
+1: class Fl_Radio_Light_Button
+2: class RadioLightButton
+*: should map easily
+
+1: class Fl_Radio_Round_Button
+2:
+
+1:
+2: class Rectangle
+
+1:
+2: class RecursiveMutex
+
+1: class Fl_Repeat_Button
+2: class RepeatButton
+*: should map easily
+
+1: class Fl_Return_Button
+2: class ReturnButton
+*: should map easily
+
+1: class Fl_Roller
+2: class ThumbWheel
+*: should map easily
+
+1: class Fl_Round_Button
+2:
+
+1: class Fl_Round_Clock
+2:
+
+1: class Fl_Scroll
+2: class ScrollGroup
+*: should map easily
+
+1: class Fl_Scrollbar
+2: class Scrollbar
+*: should map easily
+
+1: class Fl_Secret_Input
+2: class SecretInput
+*: should map easily
+
+1: class Fl_Select_Browser
+2:
+
+1:
+2: class ShapedWindow
+
+1: class Fl_Shared_Image
+2: class SharedImage
+*: should map easily
+
+1:
+2: class ShortcutFunctor
+
+1: class Fl_Simple_Counter
+2:
+
+1: class Fl_Single_Window
+2:
+
+1:
+2: class SignalMutex
+
+1: class Fl_Slider
+2: class Slider
+*: should map easily
+
+1: class Fl_Spinner
+2:
+
+1:
+2: class StatusBarGroup
+
+1:
+2: class StringArray
+
+1:
+2: class StringHierarchy
+
+1:
+2: class StringList
+
+1:
+2: class Style
+
+1:
+2: class StyleSet
+
+1:
+2: class Symbol
+
+1: class Fl_Sys_Menu_Bar
+2: class SystemMenuBar
+*: should map easily
+
+1: class Fl_Tabs
+2: class TabGroup
+*: should map easily
+
+1:
+2: class TabGroupPager
+
+1: class Fl_Text_Buffer
+2: class TextBuffer
+*: should map easily
+
+1: class Fl_Text_Display
+2: class TextDisplay
+*: should map easily
+
+1: class Fl_Text_Editor
+2: class TextEditor
+*: should map easily
+
+1: class Fl_Text_Selection
+2: class TextSelection
+*: should map easily
+
+1: class Fl_Tile
+2: class TiledGroup
+*: should map easily
+
+1: class Fl_Tiled_Image
+2: class TiledImage
+*: should map easily
+
+1: class Fl_Timer
+2:
+
+1: class Fl_Toggle_Button
+2: class ToggleButton
+*: should map easily
+
+1:
+2: class ToggleItem
+
+1: class Fl_Tooltip
+2: class Tooltip
+*: should map easily
+
+1:
+2: class WordwrapInput
+
+1:
+2: class WordwrapOutput
+
+1: class Fl_Valuator
+2: class Valuator
+*: should map easily
+
+1: class Fl_Value_Input
+2: class ValueInput
+*: should map easily
+
+1: class Fl_Value_Output
+2: class ValueOutput
+*: should map easily
+
+1: class Fl_Value_Slider
+2: class ValueSlider
+*: should map easily
+
+1: class Fl_Widget
+2: class Widget
+*: should map easily for the most part
+
+1: class Fl_Widget_Tracker
+2:
+
+1: class Fl_Window
+2: class Window
+*: should map easily
+
+1: class Fl_Wizard
+2: class WizardGroup
+*: should map easily
+
+1: class Fl_X
+2: class CreatedWindow
+*: should map easily
+
+1: class Fl_XBM_Image
+2: class xbmImage
+*: should map easily
+
+1: class Fl_XPM_Image
+2: class xpmImage
+*: should map easily
+
+1:
+2: class xpmFileImage
+
+1:
+2: struct Cursor
+
+1:
+2: struct Font
+
+1: struct Fl_Glut_Bitmap_Font
+2:
+
+1: struct Fl_Glut_StrokeChar
+2:
+
+1: struct Fl_Glut_StrokeFont
+2:
+
+1: struct Fl_Glut_StrokeStrip
+2:
+
+1: struct Fl_Glut_StrokeVertex
+2:
+
+1: struct Fl_Help_Block
+2: struct HelpBlock
+*: should map easily
+
+1: struct Fl_Help_Font_Stack
+2:
+
+1: struct Fl_Help_Font_Style
+2:
+
+1: struct Fl_Help_Link
+2: struct HelpLink
+*: should map easily
+
+1: struct Fl_Help_Target
+2: struct HelpTarget
+*: should map easily
+
+1:
+2: struct ImageType
+
+1: struct Fl_Label
+2:
+
+1: struct Fl_Menu_Item
+2:
+
+1: struct Fl_Multi_Label
+2:
+
+1:
+2: struct NamedStyle
+
+
diff --git a/plugins/zynaddsubfx/fltk/src/CMakeLists.txt b/plugins/zynaddsubfx/fltk/src/CMakeLists.txt
index 7b628bd01..d12f04db2 100644
--- a/plugins/zynaddsubfx/fltk/src/CMakeLists.txt
+++ b/plugins/zynaddsubfx/fltk/src/CMakeLists.txt
@@ -34,7 +34,7 @@ SET(CPPFILES
Fl_Menu.cxx
Fl_Menu_.cxx
Fl_Menu_Bar.cxx
- Fl_Sys_Menu_Bar.cxx
+ Fl_Sys_Menu_Bar.cxx
Fl_Menu_Button.cxx
Fl_Menu_Window.cxx
Fl_Menu_add.cxx
@@ -130,6 +130,8 @@ SET(CPPFILES
fl_vertex.cxx
screen_xywh.cxx
fl_utf8.cxx
+ fl_encoding_latin1.cxx
+ fl_encoding_mac_roman.cxx
)
SET(FLCPPFILES
forms_compatability.cxx
@@ -165,18 +167,18 @@ SET(IMGCPPFILES
SET(CFILES
fl_call_main.c
- fl_utf.c
flstring.c
scandir.c
numericsort.c
vsnprintf.c
- xutf8/case.c
xutf8/is_right2left.c
xutf8/is_spacing.c
- xutf8/keysym2Ucs.c
+ xutf8/case.c
xutf8/utf8Input.c
xutf8/utf8Utils.c
xutf8/utf8Wrap.c
+ xutf8/keysym2Ucs.c
+ fl_utf.c
)
ADD_LIBRARY(fltk ${CPPFILES} ${CFILES})
diff --git a/plugins/zynaddsubfx/fltk/src/Fl.cxx b/plugins/zynaddsubfx/fltk/src/Fl.cxx
index d621d2318..2d6e03fe3 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl.cxx 6787 2009-05-14 20:16:09Z engelsman $"
+// "$Id: Fl.cxx 6836 2009-07-25 12:56:16Z AlbrechtS $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
@@ -1699,5 +1699,5 @@ Fl_Widget_Tracker::~Fl_Widget_Tracker() {
}
//
-// End of "$Id: Fl.cxx 6787 2009-05-14 20:16:09Z engelsman $".
+// End of "$Id: Fl.cxx 6836 2009-07-25 12:56:16Z AlbrechtS $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Browser.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Browser.cxx
index 14a2db47c..0db009245 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Browser.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Browser.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Browser.cxx 6726 2009-03-27 16:52:31Z greg.ercolano $"
+// "$Id: Fl_Browser.cxx 6895 2009-09-21 06:35:08Z greg.ercolano $"
//
// Browser widget for the Fast Light Tool Kit (FLTK).
//
@@ -44,10 +44,16 @@
#define SELECTED 1
#define NOTDISPLAYED 2
+// WARNING:
+// Fl_File_Chooser.cxx also has a definition of this structure (FL_BLINE).
+// Changes to FL_BLINE *must* be reflected in Fl_File_Chooser.cxx as well.
+// This hack in Fl_File_Chooser should be solved.
+//
struct FL_BLINE { // data is in a linked list of these
FL_BLINE* prev;
FL_BLINE* next;
void* data;
+ Fl_Image* icon;
short length; // sizeof(txt)-1, may be longer than string
char flags; // selected, displayed
char txt[1]; // start of allocated array
@@ -138,7 +144,8 @@ const char *Fl_Browser::item_text(void *item) const {
item_next(), etc. to access the internal linked list more efficiently.
\param[in] line The line number of the item to return. (1 based)
- \returns The returned item.
+ \retval item that was found.
+ \retval NULL if line is out of range.
\see item_at(), find_line(), lineno()
*/
FL_BLINE* Fl_Browser::find_line(int line) const {
@@ -287,6 +294,7 @@ void Fl_Browser::insert(int line, const char* newtext, void* d) {
t->flags = 0;
strcpy(t->txt, newtext);
t->data = d;
+ t->icon = 0;
insert(line, t);
}
@@ -321,6 +329,7 @@ void Fl_Browser::text(int line, const char* newtext) {
replacing(t, n);
cache = n;
n->data = t->data;
+ n->icon = t->icon;
n->length = (short)l;
n->flags = t->flags;
n->prev = t->prev;
@@ -364,8 +373,7 @@ int Fl_Browser::item_height(void *item) const {
fl_font(textfont(), textsize());
int hh = fl_height();
if (hh > hmax) hmax = hh;
- }
- else {
+ } else {
const int* i = column_widths();
// do each column separately as they may all set different fonts:
for (char* str = l->txt; str && *str; str++) {
@@ -400,6 +408,9 @@ int Fl_Browser::item_height(void *item) const {
}
}
+ if (l->icon && (l->icon->h()+2)>hmax) {
+ hmax = l->icon->h() + 2; // leave 2px above/below
+ }
return hmax; // previous version returned hmax+2!
}
@@ -412,7 +423,8 @@ int Fl_Browser::item_height(void *item) const {
incr_height(), full_height()
*/
int Fl_Browser::item_width(void *item) const {
- char* str = ((FL_BLINE*)item)->txt;
+ FL_BLINE* l=(FL_BLINE*)item;
+ char* str = l->txt;
const int* i = column_widths();
int ww = 0;
@@ -457,6 +469,8 @@ int Fl_Browser::item_width(void *item) const {
if (*str == format_char_ && str[1])
str ++;
+ if (ww==0 && l->icon) ww = l->icon->w();
+
fl_font(font, tsize);
return ww + int(fl_width(str)) + 6;
}
@@ -492,9 +506,11 @@ int Fl_Browser::incr_height() const {
\param[in] X,Y,W,H position and size.
*/
void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const {
- char* str = ((FL_BLINE*)item)->txt;
+ FL_BLINE* l = (FL_BLINE*)item;
+ char* str = l->txt;
const int* i = column_widths();
+ bool first = true; // for icon
while (W > 6) { // do each tab-separated field
int w1 = W; // width for this field
char* e = 0; // pointer to end of field or null if none
@@ -502,6 +518,15 @@ void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const {
e = strchr(str, column_char());
if (e) {*e = 0; w1 = *i++;}
}
+ // Icon drawing code
+ if (first) {
+ first = false;
+ if (l->icon) {
+ l->icon->draw(X+2,Y+1); // leave 2px left, 1px above
+ int iconw = l->icon->w()+2;
+ X += iconw; W -= iconw; w1 -= iconw;
+ }
+ }
int tsize = textsize();
Fl_Font font = textfont();
Fl_Color lcol = textcolor();
@@ -521,7 +546,7 @@ void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const {
case 'c': talign = FL_ALIGN_CENTER; break;
case 'r': talign = FL_ALIGN_RIGHT; break;
case 'B':
- if (!(((FL_BLINE*)item)->flags & SELECTED)) {
+ if (!(l->flags & SELECTED)) {
fl_color((Fl_Color)strtol(str, &str, 10));
fl_rectf(X, Y, w1, H);
} else strtol(str, &str, 10);
@@ -557,7 +582,7 @@ void Fl_Browser::item_draw(void* item, int X, int Y, int W, int H) const {
}
BREAK:
fl_font(font, tsize);
- if (((FL_BLINE*)item)->flags & SELECTED)
+ if (l->flags & SELECTED)
lcol = fl_contrast(lcol, selection_color());
if (!active_r()) lcol = fl_inactive(lcol);
fl_color(lcol);
@@ -592,8 +617,7 @@ Fl_Browser::Fl_Browser(int X, int Y, int W, int H, const char *L)
Updates the browser so that \p line is shown at position \p pos.
\param[in] line line number. (1 based)
\param[in] pos position.
- \see topline(), middleline(), bottomline(), \n
-+: Command not found.
+ \see topline(), middleline(), bottomline()
*/
void Fl_Browser::lineposition(int line, Fl_Line_Position pos) {
if (line<1) line = 1;
@@ -835,6 +859,58 @@ void Fl_Browser::swap(int a, int b) {
swap(ai,bi);
}
+/**
+ Set the image icon for \p line to the value \p icon.
+ Caller is responsible for keeping the icon allocated.
+ The \p line is automatically redrawn.
+ \param[in] line The line to be modified. If out of range, nothing is done.
+ \param[in] icon The image icon to be assigned to the \p line.
+ If NULL, any previous icon is removed.
+*/
+void Fl_Browser::icon(int line, Fl_Image* icon) {
+
+ if (line<1 || line > lines) return;
+
+ FL_BLINE* bl = find_line(line);
+
+ int old_h = bl->icon ? bl->icon->h()+2 : 0; // init with *old* icon height
+ bl->icon = 0; // remove icon, if any
+ int th = item_height(bl); // height of text only
+ int new_h = icon ? icon->h()+2 : 0; // init with *new* icon height
+ if (th > old_h) old_h = th;
+ if (th > new_h) new_h = th;
+ int dh = new_h - old_h;
+ full_height_ += dh; // do this *always*
+
+ bl->icon = icon; // set new icon
+ if (dh>0) {
+ redraw(); // icon larger than item? must redraw widget
+ } else {
+ redraw_line(bl); // icon same or smaller? can redraw just this line
+ }
+ replacing(bl,bl); // recalc Fl_Browser_::max_width et al
+}
+
+/**
+ Returns the icon currently defined for \p line.
+ If no icon is defined, NULL is returned.
+ \param[in] line The line whose icon is returned.
+ \returns The icon defined, or NULL if none.
+*/
+Fl_Image* Fl_Browser::icon(int line) const {
+ FL_BLINE* l = find_line(line);
+ return(l ? l->icon : NULL);
+}
+
+/**
+ Removes the icon for \p line.
+ It's ok to remove an icon if none has been defined.
+ \param[in] line The line whose icon is to be removed.
+*/
+void Fl_Browser::remove_icon(int line) {
+ icon(line,0);
+}
+
//
-// End of "$Id: Fl_Browser.cxx 6726 2009-03-27 16:52:31Z greg.ercolano $".
+// End of "$Id: Fl_Browser.cxx 6895 2009-09-21 06:35:08Z greg.ercolano $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Choice.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Choice.cxx
index 22054e821..a31bdc873 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Choice.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Choice.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Choice.cxx 6616 2009-01-01 21:28:26Z matt $"
+// "$Id: Fl_Choice.cxx 6873 2009-09-16 07:06:41Z AlbrechtS $"
//
// Choice widget for the Fast Light Tool Kit (FLTK).
//
@@ -209,5 +209,5 @@ int Fl_Choice::handle(int e) {
}
//
-// End of "$Id: Fl_Choice.cxx 6616 2009-01-01 21:28:26Z matt $".
+// End of "$Id: Fl_Choice.cxx 6873 2009-09-16 07:06:41Z AlbrechtS $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Double_Window.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Double_Window.cxx
index 8e31149c3..f26951e4d 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Double_Window.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Double_Window.cxx
@@ -128,7 +128,7 @@ HDC fl_makeDC(HBITMAP bitmap) {
SetTextAlign(new_gc, TA_BASELINE|TA_LEFT);
SetBkMode(new_gc, TRANSPARENT);
#if USE_COLORMAP
- if (fl_palette) SelectPalette(new_gc, fl_palette, false);
+ if (fl_palette) SelectPalette(new_gc, fl_palette, FALSE);
#endif
SelectObject(new_gc, bitmap);
return new_gc;
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_File_Browser.cxx b/plugins/zynaddsubfx/fltk/src/Fl_File_Browser.cxx
index 1834185a4..00b182ccf 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_File_Browser.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_File_Browser.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Browser.cxx 6616 2009-01-01 21:28:26Z matt $"
+// "$Id: Fl_File_Browser.cxx 6853 2009-09-09 05:16:41Z greg.ercolano $"
//
// Fl_File_Browser routines.
//
@@ -42,6 +42,7 @@
#include
#include
#include
+#include // icon
#include
#include
#include "flstring.h"
@@ -80,11 +81,17 @@
#define SELECTED 1
#define NOTDISPLAYED 2
+// TODO -- Warning: The definition of FL_BLINE here is a hack.
+// Fl_File_Browser should not do this. PLEASE FIX.
+// FL_BLINE should be private to Fl_Browser, and not re-defined here.
+// For now, make sure this struct is precisely consistent with Fl_Browser.cxx.
+//
struct FL_BLINE // data is in a linked list of these
{
FL_BLINE *prev; // Previous item in list
FL_BLINE *next; // Next item in list
void *data; // Pointer to data (function)
+ Fl_Image *icon; // Pointer to optional icon
short length; // sizeof(txt)-1, may be longer than string
char flags; // selected, displayed
char txt[1]; // start of allocated array
@@ -635,5 +642,5 @@ Fl_File_Browser::filter(const char *pattern) // I - Pattern string
//
-// End of "$Id: Fl_File_Browser.cxx 6616 2009-01-01 21:28:26Z matt $".
+// End of "$Id: Fl_File_Browser.cxx 6853 2009-09-09 05:16:41Z greg.ercolano $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_File_Chooser2.cxx b/plugins/zynaddsubfx/fltk/src/Fl_File_Chooser2.cxx
index 03e070e16..58df478be 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_File_Chooser2.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_File_Chooser2.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Chooser2.cxx 6678 2009-03-13 23:36:09Z AlbrechtS $"
+// "$Id: Fl_File_Chooser2.cxx 6899 2009-09-23 21:32:23Z matt $"
//
// More Fl_File_Chooser routines.
//
@@ -858,7 +858,7 @@ Fl_File_Chooser::fileNameCB()
}
} else {
// File doesn't exist, so beep at and alert the user...
- fl_alert("%s", existing_file_label);
+ fl_alert(existing_file_label);
}
}
else if (Fl::event_key() != FL_Delete &&
@@ -1046,7 +1046,7 @@ Fl_File_Chooser::newdir()
// Get a directory name from the user
- if ((dir = fl_input("%s", new_directory_label, (char *)NULL)) == NULL)
+ if ((dir = fl_input(new_directory_label, NULL)) == NULL)
return;
// Make it relative to the current directory as needed...
@@ -1213,7 +1213,7 @@ Fl_File_Chooser::showChoiceCB()
item = showChoice->text(showChoice->value());
if (strcmp(item, custom_filter_label) == 0) {
- if ((item = fl_input("%s",custom_filter_label, pattern_)) != NULL) {
+ if ((item = fl_input(custom_filter_label, pattern_)) != NULL) {
strlcpy(pattern_, item, sizeof(pattern_));
quote_pathname(temp, item, sizeof(temp));
@@ -1332,10 +1332,37 @@ Fl_File_Chooser::update_preview()
window->cursor(FL_CURSOR_DEFAULT);
Fl::check();
- // Scan the buffer for printable chars...
- for (ptr = preview_text_;
+ // Scan the buffer for printable UTF8 chars...
+ for (ptr = preview_text_; *ptr; ptr++) {
+ uchar c = uchar(*ptr);
+ if ( (c&0x80)==0 ) {
+ if (!isprint(c&255) && !isspace(c&255)) break;
+ } else if ( (c&0xe0)==0xc0 ) {
+ if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
+ ptr++;
+ } else if ( (c&0xf0)==0xe0 ) {
+ if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
+ ptr++;
+ if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
+ ptr++;
+ } else if ( (c&0xf8)==0xf0 ) {
+ if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
+ ptr++;
+ if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
+ ptr++;
+ if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
+ ptr++;
+ }
+ }
+// *ptr && (isprint(*ptr & 255) || isspace(*ptr & 255));
+// ptr ++);
+
+ // Scan the buffer for printable characters in 8 bit
+ if (*ptr || ptr == preview_text_) {
+ for (ptr = preview_text_;
*ptr && (isprint(*ptr & 255) || isspace(*ptr & 255));
ptr ++);
+ }
if (*ptr || ptr == preview_text_) {
// Non-printable file, just show a big ?...
@@ -1589,5 +1616,5 @@ unquote_pathname(char *dst, // O - Destination string
//
-// End of "$Id: Fl_File_Chooser2.cxx 6678 2009-03-13 23:36:09Z AlbrechtS $".
+// End of "$Id: Fl_File_Chooser2.cxx 6899 2009-09-23 21:32:23Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_File_Input.cxx b/plugins/zynaddsubfx/fltk/src/Fl_File_Input.cxx
index 6ed5a0759..d46c98452 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_File_Input.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_File_Input.cxx
@@ -144,7 +144,7 @@ void Fl_File_Input::update_buttons() {
\param[in] str new string value
\param[in] len lengh of value
*/
-int // O - true on success
+int // O - TRUE on success
Fl_File_Input::value(const char *str, // I - New string value
int len) { // I - Length of value
damage(FL_DAMAGE_BAR);
@@ -157,7 +157,7 @@ Fl_File_Input::value(const char *str, // I - New string value
Returns non 0 on success.
\param[in] str new string value
*/
-int // O - true on success
+int // O - TRUE on success
Fl_File_Input::value(const char *str) { // I - New string value
damage(FL_DAMAGE_BAR);
return Fl_Input::value(str);
@@ -187,7 +187,7 @@ void Fl_File_Input::draw() {
Return non zero if event is handled.
\param[in] event
*/
-int // O - true if we handled event
+int // O - TRUE if we handled event
Fl_File_Input::handle(int event) // I - Event
{
// printf("handle(event = %d)\n", event);
@@ -230,7 +230,7 @@ Fl_File_Input::handle(int event) // I - Event
Return non zero if event is handled.
\param[in] event
*/
-int // O - true if we handled event
+int // O - TRUE if we handled event
Fl_File_Input::handle_button(int event) // I - Event
{
int i, // Looping var
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Image.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Image.cxx
index 79c8762b1..e0ffc14fe 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Image.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Image.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Image.cxx 6773 2009-04-21 09:25:22Z AlbrechtS $"
+// "$Id: Fl_Image.cxx 6804 2009-06-29 07:44:25Z AlbrechtS $"
//
// Image drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -551,5 +551,5 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) {
//
-// End of "$Id: Fl_Image.cxx 6773 2009-04-21 09:25:22Z AlbrechtS $".
+// End of "$Id: Fl_Image.cxx 6804 2009-06-29 07:44:25Z AlbrechtS $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Input.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Input.cxx
index 1b25a6898..7be68aafa 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Input.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Input.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Input.cxx 6765 2009-04-15 08:35:28Z matt $"
+// "$Id: Fl_Input.cxx 6888 2009-09-19 21:16:21Z matt $"
//
// Input widget for the Fast Light Tool Kit (FLTK).
//
@@ -621,6 +621,18 @@ int Fl_Input::handle(int event) {
take_focus();
return 1;
+/* TODO: this will scroll the area, but stop if the cursor would become invisible.
+ That clipping happens in drawtext(). Do we change the clipping or should
+ we move the cursor (ouch)?
+ case FL_MOUSEWHEEL:
+ if (Fl::e_dy > 0) {
+ yscroll( yscroll() - Fl::e_dy*15 );
+ } else if (Fl::e_dy < 0) {
+ yscroll( yscroll() - Fl::e_dy*15 );
+ }
+ return 1;
+*/
+
}
Fl_Boxtype b = box();
return Fl_Input_::handletext(event,
@@ -637,5 +649,5 @@ Fl_Input::Fl_Input(int X, int Y, int W, int H, const char *l)
}
//
-// End of "$Id: Fl_Input.cxx 6765 2009-04-15 08:35:28Z matt $".
+// End of "$Id: Fl_Input.cxx 6888 2009-09-19 21:16:21Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Input_.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Input_.cxx
index 3868255b1..ca6638c60 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Input_.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Input_.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Input_.cxx 6777 2009-04-23 15:32:19Z matt $"
+// "$Id: Fl_Input_.cxx 6887 2009-09-19 20:57:48Z matt $"
//
// Common input widget routines for the Fast Light Tool Kit (FLTK).
//
@@ -134,7 +134,7 @@ double Fl_Input_::expandpos(
if (c < ' ' || c == 127) {
if (c == '\t' && input_type()==FL_MULTILINE_INPUT) {
n += 8-(chr%8);
- chr += 8-(chr%8);
+ chr += 7-(chr%8);
} else n += 2;
} else {
n++;
@@ -239,6 +239,7 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
// count how many lines and put the last one into the buffer:
// And figure out where the cursor is:
int height = fl_height();
+ int threshold = height/2;
int lines;
int curx, cury;
for (p=value(), curx=cury=lines=0; ;) {
@@ -248,15 +249,15 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
if (Fl::focus()==this && !was_up_down) up_down_pos = curx;
cury = lines*height;
int newscroll = xscroll_;
- if (curx > newscroll+W-20) {
+ if (curx > newscroll+W-threshold) {
// figure out scrolling so there is space after the cursor:
- newscroll = curx+20-W;
+ newscroll = curx+threshold-W;
// figure out the furthest left we ever want to scroll:
int ex = int(expandpos(p, e, buf, 0))+2-W;
// use minimum of both amounts:
if (ex < newscroll) newscroll = ex;
- } else if (curx < newscroll+20) {
- newscroll = curx-20;
+ } else if (curx < newscroll+threshold) {
+ newscroll = curx-threshold;
}
if (newscroll < 0) newscroll = 0;
if (newscroll != xscroll_) {
@@ -1253,5 +1254,5 @@ Fl_Char Fl_Input_::index(int i) const
}
//
-// End of "$Id: Fl_Input_.cxx 6777 2009-04-23 15:32:19Z matt $".
+// End of "$Id: Fl_Input_.cxx 6887 2009-09-19 20:57:48Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Menu.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Menu.cxx
index 4e71f0775..f49d89668 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Menu.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Menu.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu.cxx 6757 2009-04-12 20:00:45Z matt $"
+// "$Id: Fl_Menu.cxx 6841 2009-08-03 06:26:32Z AlbrechtS $"
//
// Menu code for the Fast Light Tool Kit (FLTK).
//
@@ -1014,5 +1014,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const {
}
//
-// End of "$Id: Fl_Menu.cxx 6757 2009-04-12 20:00:45Z matt $".
+// End of "$Id: Fl_Menu.cxx 6841 2009-08-03 06:26:32Z AlbrechtS $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Menu_.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Menu_.cxx
index ce7c89e10..3c83ae7b9 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Menu_.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Menu_.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu_.cxx 6660 2009-02-15 18:58:03Z AlbrechtS $"
+// "$Id: Fl_Menu_.cxx 6904 2009-09-27 11:39:02Z matt $"
//
// Common menu code for the Fast Light Tool Kit (FLTK).
//
@@ -172,11 +172,11 @@ void Fl_Menu_Item::setonly() {
}
}
-Fl_Menu_::Fl_Menu_(int X,int Y,int W,int H,const char* l)
/**
- Creates a new Fl_Menu_ widget using the given position, size,
- and label string. menu() is initialized to null.
-*/
+ Creates a new Fl_Menu_ widget using the given position, size,
+ and label string. menu() is initialized to null.
+ */
+Fl_Menu_::Fl_Menu_(int X,int Y,int W,int H,const char* l)
: Fl_Widget(X,Y,W,H,l) {
set_flag(SHORTCUT_LABEL);
box(FL_UP_BOX);
@@ -262,5 +262,5 @@ void Fl_Menu_::clear() {
}
//
-// End of "$Id: Fl_Menu_.cxx 6660 2009-02-15 18:58:03Z AlbrechtS $".
+// End of "$Id: Fl_Menu_.cxx 6904 2009-09-27 11:39:02Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Menu_add.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Menu_add.cxx
index 9a3d4be08..cbeeb631a 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Menu_add.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Menu_add.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu_add.cxx 6716 2009-03-24 01:40:44Z fabien $"
+// "$Id: Fl_Menu_add.cxx 6878 2009-09-17 22:12:24Z matt $"
//
// Menu utilities for the Fast Light Tool Kit (FLTK).
//
@@ -177,56 +177,95 @@ int Fl_Menu_Item::add(
}
/**
- Adds a new menu item, with a title string, shortcut int (or string),
- callback, argument to the callback, and flags.
+ Adds a new menu item.
+
+ \param[in] label The text label for the menu item.
+ \param[in] shortcut Optional keyboard shortcut that can be an int or string; (FL_CTRL+'a') or "^a". Default 0 if none.
+ \param[in] callback Optional callback invoked when user clicks the item. Default 0 if none.
+ \param[in] userdata Optional user data passed as an argument to the callback. Default 0 if none.
+ \param[in] flags Optional flags that control the type of menu item; see below. Default is 0 for none.
+ \returns The index into the menu() array, where the entry was added.
+
+ \par Description
If the menu array was directly set with menu(x), then copy() is done
to make a private array.
-
- The characters "&", "/", "\", and "_" are treated as
- special characters in the label string. The "&" character
- specifies that the following character is an accelerator and
- will be underlined. The "\" character is used to escape the next
- character in the string. Labels starting with the "_" character
- cause a divider to be placed after that menu item.
-
- A label of the form "foo/bar/baz" will create submenus called
- "foo" and "bar" with an entry called "baz". The "/" character is
- ignored if it appears as the first character of the label string, e.g.
- "/foo/bar/baz".
-
+ \par
+ A menu item's callback must not add() items to its parent menu during the callback.
+
+ Detailed Description of Parameters
+ \par label
+ The menu item's label. This option is required.
+ \par
+ The characters "&", "/", "\", and "_" are treated as special characters in the label string.
+ The "&" character specifies that the following character is an accelerator and will be underlined.
+ The "\" character is used to escape the next character in the string.
+ Labels starting with the "_" character cause a divider to be placed after that menu item.
+ \par
+ A label of the form "File/Quit" will create the submenu "File"
+ with a menu item called "Quit". The "/" character is ignored if it appears
+ as the first character of the label string, e.g. "/File/Quit".
+ \par
The label string is copied to new memory and can be freed.
The other arguments (including the shortcut) are copied into the
menu item unchanged.
-
+ \par
If an item exists already with that name then it is replaced with
this new one. Otherwise this new one is added to the end of the
correct menu or submenu. The return value is the offset into the array
that the new entry was placed at.
+ \par shortcut
+ The keyboard shortcut for this menu item.
+ \par
+ This parameter is optional, and defaults to 0 to indicate no shortcut.
+ \par
Shortcut can be 0L, or either a modifier/key combination (for example
FL_CTRL+'A') or a string describing the shortcut in one of two ways:
-
- \code
+ \verbatim
[#+^] e.g. "97", "^97", "+97", "#97"
[#+^] e.g. "a", "^a", "+a", "#a"
- \endcode
+ \endverbatim
..where \ is a decimal value representing an
ascii character (eg. 97 is the ascii for 'a'), and the optional
prefixes enhance the value that follows. Multiple prefixes must
appear in the above order.
- \code
+ \verbatim
# - Alt
+ - Shift
^ - Control
- \endcode
+ \endverbatim
Text shortcuts are converted to integer shortcut by calling
- int fl_old_shortcut(const char*).
-
- The return value is the index into the array that the entry was put.
-
- No items must be added to a menu during a callback to the same menu.
+ Fl_Shortcut fl_old_shortcut(const char*).
+
+ \par callback
+ The callback to invoke when this menu item is selected.
+ \par
+ This parameter is optional, and defaults to 0 for no callback.
+
+ \par userdata
+ The callback's 'user data' that is passed to the callback.
+ \par
+ This parameter is optional, and defaults to 0.
+
+ \par flags
+ These are bit flags to define what kind of menu item this is.
+ \par
+ This parameter is optional, and defaults to 0 to define a 'regular' menu item.
+ \par
+ These flags can be 'OR'ed together:
+ \code
+ FL_MENU_INACTIVE // Deactivate menu item (gray out)
+ FL_MENU_TOGGLE // Item is a checkbox toggle (shows checkbox for on/off state)
+ FL_MENU_VALUE // The on/off state for checkbox/radio buttons (if set, state is 'on')
+ FL_MENU_RADIO // Item is a radio button (one checkbox of many can be on)
+ FL_MENU_INVISIBLE // Item will not show up (shortcut will work)
+ FL_SUBMENU_POINTER // Indicates user_data() is a pointer to another menu array
+ FL_SUBMENU // This item is a submenu to other items
+ FL_MENU_DIVIDER // Creates divider line below this item. Also ends a group of radio buttons.
+ \endcode
+
*/
-int Fl_Menu_::add(const char *t, int s, Fl_Callback *c,void *v,int f) {
+int Fl_Menu_::add(const char *label,int shortcut,Fl_Callback *callback,void *userdata,int flags) {
// make this widget own the local array:
if (this != fl_menu_array_owner) {
if (fl_menu_array_owner) {
@@ -260,7 +299,7 @@ int Fl_Menu_::add(const char *t, int s, Fl_Callback *c,void *v,int f) {
}
fl_menu_array_owner = this;
}
- int r = menu_->add(t,s,c,v,f);
+ int r = menu_->add(label,shortcut,callback,userdata,flags);
// if it rellocated array we must fix the pointer:
int value_offset = value_-menu_;
menu_ = local_array; // in case it reallocated it
@@ -335,5 +374,5 @@ void Fl_Menu_::remove(int i) {
}
//
-// End of "$Id: Fl_Menu_add.cxx 6716 2009-03-24 01:40:44Z fabien $".
+// End of "$Id: Fl_Menu_add.cxx 6878 2009-09-17 22:12:24Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Progress.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Progress.cxx
index 227c90f57..d7dee6885 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Progress.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Progress.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Progress.cxx 6616 2009-01-01 21:28:26Z matt $"
+// "$Id: Fl_Progress.cxx 6794 2009-06-27 09:29:36Z AlbrechtS $"
//
// Progress bar widget routines.
//
@@ -119,5 +119,5 @@ Fl_Progress::Fl_Progress(int X, int Y, int W, int H, const char* L)
//
-// End of "$Id: Fl_Progress.cxx 6616 2009-01-01 21:28:26Z matt $".
+// End of "$Id: Fl_Progress.cxx 6794 2009-06-27 09:29:36Z AlbrechtS $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Scroll.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Scroll.cxx
index 07ebcc28f..f9a03027a 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Scroll.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Scroll.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Scroll.cxx 6654 2009-02-08 18:47:37Z AlbrechtS $"
+// "$Id: Fl_Scroll.cxx 6828 2009-07-12 00:15:06Z greg.ercolano $"
//
// Scroll widget for the Fast Light Tool Kit (FLTK).
//
@@ -413,5 +413,5 @@ int Fl_Scroll::handle(int event) {
}
//
-// End of "$Id: Fl_Scroll.cxx 6654 2009-02-08 18:47:37Z AlbrechtS $".
+// End of "$Id: Fl_Scroll.cxx 6828 2009-07-12 00:15:06Z greg.ercolano $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Text_Buffer.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Text_Buffer.cxx
index 91c33f4bc..73f72f121 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Text_Buffer.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Text_Buffer.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Text_Buffer.cxx 6765 2009-04-15 08:35:28Z matt $"
+// "$Id: Fl_Text_Buffer.cxx 6825 2009-07-04 05:18:29Z fabien $"
//
// Copyright 2001-2009 by Bill Spitzak and others.
// Original code Copyright Mark Edel. Permission to distribute under
@@ -2502,5 +2502,5 @@ Fl_Text_Buffer::outputfile(const char *file, int start, int end, int buflen) {
//
-// End of "$Id: Fl_Text_Buffer.cxx 6765 2009-04-15 08:35:28Z matt $".
+// End of "$Id: Fl_Text_Buffer.cxx 6825 2009-07-04 05:18:29Z fabien $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Text_Display.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Text_Display.cxx
index 5a01f7462..3e09584e8 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Text_Display.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Text_Display.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Text_Display.cxx 6765 2009-04-15 08:35:28Z matt $"
+// "$Id: Fl_Text_Display.cxx 6909 2009-09-28 14:41:43Z matt $"
//
// Copyright 2001-2009 by Bill Spitzak and others.
// Original code Copyright Mark Edel. Permission to distribute under
@@ -387,8 +387,8 @@ void Fl_Text_Display::resize(int X, int Y, int W, int H) {
mMaxsize = max(mMaxsize, fl_height(mStyleTable[i].font, mStyleTable[i].size));
// did we have scrollbars initially?
- int hscrollbarvisible = mHScrollBar->visible();
- int vscrollbarvisible = mVScrollBar->visible();
+ unsigned int hscrollbarvisible = mHScrollBar->visible();
+ unsigned int vscrollbarvisible = mVScrollBar->visible();
// try without scrollbars first
mVScrollBar->clear_visible();
@@ -3439,5 +3439,5 @@ int Fl_Text_Display::handle(int event) {
//
-// End of "$Id: Fl_Text_Display.cxx 6765 2009-04-15 08:35:28Z matt $".
+// End of "$Id: Fl_Text_Display.cxx 6909 2009-09-28 14:41:43Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Text_Editor.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Text_Editor.cxx
index 5e5ea41af..dc471cafe 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Text_Editor.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Text_Editor.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Text_Editor.cxx 6765 2009-04-15 08:35:28Z matt $"
+// "$Id: Fl_Text_Editor.cxx 6894 2009-09-20 21:55:21Z greg.ercolano $"
//
// Copyright 2001-2009 by Bill Spitzak and others.
// Original code Copyright Mark Edel. Permission to distribute under
@@ -156,6 +156,14 @@ static struct {
{ 'c', FL_COMMAND, Fl_Text_Editor::kf_copy },
{ 'v', FL_COMMAND, Fl_Text_Editor::kf_paste },
{ 'a', FL_COMMAND, Fl_Text_Editor::kf_select_all },
+ { FL_Left, FL_COMMAND, Fl_Text_Editor::kf_meta_move },
+ { FL_Right, FL_COMMAND, Fl_Text_Editor::kf_meta_move },
+ { FL_Up, FL_COMMAND, Fl_Text_Editor::kf_meta_move },
+ { FL_Down, FL_COMMAND, Fl_Text_Editor::kf_meta_move },
+ { FL_Left, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move },
+ { FL_Right, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move },
+ { FL_Up, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move },
+ { FL_Down, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move },
#endif // __APPLE__
{ 0, 0, 0 }
@@ -352,6 +360,40 @@ int Fl_Text_Editor::kf_ctrl_move(int c, Fl_Text_Editor* e) {
return 1;
}
+/** Moves the current text cursor in the direction indicated by meta key */
+int Fl_Text_Editor::kf_meta_move(int c, Fl_Text_Editor* e) {
+ if (!e->buffer()->selected())
+ e->dragPos = e->insert_position();
+ if (c != FL_Up && c != FL_Down) {
+ e->buffer()->unselect();
+ e->show_insert_position();
+ }
+ switch (c) {
+ case FL_Up: // top of buffer
+ e->insert_position(0);
+ e->scroll(0, 0);
+ break;
+ case FL_Down: // end of buffer
+ e->insert_position(e->buffer()->length());
+ e->scroll(e->count_lines(0, e->buffer()->length(), 1), 0);
+ break;
+ case FL_Left: // beginning of line
+ kf_move(FL_Home, e);
+ break;
+ case FL_Right: // end of line
+ kf_move(FL_End, e);
+ break;
+ }
+ return 1;
+}
+
+/** Extends the current selection in the direction indicated by meta key c. */
+int Fl_Text_Editor::kf_m_s_move(int c, Fl_Text_Editor* e) {
+ kf_meta_move(c, e);
+ fl_text_drag_me(e->insert_position(), e);
+ return 1;
+}
+
/** Extends the current selection in the direction indicated by control key c. */
int Fl_Text_Editor::kf_c_s_move(int c, Fl_Text_Editor* e) {
kf_ctrl_move(c, e);
@@ -572,5 +614,5 @@ int Fl_Text_Editor::handle(int event) {
}
//
-// End of "$Id: Fl_Text_Editor.cxx 6765 2009-04-15 08:35:28Z matt $".
+// End of "$Id: Fl_Text_Editor.cxx 6894 2009-09-20 21:55:21Z greg.ercolano $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Tooltip.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Tooltip.cxx
index ef533a0dc..ee02ac88d 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Tooltip.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Tooltip.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Tooltip.cxx 6712 2009-03-22 19:21:34Z AlbrechtS $"
+// "$Id: Fl_Tooltip.cxx 6902 2009-09-27 11:06:56Z matt $"
//
// Tooltip source file for the Fast Light Tool Kit (FLTK).
//
@@ -34,10 +34,10 @@
float Fl_Tooltip::delay_ = 1.0f;
float Fl_Tooltip::hoverdelay_ = 0.2f;
int Fl_Tooltip::enabled_ = 1;
-unsigned Fl_Tooltip::color_ = fl_color_cube(FL_NUM_RED - 1,
+Fl_Color Fl_Tooltip::color_ = fl_color_cube(FL_NUM_RED - 1,
FL_NUM_GREEN - 1,
FL_NUM_BLUE - 2);
-unsigned Fl_Tooltip::textcolor_ = FL_BLACK;
+Fl_Color Fl_Tooltip::textcolor_ = FL_BLACK;
Fl_Font Fl_Tooltip::font_ = FL_HELVETICA;
Fl_Fontsize Fl_Tooltip::size_ = FL_NORMAL_SIZE;
@@ -278,5 +278,5 @@ void Fl_Widget::tooltip(const char *tt) {
}
//
-// End of "$Id: Fl_Tooltip.cxx 6712 2009-03-22 19:21:34Z AlbrechtS $".
+// End of "$Id: Fl_Tooltip.cxx 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Window.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Window.cxx
index c0fa1a945..558a8d2e1 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Window.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Window.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Window.cxx 6669 2009-02-25 08:44:54Z AlbrechtS $"
+// "$Id: Fl_Window.cxx 6905 2009-09-27 12:06:35Z matt $"
//
// Window widget class for the Fast Light Tool Kit (FLTK).
//
@@ -66,7 +66,7 @@ Fl_Window::Fl_Window(int X,int Y,int W, int H, const char *l)
cursor_bg = FL_WHITE;
_Fl_Window();
- set_flag(FL_FORCE_POSITION);
+ set_flag(FORCE_POSITION);
}
Fl_Window::Fl_Window(int W, int H, const char *l)
@@ -151,8 +151,7 @@ void Fl_Window::copy_label(const char *a) {
void Fl_Window::iconlabel(const char *iname) {
- // FIXME: 'flags' is 32 bit large!
- uchar saveflags = flags();
+ unsigned saveflags = flags();
label(label(), iname);
set_flag(saveflags);
}
@@ -179,5 +178,5 @@ Fl_Window *Fl_Window::current() {
//
-// End of "$Id: Fl_Window.cxx 6669 2009-02-25 08:44:54Z AlbrechtS $".
+// End of "$Id: Fl_Window.cxx 6905 2009-09-27 12:06:35Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Window_fullscreen.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Window_fullscreen.cxx
index 67f9877c8..6635133fd 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_Window_fullscreen.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_Window_fullscreen.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Window_fullscreen.cxx 6660 2009-02-15 18:58:03Z AlbrechtS $"
+// "$Id: Fl_Window_fullscreen.cxx 6905 2009-09-27 12:06:35Z matt $"
//
// Fullscreen window support for the Fast Light Tool Kit (FLTK).
//
@@ -43,10 +43,10 @@
void Fl_Window::border(int b) {
if (b) {
if (border()) return;
- clear_flag(FL_NOBORDER);
+ clear_flag(NOBORDER);
} else {
if (!border()) return;
- set_flag(FL_NOBORDER);
+ set_flag(NOBORDER);
}
#if defined(USE_X11)
if (shown()) Fl_X::i(this)->sendxjunk();
@@ -91,5 +91,5 @@ void Fl_Window::fullscreen_off(int X,int Y,int W,int H) {
}
//
-// End of "$Id: Fl_Window_fullscreen.cxx 6660 2009-02-15 18:58:03Z AlbrechtS $".
+// End of "$Id: Fl_Window_fullscreen.cxx 6905 2009-09-27 12:06:35Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_arg.cxx b/plugins/zynaddsubfx/fltk/src/Fl_arg.cxx
index d0d1b6f45..b2ed5b36c 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_arg.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_arg.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_arg.cxx 6712 2009-03-22 19:21:34Z AlbrechtS $"
+// "$Id: Fl_arg.cxx 6813 2009-07-01 07:32:14Z AlbrechtS $"
//
// Optional argument initialization code for the Fast Light Tool Kit (FLTK).
//
@@ -538,5 +538,5 @@ int XParseGeometry(const char* string, int* x, int* y,
#endif // ifdef WIN32
//
-// End of "$Id: Fl_arg.cxx 6712 2009-03-22 19:21:34Z AlbrechtS $".
+// End of "$Id: Fl_arg.cxx 6813 2009-07-01 07:32:14Z AlbrechtS $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_mac.cxx b/plugins/zynaddsubfx/fltk/src/Fl_mac.cxx
index 5e181fc6c..28541652c 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_mac.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_mac.cxx 6758 2009-04-13 07:32:01Z matt $"
+// "$Id: Fl_mac.cxx 6905 2009-09-27 12:06:35Z matt $"
//
// MacOS specific code for the Fast Light Tool Kit (FLTK).
//
@@ -1496,10 +1496,10 @@ void fl_open_display() {
beenHereDoneThat = 1;
FlushEvents(everyEvent,0);
-
+
MoreMasters(); // \todo Carbon suggests MoreMasterPointers()
AEInstallEventHandler( kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP((AEEventHandlerProcPtr)QuitAppleEventHandler), 0, false );
-
+
// create the Mac Handle for the default cursor (a pointer to a pointer)
GetQDGlobalsArrow(&default_cursor);
default_cursor_ptr = &default_cursor;
@@ -1508,12 +1508,12 @@ void fl_open_display() {
ClearMenuBar();
AppendResMenu( GetMenuHandle( 1 ), 'DRVR' );
DrawMenuBar();
-
+
// bring the application into foreground without a 'CARB' resource
Boolean same_psn;
ProcessSerialNumber cur_psn, front_psn;
if( !GetCurrentProcess( &cur_psn ) && !GetFrontProcess( &front_psn ) &&
- !SameProcess( &front_psn, &cur_psn, &same_psn ) && !same_psn )
+ !SameProcess( &front_psn, &cur_psn, &same_psn ) && !same_psn )
{
// only transform the application type for unbundled apps
CFBundleRef bundle = CFBundleGetMainBundle();
@@ -1522,35 +1522,16 @@ void fl_open_display() {
FSRef execFs;
CFURLRef execUrl = CFBundleCopyExecutableURL( bundle );
CFURLGetFSRef( execUrl, &execFs );
-
+
FSRef bundleFs;
GetProcessBundleLocation( &cur_psn, &bundleFs );
-
+
if( !FSCompareFSRefs( &execFs, &bundleFs ) )
bundle = NULL;
-
+
CFRelease(execUrl);
}
-
- // imm: keycode handler stub setting - use Gestalt to determine the running system version,
- // then set the keycode_function pointer accordingly
- SInt32 MacVersion;
- if (Gestalt(gestaltSystemVersion, &MacVersion) == noErr)
- {
-// SInt32 maj, min, fix;
-// Gestalt(gestaltSystemVersionMajor, &maj); // e.g. 10
-// Gestalt(gestaltSystemVersionMinor, &min); // e.g. 4
-// Gestalt(gestaltSystemVersionBugFix, &fix); // e.g. 11
- if(MacVersion >= 0x1050) { // 10.5.0 or later
- keycode_function = keycodeToUnicode;
- }
- else {
- keycode_function = keycode_wrap_old; // pre-10.5 mechanism
- }
- }
- // else our default handler will be used (keycode_wrap_old)
-
-
+
if( !bundle )
{
// Earlier versions of this code tried to use weak linking, however it
@@ -1558,19 +1539,30 @@ void fl_open_display() {
// both TransformProcessType and CPSEnableForegroundOperation, the following
// conditional code compiled on 10.2 will still work on newer releases...
OSErr err;
-
+
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
if (TransformProcessType != NULL) {
- err = TransformProcessType(&cur_psn, kProcessTransformToForegroundApplication);
- } else
+ err = TransformProcessType(&cur_psn, kProcessTransformToForegroundApplication);
+ } else
#endif // MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
- err = CPSEnableForegroundOperation(&cur_psn, 0x03, 0x3C, 0x2C, 0x1103);
-
+ err = CPSEnableForegroundOperation(&cur_psn, 0x03, 0x3C, 0x2C, 0x1103);
+
if (err == noErr) {
- SetFrontProcess( &cur_psn );
+ SetFrontProcess( &cur_psn );
}
}
}
+
+ // imm: keycode handler stub setting - use Gestalt to determine the running system version,
+ // then set the keycode_function pointer accordingly
+ keycode_function = keycode_wrap_old; // default to pre-10.5 mechanism
+ SInt32 MacVersion;
+ if (Gestalt(gestaltSystemVersion, &MacVersion) == noErr)
+ {
+ if(MacVersion >= 0x1050) { // 10.5.0 or later
+ keycode_function = keycodeToUnicode;
+ }
+ }
}
}
@@ -2185,7 +2177,7 @@ void Fl_X::make(Fl_Window* w)
wp += 2*bx;
hp += 2*by+bt;
}
- if (!(w->flags() & Fl_Window::FL_FORCE_POSITION)) {
+ if (!(w->flags() & Fl_Widget::FORCE_POSITION)) {
// use the Carbon functions below for default window positioning
w->x(xyPos+Fl::x());
w->y(xyPos+Fl::y());
@@ -2232,7 +2224,7 @@ void Fl_X::make(Fl_Window* w)
SetWindowClass(x->xid, kFloatingWindowClass);
SetWindowActivationScope(x->xid, kWindowActivationScopeAll);
}
- if (!(w->flags() & Fl_Window::FL_FORCE_POSITION))
+ if (!(w->flags() & Fl_Widget::FORCE_POSITION))
{
WindowRef pw = Fl_X::first ? Fl_X::first->xid : 0 ;
if (w->modal()) {
@@ -2412,7 +2404,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
int is_a_resize = (W != w() || H != h());
// printf("Fl_Winodw::resize(X=%d, Y=%d, W=%d, H=%d), is_a_resize=%d, resize_from_system=%p, this=%p\n",
// X, Y, W, H, is_a_resize, resize_from_system, this);
- if (X != x() || Y != y()) set_flag(FL_FORCE_POSITION);
+ if (X != x() || Y != y()) set_flag(FORCE_POSITION);
else if (!is_a_resize) return;
if ( (resize_from_system!=this) && (!parent()) && shown()) {
if (is_a_resize) {
@@ -2881,5 +2873,5 @@ void MacUnmapWindow(Fl_Window *w, WindowPtr p) {
#endif // FL_DOXYGEN
//
-// End of "$Id: Fl_mac.cxx 6758 2009-04-13 07:32:01Z matt $".
+// End of "$Id: Fl_mac.cxx 6905 2009-09-27 12:06:35Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_win32.cxx b/plugins/zynaddsubfx/fltk/src/Fl_win32.cxx
index be96d311f..a97a082da 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_win32.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_win32.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_win32.cxx 6668 2009-02-21 10:18:47Z AlbrechtS $"
+// "$Id: Fl_win32.cxx 6905 2009-09-27 12:06:35Z matt $"
//
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
//
@@ -398,7 +398,7 @@ int fl_wait(double time_to_wait) {
time_to_wait = (time_to_wait > 10000 ? 10000 : time_to_wait);
int t_msec = (int) (time_to_wait * 1000.0 + 0.5);
- MsgWaitForMultipleObjects(0, NULL, false, t_msec, QS_ALLINPUT);
+ MsgWaitForMultipleObjects(0, NULL, FALSE, t_msec, QS_ALLINPUT);
fl_lock_function();
@@ -1127,7 +1127,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
#if USE_COLORMAP
case WM_QUERYNEWPALETTE :
fl_GetDC(hWnd);
- if (fl_select_palette()) InvalidateRect(hWnd, NULL, false);
+ if (fl_select_palette()) InvalidateRect(hWnd, NULL, FALSE);
break;
case WM_PALETTECHANGED:
@@ -1215,7 +1215,7 @@ int Fl_X::fake_X_wm(const Fl_Window* w,int &X,int &Y, int &bt,int &bx, int &by)
r.right = w->x()+w->w();
r.bottom = w->y()+w->h();
// get the decoration rectangle for the desired client rectangle
- BOOL ok = AdjustWindowRectEx(&r, style, false, exstyle);
+ BOOL ok = AdjustWindowRectEx(&r, style, FALSE, exstyle);
if (ok) {
X = r.left;
Y = r.top;
@@ -1292,7 +1292,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
int resize_from_program = (this != resize_bug_fix);
if (!resize_from_program) resize_bug_fix = 0;
if (X != x() || Y != y()) {
- set_flag(FL_FORCE_POSITION);
+ set_flag(FORCE_POSITION);
} else {
if (!is_a_resize) return;
flags |= SWP_NOMOVE;
@@ -1474,7 +1474,7 @@ Fl_X* Fl_X::make(Fl_Window* w) {
wp += 2*bx;
hp += 2*by+bt;
}
- if (!(w->flags() & Fl_Window::FL_FORCE_POSITION)) {
+ if (!(w->flags() & Fl_Widget::FORCE_POSITION)) {
xp = yp = CW_USEDEFAULT;
} else {
if (!Fl::grab()) {
@@ -1557,7 +1557,7 @@ Fl_X* Fl_X::make(Fl_Window* w) {
CoCreateInstance(CLSID_CActiveIMM, NULL, CLSCTX_INPROC_SERVER,
IID_IActiveIMMApp, (void**) &fl_aimm);
if (fl_aimm) {
- fl_aimm->Activate(true);
+ fl_aimm->Activate(TRUE);
}
}
#endif // !__GNUC__ || __GNUC__ >= 3
@@ -1916,5 +1916,5 @@ void fl_cleanup_dc_list(void) { // clean up the list
#endif // FL_DOXYGEN
//
-// End of "$Id: Fl_win32.cxx 6668 2009-02-21 10:18:47Z AlbrechtS $".
+// End of "$Id: Fl_win32.cxx 6905 2009-09-27 12:06:35Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/Fl_x.cxx b/plugins/zynaddsubfx/fltk/src/Fl_x.cxx
index 9cb834a4b..468333831 100644
--- a/plugins/zynaddsubfx/fltk/src/Fl_x.cxx
+++ b/plugins/zynaddsubfx/fltk/src/Fl_x.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_x.cxx 6767 2009-04-16 22:23:36Z AlbrechtS $"
+// "$Id: Fl_x.cxx 6905 2009-09-27 12:06:35Z matt $"
//
// X specific code for the Fast Light Tool Kit (FLTK).
//
@@ -1352,7 +1352,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
int is_a_resize = (W != w() || H != h());
int resize_from_program = (this != resize_bug_fix);
if (!resize_from_program) resize_bug_fix = 0;
- if (is_a_move && resize_from_program) set_flag(FL_FORCE_POSITION);
+ if (is_a_move && resize_from_program) set_flag(FORCE_POSITION);
else if (!is_a_resize && !is_a_move) return;
if (is_a_resize) {
Fl_Group::resize(X,Y,W,H);
@@ -1430,7 +1430,7 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
if (!win->parent() && !Fl::grab()) {
// center windows in case window manager does not do anything:
#ifdef FL_CENTER_WINDOWS
- if (!(win->flags() & Fl_Window::FL_FORCE_POSITION)) {
+ if (!(win->flags() & Fl_Widget::FORCE_POSITION)) {
win->x(X = scr_x+(scr_w-W)/2);
win->y(Y = scr_y+(scr_h-H)/2);
}
@@ -1636,7 +1636,7 @@ void Fl_X::sendxjunk() {
prop[1] = 1|2|16; // MWM_FUNC_ALL | MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE
}
- if (w->flags() & Fl_Window::FL_FORCE_POSITION) {
+ if (w->flags() & Fl_Widget::FORCE_POSITION) {
hints->flags |= USPosition;
hints->x = w->x();
hints->y = w->y();
@@ -1741,5 +1741,5 @@ void Fl_Window::make_current() {
#endif
//
-// End of "$Id: Fl_x.cxx 6767 2009-04-16 22:23:36Z AlbrechtS $".
+// End of "$Id: Fl_x.cxx 6905 2009-09-27 12:06:35Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/fl_ask.cxx b/plugins/zynaddsubfx/fltk/src/fl_ask.cxx
index 897f6d8f8..0abb379ad 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_ask.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_ask.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_ask.cxx 6763 2009-04-13 22:47:21Z AlbrechtS $"
+// "$Id: fl_ask.cxx 6869 2009-09-13 21:57:46Z AlbrechtS $"
//
// Standard dialog functions for the Fast Light Tool Kit (FLTK).
//
@@ -215,8 +215,7 @@ static int innards(const char* fmt, va_list ap,
message_form->show();
// deactivate Fl::grab(), because it is incompatible with Fl::readqueue()
Fl_Window* g = Fl::grab();
- if (g) // do an alternative grab to avoid floating menus, if possible
- Fl::grab(message_form);
+ if (g) Fl::grab(0);
int r = 0;
for (;;) {
Fl_Widget *o = Fl::readqueue();
@@ -461,5 +460,5 @@ const char *fl_password(const char *fmt, const char *defstr, ...) {
/** @} */
//
-// End of "$Id: fl_ask.cxx 6763 2009-04-13 22:47:21Z AlbrechtS $".
+// End of "$Id: fl_ask.cxx 6869 2009-09-13 21:57:46Z AlbrechtS $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/fl_boxtype.cxx b/plugins/zynaddsubfx/fltk/src/fl_boxtype.cxx
index 32d597cbe..6f8222ee0 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_boxtype.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_boxtype.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_boxtype.cxx 6716 2009-03-24 01:40:44Z fabien $"
+// "$Id: fl_boxtype.cxx 6902 2009-09-27 11:06:56Z matt $"
//
// Box drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -406,7 +406,7 @@ void Fl_Widget::draw_box() const {
// if (t == FL_FLAT_BOX) return;
// t += 2; // convert box to frame
// }
- draw_box((Fl_Boxtype)t, x_, y_, w_, h_, (Fl_Color)color_);
+ draw_box((Fl_Boxtype)t, x_, y_, w_, h_, color_);
}
/** Draws a box of type t, of color c at the widget's position and size. */
void Fl_Widget::draw_box(Fl_Boxtype t, Fl_Color c) const {
@@ -420,5 +420,5 @@ void Fl_Widget::draw_box(Fl_Boxtype t, int X, int Y, int W, int H, Fl_Color c) c
}
//
-// End of "$Id: fl_boxtype.cxx 6716 2009-03-24 01:40:44Z fabien $".
+// End of "$Id: fl_boxtype.cxx 6902 2009-09-27 11:06:56Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/fl_color.cxx b/plugins/zynaddsubfx/fltk/src/fl_color.cxx
index f611d31ff..c1d182227 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_color.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_color.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_color.cxx 6716 2009-03-24 01:40:44Z fabien $"
+// "$Id: fl_color.cxx 6813 2009-07-01 07:32:14Z AlbrechtS $"
//
// Color functions for the Fast Light Tool Kit (FLTK).
//
@@ -484,5 +484,5 @@ Fl_Color fl_contrast(Fl_Color fg, Fl_Color bg) {
@}
*/
//
-// End of "$Id: fl_color.cxx 6716 2009-03-24 01:40:44Z fabien $".
+// End of "$Id: fl_color.cxx 6813 2009-07-01 07:32:14Z AlbrechtS $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/fl_color_win32.cxx b/plugins/zynaddsubfx/fltk/src/fl_color_win32.cxx
index a1564628c..48ce3a9fe 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_color_win32.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_color_win32.cxx
@@ -241,7 +241,7 @@ fl_select_palette(void)
fl_palette = CreatePalette(pPal);
}
if (fl_palette) {
- SelectPalette(fl_gc, fl_palette, false);
+ SelectPalette(fl_gc, fl_palette, FALSE);
RealizePalette(fl_gc);
}
return fl_palette;
diff --git a/plugins/zynaddsubfx/fltk/src/fl_dnd_win32.cxx b/plugins/zynaddsubfx/fltk/src/fl_dnd_win32.cxx
index c65cec389..133bb7ae6 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_dnd_win32.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_dnd_win32.cxx
@@ -434,14 +434,14 @@ public:
// df->pFiles = sizeof(DROPFILES);
// df->pt.x = 0;
// df->pt.y = 0;
-// df->fNC = false;
+// df->fNC = FALSE;
// for (int i = 0; i < fl_selection_length[0]; i++) {
// if (fl_selection_buffer[0][i] == '\n') {
// fl_selection_buffer[0][i] = '\0';
// }
// }
//
-// df->fWide = true;
+// df->fWide = TRUE;
// l = fl_utf2unicode((unsigned char*)fl_selection_buffer[0],
// fl_selection_length[0], (xchar*)(((char*)pMem)
// + sizeof(DROPFILES)));
diff --git a/plugins/zynaddsubfx/fltk/src/fl_draw.cxx b/plugins/zynaddsubfx/fltk/src/fl_draw.cxx
index a501c27ee..5d8e57475 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_draw.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_draw.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_draw.cxx 6735 2009-04-01 22:11:57Z engelsman $"
+// "$Id: fl_draw.cxx 6845 2009-08-28 20:14:41Z greg.ercolano $"
//
// Label drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -422,6 +422,31 @@ void fl_measure(const char* str, int& w, int& h, int draw_symbols) {
h = lines*h;
}
+/**
+ This function returns the actual height of the specified \p font
+ and \p size. Normally the font height should always be 'size',
+ but with the advent of XFT, there are (currently) complexities
+ that seem to only be solved by asking the font what its actual
+ font height is. (See STR#2115)
+
+ This function was originally undocumented in 1.1.x, and was used
+ only by Fl_Text_Display. We're now documenting it in 1.3.x so that
+ apps that need precise height info can get it with this function.
+
+ \returns the height of the font in pixels.
+
+ \todo In the future, when the XFT issues are resolved, this function
+ should simply return the 'size' value.
+*/
+int fl_height(int font, int size) {
+ if ( font == fl_font() && size == fl_size() ) return(fl_height());
+ int tf = fl_font(), ts = fl_size(); // save
+ fl_font(font,size);
+ int height = fl_height();
+ fl_font(tf,ts); // restore
+ return(height);
+}
+
//
-// End of "$Id: fl_draw.cxx 6735 2009-04-01 22:11:57Z engelsman $".
+// End of "$Id: fl_draw.cxx 6845 2009-08-28 20:14:41Z greg.ercolano $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/fl_draw_image_win32.cxx b/plugins/zynaddsubfx/fltk/src/fl_draw_image_win32.cxx
index 15dce417c..d94e8b3b2 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_draw_image_win32.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_draw_image_win32.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_draw_image_win32.cxx 6616 2009-01-01 21:28:26Z matt $"
+// "$Id: fl_draw_image_win32.cxx 6844 2009-08-24 19:55:29Z AlbrechtS $"
//
// WIN32 image drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -115,8 +115,10 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
int delta, int linedelta, int depth,
Fl_Draw_Image_Cb cb, void* userdata)
{
+ char indexed = 0;
+
#if USE_COLORMAP
- char indexed = (fl_palette != 0);
+ indexed = (fl_palette != 0);
#endif
if (depth==0) depth = 3;
@@ -319,5 +321,5 @@ void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) {
}
//
-// End of "$Id: fl_draw_image_win32.cxx 6616 2009-01-01 21:28:26Z matt $".
+// End of "$Id: fl_draw_image_win32.cxx 6844 2009-08-24 19:55:29Z AlbrechtS $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/fl_font_win32.cxx b/plugins/zynaddsubfx/fltk/src/fl_font_win32.cxx
index db7ef6b3c..fc708a8ca 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_font_win32.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_font_win32.cxx
@@ -44,8 +44,8 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize size) {
fl_angle_*10, // base-line orientation angle
weight,
italic,
- false, // underline attribute flag
- false, // strikeout attribute flag
+ FALSE, // underline attribute flag
+ FALSE, // strikeout attribute flag
DEFAULT_CHARSET, // character set identifier
OUT_DEFAULT_PRECIS, // output precision
CLIP_DEFAULT_PRECIS,// clipping precision
diff --git a/plugins/zynaddsubfx/fltk/src/fl_font_xft.cxx b/plugins/zynaddsubfx/fltk/src/fl_font_xft.cxx
index c101675a3..a7d43fcd4 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_font_xft.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_font_xft.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_font_xft.cxx 6779 2009-04-24 09:28:30Z yuri $"
+// "$Id: fl_font_xft.cxx 6862 2009-09-13 10:15:42Z matt $"
//
// Xft font code for the Fast Light Tool Kit (FLTK).
//
@@ -635,5 +635,5 @@ void fl_rtl_draw(const char* c, int n, int x, int y) {
#endif
//
-// End of "$Id: fl_font_xft.cxx 6779 2009-04-24 09:28:30Z yuri $"
+// End of "$Id: fl_font_xft.cxx 6862 2009-09-13 10:15:42Z matt $"
//
diff --git a/plugins/zynaddsubfx/fltk/src/fl_open_uri.cxx b/plugins/zynaddsubfx/fltk/src/fl_open_uri.cxx
index ea97de6c9..e882e1936 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_open_uri.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_open_uri.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_open_uri.cxx 6641 2009-01-20 11:10:29Z fabien $"
+// "$Id: fl_open_uri.cxx 6901 2009-09-26 13:56:04Z matt $"
//
// fl_open_uri() code for FLTK.
//
@@ -117,9 +117,9 @@ fl_open_uri(const char *uri, char *msg, int msglen) {
#elif defined(__APPLE__)
char *argv[3]; // Command-line arguments
- argv[0] = "open";
- argv[1] = (char *)uri;
- argv[2] = 0;
+ argv[0] = (char*)"open";
+ argv[1] = (char*)uri;
+ argv[2] = (char*)0;
if (msg) snprintf(msg, msglen, "open %s", uri);
@@ -364,5 +364,5 @@ int main(int argc, char **argv) {
//
-// End of "$Id: fl_open_uri.cxx 6641 2009-01-20 11:10:29Z fabien $".
+// End of "$Id: fl_open_uri.cxx 6901 2009-09-26 13:56:04Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/fl_shortcut.cxx b/plugins/zynaddsubfx/fltk/src/fl_shortcut.cxx
index f2f400d8a..56b03241d 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_shortcut.cxx
+++ b/plugins/zynaddsubfx/fltk/src/fl_shortcut.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_shortcut.cxx 6760 2009-04-13 11:32:58Z matt $"
+// "$Id: fl_shortcut.cxx 6878 2009-09-17 22:12:24Z matt $"
//
// Shortcut support routines for the Fast Light Tool Kit (FLTK).
//
@@ -39,7 +39,7 @@
// It also checks against the first character of Fl::event_text(),
// and zero for FL_SHIFT means "don't care".
// This allows punctuation shortcuts like "#" to work (rather than
-// calling it "shift+3")
+// calling it "shift+3" on a US keyboard)
#include
#include
@@ -58,19 +58,12 @@
be confused with
Fl_Widget::test_shortcut().
*/
-int Fl::test_shortcut(int shortcut) {
+int Fl::test_shortcut(Fl_Shortcut shortcut) {
if (!shortcut) return 0;
- int v = shortcut & 0xffff;
-#ifdef __APPLE__
- if (v > 32 && v < 0x7f || v >= 0x80 && v <= 0xff) {
-#else
- // most X11 use MSWindows Latin-1 if set to Western encoding, so 0x80 to 0xa0 are defined
- if (v > 32 && v < 0x7f || v >= 0x80 && v <= 0xff) {
-#endif
- if (isupper(v)) {
- shortcut |= FL_SHIFT;
- }
+ Fl_Char v = shortcut & FL_KEY_MASK;
+ if (fl_tolower(v)!=v) {
+ shortcut |= FL_SHIFT;
}
int shift = Fl::event_state();
@@ -81,17 +74,18 @@ int Fl::test_shortcut(int shortcut) {
// these three must always be correct:
if (mismatch&(FL_META|FL_ALT|FL_CTRL)) return 0;
- int key = shortcut & 0xffff;
+ Fl_Char key = shortcut & FL_KEY_MASK;
// if shift is also correct, check for exactly equal keysyms:
if (!(mismatch&(FL_SHIFT)) && key == Fl::event_key()) return 1;
- // try matching ascii, ignore shift:
- if (key == event_text()[0]) return 1;
+ // try matching utf8, ignore shift:
+ Fl_Char firstChar = fl_utf8decode(Fl::event_text(), Fl::event_text()+Fl::event_length(), 0);
+ if (key==firstChar) return 1;
// kludge so that Ctrl+'_' works (as opposed to Ctrl+'^_'):
if ((shift&FL_CTRL) && key >= 0x3f && key <= 0x5F
- && event_text()[0]==(key^0x40)) return 1;
+ && firstChar==(key^0x40)) return 1; // firstChar should be within a-z
return 0;
}
@@ -180,7 +174,7 @@ static Keyname table[] = {
\param [in] shortcut the integer value containing the ascii charcter or extended keystroke plus modifiers
\return a pointer to a static buffer containing human readable text for the shortcut
*/
-const char* fl_shortcut_label(int shortcut) {
+const char* fl_shortcut_label(Fl_Shortcut shortcut) {
return fl_shortcut_label(shortcut, 0L);
}
@@ -190,23 +184,17 @@ const char* fl_shortcut_label(int shortcut) {
\param [in] shortcut the integer value containing the ascii charcter or extended keystroke plus modifiers
\param [in] eom if this pointer is set, it will receive a pointer to the end of the modifier text
\return a pointer to a static buffer containing human readable text for the shortcut
- \see fl_shortcut_label(int shortcut)
+ \see fl_shortcut_label(Fl_Shortcut shortcut)
*/
-const char* fl_shortcut_label(int shortcut, const char **eom) {
+const char* fl_shortcut_label(Fl_Shortcut shortcut, const char **eom) {
static char buf[20];
char *p = buf;
if (eom) *eom = p;
if (!shortcut) {*p = 0; return buf;}
// fix upper case shortcuts
- int v = shortcut & 0xffff;
-#ifdef __APPLE__
- if (v > 32 && v < 0x7f || v >= 0x80 && v <= 0xff) {
-#else
- if (v > 32 && v < 0x7f || v >= 0xa0 && v <= 0xff) {
-#endif
- if (isupper(v)) {
- shortcut |= FL_SHIFT;
- }
+ Fl_Char v = shortcut & FL_KEY_MASK;
+ if (fl_tolower(v)!=v) {
+ shortcut |= FL_SHIFT;
}
#ifdef __APPLE__
// this column contains utf8 characters - v
@@ -221,7 +209,7 @@ const char* fl_shortcut_label(int shortcut, const char **eom) {
if (shortcut & FL_CTRL) {strcpy(p,"Ctrl+"); p += 5;}
#endif // __APPLE__
if (eom) *eom = p;
- int key = shortcut & 0xFFFF;
+ Fl_Char key = shortcut & FL_KEY_MASK;
#if defined(WIN32) || defined(__APPLE__) // if not X
if (key >= FL_F && key <= FL_F_Last) {
*p++ = 'F';
@@ -234,7 +222,7 @@ const char* fl_shortcut_label(int shortcut, const char **eom) {
while (a < b) {
int c = (a+b)/2;
if (table[c].key == key) {
- if (p > buf) {
+ if (p > buf) {
strcpy(p,table[c].name);
return buf;
} else {
@@ -252,7 +240,7 @@ const char* fl_shortcut_label(int shortcut, const char **eom) {
*p++ = uchar(key & 127);
} else {
// if none found, use the keystroke as a match:
- *p++ = uchar(toupper(key & 255));
+ p += fl_utf8encode(fl_toupper(key), p);
}
}
*p = 0;
@@ -262,7 +250,11 @@ const char* fl_shortcut_label(int shortcut, const char **eom) {
if (key == FL_Enter || key == '\r') q="Enter"; // don't use Xlib's "Return":
else if (key > 32 && key < 0x100) q = 0;
else q = XKeysymToString(key);
- if (!q) {*p++ = uchar(toupper(key & 255)); *p = 0; return buf;}
+ if (!q) {
+ p += fl_utf8encode(fl_toupper(key), p);
+ *p = 0;
+ return buf;
+ }
if (p > buf) {
strcpy(p,q);
return buf;
@@ -278,9 +270,9 @@ const char* fl_shortcut_label(int shortcut, const char **eom) {
/**
Emulation of XForms named shortcuts.
*/
-int fl_old_shortcut(const char* s) {
+Fl_Shortcut fl_old_shortcut(const char* s) {
if (!s || !*s) return 0;
- int n = 0;
+ Fl_Shortcut n = 0;
if (*s == '#') {n |= FL_ALT; s++;}
if (*s == '+') {n |= FL_SHIFT; s++;}
if (*s == '^') {n |= FL_CTRL; s++;}
@@ -290,14 +282,14 @@ int fl_old_shortcut(const char* s) {
// Tests for &x shortcuts in button labels:
-char Fl_Widget::label_shortcut(const char *t) {
+Fl_Shortcut Fl_Widget::label_shortcut(const char *t) {
if (!t) return 0;
for (;;) {
if (*t==0) return 0;
if (*t=='&') {
- char s = t[1];
+ Fl_Shortcut s = fl_utf8decode(t+1, 0, 0);
if (s==0) return 0;
- else if (s=='&') t++;
+ else if (s==(Fl_Char)'&') t++;
else return s;
}
t++;
@@ -309,8 +301,9 @@ int Fl_Widget::test_shortcut(const char *t) {
// on MSWindows, users expect shortcuts to work only when the Alt modifier is pressed
if (Fl::event_state(FL_ALT)==0) return 0;
#endif
- char c = Fl::event_text()[0];
- if (!c || !t) return 0;
+ if (!t) return 0;
+ Fl_Shortcut c = fl_utf8decode(Fl::event_text(), Fl::event_text()+Fl::event_length(), 0);
+ if (!c) return 0;
if (c == label_shortcut(t))
return 1;
return 0;
@@ -322,5 +315,5 @@ int Fl_Widget::test_shortcut() {
}
//
-// End of "$Id: fl_shortcut.cxx 6760 2009-04-13 11:32:58Z matt $".
+// End of "$Id: fl_shortcut.cxx 6878 2009-09-17 22:12:24Z matt $".
//
diff --git a/plugins/zynaddsubfx/fltk/src/fl_utf.c b/plugins/zynaddsubfx/fltk/src/fl_utf.c
index 1362ef755..cc2059ce5 100644
--- a/plugins/zynaddsubfx/fltk/src/fl_utf.c
+++ b/plugins/zynaddsubfx/fltk/src/fl_utf.c
@@ -138,11 +138,11 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
{
unsigned char c = *(unsigned char*)p;
if (c < 0x80) {
- *len = 1;
+ if (len) *len = 1;
return c;
#if ERRORS_TO_CP1252
} else if (c < 0xa0) {
- *len = 1;
+ if (len) *len = 1;
return cp1252[c-0x80];
#endif
} else if (c < 0xc2) {
@@ -150,7 +150,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
}
if (p+1 >= end || (p[1]&0xc0) != 0x80) goto FAIL;
if (c < 0xe0) {
- *len = 2;
+ if (len) *len = 2;
return
((p[0] & 0x1f) << 6) +
((p[1] & 0x3f));
@@ -171,7 +171,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
} else if (c < 0xf0) {
UTF8_3:
if (p+2 >= end || (p[2]&0xc0) != 0x80) goto FAIL;
- *len = 3;
+ if (len) *len = 3;
return
((p[0] & 0x0f) << 12) +
((p[1] & 0x3f) << 6) +
@@ -182,7 +182,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
} else if (c < 0xf4) {
UTF8_4:
if (p+3 >= end || (p[2]&0xc0) != 0x80 || (p[3]&0xc0) != 0x80) goto FAIL;
- *len = 4;
+ if (len) *len = 4;
#if STRICT_RFC3629
/* RFC 3629 says all codes ending in fffe or ffff are illegal: */
if ((p[1]&0xf)==0xf &&
@@ -199,7 +199,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len)
goto UTF8_4;
} else {
FAIL:
- *len = 1;
+ if (len) *len = 1;
#if ERRORS_TO_ISO8859_1
return c;
#else
diff --git a/plugins/zynaddsubfx/fltk/src/screen_xywh.cxx b/plugins/zynaddsubfx/fltk/src/screen_xywh.cxx
index adfaa1dd9..fa7e1e139 100644
--- a/plugins/zynaddsubfx/fltk/src/screen_xywh.cxx
+++ b/plugins/zynaddsubfx/fltk/src/screen_xywh.cxx
@@ -58,7 +58,7 @@ static fl_gmi_func fl_gmi = NULL; // used to get a proc pointer for GetMonitorIn
static RECT screens[16];
static BOOL CALLBACK screen_cb(HMONITOR mon, HDC, LPRECT r, LPARAM) {
- if (num_screens >= 16) return true;
+ if (num_screens >= 16) return TRUE;
MONITORINFO mi;
mi.cbSize = sizeof(mi);
@@ -69,7 +69,7 @@ static BOOL CALLBACK screen_cb(HMONITOR mon, HDC, LPRECT r, LPARAM) {
screens[num_screens] = mi.rcWork;
num_screens ++;
}
- return true;
+ return TRUE;
}
static void screen_init() {
diff --git a/plugins/zynaddsubfx/src/Controls/Control.cpp b/plugins/zynaddsubfx/src/Controls/Control.cpp
index 36792fc63..d7cf5cb9d 100644
--- a/plugins/zynaddsubfx/src/Controls/Control.cpp
+++ b/plugins/zynaddsubfx/src/Controls/Control.cpp
@@ -22,19 +22,19 @@
#include "Control.h"
Control::Control(char ndefaultval)
- :defaultval(ndefaultval),lockqueue(-1),locked(false)
+ :defaultval(ndefaultval), lockqueue(-1), locked(false)
{}
void Control::lock()
{
- locked=true;
- lockqueue=-1;
+ locked = true;
+ lockqueue = -1;
}
void Control::ulock()
{
- if (locked&&lockqueue>=0)
+ if(locked && (lockqueue >= 0))
setmVal(lockqueue);
- locked=false;
+ locked = false;
}
diff --git a/plugins/zynaddsubfx/src/Controls/Control.h b/plugins/zynaddsubfx/src/Controls/Control.h
index 2b6eaea77..931a4745c 100644
--- a/plugins/zynaddsubfx/src/Controls/Control.h
+++ b/plugins/zynaddsubfx/src/Controls/Control.h
@@ -25,33 +25,33 @@
/**A control for a parameter within the program*/
class Control
{
-public:
- Control(char ndefaultval);/**\todo create proper initialization list*/
- ~Control() {};
- /**Return the string, which represents the internal value
- * @return a string representation of the current value*/
- virtual std::string getString()const=0;
- /**Set the Control to the given value
- * @param nval A number 0-127*/
- virtual void setmVal(char nval)=0;
- /**Return the midi value (aka the char)
- * @return the current value*/
- virtual char getmVal()const=0;
- /** Will lock the Control until it is ulocked
- *
- * Locking a Control will Stop it from having
- * its internal data altered*/
- void lock();
- /** Will unlock the Control
- *
- * This will also update the Control
- * if something attempted to update it while it was locked*/
- void ulock();
-private:
- char defaultval;/**
DelayCtl::DelayCtl()
- :Control(64),value(64/127.0*1.5) {} /**\todo finishme*/
+ :Control(64), value(64 / 127.0 * 1.5) {} /**\todo finishme*/
std::string DelayCtl::getString() const
{
std::ostringstream buf;
- buf<
#include "AnalogFilter.h"
-AnalogFilter::AnalogFilter(unsigned char Ftype,REALTYPE Ffreq, REALTYPE Fq,unsigned char Fstages)
+AnalogFilter::AnalogFilter(unsigned char Ftype,
+ REALTYPE Ffreq,
+ REALTYPE Fq,
+ unsigned char Fstages)
{
- stages=Fstages;
- for (int i=0;i<3;i++) {
- oldc[i]=0.0;
- oldd[i]=0.0;
- c[i]=0.0;
- d[i]=0.0;
- };
- type=Ftype;
- freq=Ffreq;
- q=Fq;
- gain=1.0;
- if (stages>=MAX_FILTER_STAGES) stages=MAX_FILTER_STAGES;
+ stages = Fstages;
+ for(int i = 0; i < 3; i++) {
+ oldc[i] = 0.0;
+ oldd[i] = 0.0;
+ c[i] = 0.0;
+ d[i] = 0.0;
+ }
+ type = Ftype;
+ freq = Ffreq;
+ q = Fq;
+ gain = 1.0;
+ if(stages >= MAX_FILTER_STAGES)
+ stages = MAX_FILTER_STAGES;
cleanup();
- firsttime=0;
- abovenq=0;
- oldabovenq=0;
- setfreq_and_q(Ffreq,Fq);
- firsttime=1;
- d[0]=0;//this is not used
- outgain=1.0;
-};
+ firsttime = 0;
+ abovenq = 0;
+ oldabovenq = 0;
+ setfreq_and_q(Ffreq, Fq);
+ firsttime = 1;
+ d[0] = 0; //this is not used
+ outgain = 1.0;
+}
AnalogFilter::~AnalogFilter()
-{
-};
+{}
void AnalogFilter::cleanup()
{
- for (int i=0;ifreq;
- if (freq>(SAMPLE_RATE/2-500.0)) {
- freq=SAMPLE_RATE/2-500.0;
- zerocoefs=1;
- };
- if (freq<0.1) freq=0.1;
+ REALTYPE freq = this->freq;
+ if(freq > (SAMPLE_RATE / 2 - 500.0)) {
+ freq = SAMPLE_RATE / 2 - 500.0;
+ zerocoefs = 1;
+ }
+ if(freq < 0.1)
+ freq = 0.1;
//do not allow bogus Q
- if (q<0.0) q=0.0;
- REALTYPE tmpq,tmpgain;
- if (stages==0) {
- tmpq=q;
- tmpgain=gain;
- } else {
- tmpq=(q>1.0 ? pow(q,1.0/(stages+1)) : q);
- tmpgain=pow(gain,1.0/(stages+1));
- };
+ if(q < 0.0)
+ q = 0.0;
+ REALTYPE tmpq, tmpgain;
+ if(stages == 0) {
+ tmpq = q;
+ tmpgain = gain;
+ }
+ else {
+ tmpq = (q > 1.0 ? pow(q, 1.0 / (stages + 1)) : q);
+ tmpgain = pow(gain, 1.0 / (stages + 1));
+ }
//most of theese are implementations of
//the "Cookbook formulae for audio EQ" by Robert Bristow-Johnson
//The original location of the Cookbook is:
//http://www.harmony-central.com/Computer/Programming/Audio-EQ-Cookbook.txt
- switch (type) {
- case 0://LPF 1 pole
- if (zerocoefs==0) tmp=exp(-2.0*PI*freq/SAMPLE_RATE);
- else tmp=0.0;
- c[0]=1.0-tmp;
- c[1]=0.0;
- c[2]=0.0;
- d[1]=tmp;
- d[2]=0.0;
- order=1;
+ switch(type) {
+ case 0: //LPF 1 pole
+ if(zerocoefs == 0)
+ tmp = exp(-2.0 * PI * freq / SAMPLE_RATE);
+ else
+ tmp = 0.0;
+ c[0] = 1.0 - tmp;
+ c[1] = 0.0;
+ c[2] = 0.0;
+ d[1] = tmp;
+ d[2] = 0.0;
+ order = 1;
break;
- case 1://HPF 1 pole
- if (zerocoefs==0) tmp=exp(-2.0*PI*freq/SAMPLE_RATE);
- else tmp=0.0;
- c[0]=(1.0+tmp)/2.0;
- c[1]=-(1.0+tmp)/2.0;
- c[2]=0.0;
- d[1]=tmp;
- d[2]=0.0;
- order=1;
+ case 1: //HPF 1 pole
+ if(zerocoefs == 0)
+ tmp = exp(-2.0 * PI * freq / SAMPLE_RATE);
+ else
+ tmp = 0.0;
+ c[0] = (1.0 + tmp) / 2.0;
+ c[1] = -(1.0 + tmp) / 2.0;
+ c[2] = 0.0;
+ d[1] = tmp;
+ d[2] = 0.0;
+ order = 1;
break;
- case 2://LPF 2 poles
- if (zerocoefs==0) {
- omega=2*PI*freq/SAMPLE_RATE;
- sn=sin(omega);
- cs=cos(omega);
- alpha=sn/(2*tmpq);
- tmp=1+alpha;
- c[0]=(1.0-cs)/2.0/tmp;
- c[1]=(1.0-cs)/tmp;
- c[2]=(1.0-cs)/2.0/tmp;
- d[1]=-2*cs/tmp*(-1);
- d[2]=(1-alpha)/tmp*(-1);
- } else {
- c[0]=1.0;
- c[1]=0.0;
- c[2]=0.0;
- d[1]=0.0;
- d[2]=0.0;
- };
- order=2;
+ case 2: //LPF 2 poles
+ if(zerocoefs == 0) {
+ omega = 2 * PI * freq / SAMPLE_RATE;
+ sn = sin(omega);
+ cs = cos(omega);
+ alpha = sn / (2 * tmpq);
+ tmp = 1 + alpha;
+ c[0] = (1.0 - cs) / 2.0 / tmp;
+ c[1] = (1.0 - cs) / tmp;
+ c[2] = (1.0 - cs) / 2.0 / tmp;
+ d[1] = -2 * cs / tmp * (-1);
+ d[2] = (1 - alpha) / tmp * (-1);
+ }
+ else {
+ c[0] = 1.0;
+ c[1] = 0.0;
+ c[2] = 0.0;
+ d[1] = 0.0;
+ d[2] = 0.0;
+ }
+ order = 2;
break;
- case 3://HPF 2 poles
- if (zerocoefs==0) {
- omega=2*PI*freq/SAMPLE_RATE;
- sn=sin(omega);
- cs=cos(omega);
- alpha=sn/(2*tmpq);
- tmp=1+alpha;
- c[0]=(1.0+cs)/2.0/tmp;
- c[1]=-(1.0+cs)/tmp;
- c[2]=(1.0+cs)/2.0/tmp;
- d[1]=-2*cs/tmp*(-1);
- d[2]=(1-alpha)/tmp*(-1);
- } else {
- c[0]=0.0;
- c[1]=0.0;
- c[2]=0.0;
- d[1]=0.0;
- d[2]=0.0;
- };
- order=2;
+ case 3: //HPF 2 poles
+ if(zerocoefs == 0) {
+ omega = 2 * PI * freq / SAMPLE_RATE;
+ sn = sin(omega);
+ cs = cos(omega);
+ alpha = sn / (2 * tmpq);
+ tmp = 1 + alpha;
+ c[0] = (1.0 + cs) / 2.0 / tmp;
+ c[1] = -(1.0 + cs) / tmp;
+ c[2] = (1.0 + cs) / 2.0 / tmp;
+ d[1] = -2 * cs / tmp * (-1);
+ d[2] = (1 - alpha) / tmp * (-1);
+ }
+ else {
+ c[0] = 0.0;
+ c[1] = 0.0;
+ c[2] = 0.0;
+ d[1] = 0.0;
+ d[2] = 0.0;
+ }
+ order = 2;
break;
- case 4://BPF 2 poles
- if (zerocoefs==0) {
- omega=2*PI*freq/SAMPLE_RATE;
- sn=sin(omega);
- cs=cos(omega);
- alpha=sn/(2*tmpq);
- tmp=1+alpha;
- c[0]=alpha/tmp*sqrt(tmpq+1);
- c[1]=0;
- c[2]=-alpha/tmp*sqrt(tmpq+1);
- d[1]=-2*cs/tmp*(-1);
- d[2]=(1-alpha)/tmp*(-1);
- } else {
- c[0]=0.0;
- c[1]=0.0;
- c[2]=0.0;
- d[1]=0.0;
- d[2]=0.0;
- };
- order=2;
+ case 4: //BPF 2 poles
+ if(zerocoefs == 0) {
+ omega = 2 * PI * freq / SAMPLE_RATE;
+ sn = sin(omega);
+ cs = cos(omega);
+ alpha = sn / (2 * tmpq);
+ tmp = 1 + alpha;
+ c[0] = alpha / tmp *sqrt(tmpq + 1);
+ c[1] = 0;
+ c[2] = -alpha / tmp *sqrt(tmpq + 1);
+ d[1] = -2 * cs / tmp * (-1);
+ d[2] = (1 - alpha) / tmp * (-1);
+ }
+ else {
+ c[0] = 0.0;
+ c[1] = 0.0;
+ c[2] = 0.0;
+ d[1] = 0.0;
+ d[2] = 0.0;
+ }
+ order = 2;
break;
- case 5://NOTCH 2 poles
- if (zerocoefs==0) {
- omega=2*PI*freq/SAMPLE_RATE;
- sn=sin(omega);
- cs=cos(omega);
- alpha=sn/(2*sqrt(tmpq));
- tmp=1+alpha;
- c[0]=1/tmp;
- c[1]=-2*cs/tmp;
- c[2]=1/tmp;
- d[1]=-2*cs/tmp*(-1);
- d[2]=(1-alpha)/tmp*(-1);
- } else {
- c[0]=1.0;
- c[1]=0.0;
- c[2]=0.0;
- d[1]=0.0;
- d[2]=0.0;
- };
- order=2;
+ case 5: //NOTCH 2 poles
+ if(zerocoefs == 0) {
+ omega = 2 * PI * freq / SAMPLE_RATE;
+ sn = sin(omega);
+ cs = cos(omega);
+ alpha = sn / (2 * sqrt(tmpq));
+ tmp = 1 + alpha;
+ c[0] = 1 / tmp;
+ c[1] = -2 * cs / tmp;
+ c[2] = 1 / tmp;
+ d[1] = -2 * cs / tmp * (-1);
+ d[2] = (1 - alpha) / tmp * (-1);
+ }
+ else {
+ c[0] = 1.0;
+ c[1] = 0.0;
+ c[2] = 0.0;
+ d[1] = 0.0;
+ d[2] = 0.0;
+ }
+ order = 2;
break;
- case 6://PEAK (2 poles)
- if (zerocoefs==0) {
- omega=2*PI*freq/SAMPLE_RATE;
- sn=sin(omega);
- cs=cos(omega);
- tmpq*=3.0;
- alpha=sn/(2*tmpq);
- tmp=1+alpha/tmpgain;
- c[0]=(1.0+alpha*tmpgain)/tmp;
- c[1]=(-2.0*cs)/tmp;
- c[2]=(1.0-alpha*tmpgain)/tmp;
- d[1]=-2*cs/tmp*(-1);
- d[2]=(1-alpha/tmpgain)/tmp*(-1);
- } else {
- c[0]=1.0;
- c[1]=0.0;
- c[2]=0.0;
- d[1]=0.0;
- d[2]=0.0;
- };
- order=2;
+ case 6: //PEAK (2 poles)
+ if(zerocoefs == 0) {
+ omega = 2 * PI * freq / SAMPLE_RATE;
+ sn = sin(omega);
+ cs = cos(omega);
+ tmpq *= 3.0;
+ alpha = sn / (2 * tmpq);
+ tmp = 1 + alpha / tmpgain;
+ c[0] = (1.0 + alpha * tmpgain) / tmp;
+ c[1] = (-2.0 * cs) / tmp;
+ c[2] = (1.0 - alpha * tmpgain) / tmp;
+ d[1] = -2 * cs / tmp * (-1);
+ d[2] = (1 - alpha / tmpgain) / tmp * (-1);
+ }
+ else {
+ c[0] = 1.0;
+ c[1] = 0.0;
+ c[2] = 0.0;
+ d[1] = 0.0;
+ d[2] = 0.0;
+ }
+ order = 2;
break;
- case 7://Low Shelf - 2 poles
- if (zerocoefs==0) {
- omega=2*PI*freq/SAMPLE_RATE;
- sn=sin(omega);
- cs=cos(omega);
- tmpq=sqrt(tmpq);
- alpha=sn/(2*tmpq);
- beta=sqrt(tmpgain)/tmpq;
- tmp=(tmpgain+1.0)+(tmpgain-1.0)*cs+beta*sn;
+ case 7: //Low Shelf - 2 poles
+ if(zerocoefs == 0) {
+ omega = 2 * PI * freq / SAMPLE_RATE;
+ sn = sin(omega);
+ cs = cos(omega);
+ tmpq = sqrt(tmpq);
+ alpha = sn / (2 * tmpq);
+ beta = sqrt(tmpgain) / tmpq;
+ tmp = (tmpgain + 1.0) + (tmpgain - 1.0) * cs + beta * sn;
- c[0]=tmpgain*((tmpgain+1.0)-(tmpgain-1.0)*cs+beta*sn)/tmp;
- c[1]=2.0*tmpgain*((tmpgain-1.0)-(tmpgain+1.0)*cs)/tmp;
- c[2]=tmpgain*((tmpgain+1.0)-(tmpgain-1.0)*cs-beta*sn)/tmp;
- d[1]=-2.0*((tmpgain-1.0)+(tmpgain+1.0)*cs)/tmp*(-1);
- d[2]=((tmpgain+1.0)+(tmpgain-1.0)*cs-beta*sn)/tmp*(-1);
- } else {
- c[0]=tmpgain;
- c[1]=0.0;
- c[2]=0.0;
- d[1]=0.0;
- d[2]=0.0;
- };
- order=2;
+ c[0] = tmpgain
+ * ((tmpgain
+ + 1.0) - (tmpgain - 1.0) * cs + beta * sn) / tmp;
+ c[1] = 2.0 * tmpgain
+ * ((tmpgain - 1.0) - (tmpgain + 1.0) * cs) / tmp;
+ c[2] = tmpgain
+ * ((tmpgain
+ + 1.0) - (tmpgain - 1.0) * cs - beta * sn) / tmp;
+ d[1] = -2.0 * ((tmpgain - 1.0) + (tmpgain + 1.0) * cs) / tmp * (-1);
+ d[2] =
+ ((tmpgain
+ + 1.0) + (tmpgain - 1.0) * cs - beta * sn) / tmp * (-1);
+ }
+ else {
+ c[0] = tmpgain;
+ c[1] = 0.0;
+ c[2] = 0.0;
+ d[1] = 0.0;
+ d[2] = 0.0;
+ }
+ order = 2;
break;
- case 8://High Shelf - 2 poles
- if (zerocoefs==0) {
- omega=2*PI*freq/SAMPLE_RATE;
- sn=sin(omega);
- cs=cos(omega);
- tmpq=sqrt(tmpq);
- alpha=sn/(2*tmpq);
- beta=sqrt(tmpgain)/tmpq;
- tmp=(tmpgain+1.0)-(tmpgain-1.0)*cs+beta*sn;
+ case 8: //High Shelf - 2 poles
+ if(zerocoefs == 0) {
+ omega = 2 * PI * freq / SAMPLE_RATE;
+ sn = sin(omega);
+ cs = cos(omega);
+ tmpq = sqrt(tmpq);
+ alpha = sn / (2 * tmpq);
+ beta = sqrt(tmpgain) / tmpq;
+ tmp = (tmpgain + 1.0) - (tmpgain - 1.0) * cs + beta * sn;
- c[0]=tmpgain*((tmpgain+1.0)+(tmpgain-1.0)*cs+beta*sn)/tmp;
- c[1]=-2.0*tmpgain*((tmpgain-1.0)+(tmpgain+1.0)*cs)/tmp;
- c[2]=tmpgain*((tmpgain+1.0)+(tmpgain-1.0)*cs-beta*sn)/tmp;
- d[1]=2.0*((tmpgain-1.0)-(tmpgain+1.0)*cs)/tmp*(-1);
- d[2]=((tmpgain+1.0)-(tmpgain-1.0)*cs-beta*sn)/tmp*(-1);
- } else {
- c[0]=1.0;
- c[1]=0.0;
- c[2]=0.0;
- d[1]=0.0;
- d[2]=0.0;
- };
- order=2;
+ c[0] = tmpgain
+ * ((tmpgain
+ + 1.0) + (tmpgain - 1.0) * cs + beta * sn) / tmp;
+ c[1] = -2.0 * tmpgain
+ * ((tmpgain - 1.0) + (tmpgain + 1.0) * cs) / tmp;
+ c[2] = tmpgain
+ * ((tmpgain
+ + 1.0) + (tmpgain - 1.0) * cs - beta * sn) / tmp;
+ d[1] = 2.0 * ((tmpgain - 1.0) - (tmpgain + 1.0) * cs) / tmp * (-1);
+ d[2] =
+ ((tmpgain
+ + 1.0) - (tmpgain - 1.0) * cs - beta * sn) / tmp * (-1);
+ }
+ else {
+ c[0] = 1.0;
+ c[1] = 0.0;
+ c[2] = 0.0;
+ d[1] = 0.0;
+ d[2] = 0.0;
+ }
+ order = 2;
break;
- default://wrong type
- type=0;
+ default: //wrong type
+ type = 0;
computefiltercoefs();
break;
- };
-};
+ }
+}
void AnalogFilter::setfreq(REALTYPE frequency)
{
- if (frequency<0.1) frequency=0.1;
- REALTYPE rap=freq/frequency;
- if (rap<1.0) rap=1.0/rap;
+ if(frequency < 0.1)
+ frequency = 0.1;
+ REALTYPE rap = freq / frequency;
+ if(rap < 1.0)
+ rap = 1.0 / rap;
- oldabovenq=abovenq;
- abovenq=frequency>(SAMPLE_RATE/2-500.0);
+ oldabovenq = abovenq;
+ abovenq = frequency > (SAMPLE_RATE / 2 - 500.0);
- int nyquistthresh=(abovenq^oldabovenq);
+ int nyquistthresh = (abovenq ^ oldabovenq);
- if ((rap>3.0)||(nyquistthresh!=0)) {//if the frequency is changed fast, it needs interpolation (now, filter and coeficients backup)
- for (int i=0;i<3;i++) {
- oldc[i]=c[i];
- oldd[i]=d[i];
- };
- for (int i=0;i 3.0) || (nyquistthresh != 0)) { //if the frequency is changed fast, it needs interpolation (now, filter and coeficients backup)
+ for(int i = 0; i < 3; i++) {
+ oldc[i] = c[i];
+ oldd[i] = d[i];
+ }
+ for(int i = 0; i < MAX_FILTER_STAGES + 1; i++) {
+ oldx[i] = x[i];
+ oldy[i] = y[i];
+ }
+ if(firsttime == 0)
+ needsinterpolation = 1;
+ }
+ freq = frequency;
computefiltercoefs();
- firsttime=0;
+ firsttime = 0;
+}
-};
-
-void AnalogFilter::setfreq_and_q(REALTYPE frequency,REALTYPE q_)
+void AnalogFilter::setfreq_and_q(REALTYPE frequency, REALTYPE q_)
{
- q=q_;
+ q = q_;
setfreq(frequency);
-};
+}
void AnalogFilter::setq(REALTYPE q_)
{
- q=q_;
+ q = q_;
computefiltercoefs();
-};
+}
void AnalogFilter::settype(int type_)
{
- type=type_;
+ type = type_;
computefiltercoefs();
-};
+}
void AnalogFilter::setgain(REALTYPE dBgain)
{
- gain=dB2rap(dBgain);
+ gain = dB2rap(dBgain);
computefiltercoefs();
-};
+}
void AnalogFilter::setstages(int stages_)
{
- if (stages_>=MAX_FILTER_STAGES) stages_=MAX_FILTER_STAGES-1;
- stages=stages_;
+ if(stages_ >= MAX_FILTER_STAGES)
+ stages_ = MAX_FILTER_STAGES - 1;
+ stages = stages_;
cleanup();
computefiltercoefs();
-};
+}
-void AnalogFilter::singlefilterout(REALTYPE *smp,fstage &x,fstage &y,REALTYPE *c,REALTYPE *d)
+void AnalogFilter::singlefilterout(REALTYPE *smp,
+ fstage &x,
+ fstage &y,
+ REALTYPE *c,
+ REALTYPE *d)
{
- int i;
+ int i;
REALTYPE y0;
- if (order==1) {//First order filter
- for (i=0;i1,1->2,etc.)
- REALTYPE freq;//Frequency given in Hz
- REALTYPE q; //Q factor (resonance or Q factor)
- REALTYPE gain;//the gain of the filter (if are shelf/peak) filters
+ void singlefilterout(REALTYPE *smp,
+ fstage &x,
+ fstage &y,
+ REALTYPE *c,
+ REALTYPE *d);
+ void computefiltercoefs();
+ int type; //The type of the filter (LPF1,HPF1,LPF2,HPF2...)
+ int stages; //how many times the filter is applied (0->1,1->2,etc.)
+ REALTYPE freq; //Frequency given in Hz
+ REALTYPE q; //Q factor (resonance or Q factor)
+ REALTYPE gain; //the gain of the filter (if are shelf/peak) filters
- int order;//the order of the filter (number of poles)
+ int order; //the order of the filter (number of poles)
- REALTYPE c[3],d[3];//coefficients
+ REALTYPE c[3], d[3]; //coefficients
- REALTYPE oldc[3],oldd[3];//old coefficients(used only if some filter paremeters changes very fast, and it needs interpolation)
+ REALTYPE oldc[3], oldd[3]; //old coefficients(used only if some filter paremeters changes very fast, and it needs interpolation)
- REALTYPE xd[3],yd[3];//used if the filter is applied more times
- int needsinterpolation,firsttime;/**\todo see if bool works for these*/
- int abovenq;//this is 1 if the frequency is above the nyquist
- int oldabovenq;//if the last time was above nyquist (used to see if it needs interpolation)
+ REALTYPE xd[3], yd[3]; //used if the filter is applied more times
+ int needsinterpolation, firsttime; /**\todo see if bool works for these*/
+ int abovenq; //this is 1 if the frequency is above the nyquist
+ int oldabovenq; //if the last time was above nyquist (used to see if it needs interpolation)
};
diff --git a/plugins/zynaddsubfx/src/DSP/CMakeLists.txt b/plugins/zynaddsubfx/src/DSP/CMakeLists.txt
index 8169235e0..c13cd316c 100644
--- a/plugins/zynaddsubfx/src/DSP/CMakeLists.txt
+++ b/plugins/zynaddsubfx/src/DSP/CMakeLists.txt
@@ -4,6 +4,7 @@ set(zynaddsubfx_dsp_SRCS
Filter.cpp
FormantFilter.cpp
SVFilter.cpp
+ Unison.cpp
)
add_library(zynaddsubfx_dsp STATIC
diff --git a/plugins/zynaddsubfx/src/DSP/FFTwrapper.cpp b/plugins/zynaddsubfx/src/DSP/FFTwrapper.cpp
index 7e18ae534..d93c0c40c 100644
--- a/plugins/zynaddsubfx/src/DSP/FFTwrapper.cpp
+++ b/plugins/zynaddsubfx/src/DSP/FFTwrapper.cpp
@@ -25,17 +25,29 @@
FFTwrapper::FFTwrapper(int fftsize_)
{
- fftsize=fftsize_;
- tmpfftdata1=new fftw_real[fftsize];
- tmpfftdata2=new fftw_real[fftsize];
+ fftsize = fftsize_;
+ tmpfftdata1 = new fftw_real[fftsize];
+ tmpfftdata2 = new fftw_real[fftsize];
#ifdef FFTW_VERSION_2
- planfftw=rfftw_create_plan(fftsize,FFTW_REAL_TO_COMPLEX,FFTW_ESTIMATE|FFTW_IN_PLACE);
- planfftw_inv=rfftw_create_plan(fftsize,FFTW_COMPLEX_TO_REAL,FFTW_ESTIMATE|FFTW_IN_PLACE);
+ planfftw = rfftw_create_plan(fftsize,
+ FFTW_REAL_TO_COMPLEX,
+ FFTW_ESTIMATE | FFTW_IN_PLACE);
+ planfftw_inv = rfftw_create_plan(fftsize,
+ FFTW_COMPLEX_TO_REAL,
+ FFTW_ESTIMATE | FFTW_IN_PLACE);
#else
- planfftw=fftwf_plan_r2r_1d(fftsize,tmpfftdata1,tmpfftdata1,FFTW_R2HC,FFTW_ESTIMATE);
- planfftw_inv=fftwf_plan_r2r_1d(fftsize,tmpfftdata2,tmpfftdata2,FFTW_HC2R,FFTW_ESTIMATE);
+ planfftw = fftwf_plan_r2r_1d(fftsize,
+ tmpfftdata1,
+ tmpfftdata1,
+ FFTW_R2HC,
+ FFTW_ESTIMATE);
+ planfftw_inv = fftwf_plan_r2r_1d(fftsize,
+ tmpfftdata2,
+ tmpfftdata2,
+ FFTW_HC2R,
+ FFTW_ESTIMATE);
#endif
-};
+}
FFTwrapper::~FFTwrapper()
{
@@ -49,52 +61,76 @@ FFTwrapper::~FFTwrapper()
delete [] tmpfftdata1;
delete [] tmpfftdata2;
-};
+}
/*
* do the Fast Fourier Transform
*/
-void FFTwrapper::smps2freqs(REALTYPE *smps,FFTFREQS freqs)
+void FFTwrapper::smps2freqs(REALTYPE *smps, FFTFREQS freqs)
{
#ifdef FFTW_VERSION_2
- for (int i=0;ic = new REALTYPE[size];
+ f->s = new REALTYPE[size];
+ for(int i = 0; i < size; i++) {
+ f->c[i] = 0.0;
+ f->s[i] = 0.0;
+ }
+}
+
+void deleteFFTFREQS(FFTFREQS *f)
+{
+ delete[] f->c;
+ delete[] f->s;
+ f->c = f->s = NULL;
+}
diff --git a/plugins/zynaddsubfx/src/DSP/FFTwrapper.h b/plugins/zynaddsubfx/src/DSP/FFTwrapper.h
index f2915f490..17d40805a 100644
--- a/plugins/zynaddsubfx/src/DSP/FFTwrapper.h
+++ b/plugins/zynaddsubfx/src/DSP/FFTwrapper.h
@@ -47,21 +47,24 @@ Hope all goes right." */
/**A wrapper for the FFTW library (Fast Fourier Transforms)*/
class FFTwrapper
{
-public:
- /**Constructor
- * @param fftsize The size of samples to be fed to fftw*/
- FFTwrapper(int fftsize_);
- /**Destructor*/
- ~FFTwrapper();
- /**Convert Samples to Frequencies using Fourier Transform
- * @param smps Pointer to Samples to be converted; has length fftsize_
- * @param freqs Structure FFTFREQS which stores the frequencies*/
- void smps2freqs(REALTYPE *smps,FFTFREQS freqs);
- void freqs2smps(FFTFREQS freqs,REALTYPE *smps);
-private:
- int fftsize;
- fftw_real *tmpfftdata1,*tmpfftdata2;
- rfftw_plan planfftw,planfftw_inv;
+ public:
+ /**Constructor
+ * @param fftsize The size of samples to be fed to fftw*/
+ FFTwrapper(int fftsize_);
+ /**Destructor*/
+ ~FFTwrapper();
+ /**Convert Samples to Frequencies using Fourier Transform
+ * @param smps Pointer to Samples to be converted; has length fftsize_
+ * @param freqs Structure FFTFREQS which stores the frequencies*/
+ void smps2freqs(REALTYPE *smps, FFTFREQS freqs);
+ void freqs2smps(FFTFREQS freqs, REALTYPE *smps);
+ private:
+ int fftsize;
+ fftw_real *tmpfftdata1, *tmpfftdata2;
+ rfftw_plan planfftw, planfftw_inv;
};
+
+void newFFTFREQS(FFTFREQS *f, int size);
+void deleteFFTFREQS(FFTFREQS *f);
#endif
diff --git a/plugins/zynaddsubfx/src/DSP/Filter.cpp b/plugins/zynaddsubfx/src/DSP/Filter.cpp
index f94a34214..d95abe448 100644
--- a/plugins/zynaddsubfx/src/DSP/Filter.cpp
+++ b/plugins/zynaddsubfx/src/DSP/Filter.cpp
@@ -27,56 +27,61 @@
Filter::Filter(FilterParams *pars)
{
- unsigned char Ftype=pars->Ptype;
- unsigned char Fstages=pars->Pstages;
+ unsigned char Ftype = pars->Ptype;
+ unsigned char Fstages = pars->Pstages;
- category=pars->Pcategory;
+ category = pars->Pcategory;
- switch (category) {
+ switch(category) {
case 1:
- filter=new FormantFilter(pars);
+ filter = new FormantFilter(pars);
break;
case 2:
- filter=new SVFilter(Ftype,1000.0,pars->getq(),Fstages);
- filter->outgain=dB2rap(pars->getgain());
- if (filter->outgain>1.0) filter->outgain=sqrt(filter->outgain);
+ filter = new SVFilter(Ftype, 1000.0, pars->getq(), Fstages);
+ filter->outgain = dB2rap(pars->getgain());
+ if(filter->outgain > 1.0)
+ filter->outgain = sqrt(filter->outgain);
break;
default:
- filter=new AnalogFilter(Ftype,1000.0,pars->getq(),Fstages);
- if ((Ftype>=6)&&(Ftype<=8)) filter->setgain(pars->getgain());
- else filter->outgain=dB2rap(pars->getgain());
+ filter = new AnalogFilter(Ftype, 1000.0, pars->getq(), Fstages);
+ if((Ftype >= 6) && (Ftype <= 8))
+ filter->setgain(pars->getgain());
+ else
+ filter->outgain = dB2rap(pars->getgain());
break;
- };
-};
+ }
+}
Filter::~Filter()
{
delete (filter);
-};
+}
void Filter::filterout(REALTYPE *smp)
{
filter->filterout(smp);
-};
+}
void Filter::setfreq(REALTYPE frequency)
{
filter->setfreq(frequency);
-};
+}
-void Filter::setfreq_and_q(REALTYPE frequency,REALTYPE q_)
+void Filter::setfreq_and_q(REALTYPE frequency, REALTYPE q_)
{
- filter->setfreq_and_q(frequency,q_);
-};
+ filter->setfreq_and_q(frequency, q_);
+}
void Filter::setq(REALTYPE q_)
{
filter->setq(q_);
-};
+}
REALTYPE Filter::getrealfreq(REALTYPE freqpitch)
{
- if ((category==0)||(category==2)) return(pow(2.0,freqpitch+9.96578428));//log2(1000)=9.95748
- else return(freqpitch);
-};
+ if((category == 0) || (category == 2))
+ return pow(2.0, freqpitch + 9.96578428); //log2(1000)=9.95748
+ else
+ return freqpitch;
+}
diff --git a/plugins/zynaddsubfx/src/DSP/Filter.h b/plugins/zynaddsubfx/src/DSP/Filter.h
index 42bef55ce..b8f568b21 100644
--- a/plugins/zynaddsubfx/src/DSP/Filter.h
+++ b/plugins/zynaddsubfx/src/DSP/Filter.h
@@ -33,18 +33,18 @@
class Filter
{
-public:
- Filter(FilterParams *pars);
- ~Filter();
- void filterout(REALTYPE *smp);
- void setfreq(REALTYPE frequency);
- void setfreq_and_q(REALTYPE frequency,REALTYPE q_);
- void setq(REALTYPE q_);
+ public:
+ Filter(FilterParams *pars);
+ ~Filter();
+ void filterout(REALTYPE *smp);
+ void setfreq(REALTYPE frequency);
+ void setfreq_and_q(REALTYPE frequency, REALTYPE q_);
+ void setq(REALTYPE q_);
- REALTYPE getrealfreq(REALTYPE freqpitch);
-private:
- Filter_ *filter;
- unsigned char category;
+ REALTYPE getrealfreq(REALTYPE freqpitch);
+ private:
+ Filter_ *filter;
+ unsigned char category;
};
diff --git a/plugins/zynaddsubfx/src/DSP/Filter_.h b/plugins/zynaddsubfx/src/DSP/Filter_.h
index b3f2badc1..b577193f3 100644
--- a/plugins/zynaddsubfx/src/DSP/Filter_.h
+++ b/plugins/zynaddsubfx/src/DSP/Filter_.h
@@ -27,15 +27,15 @@
class Filter_
{
-public:
- virtual ~Filter_() {};
- virtual void filterout(REALTYPE *smp)=0;
- virtual void setfreq(REALTYPE frequency)=0;
- virtual void setfreq_and_q(REALTYPE frequency,REALTYPE q_)=0;
- virtual void setq(REALTYPE q_)=0;
- virtual void setgain(REALTYPE dBgain) {};
- REALTYPE outgain;
-private:
+ public:
+ virtual ~Filter_() {}
+ virtual void filterout(REALTYPE *smp) = 0;
+ virtual void setfreq(REALTYPE frequency) = 0;
+ virtual void setfreq_and_q(REALTYPE frequency, REALTYPE q_) = 0;
+ virtual void setq(REALTYPE q_) = 0;
+ virtual void setgain(REALTYPE dBgain) {}
+ REALTYPE outgain;
+ private:
};
diff --git a/plugins/zynaddsubfx/src/DSP/FormantFilter.cpp b/plugins/zynaddsubfx/src/DSP/FormantFilter.cpp
index 297285648..39c1002d9 100644
--- a/plugins/zynaddsubfx/src/DSP/FormantFilter.cpp
+++ b/plugins/zynaddsubfx/src/DSP/FormantFilter.cpp
@@ -26,151 +26,202 @@
FormantFilter::FormantFilter(FilterParams *pars)
{
- numformants=pars->Pnumformants;
- for (int i=0;iPstages);
+ numformants = pars->Pnumformants;
+ for(int i = 0; i < numformants; i++)
+ formant[i] = new AnalogFilter(4 /*BPF*/, 1000.0, 10.0, pars->Pstages);
cleanup();
- inbuffer=new REALTYPE [SOUND_BUFFER_SIZE];
- tmpbuf=new REALTYPE [SOUND_BUFFER_SIZE];
+ inbuffer = new REALTYPE [SOUND_BUFFER_SIZE];
+ tmpbuf = new REALTYPE [SOUND_BUFFER_SIZE];
- for (int j=0;jgetformantfreq(pars->Pvowels[j].formants[i].freq);
- formantpar[j][i].amp=pars->getformantamp(pars->Pvowels[j].formants[i].amp);
- formantpar[j][i].q=pars->getformantq(pars->Pvowels[j].formants[i].q);
- };
- for (int i=0;igetformantfreq(
+ pars->Pvowels[j].formants[i].freq);
+ formantpar[j][i].amp = pars->getformantamp(
+ pars->Pvowels[j].formants[i].amp);
+ formantpar[j][i].q = pars->getformantq(
+ pars->Pvowels[j].formants[i].q);
+ }
+ ;
+ for(int i = 0; i < FF_MAX_FORMANTS; i++)
+ oldformantamp[i] = 1.0;
+ for(int i = 0; i < numformants; i++) {
+ currentformants[i].freq = 1000.0;
+ currentformants[i].amp = 1.0;
+ currentformants[i].q = 2.0;
+ }
- formantslowness=pow(1.0-(pars->Pformantslowness/128.0),3.0);
+ formantslowness = pow(1.0 - (pars->Pformantslowness / 128.0), 3.0);
- sequencesize=pars->Psequencesize;
- if (sequencesize==0) sequencesize=1;
- for (int k=0;kPsequence[k].nvowel;
+ sequencesize = pars->Psequencesize;
+ if(sequencesize == 0)
+ sequencesize = 1;
+ for(int k = 0; k < sequencesize; k++)
+ sequence[k].nvowel = pars->Psequence[k].nvowel;
- vowelclearness=pow(10.0,(pars->Pvowelclearness-32.0)/48.0);
+ vowelclearness = pow(10.0, (pars->Pvowelclearness - 32.0) / 48.0);
- sequencestretch=pow(0.1,(pars->Psequencestretch-32.0)/48.0);
- if (pars->Psequencereversed) sequencestretch*= -1.0;
+ sequencestretch = pow(0.1, (pars->Psequencestretch - 32.0) / 48.0);
+ if(pars->Psequencereversed)
+ sequencestretch *= -1.0;
- outgain=dB2rap(pars->getgain());
+ outgain = dB2rap(pars->getgain());
- oldinput=-1.0;
- Qfactor=1.0;
- oldQfactor=Qfactor;
- firsttime=1;
-};
+ oldinput = -1.0;
+ Qfactor = 1.0;
+ oldQfactor = Qfactor;
+ firsttime = 1;
+}
FormantFilter::~FormantFilter()
{
- for (int i=0;icleanup();
-};
+ for(int i = 0; i < numformants; i++)
+ formant[i]->cleanup();
+}
void FormantFilter::setpos(REALTYPE input)
{
- int p1,p2;
+ int p1, p2;
- if (firsttime!=0) slowinput=input;
- else slowinput=slowinput*(1.0-formantslowness)+input*formantslowness;
+ if(firsttime != 0)
+ slowinput = input;
+ else
+ slowinput = slowinput
+ * (1.0 - formantslowness) + input * formantslowness;
- if ((fabs(oldinput-input)<0.001)&&(fabs(slowinput-input)<0.001)&&
- (fabs(Qfactor-oldQfactor)<0.001)) {
+ if((fabs(oldinput - input) < 0.001) && (fabs(slowinput - input) < 0.001)
+ && (fabs(Qfactor - oldQfactor) < 0.001)) {
// oldinput=input; daca setez asta, o sa faca probleme la schimbari foarte lente
- firsttime=0;
+ firsttime = 0;
return;
- } else oldinput=input;
+ }
+ else
+ oldinput = input;
- REALTYPE pos=fmod(input*sequencestretch,1.0);
- if (pos<0.0) pos+=1.0;
+ REALTYPE pos = fmod(input * sequencestretch, 1.0);
+ if(pos < 0.0)
+ pos += 1.0;
- F2I(pos*sequencesize,p2);
- p1=p2-1;
- if (p1<0) p1+=sequencesize;
+ F2I(pos * sequencesize, p2);
+ p1 = p2 - 1;
+ if(p1 < 0)
+ p1 += sequencesize;
- pos=fmod(pos*sequencesize,1.0);
- if (pos<0.0) pos=0.0;
- else if (pos>1.0) pos=1.0;
- pos=(atan((pos*2.0-1.0)*vowelclearness)/atan(vowelclearness)+1.0)*0.5;
+ pos = fmod(pos * sequencesize, 1.0);
+ if(pos < 0.0)
+ pos = 0.0;
+ else
+ if(pos > 1.0)
+ pos = 1.0;
+ pos =
+ (atan((pos * 2.0
+ - 1.0) * vowelclearness) / atan(vowelclearness) + 1.0) * 0.5;
- p1=sequence[p1].nvowel;
- p2=sequence[p2].nvowel;
+ p1 = sequence[p1].nvowel;
+ p2 = sequence[p2].nvowel;
- if (firsttime!=0) {
- for (int i=0;isetfreq_and_q(currentformants[i].freq,currentformants[i].q*Qfactor);
- oldformantamp[i]=currentformants[i].amp;
- };
- firsttime=0;
- } else {
- for (int i=0;isetfreq_and_q(currentformants[i].freq,
+ currentformants[i].q * Qfactor);
+ oldformantamp[i] = currentformants[i].amp;
+ }
+ firsttime = 0;
+ }
+ else {
+ for(int i = 0; i < numformants; i++) {
+ currentformants[i].freq = currentformants[i].freq
+ * (1.0 - formantslowness)
+ + (formantpar[p1][i].freq
+ * (1.0
+ - pos) + formantpar[p2][i].freq
+ * pos) * formantslowness;
- currentformants[i].amp=currentformants[i].amp*(1.0-formantslowness)
- +(formantpar[p1][i].amp*(1.0-pos)+formantpar[p2][i].amp*pos)*formantslowness;
+ currentformants[i].amp = currentformants[i].amp
+ * (1.0 - formantslowness)
+ + (formantpar[p1][i].amp
+ * (1.0
+ - pos) + formantpar[p2][i].amp
+ * pos) * formantslowness;
- currentformants[i].q=currentformants[i].q*(1.0-formantslowness)
- +(formantpar[p1][i].q*(1.0-pos)+formantpar[p2][i].q*pos)*formantslowness;
+ currentformants[i].q = currentformants[i].q
+ * (1.0 - formantslowness)
+ + (formantpar[p1][i].q
+ * (1.0
+ - pos) + formantpar[p2][i].q
+ * pos) * formantslowness;
- formant[i]->setfreq_and_q(currentformants[i].freq,currentformants[i].q*Qfactor);
- };
- };
+ formant[i]->setfreq_and_q(currentformants[i].freq,
+ currentformants[i].q * Qfactor);
+ }
+ }
- oldQfactor=Qfactor;
-};
+ oldQfactor = Qfactor;
+}
void FormantFilter::setfreq(REALTYPE frequency)
{
setpos(frequency);
-};
+}
void FormantFilter::setq(REALTYPE q_)
{
- Qfactor=q_;
- for (int i=0;isetq(Qfactor*currentformants[i].q);
-};
+ Qfactor = q_;
+ for(int i = 0; i < numformants; i++)
+ formant[i]->setq(Qfactor * currentformants[i].q);
+}
-void FormantFilter::setfreq_and_q(REALTYPE frequency,REALTYPE q_)
+void FormantFilter::setfreq_and_q(REALTYPE frequency, REALTYPE q_)
{
- Qfactor=q_;
+ Qfactor = q_;
setpos(frequency);
-};
+}
void FormantFilter::filterout(REALTYPE *smp)
{
- int i,j;
- for (i=0;ifilterout(tmpbuf);
- if (ABOVE_AMPLITUDE_THRESHOLD(oldformantamp[j],currentformants[j].amp))
- for (i=0;i
#include "SVFilter.h"
-SVFilter::SVFilter(unsigned char Ftype,REALTYPE Ffreq, REALTYPE Fq,unsigned char Fstages)
+SVFilter::SVFilter(unsigned char Ftype,
+ REALTYPE Ffreq,
+ REALTYPE Fq,
+ unsigned char Fstages)
{
- stages=Fstages;
- type=Ftype;
- freq=Ffreq;
- q=Fq;
- gain=1.0;
- outgain=1.0;
- needsinterpolation=0;
- firsttime=1;
- if (stages>=MAX_FILTER_STAGES) stages=MAX_FILTER_STAGES;
+ stages = Fstages;
+ type = Ftype;
+ freq = Ffreq;
+ q = Fq;
+ gain = 1.0;
+ outgain = 1.0;
+ needsinterpolation = 0;
+ firsttime = 1;
+ if(stages >= MAX_FILTER_STAGES)
+ stages = MAX_FILTER_STAGES;
cleanup();
- setfreq_and_q(Ffreq,Fq);
-};
+ setfreq_and_q(Ffreq, Fq);
+}
SVFilter::~SVFilter()
-{
-};
+{}
void SVFilter::cleanup()
{
- for (int i=0;i0.99999) par.f=0.99999;
- par.q=1.0-atan(sqrt(q))*2.0/PI;
- par.q=pow(par.q,1.0/(stages+1));
- par.q_sqrt=sqrt(par.q);
-};
+ par.f = freq / SAMPLE_RATE * 4.0;
+ if(par.f > 0.99999)
+ par.f = 0.99999;
+ par.q = 1.0 - atan(sqrt(q)) * 2.0 / PI;
+ par.q = pow(par.q, 1.0 / (stages + 1));
+ par.q_sqrt = sqrt(par.q);
+}
void SVFilter::setfreq(REALTYPE frequency)
{
- if (frequency<0.1) frequency=0.1;
- REALTYPE rap=freq/frequency;
- if (rap<1.0) rap=1.0/rap;
+ if(frequency < 0.1)
+ frequency = 0.1;
+ REALTYPE rap = freq / frequency;
+ if(rap < 1.0)
+ rap = 1.0 / rap;
- oldabovenq=abovenq;
- abovenq=frequency>(SAMPLE_RATE/2-500.0);
+ oldabovenq = abovenq;
+ abovenq = frequency > (SAMPLE_RATE / 2 - 500.0);
- int nyquistthresh=(abovenq^oldabovenq);
+ int nyquistthresh = (abovenq ^ oldabovenq);
- if ((rap>3.0)||(nyquistthresh!=0)) {//if the frequency is changed fast, it needs interpolation (now, filter and coeficients backup)
- if (firsttime==0) needsinterpolation=1;
- ipar=par;
- };
- freq=frequency;
+ if((rap > 3.0) || (nyquistthresh != 0)) { //if the frequency is changed fast, it needs interpolation (now, filter and coeficients backup)
+ if(firsttime == 0)
+ needsinterpolation = 1;
+ ipar = par;
+ }
+ freq = frequency;
computefiltercoefs();
- firsttime=0;
+ firsttime = 0;
+}
-};
-
-void SVFilter::setfreq_and_q(REALTYPE frequency,REALTYPE q_)
+void SVFilter::setfreq_and_q(REALTYPE frequency, REALTYPE q_)
{
- q=q_;
+ q = q_;
setfreq(frequency);
-};
+}
void SVFilter::setq(REALTYPE q_)
{
- q=q_;
+ q = q_;
computefiltercoefs();
-};
+}
void SVFilter::settype(int type_)
{
- type=type_;
+ type = type_;
computefiltercoefs();
-};
+}
void SVFilter::setgain(REALTYPE dBgain)
{
- gain=dB2rap(dBgain);
+ gain = dB2rap(dBgain);
computefiltercoefs();
-};
+}
void SVFilter::setstages(int stages_)
{
- if (stages_>=MAX_FILTER_STAGES) stages_=MAX_FILTER_STAGES-1;
- stages=stages_;
+ if(stages_ >= MAX_FILTER_STAGES)
+ stages_ = MAX_FILTER_STAGES - 1;
+ stages = stages_;
cleanup();
computefiltercoefs();
-};
+}
-void SVFilter::singlefilterout(REALTYPE *smp,fstage &x,parameters &par)
+void SVFilter::singlefilterout(REALTYPE *smp, fstage &x, parameters &par)
{
int i;
- REALTYPE *out=NULL;
- switch (type) {
+ REALTYPE *out = NULL;
+ switch(type) {
case 0:
- out=&x.low;
+ out = &x.low;
break;
case 1:
- out=&x.high;
+ out = &x.high;
break;
case 2:
- out=&x.band;
+ out = &x.band;
break;
case 3:
- out=&x.notch;
+ out = &x.notch;
break;
- };
+ }
- for (i=0;i1,1->2,etc.)
- REALTYPE freq;//Frequency given in Hz
- REALTYPE q; //Q factor (resonance or Q factor)
- REALTYPE gain;//the gain of the filter (if are shelf/peak) filters
+ void singlefilterout(REALTYPE *smp, fstage &x, parameters &par);
+ void computefiltercoefs();
+ int type; //The type of the filter (LPF1,HPF1,LPF2,HPF2...)
+ int stages; //how many times the filter is applied (0->1,1->2,etc.)
+ REALTYPE freq; //Frequency given in Hz
+ REALTYPE q; //Q factor (resonance or Q factor)
+ REALTYPE gain; //the gain of the filter (if are shelf/peak) filters
- int abovenq;//this is 1 if the frequency is above the nyquist
- int oldabovenq;
- int needsinterpolation,firsttime;
+ int abovenq; //this is 1 if the frequency is above the nyquist
+ int oldabovenq;
+ int needsinterpolation, firsttime;
};
diff --git a/plugins/zynaddsubfx/src/DSP/Unison.cpp b/plugins/zynaddsubfx/src/DSP/Unison.cpp
new file mode 100644
index 000000000..031a868c3
--- /dev/null
+++ b/plugins/zynaddsubfx/src/DSP/Unison.cpp
@@ -0,0 +1,192 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ Unison.cpp - Unison effect (multivoice chorus)
+ Copyright (C) 2002-2009 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2 or later) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#include
+#include
+#include "Unison.h"
+
+Unison::Unison(int update_period_samples_, REALTYPE max_delay_sec_) {
+ update_period_samples = update_period_samples_;
+ max_delay = (int)(max_delay_sec_ * (REALTYPE)SAMPLE_RATE + 1);
+ if(max_delay < 10)
+ max_delay = 10;
+ delay_buffer = new REALTYPE[max_delay];
+ delay_k = 0;
+ base_freq = 1.0;
+ unison_bandwidth_cents = 10.0;
+
+ ZERO_REALTYPE(delay_buffer, max_delay);
+
+ uv = NULL;
+ update_period_sample_k = 0;
+ first_time = 0;
+
+ set_size(1);
+}
+
+Unison::~Unison() {
+ delete [] delay_buffer;
+ if(uv)
+ delete [] uv;
+}
+
+void Unison::set_size(int new_size) {
+ if(new_size < 1)
+ new_size = 1;
+ unison_size = new_size;
+ if(uv)
+ delete [] uv;
+ uv = new UnisonVoice[unison_size];
+ first_time = true;
+ update_parameters();
+}
+
+void Unison::set_base_frequency(REALTYPE freq) {
+ base_freq = freq;
+ update_parameters();
+}
+
+void Unison::set_bandwidth(REALTYPE bandwidth) {
+ if(bandwidth < 0)
+ bandwidth = 0.0;
+ if(bandwidth > 1200.0)
+ bandwidth = 1200.0;
+
+ printf("bandwidth %g\n", bandwidth);
+#warning \
+ : todo: if bandwidth is too small the audio will be self canceled (because of the sign change of the outputs)
+ unison_bandwidth_cents = bandwidth;
+ update_parameters();
+}
+
+void Unison::update_parameters() {
+ if(!uv)
+ return;
+ REALTYPE increments_per_second = SAMPLE_RATE
+ / (REALTYPE) update_period_samples;
+// printf("#%g, %g\n",increments_per_second,base_freq);
+ for(int i = 0; i < unison_size; i++) {
+ REALTYPE base = pow(UNISON_FREQ_SPAN, RND * 2.0 - 1.0);
+ uv[i].relative_amplitude = base;
+ REALTYPE period = base / base_freq;
+ REALTYPE m = 4.0 / (period * increments_per_second);
+ if(RND < 0.5)
+ m = -m;
+ uv[i].step = m;
+// printf("%g %g\n",uv[i].relative_amplitude,period);
+ }
+
+ REALTYPE max_speed = pow(2.0, unison_bandwidth_cents / 1200.0);
+ unison_amplitude_samples = 0.125
+ * (max_speed - 1.0) * SAMPLE_RATE / base_freq;
+ printf("unison_amplitude_samples %g\n", unison_amplitude_samples);
+
+#warning \
+ todo: test if unison_amplitude_samples is to big and reallocate bigger memory
+ if(unison_amplitude_samples >= max_delay - 1)
+ unison_amplitude_samples = max_delay - 2;
+
+ update_unison_data();
+}
+
+void Unison::process(int bufsize, REALTYPE *inbuf, REALTYPE *outbuf) {
+ if(!uv)
+ return;
+ if(!outbuf)
+ outbuf = inbuf;
+
+ REALTYPE volume = 1.0 / sqrt(unison_size);
+ REALTYPE xpos_step = 1.0 / (REALTYPE) update_period_samples;
+ REALTYPE xpos = (REALTYPE) update_period_sample_k * xpos_step;
+ for(int i = 0; i < bufsize; i++) {
+ if((update_period_sample_k++) >= update_period_samples) {
+ update_unison_data();
+ update_period_sample_k = 0;
+ xpos = 0.0;
+ }
+ xpos += xpos_step;
+ REALTYPE in = inbuf[i], out = 0.0;
+
+ REALTYPE sign = 1.0;
+ for(int k = 0; k < unison_size; k++) {
+ REALTYPE vpos = uv[k].realpos1
+ * (1.0 - xpos) + uv[k].realpos2 * xpos; //optimize
+ REALTYPE pos = delay_k + max_delay - vpos - 1.0; //optimize
+ int posi;
+ REALTYPE posf;
+ F2I(pos, posi); //optimize!
+ if(posi >= max_delay)
+ posi -= max_delay;
+ posf = pos - floor(pos);
+ out +=
+ ((1.0
+ - posf) * delay_buffer[posi] + posf
+ * delay_buffer[posi + 1]) * sign;
+ sign = -sign;
+ }
+ outbuf[i] = out * volume;
+// printf("%d %g\n",i,outbuf[i]);
+ delay_buffer[delay_k] = in;
+ if((++delay_k) >= max_delay)
+ delay_k = 0;
+ }
+}
+
+void Unison::update_unison_data() {
+ if(!uv)
+ return;
+
+ for(int k = 0; k < unison_size; k++) {
+ REALTYPE pos = uv[k].position;
+ REALTYPE step = uv[k].step;
+ pos += step;
+ if(pos <= -1.0) {
+ pos = -1.0;
+ step = -step;
+ }
+ if(pos >= 1.0) {
+ pos = 1.0;
+ step = -step;
+ }
+ REALTYPE vibratto_val = (pos - 0.333333333 * pos * pos * pos) * 1.5; //make the vibratto lfo smoother
+#warning \
+ I will use relative amplitude, so the delay might be bigger than the whole buffer
+#warning \
+ I have to enlarge (reallocate) the buffer to make place for the whole delay
+ REALTYPE newval = 1.0 + 0.5
+ * (vibratto_val
+ + 1.0) * unison_amplitude_samples
+ * uv[k].relative_amplitude;
+
+ if(first_time)
+ uv[k].realpos1 = uv[k].realpos2 = newval;
+ else{
+ uv[k].realpos1 = uv[k].realpos2;
+ uv[k].realpos2 = newval;
+ }
+
+ uv[k].position = pos;
+ uv[k].step = step;
+ }
+ if(first_time)
+ first_time = false;
+}
+
diff --git a/plugins/zynaddsubfx/src/DSP/Unison.h b/plugins/zynaddsubfx/src/DSP/Unison.h
new file mode 100644
index 000000000..d4254a114
--- /dev/null
+++ b/plugins/zynaddsubfx/src/DSP/Unison.h
@@ -0,0 +1,69 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ Unison.h - Unison effect (multivoice chorus)
+ Copyright (C) 2002-2009 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2 or later) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef UNISON_H
+#define UNISON_H
+#include
+#include "../globals.h"
+
+#define UNISON_FREQ_SPAN 2.0
+//how much the unison frequencies varies (always >= 1.0)
+
+class Unison
+{
+ public:
+ Unison(int update_period_samples_, REALTYPE max_delay_sec_);
+ ~Unison();
+
+ void set_size(int new_size);
+ void set_base_frequency(REALTYPE freq);
+ void set_bandwidth(REALTYPE bandwidth_cents);
+
+ void process(int bufsize, REALTYPE *inbuf, REALTYPE *outbuf = NULL);
+
+ private:
+ void update_parameters();
+ void update_unison_data();
+
+ int unison_size;
+ REALTYPE base_freq;
+ struct UnisonVoice {
+ REALTYPE step, position; //base LFO
+ REALTYPE realpos1, realpos2; //the position regarding samples
+ REALTYPE relative_amplitude;
+ REALTYPE lin_fpos, lin_ffreq;
+ UnisonVoice() {
+ position = RND * 1.8 - 0.9;
+ realpos1 = 0.0;
+ realpos2 = 0.0;
+ step = 0.0;
+ relative_amplitude = 1.0;
+ }
+ } *uv;
+ int update_period_samples, update_period_sample_k;
+ int max_delay, delay_k;
+ bool first_time;
+ REALTYPE *delay_buffer;
+ REALTYPE unison_amplitude_samples;
+ REALTYPE unison_bandwidth_cents;
+};
+#endif
+
diff --git a/plugins/zynaddsubfx/src/Effects/Alienwah.cpp b/plugins/zynaddsubfx/src/Effects/Alienwah.cpp
index a4bf58e54..fb07d4f11 100644
--- a/plugins/zynaddsubfx/src/Effects/Alienwah.cpp
+++ b/plugins/zynaddsubfx/src/Effects/Alienwah.cpp
@@ -23,83 +23,87 @@
#include
#include "Alienwah.h"
-Alienwah::Alienwah(const int &insertion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_)
- :Effect(insertion_,efxoutl_,efxoutr_,NULL,0),oldl(NULL),oldr(NULL)
+Alienwah::Alienwah(const int &insertion_,
+ REALTYPE *const efxoutl_,
+ REALTYPE *const efxoutr_)
+ :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0), oldl(NULL), oldr(NULL)
{
setpreset(Ppreset);
cleanup();
- oldclfol=complex(fb,0.0);
- oldclfor=complex(fb,0.0);
-};
+ oldclfol = complex(fb, 0.0);
+ oldclfor = complex(fb, 0.0);
+}
Alienwah::~Alienwah()
{
- if (oldl!=NULL) delete [] oldl;
- if (oldr!=NULL) delete [] oldr ;
-};
+ if(oldl != NULL)
+ delete [] oldl;
+ if(oldr != NULL)
+ delete [] oldr;
+}
/*
* Apply the effect
*/
-void Alienwah::out(REALTYPE *smpsl,REALTYPE *smpsr)
+void Alienwah::out(REALTYPE *smpsl, REALTYPE *smpsr)
{
- REALTYPE lfol,lfor; //Left/Right LFOs
- complex clfol,clfor,out,tmp;
+ REALTYPE lfol, lfor; //Left/Right LFOs
+ complex clfol, clfor, out, tmp;
/**\todo Rework, as optimization can be used when the new complex type is
* utilized.
* Before all calculations needed to be done with individual REALTYPE,
* but now they can be done together*/
- lfo.effectlfoout(&lfol,&lfor);
- lfol*=depth*PI*2.0;
- lfor*=depth*PI*2.0;
- clfol=complex(cos(lfol+phase)*fb,sin(lfol+phase)*fb); //rework
- clfor=complex(cos(lfor+phase)*fb,sin(lfor+phase)*fb); //rework
+ lfo.effectlfoout(&lfol, &lfor);
+ lfol *= depth * PI * 2.0;
+ lfor *= depth * PI * 2.0;
+ clfol = complex(cos(lfol + phase) * fb, sin(lfol + phase) * fb); //rework
+ clfor = complex(cos(lfor + phase) * fb, sin(lfor + phase) * fb); //rework
- for (int i=0;i=Pdelay) oldk=0;
+ if(++oldk >= Pdelay)
+ oldk = 0;
//LRcross
- efxoutl[i]=l*(1.0-lrcross)+r*lrcross;
- efxoutr[i]=r*(1.0-lrcross)+l*lrcross;
- };
+ efxoutl[i] = l * (1.0 - lrcross) + r * lrcross;
+ efxoutr[i] = r * (1.0 - lrcross) + l * lrcross;
+ }
- oldclfol=clfol;
- oldclfor=clfor;
-
-};
+ oldclfol = clfol;
+ oldclfor = clfor;
+}
/*
* Cleanup the effect
*/
void Alienwah::cleanup()
{
- for (int i=0;i(0.0,0.0);
- oldr[i]=complex(0.0,0.0);
- };
- oldk=0;
-};
+ for(int i = 0; i < Pdelay; i++) {
+ oldl[i] = complex(0.0, 0.0);
+ oldr[i] = complex(0.0, 0.0);
+ }
+ oldk = 0;
+}
/*
@@ -108,81 +112,92 @@ void Alienwah::cleanup()
void Alienwah::setdepth(const unsigned char &Pdepth)
{
- this->Pdepth=Pdepth;
- depth=(Pdepth/127.0);
-};
+ this->Pdepth = Pdepth;
+ depth = (Pdepth / 127.0);
+}
void Alienwah::setfb(const unsigned char &Pfb)
{
- this->Pfb=Pfb;
- fb=fabs((Pfb-64.0)/64.1);
- fb=sqrt(fb);
- if (fb<0.4) fb=0.4;
- if (Pfb<64) fb=-fb;
-};
+ this->Pfb = Pfb;
+ fb = fabs((Pfb - 64.0) / 64.1);
+ fb = sqrt(fb);
+ if(fb < 0.4)
+ fb = 0.4;
+ if(Pfb < 64)
+ fb = -fb;
+}
void Alienwah::setvolume(const unsigned char &Pvolume)
{
- this->Pvolume=Pvolume;
- outvolume=Pvolume/127.0;
- if (insertion==0) volume=1.0;
- else volume=outvolume;
-};
+ this->Pvolume = Pvolume;
+ outvolume = Pvolume / 127.0;
+ if(insertion == 0)
+ volume = 1.0;
+ else
+ volume = outvolume;
+}
void Alienwah::setpanning(const unsigned char &Ppanning)
{
- this->Ppanning=Ppanning;
- panning=Ppanning/127.0;
-};
+ this->Ppanning = Ppanning;
+ panning = Ppanning / 127.0;
+}
void Alienwah::setlrcross(const unsigned char &Plrcross)
{
- this->Plrcross=Plrcross;
- lrcross=Plrcross/127.0;
-};
+ this->Plrcross = Plrcross;
+ lrcross = Plrcross / 127.0;
+}
void Alienwah::setphase(const unsigned char &Pphase)
{
- this->Pphase=Pphase;
- phase=(Pphase-64.0)/64.0*PI;
-};
+ this->Pphase = Pphase;
+ phase = (Pphase - 64.0) / 64.0 * PI;
+}
void Alienwah::setdelay(const unsigned char &Pdelay)
{
- if (oldl!=NULL) delete [] oldl;
- if (oldr!=NULL) delete [] oldr;
- if (Pdelay>=MAX_ALIENWAH_DELAY) this->Pdelay=MAX_ALIENWAH_DELAY;
- else this->Pdelay=Pdelay;
- oldl=new complex[Pdelay];
- oldr=new complex[Pdelay];
+ if(oldl != NULL)
+ delete [] oldl;
+ if(oldr != NULL)
+ delete [] oldr;
+ if(Pdelay >= MAX_ALIENWAH_DELAY)
+ this->Pdelay = MAX_ALIENWAH_DELAY;
+ else
+ this->Pdelay = Pdelay;
+ oldl = new complex[Pdelay];
+ oldr = new complex[Pdelay];
cleanup();
-};
+}
void Alienwah::setpreset(unsigned char npreset)
{
- const int PRESET_SIZE=11;
- const int NUM_PRESETS=4;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE]={
+ const int PRESET_SIZE = 11;
+ const int NUM_PRESETS = 4;
+ unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//AlienWah1
- {127,64,70,0,0,62,60,105,25,0,64},
+ {127, 64, 70, 0, 0, 62, 60, 105, 25, 0, 64},
//AlienWah2
- {127,64,73,106,0,101,60,105,17,0,64},
+ {127, 64, 73, 106, 0, 101, 60, 105, 17, 0, 64},
//AlienWah3
- {127,64,63,0,1,100,112,105,31,0,42},
+ {127, 64, 63, 0, 1, 100, 112, 105, 31, 0, 42},
//AlienWah4
- {93,64,25,0,1,66,101,11,47,0,86}
+ {93, 64, 25, 0, 1, 66, 101, 11, 47, 0, 86}
};
- if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1;
- for (int n=0;n= NUM_PRESETS)
+ npreset = NUM_PRESETS - 1;
+ for(int n = 0; n < PRESET_SIZE; n++)
+ changepar(n, presets[npreset][n]);
+ if(insertion == 0)
+ changepar(0, presets[npreset][0] / 2); //lower the volume if this is system effect
+ Ppreset = npreset;
+}
-void Alienwah::changepar(const int &npar,const unsigned char &value)
+void Alienwah::changepar(const int &npar, const unsigned char &value)
{
- switch (npar) {
+ switch(npar) {
case 0:
setvolume(value);
break;
@@ -190,19 +205,19 @@ void Alienwah::changepar(const int &npar,const unsigned char &value)
setpanning(value);
break;
case 2:
- lfo.Pfreq=value;
+ lfo.Pfreq = value;
lfo.updateparams();
break;
case 3:
- lfo.Prandomness=value;
+ lfo.Prandomness = value;
lfo.updateparams();
break;
case 4:
- lfo.PLFOtype=value;
+ lfo.PLFOtype = value;
lfo.updateparams();
break;
case 5:
- lfo.Pstereo=value;
+ lfo.Pstereo = value;
lfo.updateparams();
break;
case 6:
@@ -220,48 +235,47 @@ void Alienwah::changepar(const int &npar,const unsigned char &value)
case 10:
setphase(value);
break;
- };
-};
+ }
+}
-unsigned char Alienwah::getpar(const int &npar)const
+unsigned char Alienwah::getpar(const int &npar) const
{
- switch (npar) {
+ switch(npar) {
case 0:
- return(Pvolume);
+ return Pvolume;
break;
case 1:
- return(Ppanning);
+ return Ppanning;
break;
case 2:
- return(lfo.Pfreq);
+ return lfo.Pfreq;
break;
case 3:
- return(lfo.Prandomness);
+ return lfo.Prandomness;
break;
case 4:
- return(lfo.PLFOtype);
+ return lfo.PLFOtype;
break;
case 5:
- return(lfo.Pstereo);
+ return lfo.Pstereo;
break;
case 6:
- return(Pdepth);
+ return Pdepth;
break;
case 7:
- return(Pfb);
+ return Pfb;
break;
case 8:
- return(Pdelay);
+ return Pdelay;
break;
case 9:
- return(Plrcross);
+ return Plrcross;
break;
case 10:
- return(Pphase);
+ return Pphase;
break;
default:
- return (0);
- };
-
-};
+ return 0;
+ }
+}
diff --git a/plugins/zynaddsubfx/src/Effects/Alienwah.h b/plugins/zynaddsubfx/src/Effects/Alienwah.h
index e813737bf..175c41f24 100644
--- a/plugins/zynaddsubfx/src/Effects/Alienwah.h
+++ b/plugins/zynaddsubfx/src/Effects/Alienwah.h
@@ -34,49 +34,51 @@ using namespace std;
/**"AlienWah" Effect*/
class Alienwah:public Effect
{
-public:
- /**
- * Constructor
- * @param insetion_ 1 for insertion Effect, 0 for others
- * @param efxoutl_ Pointer to Alienwah's left channel output buffer
- * @param efxoutr_ Pointer to Alienwah's left channel output buffer
- * @return Initialized Alienwah
- */
- Alienwah(const int &insetion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_);
- ~Alienwah();
- void out(REALTYPE *const smpsl,REALTYPE *const smpsr);
+ public:
+ /**
+ * Constructor
+ * @param insetion_ 1 for insertion Effect, 0 for others
+ * @param efxoutl_ Pointer to Alienwah's left channel output buffer
+ * @param efxoutr_ Pointer to Alienwah's left channel output buffer
+ * @return Initialized Alienwah
+ */
+ Alienwah(const int &insetion_,
+ REALTYPE *const efxoutl_,
+ REALTYPE *const efxoutr_);
+ ~Alienwah();
+ void out(REALTYPE *const smpsl, REALTYPE *const smpsr);
- void setpreset(unsigned char npreset);
- void changepar(const int &npar,const unsigned char &value);
- unsigned char getpar(const int &npar)const;
- void cleanup();
+ void setpreset(unsigned char npreset);
+ void changepar(const int &npar, const unsigned char &value);
+ unsigned char getpar(const int &npar) const;
+ void cleanup();
-private:
- //Alienwah Parameters
- EffectLFO lfo;//lfo-ul Alienwah
- unsigned char Pvolume;
- unsigned char Ppanning;
- unsigned char Pdepth;//the depth of the Alienwah
- unsigned char Pfb;//feedback
- unsigned char Plrcross;//feedback
- unsigned char Pdelay;
- unsigned char Pphase;
+ private:
+ //Alienwah Parameters
+ EffectLFO lfo; //lfo-ul Alienwah
+ unsigned char Pvolume;
+ unsigned char Ppanning;
+ unsigned char Pdepth; //the depth of the Alienwah
+ unsigned char Pfb; //feedback
+ unsigned char Plrcross; //feedback
+ unsigned char Pdelay;
+ unsigned char Pphase;
- //Control Parameters
- void setvolume(const unsigned char &Pvolume);
- void setpanning(const unsigned char &Ppanning);
- void setdepth(const unsigned char &Pdepth);
- void setfb(const unsigned char &Pfb);
- void setlrcross(const unsigned char &Plrcross);
- void setdelay(const unsigned char &Pdelay);
- void setphase(const unsigned char &Pphase);
+ //Control Parameters
+ void setvolume(const unsigned char &Pvolume);
+ void setpanning(const unsigned char &Ppanning);
+ void setdepth(const unsigned char &Pdepth);
+ void setfb(const unsigned char &Pfb);
+ void setlrcross(const unsigned char &Plrcross);
+ void setdelay(const unsigned char &Pdelay);
+ void setphase(const unsigned char &Pphase);
- //Internal Values
- REALTYPE panning,fb,depth,lrcross,phase;
- complex *oldl,*oldr;
- complex oldclfol,oldclfor;
- int oldk;
+ //Internal Values
+ REALTYPE panning, fb, depth, lrcross, phase;
+ complex *oldl, *oldr;
+ complex oldclfol, oldclfor;
+ int oldk;
};
#endif
diff --git a/plugins/zynaddsubfx/src/Effects/Chorus.cpp b/plugins/zynaddsubfx/src/Effects/Chorus.cpp
index 844e87f50..708c0cd75 100644
--- a/plugins/zynaddsubfx/src/Effects/Chorus.cpp
+++ b/plugins/zynaddsubfx/src/Effects/Chorus.cpp
@@ -26,26 +26,28 @@
using namespace std;
-Chorus::Chorus(const int &insertion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_)
- :Effect(insertion_,efxoutl_,efxoutr_,NULL,0),
- maxdelay((int)(MAX_CHORUS_DELAY/1000.0*SAMPLE_RATE)),
- delaySample(maxdelay)
+Chorus::Chorus(const int &insertion_,
+ REALTYPE *const efxoutl_,
+ REALTYPE *const efxoutr_)
+ :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0),
+ maxdelay((int)(MAX_CHORUS_DELAY / 1000.0 * SAMPLE_RATE)),
+ delaySample(maxdelay)
{
- dlk=0;
- drk=0;
+ dlk = 0;
+ drk = 0;
//maxdelay=(int)(MAX_CHORUS_DELAY/1000.0*SAMPLE_RATE);
//delayl=new REALTYPE[maxdelay];
//delayr=new REALTYPE[maxdelay];
setpreset(Ppreset);
- lfo.effectlfoout(&lfol,&lfor);
- dl2=getdelay(lfol);
- dr2=getdelay(lfor);
+ lfo.effectlfoout(&lfol, &lfor);
+ dl2 = getdelay(lfol);
+ dr2 = getdelay(lfor);
cleanup();
-};
+}
-Chorus::~Chorus() {};
+Chorus::~Chorus() {}
/*
* get the delay value in samples; xlfo is the current lfo value
@@ -53,91 +55,100 @@ Chorus::~Chorus() {};
REALTYPE Chorus::getdelay(REALTYPE xlfo)
{
REALTYPE result;
- if (Pflangemode==0) {
- result=(delay+xlfo*depth)*SAMPLE_RATE;
- } else result=0;
+ if(Pflangemode == 0)
+ result = (delay + xlfo * depth) * SAMPLE_RATE;
+ else
+ result = 0;
//check if it is too big delay(caused bu errornous setdelay() and setdepth()
/**\todo fix setdelay() and setdepth(), so this error cannot occur*/
- if ((result+0.5)>=maxdelay) {
- cerr << "WARNING: Chorus.C::getdelay(..) too big delay (see setdelay and setdepth funcs.)\n";
- result=maxdelay-1.0;
- };
- return(result);
-};
+ if((result + 0.5) >= maxdelay) {
+ cerr
+ <<
+ "WARNING: Chorus.C::getdelay(..) too big delay (see setdelay and setdepth funcs.)\n";
+ result = maxdelay - 1.0;
+ }
+ return result;
+}
/*
* Apply the effect
*/
-void Chorus::out(REALTYPE *smpsl,REALTYPE *smpsr)
+void Chorus::out(REALTYPE *smpsl, REALTYPE *smpsr)
{
- const Stereo input(AuSample(SOUND_BUFFER_SIZE,smpsl),AuSample(SOUND_BUFFER_SIZE,smpsr));
+ const Stereo input(AuSample(SOUND_BUFFER_SIZE, smpsl), AuSample(
+ SOUND_BUFFER_SIZE,
+ smpsr));
out(input);
}
void Chorus::out(const Stereo &input)
{
- const REALTYPE one=1.0;
- dl1=dl2;
- dr1=dr2;
- lfo.effectlfoout(&lfol,&lfor);
+ const REALTYPE one = 1.0;
+ dl1 = dl2;
+ dr1 = dr2;
+ lfo.effectlfoout(&lfol, &lfor);
- dl2=getdelay(lfol);
- dr2=getdelay(lfor);
+ dl2 = getdelay(lfol);
+ dr2 = getdelay(lfor);
- for (int i=0;i tmpc(inl,inr);
+ Stereo tmpc(inl, inr);
//REALTYPE r=inr;
- inl=tmpc.l()*(1.0-lrcross)+tmpc.r()*lrcross;
- inr=tmpc.r()*(1.0-lrcross)+tmpc.l()*lrcross;
+ inl = tmpc.l() * (1.0 - lrcross) + tmpc.r() * lrcross;
+ inr = tmpc.r() * (1.0 - lrcross) + tmpc.l() * lrcross;
//Left channel
//compute the delay in samples using linear interpolation between the lfo delays
- mdel=(dl1*(SOUND_BUFFER_SIZE-i)+dl2*i)/SOUND_BUFFER_SIZE;
- if (++dlk>=maxdelay) dlk=0;
- REALTYPE tmp=dlk-mdel+maxdelay*2.0;//where should I get the sample from
+ mdel = (dl1 * (SOUND_BUFFER_SIZE - i) + dl2 * i) / SOUND_BUFFER_SIZE;
+ if(++dlk >= maxdelay)
+ dlk = 0;
+ REALTYPE tmp = dlk - mdel + maxdelay * 2.0; //where should I get the sample from
- F2I(tmp,dlhi);
- dlhi%=maxdelay;
+ F2I(tmp, dlhi);
+ dlhi %= maxdelay;
- dlhi2=(dlhi-1+maxdelay)%maxdelay;
- dllo=1.0-fmod(tmp,one);
- efxoutl[i]=delaySample.l()[dlhi2]*dllo+delaySample.l()[dlhi]*(1.0-dllo);
- delaySample.l()[dlk]=inl+efxoutl[i]*fb;
+ dlhi2 = (dlhi - 1 + maxdelay) % maxdelay;
+ dllo = 1.0 - fmod(tmp, one);
+ efxoutl[i] = delaySample.l()[dlhi2] * dllo + delaySample.l()[dlhi]
+ * (1.0 - dllo);
+ delaySample.l()[dlk] = inl + efxoutl[i] * fb;
//Right channel
//compute the delay in samples using linear interpolation between the lfo delays
- mdel=(dr1*(SOUND_BUFFER_SIZE-i)+dr2*i)/SOUND_BUFFER_SIZE;
- if (++drk>=maxdelay) drk=0;
- tmp=drk*1.0-mdel+maxdelay*2.0;//where should I get the sample from
+ mdel = (dr1 * (SOUND_BUFFER_SIZE - i) + dr2 * i) / SOUND_BUFFER_SIZE;
+ if(++drk >= maxdelay)
+ drk = 0;
+ tmp = drk * 1.0 - mdel + maxdelay * 2.0; //where should I get the sample from
- F2I(tmp,dlhi);
- dlhi%=maxdelay;
+ F2I(tmp, dlhi);
+ dlhi %= maxdelay;
- dlhi2=(dlhi-1+maxdelay)%maxdelay;
- dllo=1.0-fmod(tmp,one);
- efxoutr[i]=delaySample.r()[dlhi2]*dllo+delaySample.r()[dlhi]*(1.0-dllo);
- delaySample.r()[dlk]=inr+efxoutr[i]*fb;
+ dlhi2 = (dlhi - 1 + maxdelay) % maxdelay;
+ dllo = 1.0 - fmod(tmp, one);
+ efxoutr[i] = delaySample.r()[dlhi2] * dllo + delaySample.r()[dlhi]
+ * (1.0 - dllo);
+ delaySample.r()[dlk] = inr + efxoutr[i] * fb;
+ }
- };
-
- if (Poutsub!=0)
- for (int i=0;iPdepth=Pdepth;
- depth=(pow(8.0,(Pdepth/127.0)*2.0)-1.0)/1000.0;//seconds
-};
+ this->Pdepth = Pdepth;
+ depth = (pow(8.0, (Pdepth / 127.0) * 2.0) - 1.0) / 1000.0; //seconds
+}
void Chorus::setdelay(const unsigned char &Pdelay)
{
- this->Pdelay=Pdelay;
- delay=(pow(10.0,(Pdelay/127.0)*2.0)-1.0)/1000.0;//seconds
-};
+ this->Pdelay = Pdelay;
+ delay = (pow(10.0, (Pdelay / 127.0) * 2.0) - 1.0) / 1000.0; //seconds
+}
void Chorus::setfb(const unsigned char &Pfb)
{
- this->Pfb=Pfb;
- fb=(Pfb-64.0)/64.1;
-};
+ this->Pfb = Pfb;
+ fb = (Pfb - 64.0) / 64.1;
+}
void Chorus::setvolume(const unsigned char &Pvolume)
{
- this->Pvolume=Pvolume;
- outvolume=Pvolume/127.0;
- if (insertion==0) volume=1.0;
- else volume=outvolume;
-};
+ this->Pvolume = Pvolume;
+ outvolume = Pvolume / 127.0;
+ if(insertion == 0)
+ volume = 1.0;
+ else
+ volume = outvolume;
+}
void Chorus::setpanning(const unsigned char &Ppanning)
{
- this->Ppanning=Ppanning;
- panning=Ppanning/127.0;
-};
+ this->Ppanning = Ppanning;
+ panning = Ppanning / 127.0;
+}
void Chorus::setlrcross(const unsigned char &Plrcross)
{
- this->Plrcross=Plrcross;
- lrcross=Plrcross/127.0;
-};
+ this->Plrcross = Plrcross;
+ lrcross = Plrcross / 127.0;
+}
void Chorus::setpreset(unsigned char npreset)
{
- const int PRESET_SIZE=12;
- const int NUM_PRESETS=10;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE]={
+ const int PRESET_SIZE = 12;
+ const int NUM_PRESETS = 10;
+ unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//Chorus1
- {64,64,50,0,0,90,40,85,64,119,0,0},
+ {64, 64, 50, 0, 0, 90, 40, 85, 64, 119, 0, 0 },
//Chorus2
- {64,64,45,0,0,98,56,90,64,19,0,0},
+ {64, 64, 45, 0, 0, 98, 56, 90, 64, 19, 0, 0 },
//Chorus3
- {64,64,29,0,1,42,97,95,90,127,0,0},
+ {64, 64, 29, 0, 1, 42, 97, 95, 90, 127, 0, 0 },
//Celeste1
- {64,64,26,0,0,42,115,18,90,127,0,0},
+ {64, 64, 26, 0, 0, 42, 115, 18, 90, 127, 0, 0 },
//Celeste2
- {64,64,29,117,0,50,115,9,31,127,0,1},
+ {64, 64, 29, 117, 0, 50, 115, 9, 31, 127, 0, 1 },
//Flange1
- {64,64,57,0,0,60,23,3,62,0,0,0},
+ {64, 64, 57, 0, 0, 60, 23, 3, 62, 0, 0, 0 },
//Flange2
- {64,64,33,34,1,40,35,3,109,0,0,0},
+ {64, 64, 33, 34, 1, 40, 35, 3, 109, 0, 0, 0 },
//Flange3
- {64,64,53,34,1,94,35,3,54,0,0,1},
+ {64, 64, 53, 34, 1, 94, 35, 3, 54, 0, 0, 1 },
//Flange4
- {64,64,40,0,1,62,12,19,97,0,0,0},
+ {64, 64, 40, 0, 1, 62, 12, 19, 97, 0, 0, 0 },
//Flange5
- {64,64,55,105,0,24,39,19,17,0,0,1}
+ {64, 64, 55, 105, 0, 24, 39, 19, 17, 0, 0, 1 }
};
- if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1;
- for (int n=0;n= NUM_PRESETS)
+ npreset = NUM_PRESETS - 1;
+ for(int n = 0; n < PRESET_SIZE; n++)
+ changepar(n, presets[npreset][n]);
+ Ppreset = npreset;
+}
-void Chorus::changepar(const int &npar,const unsigned char &value)
+void Chorus::changepar(const int &npar, const unsigned char &value)
{
- switch (npar) {
+ switch(npar) {
case 0:
setvolume(value);
break;
@@ -231,19 +246,19 @@ void Chorus::changepar(const int &npar,const unsigned char &value)
setpanning(value);
break;
case 2:
- lfo.Pfreq=value;
+ lfo.Pfreq = value;
lfo.updateparams();
break;
case 3:
- lfo.Prandomness=value;
+ lfo.Prandomness = value;
lfo.updateparams();
break;
case 4:
- lfo.PLFOtype=value;
+ lfo.PLFOtype = value;
lfo.updateparams();
break;
case 5:
- lfo.Pstereo=value;
+ lfo.Pstereo = value;
lfo.updateparams();
break;
case 6:
@@ -259,58 +274,61 @@ void Chorus::changepar(const int &npar,const unsigned char &value)
setlrcross(value);
break;
case 10:
- if (value>1) Pflangemode=1;
- else Pflangemode=value;
+ if(value > 1)
+ Pflangemode = 1;
+ else
+ Pflangemode = value;
break;
case 11:
- if (value>1) Poutsub=1;
- else Poutsub=value;
+ if(value > 1)
+ Poutsub = 1;
+ else
+ Poutsub = value;
break;
- };
-};
+ }
+}
-unsigned char Chorus::getpar(const int &npar)const
+unsigned char Chorus::getpar(const int &npar) const
{
- switch (npar) {
+ switch(npar) {
case 0:
- return(Pvolume);
+ return Pvolume;
break;
case 1:
- return(Ppanning);
+ return Ppanning;
break;
case 2:
- return(lfo.Pfreq);
+ return lfo.Pfreq;
break;
case 3:
- return(lfo.Prandomness);
+ return lfo.Prandomness;
break;
case 4:
- return(lfo.PLFOtype);
+ return lfo.PLFOtype;
break;
case 5:
- return(lfo.Pstereo);
+ return lfo.Pstereo;
break;
case 6:
- return(Pdepth);
+ return Pdepth;
break;
case 7:
- return(Pdelay);
+ return Pdelay;
break;
case 8:
- return(Pfb);
+ return Pfb;
break;
case 9:
- return(Plrcross);
+ return Plrcross;
break;
case 10:
- return(Pflangemode);
+ return Pflangemode;
break;
case 11:
- return(Poutsub);
+ return Poutsub;
break;
default:
- return (0);
- };
-
-};
+ return 0;
+ }
+}
diff --git a/plugins/zynaddsubfx/src/Effects/Chorus.h b/plugins/zynaddsubfx/src/Effects/Chorus.h
index 488e4d85d..748ce5eaf 100644
--- a/plugins/zynaddsubfx/src/Effects/Chorus.h
+++ b/plugins/zynaddsubfx/src/Effects/Chorus.h
@@ -33,83 +33,83 @@
/**Chorus and Flange effects*/
class Chorus:public Effect
{
-public:
- Chorus(const int &insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
- /**Destructor*/
- ~Chorus();
- void out(REALTYPE *smpsl,REALTYPE *smpsr);
- void out(const Stereo &input);
- void setpreset(unsigned char npreset);
- /**
- * Sets the value of the chosen variable
- *
- * The possible parameters are:
- * -# Volume
- * -# Panning
- * -# LFO Frequency
- * -# LFO Randomness
- * -# LFO Type
- * -# LFO stereo
- * -# Depth
- * -# Delay
- * -# Feedback
- * -# Flange Mode
- * -# Subtractive
- * @param npar number of chosen parameter
- * @param value the new value
- */
- void changepar(const int &npar,const unsigned char &value);
- /**
- * Gets the value of the chosen variable
- *
- * The possible parameters are:
- * -# Volume
- * -# Panning
- * -# LFO Frequency
- * -# LFO Randomness
- * -# LFO Type
- * -# LFO stereo
- * -# Depth
- * -# Delay
- * -# Feedback
- * -# Flange Mode
- * -# Subtractive
- * @param npar number of chosen parameter
- * @return the value of the parameter
- */
- unsigned char getpar(const int &npar)const;
- void cleanup();
+ public:
+ Chorus(const int &insetion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ /**Destructor*/
+ ~Chorus();
+ void out(REALTYPE *smpsl, REALTYPE *smpsr);
+ void out(const Stereo &input);
+ void setpreset(unsigned char npreset);
+ /**
+ * Sets the value of the chosen variable
+ *
+ * The possible parameters are:
+ * -# Volume
+ * -# Panning
+ * -# LFO Frequency
+ * -# LFO Randomness
+ * -# LFO Type
+ * -# LFO stereo
+ * -# Depth
+ * -# Delay
+ * -# Feedback
+ * -# Flange Mode
+ * -# Subtractive
+ * @param npar number of chosen parameter
+ * @param value the new value
+ */
+ void changepar(const int &npar, const unsigned char &value);
+ /**
+ * Gets the value of the chosen variable
+ *
+ * The possible parameters are:
+ * -# Volume
+ * -# Panning
+ * -# LFO Frequency
+ * -# LFO Randomness
+ * -# LFO Type
+ * -# LFO stereo
+ * -# Depth
+ * -# Delay
+ * -# Feedback
+ * -# Flange Mode
+ * -# Subtractive
+ * @param npar number of chosen parameter
+ * @return the value of the parameter
+ */
+ unsigned char getpar(const int &npar) const;
+ void cleanup();
-private:
- //Chorus Parameters
- EffectLFO lfo;//lfo-ul chorus
- unsigned char Pvolume;
- unsigned char Ppanning;
- unsigned char Pdepth;//the depth of the Chorus(ms)
- unsigned char Pdelay;//the delay (ms)
- unsigned char Pfb;//feedback
- unsigned char Plrcross;//feedback
- unsigned char Pflangemode;//how the LFO is scaled, to result chorus or flange
- unsigned char Poutsub;//if I wish to substract the output instead of the adding it
+ private:
+ //Chorus Parameters
+ EffectLFO lfo; //lfo-ul chorus
+ unsigned char Pvolume;
+ unsigned char Ppanning;
+ unsigned char Pdepth; //the depth of the Chorus(ms)
+ unsigned char Pdelay; //the delay (ms)
+ unsigned char Pfb; //feedback
+ unsigned char Plrcross; //feedback
+ unsigned char Pflangemode; //how the LFO is scaled, to result chorus or flange
+ unsigned char Poutsub; //if I wish to substract the output instead of the adding it
- //Parameter Controls
- void setvolume(const unsigned char &Pvolume);
- void setpanning(const unsigned char &Ppanning);
- void setdepth(const unsigned char &Pdepth);
- void setdelay(const unsigned char &Pdelay);
- void setfb(const unsigned char &Pfb);
- void setlrcross(const unsigned char &Plrcross);
+ //Parameter Controls
+ void setvolume(const unsigned char &Pvolume);
+ void setpanning(const unsigned char &Ppanning);
+ void setdepth(const unsigned char &Pdepth);
+ void setdelay(const unsigned char &Pdelay);
+ void setfb(const unsigned char &Pfb);
+ void setlrcross(const unsigned char &Plrcross);
- //Internal Values
- REALTYPE depth,delay,fb,lrcross,panning;
- REALTYPE dl1,dl2,dr1,dr2,lfol,lfor;
- int maxdelay;
- Stereo delaySample;
- //REALTYPE *delayl,*delayr;
- int dlk,drk,dlhi,dlhi2;
- REALTYPE getdelay(REALTYPE xlfo);
- REALTYPE dllo,mdel;
+ //Internal Values
+ REALTYPE depth, delay, fb, lrcross, panning;
+ REALTYPE dl1, dl2, dr1, dr2, lfol, lfor;
+ int maxdelay;
+ Stereo delaySample;
+ //REALTYPE *delayl,*delayr;
+ int dlk, drk, dlhi, dlhi2;
+ REALTYPE getdelay(REALTYPE xlfo);
+ REALTYPE dllo, mdel;
};
#endif
diff --git a/plugins/zynaddsubfx/src/Effects/Distorsion.cpp b/plugins/zynaddsubfx/src/Effects/Distorsion.cpp
index 6aeaab4fb..61fe9966b 100644
--- a/plugins/zynaddsubfx/src/Effects/Distorsion.cpp
+++ b/plugins/zynaddsubfx/src/Effects/Distorsion.cpp
@@ -28,159 +28,199 @@
* Waveshape (this is called by OscilGen::waveshape and Distorsion::process)
*/
-void waveshapesmps(int n,REALTYPE *smps,unsigned char type,unsigned char drive)
+void waveshapesmps(int n,
+ REALTYPE *smps,
+ unsigned char type,
+ unsigned char drive)
{
- int i;
- REALTYPE ws=drive/127.0;
+ int i;
+ REALTYPE ws = drive / 127.0;
REALTYPE tmpv;
- switch (type) {
+ switch(type) {
case 1:
- ws=pow(10,ws*ws*3.0)-1.0+0.001;//Arctangent
- for (i=0;iws) {
- if (tmp>=0.0) smps[i]=1.0;
- else smps[i]=-1.0;
- } else smps[i]/=ws;
- };
+ ws = pow(2.0, -ws * ws * 8.0); //Limiter
+ for(i = 0; i < n; i++) {
+ REALTYPE tmp = smps[i];
+ if(fabs(tmp) > ws) {
+ if(tmp >= 0.0)
+ smps[i] = 1.0;
+ else
+ smps[i] = -1.0;
+ }
+ else
+ smps[i] /= ws;
+ }
break;
case 8:
- ws=pow(2.0,-ws*ws*8.0); //Upper Limiter
- for (i=0;iws) smps[i]=ws;
- smps[i]*=2.0;
- };
+ ws = pow(2.0, -ws * ws * 8.0); //Upper Limiter
+ for(i = 0; i < n; i++) {
+ REALTYPE tmp = smps[i];
+ if(tmp > ws)
+ smps[i] = ws;
+ smps[i] *= 2.0;
+ }
break;
case 9:
- ws=pow(2.0,-ws*ws*8.0); //Lower Limiter
- for (i=0;iws) {
- if (tmp>=0.0) smps[i]=tmp-ws;
- else smps[i]=tmp+ws;
- } else smps[i]=0;
- };
+ ws = (pow(2.0, ws * 6.0) - 1.0) / pow(2.0, 6.0); //Inverse Limiter
+ for(i = 0; i < n; i++) {
+ REALTYPE tmp = smps[i];
+ if(fabs(tmp) > ws) {
+ if(tmp >= 0.0)
+ smps[i] = tmp - ws;
+ else
+ smps[i] = tmp + ws;
+ }
+ else
+ smps[i] = 0;
+ }
break;
case 11:
- ws=pow(5,ws*ws*1.0)-1.0;//Clip
- for (i=0;i-2.0) && (tmp<1.0)) smps[i]=tmp*(1.0-tmp)*(tmp+2.0)/tmpv;
- else smps[i]=0.0;
- };
+ ws = ws * ws * ws * 30 + 0.001; //Asym2
+ if(ws < 0.3)
+ tmpv = ws;
+ else
+ tmpv = 1.0;
+ for(i = 0; i < n; i++) {
+ REALTYPE tmp = smps[i] * ws;
+ if((tmp > -2.0) && (tmp < 1.0))
+ smps[i] = tmp * (1.0 - tmp) * (tmp + 2.0) / tmpv;
+ else
+ smps[i] = 0.0;
+ }
break;
case 13:
- ws=ws*ws*ws*32.0+0.0001;//Pow2
- if (ws<1.0) tmpv=ws*(1+ws)/2.0;
- else tmpv=1.0;
- for (i=0;i-1.0)&&(tmp<1.618034)) smps[i]=tmp*(1.0-tmp)/tmpv;
- else if (tmp>0.0) smps[i]=-1.0;
- else smps[i]=-2.0;
- };
+ ws = ws * ws * ws * 32.0 + 0.0001; //Pow2
+ if(ws < 1.0)
+ tmpv = ws * (1 + ws) / 2.0;
+ else
+ tmpv = 1.0;
+ for(i = 0; i < n; i++) {
+ REALTYPE tmp = smps[i] * ws;
+ if((tmp > -1.0) && (tmp < 1.618034))
+ smps[i] = tmp * (1.0 - tmp) / tmpv;
+ else
+ if(tmp > 0.0)
+ smps[i] = -1.0;
+ else
+ smps[i] = -2.0;
+ }
break;
case 14:
- ws=pow(ws,5.0)*80.0+0.0001;//sigmoid
- if (ws>10.0) tmpv=0.5;
- else tmpv=0.5-1.0/(exp(ws)+1.0);
- for (i=0;i10.0) tmp=10.0;
- tmp=0.5-1.0/(exp(tmp)+1.0);
- smps[i]=tmp/tmpv;
- };
+ ws = pow(ws, 5.0) * 80.0 + 0.0001; //sigmoid
+ if(ws > 10.0)
+ tmpv = 0.5;
+ else
+ tmpv = 0.5 - 1.0 / (exp(ws) + 1.0);
+ for(i = 0; i < n; i++) {
+ REALTYPE tmp = smps[i] * ws;
+ if(tmp < -10.0)
+ tmp = -10.0;
+ else
+ if(tmp > 10.0)
+ tmp = 10.0;
+ tmp = 0.5 - 1.0 / (exp(tmp) + 1.0);
+ smps[i] = tmp / tmpv;
+ }
break;
/**\todo update to Distorsion::changepar (Ptype max) if there is added more waveshapings functions*/
- };
-
-};
+ }
+}
-Distorsion::Distorsion(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
- :Effect(insertion_,efxoutl_,efxoutr_,NULL,0)
+Distorsion::Distorsion(const int &insertion_,
+ REALTYPE *efxoutl_,
+ REALTYPE *efxoutr_)
+ :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0)
{
-
- lpfl=new AnalogFilter(2,22000,1,0);
- lpfr=new AnalogFilter(2,22000,1,0);
- hpfl=new AnalogFilter(3,20,1,0);
- hpfr=new AnalogFilter(3,20,1,0);
+ lpfl = new AnalogFilter(2, 22000, 1, 0);
+ lpfr = new AnalogFilter(2, 22000, 1, 0);
+ hpfl = new AnalogFilter(3, 20, 1, 0);
+ hpfr = new AnalogFilter(3, 20, 1, 0);
//default values
- Pvolume=50;
- Plrcross=40;
- Pdrive=90;
- Plevel=64;
- Ptype=0;
- Pnegate=0;
- Plpf=127;
- Phpf=0;
- Pstereo=0;
- Pprefiltering=0;
+ Pvolume = 50;
+ Plrcross = 40;
+ Pdrive = 90;
+ Plevel = 64;
+ Ptype = 0;
+ Pnegate = 0;
+ Plpf = 127;
+ Phpf = 0;
+ Pstereo = 0;
+ Pprefiltering = 0;
setpreset(Ppreset);
cleanup();
-};
+}
Distorsion::~Distorsion()
{
@@ -188,8 +228,7 @@ Distorsion::~Distorsion()
delete lpfr;
delete hpfl;
delete hpfr;
-
-};
+}
/*
* Cleanup the effect
@@ -200,72 +239,77 @@ void Distorsion::cleanup()
hpfl->cleanup();
lpfr->cleanup();
hpfr->cleanup();
-};
+}
/*
* Apply the filters
*/
-void Distorsion::applyfilters(REALTYPE *efxoutl,REALTYPE *efxoutr)
+void Distorsion::applyfilters(REALTYPE *efxoutl, REALTYPE *efxoutr)
{
lpfl->filterout(efxoutl);
hpfl->filterout(efxoutl);
- if (Pstereo!=0) {//stereo
+ if(Pstereo != 0) { //stereo
lpfr->filterout(efxoutr);
hpfr->filterout(efxoutr);
- };
-
-};
+ }
+}
/*
* Effect output
*/
-void Distorsion::out(REALTYPE *smpsl,REALTYPE *smpsr)
+void Distorsion::out(REALTYPE *smpsl, REALTYPE *smpsr)
{
- int i;
- REALTYPE l,r,lout,rout;
+ int i;
+ REALTYPE l, r, lout, rout;
- REALTYPE inputvol=pow(5.0,(Pdrive-32.0)/127.0);
- if (Pnegate!=0) inputvol*=-1.0;
+ REALTYPE inputvol = pow(5.0, (Pdrive - 32.0) / 127.0);
+ if(Pnegate != 0)
+ inputvol *= -1.0;
- if (Pstereo!=0) {//Stereo
- for (i=0;iPvolume=Pvolume;
+ this->Pvolume = Pvolume;
- if (insertion==0) {
- outvolume=pow(0.01,(1.0-Pvolume/127.0))*4.0;
- volume=1.0;
- } else {
- volume=outvolume=Pvolume/127.0;
- };
- if (Pvolume==0) cleanup();
-
-};
+ if(insertion == 0) {
+ outvolume = pow(0.01, (1.0 - Pvolume / 127.0)) * 4.0;
+ volume = 1.0;
+ }
+ else
+ volume = outvolume = Pvolume / 127.0;
+ ;
+ if(Pvolume == 0)
+ cleanup();
+}
void Distorsion::setpanning(const unsigned char &Ppanning)
{
- this->Ppanning=Ppanning;
- panning=(Ppanning+0.5)/127.0;
-};
+ this->Ppanning = Ppanning;
+ panning = (Ppanning + 0.5) / 127.0;
+}
void Distorsion::setlrcross(const unsigned char &Plrcross)
{
- this->Plrcross=Plrcross;
- lrcross=Plrcross/127.0*1.0;
-};
+ this->Plrcross = Plrcross;
+ lrcross = Plrcross / 127.0 * 1.0;
+}
void Distorsion::setlpf(const unsigned char &Plpf)
{
- this->Plpf=Plpf;
- REALTYPE fr=exp(pow(Plpf/127.0,0.5)*log(25000.0))+40;
+ this->Plpf = Plpf;
+ REALTYPE fr = exp(pow(Plpf / 127.0, 0.5) * log(25000.0)) + 40;
lpfl->setfreq(fr);
lpfr->setfreq(fr);
-};
+}
void Distorsion::sethpf(const unsigned char &Phpf)
{
- this->Phpf=Phpf;
- REALTYPE fr=exp(pow(Phpf/127.0,0.5)*log(25000.0))+20.0;
+ this->Phpf = Phpf;
+ REALTYPE fr = exp(pow(Phpf / 127.0, 0.5) * log(25000.0)) + 20.0;
hpfl->setfreq(fr);
hpfr->setfreq(fr);
-};
+}
void Distorsion::setpreset(unsigned char npreset)
{
- const int PRESET_SIZE=11;
- const int NUM_PRESETS=6;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE]={
+ const int PRESET_SIZE = 11;
+ const int NUM_PRESETS = 6;
+ unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//Overdrive 1
- {127,64,35,56,70,0,0,96,0,0,0},
+ {127, 64, 35, 56, 70, 0, 0, 96, 0, 0, 0 },
//Overdrive 2
- {127,64,35,29,75,1,0,127,0,0,0},
+ {127, 64, 35, 29, 75, 1, 0, 127, 0, 0, 0 },
//A. Exciter 1
- {64,64,35,75,80,5,0,127,105,1,0},
+ {64, 64, 35, 75, 80, 5, 0, 127, 105, 1, 0 },
//A. Exciter 2
- {64,64,35,85,62,1,0,127,118,1,0},
+ {64, 64, 35, 85, 62, 1, 0, 127, 118, 1, 0 },
//Guitar Amp
- {127,64,35,63,75,2,0,55,0,0,0},
+ {127, 64, 35, 63, 75, 2, 0, 55, 0, 0, 0 },
//Quantisize
- {127,64,35,88,75,4,0,127,0,1,0}
+ {127, 64, 35, 88, 75, 4, 0, 127, 0, 1, 0 }
};
- if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1;
- for (int n=0;n= NUM_PRESETS)
+ npreset = NUM_PRESETS - 1;
+ for(int n = 0; n < PRESET_SIZE; n++)
+ changepar(n, presets[npreset][n]);
+ if(insertion == 0)
+ changepar(0, (int) (presets[npreset][0] / 1.5)); //lower the volume if this is system effect
+ Ppreset = npreset;
cleanup();
-};
+}
-void Distorsion::changepar(const int &npar,const unsigned char &value)
+void Distorsion::changepar(const int &npar, const unsigned char &value)
{
- switch (npar) {
+ switch(npar) {
case 0:
setvolume(value);
break;
@@ -356,18 +404,22 @@ void Distorsion::changepar(const int &npar,const unsigned char &value)
setlrcross(value);
break;
case 3:
- Pdrive=value;
+ Pdrive = value;
break;
case 4:
- Plevel=value;
+ Plevel = value;
break;
case 5:
- if (value>13) Ptype=13;//this must be increased if more distorsion types are added
- else Ptype=value;
+ if(value > 13)
+ Ptype = 13; //this must be increased if more distorsion types are added
+ else
+ Ptype = value;
break;
case 6:
- if (value>1) Pnegate=1;
- else Pnegate=value;
+ if(value > 1)
+ Pnegate = 1;
+ else
+ Pnegate = value;
break;
case 7:
setlpf(value);
@@ -376,52 +428,54 @@ void Distorsion::changepar(const int &npar,const unsigned char &value)
sethpf(value);
break;
case 9:
- if (value>1) Pstereo=1;
- else Pstereo=value;
+ if(value > 1)
+ Pstereo = 1;
+ else
+ Pstereo = value;
break;
case 10:
- Pprefiltering=value;
+ Pprefiltering = value;
break;
- };
-};
+ }
+}
-unsigned char Distorsion::getpar(const int &npar)const
+unsigned char Distorsion::getpar(const int &npar) const
{
- switch (npar) {
+ switch(npar) {
case 0:
- return(Pvolume);
+ return Pvolume;
break;
case 1:
- return(Ppanning);
+ return Ppanning;
break;
case 2:
- return(Plrcross);
+ return Plrcross;
break;
case 3:
- return(Pdrive);
+ return Pdrive;
break;
case 4:
- return(Plevel);
+ return Plevel;
break;
case 5:
- return(Ptype);
+ return Ptype;
break;
case 6:
- return(Pnegate);
+ return Pnegate;
break;
case 7:
- return(Plpf);
+ return Plpf;
break;
case 8:
- return(Phpf);
+ return Phpf;
break;
case 9:
- return(Pstereo);
+ return Pstereo;
break;
case 10:
- return(Pprefiltering);
+ return Pprefiltering;
break;
- };
- return(0);//in case of bogus parameter number
-};
+ }
+ return 0; //in case of bogus parameter number
+}
diff --git a/plugins/zynaddsubfx/src/Effects/Distorsion.h b/plugins/zynaddsubfx/src/Effects/Distorsion.h
index efe3b8287..8c082f13f 100644
--- a/plugins/zynaddsubfx/src/Effects/Distorsion.h
+++ b/plugins/zynaddsubfx/src/Effects/Distorsion.h
@@ -28,44 +28,46 @@
#include "Effect.h"
//Waveshaping(called by Distorsion effect and waveshape from OscilGen)
-void waveshapesmps(int n,REALTYPE *smps,unsigned char type,unsigned char drive);
+void waveshapesmps(int n,
+ REALTYPE *smps,
+ unsigned char type,
+ unsigned char drive);
/**Distortion Effect*/
class Distorsion:public Effect
{
-public:
- Distorsion(const int &insertion,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
- ~Distorsion();
- void out(REALTYPE *smpsl,REALTYPE *smpr);
- void setpreset(unsigned char npreset);
- void changepar(const int &npar,const unsigned char &value);
- unsigned char getpar(const int &npar)const;
- void cleanup();
- void applyfilters(REALTYPE *efxoutl,REALTYPE *efxoutr);
+ public:
+ Distorsion(const int &insertion, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ ~Distorsion();
+ void out(REALTYPE *smpsl, REALTYPE *smpr);
+ void setpreset(unsigned char npreset);
+ void changepar(const int &npar, const unsigned char &value);
+ unsigned char getpar(const int &npar) const;
+ void cleanup();
+ void applyfilters(REALTYPE *efxoutl, REALTYPE *efxoutr);
-private:
- //Parametrii
- unsigned char Pvolume; //Volumul or E/R
- unsigned char Ppanning;//Panning
- unsigned char Plrcross;// L/R Mixing
- unsigned char Pdrive; //the input amplification
- unsigned char Plevel; //the output amplification
- unsigned char Ptype; //Distorsion type
- unsigned char Pnegate; //if the input is negated
- unsigned char Plpf; //lowpass filter
- unsigned char Phpf; //highpass filter
- unsigned char Pstereo; //0=mono,1=stereo
- unsigned char Pprefiltering;//if you want to do the filtering before the distorsion
+ private:
+ //Parametrii
+ unsigned char Pvolume; //Volumul or E/R
+ unsigned char Ppanning; //Panning
+ unsigned char Plrcross; // L/R Mixing
+ unsigned char Pdrive; //the input amplification
+ unsigned char Plevel; //the output amplification
+ unsigned char Ptype; //Distorsion type
+ unsigned char Pnegate; //if the input is negated
+ unsigned char Plpf; //lowpass filter
+ unsigned char Phpf; //highpass filter
+ unsigned char Pstereo; //0=mono,1=stereo
+ unsigned char Pprefiltering; //if you want to do the filtering before the distorsion
- void setvolume(const unsigned char &Pvolume);
- void setpanning(const unsigned char &Ppanning);
- void setlrcross(const unsigned char &Plrcross);
- void setlpf(const unsigned char &Plpf);
- void sethpf(const unsigned char &Phpf);
-
- //Real Parameters
- REALTYPE panning,lrcross;
- AnalogFilter *lpfl,*lpfr,*hpfl,*hpfr;
+ void setvolume(const unsigned char &Pvolume);
+ void setpanning(const unsigned char &Ppanning);
+ void setlrcross(const unsigned char &Plrcross);
+ void setlpf(const unsigned char &Plpf);
+ void sethpf(const unsigned char &Phpf);
+ //Real Parameters
+ REALTYPE panning, lrcross;
+ AnalogFilter *lpfl, *lpfr, *hpfl, *hpfr;
};
diff --git a/plugins/zynaddsubfx/src/Effects/DynamicFilter.cpp b/plugins/zynaddsubfx/src/Effects/DynamicFilter.cpp
index b7b367ea3..1b2bb1eb0 100644
--- a/plugins/zynaddsubfx/src/Effects/DynamicFilter.cpp
+++ b/plugins/zynaddsubfx/src/Effects/DynamicFilter.cpp
@@ -23,74 +23,75 @@
#include
#include "DynamicFilter.h"
-DynamicFilter::DynamicFilter(int insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
- :Effect(insertion_,efxoutl_,efxoutr_,new FilterParams(0,64,64),0),
- Pvolume(110),Ppanning(64),Pdepth(0),Pampsns(90),
- Pampsnsinv(0),Pampsmooth(60),
- filterl(NULL),filterr(NULL)
+DynamicFilter::DynamicFilter(int insertion_,
+ REALTYPE *efxoutl_,
+ REALTYPE *efxoutr_)
+ :Effect(insertion_, efxoutl_, efxoutr_, new FilterParams(0, 64, 64), 0),
+ Pvolume(110), Ppanning(64), Pdepth(0), Pampsns(90),
+ Pampsnsinv(0), Pampsmooth(60),
+ filterl(NULL), filterr(NULL)
{
setpreset(Ppreset);
cleanup();
-};
+}
DynamicFilter::~DynamicFilter()
{
delete filterpars;
delete filterl;
delete filterr;
-};
+}
/*
* Apply the effect
*/
-void DynamicFilter::out(REALTYPE *smpsl,REALTYPE *smpsr)
+void DynamicFilter::out(REALTYPE *smpsl, REALTYPE *smpsr)
{
int i;
- if (filterpars->changed) {
- filterpars->changed=false;
+ if(filterpars->changed) {
+ filterpars->changed = false;
cleanup();
- };
+ }
- REALTYPE lfol,lfor;
- lfo.effectlfoout(&lfol,&lfor);
- lfol*=depth*5.0;
- lfor*=depth*5.0;
- REALTYPE freq=filterpars->getfreq();
- REALTYPE q=filterpars->getq();
+ REALTYPE lfol, lfor;
+ lfo.effectlfoout(&lfol, &lfor);
+ lfol *= depth * 5.0;
+ lfor *= depth * 5.0;
+ REALTYPE freq = filterpars->getfreq();
+ REALTYPE q = filterpars->getq();
- for (i=0;igetrealfreq(freq+lfol+rms);
- REALTYPE frr=filterr->getrealfreq(freq+lfor+rms);
+ REALTYPE frl = filterl->getrealfreq(freq + lfol + rms);
+ REALTYPE frr = filterr->getrealfreq(freq + lfor + rms);
- filterl->setfreq_and_q(frl,q);
- filterr->setfreq_and_q(frr,q);
+ filterl->setfreq_and_q(frl, q);
+ filterr->setfreq_and_q(frr, q);
filterl->filterout(efxoutl);
filterr->filterout(efxoutr);
//panning
- for (i=0;iPdepth=Pdepth;
- depth=pow((Pdepth/127.0),2.0);
-};
+ this->Pdepth = Pdepth;
+ depth = pow((Pdepth / 127.0), 2.0);
+}
void DynamicFilter::setvolume(const unsigned char &Pvolume)
{
- this->Pvolume=Pvolume;
- outvolume=Pvolume/127.0;
- if (insertion==0) volume=1.0;
- else volume=outvolume;
-};
+ this->Pvolume = Pvolume;
+ outvolume = Pvolume / 127.0;
+ if(insertion == 0)
+ volume = 1.0;
+ else
+ volume = outvolume;
+}
void DynamicFilter::setpanning(const unsigned char &Ppanning)
{
- this->Ppanning=Ppanning;
- panning=Ppanning/127.0;
-};
+ this->Ppanning = Ppanning;
+ panning = Ppanning / 127.0;
+}
void DynamicFilter::setampsns(const unsigned char &Pampsns)
{
- ampsns=pow(Pampsns/127.0,2.5)*10.0;
- if (Pampsnsinv!=0) ampsns=-ampsns;
- ampsmooth=exp(-Pampsmooth/127.0*10.0)*0.99;
- this->Pampsns=Pampsns;
-};
+ ampsns = pow(Pampsns / 127.0, 2.5) * 10.0;
+ if(Pampsnsinv != 0)
+ ampsns = -ampsns;
+ ampsmooth = exp(-Pampsmooth / 127.0 * 10.0) * 0.99;
+ this->Pampsns = Pampsns;
+}
void DynamicFilter::reinitfilter()
{
- if (filterl!=NULL) delete(filterl);
- if (filterr!=NULL) delete(filterr);
- filterl=new Filter(filterpars);
- filterr=new Filter(filterpars);
-};
+ if(filterl != NULL)
+ delete (filterl);
+ if(filterr != NULL)
+ delete (filterr);
+ filterl = new Filter(filterpars);
+ filterr = new Filter(filterpars);
+}
void DynamicFilter::setpreset(unsigned char npreset)
{
- const int PRESET_SIZE=10;
- const int NUM_PRESETS=5;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE]={
+ const int PRESET_SIZE = 10;
+ const int NUM_PRESETS = 5;
+ unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//WahWah
- {110,64,80,0,0,64,0,90,0,60},
+ {110, 64, 80, 0, 0, 64, 0, 90, 0, 60},
//AutoWah
- {110,64,70,0,0,80,70,0,0,60},
+ {110, 64, 70, 0, 0, 80, 70, 0, 0, 60},
//Sweep
- {100,64,30,0,0,50,80,0,0,60},
+ {100, 64, 30, 0, 0, 50, 80, 0, 0, 60},
//VocalMorph1
- {110,64,80,0,0,64,0,64,0,60},
+ {110, 64, 80, 0, 0, 64, 0, 64, 0, 60},
//VocalMorph1
- {127,64,50,0,0,96,64,0,0,60}
+ {127, 64, 50, 0, 0, 96, 64, 0, 0, 60}
};
- if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1;
- for (int n=0;n= NUM_PRESETS)
+ npreset = NUM_PRESETS - 1;
+ for(int n = 0; n < PRESET_SIZE; n++)
+ changepar(n, presets[npreset][n]);
filterpars->defaults();
- switch (npreset) {
+ switch(npreset) {
case 0:
- filterpars->Pcategory=0;
- filterpars->Ptype=2;
- filterpars->Pfreq=45;
- filterpars->Pq=64;
- filterpars->Pstages=1;
- filterpars->Pgain=64;
+ filterpars->Pcategory = 0;
+ filterpars->Ptype = 2;
+ filterpars->Pfreq = 45;
+ filterpars->Pq = 64;
+ filterpars->Pstages = 1;
+ filterpars->Pgain = 64;
break;
case 1:
- filterpars->Pcategory=2;
- filterpars->Ptype=0;
- filterpars->Pfreq=72;
- filterpars->Pq=64;
- filterpars->Pstages=0;
- filterpars->Pgain=64;
+ filterpars->Pcategory = 2;
+ filterpars->Ptype = 0;
+ filterpars->Pfreq = 72;
+ filterpars->Pq = 64;
+ filterpars->Pstages = 0;
+ filterpars->Pgain = 64;
break;
case 2:
- filterpars->Pcategory=0;
- filterpars->Ptype=4;
- filterpars->Pfreq=64;
- filterpars->Pq=64;
- filterpars->Pstages=2;
- filterpars->Pgain=64;
+ filterpars->Pcategory = 0;
+ filterpars->Ptype = 4;
+ filterpars->Pfreq = 64;
+ filterpars->Pq = 64;
+ filterpars->Pstages = 2;
+ filterpars->Pgain = 64;
break;
case 3:
- filterpars->Pcategory=1;
- filterpars->Ptype=0;
- filterpars->Pfreq=50;
- filterpars->Pq=70;
- filterpars->Pstages=1;
- filterpars->Pgain=64;
+ filterpars->Pcategory = 1;
+ filterpars->Ptype = 0;
+ filterpars->Pfreq = 50;
+ filterpars->Pq = 70;
+ filterpars->Pstages = 1;
+ filterpars->Pgain = 64;
- filterpars->Psequencesize=2;
+ filterpars->Psequencesize = 2;
// "I"
- filterpars->Pvowels[0].formants[0].freq=34;
- filterpars->Pvowels[0].formants[0].amp=127;
- filterpars->Pvowels[0].formants[0].q=64;
- filterpars->Pvowels[0].formants[1].freq=99;
- filterpars->Pvowels[0].formants[1].amp=122;
- filterpars->Pvowels[0].formants[1].q=64;
- filterpars->Pvowels[0].formants[2].freq=108;
- filterpars->Pvowels[0].formants[2].amp=112;
- filterpars->Pvowels[0].formants[2].q=64;
+ filterpars->Pvowels[0].formants[0].freq = 34;
+ filterpars->Pvowels[0].formants[0].amp = 127;
+ filterpars->Pvowels[0].formants[0].q = 64;
+ filterpars->Pvowels[0].formants[1].freq = 99;
+ filterpars->Pvowels[0].formants[1].amp = 122;
+ filterpars->Pvowels[0].formants[1].q = 64;
+ filterpars->Pvowels[0].formants[2].freq = 108;
+ filterpars->Pvowels[0].formants[2].amp = 112;
+ filterpars->Pvowels[0].formants[2].q = 64;
// "A"
- filterpars->Pvowels[1].formants[0].freq=61;
- filterpars->Pvowels[1].formants[0].amp=127;
- filterpars->Pvowels[1].formants[0].q=64;
- filterpars->Pvowels[1].formants[1].freq=71;
- filterpars->Pvowels[1].formants[1].amp=121;
- filterpars->Pvowels[1].formants[1].q=64;
- filterpars->Pvowels[1].formants[2].freq=99;
- filterpars->Pvowels[1].formants[2].amp=117;
- filterpars->Pvowels[1].formants[2].q=64;
+ filterpars->Pvowels[1].formants[0].freq = 61;
+ filterpars->Pvowels[1].formants[0].amp = 127;
+ filterpars->Pvowels[1].formants[0].q = 64;
+ filterpars->Pvowels[1].formants[1].freq = 71;
+ filterpars->Pvowels[1].formants[1].amp = 121;
+ filterpars->Pvowels[1].formants[1].q = 64;
+ filterpars->Pvowels[1].formants[2].freq = 99;
+ filterpars->Pvowels[1].formants[2].amp = 117;
+ filterpars->Pvowels[1].formants[2].q = 64;
break;
case 4:
- filterpars->Pcategory=1;
- filterpars->Ptype=0;
- filterpars->Pfreq=64;
- filterpars->Pq=70;
- filterpars->Pstages=1;
- filterpars->Pgain=64;
+ filterpars->Pcategory = 1;
+ filterpars->Ptype = 0;
+ filterpars->Pfreq = 64;
+ filterpars->Pq = 70;
+ filterpars->Pstages = 1;
+ filterpars->Pgain = 64;
- filterpars->Psequencesize=2;
- filterpars->Pnumformants=2;
- filterpars->Pvowelclearness=0;
+ filterpars->Psequencesize = 2;
+ filterpars->Pnumformants = 2;
+ filterpars->Pvowelclearness = 0;
- filterpars->Pvowels[0].formants[0].freq=70;
- filterpars->Pvowels[0].formants[0].amp=127;
- filterpars->Pvowels[0].formants[0].q=64;
- filterpars->Pvowels[0].formants[1].freq=80;
- filterpars->Pvowels[0].formants[1].amp=122;
- filterpars->Pvowels[0].formants[1].q=64;
+ filterpars->Pvowels[0].formants[0].freq = 70;
+ filterpars->Pvowels[0].formants[0].amp = 127;
+ filterpars->Pvowels[0].formants[0].q = 64;
+ filterpars->Pvowels[0].formants[1].freq = 80;
+ filterpars->Pvowels[0].formants[1].amp = 122;
+ filterpars->Pvowels[0].formants[1].q = 64;
- filterpars->Pvowels[1].formants[0].freq=20;
- filterpars->Pvowels[1].formants[0].amp=127;
- filterpars->Pvowels[1].formants[0].q=64;
- filterpars->Pvowels[1].formants[1].freq=100;
- filterpars->Pvowels[1].formants[1].amp=121;
- filterpars->Pvowels[1].formants[1].q=64;
+ filterpars->Pvowels[1].formants[0].freq = 20;
+ filterpars->Pvowels[1].formants[0].amp = 127;
+ filterpars->Pvowels[1].formants[0].q = 64;
+ filterpars->Pvowels[1].formants[1].freq = 100;
+ filterpars->Pvowels[1].formants[1].amp = 121;
+ filterpars->Pvowels[1].formants[1].q = 64;
break;
- };
+ }
// for (int i=0;i<5;i++){
// printf("freq=%d amp=%d q=%d\n",filterpars->Pvowels[0].formants[i].freq,filterpars->Pvowels[0].formants[i].amp,filterpars->Pvowels[0].formants[i].q);
// };
- if (insertion==0) changepar(0,presets[npreset][0]/2);//lower the volume if this is system effect
- Ppreset=npreset;
+ if(insertion == 0)
+ changepar(0, presets[npreset][0] / 2); //lower the volume if this is system effect
+ Ppreset = npreset;
reinitfilter();
-};
+}
-void DynamicFilter::changepar(const int &npar,const unsigned char &value)
+void DynamicFilter::changepar(const int &npar, const unsigned char &value)
{
- switch (npar) {
+ switch(npar) {
case 0:
setvolume(value);
break;
@@ -271,19 +280,19 @@ void DynamicFilter::changepar(const int &npar,const unsigned char &value)
setpanning(value);
break;
case 2:
- lfo.Pfreq=value;
+ lfo.Pfreq = value;
lfo.updateparams();
break;
case 3:
- lfo.Prandomness=value;
+ lfo.Prandomness = value;
lfo.updateparams();
break;
case 4:
- lfo.PLFOtype=value;
+ lfo.PLFOtype = value;
lfo.updateparams();
break;
case 5:
- lfo.Pstereo=value;
+ lfo.Pstereo = value;
lfo.updateparams();
break;
case 6:
@@ -293,52 +302,51 @@ void DynamicFilter::changepar(const int &npar,const unsigned char &value)
setampsns(value);
break;
case 8:
- Pampsnsinv=value;
+ Pampsnsinv = value;
setampsns(Pampsns);
break;
case 9:
- Pampsmooth=value;
+ Pampsmooth = value;
setampsns(Pampsns);
break;
- };
-};
+ }
+}
-unsigned char DynamicFilter::getpar(const int &npar)const
+unsigned char DynamicFilter::getpar(const int &npar) const
{
- switch (npar) {
+ switch(npar) {
case 0:
- return(Pvolume);
+ return Pvolume;
break;
case 1:
- return(Ppanning);
+ return Ppanning;
break;
case 2:
- return(lfo.Pfreq);
+ return lfo.Pfreq;
break;
case 3:
- return(lfo.Prandomness);
+ return lfo.Prandomness;
break;
case 4:
- return(lfo.PLFOtype);
+ return lfo.PLFOtype;
break;
case 5:
- return(lfo.Pstereo);
+ return lfo.Pstereo;
break;
case 6:
- return(Pdepth);
+ return Pdepth;
break;
case 7:
- return(Pampsns);
+ return Pampsns;
break;
case 8:
- return(Pampsnsinv);
+ return Pampsnsinv;
break;
case 9:
- return(Pampsmooth);
+ return Pampsmooth;
break;
default:
- return (0);
- };
-
-};
+ return 0;
+ }
+}
diff --git a/plugins/zynaddsubfx/src/Effects/DynamicFilter.h b/plugins/zynaddsubfx/src/Effects/DynamicFilter.h
index 9c547c332..2bb5fcd9b 100644
--- a/plugins/zynaddsubfx/src/Effects/DynamicFilter.h
+++ b/plugins/zynaddsubfx/src/Effects/DynamicFilter.h
@@ -30,42 +30,42 @@
/**DynamicFilter Effect*/
class DynamicFilter:public Effect
{
-public:
- DynamicFilter(int insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
- ~DynamicFilter();
- void out(REALTYPE *smpsl,REALTYPE *smpsr);
+ public:
+ DynamicFilter(int insetion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ ~DynamicFilter();
+ void out(REALTYPE *smpsl, REALTYPE *smpsr);
- void setpreset(unsigned char npreset);
- void changepar(const int &npar,const unsigned char &value);
- unsigned char getpar(const int &npar)const;
- void cleanup();
+ void setpreset(unsigned char npreset);
+ void changepar(const int &npar, const unsigned char &value);
+ unsigned char getpar(const int &npar) const;
+ void cleanup();
// void setdryonly();
-private:
- //Parametrii DynamicFilter
- EffectLFO lfo;//lfo-ul DynamicFilter
- unsigned char Pvolume;
- unsigned char Ppanning;
- unsigned char Pdepth;/**
#include "EQ.h"
-EQ::EQ(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
- :Effect(insertion_,efxoutl_,efxoutr_,NULL,0)
+EQ::EQ(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_)
+ :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0)
{
-
- for (int i=0;icleanup();
filter[i].r->cleanup();
- };
-};
+ }
+}
/*
* Effect output
*/
-void EQ::out(REALTYPE *smpsl,REALTYPE *smpsr)
+void EQ::out(REALTYPE *smpsl, REALTYPE *smpsr)
{
int i;
- for (i=0;ifilterout(efxoutl);
filter[i].r->filterout(efxoutr);
- };
-};
+ }
+}
/*
@@ -84,131 +83,138 @@ void EQ::out(REALTYPE *smpsl,REALTYPE *smpsr)
*/
void EQ::setvolume(const unsigned char &Pvolume)
{
- this->Pvolume=Pvolume;
+ this->Pvolume = Pvolume;
- outvolume=pow(0.005,(1.0-Pvolume/127.0))*10.0;
- if (insertion==0) {
- volume=1.0;
- } else {
- volume=outvolume;
- };
-
-};
+ outvolume = pow(0.005, (1.0 - Pvolume / 127.0)) * 10.0;
+ if(insertion == 0)
+ volume = 1.0;
+ else
+ volume = outvolume;
+ ;
+}
void EQ::setpreset(unsigned char npreset)
{
- const int PRESET_SIZE=1;
- const int NUM_PRESETS=2;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE]={
+ const int PRESET_SIZE = 1;
+ const int NUM_PRESETS = 2;
+ unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//EQ 1
{67},
//EQ 2
{67}
};
- if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1;
- for (int n=0;n= NUM_PRESETS)
+ npreset = NUM_PRESETS - 1;
+ for(int n = 0; n < PRESET_SIZE; n++)
+ changepar(n, presets[npreset][n]);
+ Ppreset = npreset;
+}
-void EQ::changepar(const int &npar,const unsigned char &value)
+void EQ::changepar(const int &npar, const unsigned char &value)
{
- switch (npar) {
+ switch(npar) {
case 0:
setvolume(value);
break;
- };
- if (npar<10) return;
+ }
+ if(npar < 10)
+ return;
- int nb=(npar-10)/5;//number of the band (filter)
- if (nb>=MAX_EQ_BANDS) return;
- int bp=npar%5;//band paramenter
+ int nb = (npar - 10) / 5; //number of the band (filter)
+ if(nb >= MAX_EQ_BANDS)
+ return;
+ int bp = npar % 5; //band paramenter
REALTYPE tmp;
- switch (bp) {
+ switch(bp) {
case 0:
- filter[nb].Ptype=value;
- if (value>9) filter[nb].Ptype=0;//has to be changed if more filters will be added
- if (filter[nb].Ptype!=0) {
- filter[nb].l->settype(value-1);
- filter[nb].r->settype(value-1);
- };
+ filter[nb].Ptype = value;
+ if(value > 9)
+ filter[nb].Ptype = 0; //has to be changed if more filters will be added
+ if(filter[nb].Ptype != 0) {
+ filter[nb].l->settype(value - 1);
+ filter[nb].r->settype(value - 1);
+ }
break;
case 1:
- filter[nb].Pfreq=value;
- tmp=600.0*pow(30.0,(value-64.0)/64.0);
+ filter[nb].Pfreq = value;
+ tmp = 600.0 * pow(30.0, (value - 64.0) / 64.0);
filter[nb].l->setfreq(tmp);
filter[nb].r->setfreq(tmp);
break;
case 2:
- filter[nb].Pgain=value;
- tmp=30.0*(value-64.0)/64.0;
+ filter[nb].Pgain = value;
+ tmp = 30.0 * (value - 64.0) / 64.0;
filter[nb].l->setgain(tmp);
filter[nb].r->setgain(tmp);
break;
case 3:
- filter[nb].Pq=value;
- tmp=pow(30.0,(value-64.0)/64.0);
+ filter[nb].Pq = value;
+ tmp = pow(30.0, (value - 64.0) / 64.0);
filter[nb].l->setq(tmp);
filter[nb].r->setq(tmp);
break;
case 4:
- filter[nb].Pstages=value;
- if (value>=MAX_FILTER_STAGES) filter[nb].Pstages=MAX_FILTER_STAGES-1;
+ filter[nb].Pstages = value;
+ if(value >= MAX_FILTER_STAGES)
+ filter[nb].Pstages = MAX_FILTER_STAGES - 1;
filter[nb].l->setstages(value);
filter[nb].r->setstages(value);
break;
- };
-};
+ }
+}
-unsigned char EQ::getpar(const int &npar)const
+unsigned char EQ::getpar(const int &npar) const
{
- switch (npar) {
+ switch(npar) {
case 0:
- return(Pvolume);
+ return Pvolume;
break;
- };
+ }
- if (npar<10) return(0);
+ if(npar < 10)
+ return 0;
- int nb=(npar-10)/5;//number of the band (filter)
- if (nb>=MAX_EQ_BANDS) return(0);
- int bp=npar%5;//band paramenter
- switch (bp) {
+ int nb = (npar - 10) / 5; //number of the band (filter)
+ if(nb >= MAX_EQ_BANDS)
+ return 0;
+ int bp = npar % 5; //band paramenter
+ switch(bp) {
case 0:
- return(filter[nb].Ptype);
+ return filter[nb].Ptype;
break;
case 1:
- return(filter[nb].Pfreq);
+ return filter[nb].Pfreq;
break;
case 2:
- return(filter[nb].Pgain);
+ return filter[nb].Pgain;
break;
case 3:
- return(filter[nb].Pq);
+ return filter[nb].Pq;
break;
case 4:
- return(filter[nb].Pstages);
+ return filter[nb].Pstages;
break;
- };
+ }
- return(0);//in case of bogus parameter number
-};
+ return 0; //in case of bogus parameter number
+}
REALTYPE EQ::getfreqresponse(REALTYPE freq)
{
- REALTYPE resp=1.0;
-
- for (int i=0;iH(freq);
- };
- return(rap2dB(resp*outvolume));
-};
+ REALTYPE resp = 1.0;
+ for(int i = 0; i < MAX_EQ_BANDS; i++) {
+ if(filter[i].Ptype == 0)
+ continue;
+ resp *= filter[i].l->H(freq);
+ }
+ return rap2dB(resp * outvolume);
+}
diff --git a/plugins/zynaddsubfx/src/Effects/EQ.h b/plugins/zynaddsubfx/src/Effects/EQ.h
index 810dd6ee6..6f4130cd1 100644
--- a/plugins/zynaddsubfx/src/Effects/EQ.h
+++ b/plugins/zynaddsubfx/src/Effects/EQ.h
@@ -30,31 +30,29 @@
/**EQ Effect*/
class EQ:public Effect
{
-public:
- EQ(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
- ~EQ();
- void out(REALTYPE *smpsl,REALTYPE *smpr);
- void setpreset(unsigned char npreset);
- void changepar(const int &npar,const unsigned char &value);
- unsigned char getpar(const int &npar)const;
- void cleanup();
- REALTYPE getfreqresponse(REALTYPE freq);
-private:
- //Parameters
- unsigned char Pvolume;/**
#include "Echo.h"
-Echo::Echo(const int & insertion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_)
- : Effect(insertion_,efxoutl_,efxoutr_,NULL,0),
- Pvolume(50),Ppanning(64),//Pdelay(60),
- Plrdelay(100),Plrcross(100),Pfb(40),Phidamp(60),
- lrdelay(0),delaySample(1),old(0.0)
+Echo::Echo(const int &insertion_,
+ REALTYPE *const efxoutl_,
+ REALTYPE *const efxoutr_)
+ :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0),
+ Pvolume(50), Ppanning(64), //Pdelay(60),
+ Plrdelay(100), Plrcross(100), Pfb(40), Phidamp(60),
+ lrdelay(0), delaySample(1), old(0.0)
{
setpreset(Ppreset);
}
@@ -42,7 +44,7 @@ void Echo::cleanup()
{
delaySample.l().clear();
delaySample.r().clear();
- old=Stereo(0.0);
+ old = Stereo(0.0);
}
@@ -52,85 +54,91 @@ void Echo::cleanup()
void Echo::initdelays()
{
/**\todo make this adjust insted of destroy old delays*/
- kl=0;
- kr=0;
- dl=(int)(1+delay.getiVal()*SAMPLE_RATE-lrdelay);
- if (dl<1) dl=1;
- dr=(int)(1+delay.getiVal()*SAMPLE_RATE+lrdelay);
- if (dr<1) dr=1;
+ kl = 0;
+ kr = 0;
+ dl = (int)(1 + delay.getiVal() * SAMPLE_RATE - lrdelay);
+ if(dl < 1)
+ dl = 1;
+ dr = (int)(1 + delay.getiVal() * SAMPLE_RATE + lrdelay);
+ if(dr < 1)
+ dr = 1;
- delaySample.l()=AuSample(dl);
- delaySample.r()=AuSample(dr);
+ delaySample.l() = AuSample(dl);
+ delaySample.r() = AuSample(dr);
- old=Stereo(0.0);
+ old = Stereo(0.0);
}
/*
* Effect output
*/
-void Echo::out(REALTYPE *const smpsl,REALTYPE *const smpsr)
+void Echo::out(REALTYPE *const smpsl, REALTYPE *const smpsr)
{
- Stereo input(AuSample(SOUND_BUFFER_SIZE,smpsl),AuSample(SOUND_BUFFER_SIZE,smpsr));
+ Stereo input(AuSample(SOUND_BUFFER_SIZE, smpsl), AuSample(
+ SOUND_BUFFER_SIZE,
+ smpsr));
out(input);
}
void Echo::out(const Stereo &input)
{
//void Echo::out(const Stereo & input){ //ideal
- REALTYPE l,r,ldl,rdl;/**\todo move l+r->? ldl+rdl->?*/
+ REALTYPE l, r, ldl, rdl; /**\todo move l+r->? ldl+rdl->?*/
- for (int i=0;i=dl) kl=0;
- if (++kr>=dr) kr=0;
- };
+ delaySample.l()[kl] = ldl = ldl * hidamp + old.l() * (1.0 - hidamp);
+ delaySample.r()[kr] = rdl = rdl * hidamp + old.r() * (1.0 - hidamp);
+ old.l() = ldl;
+ old.r() = rdl;
+ if(++kl >= dl)
+ kl = 0;
+ if(++kr >= dr)
+ kr = 0;
+ }
}
/*
* Parameter control
*/
-void Echo::setvolume(const unsigned char & Pvolume)
+void Echo::setvolume(const unsigned char &Pvolume)
{
- this->Pvolume=Pvolume;
-
- if (insertion==0) {
- outvolume=pow(0.01,(1.0-Pvolume/127.0))*4.0;
- volume=1.0;
- } else {
- volume=outvolume=Pvolume/127.0;
- };
- if (Pvolume==0) cleanup();
+ this->Pvolume = Pvolume;
+ if(insertion == 0) {
+ outvolume = pow(0.01, (1.0 - Pvolume / 127.0)) * 4.0;
+ volume = 1.0;
+ }
+ else
+ volume = outvolume = Pvolume / 127.0;
+ ;
+ if(Pvolume == 0)
+ cleanup();
}
-void Echo::setpanning(const unsigned char & Ppanning)
+void Echo::setpanning(const unsigned char &Ppanning)
{
- this->Ppanning=Ppanning;
- panning=(Ppanning+0.5)/127.0;
+ this->Ppanning = Ppanning;
+ panning = (Ppanning + 0.5) / 127.0;
}
-void Echo::setdelay(const unsigned char & Pdelay)
+void Echo::setdelay(const unsigned char &Pdelay)
{
delay.setmVal(Pdelay);
//this->Pdelay=Pdelay;
@@ -138,71 +146,76 @@ void Echo::setdelay(const unsigned char & Pdelay)
initdelays();
}
-void Echo::setlrdelay(const unsigned char & Plrdelay)
+void Echo::setlrdelay(const unsigned char &Plrdelay)
{
REALTYPE tmp;
- this->Plrdelay=Plrdelay;
- tmp=(pow(2,fabs(Plrdelay-64.0)/64.0*9)-1.0)/1000.0*SAMPLE_RATE;
- if (Plrdelay<64.0) tmp=-tmp;
- lrdelay=(int) tmp;
+ this->Plrdelay = Plrdelay;
+ tmp =
+ (pow(2, fabs(Plrdelay - 64.0) / 64.0 * 9) - 1.0) / 1000.0 * SAMPLE_RATE;
+ if(Plrdelay < 64.0)
+ tmp = -tmp;
+ lrdelay = (int) tmp;
initdelays();
}
-void Echo::setlrcross(const unsigned char & Plrcross)
+void Echo::setlrcross(const unsigned char &Plrcross)
{
- this->Plrcross=Plrcross;
- lrcross=Plrcross/127.0*1.0;
+ this->Plrcross = Plrcross;
+ lrcross = Plrcross / 127.0 * 1.0;
}
-void Echo::setfb(const unsigned char & Pfb)
+void Echo::setfb(const unsigned char &Pfb)
{
- this->Pfb=Pfb;
- fb=Pfb/128.0;
+ this->Pfb = Pfb;
+ fb = Pfb / 128.0;
}
-void Echo::sethidamp(const unsigned char & Phidamp)
+void Echo::sethidamp(const unsigned char &Phidamp)
{
- this->Phidamp=Phidamp;
- hidamp=1.0-Phidamp/127.0;
+ this->Phidamp = Phidamp;
+ hidamp = 1.0 - Phidamp / 127.0;
}
void Echo::setpreset(unsigned char npreset)
{
/**\todo see if the preset array can be replaced with a struct or a class*/
- const int PRESET_SIZE=7;
- const int NUM_PRESETS=9;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE]={
+ const int PRESET_SIZE = 7;
+ const int NUM_PRESETS = 9;
+ unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
//Echo 1
- {67,64,35,64,30,59,0},
+ {67, 64, 35, 64, 30, 59, 0 },
//Echo 2
- {67,64,21,64,30,59,0},
+ {67, 64, 21, 64, 30, 59, 0 },
//Echo 3
- {67,75,60,64,30,59,10},
+ {67, 75, 60, 64, 30, 59, 10 },
//Simple Echo
- {67,60,44,64,30,0,0},
+ {67, 60, 44, 64, 30, 0, 0 },
//Canyon
- {67,60,102,50,30,82,48},
+ {67, 60, 102, 50, 30, 82, 48 },
//Panning Echo 1
- {67,64,44,17,0,82,24},
+ {67, 64, 44, 17, 0, 82, 24 },
//Panning Echo 2
- {81,60,46,118,100,68,18},
+ {81, 60, 46, 118, 100, 68, 18 },
//Panning Echo 3
- {81,60,26,100,127,67,36},
+ {81, 60, 26, 100, 127, 67, 36 },
//Feedback Echo
- {62,64,28,64,100,90,55}
+ {62, 64, 28, 64, 100, 90, 55 }
};
- if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1;
- for (int n=0;n= NUM_PRESETS)
+ npreset = NUM_PRESETS - 1;
+ for(int n = 0; n < PRESET_SIZE; n++)
+ changepar(n, presets[npreset][n]);
+ if(insertion)
+ setvolume(presets[npreset][0] / 2); //lower the volume if this is insertion effect
+ Ppreset = npreset;
}
-void Echo::changepar(const int & npar,const unsigned char & value)
+void Echo::changepar(const int &npar, const unsigned char &value)
{
- switch (npar) {
+ switch(npar) {
case 0:
setvolume(value);
break;
@@ -224,34 +237,34 @@ void Echo::changepar(const int & npar,const unsigned char & value)
case 6:
sethidamp(value);
break;
- };
+ }
}
-unsigned char Echo::getpar(const int & npar)const
+unsigned char Echo::getpar(const int &npar) const
{
- switch (npar) {
+ switch(npar) {
case 0:
- return(Pvolume);
+ return Pvolume;
break;
case 1:
- return(Ppanning);
+ return Ppanning;
break;
case 2:
- return(delay.getmVal());
+ return delay.getmVal();
break;
case 3:
- return(Plrdelay);
+ return Plrdelay;
break;
case 4:
- return(Plrcross);
+ return Plrcross;
break;
case 5:
- return(Pfb);
+ return Pfb;
break;
case 6:
- return(Phidamp);
+ return Phidamp;
break;
- };
- return(0);// in case of bogus parameter number
+ }
+ return 0; // in case of bogus parameter number
}
diff --git a/plugins/zynaddsubfx/src/Effects/Echo.h b/plugins/zynaddsubfx/src/Effects/Echo.h
index 5ed429609..4dbe40925 100644
--- a/plugins/zynaddsubfx/src/Effects/Echo.h
+++ b/plugins/zynaddsubfx/src/Effects/Echo.h
@@ -32,105 +32,107 @@
/**Echo Effect*/
class Echo:public Effect
{
-public:
+ public:
- /**
- * The Constructor For Echo
- * @param insertion_ integer to determine if Echo is an insertion effect
- * or not
- * @param efxoutl_ Effect out Left Channel
- * @param efxoutr_ Effect out Right Channel
- * @return An initialized Echo Object
- */
- Echo(const int & insertion_,REALTYPE *const efxoutl_,REALTYPE *const efxoutr_);
+ /**
+ * The Constructor For Echo
+ * @param insertion_ integer to determine if Echo is an insertion effect
+ * or not
+ * @param efxoutl_ Effect out Left Channel
+ * @param efxoutr_ Effect out Right Channel
+ * @return An initialized Echo Object
+ */
+ Echo(const int &insertion_,
+ REALTYPE *const efxoutl_,
+ REALTYPE *const efxoutr_);
- /**
- * The destructor
- */
- ~Echo();
+ /**
+ * The destructor
+ */
+ ~Echo();
- /**
- * Outputs the echo to efxoutl and efxoutr
- * @param smpsl Sample from Left channel
- * @param smpsr Sample from Right channel
- * \todo try to figure out if smpsl should be const *const
- * or not (It should be)
- */
- void out(REALTYPE *const smpsl,REALTYPE *const smpr);
- void out(const Stereo &input);
+ /**
+ * Outputs the echo to efxoutl and efxoutr
+ * @param smpsl Sample from Left channel
+ * @param smpsr Sample from Right channel
+ * \todo try to figure out if smpsl should be const *const
+ * or not (It should be)
+ */
+ void out(REALTYPE *const smpsl, REALTYPE *const smpr);
+ void out(const Stereo &input);
- /**
- * Sets the state of Echo to the specified preset
- * @param npreset number of chosen preset
- */
- void setpreset(unsigned char npreset);
+ /**
+ * Sets the state of Echo to the specified preset
+ * @param npreset number of chosen preset
+ */
+ void setpreset(unsigned char npreset);
- /**
- * Sets the value of the chosen variable
- *
- * The possible parameters are:
- * -# Volume
- * -# Panning
- * -# Delay
- * -# L/R Delay
- * -# L/R Crossover
- * -# Feedback
- * -# Dampening
- * @param npar number of chosen parameter
- * @param value the new value
- */
- void changepar(const int & npar,const unsigned char & value);
+ /**
+ * Sets the value of the chosen variable
+ *
+ * The possible parameters are:
+ * -# Volume
+ * -# Panning
+ * -# Delay
+ * -# L/R Delay
+ * -# L/R Crossover
+ * -# Feedback
+ * -# Dampening
+ * @param npar number of chosen parameter
+ * @param value the new value
+ */
+ void changepar(const int &npar, const unsigned char &value);
- /**
- * Gets the specified parameter
- *
- * The possible parameters are
- * -# Volume
- * -# Panning
- * -# Delay
- * -# L/R Delay
- * -# L/R Crossover
- * -# Feedback
- * -# Dampening
- * @param npar number of chosen parameter
- * @return value of parameter
- */
- unsigned char getpar(const int & npar)const;
+ /**
+ * Gets the specified parameter
+ *
+ * The possible parameters are
+ * -# Volume
+ * -# Panning
+ * -# Delay
+ * -# L/R Delay
+ * -# L/R Crossover
+ * -# Feedback
+ * -# Dampening
+ * @param npar number of chosen parameter
+ * @return value of parameter
+ */
+ unsigned char getpar(const int &npar) const;
- int getnumparams();
+ int getnumparams();
- /**Zeros out the state of the Echo*/
- void cleanup();
+ /**Zeros out the state of the Echo*/
+ void cleanup();
- /**\todo This function needs to be implemented or the prototype should be removed*/
- void setdryonly();
-private:
- //Parameters
- char Pvolume;/**<#1 Volume or Dry/Wetness*/
- char Ppanning;/**<#2 Panning*/
- DelayCtl delay;/**<#3 Delay of the Echo*/
- char Plrdelay;/**<#4 L/R delay difference*/
- char Plrcross;/**<#5 L/R Mixing*/
- char Pfb;/**<#6Feedback*/
- char Phidamp;/**<#7Dampening of the Echo*/
+ /**\todo This function needs to be implemented or the prototype should be removed*/
+ void setdryonly();
+ private:
+ //Parameters
+ char Pvolume; /**<#1 Volume or Dry/Wetness*/
+ char Ppanning; /**<#2 Panning*/
+ DelayCtl delay; /**<#3 Delay of the Echo*/
+ char Plrdelay; /**<#4 L/R delay difference*/
+ char Plrcross; /**<#5 L/R Mixing*/
+ char Pfb; /**<#6Feedback*/
+ char Phidamp; /**<#7Dampening of the Echo*/
- void setvolume(const unsigned char & Pvolume);
- void setpanning(const unsigned char & Ppanning);
- void setdelay(const unsigned char & Pdelay);
- void setlrdelay(const unsigned char & Plrdelay);
- void setlrcross(const unsigned char & Plrcross);
- void setfb(const unsigned char & Pfb);
- void sethidamp(const unsigned char & Phidamp);
+ void setvolume(const unsigned char &Pvolume);
+ void setpanning(const unsigned char &Ppanning);
+ void setdelay(const unsigned char &Pdelay);
+ void setlrdelay(const unsigned char &Plrdelay);
+ void setlrcross(const unsigned char &Plrcross);
+ void setfb(const unsigned char &Pfb);
+ void sethidamp(const unsigned char &Phidamp);
- //Real Parameters
- REALTYPE panning,lrcross,fb,hidamp; //needs better names
- int dl,dr,lrdelay; //needs better names
+ //Real Parameters
+ REALTYPE panning, lrcross, fb, hidamp; //needs better names
+ int dl, dr, lrdelay; //needs better names
- void initdelays();
- Stereo delaySample;
- Stereo old;
+ void initdelays();
+ Stereo delaySample;
+ Stereo old;
- int kl,kr;
+ int kl, kr;
};
#endif
diff --git a/plugins/zynaddsubfx/src/Effects/Effect.cpp b/plugins/zynaddsubfx/src/Effects/Effect.cpp
index b0b4dac30..0a17ebdc4 100644
--- a/plugins/zynaddsubfx/src/Effects/Effect.cpp
+++ b/plugins/zynaddsubfx/src/Effects/Effect.cpp
@@ -23,8 +23,9 @@
#include "Effect.h"
-Effect::Effect(bool insertion_,REALTYPE *const efxoutl_,
- REALTYPE *const efxoutr_,FilterParams *filterpars_,
- const unsigned char & Ppreset_)
- :Ppreset(Ppreset_),efxoutl(efxoutl_),efxoutr(efxoutr_),
- filterpars(filterpars_),insertion(insertion_) {}
+Effect::Effect(bool insertion_, REALTYPE *const efxoutl_,
+ REALTYPE *const efxoutr_, FilterParams *filterpars_,
+ const unsigned char &Ppreset_)
+ :Ppreset(Ppreset_), efxoutl(efxoutl_), efxoutr(efxoutr_),
+ filterpars(filterpars_), insertion(insertion_) {}
+
diff --git a/plugins/zynaddsubfx/src/Effects/Effect.h b/plugins/zynaddsubfx/src/Effects/Effect.h
index 0da3d8317..7f769ead8 100644
--- a/plugins/zynaddsubfx/src/Effects/Effect.h
+++ b/plugins/zynaddsubfx/src/Effects/Effect.h
@@ -31,71 +31,71 @@
/**this class is inherited by the all effects(Reverb, Echo, ..)*/
class Effect
{
-public:
- /**
- * Effect Constructor
- * @param insertion_ 1 when it is an insertion Effect and 0 when it
- * is not an insertion Effect
- * @param efxoutl_ Effect output buffer Left channel
- * @param efxoutr_ Effect output buffer Right channel
- * @param filterpars_ pointer to FilterParams array
- * @param Ppreset_ chosen preset
- * @return Initialized Effect object*/
- Effect(bool insertion_,REALTYPE *const efxoutl_,
- REALTYPE *const efxoutr_,FilterParams *filterpars_,
- const unsigned char & Ppreset_);
- /**Deconstructor
- *
- * Deconstructs the Effect and releases any resouces that it has
- * allocated for itself*/
- virtual ~Effect() {};
- /**
- * Choose a preset
- * @param npreset number of chosen preset*/
- virtual void setpreset(unsigned char npreset)=0;
- /**Change parameter npar to value
- * @param npar chosen parameter
- * @param value chosen new value*/
- virtual void changepar(const int &npar,const unsigned char &value)=0;
- /**Get the value of parameter npar
- * @param npar chosen parameter
- * @return the value of the parameter in an unsigned char or 0 if it
- * does not exist*/
- virtual unsigned char getpar(const int &npar)const=0;
- /**Output result of effect based on the given buffers
- *
- * This method should result in the effect generating its results
- * and placing them into the efxoutl and efxoutr buffers.
- * Every Effect should overide this method.
- *
- * @param smpsl Input buffer for the Left channel
- * @param smpsr Input buffer for the Right channel
- */
- virtual void out(REALTYPE *const smpsl,REALTYPE *const smpsr)=0;
- /**Reset the state of the effect*/
- virtual void cleanup() {};
- /**This is only used for EQ (for user interface)*/
- virtual REALTYPE getfreqresponse(REALTYPE freq) {
- return (0);
- };
+ public:
+ /**
+ * Effect Constructor
+ * @param insertion_ 1 when it is an insertion Effect and 0 when it
+ * is not an insertion Effect
+ * @param efxoutl_ Effect output buffer Left channel
+ * @param efxoutr_ Effect output buffer Right channel
+ * @param filterpars_ pointer to FilterParams array
+ * @param Ppreset_ chosen preset
+ * @return Initialized Effect object*/
+ Effect(bool insertion_, REALTYPE *const efxoutl_,
+ REALTYPE *const efxoutr_, FilterParams *filterpars_,
+ const unsigned char &Ppreset_);
+ /**Deconstructor
+ *
+ * Deconstructs the Effect and releases any resouces that it has
+ * allocated for itself*/
+ virtual ~Effect() {}
+ /**
+ * Choose a preset
+ * @param npreset number of chosen preset*/
+ virtual void setpreset(unsigned char npreset) = 0;
+ /**Change parameter npar to value
+ * @param npar chosen parameter
+ * @param value chosen new value*/
+ virtual void changepar(const int &npar, const unsigned char &value) = 0;
+ /**Get the value of parameter npar
+ * @param npar chosen parameter
+ * @return the value of the parameter in an unsigned char or 0 if it
+ * does not exist*/
+ virtual unsigned char getpar(const int &npar) const = 0;
+ /**Output result of effect based on the given buffers
+ *
+ * This method should result in the effect generating its results
+ * and placing them into the efxoutl and efxoutr buffers.
+ * Every Effect should overide this method.
+ *
+ * @param smpsl Input buffer for the Left channel
+ * @param smpsr Input buffer for the Right channel
+ */
+ virtual void out(REALTYPE *const smpsl, REALTYPE *const smpsr) = 0;
+ /**Reset the state of the effect*/
+ virtual void cleanup() {}
+ /**This is only used for EQ (for user interface)*/
+ virtual REALTYPE getfreqresponse(REALTYPE freq) {
+ return 0;
+ }
- unsigned char Ppreset;/**0.49999999) incx=0.499999999; //Limit the Frequency
+ REALTYPE lfofreq = (pow(2, Pfreq / 127.0 * 10.0) - 1.0) * 0.03;
+ incx = fabs(lfofreq) * (REALTYPE)SOUND_BUFFER_SIZE / (REALTYPE)SAMPLE_RATE;
+ if(incx > 0.49999999)
+ incx = 0.499999999; //Limit the Frequency
- lfornd=Prandomness/127.0;
- if (lfornd<0.0) lfornd=0.0;
- else if (lfornd>1.0) lfornd=1.0;
+ lfornd = Prandomness / 127.0;
+ if(lfornd < 0.0)
+ lfornd = 0.0;
+ else
+ if(lfornd > 1.0)
+ lfornd = 1.0;
- if (PLFOtype>1) PLFOtype=1;//this has to be updated if more lfo's are added
- lfotype=PLFOtype;
+ if(PLFOtype > 1)
+ PLFOtype = 1; //this has to be updated if more lfo's are added
+ lfotype = PLFOtype;
- xr=fmod(xl+(Pstereo-64.0)/127.0+1.0,1.0);
-};
+ xr = fmod(xl + (Pstereo - 64.0) / 127.0 + 1.0, 1.0);
+}
/*
@@ -74,44 +78,50 @@ void EffectLFO::updateparams()
REALTYPE EffectLFO::getlfoshape(REALTYPE x)
{
REALTYPE out;
- switch (lfotype) {
+ switch(lfotype) {
case 1: //EffectLFO_TRIANGLE
- if ((x>0.0)&&(x<0.25)) out=4.0*x;
- else if ((x>0.25)&&(x<0.75)) out=2-4*x;
- else out=4.0*x-4.0;
+ if((x > 0.0) && (x < 0.25))
+ out = 4.0 * x;
+ else
+ if((x > 0.25) && (x < 0.75))
+ out = 2 - 4 * x;
+ else
+ out = 4.0 * x - 4.0;
break;
- /**\todo more to be added here; also ::updateparams() need to be updated (to allow more lfotypes)*/
+ /**\todo more to be added here; also ::updateparams() need to be updated (to allow more lfotypes)*/
default:
- out=cos(x*2*PI);//EffectLFO_SINE
- };
- return(out);
-};
+ out = cos(x * 2 * PI); //EffectLFO_SINE
+ }
+ return out;
+}
/*
* LFO output
*/
-void EffectLFO::effectlfoout(REALTYPE *outl,REALTYPE *outr)
+void EffectLFO::effectlfoout(REALTYPE *outl, REALTYPE *outr)
{
REALTYPE out;
- out=getlfoshape(xl);
- if ((lfotype==0)||(lfotype==1)) out*=(ampl1+xl*(ampl2-ampl1));
- xl+=incx;
- if (xl>1.0) {
- xl-=1.0;
- ampl1=ampl2;
- ampl2=(1.0-lfornd)+lfornd*RND;
- };
- *outl=(out+1.0)*0.5;
+ out = getlfoshape(xl);
+ if((lfotype == 0) || (lfotype == 1))
+ out *= (ampl1 + xl * (ampl2 - ampl1));
+ xl += incx;
+ if(xl > 1.0) {
+ xl -= 1.0;
+ ampl1 = ampl2;
+ ampl2 = (1.0 - lfornd) + lfornd * RND;
+ }
+ *outl = (out + 1.0) * 0.5;
- out=getlfoshape(xr);
- if ((lfotype==0)||(lfotype==1)) out*=(ampr1+xr*(ampr2-ampr1));
- xr+=incx;
- if (xr>1.0) {
- xr-=1.0;
- ampr1=ampr2;
- ampr2=(1.0-lfornd)+lfornd*RND;
- };
- *outr=(out+1.0)*0.5;
-};
+ out = getlfoshape(xr);
+ if((lfotype == 0) || (lfotype == 1))
+ out *= (ampr1 + xr * (ampr2 - ampr1));
+ xr += incx;
+ if(xr > 1.0) {
+ xr -= 1.0;
+ ampr1 = ampr2;
+ ampr2 = (1.0 - lfornd) + lfornd * RND;
+ }
+ *outr = (out + 1.0) * 0.5;
+}
diff --git a/plugins/zynaddsubfx/src/Effects/EffectLFO.h b/plugins/zynaddsubfx/src/Effects/EffectLFO.h
index 54a595110..cc14d6652 100644
--- a/plugins/zynaddsubfx/src/Effects/EffectLFO.h
+++ b/plugins/zynaddsubfx/src/Effects/EffectLFO.h
@@ -28,24 +28,24 @@
* \todo see if this should inherit LFO*/
class EffectLFO
{
-public:
- EffectLFO();
- ~EffectLFO();
- void effectlfoout(REALTYPE *outl,REALTYPE *outr);
- void updateparams();
- unsigned char Pfreq;
- unsigned char Prandomness;
- unsigned char PLFOtype;
- unsigned char Pstereo;//"64"=0
-private:
- REALTYPE getlfoshape(REALTYPE x);
+ public:
+ EffectLFO();
+ ~EffectLFO();
+ void effectlfoout(REALTYPE *outl, REALTYPE *outr);
+ void updateparams();
+ unsigned char Pfreq;
+ unsigned char Prandomness;
+ unsigned char PLFOtype;
+ unsigned char Pstereo; //"64"=0
+ private:
+ REALTYPE getlfoshape(REALTYPE x);
- REALTYPE xl,xr;
- REALTYPE incx;
- REALTYPE ampl1,ampl2,ampr1,ampr2;//necessary for "randomness"
- REALTYPE lfointensity;
- REALTYPE lfornd;
- char lfotype; /**\todo GET RID OF CHAR (replace with short or enum)*/
+ REALTYPE xl, xr;
+ REALTYPE incx;
+ REALTYPE ampl1, ampl2, ampr1, ampr2; //necessary for "randomness"
+ REALTYPE lfointensity;
+ REALTYPE lfornd;
+ char lfotype; /**\todo GET RID OF CHAR (replace with short or enum)*/
};
diff --git a/plugins/zynaddsubfx/src/Effects/EffectMgr.cpp b/plugins/zynaddsubfx/src/Effects/EffectMgr.cpp
index 081101184..cbb44c02f 100644
--- a/plugins/zynaddsubfx/src/Effects/EffectMgr.cpp
+++ b/plugins/zynaddsubfx/src/Effects/EffectMgr.cpp
@@ -22,11 +22,11 @@
#include "EffectMgr.h"
-EffectMgr::EffectMgr(int insertion_,pthread_mutex_t *mutex_)
- :insertion(insertion_),
- efxoutl(new REALTYPE[SOUND_BUFFER_SIZE]),
- efxoutr(new REALTYPE[SOUND_BUFFER_SIZE]),
- filterpars(NULL),nefx(0),efx(NULL),mutex(mutex_),dryonly(false)
+EffectMgr::EffectMgr(int insertion_, pthread_mutex_t *mutex_)
+ :insertion(insertion_),
+ efxoutl(new REALTYPE[SOUND_BUFFER_SIZE]),
+ efxoutr(new REALTYPE[SOUND_BUFFER_SIZE]),
+ filterpars(NULL), nefx(0), efx(NULL), mutex(mutex_), dryonly(false)
{
setpresettype("Peffect"); /**\todo Figure out what this is doing
* , as it might be another leaky abstraction.*/
@@ -36,10 +36,10 @@ EffectMgr::EffectMgr(int insertion_,pthread_mutex_t *mutex_)
// mutex=mutex_;
// efxoutl=new REALTYPE[SOUND_BUFFER_SIZE];
// efxoutr=new REALTYPE[SOUND_BUFFER_SIZE];
- for (int i=0;ifilterpars;
+ if(efx != NULL)
+ filterpars = efx->filterpars;
}
/*
@@ -112,7 +116,7 @@ void EffectMgr::changeeffect(int nefx_)
*/
int EffectMgr::geteffect()
{
- return (nefx);
+ return nefx;
}
/*
@@ -120,7 +124,8 @@ int EffectMgr::geteffect()
*/
void EffectMgr::cleanup()
{
- if (efx!=NULL) efx->cleanup();
+ if(efx != NULL)
+ efx->cleanup();
}
@@ -130,8 +135,10 @@ void EffectMgr::cleanup()
unsigned char EffectMgr::getpreset()
{
- if (efx!=NULL) return(efx->Ppreset);
- else return(0);
+ if(efx != NULL)
+ return efx->Ppreset;
+ else
+ return 0;
}
/*
@@ -139,7 +146,8 @@ unsigned char EffectMgr::getpreset()
*/
void EffectMgr::changepreset_nolock(unsigned char npreset)
{
- if (efx!=NULL) efx->setpreset(npreset);
+ if(efx != NULL)
+ efx->setpreset(npreset);
}
/*
@@ -156,19 +164,20 @@ void EffectMgr::changepreset(unsigned char npreset)
/*
* Change a parameter of the current effect
*/
-void EffectMgr::seteffectpar_nolock(int npar,unsigned char value)
+void EffectMgr::seteffectpar_nolock(int npar, unsigned char value)
{
- if (efx==NULL) return;
- efx->changepar(npar,value);
+ if(efx == NULL)
+ return;
+ efx->changepar(npar, value);
}
/*
* Change a parameter of the current effect (with thread locking)
*/
-void EffectMgr::seteffectpar(int npar,unsigned char value)
+void EffectMgr::seteffectpar(int npar, unsigned char value)
{
pthread_mutex_lock(mutex);
- seteffectpar_nolock(npar,value);
+ seteffectpar_nolock(npar, value);
pthread_mutex_unlock(mutex);
}
@@ -177,80 +186,85 @@ void EffectMgr::seteffectpar(int npar,unsigned char value)
*/
unsigned char EffectMgr::geteffectpar(int npar)
{
- if (efx==NULL) return(0);
- return(efx->getpar(npar));
+ if(efx == NULL)
+ return 0;
+ return efx->getpar(npar);
}
/*
* Apply the effect
*/
-void EffectMgr::out(REALTYPE *smpsl,REALTYPE *smpsr)
+void EffectMgr::out(REALTYPE *smpsl, REALTYPE *smpsr)
{
int i;
- if (efx==NULL) {
- if (insertion==0)
- for (i=0;iout(smpsl,smpsr);
+ }
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ smpsl[i] += denormalkillbuf[i];
+ smpsr[i] += denormalkillbuf[i];
+ efxoutl[i] = 0.0;
+ efxoutr[i] = 0.0;
+ }
+ efx->out(smpsl, smpsr);
- REALTYPE volume=efx->volume;
+ REALTYPE volume = efx->volume;
- if (nefx==7) {//this is need only for the EQ effect
+ if(nefx == 7) { //this is need only for the EQ effect
/**\todo figure out why*/
- for (i=0;ioutvolume);
+ if(efx == NULL)
+ return 1.0;
+ else
+ return efx->outvolume;
}
@@ -268,65 +284,72 @@ REALTYPE EffectMgr::sysefxgetvolume()
*/
REALTYPE EffectMgr::getEQfreqresponse(REALTYPE freq)
{
- if (nefx==7) return(efx->getfreqresponse(freq));
- else return(0.0);
+ if(nefx == 7)
+ return efx->getfreqresponse(freq);
+ else
+ return 0.0;
}
void EffectMgr::setdryonly(bool value)
{
- dryonly=value;
+ dryonly = value;
}
void EffectMgr::add2XML(XMLwrapper *xml)
{
- xml->addpar("type",geteffect());
+ xml->addpar("type", geteffect());
- if ((efx==NULL)||(geteffect()==0)) return;
- xml->addpar("preset",efx->Ppreset);
+ if((efx == NULL) || (geteffect() == 0))
+ return;
+ xml->addpar("preset", efx->Ppreset);
xml->beginbranch("EFFECT_PARAMETERS");
- for (int n=0;n<128;n++) { /**\todo evaluate who should oversee saving
- * and loading of parameters*/
- int par=geteffectpar(n);
- if (par==0) continue;
- xml->beginbranch("par_no",n);
- xml->addpar("par",par);
+ for(int n = 0; n < 128; n++) {
+ /**\todo evaluate who should oversee saving
+ * and loading of parameters*/
+ int par = geteffectpar(n);
+ if(par == 0)
+ continue;
+ xml->beginbranch("par_no", n);
+ xml->addpar("par", par);
xml->endbranch();
- };
- if (filterpars!=NULL) {
+ }
+ if(filterpars != NULL) {
xml->beginbranch("FILTER");
filterpars->add2XML(xml);
xml->endbranch();
- };
+ }
xml->endbranch();
}
void EffectMgr::getfromXML(XMLwrapper *xml)
{
- changeeffect(xml->getpar127("type",geteffect()));
+ changeeffect(xml->getpar127("type", geteffect()));
- if ((efx==NULL)||(geteffect()==0)) return;
+ if((efx == NULL) || (geteffect() == 0))
+ return;
- efx->Ppreset=xml->getpar127("preset",efx->Ppreset);
+ efx->Ppreset = xml->getpar127("preset", efx->Ppreset);
- if (xml->enterbranch("EFFECT_PARAMETERS")) {
- for (int n=0;n<128;n++) {
- seteffectpar_nolock(n,0);//erase effect parameter
- if (xml->enterbranch("par_no",n)==0) continue;
+ if(xml->enterbranch("EFFECT_PARAMETERS")) {
+ for(int n = 0; n < 128; n++) {
+ seteffectpar_nolock(n, 0); //erase effect parameter
+ if(xml->enterbranch("par_no", n) == 0)
+ continue;
- int par=geteffectpar(n);
- seteffectpar_nolock(n,xml->getpar127("par",par));
+ int par = geteffectpar(n);
+ seteffectpar_nolock(n, xml->getpar127("par", par));
xml->exitbranch();
- };
- if (filterpars!=NULL) {
- if (xml->enterbranch("FILTER")) {
+ }
+ if(filterpars != NULL) {
+ if(xml->enterbranch("FILTER")) {
filterpars->getfromXML(xml);
xml->exitbranch();
- };
- };
+ }
+ }
xml->exitbranch();
- };
+ }
cleanup();
}
diff --git a/plugins/zynaddsubfx/src/Effects/EffectMgr.h b/plugins/zynaddsubfx/src/Effects/EffectMgr.h
index dd5d52ce6..2a1257707 100644
--- a/plugins/zynaddsubfx/src/Effects/EffectMgr.h
+++ b/plugins/zynaddsubfx/src/Effects/EffectMgr.h
@@ -41,62 +41,62 @@
/**Effect manager, an interface betwen the program and effects*/
class EffectMgr:public Presets
{
-public:
- EffectMgr(int insertion_,pthread_mutex_t *mutex_);
- ~EffectMgr();
+ public:
+ EffectMgr(int insertion_, pthread_mutex_t *mutex_);
+ ~EffectMgr();
- void add2XML(XMLwrapper *xml);
- void defaults();
- void getfromXML(XMLwrapper *xml);
+ void add2XML(XMLwrapper *xml);
+ void defaults();
+ void getfromXML(XMLwrapper *xml);
- void out(REALTYPE *smpsl,REALTYPE *smpsr);
+ void out(REALTYPE *smpsl, REALTYPE *smpsr);
- void setdryonly(bool value);
+ void setdryonly(bool value);
- /**get the output(to speakers) volume of the systemeffect*/
- REALTYPE sysefxgetvolume();
+ /**get the output(to speakers) volume of the systemeffect*/
+ REALTYPE sysefxgetvolume();
- void cleanup();/**
-#include "Phaser.h"
-#define PHASER_LFO_SHAPE 2
-
-Phaser::Phaser(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
- :Effect(insertion_,efxoutl_,efxoutr_,NULL,0),old(1),oldgain(0.0)
-{
- setpreset(Ppreset);
- cleanup();
-};
-
-Phaser::~Phaser()
-{
-};
-
-
-/*
- * Effect output
- */
-void Phaser::out(REALTYPE *smpsl,REALTYPE *smpsr)
-{
- int i,j;
- REALTYPE lfol,lfor,lgain,rgain,tmp;
-
- lfo.effectlfoout(&lfol,&lfor);
- lgain=lfol;
- rgain=lfor;
- lgain=(exp(lgain*PHASER_LFO_SHAPE)-1)/(exp(PHASER_LFO_SHAPE)-1.0);
- rgain=(exp(rgain*PHASER_LFO_SHAPE)-1)/(exp(PHASER_LFO_SHAPE)-1.0);
-
-
- lgain=1.0-phase*(1.0-depth)-(1.0-phase)*lgain*depth;
- rgain=1.0-phase*(1.0-depth)-(1.0-phase)*rgain*depth;
-
- if (lgain>1.0) lgain=1.0;
- else if (lgain<0.0) lgain=0.0;
- if (rgain>1.0) rgain=1.0;
- else if (rgain<0.0) rgain=0.0;
-
- for (i=0;i(lgain,rgain);
-
- if (Poutsub!=0)
- for (i=0;i(0.0);
- old.l().clear();
- old.r().clear();
-};
-
-/*
- * Parameter control
- */
-void Phaser::setdepth(const unsigned char &Pdepth)
-{
- this->Pdepth=Pdepth;
- depth=(Pdepth/127.0);
-};
-
-
-void Phaser::setfb(const unsigned char &Pfb)
-{
- this->Pfb=Pfb;
- fb=(Pfb-64.0)/64.1;
-};
-
-void Phaser::setvolume(const unsigned char &Pvolume)
-{
- this->Pvolume=Pvolume;
- outvolume=Pvolume/127.0;
- if (insertion==0) volume=1.0;
- else volume=outvolume;
-};
-
-void Phaser::setpanning(const unsigned char &Ppanning)
-{
- this->Ppanning=Ppanning;
- panning=Ppanning/127.0;
-};
-
-void Phaser::setlrcross(const unsigned char &Plrcross)
-{
- this->Plrcross=Plrcross;
- lrcross=Plrcross/127.0;
-};
-
-void Phaser::setstages(const unsigned char &Pstages)
-{
- if (Pstages>=MAX_PHASER_STAGES) this->Pstages=MAX_PHASER_STAGES-1;
- else this->Pstages=Pstages;
- old=Stereo(Pstages*2);
- cleanup();
-};
-
-void Phaser::setphase(const unsigned char &Pphase)
-{
- this->Pphase=Pphase;
- phase=(Pphase/127.0);
-};
-
-
-void Phaser::setpreset(unsigned char npreset)
-{
- const int PRESET_SIZE=12;
- const int NUM_PRESETS=6;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE]={
- //Phaser1
- {64,64,36,0,0,64,110,64,1,0,0,20},
- //Phaser2
- {64,64,35,0,0,88,40,64,3,0,0,20},
- //Phaser3
- {64,64,31,0,0,66,68,107,2,0,0,20},
- //Phaser4
- {39,64,22,0,0,66,67,10,5,0,1,20},
- //Phaser5
- {64,64,20,0,1,110,67,78,10,0,0,20},
- //Phaser6
- {64,64,53,100,0,58,37,78,3,0,0,20}
- };
- if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1;
- for (int n=0;n1) Poutsub=1;
- else Poutsub=value;
- break;
- case 11:
- setphase(value);
- break;
- };
-};
-
-unsigned char Phaser::getpar(const int &npar)const
-{
- switch (npar) {
- case 0:
- return(Pvolume);
- break;
- case 1:
- return(Ppanning);
- break;
- case 2:
- return(lfo.Pfreq);
- break;
- case 3:
- return(lfo.Prandomness);
- break;
- case 4:
- return(lfo.PLFOtype);
- break;
- case 5:
- return(lfo.Pstereo);
- break;
- case 6:
- return(Pdepth);
- break;
- case 7:
- return(Pfb);
- break;
- case 8:
- return(Pstages);
- break;
- case 9:
- return(Plrcross);
- break;
- case 10:
- return(Poutsub);
- break;
- case 11:
- return(Pphase);
- break;
- default:
- return (0);
- };
-
-};
-
+/*
+ ZynAddSubFX - a software synthesizer
+
+ Phaser.C - Phaser effect
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2 or later) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#include
+#include "Phaser.h"
+#define PHASER_LFO_SHAPE 2
+
+Phaser::Phaser(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_)
+ :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0), old(1), oldgain(0.0)
+{
+ setpreset(Ppreset);
+ cleanup();
+}
+
+Phaser::~Phaser()
+{}
+
+
+/*
+ * Effect output
+ */
+void Phaser::out(REALTYPE *smpsl, REALTYPE *smpsr)
+{
+ int i, j;
+ REALTYPE lfol, lfor, lgain, rgain, tmp;
+
+ lfo.effectlfoout(&lfol, &lfor);
+ lgain = lfol;
+ rgain = lfor;
+ lgain = (exp(lgain * PHASER_LFO_SHAPE) - 1) / (exp(PHASER_LFO_SHAPE) - 1.0);
+ rgain = (exp(rgain * PHASER_LFO_SHAPE) - 1) / (exp(PHASER_LFO_SHAPE) - 1.0);
+
+
+ lgain = 1.0 - phase * (1.0 - depth) - (1.0 - phase) * lgain * depth;
+ rgain = 1.0 - phase * (1.0 - depth) - (1.0 - phase) * rgain * depth;
+
+ if(lgain > 1.0)
+ lgain = 1.0;
+ else
+ if(lgain < 0.0)
+ lgain = 0.0;
+ if(rgain > 1.0)
+ rgain = 1.0;
+ else
+ if(rgain < 0.0)
+ rgain = 0.0;
+
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ REALTYPE x = (REALTYPE) i / SOUND_BUFFER_SIZE;
+ REALTYPE x1 = 1.0 - x;
+ REALTYPE gl = lgain * x + oldgain.left() * x1;
+ REALTYPE gr = rgain * x + oldgain.right() * x1;
+ REALTYPE inl = smpsl[i] * panning + fbl;
+ REALTYPE inr = smpsr[i] * (1.0 - panning) + fbr;
+
+ //Left channel
+ for(j = 0; j < Pstages * 2; j++) { //Phasing routine
+ tmp = old.left()[j];
+ old.left()[j] = gl * tmp + inl;
+ inl = tmp - gl *old.left()[j];
+ }
+ //Right channel
+ for(j = 0; j < Pstages * 2; j++) { //Phasing routine
+ tmp = old.right()[j];
+ old.right()[j] = gr * tmp + inr;
+ inr = tmp - gr *old.right()[j];
+ }
+ //Left/Right crossing
+ REALTYPE l = inl;
+ REALTYPE r = inr;
+ inl = l * (1.0 - lrcross) + r * lrcross;
+ inr = r * (1.0 - lrcross) + l * lrcross;
+
+ fbl = inl * fb;
+ fbr = inr * fb;
+ efxoutl[i] = inl;
+ efxoutr[i] = inr;
+ }
+
+ oldgain = Stereo(lgain, rgain);
+
+ if(Poutsub != 0)
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ efxoutl[i] *= -1.0;
+ efxoutr[i] *= -1.0;
+ }
+ ;
+}
+
+/*
+ * Cleanup the effect
+ */
+void Phaser::cleanup()
+{
+ fbl = 0.0;
+ fbr = 0.0;
+ oldgain = Stereo(0.0);
+ old.l().clear();
+ old.r().clear();
+}
+
+/*
+ * Parameter control
+ */
+void Phaser::setdepth(const unsigned char &Pdepth)
+{
+ this->Pdepth = Pdepth;
+ depth = (Pdepth / 127.0);
+}
+
+
+void Phaser::setfb(const unsigned char &Pfb)
+{
+ this->Pfb = Pfb;
+ fb = (Pfb - 64.0) / 64.1;
+}
+
+void Phaser::setvolume(const unsigned char &Pvolume)
+{
+ this->Pvolume = Pvolume;
+ outvolume = Pvolume / 127.0;
+ if(insertion == 0)
+ volume = 1.0;
+ else
+ volume = outvolume;
+}
+
+void Phaser::setpanning(const unsigned char &Ppanning)
+{
+ this->Ppanning = Ppanning;
+ panning = Ppanning / 127.0;
+}
+
+void Phaser::setlrcross(const unsigned char &Plrcross)
+{
+ this->Plrcross = Plrcross;
+ lrcross = Plrcross / 127.0;
+}
+
+void Phaser::setstages(const unsigned char &Pstages)
+{
+ if(Pstages >= MAX_PHASER_STAGES)
+ this->Pstages = MAX_PHASER_STAGES - 1;
+ else
+ this->Pstages = Pstages;
+ old = Stereo(Pstages * 2);
+ cleanup();
+}
+
+void Phaser::setphase(const unsigned char &Pphase)
+{
+ this->Pphase = Pphase;
+ phase = (Pphase / 127.0);
+}
+
+
+void Phaser::setpreset(unsigned char npreset)
+{
+ const int PRESET_SIZE = 12;
+ const int NUM_PRESETS = 6;
+ unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
+ //Phaser1
+ {64, 64, 36, 0, 0, 64, 110, 64, 1, 0, 0, 20},
+ //Phaser2
+ {64, 64, 35, 0, 0, 88, 40, 64, 3, 0, 0, 20},
+ //Phaser3
+ {64, 64, 31, 0, 0, 66, 68, 107, 2, 0, 0, 20},
+ //Phaser4
+ {39, 64, 22, 0, 0, 66, 67, 10, 5, 0, 1, 20},
+ //Phaser5
+ {64, 64, 20, 0, 1, 110, 67, 78, 10, 0, 0, 20},
+ //Phaser6
+ {64, 64, 53, 100, 0, 58, 37, 78, 3, 0, 0, 20}
+ };
+ if(npreset >= NUM_PRESETS)
+ npreset = NUM_PRESETS - 1;
+ for(int n = 0; n < PRESET_SIZE; n++)
+ changepar(n, presets[npreset][n]);
+ Ppreset = npreset;
+}
+
+
+void Phaser::changepar(const int &npar, const unsigned char &value)
+{
+ switch(npar) {
+ case 0:
+ setvolume(value);
+ break;
+ case 1:
+ setpanning(value);
+ break;
+ case 2:
+ lfo.Pfreq = value;
+ lfo.updateparams();
+ break;
+ case 3:
+ lfo.Prandomness = value;
+ lfo.updateparams();
+ break;
+ case 4:
+ lfo.PLFOtype = value;
+ lfo.updateparams();
+ break;
+ case 5:
+ lfo.Pstereo = value;
+ lfo.updateparams();
+ break;
+ case 6:
+ setdepth(value);
+ break;
+ case 7:
+ setfb(value);
+ break;
+ case 8:
+ setstages(value);
+ break;
+ case 9:
+ setlrcross(value);
+ break;
+ case 10:
+ if(value > 1)
+ Poutsub = 1;
+ else
+ Poutsub = value;
+ break;
+ case 11:
+ setphase(value);
+ break;
+ }
+}
+
+unsigned char Phaser::getpar(const int &npar) const
+{
+ switch(npar) {
+ case 0:
+ return Pvolume;
+ break;
+ case 1:
+ return Ppanning;
+ break;
+ case 2:
+ return lfo.Pfreq;
+ break;
+ case 3:
+ return lfo.Prandomness;
+ break;
+ case 4:
+ return lfo.PLFOtype;
+ break;
+ case 5:
+ return lfo.Pstereo;
+ break;
+ case 6:
+ return Pdepth;
+ break;
+ case 7:
+ return Pfb;
+ break;
+ case 8:
+ return Pstages;
+ break;
+ case 9:
+ return Plrcross;
+ break;
+ case 10:
+ return Poutsub;
+ break;
+ case 11:
+ return Pphase;
+ break;
+ default:
+ return 0;
+ }
+}
+
diff --git a/plugins/zynaddsubfx/src/Effects/Phaser.h b/plugins/zynaddsubfx/src/Effects/Phaser.h
index 700af3dfc..30370a8c6 100644
--- a/plugins/zynaddsubfx/src/Effects/Phaser.h
+++ b/plugins/zynaddsubfx/src/Effects/Phaser.h
@@ -1,76 +1,76 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- Phaser.h - Phaser effect
- Copyright (C) 2002-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#ifndef PHASER_H
-#define PHASER_H
-#include "../globals.h"
-#include "../Misc/Stereo.h"
-#include "../Samples/AuSample.h"
-#include "Effect.h"
-#include "EffectLFO.h"
-
-#define MAX_PHASER_STAGES 12
-/**Phaser Effect*/
-class Phaser:public Effect
-{
-public:
- Phaser(const int &insetion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
- ~Phaser();
- void out(REALTYPE *smpsl,REALTYPE *smpsr);
- void setpreset(unsigned char npreset);
- void changepar(const int &npar,const unsigned char &value);
- unsigned char getpar(const int &npar)const;
- void cleanup();
- void setdryonly();
-
-private:
- //Parametrii Phaser
- EffectLFO lfo;/** old;
- //REALTYPE oldlgain,oldrgain;
- Stereo oldgain;
-};
-
-#endif
-
+/*
+ ZynAddSubFX - a software synthesizer
+
+ Phaser.h - Phaser effect
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2 or later) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#ifndef PHASER_H
+#define PHASER_H
+#include "../globals.h"
+#include "../Misc/Stereo.h"
+#include "../Samples/AuSample.h"
+#include "Effect.h"
+#include "EffectLFO.h"
+
+#define MAX_PHASER_STAGES 12
+/**Phaser Effect*/
+class Phaser:public Effect
+{
+ public:
+ Phaser(const int &insetion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ ~Phaser();
+ void out(REALTYPE *smpsl, REALTYPE *smpsr);
+ void setpreset(unsigned char npreset);
+ void changepar(const int &npar, const unsigned char &value);
+ unsigned char getpar(const int &npar) const;
+ void cleanup();
+ void setdryonly();
+
+ private:
+ //Parametrii Phaser
+ EffectLFO lfo; /** old;
+ //REALTYPE oldlgain,oldrgain;
+ Stereo oldgain;
+};
+
+#endif
+
diff --git a/plugins/zynaddsubfx/src/Effects/Reverb.cpp b/plugins/zynaddsubfx/src/Effects/Reverb.cpp
index 943439716..27b0a554b 100644
--- a/plugins/zynaddsubfx/src/Effects/Reverb.cpp
+++ b/plugins/zynaddsubfx/src/Effects/Reverb.cpp
@@ -1,471 +1,557 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- Reverb.C - Reverberation effect
- Copyright (C) 2002-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#include
-#include "Reverb.h"
-
-/**\todo: EarlyReflections,Prdelay,Perbalance */
-
-Reverb::Reverb(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_)
- :Effect(insertion_,efxoutl_,efxoutr_,NULL,0)
-{
- inputbuf=new REALTYPE[SOUND_BUFFER_SIZE];
-
- //defaults
- Pvolume=48;
- Ppan=64;
- Ptime=64;
- Pidelay=40;
- Pidelayfb=0;
- Prdelay=0;
- Plpf=127;
- Phpf=0;
- Perbalance=64;
- Plohidamp=80;
- Ptype=1;
- Proomsize=64;
- roomsize=1.0;
- rs=1.0;
-
- for (int i=0;icleanup();
- if (lpf!=NULL) lpf->cleanup();
-
-};
-
-/*
- * Process one channel; 0=left,1=right
- */
-void Reverb::processmono(int ch,REALTYPE *output)
-{
- int i,j;
- REALTYPE fbout,tmp;
- /**\todo: implement the high part from lohidamp*/
-
- for (j=REV_COMBS*ch;j=comblength) ck=0;
- };
-
- combk[j]=ck;
- lpcomb[j]=lpcombj;
- };
-
- for (j=REV_APS*ch;j=aplength) ak=0;
- };
- apk[j]=ak;
- };
-};
-
-/*
- * Effect output
- */
-void Reverb::out(REALTYPE *smps_l, REALTYPE *smps_r)
-{
- int i;
- if ((Pvolume==0)&&(insertion!=0)) return;
-
- for (i=0;i=idelaylen) idelayk=0;
- };
- };
-
- if (lpf!=NULL) lpf->filterout(inputbuf);
- if (hpf!=NULL) hpf->filterout(inputbuf);
-
- processmono(0,efxoutl);//left
- processmono(1,efxoutr);//right
-
- REALTYPE lvol=rs/REV_COMBS*pan;
- REALTYPE rvol=rs/REV_COMBS*(1.0-pan);
- if (insertion!=0) {
- lvol*=2;
- rvol*=2;
- };
- for (int i=0;iPvolume=Pvolume;
- if (insertion==0) {
- outvolume=pow(0.01,(1.0-Pvolume/127.0))*4.0;
- volume=1.0;
- } else {
- volume=outvolume=Pvolume/127.0;
- if (Pvolume==0) cleanup();
- };
-};
-
-void Reverb::setpan(const unsigned char &Ppan)
-{
- this->Ppan=Ppan;
- pan=(REALTYPE)Ppan/127.0;
-};
-
-void Reverb::settime(const unsigned char &Ptime)
-{
- int i;
- REALTYPE t;
- this->Ptime=Ptime;
- t=pow(60.0,(REALTYPE)Ptime/127.0)-0.97;
-
- for (i=0;iPlohidamp=Plohidamp;
- if (Plohidamp==64) {
- lohidamptype=0;
- lohifb=0.0;
- } else {
- if (Plohidamp<64) lohidamptype=1;
- if (Plohidamp>64) lohidamptype=2;
- x=fabs((REALTYPE)(Plohidamp-64)/64.1);
- lohifb=x*x;
- };
-};
-
-void Reverb::setidelay(const unsigned char &Pidelay)
-{
- REALTYPE delay;
- this->Pidelay=Pidelay;
- delay=pow(50*Pidelay/127.0,2)-1.0;
-
- if (idelay!=NULL) delete []idelay;
- idelay=NULL;
-
- idelaylen=(int) (SAMPLE_RATE*delay/1000);
- if (idelaylen>1) {
- idelayk=0;
- idelay=new REALTYPE[idelaylen];
- for (int i=0;iPidelayfb=Pidelayfb;
- idelayfb=Pidelayfb/128.0;
-};
-
-void Reverb::sethpf(const unsigned char &Phpf)
-{
- this->Phpf=Phpf;
- if (Phpf==0) {//No HighPass
- if (hpf!=NULL) delete hpf;
- hpf=NULL;
- } else {
- REALTYPE fr=exp(pow(Phpf/127.0,0.5)*log(10000.0))+20.0;
- if (hpf==NULL) hpf=new AnalogFilter(3,fr,1,0);
- else hpf->setfreq(fr);
- };
-};
-
-void Reverb::setlpf(const unsigned char &Plpf)
-{
- this->Plpf=Plpf;
- if (Plpf==127) {//No LowPass
- if (lpf!=NULL) delete lpf;
- lpf=NULL;
- } else {
- REALTYPE fr=exp(pow(Plpf/127.0,0.5)*log(25000.0))+40;
- if (lpf==NULL) lpf=new AnalogFilter(2,fr,1,0);
- else lpf->setfreq(fr);
- };
-};
-
-void Reverb::settype(unsigned char Ptype)
-{
- const int NUM_TYPES=2;
- int combtunings[NUM_TYPES][REV_COMBS]={
- //this is unused (for random)
- {0,0,0,0,0,0,0,0},
- //Freeverb by Jezar at Dreampoint
- {1116,1188,1277,1356,1422,1491,1557,1617}
- };
- int aptunings[NUM_TYPES][REV_APS]={
- //this is unused (for random)
- {0,0,0,0},
- //Freeverb by Jezar at Dreampoint
- {225,341,441,556}
- };
-
- if (Ptype>=NUM_TYPES) Ptype=NUM_TYPES-1;
- this->Ptype=Ptype;
-
- REALTYPE tmp;
- for (int i=0;iREV_COMBS) tmp+=23.0;
- tmp*=SAMPLE_RATE/44100.0;//adjust the combs according to the samplerate
- if (tmp<10) tmp=10;
-
- comblen[i]=(int) tmp;
- combk[i]=0;
- lpcomb[i]=0;
- if (comb[i]!=NULL) delete []comb[i];
- comb[i]=new REALTYPE[comblen[i]];
- };
-
- for (int i=0;iREV_APS) tmp+=23.0;
- tmp*=SAMPLE_RATE/44100.0;//adjust the combs according to the samplerate
- if (tmp<10) tmp=10;
- aplen[i]=(int) tmp;
- apk[i]=0;
- if (ap[i]!=NULL) delete []ap[i];
- ap[i]=new REALTYPE[aplen[i]];
- };
- settime(Ptime);
- cleanup();
-};
-
-void Reverb::setroomsize(const unsigned char &Proomsize)
-{
- this->Proomsize=Proomsize;
- if (Proomsize==0) this->Proomsize=64;//this is because the older versions consider roomsize=0
- roomsize=(this->Proomsize-64.0)/64.0;
- if (roomsize>0.0) roomsize*=2.0;
- roomsize=pow(10.0,roomsize);
- rs=sqrt(roomsize);
- settype(Ptype);
-};
-
-void Reverb::setpreset(unsigned char npreset)
-{
- const int PRESET_SIZE=12;
- const int NUM_PRESETS=13;
- unsigned char presets[NUM_PRESETS][PRESET_SIZE]={
- //Cathedral1
- {80,64,63,24,0,0,0,85,5,83,1,64},
- //Cathedral2
- {80,64,69,35,0,0,0,127,0,71,0,64},
- //Cathedral3
- {80,64,69,24,0,0,0,127,75,78,1,85},
- //Hall1
- {90,64,51,10,0,0,0,127,21,78,1,64},
- //Hall2
- {90,64,53,20,0,0,0,127,75,71,1,64},
- //Room1
- {100,64,33,0,0,0,0,127,0,106,0,30},
- //Room2
- {100,64,21,26,0,0,0,62,0,77,1,45},
- //Basement
- {110,64,14,0,0,0,0,127,5,71,0,25},
- //Tunnel
- {85,80,84,20,42,0,0,51,0,78,1,105},
- //Echoed1
- {95,64,26,60,71,0,0,114,0,64,1,64},
- //Echoed2
- {90,64,40,88,71,0,0,114,0,88,1,64},
- //VeryLong1
- {90,64,93,15,0,0,0,114,0,77,0,95},
- //VeryLong2
- {90,64,111,30,0,0,0,114,90,74,1,80}
- };
-
- if (npreset>=NUM_PRESETS) npreset=NUM_PRESETS-1;
- for (int n=0;n
+#include "Reverb.h"
+
+/**\todo: EarlyReflections,Prdelay,Perbalance */
+
+Reverb::Reverb(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_)
+ :Effect(insertion_, efxoutl_, efxoutr_, NULL, 0)
+{
+ inputbuf = new REALTYPE[SOUND_BUFFER_SIZE];
+
+ bandwidth = NULL;
+
+ //defaults
+ Pvolume = 48;
+ Ppan = 64;
+ Ptime = 64;
+ Pidelay = 40;
+ Pidelayfb = 0;
+ Prdelay = 0;
+ Plpf = 127;
+ Phpf = 0;
+ Perbalance = 64;
+ Plohidamp = 80;
+ Ptype = 1;
+ Proomsize = 64;
+ Pbandwidth = 30;
+ roomsize = 1.0;
+ rs = 1.0;
+
+ for(int i = 0; i < REV_COMBS * 2; i++) {
+ comblen[i] = 800 + (int)(RND * 1400);
+ combk[i] = 0;
+ lpcomb[i] = 0;
+ combfb[i] = -0.97;
+ comb[i] = NULL;
+ }
+
+ for(int i = 0; i < REV_APS * 2; i++) {
+ aplen[i] = 500 + (int)(RND * 500);
+ apk[i] = 0;
+ ap[i] = NULL;
+ }
+
+ lpf = NULL;
+ hpf = NULL; //no filter
+ idelay = NULL;
+
+ setpreset(Ppreset);
+ cleanup(); //do not call this before the comb initialisation
+}
+
+
+Reverb::~Reverb()
+{
+ int i;
+ if(idelay != NULL)
+ delete [] idelay;
+ if(hpf != NULL)
+ delete hpf;
+ if(lpf != NULL)
+ delete lpf;
+
+ for(i = 0; i < REV_APS * 2; i++)
+ delete [] ap[i];
+ for(i = 0; i < REV_COMBS * 2; i++)
+ delete [] comb[i];
+
+ delete [] inputbuf;
+ if(bandwidth)
+ delete bandwidth;
+}
+
+/*
+ * Cleanup the effect
+ */
+void Reverb::cleanup()
+{
+ int i, j;
+ for(i = 0; i < REV_COMBS * 2; i++) {
+ lpcomb[i] = 0.0;
+ for(j = 0; j < comblen[i]; j++)
+ comb[i][j] = 0.0;
+ }
+
+ for(i = 0; i < REV_APS * 2; i++)
+ for(j = 0; j < aplen[i]; j++)
+ ap[i][j] = 0.0;
+
+ if(idelay != NULL)
+ for(i = 0; i < idelaylen; i++)
+ idelay[i] = 0.0;
+
+ if(hpf != NULL)
+ hpf->cleanup();
+ if(lpf != NULL)
+ lpf->cleanup();
+}
+
+/*
+ * Process one channel; 0=left,1=right
+ */
+void Reverb::processmono(int ch, REALTYPE *output)
+{
+ int i, j;
+ REALTYPE fbout, tmp;
+ /**\todo: implement the high part from lohidamp*/
+
+ for(j = REV_COMBS * ch; j < REV_COMBS * (ch + 1); j++) {
+ int ck = combk[j];
+ int comblength = comblen[j];
+ REALTYPE lpcombj = lpcomb[j];
+
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ fbout = comb[j][ck] * combfb[j];
+ fbout = fbout * (1.0 - lohifb) + lpcombj * lohifb;
+ lpcombj = fbout;
+
+ comb[j][ck] = inputbuf[i] + fbout;
+ output[i] += fbout;
+
+ if((++ck) >= comblength)
+ ck = 0;
+ }
+
+ combk[j] = ck;
+ lpcomb[j] = lpcombj;
+ }
+
+ for(j = REV_APS * ch; j < REV_APS * (1 + ch); j++) {
+ int ak = apk[j];
+ int aplength = aplen[j];
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ tmp = ap[j][ak];
+ ap[j][ak] = 0.7 * tmp + output[i];
+ output[i] = tmp - 0.7 * ap[j][ak];
+ if((++ak) >= aplength)
+ ak = 0;
+ }
+ apk[j] = ak;
+ }
+}
+
+/*
+ * Effect output
+ */
+void Reverb::out(REALTYPE *smps_l, REALTYPE *smps_r)
+{
+ int i;
+ if((Pvolume == 0) && (insertion != 0))
+ return;
+
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++)
+ inputbuf[i] = (smps_l[i] + smps_r[i]) / 2.0;
+ ;
+
+ if(idelay != NULL) {
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ //Initial delay r
+ REALTYPE tmp = inputbuf[i] + idelay[idelayk] * idelayfb;
+ inputbuf[i] = idelay[idelayk];
+ idelay[idelayk] = tmp;
+ idelayk++;
+ if(idelayk >= idelaylen)
+ idelayk = 0;
+ ;
+ }
+ }
+
+ if(bandwidth)
+ bandwidth->process(SOUND_BUFFER_SIZE, inputbuf);
+
+ if(lpf != NULL)
+ lpf->filterout(inputbuf);
+ if(hpf != NULL)
+ hpf->filterout(inputbuf);
+
+ processmono(0, efxoutl); //left
+ processmono(1, efxoutr); //right
+
+ REALTYPE lvol = rs / REV_COMBS * pan;
+ REALTYPE rvol = rs / REV_COMBS * (1.0 - pan);
+ if(insertion != 0) {
+ lvol *= 2;
+ rvol *= 2;
+ }
+ for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ efxoutl[i] *= lvol;
+ efxoutr[i] *= rvol;
+ }
+}
+
+
+/*
+ * Parameter control
+ */
+void Reverb::setvolume(const unsigned char &Pvolume)
+{
+ this->Pvolume = Pvolume;
+ if(insertion == 0) {
+ outvolume = pow(0.01, (1.0 - Pvolume / 127.0)) * 4.0;
+ volume = 1.0;
+ }
+ else {
+ volume = outvolume = Pvolume / 127.0;
+ if(Pvolume == 0)
+ cleanup();
+ }
+}
+
+void Reverb::setpan(const unsigned char &Ppan)
+{
+ this->Ppan = Ppan;
+ pan = (REALTYPE)Ppan / 127.0;
+}
+
+void Reverb::settime(const unsigned char &Ptime)
+{
+ int i;
+ REALTYPE t;
+ this->Ptime = Ptime;
+ t = pow(60.0, (REALTYPE)Ptime / 127.0) - 0.97;
+
+ for(i = 0; i < REV_COMBS * 2; i++)
+ combfb[i] =
+ -exp((REALTYPE)comblen[i] / (REALTYPE)SAMPLE_RATE * log(0.001) / t);
+ //the feedback is negative because it removes the DC
+ ;
+}
+
+void Reverb::setlohidamp(unsigned char Plohidamp)
+{
+ REALTYPE x;
+
+ if(Plohidamp < 64)
+ Plohidamp = 64; //remove this when the high part from lohidamp will be added
+
+ this->Plohidamp = Plohidamp;
+ if(Plohidamp == 64) {
+ lohidamptype = 0;
+ lohifb = 0.0;
+ }
+ else {
+ if(Plohidamp < 64)
+ lohidamptype = 1;
+ if(Plohidamp > 64)
+ lohidamptype = 2;
+ x = fabs((REALTYPE)(Plohidamp - 64) / 64.1);
+ lohifb = x * x;
+ }
+}
+
+void Reverb::setidelay(const unsigned char &Pidelay)
+{
+ REALTYPE delay;
+ this->Pidelay = Pidelay;
+ delay = pow(50 * Pidelay / 127.0, 2) - 1.0;
+
+ if(idelay != NULL)
+ delete [] idelay;
+ idelay = NULL;
+
+ idelaylen = (int) (SAMPLE_RATE * delay / 1000);
+ if(idelaylen > 1) {
+ idelayk = 0;
+ idelay = new REALTYPE[idelaylen];
+ for(int i = 0; i < idelaylen; i++)
+ idelay[i] = 0.0;
+ }
+}
+
+void Reverb::setidelayfb(const unsigned char &Pidelayfb)
+{
+ this->Pidelayfb = Pidelayfb;
+ idelayfb = Pidelayfb / 128.0;
+}
+
+void Reverb::sethpf(const unsigned char &Phpf)
+{
+ this->Phpf = Phpf;
+ if(Phpf == 0) { //No HighPass
+ if(hpf != NULL)
+ delete hpf;
+ hpf = NULL;
+ }
+ else {
+ REALTYPE fr = exp(pow(Phpf / 127.0, 0.5) * log(10000.0)) + 20.0;
+ if(hpf == NULL)
+ hpf = new AnalogFilter(3, fr, 1, 0);
+ else
+ hpf->setfreq(fr);
+ }
+}
+
+void Reverb::setlpf(const unsigned char &Plpf)
+{
+ this->Plpf = Plpf;
+ if(Plpf == 127) { //No LowPass
+ if(lpf != NULL)
+ delete lpf;
+ lpf = NULL;
+ }
+ else {
+ REALTYPE fr = exp(pow(Plpf / 127.0, 0.5) * log(25000.0)) + 40;
+ if(lpf == NULL)
+ lpf = new AnalogFilter(2, fr, 1, 0);
+ else
+ lpf->setfreq(fr);
+ }
+}
+
+void Reverb::settype(unsigned char Ptype)
+{
+ const int NUM_TYPES = 3;
+ int combtunings[NUM_TYPES][REV_COMBS] = {
+ //this is unused (for random)
+ {0, 0, 0, 0, 0, 0, 0, 0 },
+ //Freeverb by Jezar at Dreampoint
+ {1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617 },
+ //Freeverb by Jezar at Dreampoint //duplicate
+ {1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617 }
+ };
+ int aptunings[NUM_TYPES][REV_APS] = {
+ //this is unused (for random)
+ {0, 0, 0, 0 },
+ //Freeverb by Jezar at Dreampoint
+ {225, 341, 441, 556 },
+ //Freeverb by Jezar at Dreampoint (duplicate)
+ {225, 341, 441, 556 }
+ };
+
+ if(Ptype >= NUM_TYPES)
+ Ptype = NUM_TYPES - 1;
+ this->Ptype = Ptype;
+
+ REALTYPE tmp;
+ for(int i = 0; i < REV_COMBS * 2; i++) {
+ if(Ptype == 0)
+ tmp = 800.0 + (int)(RND * 1400.0);
+ else
+ tmp = combtunings[Ptype][i % REV_COMBS];
+ tmp *= roomsize;
+ if(i > REV_COMBS)
+ tmp += 23.0;
+ tmp *= SAMPLE_RATE / 44100.0; //adjust the combs according to the samplerate
+ if(tmp < 10)
+ tmp = 10;
+
+ comblen[i] = (int) tmp;
+ combk[i] = 0;
+ lpcomb[i] = 0;
+ if(comb[i] != NULL)
+ delete [] comb[i];
+ comb[i] = new REALTYPE[comblen[i]];
+ }
+
+ for(int i = 0; i < REV_APS * 2; i++) {
+ if(Ptype == 0)
+ tmp = 500 + (int)(RND * 500);
+ else
+ tmp = aptunings[Ptype][i % REV_APS];
+ tmp *= roomsize;
+ if(i > REV_APS)
+ tmp += 23.0;
+ tmp *= SAMPLE_RATE / 44100.0; //adjust the combs according to the samplerate
+ if(tmp < 10)
+ tmp = 10;
+ aplen[i] = (int) tmp;
+ apk[i] = 0;
+ if(ap[i] != NULL)
+ delete [] ap[i];
+ ap[i] = new REALTYPE[aplen[i]];
+ }
+ settime(Ptime);
+ cleanup();
+ if(bandwidth)
+ delete bandwidth;
+ bandwidth = NULL;
+ if(Ptype == 2) { //bandwidth
+ bandwidth = new Unison(SOUND_BUFFER_SIZE / 4 + 1, 2.0);
+ bandwidth->set_size(50);
+ bandwidth->set_base_frequency(1.0);
+#warning sa schimb size-ul
+ }
+}
+
+void Reverb::setroomsize(const unsigned char &Proomsize)
+{
+ this->Proomsize = Proomsize;
+ if(Proomsize == 0)
+ this->Proomsize = 64; //this is because the older versions consider roomsize=0
+ roomsize = (this->Proomsize - 64.0) / 64.0;
+ if(roomsize > 0.0)
+ roomsize *= 2.0;
+ roomsize = pow(10.0, roomsize);
+ rs = sqrt(roomsize);
+ settype(Ptype);
+}
+
+void Reverb::setbandwidth(const unsigned char &Pbandwidth) {
+ this->Pbandwidth = Pbandwidth;
+ REALTYPE v = Pbandwidth / 127.0;
+ if(bandwidth)
+ bandwidth->set_bandwidth(pow(v, 2.0) * 200.0);
+}
+
+void Reverb::setpreset(unsigned char npreset)
+{
+ const int PRESET_SIZE = 13;
+ const int NUM_PRESETS = 13;
+ unsigned char presets[NUM_PRESETS][PRESET_SIZE] = {
+ //Cathedral1
+ {80, 64, 63, 24, 0, 0, 0, 85, 5, 83, 1, 64, 20 },
+ //Cathedral2
+ {80, 64, 69, 35, 0, 0, 0, 127, 0, 71, 0, 64, 20 },
+ //Cathedral3
+ {80, 64, 69, 24, 0, 0, 0, 127, 75, 78, 1, 85, 20 },
+ //Hall1
+ {90, 64, 51, 10, 0, 0, 0, 127, 21, 78, 1, 64, 20 },
+ //Hall2
+ {90, 64, 53, 20, 0, 0, 0, 127, 75, 71, 1, 64, 20 },
+ //Room1
+ {100, 64, 33, 0, 0, 0, 0, 127, 0, 106, 0, 30, 20 },
+ //Room2
+ {100, 64, 21, 26, 0, 0, 0, 62, 0, 77, 1, 45, 20 },
+ //Basement
+ {110, 64, 14, 0, 0, 0, 0, 127, 5, 71, 0, 25, 20 },
+ //Tunnel
+ {85, 80, 84, 20, 42, 0, 0, 51, 0, 78, 1, 105, 20 },
+ //Echoed1
+ {95, 64, 26, 60, 71, 0, 0, 114, 0, 64, 1, 64, 20 },
+ //Echoed2
+ {90, 64, 40, 88, 71, 0, 0, 114, 0, 88, 1, 64, 20 },
+ //VeryLong1
+ {90, 64, 93, 15, 0, 0, 0, 114, 0, 77, 0, 95, 20 },
+ //VeryLong2
+ {90, 64, 111, 30, 0, 0, 0, 114, 90, 74, 1, 80, 20 }
+ };
+
+ if(npreset >= NUM_PRESETS)
+ npreset = NUM_PRESETS - 1;
+ for(int n = 0; n < PRESET_SIZE; n++)
+ changepar(n, presets[npreset][n]);
+ if(insertion != 0)
+ changepar(0, presets[npreset][0] / 2); //lower the volume if reverb is insertion effect
+ Ppreset = npreset;
+}
+
+
+void Reverb::changepar(const int &npar, const unsigned char &value)
+{
+ switch(npar) {
+ case 0:
+ setvolume(value);
+ break;
+ case 1:
+ setpan(value);
+ break;
+ case 2:
+ settime(value);
+ break;
+ case 3:
+ setidelay(value);
+ break;
+ case 4:
+ setidelayfb(value);
+ break;
+// case 5: setrdelay(value);
+// break;
+// case 6: seterbalance(value);
+// break;
+ case 7:
+ setlpf(value);
+ break;
+ case 8:
+ sethpf(value);
+ break;
+ case 9:
+ setlohidamp(value);
+ break;
+ case 10:
+ settype(value);
+ break;
+ case 11:
+ setroomsize(value);
+ break;
+ case 12:
+ setbandwidth(value);
+ break;
+ }
+}
+
+unsigned char Reverb::getpar(const int &npar) const
+{
+ switch(npar) {
+ case 0:
+ return Pvolume;
+ break;
+ case 1:
+ return Ppan;
+ break;
+ case 2:
+ return Ptime;
+ break;
+ case 3:
+ return Pidelay;
+ break;
+ case 4:
+ return Pidelayfb;
+ break;
+// case 5: return(Prdelay);
+// break;
+// case 6: return(Perbalance);
+// break;
+ case 7:
+ return Plpf;
+ break;
+ case 8:
+ return Phpf;
+ break;
+ case 9:
+ return Plohidamp;
+ break;
+ case 10:
+ return Ptype;
+ break;
+ case 11:
+ return Proomsize;
+ break;
+ case 12:
+ return Pbandwidth;
+ break;
+ }
+ return 0; //in case of bogus "parameter"
+}
+
diff --git a/plugins/zynaddsubfx/src/Effects/Reverb.h b/plugins/zynaddsubfx/src/Effects/Reverb.h
index ddf5900f6..d94f0bcef 100644
--- a/plugins/zynaddsubfx/src/Effects/Reverb.h
+++ b/plugins/zynaddsubfx/src/Effects/Reverb.h
@@ -1,127 +1,135 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- Reverb.h - Reverberation effect
- Copyright (C) 2002-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#ifndef REVERB_H
-#define REVERB_H
-
-
-#include "../globals.h"
-#include "../DSP/AnalogFilter.h"
-#include "Effect.h"
-
-#define REV_COMBS 8
-#define REV_APS 4
-
-/**Creates Reverberation Effects*/
-class Reverb:public Effect
-{
-public:
- Reverb(const int &insertion_,REALTYPE *efxoutl_,REALTYPE *efxoutr_);
- ~Reverb();
- void out(REALTYPE *smps_l,REALTYPE *smps_r);
- void cleanup();
-
- void setpreset(unsigned char npreset);
- void changepar(const int &npar,const unsigned char &value);
- unsigned char getpar(const int &npar)const;
-
-private:
- //Parametrii
- /**Amount of the reverb*/
- unsigned char Pvolume;
-
- /**Left/Right Panning*/
- unsigned char Ppan;
-
- /**duration of reverb*/
- unsigned char Ptime;
-
- /**Initial delay*/
- unsigned char Pidelay;
-
- /**Initial delay feedback*/
- unsigned char Pidelayfb;
-
- /**delay between ER/Reverbs*/
- unsigned char Prdelay;
-
- /**EarlyReflections/Reverb Balance*/
- unsigned char Perbalance;
-
- /**HighPassFilter*/
- unsigned char Plpf;
-
- /**LowPassFilter*/
- unsigned char Phpf;
-
- /**Low/HighFrequency Damping
- * \todo 0..63 lpf,64=off,65..127=hpf(TODO)*/
- unsigned char Plohidamp;
-
- /**Reverb type*/
- unsigned char Ptype;
-
- /**Room Size*/
- unsigned char Proomsize;
-
- //parameter control
- void setvolume(const unsigned char &Pvolume);
- void setpan(const unsigned char &Ppan);
- void settime(const unsigned char &Ptime);
- void setlohidamp(unsigned char Plohidamp);
- void setidelay(const unsigned char &Pidelay);
- void setidelayfb(const unsigned char &Pidelayfb);
- void sethpf(const unsigned char &Phpf);
- void setlpf(const unsigned char &Plpf);
- void settype( unsigned char Ptype);
- void setroomsize(const unsigned char &Proomsize);
-
- REALTYPE pan,erbalance;
- //Parametrii 2
- int lohidamptype;/**<0=disable,1=highdamp(lowpass),2=lowdamp(highpass)*/
- int idelaylen,rdelaylen;
- int idelayk;
- REALTYPE lohifb,idelayfb,roomsize,rs;//rs is used to "normalise" the volume according to the roomsize
- int comblen[REV_COMBS*2];
- int aplen[REV_APS*2];
-
- //Internal Variables
-
- REALTYPE *comb[REV_COMBS*2];
-
- int combk[REV_COMBS*2];
- REALTYPE combfb[REV_COMBS*2];/**
+#include "../globals.h"
+#include "../DSP/AnalogFilter.h"
+#include "../DSP/FFTwrapper.h"
+#include "../DSP/Unison.h"
+#include "Effect.h"
+
+#define REV_COMBS 8
+#define REV_APS 4
+
+/**Creates Reverberation Effects*/
+
+class Reverb:public Effect
+{
+ public:
+ Reverb(const int &insertion_, REALTYPE *efxoutl_, REALTYPE *efxoutr_);
+ ~Reverb();
+ void out(REALTYPE *smps_l, REALTYPE *smps_r);
+ void cleanup();
+
+ void setpreset(unsigned char npreset);
+ void changepar(const int &npar, const unsigned char &value);
+ unsigned char getpar(const int &npar) const;
+
+ private:
+ //Parametrii
+ /**Amount of the reverb*/
+ unsigned char Pvolume;
+
+ /**Left/Right Panning*/
+ unsigned char Ppan;
+
+ /**duration of reverb*/
+ unsigned char Ptime;
+
+ /**Initial delay*/
+ unsigned char Pidelay;
+
+ /**Initial delay feedback*/
+ unsigned char Pidelayfb;
+
+ /**delay between ER/Reverbs*/
+ unsigned char Prdelay;
+
+ /**EarlyReflections/Reverb Balance*/
+ unsigned char Perbalance;
+
+ /**HighPassFilter*/
+ unsigned char Plpf;
+
+ /**LowPassFilter*/
+ unsigned char Phpf;
+
+ /**Low/HighFrequency Damping
+ * \todo 0..63 lpf,64=off,65..127=hpf(TODO)*/
+ unsigned char Plohidamp;
+
+ /**Reverb type*/
+ unsigned char Ptype;
+
+ /**Room Size*/
+ unsigned char Proomsize;
+
+ /**Bandwidth */
+ unsigned char Pbandwidth;
+
+ //parameter control
+ void setvolume(const unsigned char &Pvolume);
+ void setpan(const unsigned char &Ppan);
+ void settime(const unsigned char &Ptime);
+ void setlohidamp(unsigned char Plohidamp);
+ void setidelay(const unsigned char &Pidelay);
+ void setidelayfb(const unsigned char &Pidelayfb);
+ void sethpf(const unsigned char &Phpf);
+ void setlpf(const unsigned char &Plpf);
+ void settype(unsigned char Ptype);
+ void setroomsize(const unsigned char &Proomsize);
+ void setbandwidth(const unsigned char &Pbandwidth);
+
+ REALTYPE pan, erbalance;
+ //Parameters
+ int lohidamptype; /**<0=disable,1=highdamp(lowpass),2=lowdamp(highpass)*/
+ int idelaylen, rdelaylen;
+ int idelayk;
+ REALTYPE lohifb, idelayfb, roomsize, rs; //rs is used to "normalise" the volume according to the roomsize
+ int comblen[REV_COMBS * 2];
+ int aplen[REV_APS * 2];
+ Unison *bandwidth;
+
+ //Internal Variables
+
+ REALTYPE *comb[REV_COMBS * 2];
+
+ int combk[REV_COMBS * 2];
+ REALTYPE combfb[REV_COMBS * 2]; /**type) {
+ if(midievent == NULL)
+ return;
+ switch(midievent->type) {
case SND_SEQ_EVENT_NOTEON:
- cmdtype=MidiNoteON;
- cmdchan=midievent->data.note.channel;
- cmdparams[0]=midievent->data.note.note;
- cmdparams[1]=midievent->data.note.velocity;
+ cmdtype = MidiNoteON;
+ cmdchan = midievent->data.note.channel;
+ cmdparams[0] = midievent->data.note.note;
+ cmdparams[1] = midievent->data.note.velocity;
break;
case SND_SEQ_EVENT_NOTEOFF:
- cmdtype=MidiNoteOFF;
- cmdchan=midievent->data.note.channel;
- cmdparams[0]=midievent->data.note.note;
+ cmdtype = MidiNoteOFF;
+ cmdchan = midievent->data.note.channel;
+ cmdparams[0] = midievent->data.note.note;
break;
case SND_SEQ_EVENT_PITCHBEND:
- cmdtype=MidiController;
- cmdchan=midievent->data.control.channel;
- cmdparams[0]=C_pitchwheel;//Pitch Bend
- cmdparams[1]=midievent->data.control.value;
+ cmdtype = MidiController;
+ cmdchan = midievent->data.control.channel;
+ cmdparams[0] = C_pitchwheel; //Pitch Bend
+ cmdparams[1] = midievent->data.control.value;
break;
case SND_SEQ_EVENT_CONTROLLER:
- cmdtype=MidiController;
- cmdchan=midievent->data.control.channel;
- cmdparams[0]=getcontroller(midievent->data.control.param);
- cmdparams[1]=midievent->data.control.value;
+ cmdtype = MidiController;
+ cmdchan = midievent->data.control.channel;
+ cmdparams[0] = getcontroller(midievent->data.control.param);
+ cmdparams[1] = midievent->data.control.value;
//fprintf(stderr,"t=%d val=%d\n",midievent->data.control.param,midievent->data.control.value);
break;
-
- };
-};
+ }
+}
int ALSAMidiIn::getalsaid()
{
- if (midi_handle) {
- snd_seq_client_info_t* seq_info;
+ if(midi_handle) {
+ snd_seq_client_info_t *seq_info;
snd_seq_client_info_malloc(&seq_info);
snd_seq_get_client_info(midi_handle, seq_info);
int id = snd_seq_client_info_get_client(seq_info);
diff --git a/plugins/zynaddsubfx/src/Input/ALSAMidiIn.h b/plugins/zynaddsubfx/src/Input/ALSAMidiIn.h
index e4671014f..cea61fb36 100644
--- a/plugins/zynaddsubfx/src/Input/ALSAMidiIn.h
+++ b/plugins/zynaddsubfx/src/Input/ALSAMidiIn.h
@@ -30,19 +30,21 @@
/**Midi input for ALSA (this creates an ALSA virtual port)*/
class ALSAMidiIn:public MidiIn
{
-public:
- /**Constructor*/
- ALSAMidiIn();
- /**Destructor*/
- ~ALSAMidiIn();
+ public:
+ /**Constructor*/
+ ALSAMidiIn();
+ /**Destructor*/
+ ~ALSAMidiIn();
- void getmidicmd(MidiCmdType &cmdtype,unsigned char &cmdchan,int *cmdparams);
- /**Get the ALSA id
- * @return ALSA id*/
- int getalsaid();
+ void getmidicmd(MidiCmdType &cmdtype,
+ unsigned char &cmdchan,
+ int *cmdparams);
+ /**Get the ALSA id
+ * @return ALSA id*/
+ int getalsaid();
-private:
- snd_seq_t *midi_handle;
+ private:
+ snd_seq_t *midi_handle;
};
#endif
diff --git a/plugins/zynaddsubfx/src/Input/MidiIn.cpp b/plugins/zynaddsubfx/src/Input/MidiIn.cpp
index 2355b3a64..90df75d95 100644
--- a/plugins/zynaddsubfx/src/Input/MidiIn.cpp
+++ b/plugins/zynaddsubfx/src/Input/MidiIn.cpp
@@ -26,70 +26,71 @@
int MidiIn::getcontroller(unsigned char b)
{
/**\todo there might be a better way to do this*/
- int ctl=C_NULL;
- switch (b) {
+ int ctl = C_NULL;
+ switch(b) {
case 1:
- ctl=C_modwheel;//Modulation Wheel
+ ctl = C_modwheel; //Modulation Wheel
break;
case 7:
- ctl=C_volume;//Volume
+ ctl = C_volume; //Volume
break;
case 10:
- ctl=C_panning;//Panning
+ ctl = C_panning; //Panning
break;
case 11:
- ctl=C_expression;//Expression
+ ctl = C_expression; //Expression
break;
case 64:
- ctl=C_sustain;//Sustain pedal
+ ctl = C_sustain; //Sustain pedal
break;
case 65:
- ctl=C_portamento;//Portamento
+ ctl = C_portamento; //Portamento
break;
case 71:
- ctl=C_filterq;//Filter Q (Sound Timbre)
+ ctl = C_filterq; //Filter Q (Sound Timbre)
break;
case 74:
- ctl=C_filtercutoff;//Filter Cutoff (Brightness)
+ ctl = C_filtercutoff; //Filter Cutoff (Brightness)
break;
case 75:
- ctl=C_bandwidth;//BandWidth
+ ctl = C_bandwidth; //BandWidth
break;
case 76:
- ctl=C_fmamp;//FM amplitude
+ ctl = C_fmamp; //FM amplitude
break;
case 77:
- ctl=C_resonance_center;//Resonance Center Frequency
+ ctl = C_resonance_center; //Resonance Center Frequency
break;
case 78:
- ctl=C_resonance_bandwidth;//Resonance Bandwith
+ ctl = C_resonance_bandwidth; //Resonance Bandwith
break;
case 120:
- ctl=C_allsoundsoff;//All Sounds OFF
+ ctl = C_allsoundsoff; //All Sounds OFF
break;
case 121:
- ctl=C_resetallcontrollers;//Reset All Controllers
+ ctl = C_resetallcontrollers; //Reset All Controllers
break;
case 123:
- ctl=C_allnotesoff;//All Notes OFF
+ ctl = C_allnotesoff; //All Notes OFF
break;
- //RPN and NRPN
+ //RPN and NRPN
case 0x06:
- ctl=C_dataentryhi;//Data Entry (Coarse)
+ ctl = C_dataentryhi; //Data Entry (Coarse)
break;
case 0x26:
- ctl=C_dataentrylo;//Data Entry (Fine)
+ ctl = C_dataentrylo; //Data Entry (Fine)
break;
case 99:
- ctl=C_nrpnhi;//NRPN (Coarse)
+ ctl = C_nrpnhi; //NRPN (Coarse)
break;
case 98:
- ctl=C_nrpnlo;//NRPN (Fine)
+ ctl = C_nrpnlo; //NRPN (Fine)
break;
default:
- ctl=C_NULL;//unknown controller
+ ctl = C_NULL; //unknown controller
//fprintf(stderr,"Controller=%d , par=%d\n",midievent->data.control.param,cmdparams[1]);
break;
- };
- return(ctl);
-};
+ }
+ return ctl;
+}
+
diff --git a/plugins/zynaddsubfx/src/Input/MidiIn.h b/plugins/zynaddsubfx/src/Input/MidiIn.h
index f02d10e76..5d978eaeb 100644
--- a/plugins/zynaddsubfx/src/Input/MidiIn.h
+++ b/plugins/zynaddsubfx/src/Input/MidiIn.h
@@ -25,23 +25,27 @@
#include "../globals.h"
-enum MidiCmdType {MidiNull,MidiNoteOFF,MidiNoteON,MidiController};
+enum MidiCmdType {
+ MidiNull, MidiNoteOFF, MidiNoteON, MidiController
+};
#define MP_MAX_BYTES 4000 //in case of loooong SYS_EXes
/**This class is inherited by all the Midi input classes*/
class MidiIn
{
-public:
- /**Get the command,channel and parameters of the MIDI
- *
- * \todo make pure virtual
- * @param cmdtype the referece to the variable that will store the type
- * @param cmdchan the channel for the event
- * @param parameters for the event*/
- virtual void getmidicmd(MidiCmdType &cmdtype,unsigned char &cmdchan,int *cmdparams)=0;
- int getcontroller(unsigned char b);
-protected:
- bool inputok;/**<1 if I can read midi bytes from input ports*/
+ public:
+ /**Get the command,channel and parameters of the MIDI
+ *
+ * \todo make pure virtual
+ * @param cmdtype the referece to the variable that will store the type
+ * @param cmdchan the channel for the event
+ * @param parameters for the event*/
+ virtual void getmidicmd(MidiCmdType &cmdtype,
+ unsigned char &cmdchan,
+ int *cmdparams) = 0;
+ int getcontroller(unsigned char b);
+ protected:
+ bool inputok; /**<1 if I can read midi bytes from input ports*/
};
#endif
diff --git a/plugins/zynaddsubfx/src/Input/NULLMidiIn.cpp b/plugins/zynaddsubfx/src/Input/NULLMidiIn.cpp
index 2a727ac7e..22ee76d75 100644
--- a/plugins/zynaddsubfx/src/Input/NULLMidiIn.cpp
+++ b/plugins/zynaddsubfx/src/Input/NULLMidiIn.cpp
@@ -23,19 +23,19 @@
#include "NULLMidiIn.h"
NULLMidiIn::NULLMidiIn()
-{
-};
+{}
NULLMidiIn::~NULLMidiIn()
-{
-};
+{}
/*
* Get the midi command,channel and parameters
* It returns MidiNull because it is a dummy driver
*/
-void NULLMidiIn::getmidicmd(MidiCmdType &cmdtype,unsigned char &cmdchan,int *cmdparams)
+void NULLMidiIn::getmidicmd(MidiCmdType &cmdtype,
+ unsigned char &cmdchan,
+ int *cmdparams)
{
- cmdtype=MidiNull;
-};
+ cmdtype = MidiNull;
+}
diff --git a/plugins/zynaddsubfx/src/Input/NULLMidiIn.h b/plugins/zynaddsubfx/src/Input/NULLMidiIn.h
index 636302c57..72cef4ad0 100644
--- a/plugins/zynaddsubfx/src/Input/NULLMidiIn.h
+++ b/plugins/zynaddsubfx/src/Input/NULLMidiIn.h
@@ -29,19 +29,21 @@
/**a dummy Midi port*/
class NULLMidiIn:public MidiIn
{
-public:
- /**Dummy Constructor
- * \todo see if the default constructor would work here*/
- NULLMidiIn();
- /**Dummy Destructor
- * \todo see if the default destructor would work here*/
- ~NULLMidiIn();
- /**Get the midi command,channel and parameters
- * It returns MidiNull because it is a dummy driver
- */
- void getmidicmd(MidiCmdType &cmdtype,unsigned char &cmdchan,int *cmdparams);
+ public:
+ /**Dummy Constructor
+ * \todo see if the default constructor would work here*/
+ NULLMidiIn();
+ /**Dummy Destructor
+ * \todo see if the default destructor would work here*/
+ ~NULLMidiIn();
+ /**Get the midi command,channel and parameters
+ * It returns MidiNull because it is a dummy driver
+ */
+ void getmidicmd(MidiCmdType &cmdtype,
+ unsigned char &cmdchan,
+ int *cmdparams);
-private:
+ private:
};
#endif
diff --git a/plugins/zynaddsubfx/src/Input/OSSMidiIn.cpp b/plugins/zynaddsubfx/src/Input/OSSMidiIn.cpp
index 440775abd..b278ae6bf 100644
--- a/plugins/zynaddsubfx/src/Input/OSSMidiIn.cpp
+++ b/plugins/zynaddsubfx/src/Input/OSSMidiIn.cpp
@@ -33,88 +33,91 @@
OSSMidiIn::OSSMidiIn()
{
- inputok=false;
- midi_handle=open(config.cfg.LinuxOSSSeqInDev,O_RDONLY,0);
- if (midi_handle!=-1) inputok=true;
+ inputok = false;
+ midi_handle = open(config.cfg.LinuxOSSSeqInDev, O_RDONLY, 0);
+ if(midi_handle != -1)
+ inputok = true;
- lastmidicmd=0;
- cmdtype=0;
- cmdchan=0;
-
-};
+ lastmidicmd = 0;
+ cmdtype = 0;
+ cmdchan = 0;
+}
OSSMidiIn::~OSSMidiIn()
{
close(midi_handle);
-};
+}
unsigned char OSSMidiIn::readbyte()
{
unsigned char tmp[4];
- read(midi_handle,&tmp[0],1);
- while (tmp[0]!=SEQ_MIDIPUTC) {
- read(midi_handle,&tmp[0],4);
+ read(midi_handle, &tmp[0], 1);
+ while(tmp[0] != SEQ_MIDIPUTC) {
+ read(midi_handle, &tmp[0], 4);
}
- return(tmp[1]);
-};
+ return tmp[1];
+}
unsigned char OSSMidiIn::getmidibyte()
{
unsigned char b;
do {
- b=readbyte();
- } while (b==0xfe);//drops the Active Sense Messages
- return(b);
-};
+ b = readbyte();
+ } while(b == 0xfe); //drops the Active Sense Messages
+ return b;
+}
/*
* Get the midi command,channel and parameters
*/
-void OSSMidiIn::getmidicmd(MidiCmdType &cmdtype,unsigned char &cmdchan,int *cmdparams)
+void OSSMidiIn::getmidicmd(MidiCmdType &cmdtype,
+ unsigned char &cmdchan,
+ int *cmdparams)
{
- unsigned char tmp,i;
- if (inputok==false) {
- cmdtype=MidiNull;
+ unsigned char tmp, i;
+ if(inputok == false) {
+ cmdtype = MidiNull;
return;
}
- i=0;
- if (lastmidicmd==0) {//asteapta prima data pana cand vine prima comanda midi
- while (tmp<0x80) tmp=getmidibyte();
- lastmidicmd=tmp;
+ i = 0;
+ if(lastmidicmd == 0) { //asteapta prima data pana cand vine prima comanda midi
+ while(tmp < 0x80)
+ tmp = getmidibyte();
+ lastmidicmd = tmp;
}
- tmp=getmidibyte();
+ tmp = getmidibyte();
- if (tmp>=0x80) {
- lastmidicmd=tmp;
- tmp=getmidibyte();
+ if(tmp >= 0x80) {
+ lastmidicmd = tmp;
+ tmp = getmidibyte();
}
- if ((lastmidicmd>=0x80)&&(lastmidicmd<=0x8f)) {//Note OFF
- cmdtype=MidiNoteOFF;
- cmdchan=lastmidicmd%16;
- cmdparams[0]=tmp;//note number
+ if((lastmidicmd >= 0x80) && (lastmidicmd <= 0x8f)) { //Note OFF
+ cmdtype = MidiNoteOFF;
+ cmdchan = lastmidicmd % 16;
+ cmdparams[0] = tmp; //note number
}
- if ((lastmidicmd>=0x90)&&(lastmidicmd<=0x9f)) {//Note ON
- cmdtype=MidiNoteON;
- cmdchan=lastmidicmd%16;
- cmdparams[0]=tmp;//note number
- cmdparams[1]=getmidibyte();//velocity
- if (cmdparams[1]==0) cmdtype=MidiNoteOFF;//if velocity==0 then is note off
+ if((lastmidicmd >= 0x90) && (lastmidicmd <= 0x9f)) { //Note ON
+ cmdtype = MidiNoteON;
+ cmdchan = lastmidicmd % 16;
+ cmdparams[0] = tmp; //note number
+ cmdparams[1] = getmidibyte(); //velocity
+ if(cmdparams[1] == 0)
+ cmdtype = MidiNoteOFF; //if velocity==0 then is note off
}
- if ((lastmidicmd>=0xB0)&&(lastmidicmd<=0xBF)) {//Controllers
- cmdtype=MidiController;
- cmdchan=lastmidicmd%16;
- cmdparams[0]=getcontroller(tmp);
- cmdparams[1]=getmidibyte();
+ if((lastmidicmd >= 0xB0) && (lastmidicmd <= 0xBF)) { //Controllers
+ cmdtype = MidiController;
+ cmdchan = lastmidicmd % 16;
+ cmdparams[0] = getcontroller(tmp);
+ cmdparams[1] = getmidibyte();
}
- if ((lastmidicmd>=0xE0)&&(lastmidicmd<=0xEF)) {//Pitch Wheel
- cmdtype=MidiController;
- cmdchan=lastmidicmd%16;
- cmdparams[0]=C_pitchwheel;
- cmdparams[1]=(tmp+getmidibyte()*(int) 128)-8192;//hope this is correct
+ if((lastmidicmd >= 0xE0) && (lastmidicmd <= 0xEF)) { //Pitch Wheel
+ cmdtype = MidiController;
+ cmdchan = lastmidicmd % 16;
+ cmdparams[0] = C_pitchwheel;
+ cmdparams[1] = (tmp + getmidibyte() * (int) 128) - 8192; //hope this is correct
}
-};
-
+}
diff --git a/plugins/zynaddsubfx/src/Input/OSSMidiIn.h b/plugins/zynaddsubfx/src/Input/OSSMidiIn.h
index 7626950ed..a3b56f51b 100644
--- a/plugins/zynaddsubfx/src/Input/OSSMidiIn.h
+++ b/plugins/zynaddsubfx/src/Input/OSSMidiIn.h
@@ -27,21 +27,22 @@
class OSSMidiIn:public MidiIn
{
-public:
- OSSMidiIn();
- ~OSSMidiIn();
- unsigned char getmidibyte();
- unsigned char readbyte();
+ public:
+ OSSMidiIn();
+ ~OSSMidiIn();
+ unsigned char getmidibyte();
+ unsigned char readbyte();
- //Midi parser
- void getmidicmd(MidiCmdType &cmdtype,unsigned char &cmdchan,int *cmdparams);
- unsigned char cmdtype;//the Message Type (noteon,noteof,sysex..)
- unsigned char cmdchan;//the channel number
-
-private:
- int midi_handle;
- unsigned char lastmidicmd;//last byte (>=80) received from the Midi
+ //Midi parser
+ void getmidicmd(MidiCmdType &cmdtype,
+ unsigned char &cmdchan,
+ int *cmdparams);
+ unsigned char cmdtype; //the Message Type (noteon,noteof,sysex..)
+ unsigned char cmdchan; //the channel number
+ private:
+ int midi_handle;
+ unsigned char lastmidicmd; //last byte (>=80) received from the Midi
};
diff --git a/plugins/zynaddsubfx/src/Input/WINMidiIn.cpp b/plugins/zynaddsubfx/src/Input/WINMidiIn.cpp
index 155aa7375..e8462457d 100644
--- a/plugins/zynaddsubfx/src/Input/WINMidiIn.cpp
+++ b/plugins/zynaddsubfx/src/Input/WINMidiIn.cpp
@@ -32,56 +32,63 @@
Master *winmaster;
HMIDIIN winmidiinhandle;
-MidiIn midictl;//used to convert the controllers to ZynAddSubFX controllers
+MidiIn midictl; //used to convert the controllers to ZynAddSubFX controllers
-void CALLBACK WinMidiInProc(HMIDIIN hMidiIn,UINT wMsg,DWORD dwInstance,
- DWORD dwParam1,DWORD dwParam2)
+void CALLBACK WinMidiInProc(HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance,
+ DWORD dwParam1, DWORD dwParam2)
{
- int midicommand=MidiNull;
- if (wMsg==MIM_DATA) {
- int cmd,par1,par2;
- cmd=dwParam1&0xff;
- if (cmd==0xfe) return;
- par1=(dwParam1>>8)&0xff;
- par2=dwParam1>>16;
+ int midicommand = MidiNull;
+ if(wMsg == MIM_DATA) {
+ int cmd, par1, par2;
+ cmd = dwParam1 & 0xff;
+ if(cmd == 0xfe)
+ return;
+ par1 = (dwParam1 >> 8) & 0xff;
+ par2 = dwParam1 >> 16;
//printf("%x %x %x\n",cmd,par1,par2);fflush(stdout);
- int cmdchan=cmd&0x0f;
- int cmdtype=(cmd>>4)&0x0f;
+ int cmdchan = cmd & 0x0f;
+ int cmdtype = (cmd >> 4) & 0x0f;
- int tmp=0;
+ int tmp = 0;
pthread_mutex_lock(&winmaster->mutex);
- switch (cmdtype) {
- case(0x8)://noteon
- winmaster->NoteOff(cmdchan,par1);
+ switch(cmdtype) {
+ case (0x8): //noteon
+ winmaster->NoteOff(cmdchan, par1);
break;
- case(0x9)://noteoff
- winmaster->NoteOn(cmdchan,par1,par2&0xff);
+ case (0x9): //noteoff
+ winmaster->NoteOn(cmdchan, par1, par2 & 0xff);
break;
- case(0xb)://controller
- winmaster->SetController(cmdchan,midictl.getcontroller(par1),par2&0xff);
+ case (0xb): //controller
+ winmaster->SetController(cmdchan, midictl.getcontroller(
+ par1), par2 & 0xff);
break;
- case(0xe)://pitch wheel
- tmp=(par1+par2*(long int) 128)-8192;
- winmaster->SetController(cmdchan,C_pitchwheel,tmp);
+ case (0xe): //pitch wheel
+ tmp = (par1 + par2 * (long int) 128) - 8192;
+ winmaster->SetController(cmdchan, C_pitchwheel, tmp);
break;
default:
break;
- };
+ }
pthread_mutex_unlock(&winmaster->mutex);
-
- };
-};
+ }
+}
void InitWinMidi(Master *master_)
{
- winmaster=master_;
+ winmaster = master_;
- long int result=midiInOpen(&winmidiinhandle,config.cfg.WindowsMidiInId,(DWORD)WinMidiInProc,0,CALLBACK_FUNCTION);
- result=midiInStart(winmidiinhandle);
-};
+ long int result =
+ midiInOpen(&winmidiinhandle,
+ config.cfg.WindowsMidiInId,
+ (DWORD)WinMidiInProc,
+ 0,
+ CALLBACK_FUNCTION);
+ result = midiInStart(winmidiinhandle);
+}
void StopWinMidi()
{
midiInStop(winmidiinhandle);
midiInClose(winmidiinhandle);
-};
+}
+
diff --git a/plugins/zynaddsubfx/src/Misc/Bank.cpp b/plugins/zynaddsubfx/src/Misc/Bank.cpp
index 4c1b27a96..256184736 100644
--- a/plugins/zynaddsubfx/src/Misc/Bank.cpp
+++ b/plugins/zynaddsubfx/src/Misc/Bank.cpp
@@ -41,183 +41,213 @@
Bank::Bank()
{
+ ZERO(defaultinsname, PART_MAX_NAME_LEN);
+ snprintf(defaultinsname, PART_MAX_NAME_LEN, "%s", " ");
-
- ZERO(defaultinsname,PART_MAX_NAME_LEN);
- snprintf(defaultinsname,PART_MAX_NAME_LEN,"%s"," ");
-
- for (int i=0;i=0) snprintf(tmpfilename,100,"%4d-%s",newslot+1,newname);
- else snprintf(tmpfilename,100,"%4d-%s",ninstrument+1,newname);
+ ZERO(newfilename, 1001);
+ ZERO(tmpfilename, 101);
+ if(newslot >= 0)
+ snprintf(tmpfilename, 100, "%4d-%s", newslot + 1, newname);
+ else
+ snprintf(tmpfilename, 100, "%4d-%s", ninstrument + 1, newname);
//add the zeroes at the start of filename
- for (int i=0;i<4;i++) if (tmpfilename[i]==' ') tmpfilename[i]='0';
+ for(int i = 0; i < 4; i++)
+ if(tmpfilename[i] == ' ')
+ tmpfilename[i] = '0';
//make the filenames legal
- for (int i=0;i<(int) strlen(tmpfilename);i++) {
- char c=tmpfilename[i];
- if ((c>='0')&&(c<='9')) continue;
- if ((c>='A')&&(c<='Z')) continue;
- if ((c>='a')&&(c<='z')) continue;
- if ((c=='-')||(c==' ')) continue;
+ for(int i = 0; i < (int) strlen(tmpfilename); i++) {
+ char c = tmpfilename[i];
+ if((c >= '0') && (c <= '9'))
+ continue;
+ if((c >= 'A') && (c <= 'Z'))
+ continue;
+ if((c >= 'a') && (c <= 'z'))
+ continue;
+ if((c == '-') || (c == ' '))
+ continue;
- tmpfilename[i]='_';
- };
+ tmpfilename[i] = '_';
+ }
- snprintf(newfilename,1000,"%s/%s.xiz",dirname,tmpfilename);
+ snprintf(newfilename, 1000, "%s/%s.xiz", dirname, tmpfilename);
// printf("rename %s -> %s\n",ins[ninstrument].filename,newfilename);//////////////
- rename(ins[ninstrument].filename,newfilename);
- if (ins[ninstrument].filename) delete []ins[ninstrument].filename;
- ins[ninstrument].filename=new char[strlen(newfilename)+5];
- snprintf(ins[ninstrument].filename,strlen(newfilename)+1,"%s",newfilename);
- snprintf(ins[ninstrument].name,PART_MAX_NAME_LEN,"%s",&tmpfilename[5]);
-
-};
+ rename(ins[ninstrument].filename, newfilename);
+ if(ins[ninstrument].filename)
+ delete [] ins[ninstrument].filename;
+ ins[ninstrument].filename = new char[strlen(newfilename) + 5];
+ snprintf(ins[ninstrument].filename, strlen(
+ newfilename) + 1, "%s", newfilename);
+ snprintf(ins[ninstrument].name, PART_MAX_NAME_LEN, "%s", &tmpfilename[5]);
+}
/*
* Check if there is no instrument on a slot from the bank
*/
int Bank::emptyslot(unsigned int ninstrument)
{
- if (ninstrument>=BANK_SIZE) return (1);
- if (ins[ninstrument].filename==NULL) return(1);
+ if(ninstrument >= BANK_SIZE)
+ return 1;
+ if(ins[ninstrument].filename == NULL)
+ return 1;
- if (ins[ninstrument].used) return (0);
- else return(1);
-};
+ if(ins[ninstrument].used)
+ return 0;
+ else
+ return 1;
+}
/*
* Removes the instrument from the bank
*/
void Bank::clearslot(unsigned int ninstrument)
{
- if (emptyslot(ninstrument)) return;
+ if(emptyslot(ninstrument))
+ return;
// printf("remove %s \n",ins[ninstrument].filename);////////////////////////
remove(ins[ninstrument].filename);
deletefrombank(ninstrument);
-};
+}
/*
* Save the instrument to a slot
*/
-void Bank::savetoslot(unsigned int ninstrument,Part *part)
+void Bank::savetoslot(unsigned int ninstrument, Part *part)
{
clearslot(ninstrument);
- const int maxfilename=200;
- char tmpfilename[maxfilename+20];
- ZERO(tmpfilename,maxfilename+20);
+ const int maxfilename = 200;
+ char tmpfilename[maxfilename + 20];
+ ZERO(tmpfilename, maxfilename + 20);
- snprintf(tmpfilename,maxfilename,"%4d-%s",ninstrument+1,(char *)part->Pname);
+ snprintf(tmpfilename,
+ maxfilename,
+ "%4d-%s",
+ ninstrument + 1,
+ (char *)part->Pname);
//add the zeroes at the start of filename
- for (int i=0;i<4;i++) if (tmpfilename[i]==' ') tmpfilename[i]='0';
+ for(int i = 0; i < 4; i++)
+ if(tmpfilename[i] == ' ')
+ tmpfilename[i] = '0';
//make the filenames legal
- for (int i=0;i<(int)strlen(tmpfilename);i++) {
- char c=tmpfilename[i];
- if ((c>='0')&&(c<='9')) continue;
- if ((c>='A')&&(c<='Z')) continue;
- if ((c>='a')&&(c<='z')) continue;
- if ((c=='-')||(c==' ')) continue;
+ for(int i = 0; i < (int)strlen(tmpfilename); i++) {
+ char c = tmpfilename[i];
+ if((c >= '0') && (c <= '9'))
+ continue;
+ if((c >= 'A') && (c <= 'Z'))
+ continue;
+ if((c >= 'a') && (c <= 'z'))
+ continue;
+ if((c == '-') || (c == ' '))
+ continue;
- tmpfilename[i]='_';
- };
+ tmpfilename[i] = '_';
+ }
- strncat(tmpfilename,".xiz",maxfilename+10);
+ strncat(tmpfilename, ".xiz", maxfilename + 10);
- int fnsize=strlen(dirname)+strlen(tmpfilename)+10;
- char *filename=new char[fnsize+4];
- ZERO(filename,fnsize+2);
+ int fnsize = strlen(dirname) + strlen(tmpfilename) + 10;
+ char *filename = new char[fnsize + 4];
+ ZERO(filename, fnsize + 2);
- snprintf(filename,fnsize,"%s/%s",dirname,tmpfilename);
+ snprintf(filename, fnsize, "%s/%s", dirname, tmpfilename);
remove(filename);
part->saveXML(filename);
- addtobank(ninstrument,tmpfilename,(char *) part->Pname);
+ addtobank(ninstrument, tmpfilename, (char *) part->Pname);
- delete[]filename;
-};
+ delete[] filename;
+}
/*
* Loads the instrument from the bank
*/
-void Bank::loadfromslot(unsigned int ninstrument,Part *part)
+void Bank::loadfromslot(unsigned int ninstrument, Part *part)
{
- if (emptyslot(ninstrument)) return;
+ if(emptyslot(ninstrument))
+ return;
part->defaultsinstrument();
// printf("load: %s\n",ins[ninstrument].filename);
part->loadXMLinstrument(ins[ninstrument].filename);
-
-};
+}
/*
@@ -225,160 +255,173 @@ void Bank::loadfromslot(unsigned int ninstrument,Part *part)
*/
int Bank::loadbank(const char *bankdirname)
{
- DIR *dir=opendir(bankdirname);
+ DIR *dir = opendir(bankdirname);
clearbank();
- if (dir==NULL) return(-1);
+ if(dir == NULL)
+ return -1;
- if (dirname!=NULL) delete[]dirname;
- dirname=new char[strlen(bankdirname)+1];
- snprintf(dirname,strlen(bankdirname)+1,"%s",bankdirname);
+ if(dirname != NULL)
+ delete[] dirname;
+ dirname = new char[strlen(bankdirname) + 1];
+ snprintf(dirname, strlen(bankdirname) + 1, "%s", bankdirname);
- bankfiletitle=dirname;
+ bankfiletitle = dirname;
// printf("loadbank %s/\n",bankdirname);
struct dirent *fn;
- while ((fn=readdir(dir))) {
- const char *filename= fn->d_name;
+ while((fn = readdir(dir))) {
+ const char *filename = fn->d_name;
//sa verific daca e si extensia dorita
- if (strstr(filename,INSTRUMENT_EXTENSION)==NULL) continue;
+ if(strstr(filename, INSTRUMENT_EXTENSION) == NULL)
+ continue;
//verify if the name is like this NNNN-name (where N is a digit)
- int no=0;
- unsigned int startname=0;
+ int no = 0;
+ unsigned int startname = 0;
- for (unsigned int i=0;i<4;i++) {
- if (strlen(filename)<=i) break;
+ for(unsigned int i = 0; i < 4; i++) {
+ if(strlen(filename) <= i)
+ break;
- if ((filename[i]>='0')&&(filename[i]<='9')) {
- no=no*10+(filename[i]-'0');
+ if((filename[i] >= '0') && (filename[i] <= '9')) {
+ no = no * 10 + (filename[i] - '0');
startname++;
- };
- };
+ }
+ }
- if ((startname+1)=2;i--) {
- if (name[i]=='.') {
- name[i]='\0';
+ for(int i = strlen(name) - 1; i >= 2; i--) {
+ if(name[i] == '.') {
+ name[i] = '\0';
break;
- };
- };
+ }
+ }
- if (no!=0) {//the instrument position in the bank is found
- addtobank(no-1,filename,&name[startname]);
- } else {
- addtobank(-1,filename,name);
- };
-
- };
+ if(no != 0) //the instrument position in the bank is found
+ addtobank(no - 1, filename, &name[startname]);
+ else
+ addtobank(-1, filename, name);
+ ;
+ }
closedir(dir);
- if (dirname!=NULL) {
- sprintf(config.cfg.currentBankDir,"%s",dirname);
- };
+ if(dirname != NULL)
+ sprintf(config.cfg.currentBankDir, "%s", dirname);
+ ;
- return(0);
-};
+ return 0;
+}
/*
* Makes a new bank, put it on a file and makes it current bank
*/
int Bank::newbank(const char *newbankdirname)
{
- int result;
+ int result;
char tmpfilename[MAX_STRING_SIZE];
char bankdir[MAX_STRING_SIZE];
- snprintf(bankdir,MAX_STRING_SIZE,"%s",config.cfg.bankRootDirList[0]);
+ snprintf(bankdir, MAX_STRING_SIZE, "%s", config.cfg.bankRootDirList[0]);
- if (((bankdir[strlen(bankdir)-1])!='/')&&((bankdir[strlen(bankdir)-1])!='\\')) {
- strncat(bankdir,"/",MAX_STRING_SIZE);
- };
- strncat(bankdir,newbankdirname,MAX_STRING_SIZE);
+ if(((bankdir[strlen(bankdir) - 1]) != '/')
+ && ((bankdir[strlen(bankdir) - 1]) != '\\'))
+ strncat(bankdir, "/", MAX_STRING_SIZE);
+ ;
+ strncat(bankdir, newbankdirname, MAX_STRING_SIZE);
#ifdef OS_WINDOWS
- result=mkdir(bankdir);
+ result = mkdir(bankdir);
#else
- result=mkdir(bankdir,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+ result = mkdir(bankdir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#endif
- if (result<0) return(-1);
+ if(result < 0)
+ return -1;
- snprintf(tmpfilename,MAX_STRING_SIZE,"%s/%s",bankdir,FORCE_BANK_DIR_FILE);
+ snprintf(tmpfilename,
+ MAX_STRING_SIZE,
+ "%s/%s",
+ bankdir,
+ FORCE_BANK_DIR_FILE);
// printf("%s\n",tmpfilename);
- FILE *tmpfile=fopen(tmpfilename,"w+");
+ FILE *tmpfile = fopen(tmpfilename, "w+");
fclose(tmpfile);
- return(loadbank(bankdir));
-};
+ return loadbank(bankdir);
+}
/*
* Check if the bank is locked (i.e. the file opened was readonly)
*/
int Bank::locked()
{
- return(dirname==NULL);
-};
+ return dirname == NULL;
+}
/*
* Swaps a slot with another
*/
void Bank::swapslot(unsigned int n1, unsigned int n2)
{
- if ((n1==n2)||(locked())) return;
- if (emptyslot(n1)&&(emptyslot(n2))) return;
- if (emptyslot(n1)) {//change n1 to n2 in order to make
- int tmp=n2;
- n2=n1;
- n1=tmp;
- };
+ if((n1 == n2) || (locked()))
+ return;
+ if(emptyslot(n1) && (emptyslot(n2)))
+ return;
+ if(emptyslot(n1)) { //change n1 to n2 in order to make
+ int tmp = n2;
+ n2 = n1;
+ n1 = tmp;
+ }
- if (emptyslot(n2)) {//this is just a movement from slot1 to slot2
- setname(n1,getname(n1),n2);
- ins[n2]=ins[n1];
- ins[n1].used=false;
- ins[n1].name[0]='\0';
- ins[n1].filename=NULL;
- ins[n1].info.PADsynth_used=0;
- } else {//if both slots are used
- if (strcmp(ins[n1].name,ins[n2].name)==0) {//change the name of the second instrument if the name are equal
- strncat(ins[n2].name,"2",PART_MAX_NAME_LEN);
- };
- setname(n1,getname(n1),n2);
- setname(n2,getname(n2),n1);
+ if(emptyslot(n2)) { //this is just a movement from slot1 to slot2
+ setname(n1, getname(n1), n2);
+ ins[n2] = ins[n1];
+ ins[n1].used = false;
+ ins[n1].name[0] = '\0';
+ ins[n1].filename = NULL;
+ ins[n1].info.PADsynth_used = 0;
+ }
+ else { //if both slots are used
+ if(strcmp(ins[n1].name, ins[n2].name) == 0) //change the name of the second instrument if the name are equal
+ strncat(ins[n2].name, "2", PART_MAX_NAME_LEN);
+ ;
+ setname(n1, getname(n1), n2);
+ setname(n2, getname(n2), n1);
ins_t tmp;
- tmp.used=true;
- strcpy(tmp.name,ins[n2].name);
- char *tmpfilename=ins[n2].filename;
- bool padsynth_used=ins[n2].info.PADsynth_used;
+ tmp.used = true;
+ strcpy(tmp.name, ins[n2].name);
+ char *tmpfilename = ins[n2].filename;
+ bool padsynth_used = ins[n2].info.PADsynth_used;
- ins[n2]=ins[n1];
- strcpy(ins[n1].name,tmp.name);
- ins[n1].filename=tmpfilename;
- ins[n1].info.PADsynth_used=padsynth_used;
- };
-
-};
+ ins[n2] = ins[n1];
+ strcpy(ins[n1].name, tmp.name);
+ ins[n1].filename = tmpfilename;
+ ins[n1].info.PADsynth_used = padsynth_used;
+ }
+}
//a helper function that compares 2 banks[] arrays
-int Bank_compar(const void *a,const void *b)
+int Bank_compar(const void *a, const void *b)
{
- struct Bank::bankstruct *bank1= (Bank::bankstruct *)a;
- struct Bank::bankstruct *bank2= (Bank::bankstruct *)b;
- if (((bank1->name)==NULL)||((bank2->name)==NULL)) return(0);
+ struct Bank::bankstruct *bank1 = (Bank::bankstruct *)a;
+ struct Bank::bankstruct *bank2 = (Bank::bankstruct *)b;
+ if(((bank1->name) == NULL) || ((bank2->name) == NULL))
+ return 0;
- int result=strcasecmp(bank1->name,bank2->name);
- return(result<0);
-};
+ int result = strcasecmp(bank1->name, bank2->name);
+ return result < 0;
+}
/*
@@ -387,56 +430,61 @@ int Bank_compar(const void *a,const void *b)
void Bank::rescanforbanks()
{
- for (int i=0;id_name;
- if (dirname[0]=='.') continue;
+ while((fn = readdir(dir))) {
+ const char *dirname = fn->d_name;
+ if(dirname[0] == '.')
+ continue;
- snprintf(bank.dir,maxdirsize,"%s%s%s/",rootdir,separator,dirname);
- snprintf(bank.name,maxdirsize,"%s",dirname);
+ snprintf(bank.dir, maxdirsize, "%s%s%s/", rootdir, separator, dirname);
+ snprintf(bank.name, maxdirsize, "%s", dirname);
//find out if the directory contains at least 1 instrument
- bool isbank=false;
+ bool isbank = false;
- DIR *d=opendir(bank.dir);
- if (d==NULL) continue;
+ DIR *d = opendir(bank.dir);
+ if(d == NULL)
+ continue;
struct dirent *fname;
- while ((fname=readdir(d))) {
- if ((strstr(fname->d_name,INSTRUMENT_EXTENSION)!=NULL)||
- (strstr(fname->d_name,FORCE_BANK_DIR_FILE)!=NULL)) {
- isbank=true;
- break;//aici as putea pune in loc de break un update la un counter care imi arata nr. de instrumente din bank
- };
- };
+ while((fname = readdir(d))) {
+ if((strstr(fname->d_name, INSTRUMENT_EXTENSION) != NULL)
+ || (strstr(fname->d_name, FORCE_BANK_DIR_FILE) != NULL)) {
+ isbank = true;
+ break; //aici as putea pune in loc de break un update la un counter care imi arata nr. de instrumente din bank
+ }
+ }
closedir(d);
- if (isbank) {
- int pos=-1;
- for (int i=1;i=0) {
- banks[pos].name=new char[maxdirsize];
- banks[pos].dir=new char[maxdirsize];
- snprintf(banks[pos].name,maxdirsize,"%s",bank.name);
- snprintf(banks[pos].dir,maxdirsize,"%s",bank.dir);
- };
-
- };
-
- };
+ if(pos >= 0) {
+ banks[pos].name = new char[maxdirsize];
+ banks[pos].dir = new char[maxdirsize];
+ snprintf(banks[pos].name, maxdirsize, "%s", bank.name);
+ snprintf(banks[pos].dir, maxdirsize, "%s", bank.dir);
+ }
+ }
+ }
closedir(dir);
-
-};
+}
void Bank::clearbank()
{
- for (int i=0;i=0)&&(pos=BANK_SIZE) pos=-1;
+ if((pos >= 0) && (pos < BANK_SIZE)) {
+ if(ins[pos].used)
+ pos = -1; //force it to find a new free position
+ }
+ else
+ if(pos >= BANK_SIZE)
+ pos = -1;
- if (pos<0) {//find a free position
- for (int i=BANK_SIZE-1;i>=0;i--)
- if (!ins[i].used) {
- pos=i;
+ if(pos < 0) { //find a free position
+ for(int i = BANK_SIZE - 1; i >= 0; i--)
+ if(!ins[i].used) {
+ pos = i;
break;
- };
+ }
+ ;
+ }
- };
-
- if (pos<0) return (-1);//the bank is full
+ if(pos < 0)
+ return -1; //the bank is full
// printf("%s %d\n",filename,pos);
deletefrombank(pos);
- ins[pos].used=true;
- snprintf(ins[pos].name,PART_MAX_NAME_LEN,"%s",name);
+ ins[pos].used = true;
+ snprintf(ins[pos].name, PART_MAX_NAME_LEN, "%s", name);
- snprintf(tmpinsname[pos],PART_MAX_NAME_LEN+10," ");
+ snprintf(tmpinsname[pos], PART_MAX_NAME_LEN + 10, " ");
- int len=strlen(filename)+1+strlen(dirname);
- ins[pos].filename=new char[len+2];
- ins[pos].filename[len+1]=0;
- snprintf(ins[pos].filename,len+1,"%s/%s",dirname,filename);
+ int len = strlen(filename) + 1 + strlen(dirname);
+ ins[pos].filename = new char[len + 2];
+ ins[pos].filename[len + 1] = 0;
+ snprintf(ins[pos].filename, len + 1, "%s/%s", dirname, filename);
//see if PADsynth is used
- if (config.cfg.CheckPADsynth) {
- XMLwrapper *xml=new XMLwrapper();
- xml->checkfileinformation(ins[pos].filename);
+ if(config.cfg.CheckPADsynth) {
+ XMLwrapper *xml = new XMLwrapper();
+ xml->loadXMLfile(ins[pos].filename);
- ins[pos].info.PADsynth_used=xml->information.PADsynth_used;
+ ins[pos].info.PADsynth_used = xml->hasPadSynth();
delete xml;
- } else ins[pos].info.PADsynth_used=false;
+ }
+ else
+ ins[pos].info.PADsynth_used = false;
- return(0);
-};
+ return 0;
+}
bool Bank::isPADsynth_used(unsigned int ninstrument)
{
- if (config.cfg.CheckPADsynth==0) return(0);
- else return(ins[ninstrument].info.PADsynth_used);
-};
+ if(config.cfg.CheckPADsynth == 0)
+ return 0;
+ else
+ return ins[ninstrument].info.PADsynth_used;
+}
void Bank::deletefrombank(int pos)
{
- if ((pos<0)||(pos>=BANK_SIZE)) return;
- ins[pos].used=false;
- ZERO(ins[pos].name,PART_MAX_NAME_LEN+1);
- if (ins[pos].filename!=NULL) {
- delete []ins[pos].filename;
- ins[pos].filename=NULL;
- };
+ if((pos < 0) || (pos >= BANK_SIZE))
+ return;
+ ins[pos].used = false;
+ ZERO(ins[pos].name, PART_MAX_NAME_LEN + 1);
+ if(ins[pos].filename != NULL) {
+ delete [] ins[pos].filename;
+ ins[pos].filename = NULL;
+ }
- ZERO(tmpinsname[pos],PART_MAX_NAME_LEN+20);
-
-};
+ ZERO(tmpinsname[pos], PART_MAX_NAME_LEN + 20);
+}
diff --git a/plugins/zynaddsubfx/src/Misc/Bank.h b/plugins/zynaddsubfx/src/Misc/Bank.h
index 8359b541b..81acc3dec 100644
--- a/plugins/zynaddsubfx/src/Misc/Bank.h
+++ b/plugins/zynaddsubfx/src/Misc/Bank.h
@@ -38,70 +38,70 @@
* \todo add in strings to replace char* */
class Bank
{
-public:
- /**Constructor*/
- Bank();
- ~Bank();
- char *getname(unsigned int ninstrument);
- char *getnamenumbered(unsigned int ninstrument);
- void setname(unsigned int ninstrument,const char *newname,int newslot);//if newslot==-1 then this is ignored, else it will be put on that slot
- bool isPADsynth_used(unsigned int ninstrument);
+ public:
+ /**Constructor*/
+ Bank();
+ ~Bank();
+ char *getname(unsigned int ninstrument);
+ char *getnamenumbered(unsigned int ninstrument);
+ void setname(unsigned int ninstrument, const char *newname, int newslot); //if newslot==-1 then this is ignored, else it will be put on that slot
+ bool isPADsynth_used(unsigned int ninstrument);
- /**returns 0 if the slot is not empty or 1 if the slot is empty
- * \todo start using bool before facepalm*/
- int emptyslot(unsigned int ninstrument);
+ /**returns 0 if the slot is not empty or 1 if the slot is empty
+ * \todo start using bool before facepalm*/
+ int emptyslot(unsigned int ninstrument);
- /**Empties out the selected slot*/
- void clearslot(unsigned int ninstrument);
- /**Saves the given Part to slot*/
- void savetoslot(unsigned int ninstrument,Part *part);
- /**Loads the given slot into a Part*/
- void loadfromslot(unsigned int ninstrument,Part *part);
+ /**Empties out the selected slot*/
+ void clearslot(unsigned int ninstrument);
+ /**Saves the given Part to slot*/
+ void savetoslot(unsigned int ninstrument, Part *part);
+ /**Loads the given slot into a Part*/
+ void loadfromslot(unsigned int ninstrument, Part *part);
- /**Swaps Slots*/
- void swapslot(unsigned int n1,unsigned int n2);
+ /**Swaps Slots*/
+ void swapslot(unsigned int n1, unsigned int n2);
- int loadbank(const char *bankdirname);
- int newbank(const char *newbankdirname);
+ int loadbank(const char *bankdirname);
+ int newbank(const char *newbankdirname);
- char *bankfiletitle; //this is shown on the UI of the bank (the title of the window)
- int locked();
+ char *bankfiletitle; //this is shown on the UI of the bank (the title of the window)
+ int locked();
- void rescanforbanks();
+ void rescanforbanks();
- struct bankstruct {
- char *dir;
- char *name;
- };
+ struct bankstruct {
+ char *dir;
+ char *name;
+ };
- bankstruct banks[MAX_NUM_BANKS];
+ bankstruct banks[MAX_NUM_BANKS];
-private:
+ private:
- //it adds a filename to the bank
- //if pos is -1 it try to find a position
- //returns -1 if the bank is full, or 0 if the instrument was added
- int addtobank(int pos,const char* filename,const char* name);
+ //it adds a filename to the bank
+ //if pos is -1 it try to find a position
+ //returns -1 if the bank is full, or 0 if the instrument was added
+ int addtobank(int pos, const char *filename, const char *name);
- void deletefrombank(int pos);
+ void deletefrombank(int pos);
- void clearbank();
+ void clearbank();
- char defaultinsname[PART_MAX_NAME_LEN];
- char tmpinsname[BANK_SIZE][PART_MAX_NAME_LEN+20];//this keeps the numbered names
+ char defaultinsname[PART_MAX_NAME_LEN];
+ char tmpinsname[BANK_SIZE][PART_MAX_NAME_LEN + 20]; //this keeps the numbered names
- struct ins_t {
- bool used;
- char name[PART_MAX_NAME_LEN+1];
- char *filename;
- struct {
- bool PADsynth_used;
- } info;
- }ins[BANK_SIZE];
+ struct ins_t {
+ bool used;
+ char name[PART_MAX_NAME_LEN + 1];
+ char *filename;
+ struct {
+ bool PADsynth_used;
+ } info;
+ } ins[BANK_SIZE];
- char *dirname;
+ char *dirname;
- void scanrootdir(char *rootdir);//scans a root dir for banks
+ void scanrootdir(char *rootdir); //scans a root dir for banks
};
#endif
diff --git a/plugins/zynaddsubfx/src/Misc/Config.cpp b/plugins/zynaddsubfx/src/Misc/Config.cpp
index 9a290158c..94966e4af 100644
--- a/plugins/zynaddsubfx/src/Misc/Config.cpp
+++ b/plugins/zynaddsubfx/src/Misc/Config.cpp
@@ -33,309 +33,369 @@
#include "XMLwrapper.h"
Config::Config()
-{
-};
+{}
void Config::init()
{
- maxstringsize=MAX_STRING_SIZE;//for ui
+ maxstringsize = MAX_STRING_SIZE; //for ui
//defaults
- cfg.SampleRate=44100;
- cfg.SoundBufferSize=256;
- cfg.OscilSize=1024;
- cfg.SwapStereo=0;
+ cfg.SampleRate = 44100;
+ cfg.SoundBufferSize = 256;
+ cfg.OscilSize = 1024;
+ cfg.SwapStereo = 0;
- cfg.LinuxOSSWaveOutDev=new char[MAX_STRING_SIZE];
- snprintf(cfg.LinuxOSSWaveOutDev,MAX_STRING_SIZE,"/dev/dsp");
- cfg.LinuxOSSSeqInDev=new char[MAX_STRING_SIZE];
- snprintf(cfg.LinuxOSSSeqInDev,MAX_STRING_SIZE,"/dev/sequencer");
+ cfg.LinuxOSSWaveOutDev = new char[MAX_STRING_SIZE];
+ snprintf(cfg.LinuxOSSWaveOutDev, MAX_STRING_SIZE, "/dev/dsp");
+ cfg.LinuxOSSSeqInDev = new char[MAX_STRING_SIZE];
+ snprintf(cfg.LinuxOSSSeqInDev, MAX_STRING_SIZE, "/dev/sequencer");
- cfg.DumpFile=new char[MAX_STRING_SIZE];
- snprintf(cfg.DumpFile,MAX_STRING_SIZE,"zynaddsubfx_dump.txt");
+ cfg.DumpFile = new char[MAX_STRING_SIZE];
+ snprintf(cfg.DumpFile, MAX_STRING_SIZE, "zynaddsubfx_dump.txt");
- cfg.WindowsWaveOutId=0;
- cfg.WindowsMidiInId=0;
+ cfg.WindowsWaveOutId = 0;
+ cfg.WindowsMidiInId = 0;
- cfg.BankUIAutoClose=0;
- cfg.DumpNotesToFile=0;
- cfg.DumpAppend=1;
+ cfg.BankUIAutoClose = 0;
+ cfg.DumpNotesToFile = 0;
+ cfg.DumpAppend = 1;
- cfg.GzipCompression=3;
+ cfg.GzipCompression = 3;
- cfg.Interpolation=0;
- cfg.CheckPADsynth=1;
+ cfg.Interpolation = 0;
+ cfg.CheckPADsynth = 1;
- cfg.UserInterfaceMode=0;
- cfg.VirKeybLayout=1;
- winwavemax=1;
- winmidimax=1;
+ cfg.UserInterfaceMode = 0;
+ cfg.VirKeybLayout = 1;
+ winwavemax = 1;
+ winmidimax = 1;
//try to find out how many input midi devices are there
#ifdef WINMIDIIN
- winmidimax=midiInGetNumDevs();
- if (winmidimax==0) winmidimax=1;
+ winmidimax = midiInGetNumDevs();
+ if(winmidimax == 0)
+ winmidimax = 1;
#endif
- winmididevices=new winmidionedevice[winmidimax];
- for (int i=0;iloadXMLfile(filename)<0) return;
- if (xmlcfg->enterbranch("CONFIGURATION")) {
- cfg.SampleRate=xmlcfg->getpar("sample_rate",cfg.SampleRate,4000,1024000);
- cfg.SoundBufferSize=xmlcfg->getpar("sound_buffer_size",cfg.SoundBufferSize,16,8192);
- cfg.OscilSize=xmlcfg->getpar("oscil_size",cfg.OscilSize,MAX_AD_HARMONICS*2,131072);
- cfg.SwapStereo=xmlcfg->getpar("swap_stereo",cfg.SwapStereo,0,1);
- cfg.BankUIAutoClose=xmlcfg->getpar("bank_window_auto_close",cfg.BankUIAutoClose,0,1);
+ XMLwrapper *xmlcfg = new XMLwrapper();
+ if(xmlcfg->loadXMLfile(filename) < 0)
+ return;
+ if(xmlcfg->enterbranch("CONFIGURATION")) {
+ cfg.SampleRate = xmlcfg->getpar("sample_rate",
+ cfg.SampleRate,
+ 4000,
+ 1024000);
+ cfg.SoundBufferSize = xmlcfg->getpar("sound_buffer_size",
+ cfg.SoundBufferSize,
+ 16,
+ 8192);
+ cfg.OscilSize = xmlcfg->getpar("oscil_size",
+ cfg.OscilSize,
+ MAX_AD_HARMONICS * 2,
+ 131072);
+ cfg.SwapStereo = xmlcfg->getpar("swap_stereo",
+ cfg.SwapStereo,
+ 0,
+ 1);
+ cfg.BankUIAutoClose = xmlcfg->getpar("bank_window_auto_close",
+ cfg.BankUIAutoClose,
+ 0,
+ 1);
- cfg.DumpNotesToFile=xmlcfg->getpar("dump_notes_to_file",cfg.DumpNotesToFile,0,1);
- cfg.DumpAppend=xmlcfg->getpar("dump_append",cfg.DumpAppend,0,1);
- xmlcfg->getparstr("dump_file",cfg.DumpFile,MAX_STRING_SIZE);
+ cfg.DumpNotesToFile = xmlcfg->getpar("dump_notes_to_file",
+ cfg.DumpNotesToFile,
+ 0,
+ 1);
+ cfg.DumpAppend = xmlcfg->getpar("dump_append",
+ cfg.DumpAppend,
+ 0,
+ 1);
+ xmlcfg->getparstr("dump_file", cfg.DumpFile, MAX_STRING_SIZE);
- cfg.GzipCompression=xmlcfg->getpar("gzip_compression",cfg.GzipCompression,0,9);
+ cfg.GzipCompression = xmlcfg->getpar("gzip_compression",
+ cfg.GzipCompression,
+ 0,
+ 9);
- xmlcfg->getparstr("bank_current",cfg.currentBankDir,MAX_STRING_SIZE);
- cfg.Interpolation=xmlcfg->getpar("interpolation",cfg.Interpolation,0,1);
+ xmlcfg->getparstr("bank_current", cfg.currentBankDir, MAX_STRING_SIZE);
+ cfg.Interpolation = xmlcfg->getpar("interpolation",
+ cfg.Interpolation,
+ 0,
+ 1);
- cfg.CheckPADsynth=xmlcfg->getpar("check_pad_synth",cfg.CheckPADsynth,0,1);
+ cfg.CheckPADsynth = xmlcfg->getpar("check_pad_synth",
+ cfg.CheckPADsynth,
+ 0,
+ 1);
- cfg.UserInterfaceMode=xmlcfg->getpar("user_interface_mode",cfg.UserInterfaceMode,0,2);
- cfg.VirKeybLayout=xmlcfg->getpar("virtual_keyboard_layout",cfg.VirKeybLayout,0,10);
+ cfg.UserInterfaceMode = xmlcfg->getpar("user_interface_mode",
+ cfg.UserInterfaceMode,
+ 0,
+ 2);
+ cfg.VirKeybLayout = xmlcfg->getpar("virtual_keyboard_layout",
+ cfg.VirKeybLayout,
+ 0,
+ 10);
//get bankroot dirs
- for (int i=0;ienterbranch("BANKROOT",i)) {
- cfg.bankRootDirList[i]=new char[MAX_STRING_SIZE];
- xmlcfg->getparstr("bank_root",cfg.bankRootDirList[i],MAX_STRING_SIZE);
+ for(int i = 0; i < MAX_BANK_ROOT_DIRS; i++) {
+ if(xmlcfg->enterbranch("BANKROOT", i)) {
+ cfg.bankRootDirList[i] = new char[MAX_STRING_SIZE];
+ xmlcfg->getparstr("bank_root",
+ cfg.bankRootDirList[i],
+ MAX_STRING_SIZE);
xmlcfg->exitbranch();
- };
- };
+ }
+ }
//get preset root dirs
- for (int i=0;ienterbranch("PRESETSROOT",i)) {
- cfg.presetsDirList[i]=new char[MAX_STRING_SIZE];
- xmlcfg->getparstr("presets_root",cfg.presetsDirList[i],MAX_STRING_SIZE);
+ for(int i = 0; i < MAX_BANK_ROOT_DIRS; i++) {
+ if(xmlcfg->enterbranch("PRESETSROOT", i)) {
+ cfg.presetsDirList[i] = new char[MAX_STRING_SIZE];
+ xmlcfg->getparstr("presets_root",
+ cfg.presetsDirList[i],
+ MAX_STRING_SIZE);
xmlcfg->exitbranch();
- };
- };
+ }
+ }
//linux stuff
- xmlcfg->getparstr("linux_oss_wave_out_dev",cfg.LinuxOSSWaveOutDev,MAX_STRING_SIZE);
- xmlcfg->getparstr("linux_oss_seq_in_dev",cfg.LinuxOSSSeqInDev,MAX_STRING_SIZE);
+ xmlcfg->getparstr("linux_oss_wave_out_dev",
+ cfg.LinuxOSSWaveOutDev,
+ MAX_STRING_SIZE);
+ xmlcfg->getparstr("linux_oss_seq_in_dev",
+ cfg.LinuxOSSSeqInDev,
+ MAX_STRING_SIZE);
//windows stuff
- cfg.WindowsWaveOutId=xmlcfg->getpar("windows_wave_out_id",cfg.WindowsWaveOutId,0,winwavemax);
- cfg.WindowsMidiInId=xmlcfg->getpar("windows_midi_in_id",cfg.WindowsMidiInId,0,winmidimax);
+ cfg.WindowsWaveOutId = xmlcfg->getpar("windows_wave_out_id",
+ cfg.WindowsWaveOutId,
+ 0,
+ winwavemax);
+ cfg.WindowsMidiInId = xmlcfg->getpar("windows_midi_in_id",
+ cfg.WindowsMidiInId,
+ 0,
+ winmidimax);
xmlcfg->exitbranch();
- };
- delete(xmlcfg);
+ }
+ delete (xmlcfg);
- cfg.OscilSize=(int) pow(2,ceil(log (cfg.OscilSize-1.0)/log(2.0)));
-
-};
+ cfg.OscilSize = (int) pow(2, ceil(log(cfg.OscilSize - 1.0) / log(2.0)));
+}
void Config::saveConfig(const char *filename)
{
- XMLwrapper *xmlcfg=new XMLwrapper();
+ XMLwrapper *xmlcfg = new XMLwrapper();
xmlcfg->beginbranch("CONFIGURATION");
- xmlcfg->addpar("sample_rate",cfg.SampleRate);
- xmlcfg->addpar("sound_buffer_size",cfg.SoundBufferSize);
- xmlcfg->addpar("oscil_size",cfg.OscilSize);
- xmlcfg->addpar("swap_stereo",cfg.SwapStereo);
- xmlcfg->addpar("bank_window_auto_close",cfg.BankUIAutoClose);
+ xmlcfg->addpar("sample_rate", cfg.SampleRate);
+ xmlcfg->addpar("sound_buffer_size", cfg.SoundBufferSize);
+ xmlcfg->addpar("oscil_size", cfg.OscilSize);
+ xmlcfg->addpar("swap_stereo", cfg.SwapStereo);
+ xmlcfg->addpar("bank_window_auto_close", cfg.BankUIAutoClose);
- xmlcfg->addpar("dump_notes_to_file",cfg.DumpNotesToFile);
- xmlcfg->addpar("dump_append",cfg.DumpAppend);
- xmlcfg->addparstr("dump_file",cfg.DumpFile);
+ xmlcfg->addpar("dump_notes_to_file", cfg.DumpNotesToFile);
+ xmlcfg->addpar("dump_append", cfg.DumpAppend);
+ xmlcfg->addparstr("dump_file", cfg.DumpFile);
- xmlcfg->addpar("gzip_compression",cfg.GzipCompression);
+ xmlcfg->addpar("gzip_compression", cfg.GzipCompression);
- xmlcfg->addpar("check_pad_synth",cfg.CheckPADsynth);
+ xmlcfg->addpar("check_pad_synth", cfg.CheckPADsynth);
- xmlcfg->addparstr("bank_current",cfg.currentBankDir);
+ xmlcfg->addparstr("bank_current", cfg.currentBankDir);
- xmlcfg->addpar("user_interface_mode",cfg.UserInterfaceMode);
- xmlcfg->addpar("virtual_keyboard_layout",cfg.VirKeybLayout);
+ xmlcfg->addpar("user_interface_mode", cfg.UserInterfaceMode);
+ xmlcfg->addpar("virtual_keyboard_layout", cfg.VirKeybLayout);
- for (int i=0;ibeginbranch("BANKROOT",i);
- xmlcfg->addparstr("bank_root",cfg.bankRootDirList[i]);
+ for(int i = 0; i < MAX_BANK_ROOT_DIRS; i++)
+ if(cfg.bankRootDirList[i] != NULL) {
+ xmlcfg->beginbranch("BANKROOT", i);
+ xmlcfg->addparstr("bank_root", cfg.bankRootDirList[i]);
xmlcfg->endbranch();
- };
+ }
+ ;
- for (int i=0;ibeginbranch("PRESETSROOT",i);
- xmlcfg->addparstr("presets_root",cfg.presetsDirList[i]);
+ for(int i = 0; i < MAX_BANK_ROOT_DIRS; i++)
+ if(cfg.presetsDirList[i] != NULL) {
+ xmlcfg->beginbranch("PRESETSROOT", i);
+ xmlcfg->addparstr("presets_root", cfg.presetsDirList[i]);
xmlcfg->endbranch();
- };
+ }
+ ;
- xmlcfg->addpar("interpolation",cfg.Interpolation);
+ xmlcfg->addpar("interpolation", cfg.Interpolation);
//linux stuff
- xmlcfg->addparstr("linux_oss_wave_out_dev",cfg.LinuxOSSWaveOutDev);
- xmlcfg->addparstr("linux_oss_seq_in_dev",cfg.LinuxOSSSeqInDev);
+ xmlcfg->addparstr("linux_oss_wave_out_dev", cfg.LinuxOSSWaveOutDev);
+ xmlcfg->addparstr("linux_oss_seq_in_dev", cfg.LinuxOSSSeqInDev);
//windows stuff
- xmlcfg->addpar("windows_wave_out_id",cfg.WindowsWaveOutId);
- xmlcfg->addpar("windows_midi_in_id",cfg.WindowsMidiInId);
+ xmlcfg->addpar("windows_wave_out_id", cfg.WindowsWaveOutId);
+ xmlcfg->addpar("windows_midi_in_id", cfg.WindowsMidiInId);
xmlcfg->endbranch();
- int tmp=cfg.GzipCompression;
- cfg.GzipCompression=0;
+ int tmp = cfg.GzipCompression;
+ cfg.GzipCompression = 0;
xmlcfg->saveXMLfile(filename);
- cfg.GzipCompression=tmp;
+ cfg.GzipCompression = tmp;
- delete(xmlcfg);
-};
+ delete (xmlcfg);
+}
void Config::getConfigFileName(char *name, int namesize)
{
- name[0]=0;
+ name[0] = 0;
#ifdef OS_LINUX
- snprintf(name,namesize,"%s%s",getenv("HOME"),"/.zynaddsubfxXML.cfg");
+ snprintf(name, namesize, "%s%s", getenv("HOME"), "/.zynaddsubfxXML.cfg");
#else
- snprintf(name,namesize,"%s","zynaddsubfxXML.cfg");
+ snprintf(name, namesize, "%s", "zynaddsubfxXML.cfg");
#endif
-
-};
+}
diff --git a/plugins/zynaddsubfx/src/Misc/Config.h b/plugins/zynaddsubfx/src/Misc/Config.h
index 9d4fef615..f08505d80 100644
--- a/plugins/zynaddsubfx/src/Misc/Config.h
+++ b/plugins/zynaddsubfx/src/Misc/Config.h
@@ -29,43 +29,43 @@
/**Configuration file functions*/
class Config
{
-public:
- /** Constructor*/
- Config();
- /** Destructor*/
- ~Config();
- struct {
- char *LinuxOSSWaveOutDev,*LinuxOSSSeqInDev;
- int SampleRate,SoundBufferSize,OscilSize,SwapStereo;
- int WindowsWaveOutId,WindowsMidiInId;
- int BankUIAutoClose;
- int DumpNotesToFile,DumpAppend;
- int GzipCompression;
- int Interpolation;
- char *DumpFile;
- char *bankRootDirList[MAX_BANK_ROOT_DIRS],*currentBankDir;
- char *presetsDirList[MAX_BANK_ROOT_DIRS];
- int CheckPADsynth;
- int UserInterfaceMode;
- int VirKeybLayout;
- } cfg;
- int winwavemax,winmidimax;//number of wave/midi devices on Windows
- int maxstringsize;
+ public:
+ /** Constructor*/
+ Config();
+ /** Destructor*/
+ ~Config();
+ struct {
+ char *LinuxOSSWaveOutDev, *LinuxOSSSeqInDev;
+ int SampleRate, SoundBufferSize, OscilSize, SwapStereo;
+ int WindowsWaveOutId, WindowsMidiInId;
+ int BankUIAutoClose;
+ int DumpNotesToFile, DumpAppend;
+ int GzipCompression;
+ int Interpolation;
+ char *DumpFile;
+ char *bankRootDirList[MAX_BANK_ROOT_DIRS], *currentBankDir;
+ char *presetsDirList[MAX_BANK_ROOT_DIRS];
+ int CheckPADsynth;
+ int UserInterfaceMode;
+ int VirKeybLayout;
+ } cfg;
+ int winwavemax, winmidimax; //number of wave/midi devices on Windows
+ int maxstringsize;
- struct winmidionedevice {
- char *name;
- };
- winmidionedevice *winmididevices;
+ struct winmidionedevice {
+ char *name;
+ };
+ winmidionedevice *winmididevices;
- void clearbankrootdirlist();
- void clearpresetsdirlist();
- void init();
- void save();
+ void clearbankrootdirlist();
+ void clearpresetsdirlist();
+ void init();
+ void save();
-private:
- void readConfig(const char *filename);
- void saveConfig(const char *filename);
- void getConfigFileName(char *name,int namesize);
+ private:
+ void readConfig(const char *filename);
+ void saveConfig(const char *filename);
+ void getConfigFileName(char *name, int namesize);
};
#endif
diff --git a/plugins/zynaddsubfx/src/Misc/Control.h b/plugins/zynaddsubfx/src/Misc/Control.h
index 780d4b9e6..297e6f0da 100644
--- a/plugins/zynaddsubfx/src/Misc/Control.h
+++ b/plugins/zynaddsubfx/src/Misc/Control.h
@@ -27,74 +27,74 @@
class Control
{
-public:
- /**
- * The parent is the logical owner of this control. Parent should only
- * be null for the root node.
- * The id is a string uniquely identifying this control within the
- * context of the parent control. No spaces or dots are allowed in this
- * id.
- * Children id's are denoted by ., so that one
- * can refer to any control in the hierarchy by separating them with
- * dots. Example: Main.AddSynth.FrequencyLFO.Amplitude
- */
- Control(Control *parent, string id);
+ public:
+ /**
+ * The parent is the logical owner of this control. Parent should only
+ * be null for the root node.
+ * The id is a string uniquely identifying this control within the
+ * context of the parent control. No spaces or dots are allowed in this
+ * id.
+ * Children id's are denoted by ., so that one
+ * can refer to any control in the hierarchy by separating them with
+ * dots. Example: Main.AddSynth.FrequencyLFO.Amplitude
+ */
+ Control(Control *parent, string id);
- /**
- * Will recursively get the XML representation for all the subcontrols.
- * Used for saving to file and copy-pasting settings
- */
- string getXMLRepresentation();
+ /**
+ * Will recursively get the XML representation for all the subcontrols.
+ * Used for saving to file and copy-pasting settings
+ */
+ string getXMLRepresentation();
- /**
- * Set the value of this (and possibly subcomponents as well) based on
- * a xml description.
- */
- void restoreFromXML(string xml);
+ /**
+ * Set the value of this (and possibly subcomponents as well) based on
+ * a xml description.
+ */
+ void restoreFromXML(string xml);
- /**
- * Register a controluser. This will cause this user to be notified
- * whenever the contents of the control changes.
- */
- void registerControlUser(ControlUser *user);
-
- /**
- * This should return a string representation of the controls internal
- * value
- */
- virtual string getStringRepresentation() = 0;
+ /**
+ * Register a controluser. This will cause this user to be notified
+ * whenever the contents of the control changes.
+ */
+ void registerControlUser(ControlUser *user);
+ /**
+ * This should return a string representation of the controls internal
+ * value
+ */
+ virtual string getStringRepresentation() = 0;
};
-class FloatControl : public Control
+class FloatControl:public Control
{
-public:
- /**
- * Set the value of this control. If the ControlUser variable is set,
- * then this user will not be updated with the new value. This is to
- * avoid setting a value being set back to the source that set it
- * (which would be redundant, or possibly causing infinite setValue
- * loops).
- * NOTE: this function is thread-safe (using a mutex internally)
- */
- void setValue(float value, ControlUser *user = NULL);
+ public:
+ /**
+ * Set the value of this control. If the ControlUser variable is set,
+ * then this user will not be updated with the new value. This is to
+ * avoid setting a value being set back to the source that set it
+ * (which would be redundant, or possibly causing infinite setValue
+ * loops).
+ * NOTE: this function is thread-safe (using a mutex internally)
+ */
+ void setValue(float value, ControlUser *user = NULL);
- /**
- * Reimplemented from Control
- */
- virtual string getStringRepresentation();
+ /**
+ * Reimplemented from Control
+ */
+ virtual string getStringRepresentation();
- float value();
+ float value();
};
class ControlUser
{
-public:
- /**
- * Pure virtual method, to notify the controluser that the value has
- * been changed internally, and needs to be read again.
- */
- virtual void controlUpdated(Control *control) = 0;
+ public:
+ /**
+ * Pure virtual method, to notify the controluser that the value has
+ * been changed internally, and needs to be read again.
+ */
+ virtual void controlUpdated(Control *control) = 0;
};
#endif /* _CONTROL_H_ */
+
diff --git a/plugins/zynaddsubfx/src/Misc/Dump.cpp b/plugins/zynaddsubfx/src/Misc/Dump.cpp
index cb1728ec6..4c13c9464 100644
--- a/plugins/zynaddsubfx/src/Misc/Dump.cpp
+++ b/plugins/zynaddsubfx/src/Misc/Dump.cpp
@@ -28,80 +28,97 @@ Dump dump;
Dump::Dump()
{
- file=NULL;
- tick=0;
- k=0;
- keyspressed=0;
-};
+ file = NULL;
+ tick = 0;
+ k = 0;
+ keyspressed = 0;
+}
Dump::~Dump()
{
- if (file!=NULL) {
- double duration=(double)tick*(double) SOUND_BUFFER_SIZE/(double) SAMPLE_RATE;
- fprintf(file,"\n# statistics: duration = %d seconds; keyspressed = %d\n\n\n\n",(int) duration,keyspressed);
+ if(file != NULL) {
+ double duration = (double)tick * (double) SOUND_BUFFER_SIZE
+ / (double) SAMPLE_RATE;
+ fprintf(
+ file,
+ "\n# statistics: duration = %d seconds; keyspressed = %d\n\n\n\n",
+ (int) duration,
+ keyspressed);
fclose(file);
- };
-};
+ }
+}
void Dump::startnow()
{
- if (file!=NULL) return;//the file is already open
+ if(file != NULL)
+ return; //the file is already open
- if (config.cfg.DumpNotesToFile!=0) {
- if (config.cfg.DumpAppend!=0) file=fopen(config.cfg.DumpFile,"a");
- else file=fopen(config.cfg.DumpFile,"w");
- if (file==NULL) return;
- if (config.cfg.DumpAppend!=0) fprintf(file,"%s","#************************************\n");
+ if(config.cfg.DumpNotesToFile != 0) {
+ if(config.cfg.DumpAppend != 0)
+ file = fopen(config.cfg.DumpFile, "a");
+ else
+ file = fopen(config.cfg.DumpFile, "w");
+ if(file == NULL)
+ return;
+ if(config.cfg.DumpAppend != 0)
+ fprintf(file, "%s", "#************************************\n");
- time_t tm=time(NULL);
+ time_t tm = time(NULL);
- fprintf(file,"#date/time = %s\n",ctime(&tm));
- fprintf(file,"#1 tick = %g milliseconds\n",SOUND_BUFFER_SIZE*1000.0/SAMPLE_RATE);
- fprintf(file,"SAMPLERATE = %d\n",SAMPLE_RATE);
- fprintf(file,"TICKSIZE = %d #samples\n",SOUND_BUFFER_SIZE);
- fprintf(file,"\n\nSTART\n");
- };
-};
+ fprintf(file, "#date/time = %s\n", ctime(&tm));
+ fprintf(file,
+ "#1 tick = %g milliseconds\n",
+ SOUND_BUFFER_SIZE * 1000.0 / SAMPLE_RATE);
+ fprintf(file, "SAMPLERATE = %d\n", SAMPLE_RATE);
+ fprintf(file, "TICKSIZE = %d #samples\n", SOUND_BUFFER_SIZE);
+ fprintf(file, "\n\nSTART\n");
+ }
+}
void Dump::inctick()
{
tick++;
-};
+}
-void Dump::dumpnote(char chan,char note, char vel)
+void Dump::dumpnote(char chan, char note, char vel)
{
- if (file==NULL) return;
- if (note==0) return;
- if (vel==0) fprintf(file,"n %d -> %d %d \n",tick,chan,note);//note off
- else fprintf(file,"N %d -> %d %d %d \n",tick,chan,note,vel);//note on
+ if(file == NULL)
+ return;
+ if(note == 0)
+ return;
+ if(vel == 0)
+ fprintf(file, "n %d -> %d %d \n", tick, chan, note); //note off
+ else
+ fprintf(file, "N %d -> %d %d %d \n", tick, chan, note, vel); //note on
- if (vel!=0) keyspressed++;
+ if(vel != 0)
+ keyspressed++;
#ifndef JACKAUDIOOUT
- if (k++>25) {
+ if(k++ > 25) {
fflush(file);
- k=0;
- };
+ k = 0;
+ }
#endif
-};
+}
-void Dump::dumpcontroller(char chan,unsigned int type,int par)
+void Dump::dumpcontroller(char chan, unsigned int type, int par)
{
- if (file==NULL) return;
- switch (type) {
+ if(file == NULL)
+ return;
+ switch(type) {
case C_pitchwheel:
- fprintf(file,"P %d -> %d %d\n",tick,chan,par);
+ fprintf(file, "P %d -> %d %d\n", tick, chan, par);
break;
default:
- fprintf(file,"C %d -> %d %d %d\n",tick,chan,type,par);
+ fprintf(file, "C %d -> %d %d %d\n", tick, chan, type, par);
break;
- };
+ }
#ifndef JACKAUDIOOUT
- if (k++>25) {
+ if(k++ > 25) {
fflush(file);
- k=0;
- };
+ k = 0;
+ }
#endif
-};
-
+}
diff --git a/plugins/zynaddsubfx/src/Misc/Dump.h b/plugins/zynaddsubfx/src/Misc/Dump.h
index d285eb936..392fd407b 100644
--- a/plugins/zynaddsubfx/src/Misc/Dump.h
+++ b/plugins/zynaddsubfx/src/Misc/Dump.h
@@ -30,34 +30,35 @@
* \todo upgrade from stdio to iostream*/
class Dump
{
-public:
- /**Constructor*/
- Dump();
- /**Destructor
- * Closes the dumpfile*/
- ~Dump();
- /**Open dumpfile and prepare it for dumps
- * \todo see if this fits better in the constructor*/
- void startnow();
- /**Tick the timestamp*/
- void inctick();
- /**Dump Note to dumpfile
- * @param chan The channel of the note
- * @param note The note
- * @param vel The velocity of the note*/
- void dumpnote(char chan,char note, char vel);
- /** Dump the Controller
- * @param chan The channel of the Controller
- * @param type The type
- * @param par The value of the controller
- * \todo figure out what type is exactly meaning*/
- void dumpcontroller(char chan,unsigned int type,int par);
+ public:
+ /**Constructor*/
+ Dump();
+ /**Destructor
+ * Closes the dumpfile*/
+ ~Dump();
+ /**Open dumpfile and prepare it for dumps
+ * \todo see if this fits better in the constructor*/
+ void startnow();
+ /**Tick the timestamp*/
+ void inctick();
+ /**Dump Note to dumpfile
+ * @param chan The channel of the note
+ * @param note The note
+ * @param vel The velocity of the note*/
+ void dumpnote(char chan, char note, char vel);
+ /** Dump the Controller
+ * @param chan The channel of the Controller
+ * @param type The type
+ * @param par The value of the controller
+ * \todo figure out what type is exactly meaning*/
+ void dumpcontroller(char chan, unsigned int type, int par);
-private:
- FILE *file;
- int tick;
- int k;//This appears to be a constant used to flush the file
- //periodically when JACK is used
- int keyspressed;
+ private:
+ FILE *file;
+ int tick;
+ int k; //This appears to be a constant used to flush the file
+ //periodically when JACK is used
+ int keyspressed;
};
#endif
+
diff --git a/plugins/zynaddsubfx/src/Misc/LASHClient.cpp b/plugins/zynaddsubfx/src/Misc/LASHClient.cpp
index 3434a05fb..a21461f29 100644
--- a/plugins/zynaddsubfx/src/Misc/LASHClient.cpp
+++ b/plugins/zynaddsubfx/src/Misc/LASHClient.cpp
@@ -26,7 +26,7 @@
#include "LASHClient.h"
-LASHClient::LASHClient(int* argc, char*** argv)
+LASHClient::LASHClient(int *argc, char ***argv)
{
client = lash_init(lash_extract_args(argc, argv), "ZynAddSubFX",
LASH_Config_File, LASH_PROTOCOL(2, 0));
@@ -35,56 +35,54 @@ LASHClient::LASHClient(int* argc, char*** argv)
void LASHClient::setalsaid(int id)
{
- if (lash_enabled(client)) {
- if (id != -1)
+ if(lash_enabled(client))
+ if(id != -1)
lash_alsa_client_id(client, id);
- }
}
-void LASHClient::setjackname(const char* name)
+void LASHClient::setjackname(const char *name)
{
- if (lash_enabled(client)) {
- if (name != NULL) {
+ if(lash_enabled(client))
+ if(name != NULL) {
lash_jack_client_name(client, name);
lash_event_t *event = lash_event_new_with_type(LASH_Client_Name);
lash_event_set_string(event, name);
lash_send_event(client, event);
}
- }
}
-LASHClient::Event LASHClient::checkevents(std::string& filename)
+LASHClient::Event LASHClient::checkevents(std::string &filename)
{
-
- if (!lash_enabled(client))
+ if(!lash_enabled(client))
return NoEvent;
Event received = NoEvent;
- lash_event_t* event;
- while (event = lash_get_event(client)) {
-
+ lash_event_t *event;
+ while(event = lash_get_event(client)) {
// save
- if (lash_event_get_type(event) == LASH_Save_File) {
- std::cerr<<"LASH event: LASH_Save_File"<defaults();
- part[npart]->Prcvchn=npart%NUM_MIDI_CHANNELS;
- };
+ part[npart]->Prcvchn = npart % NUM_MIDI_CHANNELS;
+ }
- partonoff(0,1);//enable the first part
+ partonoff(0, 1); //enable the first part
- for (int nefx=0;nefxdefaults();
- Pinsparts[nefx]=-1;
- };
+ Pinsparts[nefx] = -1;
+ }
//System Effects init
- for (int nefx=0;nefxdefaults();
- for (int npart=0;npartchangeeffect(1);
microtonal.defaults();
ShutUp();
-};
+}
/*
* Note On Messages (velocity=0 for NoteOff)
*/
-void Master::NoteOn(unsigned char chan,unsigned char note,unsigned char velocity)
+void Master::NoteOn(unsigned char chan,
+ unsigned char note,
+ unsigned char velocity)
{
- dump.dumpnote(chan,note,velocity);
+ dump.dumpnote(chan, note, velocity);
- noteon(chan,note,velocity);
-};
+ noteon(chan, note, velocity);
+}
/*
* Internal Note On (velocity=0 for NoteOff)
*/
-void Master::noteon(unsigned char chan,unsigned char note,unsigned char velocity)
+void Master::noteon(unsigned char chan,
+ unsigned char note,
+ unsigned char velocity)
{
int npart;
- if (velocity!=0) {
- for (npart=0;npartPrcvchn) {
- fakepeakpart[npart]=velocity*2;
- if (part[npart]->Penabled!=0) part[npart]->NoteOn(note,velocity,keyshift);
- };
- };
- } else {
- this->NoteOff(chan,note);
- };
+ if(velocity != 0) {
+ for(npart = 0; npart < NUM_MIDI_PARTS; npart++) {
+ if(chan == part[npart]->Prcvchn) {
+ fakepeakpart[npart] = velocity * 2;
+ if(part[npart]->Penabled != 0)
+ part[npart]->NoteOn(note, velocity, keyshift);
+ }
+ }
+ }
+ else
+ this->NoteOff(chan, note);
+ ;
HDDRecorder.triggernow();
-};
+}
/*
* Note Off Messages
*/
-void Master::NoteOff(unsigned char chan,unsigned char note)
+void Master::NoteOff(unsigned char chan, unsigned char note)
{
- dump.dumpnote(chan,note,0);
+ dump.dumpnote(chan, note, 0);
- noteoff(chan,note);
-};
+ noteoff(chan, note);
+}
/*
* Internal Note Off
*/
-void Master::noteoff(unsigned char chan,unsigned char note)
+void Master::noteoff(unsigned char chan, unsigned char note)
{
int npart;
- for (npart=0;npartPrcvchn) && (part[npart]->Penabled!=0))
+ for(npart = 0; npart < NUM_MIDI_PARTS; npart++)
+ if((chan == part[npart]->Prcvchn) && (part[npart]->Penabled != 0))
part[npart]->NoteOff(note);
- };
-};
+ ;
+}
/*
* Controllers
*/
-void Master::SetController(unsigned char chan,unsigned int type,int par)
+void Master::SetController(unsigned char chan, unsigned int type, int par)
{
- dump.dumpcontroller(chan,type,par);
+ dump.dumpcontroller(chan, type, par);
- setcontroller(chan,type,par);
-};
+ setcontroller(chan, type, par);
+}
/*
* Internal Controllers
*/
-void Master::setcontroller(unsigned char chan,unsigned int type,int par)
+void Master::setcontroller(unsigned char chan, unsigned int type, int par)
{
- if ((type==C_dataentryhi)||(type==C_dataentrylo)||
- (type==C_nrpnhi)||(type==C_nrpnlo)) {//Process RPN and NRPN by the Master (ignore the chan)
- ctl.setparameternumber(type,par);
+ if((type == C_dataentryhi) || (type == C_dataentrylo)
+ || (type == C_nrpnhi) || (type == C_nrpnlo)) { //Process RPN and NRPN by the Master (ignore the chan)
+ ctl.setparameternumber(type, par);
- int parhi=-1,parlo=-1,valhi=-1,vallo=-1;
- if (ctl.getnrpn(&parhi,&parlo,&valhi,&vallo)==0) {//this is NRPN
+ int parhi = -1, parlo = -1, valhi = -1, vallo = -1;
+ if(ctl.getnrpn(&parhi, &parlo, &valhi, &vallo) == 0) //this is NRPN
//fprintf(stderr,"rcv. NRPN: %d %d %d %d\n",parhi,parlo,valhi,vallo);
- switch (parhi) {
- case 0x04://System Effects
- if (parloseteffectpar_nolock(valhi,vallo);
- };
+ switch(parhi) {
+ case 0x04: //System Effects
+ if(parlo < NUM_SYS_EFX)
+ sysefx[parlo]->seteffectpar_nolock(valhi, vallo);
+ ;
break;
- case 0x08://Insertion Effects
- if (parloseteffectpar_nolock(valhi,vallo);
- };
+ case 0x08: //Insertion Effects
+ if(parlo < NUM_INS_EFX)
+ insefx[parlo]->seteffectpar_nolock(valhi, vallo);
+ ;
break;
+ }
+ ;
+ }
+ else { //other controllers
+ for(int npart = 0; npart < NUM_MIDI_PARTS; npart++) //Send the controller to all part assigned to the channel
+ if((chan == part[npart]->Prcvchn) && (part[npart]->Penabled != 0))
+ part[npart]->SetController(type, par);
+ ;
- };
- };
- } else {//other controllers
- for (int npart=0;npartPrcvchn) && (part[npart]->Penabled!=0))
- part[npart]->SetController(type,par);
- };
-
- if (type==C_allsoundsoff) { //cleanup insertion/system FX
- for (int nefx=0;nefxcleanup();
- }
- for (int nefx=0;nefxcleanup();
- }
}
- };
-};
+ }
+}
/*
* Enable/Disable a part
*/
-void Master::partonoff(int npart,int what)
+void Master::partonoff(int npart, int what)
{
- if (npart>=NUM_MIDI_PARTS) return;
- if (what==0) {//disable part
- fakepeakpart[npart]=0;
- part[npart]->Penabled=0;
+ if(npart >= NUM_MIDI_PARTS)
+ return;
+ if(what == 0) { //disable part
+ fakepeakpart[npart] = 0;
+ part[npart]->Penabled = 0;
part[npart]->cleanup();
- for (int nefx=0;nefxcleanup();
- };
- };
- } else {//enabled
- part[npart]->Penabled=1;
- fakepeakpart[npart]=0;
- };
-};
+ ;
+ }
+ }
+ else { //enabled
+ part[npart]->Penabled = 1;
+ fakepeakpart[npart] = 0;
+ }
+}
/*
* Master audio out (the final sound)
*/
-void Master::AudioOut(REALTYPE *outl,REALTYPE *outr)
+void Master::AudioOut(REALTYPE *outl, REALTYPE *outr)
{
- int i,npart,nefx;
+ int i, npart, nefx;
/* //test!!!!!!!!!!!!! se poate bloca aici (mutex)
if (seq.play){
- int type,par1,par2,again,midichan;
- int ntrack=1;
+ int type,par1,par2,again,midichan;
+ int ntrack=1;
// do{
- again=seq.getevent(ntrack,&midichan,&type,&par1,&par2);
- if (type>0) {
+ again=seq.getevent(ntrack,&midichan,&type,&par1,&par2);
+ if (type>0) {
// printf("aaa\n");
- if (type==1){//note_on or note_off
- if (par2!=0) NoteOn(midichan,par1,par2);
- else NoteOff(midichan,par1);
- };
- };
+ if (type==1){//note_on or note_off
+ if (par2!=0) NoteOn(midichan,par1,par2);
+ else NoteOff(midichan,par1);
+ };
+ };
// } while (again);
};
*/
@@ -265,250 +271,287 @@ void Master::AudioOut(REALTYPE *outl,REALTYPE *outr)
//Swaps the Left channel with Right Channel (if it is asked for)
- if (swaplr!=0) {
- REALTYPE *tmp=outl;
- outl=outr;
- outr=tmp;
- };
+ if(swaplr != 0) {
+ REALTYPE *tmp = outl;
+ outl = outr;
+ outr = tmp;
+ }
//clean up the output samples
- for (i=0;ipartoutl,partoutr
- for (npart=0;npartPenabled!=0) part[npart]->ComputePartSmps();
+ for(npart = 0; npart < NUM_MIDI_PARTS; npart++)
+ if(part[npart]->Penabled != 0)
+ part[npart]->ComputePartSmps();
//Insertion effects
- for (nefx=0;nefx=0) {
- int efxpart=Pinsparts[nefx];
- if (part[efxpart]->Penabled!=0)
- insefx[nefx]->out(part[efxpart]->partoutl,part[efxpart]->partoutr);
- };
- };
+ for(nefx = 0; nefx < NUM_INS_EFX; nefx++) {
+ if(Pinsparts[nefx] >= 0) {
+ int efxpart = Pinsparts[nefx];
+ if(part[efxpart]->Penabled != 0)
+ insefx[nefx]->out(part[efxpart]->partoutl,
+ part[efxpart]->partoutr);
+ }
+ }
//Apply the part volumes and pannings (after insertion effects)
- for (npart=0;npartPenabled==0) continue;
+ for(npart = 0; npart < NUM_MIDI_PARTS; npart++) {
+ if(part[npart]->Penabled == 0)
+ continue;
- REALTYPE newvol_l=part[npart]->volume;
- REALTYPE newvol_r=part[npart]->volume;
- REALTYPE oldvol_l=part[npart]->oldvolumel;
- REALTYPE oldvol_r=part[npart]->oldvolumer;
- REALTYPE pan=part[npart]->panning;
- if (pan<0.5) newvol_l*=pan*2.0;
- else newvol_r*=(1.0-pan)*2.0;
+ REALTYPE newvol_l = part[npart]->volume;
+ REALTYPE newvol_r = part[npart]->volume;
+ REALTYPE oldvol_l = part[npart]->oldvolumel;
+ REALTYPE oldvol_r = part[npart]->oldvolumer;
+ REALTYPE pan = part[npart]->panning;
+ if(pan < 0.5)
+ newvol_l *= pan * 2.0;
+ else
+ newvol_r *= (1.0 - pan) * 2.0;
- if (ABOVE_AMPLITUDE_THRESHOLD(oldvol_l,newvol_l)||
- ABOVE_AMPLITUDE_THRESHOLD(oldvol_r,newvol_r)) {//the volume or the panning has changed and needs interpolation
-
- for (i=0;ipartoutl[i]*=vol_l;
- part[npart]->partoutr[i]*=vol_r;
- };
- part[npart]->oldvolumel=newvol_l;
- part[npart]->oldvolumer=newvol_r;
-
- } else {
- for (i=0;ipartoutl[i]*=newvol_l;
- part[npart]->partoutr[i]*=newvol_r;
- };
- };
- };
+ if(ABOVE_AMPLITUDE_THRESHOLD(oldvol_l, newvol_l)
+ || ABOVE_AMPLITUDE_THRESHOLD(oldvol_r, newvol_r)) { //the volume or the panning has changed and needs interpolation
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ REALTYPE vol_l = INTERPOLATE_AMPLITUDE(oldvol_l,
+ newvol_l,
+ i,
+ SOUND_BUFFER_SIZE);
+ REALTYPE vol_r = INTERPOLATE_AMPLITUDE(oldvol_r,
+ newvol_r,
+ i,
+ SOUND_BUFFER_SIZE);
+ part[npart]->partoutl[i] *= vol_l;
+ part[npart]->partoutr[i] *= vol_r;
+ }
+ part[npart]->oldvolumel = newvol_l;
+ part[npart]->oldvolumer = newvol_r;
+ }
+ else {
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) { //the volume did not changed
+ part[npart]->partoutl[i] *= newvol_l;
+ part[npart]->partoutr[i] *= newvol_r;
+ }
+ }
+ }
//System effects
- for (nefx=0;nefxgeteffect()==0) continue;//the effect is disabled
+ for(nefx = 0; nefx < NUM_SYS_EFX; nefx++) {
+ if(sysefx[nefx]->geteffect() == 0)
+ continue; //the effect is disabled
//Clean up the samples used by the system effects
- for (i=0;iPenabled==0) continue;
+ if(part[npart]->Penabled == 0)
+ continue;
//the output volume of each part to system effect
- REALTYPE vol=sysefxvol[nefx][npart];
- for (i=0;ipartoutl[i]*vol;
- tmpmixr[i]+=part[npart]->partoutr[i]*vol;
- };
- };
+ REALTYPE vol = sysefxvol[nefx][npart];
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ tmpmixl[i] += part[npart]->partoutl[i] * vol;
+ tmpmixr[i] += part[npart]->partoutr[i] * vol;
+ }
+ }
// system effect send to next ones
- for (int nefxfrom=0;nefxfromefxoutl[i]*v;
- tmpmixr[i]+=sysefx[nefxfrom]->efxoutr[i]*v;
- };
- };
- };
+ for(int nefxfrom = 0; nefxfrom < nefx; nefxfrom++) {
+ if(Psysefxsend[nefxfrom][nefx] != 0) {
+ REALTYPE v = sysefxsend[nefxfrom][nefx];
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ tmpmixl[i] += sysefx[nefxfrom]->efxoutl[i] * v;
+ tmpmixr[i] += sysefx[nefxfrom]->efxoutr[i] * v;
+ }
+ }
+ }
- sysefx[nefx]->out(tmpmixl,tmpmixr);
+ sysefx[nefx]->out(tmpmixl, tmpmixr);
//Add the System Effect to sound output
- REALTYPE outvol=sysefx[nefx]->sysefxgetvolume();
- for (i=0;isysefxgetvolume();
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ outl[i] += tmpmixl[i] * outvol;
+ outr[i] += tmpmixr[i] * outvol;
+ }
+ }
//Mix all parts
- for (npart=0;npartpartoutl[i];
- outr[i]+=part[npart]->partoutr[i];
- };
- };
+ for(npart = 0; npart < NUM_MIDI_PARTS; npart++) {
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) { //the volume did not changed
+ outl[i] += part[npart]->partoutl[i];
+ outr[i] += part[npart]->partoutr[i];
+ }
+ }
//Insertion effects for Master Out
- for (nefx=0;nefxout(outl,outr);
- };
+ for(nefx = 0; nefx < NUM_INS_EFX; nefx++)
+ if(Pinsparts[nefx] == -2)
+ insefx[nefx]->out(outl, outr);
+ ;
//Master Volume
- for (i=0;ivuoutpeakl) vuoutpeakl=fabs(outl[i]);
- if (fabs(outr[i])>vuoutpeakr) vuoutpeakr=fabs(outr[i]);
- };
- if ((vuoutpeakl>1.0)||(vuoutpeakr>1.0)) vuclipped=1;
- if (vumaxoutpeakl vuoutpeakl)
+ vuoutpeakl = fabs(outl[i]);
+ if(fabs(outr[i]) > vuoutpeakr)
+ vuoutpeakr = fabs(outr[i]);
+ }
+ if((vuoutpeakl > 1.0) || (vuoutpeakr > 1.0))
+ vuclipped = 1;
+ if(vumaxoutpeakl < vuoutpeakl)
+ vumaxoutpeakl = vuoutpeakl;
+ if(vumaxoutpeakr < vuoutpeakr)
+ vumaxoutpeakr = vuoutpeakr;
//RMS Peak computation (for vumeters)
- vurmspeakl=1e-12;
- vurmspeakr=1e-12;
- for (i=0;iPenabled!=0) {
- REALTYPE *outl=part[npart]->partoutl,
- *outr=part[npart]->partoutr;
- for (i=0;ivuoutpeakpart[npart]) vuoutpeakpart[npart]=tmp;
- };
- vuoutpeakpart[npart]*=volume;
- } else {
- if (fakepeakpart[npart]>1) fakepeakpart[npart]--;
- };
- };
+ for(npart = 0; npart < NUM_MIDI_PARTS; npart++) {
+ vuoutpeakpart[npart] = 1.0e-12;
+ if(part[npart]->Penabled != 0) {
+ REALTYPE *outl = part[npart]->partoutl,
+ *outr = part[npart]->partoutr;
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ REALTYPE tmp = fabs(outl[i] + outr[i]);
+ if(tmp > vuoutpeakpart[npart])
+ vuoutpeakpart[npart] = tmp;
+ }
+ vuoutpeakpart[npart] *= volume;
+ }
+ else
+ if(fakepeakpart[npart] > 1)
+ fakepeakpart[npart]--;
+ ;
+ }
//Shutup if it is asked (with fade-out)
- if (shutup!=0) {
- for (i=0;i=SOUND_BUFFER_SIZE) {
- AudioOut(&audiooutl[0],&audiooutr[0]);
- ksoundbuffersample=0;
- };
- };
- } else {//Resample
- int ksample=0;
- REALTYPE srinc=SAMPLE_RATE/(REALTYPE)samplerate;
+ if(ksoundbuffersample >= SOUND_BUFFER_SIZE) {
+ AudioOut(&audiooutl[0], &audiooutr[0]);
+ ksoundbuffersample = 0;
+ }
+ }
+ }
+ else { //Resample
+ int ksample = 0;
+ REALTYPE srinc = SAMPLE_RATE / (REALTYPE)samplerate;
- while (ksample=1.0) {
- ksoundbuffersample+=(int) floor(ksoundbuffersamplelow);
- ksoundbuffersamplelow=ksoundbuffersamplelow-floor(ksoundbuffersamplelow);
- };
+ ksoundbuffersamplelow += srinc;
+ if(ksoundbuffersamplelow >= 1.0) {
+ ksoundbuffersample += (int) floor(ksoundbuffersamplelow);
+ ksoundbuffersamplelow = ksoundbuffersamplelow - floor(
+ ksoundbuffersamplelow);
+ }
- if (ksoundbuffersample>=SOUND_BUFFER_SIZE) {
- oldsamplel=audiooutl[SOUND_BUFFER_SIZE-1];
- oldsampler=audiooutr[SOUND_BUFFER_SIZE-1];
- AudioOut(&audiooutl[0],&audiooutr[0]);
- ksoundbuffersample=0;
- };
- };
- };
-};
+ if(ksoundbuffersample >= SOUND_BUFFER_SIZE) {
+ oldsamplel = audiooutl[SOUND_BUFFER_SIZE - 1];
+ oldsampler = audiooutr[SOUND_BUFFER_SIZE - 1];
+ AudioOut(&audiooutl[0], &audiooutr[0]);
+ ksoundbuffersample = 0;
+ }
+ }
+ }
+}
Master::~Master()
{
- for (int npart=0;npartcleanup();
- fakepeakpart[npart]=0;
- };
- for (int nefx=0;nefxcleanup();
- for (int nefx=0;nefxcleanup();
+ fakepeakpart[npart] = 0;
+ }
+ for(int nefx = 0; nefx < NUM_INS_EFX; nefx++)
+ insefx[nefx]->cleanup();
+ for(int nefx = 0; nefx < NUM_SYS_EFX; nefx++)
+ sysefx[nefx]->cleanup();
vuresetpeaks();
- shutup=0;
-};
+ shutup = 0;
+}
/*
@@ -570,81 +615,80 @@ void Master::ShutUp()
*/
void Master::vuresetpeaks()
{
- vuoutpeakl=1e-9;
- vuoutpeakr=1e-9;
- vumaxoutpeakl=1e-9;
- vumaxoutpeakr=1e-9;
- vuclipped=0;
-};
+ vuoutpeakl = 1e-9;
+ vuoutpeakr = 1e-9;
+ vumaxoutpeakl = 1e-9;
+ vumaxoutpeakr = 1e-9;
+ vuclipped = 0;
+}
void Master::applyparameters()
{
- for (int npart=0;npartapplyparameters();
- };
-};
+ ;
+}
void Master::add2XML(XMLwrapper *xml)
{
- xml->addpar("volume",Pvolume);
- xml->addpar("key_shift",Pkeyshift);
- xml->addparbool("nrpn_receive",ctl.NRPN.receive);
+ xml->addpar("volume", Pvolume);
+ xml->addpar("key_shift", Pkeyshift);
+ xml->addparbool("nrpn_receive", ctl.NRPN.receive);
xml->beginbranch("MICROTONAL");
microtonal.add2XML(xml);
xml->endbranch();
- for (int npart=0;npartbeginbranch("PART",npart);
+ for(int npart = 0; npart < NUM_MIDI_PARTS; npart++) {
+ xml->beginbranch("PART", npart);
part[npart]->add2XML(xml);
xml->endbranch();
- };
+ }
xml->beginbranch("SYSTEM_EFFECTS");
- for (int nefx=0;nefxbeginbranch("SYSTEM_EFFECT",nefx);
+ for(int nefx = 0; nefx < NUM_SYS_EFX; nefx++) {
+ xml->beginbranch("SYSTEM_EFFECT", nefx);
xml->beginbranch("EFFECT");
sysefx[nefx]->add2XML(xml);
xml->endbranch();
- for (int pefx=0;pefxbeginbranch("VOLUME",pefx);
- xml->addpar("vol",Psysefxvol[nefx][pefx]);
+ for(int pefx = 0; pefx < NUM_MIDI_PARTS; pefx++) {
+ xml->beginbranch("VOLUME", pefx);
+ xml->addpar("vol", Psysefxvol[nefx][pefx]);
xml->endbranch();
- };
+ }
- for (int tonefx=nefx+1;tonefxbeginbranch("SENDTO",tonefx);
- xml->addpar("send_vol",Psysefxsend[nefx][tonefx]);
+ for(int tonefx = nefx + 1; tonefx < NUM_SYS_EFX; tonefx++) {
+ xml->beginbranch("SENDTO", tonefx);
+ xml->addpar("send_vol", Psysefxsend[nefx][tonefx]);
xml->endbranch();
- };
+ }
xml->endbranch();
- };
+ }
xml->endbranch();
xml->beginbranch("INSERTION_EFFECTS");
- for (int nefx=0;nefxbeginbranch("INSERTION_EFFECT",nefx);
- xml->addpar("part",Pinsparts[nefx]);
+ for(int nefx = 0; nefx < NUM_INS_EFX; nefx++) {
+ xml->beginbranch("INSERTION_EFFECT", nefx);
+ xml->addpar("part", Pinsparts[nefx]);
xml->beginbranch("EFFECT");
insefx[nefx]->add2XML(xml);
xml->endbranch();
xml->endbranch();
- };
+ }
xml->endbranch();
-
-};
+}
int Master::getalldata(char **data)
{
- XMLwrapper *xml=new XMLwrapper();
+ XMLwrapper *xml = new XMLwrapper();
xml->beginbranch("MASTER");
@@ -654,20 +698,21 @@ int Master::getalldata(char **data)
xml->endbranch();
- *data=xml->getXMLdata();
+ *data = xml->getXMLdata();
delete (xml);
- return(strlen(*data)+1);
-};
+ return strlen(*data) + 1;
+}
-void Master::putalldata(char *data,int size)
+void Master::putalldata(char *data, int size)
{
- XMLwrapper *xml=new XMLwrapper();
- if (!xml->putXMLdata(data)) {
- delete(xml);
+ XMLwrapper *xml = new XMLwrapper();
+ if(!xml->putXMLdata(data)) {
+ delete (xml);
return;
- };
+ }
- if (xml->enterbranch("MASTER")==0) return;
+ if(xml->enterbranch("MASTER") == 0)
+ return;
pthread_mutex_lock(&mutex);
getfromXML(xml);
@@ -675,104 +720,109 @@ void Master::putalldata(char *data,int size)
xml->exitbranch();
- delete(xml);
-};
+ delete (xml);
+}
int Master::saveXML(const char *filename)
{
- XMLwrapper *xml=new XMLwrapper();
+ XMLwrapper *xml = new XMLwrapper();
xml->beginbranch("MASTER");
add2XML(xml);
xml->endbranch();
- int result=xml->saveXMLfile(filename);
+ int result = xml->saveXMLfile(filename);
delete (xml);
- return(result);
-};
+ return result;
+}
int Master::loadXML(const char *filename)
{
- XMLwrapper *xml=new XMLwrapper();
- if (xml->loadXMLfile(filename)<0) {
- delete(xml);
- return(-1);
- };
+ XMLwrapper *xml = new XMLwrapper();
+ if(xml->loadXMLfile(filename) < 0) {
+ delete (xml);
+ return -1;
+ }
- if (xml->enterbranch("MASTER")==0) return(-10);
+ if(xml->enterbranch("MASTER") == 0)
+ return -10;
getfromXML(xml);
xml->exitbranch();
- delete(xml);
- return(0);
-};
+ delete (xml);
+ return 0;
+}
void Master::getfromXML(XMLwrapper *xml)
{
- setPvolume(xml->getpar127("volume",Pvolume));
- setPkeyshift(xml->getpar127("key_shift",Pkeyshift));
- ctl.NRPN.receive=xml->getparbool("nrpn_receive",ctl.NRPN.receive);
+ setPvolume(xml->getpar127("volume", Pvolume));
+ setPkeyshift(xml->getpar127("key_shift", Pkeyshift));
+ ctl.NRPN.receive = xml->getparbool("nrpn_receive", ctl.NRPN.receive);
- part[0]->Penabled=0;
- for (int npart=0;npartenterbranch("PART",npart)==0) continue;
+ part[0]->Penabled = 0;
+ for(int npart = 0; npart < NUM_MIDI_PARTS; npart++) {
+ if(xml->enterbranch("PART", npart) == 0)
+ continue;
part[npart]->getfromXML(xml);
xml->exitbranch();
- };
+ }
- if (xml->enterbranch("MICROTONAL")) {
+ if(xml->enterbranch("MICROTONAL")) {
microtonal.getfromXML(xml);
xml->exitbranch();
- };
+ }
sysefx[0]->changeeffect(0);
- if (xml->enterbranch("SYSTEM_EFFECTS")) {
- for (int nefx=0;nefxenterbranch("SYSTEM_EFFECT",nefx)==0) continue;
- if (xml->enterbranch("EFFECT")) {
+ if(xml->enterbranch("SYSTEM_EFFECTS")) {
+ for(int nefx = 0; nefx < NUM_SYS_EFX; nefx++) {
+ if(xml->enterbranch("SYSTEM_EFFECT", nefx) == 0)
+ continue;
+ if(xml->enterbranch("EFFECT")) {
sysefx[nefx]->getfromXML(xml);
xml->exitbranch();
- };
+ }
- for (int partefx=0;partefxenterbranch("VOLUME",partefx)==0) continue;
- setPsysefxvol(partefx,nefx,xml->getpar127("vol",Psysefxvol[partefx][nefx]));
+ for(int partefx = 0; partefx < NUM_MIDI_PARTS; partefx++) {
+ if(xml->enterbranch("VOLUME", partefx) == 0)
+ continue;
+ setPsysefxvol(partefx, nefx,
+ xml->getpar127("vol", Psysefxvol[partefx][nefx]));
xml->exitbranch();
- };
+ }
- for (int tonefx=nefx+1;tonefxenterbranch("SENDTO",tonefx)==0) continue;
- setPsysefxsend(nefx,tonefx,xml->getpar127("send_vol",Psysefxsend[nefx][tonefx]));
+ for(int tonefx = nefx + 1; tonefx < NUM_SYS_EFX; tonefx++) {
+ if(xml->enterbranch("SENDTO", tonefx) == 0)
+ continue;
+ setPsysefxsend(nefx, tonefx,
+ xml->getpar127("send_vol",
+ Psysefxsend[nefx][tonefx]));
xml->exitbranch();
- };
+ }
xml->exitbranch();
- };
+ }
xml->exitbranch();
- };
+ }
- if (xml->enterbranch("INSERTION_EFFECTS")) {
- for (int nefx=0;nefxenterbranch("INSERTION_EFFECT",nefx)==0) continue;
- Pinsparts[nefx]=xml->getpar("part",Pinsparts[nefx],-2,NUM_MIDI_PARTS);
- if (xml->enterbranch("EFFECT")) {
+ if(xml->enterbranch("INSERTION_EFFECTS")) {
+ for(int nefx = 0; nefx < NUM_INS_EFX; nefx++) {
+ if(xml->enterbranch("INSERTION_EFFECT", nefx) == 0)
+ continue;
+ Pinsparts[nefx] = xml->getpar("part",
+ Pinsparts[nefx],
+ -2,
+ NUM_MIDI_PARTS);
+ if(xml->enterbranch("EFFECT")) {
insefx[nefx]->getfromXML(xml);
xml->exitbranch();
- };
+ }
xml->exitbranch();
-
- };
+ }
xml->exitbranch();
- };
-
-
-};
-
-
-
+ }
+}
diff --git a/plugins/zynaddsubfx/src/Misc/Master.h b/plugins/zynaddsubfx/src/Misc/Master.h
index 69f1a1ec2..eb4752245 100644
--- a/plugins/zynaddsubfx/src/Misc/Master.h
+++ b/plugins/zynaddsubfx/src/Misc/Master.h
@@ -40,129 +40,136 @@ extern Dump dump;
* process them with system/insertion effects and mix them */
class Master
{
-public:
- /** Constructor*/
- Master();
- /** Destructor*/
- ~Master();
+ public:
+ /** Constructor*/
+ Master();
+ /** Destructor*/
+ ~Master();
- /**Saves all settings to a XML file
- * @return 0 for ok or <0 if there is an error*/
- int saveXML(const char *filename);
+ /**Saves all settings to a XML file
+ * @return 0 for ok or <0 if there is an error*/
+ int saveXML(const char *filename);
- /**This adds the parameters to the XML data*/
- void add2XML(XMLwrapper *xml);
+ /**This adds the parameters to the XML data*/
+ void add2XML(XMLwrapper *xml);
- void defaults();
+ void defaults();
- /**loads all settings from a XML file
- * @return 0 for ok or -1 if there is an error*/
- int loadXML(const char *filename);
- void applyparameters();
+ /**loads all settings from a XML file
+ * @return 0 for ok or -1 if there is an error*/
+ int loadXML(const char *filename);
+ void applyparameters();
- void getfromXML(XMLwrapper *xml);
+ void getfromXML(XMLwrapper *xml);
- /**get all data to a newly allocated array (used for VST)
- * @return the datasize*/
- int getalldata(char **data);
- /**put all data from the *data array to zynaddsubfx parameters (used for VST)*/
- void putalldata(char *data,int size);
+ /**get all data to a newly allocated array (used for VST)
+ * @return the datasize*/
+ int getalldata(char **data);
+ /**put all data from the *data array to zynaddsubfx parameters (used for VST)*/
+ void putalldata(char *data, int size);
- //Midi IN
- void NoteOn(unsigned char chan,unsigned char note,unsigned char velocity);
- void NoteOff(unsigned char chan,unsigned char note);
- void SetController(unsigned char chan,unsigned int type,int par);
- //void NRPN...
+ //Midi IN
+ void NoteOn(unsigned char chan,
+ unsigned char note,
+ unsigned char velocity);
+ void NoteOff(unsigned char chan, unsigned char note);
+ void SetController(unsigned char chan, unsigned int type, int par);
+ //void NRPN...
- void ShutUp();
- int shutup;
+ void ShutUp();
+ int shutup;
- /**Audio Output*/
- void AudioOut(REALTYPE *outl,REALTYPE *outr);
- /**Audio Output (for callback mode). This allows the program to be controled by an external program*/
- void GetAudioOutSamples(int nsamples,int samplerate,REALTYPE *outl,REALTYPE *outr);
+ /**Audio Output*/
+ void AudioOut(REALTYPE *outl, REALTYPE *outr);
+ /**Audio Output (for callback mode). This allows the program to be controled by an external program*/
+ void GetAudioOutSamples(int nsamples,
+ int samplerate,
+ REALTYPE *outl,
+ REALTYPE *outr);
- void partonoff(int npart,int what);
+ void partonoff(int npart, int what);
- /**parts \todo see if this can be made to be dynamic*/
- Part *part[NUM_MIDI_PARTS];
+ /**parts \todo see if this can be made to be dynamic*/
+ Part *part[NUM_MIDI_PARTS];
- //parameters
- unsigned char Pvolume;
- unsigned char Pkeyshift;
- unsigned char Psysefxvol[NUM_SYS_EFX][NUM_MIDI_PARTS];
- unsigned char Psysefxsend[NUM_SYS_EFX][NUM_SYS_EFX];
+ //parameters
+ unsigned char Pvolume;
+ unsigned char Pkeyshift;
+ unsigned char Psysefxvol[NUM_SYS_EFX][NUM_MIDI_PARTS];
+ unsigned char Psysefxsend[NUM_SYS_EFX][NUM_SYS_EFX];
- //parameters control
- void setPvolume(char Pvolume_);
- void setPkeyshift(char Pkeyshift_);
- void setPsysefxvol(int Ppart,int Pefx,char Pvol);
- void setPsysefxsend(int Pefxfrom,int Pefxto,char Pvol);
+ //parameters control
+ void setPvolume(char Pvolume_);
+ void setPkeyshift(char Pkeyshift_);
+ void setPsysefxvol(int Ppart, int Pefx, char Pvol);
+ void setPsysefxsend(int Pefxfrom, int Pefxto, char Pvol);
- //effects
- EffectMgr *sysefx[NUM_SYS_EFX];//system
- EffectMgr *insefx[NUM_INS_EFX];//insertion
+ //effects
+ EffectMgr *sysefx[NUM_SYS_EFX]; //system
+ EffectMgr *insefx[NUM_INS_EFX]; //insertion
// void swapcopyeffects(int what,int type,int neff1,int neff2);
- //HDD recorder
- Recorder HDDRecorder;
+ //HDD recorder
+ Recorder HDDRecorder;
- //part that's apply the insertion effect; -1 to disable
- short int Pinsparts[NUM_INS_EFX];
+ //part that's apply the insertion effect; -1 to disable
+ short int Pinsparts[NUM_INS_EFX];
- //peaks for VU-meter
- void vuresetpeaks();
- REALTYPE vuoutpeakl,vuoutpeakr,vumaxoutpeakl,vumaxoutpeakr,vurmspeakl,vurmspeakr;
- int vuclipped;
+ //peaks for VU-meter
+ void vuresetpeaks();
+ REALTYPE vuoutpeakl, vuoutpeakr, vumaxoutpeakl, vumaxoutpeakr,
+ vurmspeakl, vurmspeakr;
+ int vuclipped;
- //peaks for part VU-meters
- REALTYPE vuoutpeakpart[NUM_MIDI_PARTS];
- unsigned char fakepeakpart[NUM_MIDI_PARTS];//this is used to compute the "peak" when the part is disabled
+ //peaks for part VU-meters
+ REALTYPE vuoutpeakpart[NUM_MIDI_PARTS];
+ unsigned char fakepeakpart[NUM_MIDI_PARTS]; //this is used to compute the "peak" when the part is disabled
- Controller ctl;
- int swaplr;//1 if L and R are swapped
+ Controller ctl;
+ int swaplr; //1 if L and R are swapped
- //Sequencer
- Sequencer seq;
+ //Sequencer
+ Sequencer seq;
- //other objects
- Microtonal microtonal;
- Bank bank;
+ //other objects
+ Microtonal microtonal;
+ Bank bank;
- FFTwrapper *fft;
- pthread_mutex_t mutex;
+ FFTwrapper *fft;
+ pthread_mutex_t mutex;
-private:
- REALTYPE volume;
- REALTYPE sysefxvol[NUM_SYS_EFX][NUM_MIDI_PARTS];
- REALTYPE sysefxsend[NUM_SYS_EFX][NUM_SYS_EFX];
+ private:
+ REALTYPE volume;
+ REALTYPE sysefxvol[NUM_SYS_EFX][NUM_MIDI_PARTS];
+ REALTYPE sysefxsend[NUM_SYS_EFX][NUM_SYS_EFX];
- //Temporary mixing samples for part samples which is sent to system effect
- REALTYPE *tmpmixl;
- REALTYPE *tmpmixr;
+ //Temporary mixing samples for part samples which is sent to system effect
+ REALTYPE *tmpmixl;
+ REALTYPE *tmpmixr;
- int keyshift;
+ int keyshift;
- //Audio Output samples (if it used GetAudioOutSamples - eg. for Jack output; elsewhere is unused)
- REALTYPE *audiooutl;
- REALTYPE *audiooutr;
+ //Audio Output samples (if it used GetAudioOutSamples - eg. for Jack output; elsewhere is unused)
+ REALTYPE *audiooutl;
+ REALTYPE *audiooutr;
- int ksoundbuffersample;//this is used to know if there is need to call AudioOut by GetAudioOutSamples method
- REALTYPE ksoundbuffersamplelow;//this is used for resampling (eg. if Jack samplerate!= SAMPLE_RATE)
- REALTYPE oldsamplel,oldsampler;//this is used for resampling
-
- //These are called by the NoteOn, NoteOff,SetController (which are from external sources like MIDI, Virtual Keyboard)
- //and are called by internal parts of the program (like sequencer)
- void noteon(unsigned char chan,unsigned char note,unsigned char velocity);
- void noteoff(unsigned char chan,unsigned char note);
- void setcontroller(unsigned char chan,unsigned int type,int par);
+ int ksoundbuffersample; //this is used to know if there is need to call AudioOut by GetAudioOutSamples method
+ REALTYPE ksoundbuffersamplelow; //this is used for resampling (eg. if Jack samplerate!= SAMPLE_RATE)
+ REALTYPE oldsamplel, oldsampler; //this is used for resampling
+ //These are called by the NoteOn, NoteOff,SetController (which are from external sources like MIDI, Virtual Keyboard)
+ //and are called by internal parts of the program (like sequencer)
+ void noteon(unsigned char chan,
+ unsigned char note,
+ unsigned char velocity);
+ void noteoff(unsigned char chan, unsigned char note);
+ void setcontroller(unsigned char chan, unsigned int type, int par);
};
diff --git a/plugins/zynaddsubfx/src/Misc/Microtonal.cpp b/plugins/zynaddsubfx/src/Misc/Microtonal.cpp
index b389059c8..e84ee8e64 100644
--- a/plugins/zynaddsubfx/src/Misc/Microtonal.cpp
+++ b/plugins/zynaddsubfx/src/Misc/Microtonal.cpp
@@ -28,158 +28,190 @@
Microtonal::Microtonal()
{
- Pname=new unsigned char[MICROTONAL_MAX_NAME_LEN];
- Pcomment=new unsigned char[MICROTONAL_MAX_NAME_LEN];
+ Pname = new unsigned char[MICROTONAL_MAX_NAME_LEN];
+ Pcomment = new unsigned char[MICROTONAL_MAX_NAME_LEN];
defaults();
-};
+}
void Microtonal::defaults()
{
- Pinvertupdown=0;
- Pinvertupdowncenter=60;
- octavesize=12;
- Penabled=0;
- PAnote=69;
- PAfreq=440.0;
- Pscaleshift=64;
+ Pinvertupdown = 0;
+ Pinvertupdowncenter = 60;
+ octavesize = 12;
+ Penabled = 0;
+ PAnote = 69;
+ PAfreq = 440.0;
+ Pscaleshift = 64;
- Pfirstkey=0;
- Plastkey=127;
- Pmiddlenote=60;
- Pmapsize=12;
- Pmappingenabled=0;
+ Pfirstkey = 0;
+ Plastkey = 127;
+ Pmiddlenote = 60;
+ Pmapsize = 12;
+ Pmappingenabled = 0;
- for (int i=0;i<128;i++) Pmapping[i]=i;
+ for(int i = 0; i < 128; i++)
+ Pmapping[i] = i;
- for (int i=0;iPlastkey)) return (-1.0);
+ if(Pmappingenabled != 0) {
+ if((note < Pfirstkey) || (note > Plastkey))
+ return -1.0;
//Compute how many mapped keys are from middle note to reference note
//and find out the proportion between the freq. of middle note and "A" note
- int tmp=PAnote-Pmiddlenote,minus=0;
- if (tmp<0) {
- tmp=-tmp;
- minus=1;
- };
- int deltanote=0;
- for (int i=0;i=0) deltanote++;
- REALTYPE rap_anote_middlenote=(deltanote==0) ? (1.0) : (octave[(deltanote-1)%octavesize].tuning);
- if (deltanote!=0) rap_anote_middlenote*=pow(octave[octavesize-1].tuning,(deltanote-1)/octavesize);
- if (minus!=0) rap_anote_middlenote=1.0/rap_anote_middlenote;
+ int tmp = PAnote - Pmiddlenote, minus = 0;
+ if(tmp < 0) {
+ tmp = -tmp;
+ minus = 1;
+ }
+ int deltanote = 0;
+ for(int i = 0; i < tmp; i++)
+ if(Pmapping[i % Pmapsize] >= 0)
+ deltanote++;
+ REALTYPE rap_anote_middlenote =
+ (deltanote ==
+ 0) ? (1.0) : (octave[(deltanote - 1) % octavesize].tuning);
+ if(deltanote != 0)
+ rap_anote_middlenote *=
+ pow(octave[octavesize - 1].tuning, (deltanote - 1) / octavesize);
+ if(minus != 0)
+ rap_anote_middlenote = 1.0 / rap_anote_middlenote;
//Convert from note (midi) to degree (note from the tunning)
- int degoct=(note-(int)Pmiddlenote+(int) Pmapsize*200)/(int)Pmapsize-200;
- int degkey=(note-Pmiddlenote+(int)Pmapsize*100)%Pmapsize;
- degkey=Pmapping[degkey];
- if (degkey<0) return(-1.0);//this key is not mapped
+ int degoct =
+ (note - (int)Pmiddlenote + (int) Pmapsize
+ * 200) / (int)Pmapsize - 200;
+ int degkey = (note - Pmiddlenote + (int)Pmapsize * 100) % Pmapsize;
+ degkey = Pmapping[degkey];
+ if(degkey < 0)
+ return -1.0; //this key is not mapped
//invert the keyboard upside-down if it is asked for
//TODO: do the right way by using Pinvertupdowncenter
- if (Pinvertupdown!=0) {
- degkey=octavesize-degkey-1;
- degoct=-degoct;
- };
+ if(Pinvertupdown != 0) {
+ degkey = octavesize - degkey - 1;
+ degoct = -degoct;
+ }
//compute the frequency of the note
- degkey=degkey+scaleshift;
- degoct+=degkey/octavesize;
- degkey%=octavesize;
+ degkey = degkey + scaleshift;
+ degoct += degkey / octavesize;
+ degkey %= octavesize;
- REALTYPE freq=(degkey==0) ? (1.0):octave[degkey-1].tuning;
- freq*=pow(octave[octavesize-1].tuning,degoct);
- freq*=PAfreq/rap_anote_middlenote;
- freq*=globalfinedetunerap;
- if (scaleshift!=0) freq/=octave[scaleshift-1].tuning;
- return(freq*rap_keyshift);
- } else {//if the mapping is disabled
- int nt=note-PAnote+scaleshift;
- int ntkey=(nt+(int)octavesize*100)%octavesize;
- int ntoct=(nt-ntkey)/octavesize;
+ REALTYPE freq = (degkey == 0) ? (1.0) : octave[degkey - 1].tuning;
+ freq *= pow(octave[octavesize - 1].tuning, degoct);
+ freq *= PAfreq / rap_anote_middlenote;
+ freq *= globalfinedetunerap;
+ if(scaleshift != 0)
+ freq /= octave[scaleshift - 1].tuning;
+ return freq * rap_keyshift;
+ }
+ else { //if the mapping is disabled
+ int nt = note - PAnote + scaleshift;
+ int ntkey = (nt + (int)octavesize * 100) % octavesize;
+ int ntoct = (nt - ntkey) / octavesize;
- REALTYPE oct=octave[octavesize-1].tuning;
- REALTYPE freq=octave[(ntkey+octavesize-1)%octavesize].tuning*pow(oct,ntoct)*PAfreq;
- if (ntkey==0) freq/=oct;
- if (scaleshift!=0) freq/=octave[scaleshift-1].tuning;
+ REALTYPE oct = octave[octavesize - 1].tuning;
+ REALTYPE freq =
+ octave[(ntkey + octavesize - 1) % octavesize].tuning *pow(oct,
+ ntoct)
+ * PAfreq;
+ if(ntkey == 0)
+ freq /= oct;
+ if(scaleshift != 0)
+ freq /= octave[scaleshift - 1].tuning;
// fprintf(stderr,"note=%d freq=%.3f cents=%d\n",note,freq,(int)floor(log(freq/PAfreq)/log(2.0)*1200.0+0.5));
- freq*=globalfinedetunerap;
- return(freq*rap_keyshift);
- };
-};
+ freq *= globalfinedetunerap;
+ return freq * rap_keyshift;
+ }
+}
bool Microtonal::operator==(const Microtonal µ) const
{
- return(!(*this!=micro));
+ return !(*this != micro);
}
bool Microtonal::operator!=(const Microtonal µ) const
{
-
//A simple macro to test equality MiCRotonal EQuals (not the perfect
//approach, but good enough)
-#define MCREQ( x ) if(x!=micro.x)return true;
+#define MCREQ(x) if(x != micro.x) \
+ return true;
//for floats
-#define FMCREQ( x ) if(!((xmicro.x-0.0001)))return true;
+#define FMCREQ(x) if(!((x < micro.x + 0.0001) && (x > micro.x - 0.0001))) \
+ return true;
MCREQ(Pinvertupdown);
MCREQ(Pinvertupdowncenter);
@@ -195,18 +227,18 @@ bool Microtonal::operator!=(const Microtonal µ) const
MCREQ(Pmapsize);
MCREQ(Pmappingenabled);
- for (int i=0;i<128;i++)
+ for(int i = 0; i < 128; i++)
MCREQ(Pmapping[i]);
- for (int i=0;iPname,(const char *)micro.Pname))
+ if(strcmp((const char *)this->Pname, (const char *)micro.Pname))
return true;
- if(strcmp((const char *)this->Pcomment,(const char *)micro.Pcomment))
+ if(strcmp((const char *)this->Pcomment, (const char *)micro.Pcomment))
return true;
MCREQ(Pglobalfinedetune);
return false;
@@ -214,384 +246,442 @@ bool Microtonal::operator!=(const Microtonal µ) const
//undefine macros, as they are no longer needed
#undef MCREQ
#undef FMCREQ
-
}
/*
* Convert a line to tunings; returns -1 if it ok
*/
-int Microtonal::linetotunings(unsigned int nline,const char *line)
+int Microtonal::linetotunings(unsigned int nline, const char *line)
{
- int x1=-1,x2=-1,type=-1;
- REALTYPE x=-1.0,tmp,tuning=1.0;
- if (strstr(line,"/")==NULL) {
- if (strstr(line,".")==NULL) {// M case (M=M/1)
- sscanf(line,"%d",&x1);
- x2=1;
- type=2;//division
- } else {// float number case
- sscanf(line,"%f",&x);
- if (x<0.000001) return(1);
- type=1;//float type(cents)
- };
- } else {// M/N case
- sscanf(line,"%d/%d",&x1,&x2);
- if ((x1<0)||(x2<0)) return(1);
- if (x2==0) x2=1;
- type=2;//division
- };
+ int x1 = -1, x2 = -1, type = -1;
+ REALTYPE x = -1.0, tmp, tuning = 1.0;
+ if(strstr(line, "/") == NULL) {
+ if(strstr(line, ".") == NULL) { // M case (M=M/1)
+ sscanf(line, "%d", &x1);
+ x2 = 1;
+ type = 2; //division
+ }
+ else { // float number case
+ sscanf(line, "%f", &x);
+ if(x < 0.000001)
+ return 1;
+ type = 1; //float type(cents)
+ }
+ }
+ else { // M/N case
+ sscanf(line, "%d/%d", &x1, &x2);
+ if((x1 < 0) || (x2 < 0))
+ return 1;
+ if(x2 == 0)
+ x2 = 1;
+ type = 2; //division
+ }
- if (x1<=0) x1=1;//not allow zero frequency sounds (consider 0 as 1)
+ if(x1 <= 0)
+ x1 = 1; //not allow zero frequency sounds (consider 0 as 1)
//convert to float if the number are too big
- if ((type==2)&&((x1>(128*128*128-1))||(x2>(128*128*128-1)))) {
- type=1;
- x=((REALTYPE) x1)/x2;
- };
- switch (type) {
+ if((type == 2)
+ && ((x1 > (128 * 128 * 128 - 1)) || (x2 > (128 * 128 * 128 - 1)))) {
+ type = 1;
+ x = ((REALTYPE) x1) / x2;
+ }
+ switch(type) {
case 1:
- x1=(int) floor(x);
- tmp=fmod(x,1.0);
- x2=(int) (floor (tmp*1e6));
- tuning=pow(2.0,x/1200.0);
+ x1 = (int) floor(x);
+ tmp = fmod(x, 1.0);
+ x2 = (int) (floor(tmp * 1e6));
+ tuning = pow(2.0, x / 1200.0);
break;
case 2:
- x=((REALTYPE)x1)/x2;
- tuning=x;
+ x = ((REALTYPE)x1) / x2;
+ tuning = x;
break;
- };
+ }
- tmpoctave[nline].tuning=tuning;
- tmpoctave[nline].type=type;
- tmpoctave[nline].x1=x1;
- tmpoctave[nline].x2=x2;
+ tmpoctave[nline].tuning = tuning;
+ tmpoctave[nline].type = type;
+ tmpoctave[nline].x1 = x1;
+ tmpoctave[nline].x2 = x2;
- return(-1);//ok
-};
+ return -1; //ok
+}
/*
* Convert the text to tunnings
*/
int Microtonal::texttotunings(const char *text)
{
- unsigned int i,k=0,nl=0;
+ unsigned int i, k = 0, nl = 0;
char *lin;
- lin=new char[MAX_LINE_SIZE+1];
- while (kMAX_OCTAVE_SIZE) nl=MAX_OCTAVE_SIZE;
- if (nl==0) return(-2);//the input is empty
- octavesize=nl;
- for (i=0;i MAX_OCTAVE_SIZE)
+ nl = MAX_OCTAVE_SIZE;
+ if(nl == 0)
+ return -2; //the input is empty
+ octavesize = nl;
+ for(i = 0; i < octavesize; i++) {
+ octave[i].tuning = tmpoctave[i].tuning;
+ octave[i].type = tmpoctave[i].type;
+ octave[i].x1 = tmpoctave[i].x1;
+ octave[i].x2 = tmpoctave[i].x2;
+ }
+ return -1; //ok
+}
/*
* Convert the text to mapping
*/
void Microtonal::texttomapping(const char *text)
{
- unsigned int i,k=0;
+ unsigned int i, k = 0;
char *lin;
- lin=new char[MAX_LINE_SIZE+1];
- for (i=0;i<128;i++) Pmapping[i]=-1;
- int tx=0;
- while (k127) break;
- };
+ if((tx++) > 127)
+ break;
+ }
delete [] lin;
- if (tx==0) tx=1;
- Pmapsize=tx;
-};
+ if(tx == 0)
+ tx = 1;
+ Pmapsize = tx;
+}
/*
* Convert tunning to text line
*/
-void Microtonal::tuningtoline(int n,char *line,int maxn)
+void Microtonal::tuningtoline(int n, char *line, int maxn)
{
- if ((n>octavesize) || (n>MAX_OCTAVE_SIZE)) {
- line[0]='\0';
+ if((n > octavesize) || (n > MAX_OCTAVE_SIZE)) {
+ line[0] = '\0';
return;
- };
- if (octave[n].type==1) snprintf(line,maxn,"%d.%d",octave[n].x1,octave[n].x2);
- if (octave[n].type==2) snprintf(line,maxn,"%d/%d",octave[n].x1,octave[n].x2);
-};
+ }
+ if(octave[n].type == 1)
+ snprintf(line, maxn, "%d.%d", octave[n].x1, octave[n].x2);
+ if(octave[n].type == 2)
+ snprintf(line, maxn, "%d/%d", octave[n].x1, octave[n].x2);
+}
-int Microtonal::loadline(FILE *file,char *line)
+int Microtonal::loadline(FILE *file, char *line)
{
do {
- if (fgets(line,500,file)==0) return(1);
- } while (line[0]=='!');
- return(0);
-};
+ if(fgets(line, 500, file) == 0)
+ return 1;
+ } while(line[0] == '!');
+ return 0;
+}
/*
* Loads the tunnings from a scl file
*/
int Microtonal::loadscl(const char *filename)
{
- FILE *file=fopen(filename, "r");
- char tmp[500];
- fseek(file,0,SEEK_SET);
+ FILE *file = fopen(filename, "r");
+ char tmp[500];
+ fseek(file, 0, SEEK_SET);
//loads the short description
- if (loadline(file,&tmp[0])!=0) return(2);
- for (int i=0;i<500;i++) if (tmp[i]<32) tmp[i]=0;
- snprintf((char *) Pname,MICROTONAL_MAX_NAME_LEN,"%s",tmp);
- snprintf((char *) Pcomment,MICROTONAL_MAX_NAME_LEN,"%s",tmp);
+ if(loadline(file, &tmp[0]) != 0)
+ return 2;
+ for(int i = 0; i < 500; i++)
+ if(tmp[i] < 32)
+ tmp[i] = 0;
+ snprintf((char *) Pname, MICROTONAL_MAX_NAME_LEN, "%s", tmp);
+ snprintf((char *) Pcomment, MICROTONAL_MAX_NAME_LEN, "%s", tmp);
//loads the number of the notes
- if (loadline(file,&tmp[0])!=0) return(2);
- int nnotes=MAX_OCTAVE_SIZE;
- sscanf(&tmp[0],"%d",&nnotes);
- if (nnotes>MAX_OCTAVE_SIZE) return (2);
+ if(loadline(file, &tmp[0]) != 0)
+ return 2;
+ int nnotes = MAX_OCTAVE_SIZE;
+ sscanf(&tmp[0], "%d", &nnotes);
+ if(nnotes > MAX_OCTAVE_SIZE)
+ return 2;
//load the tunnings
- for (int nline=0;nline127) x=127;//just in case...
- Pmapsize=x;
+ if(loadline(file, &tmp[0]) != 0)
+ return 2;
+ if(sscanf(&tmp[0], "%d", &x) == 0)
+ return 2;
+ if(x < 1)
+ x = 0;
+ if(x > 127)
+ x = 127; //just in case...
+ Pmapsize = x;
//loads first MIDI note to retune
- if (loadline(file,&tmp[0])!=0) return(2);
- if (sscanf(&tmp[0],"%d",&x)==0) return(2);
- if (x<1) x=0;
- if (x>127) x=127;//just in case...
- Pfirstkey=x;
+ if(loadline(file, &tmp[0]) != 0)
+ return 2;
+ if(sscanf(&tmp[0], "%d", &x) == 0)
+ return 2;
+ if(x < 1)
+ x = 0;
+ if(x > 127)
+ x = 127; //just in case...
+ Pfirstkey = x;
//loads last MIDI note to retune
- if (loadline(file,&tmp[0])!=0) return(2);
- if (sscanf(&tmp[0],"%d",&x)==0) return(2);
- if (x<1) x=0;
- if (x>127) x=127;//just in case...
- Plastkey=x;
+ if(loadline(file, &tmp[0]) != 0)
+ return 2;
+ if(sscanf(&tmp[0], "%d", &x) == 0)
+ return 2;
+ if(x < 1)
+ x = 0;
+ if(x > 127)
+ x = 127; //just in case...
+ Plastkey = x;
//loads last the middle note where scale fro scale degree=0
- if (loadline(file,&tmp[0])!=0) return(2);
- if (sscanf(&tmp[0],"%d",&x)==0) return(2);
- if (x<1) x=0;
- if (x>127) x=127;//just in case...
- Pmiddlenote=x;
+ if(loadline(file, &tmp[0]) != 0)
+ return 2;
+ if(sscanf(&tmp[0], "%d", &x) == 0)
+ return 2;
+ if(x < 1)
+ x = 0;
+ if(x > 127)
+ x = 127; //just in case...
+ Pmiddlenote = x;
//loads the reference note
- if (loadline(file,&tmp[0])!=0) return(2);
- if (sscanf(&tmp[0],"%d",&x)==0) return(2);
- if (x<1) x=0;
- if (x>127) x=127;//just in case...
- PAnote=x;
+ if(loadline(file, &tmp[0]) != 0)
+ return 2;
+ if(sscanf(&tmp[0], "%d", &x) == 0)
+ return 2;
+ if(x < 1)
+ x = 0;
+ if(x > 127)
+ x = 127; //just in case...
+ PAnote = x;
//loads the reference freq.
- if (loadline(file,&tmp[0])!=0) return(2);
- REALTYPE tmpPAfreq=440.0;
- if (sscanf(&tmp[0],"%f",&tmpPAfreq)==0) return(2);
- PAfreq=tmpPAfreq;
+ if(loadline(file, &tmp[0]) != 0)
+ return 2;
+ REALTYPE tmpPAfreq = 440.0;
+ if(sscanf(&tmp[0], "%f", &tmpPAfreq) == 0)
+ return 2;
+ PAfreq = tmpPAfreq;
//the scale degree(which is the octave) is not loaded, it is obtained by the tunnings with getoctavesize() method
- if (loadline(file,&tmp[0])!=0) return(2);
+ if(loadline(file, &tmp[0]) != 0)
+ return 2;
//load the mappings
- if (Pmapsize!=0) {
- for (int nline=0;nlineaddparstr("name",(char *) Pname);
- xml->addparstr("comment",(char *) Pcomment);
+ xml->addparstr("name", (char *) Pname);
+ xml->addparstr("comment", (char *) Pcomment);
- xml->addparbool("invert_up_down",Pinvertupdown);
- xml->addpar("invert_up_down_center",Pinvertupdowncenter);
+ xml->addparbool("invert_up_down", Pinvertupdown);
+ xml->addpar("invert_up_down_center", Pinvertupdowncenter);
- xml->addparbool("enabled",Penabled);
- xml->addpar("global_fine_detune",Pglobalfinedetune);
+ xml->addparbool("enabled", Penabled);
+ xml->addpar("global_fine_detune", Pglobalfinedetune);
- xml->addpar("a_note",PAnote);
- xml->addparreal("a_freq",PAfreq);
+ xml->addpar("a_note", PAnote);
+ xml->addparreal("a_freq", PAfreq);
- if ((Penabled==0)&&(xml->minimal)) return;
+ if((Penabled == 0) && (xml->minimal))
+ return;
xml->beginbranch("SCALE");
- xml->addpar("scale_shift",Pscaleshift);
- xml->addpar("first_key",Pfirstkey);
- xml->addpar("last_key",Plastkey);
- xml->addpar("middle_note",Pmiddlenote);
+ xml->addpar("scale_shift", Pscaleshift);
+ xml->addpar("first_key", Pfirstkey);
+ xml->addpar("last_key", Plastkey);
+ xml->addpar("middle_note", Pmiddlenote);
xml->beginbranch("OCTAVE");
- xml->addpar("octave_size",octavesize);
- for (int i=0;ibeginbranch("DEGREE",i);
- if (octave[i].type==1) {
- xml->addparreal("cents",octave[i].tuning);
- };
- if (octave[i].type==2) {
- xml->addpar("numerator",octave[i].x1);
- xml->addpar("denominator",octave[i].x2);
- };
+ xml->addpar("octave_size", octavesize);
+ for(int i = 0; i < octavesize; i++) {
+ xml->beginbranch("DEGREE", i);
+ if(octave[i].type == 1)
+ xml->addparreal("cents", octave[i].tuning);
+ ;
+ if(octave[i].type == 2) {
+ xml->addpar("numerator", octave[i].x1);
+ xml->addpar("denominator", octave[i].x2);
+ }
xml->endbranch();
- };
+ }
xml->endbranch();
xml->beginbranch("KEYBOARD_MAPPING");
- xml->addpar("map_size",Pmapsize);
- xml->addpar("mapping_enabled",Pmappingenabled);
- for (int i=0;ibeginbranch("KEYMAP",i);
- xml->addpar("degree",Pmapping[i]);
+ xml->addpar("map_size", Pmapsize);
+ xml->addpar("mapping_enabled", Pmappingenabled);
+ for(int i = 0; i < Pmapsize; i++) {
+ xml->beginbranch("KEYMAP", i);
+ xml->addpar("degree", Pmapping[i]);
xml->endbranch();
- };
+ }
xml->endbranch();
xml->endbranch();
-};
+}
void Microtonal::getfromXML(XMLwrapper *xml)
{
- xml->getparstr("name",(char *) Pname,MICROTONAL_MAX_NAME_LEN);
- xml->getparstr("comment",(char *) Pcomment,MICROTONAL_MAX_NAME_LEN);
+ xml->getparstr("name", (char *) Pname, MICROTONAL_MAX_NAME_LEN);
+ xml->getparstr("comment", (char *) Pcomment, MICROTONAL_MAX_NAME_LEN);
- Pinvertupdown=xml->getparbool("invert_up_down",Pinvertupdown);
- Pinvertupdowncenter=xml->getpar127("invert_up_down_center",Pinvertupdowncenter);
+ Pinvertupdown = xml->getparbool("invert_up_down", Pinvertupdown);
+ Pinvertupdowncenter = xml->getpar127("invert_up_down_center",
+ Pinvertupdowncenter);
- Penabled=xml->getparbool("enabled",Penabled);
- Pglobalfinedetune=xml->getpar127("global_fine_detune",Pglobalfinedetune);
+ Penabled = xml->getparbool("enabled", Penabled);
+ Pglobalfinedetune = xml->getpar127("global_fine_detune", Pglobalfinedetune);
- PAnote=xml->getpar127("a_note",PAnote);
- PAfreq=xml->getparreal("a_freq",PAfreq,1.0,10000.0);
+ PAnote = xml->getpar127("a_note", PAnote);
+ PAfreq = xml->getparreal("a_freq", PAfreq, 1.0, 10000.0);
- if (xml->enterbranch("SCALE")) {
- Pscaleshift=xml->getpar127("scale_shift",Pscaleshift);
- Pfirstkey=xml->getpar127("first_key",Pfirstkey);
- Plastkey=xml->getpar127("last_key",Plastkey);
- Pmiddlenote=xml->getpar127("middle_note",Pmiddlenote);
+ if(xml->enterbranch("SCALE")) {
+ Pscaleshift = xml->getpar127("scale_shift", Pscaleshift);
+ Pfirstkey = xml->getpar127("first_key", Pfirstkey);
+ Plastkey = xml->getpar127("last_key", Plastkey);
+ Pmiddlenote = xml->getpar127("middle_note", Pmiddlenote);
- if (xml->enterbranch("OCTAVE")) {
- octavesize=xml->getpar127("octave_size",octavesize);
- for (int i=0;ienterbranch("DEGREE",i)==0) continue;
- octave[i].x2=0;
- octave[i].tuning=xml->getparreal("cents",octave[i].tuning);
- octave[i].x1=xml->getpar127("numerator",octave[i].x1);
- octave[i].x2=xml->getpar127("denominator",octave[i].x2);
+ if(xml->enterbranch("OCTAVE")) {
+ octavesize = xml->getpar127("octave_size", octavesize);
+ for(int i = 0; i < octavesize; i++) {
+ if(xml->enterbranch("DEGREE", i) == 0)
+ continue;
+ octave[i].x2 = 0;
+ octave[i].tuning = xml->getparreal("cents", octave[i].tuning);
+ octave[i].x1 = xml->getpar127("numerator", octave[i].x1);
+ octave[i].x2 = xml->getpar127("denominator", octave[i].x2);
- if (octave[i].x2!=0) octave[i].type=2;
- else octave[i].type=1;
+ if(octave[i].x2 != 0)
+ octave[i].type = 2;
+ else
+ octave[i].type = 1;
xml->exitbranch();
- };
+ }
xml->exitbranch();
- };
+ }
- if (xml->enterbranch("KEYBOARD_MAPPING")) {
- Pmapsize=xml->getpar127("map_size",Pmapsize);
- Pmappingenabled=xml->getpar127("mapping_enabled",Pmappingenabled);
- for (int i=0;ienterbranch("KEYMAP",i)==0) continue;
- Pmapping[i]=xml->getpar127("degree",Pmapping[i]);
+ if(xml->enterbranch("KEYBOARD_MAPPING")) {
+ Pmapsize = xml->getpar127("map_size", Pmapsize);
+ Pmappingenabled = xml->getpar127("mapping_enabled", Pmappingenabled);
+ for(int i = 0; i < Pmapsize; i++) {
+ if(xml->enterbranch("KEYMAP", i) == 0)
+ continue;
+ Pmapping[i] = xml->getpar127("degree", Pmapping[i]);
xml->exitbranch();
- };
+ }
xml->exitbranch();
- };
+ }
xml->exitbranch();
- };
-};
+ }
+}
-int Microtonal::saveXML(const char *filename)const
+int Microtonal::saveXML(const char *filename) const
{
- XMLwrapper *xml=new XMLwrapper();
+ XMLwrapper *xml = new XMLwrapper();
xml->beginbranch("MICROTONAL");
add2XML(xml);
xml->endbranch();
- int result=xml->saveXMLfile(filename);
+ int result = xml->saveXMLfile(filename);
delete (xml);
- return(result);
-};
+ return result;
+}
int Microtonal::loadXML(const char *filename)
{
- XMLwrapper *xml=new XMLwrapper();
- if (xml->loadXMLfile(filename)<0) {
- delete(xml);
- return(-1);
- };
+ XMLwrapper *xml = new XMLwrapper();
+ if(xml->loadXMLfile(filename) < 0) {
+ delete (xml);
+ return -1;
+ }
- if (xml->enterbranch("MICROTONAL")==0) return(-10);
+ if(xml->enterbranch("MICROTONAL") == 0)
+ return -10;
getfromXML(xml);
xml->exitbranch();
- delete(xml);
- return(0);
-};
-
+ delete (xml);
+ return 0;
+}
diff --git a/plugins/zynaddsubfx/src/Misc/Microtonal.h b/plugins/zynaddsubfx/src/Misc/Microtonal.h
index 99d73a24d..c7fd7c200 100644
--- a/plugins/zynaddsubfx/src/Misc/Microtonal.h
+++ b/plugins/zynaddsubfx/src/Misc/Microtonal.h
@@ -35,102 +35,100 @@
/**Tuning settings and microtonal capabilities*/
class Microtonal
{
-public:
- /**Constructor*/
- Microtonal();
- /**Destructor*/
- ~Microtonal();
- void defaults();
- /**Calculates the frequency for a given note
- */
- REALTYPE getnotefreq(int note,int keyshift) const;
+ public:
+ /**Constructor*/
+ Microtonal();
+ /**Destructor*/
+ ~Microtonal();
+ void defaults();
+ /**Calculates the frequency for a given note
+ */
+ REALTYPE getnotefreq(int note, int keyshift) const;
- //Parameters
- /**if the keys are inversed (the pitch is lower to keys from the right direction)*/
- unsigned char Pinvertupdown;
+ //Parameters
+ /**if the keys are inversed (the pitch is lower to keys from the right direction)*/
+ unsigned char Pinvertupdown;
- /**the central key of the inversion*/
- unsigned char Pinvertupdowncenter;
+ /**the central key of the inversion*/
+ unsigned char Pinvertupdowncenter;
- /**0 for 12 key temperate scale, 1 for microtonal*/
- unsigned char Penabled;
+ /**0 for 12 key temperate scale, 1 for microtonal*/
+ unsigned char Penabled;
- /**the note of "A" key*/
- unsigned char PAnote;
+ /**the note of "A" key*/
+ unsigned char PAnote;
- /**the frequency of the "A" note*/
- REALTYPE PAfreq;
+ /**the frequency of the "A" note*/
+ REALTYPE PAfreq;
- /**if the scale is "tuned" to a note, you can tune to other note*/
- unsigned char Pscaleshift;
+ /**if the scale is "tuned" to a note, you can tune to other note*/
+ unsigned char Pscaleshift;
- //first and last key (to retune)
- unsigned char Pfirstkey;
- unsigned char Plastkey;
+ //first and last key (to retune)
+ unsigned char Pfirstkey;
+ unsigned char Plastkey;
- /**The middle note where scale degree 0 is mapped to*/
- unsigned char Pmiddlenote;
+ /**The middle note where scale degree 0 is mapped to*/
+ unsigned char Pmiddlenote;
- /**Map size*/
- unsigned char Pmapsize;
+ /**Map size*/
+ unsigned char Pmapsize;
- /**Mapping ON/OFF*/
- unsigned char Pmappingenabled;
- /**Mapping (keys)*/
- short int Pmapping[128];
+ /**Mapping ON/OFF*/
+ unsigned char Pmappingenabled;
+ /**Mapping (keys)*/
+ short int Pmapping[128];
- /**Fine detune to be applied to all notes*/
- unsigned char Pglobalfinedetune;
+ /**Fine detune to be applied to all notes*/
+ unsigned char Pglobalfinedetune;
- // Functions
- /** Return the current octave size*/
- unsigned char getoctavesize() const;
- /**Convert tunning to string*/
- void tuningtoline(int n,char *line,int maxn);
- /**load the tunnings from a .scl file*/
- int loadscl(const char *filename);
- /**load the mapping from .kbm file*/
- int loadkbm(const char *filename);
- /**Load text into the internal tunings
- *
- *\todo better description*/
- int texttotunings(const char *text);
- /**Load text into the internal mappings
- *
- *\todo better description*/
- void texttomapping(const char *text);
+ // Functions
+ /** Return the current octave size*/
+ unsigned char getoctavesize() const;
+ /**Convert tunning to string*/
+ void tuningtoline(int n, char *line, int maxn);
+ /**load the tunnings from a .scl file*/
+ int loadscl(const char *filename);
+ /**load the mapping from .kbm file*/
+ int loadkbm(const char *filename);
+ /**Load text into the internal tunings
+ *
+ *\todo better description*/
+ int texttotunings(const char *text);
+ /**Load text into the internal mappings
+ *
+ *\todo better description*/
+ void texttomapping(const char *text);
- /**Name of Microtonal tuning*/
- unsigned char *Pname;
- /**Comment about the tuning*/
- unsigned char *Pcomment;
+ /**Name of Microtonal tuning*/
+ unsigned char *Pname;
+ /**Comment about the tuning*/
+ unsigned char *Pcomment;
- void add2XML(XMLwrapper *xml)const;
- void getfromXML(XMLwrapper *xml);
- int saveXML(const char *filename)const;
- int loadXML(const char *filename);
+ void add2XML(XMLwrapper *xml) const;
+ void getfromXML(XMLwrapper *xml);
+ int saveXML(const char *filename) const;
+ int loadXML(const char *filename);
- //simple operators primarily for debug
- bool operator==(const Microtonal µ) const;
- bool operator!=(const Microtonal µ) const;
+ //simple operators primarily for debug
+ bool operator==(const Microtonal µ) const;
+ bool operator!=(const Microtonal µ) const;
-private:
- int linetotunings(unsigned int nline,const char *line);
- int loadline(FILE *file,char *line);//loads a line from the text file, while ignoring the lines beggining with "!"
- unsigned char octavesize;
- struct {
- unsigned char type;//1 for cents or 2 for division
+ private:
+ int linetotunings(unsigned int nline, const char *line);
+ int loadline(FILE *file, char *line); //loads a line from the text file, while ignoring the lines beggining with "!"
+ unsigned char octavesize;
+ struct {
+ unsigned char type; //1 for cents or 2 for division
- // the real tuning (eg. +1.05946 for one halftone)
- // or 2.0 for one octave
- REALTYPE tuning;
-
- //the real tunning is x1/x2
- unsigned int x1,x2;
-
- } octave[MAX_OCTAVE_SIZE],tmpoctave[MAX_OCTAVE_SIZE];
+ // the real tuning (eg. +1.05946 for one halftone)
+ // or 2.0 for one octave
+ REALTYPE tuning;
+ //the real tunning is x1/x2
+ unsigned int x1, x2;
+ } octave[MAX_OCTAVE_SIZE], tmpoctave[MAX_OCTAVE_SIZE];
};
#endif
diff --git a/plugins/zynaddsubfx/src/Misc/Part.cpp b/plugins/zynaddsubfx/src/Misc/Part.cpp
index 2adf152d7..2f8dfe7ba 100644
--- a/plugins/zynaddsubfx/src/Misc/Part.cpp
+++ b/plugins/zynaddsubfx/src/Misc/Part.cpp
@@ -26,122 +26,122 @@
#include
#include
-Part::Part(Microtonal *microtonal_,FFTwrapper *fft_, pthread_mutex_t *mutex_)
+Part::Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_)
{
- microtonal=microtonal_;
- fft=fft_;
- mutex=mutex_;
- partoutl=new REALTYPE [SOUND_BUFFER_SIZE];
- partoutr=new REALTYPE [SOUND_BUFFER_SIZE];
- tmpoutl=new REALTYPE [SOUND_BUFFER_SIZE];
- tmpoutr=new REALTYPE [SOUND_BUFFER_SIZE];
+ microtonal = microtonal_;
+ fft = fft_;
+ mutex = mutex_;
+ partoutl = new REALTYPE [SOUND_BUFFER_SIZE];
+ partoutr = new REALTYPE [SOUND_BUFFER_SIZE];
+ tmpoutl = new REALTYPE [SOUND_BUFFER_SIZE];
+ tmpoutr = new REALTYPE [SOUND_BUFFER_SIZE];
- for (int n=0;ndefaults();
kit[0].subpars->defaults();
kit[0].padpars->defaults();
- for (int nefx=0;nefxdefaults();
- Pefxroute[nefx]=0;//route to next effect
- };
-
-};
+ Pefxroute[nefx] = 0; //route to next effect
+ }
+}
@@ -150,321 +150,515 @@ void Part::defaultsinstrument()
*/
void Part::cleanup()
{
- for (int k=0;kcleanup();
- for (int n=0;ncleanup();
+ for(int n = 0; n < NUM_PART_EFX + 1; n++) {
+ for(int i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ partfxinputl[n][i] = denormalkillbuf[i];
+ partfxinputr[n][i] = denormalkillbuf[i];
+ }
+ }
+}
Part::~Part()
{
cleanup();
- for (int n=0;nPmaxkey)) return;
+ if(Pnoteon == 0)
+ return;
+ if((note < Pminkey) || (note > Pmaxkey))
+ return;
// MonoMem stuff:
- if (Ppolymode==0) { // If Poly is off
+ if(Ppolymode == 0) { // If Poly is off
monomemnotes.push_back(note); // Add note to the list.
- monomem[note].velocity=velocity; // Store this note's velocity.
- monomem[note].mkeyshift=masterkeyshift; /* Store masterkeyshift too,
- I'm not sure why though... */
- if ((partnote[lastpos].status!=KEY_PLAYING)
- && (partnote[lastpos].status!=KEY_RELASED_AND_SUSTAINED)) {
- ismonofirstnote=true; // No other keys are held or sustained.
+ monomem[note].velocity = velocity; // Store this note's velocity.
+ monomem[note].mkeyshift = masterkeyshift; /* Store masterkeyshift too,
+ I'm not sure why though... */
+ if((partnote[lastpos].status != KEY_PLAYING)
+ && (partnote[lastpos].status != KEY_RELASED_AND_SUSTAINED))
+ ismonofirstnote = true; // No other keys are held or sustained.
+ }
+ else
+ // Poly mode is On so just make sure the list is empty.
+ if(not monomemnotes.empty())
+ monomemnotes.clear();
+
+ lastnote = note;
+
+ pos = -1;
+ for(i = 0; i < POLIPHONY; i++) {
+ if(partnote[i].status == KEY_OFF) {
+ pos = i;
+ break;
}
- } else {
- // Poly mode is On so just make sure the list is empty.
- if (not monomemnotes.empty()) monomemnotes.clear();
}
- lastnote=note;
-
- pos=-1;
- for (i=0;i POLIPHONY) - (Part.C::NoteOn(..))\n");
- } else {
-
+ fprintf(stderr,
+ "%s",
+ "NOTES TOO MANY (> POLIPHONY) - (Part.C::NoteOn(..))\n");
+ else {
//start the note
- partnote[pos].status=KEY_PLAYING;
- partnote[pos].note=note;
- if (legatomodevalid) {
- partnote[posb].status=KEY_PLAYING;
- partnote[posb].note=note;
+ partnote[pos].status = KEY_PLAYING;
+ partnote[pos].note = note;
+ if(legatomodevalid) {
+ partnote[posb].status = KEY_PLAYING;
+ partnote[posb].note = note;
}
//this computes the velocity sensing of the part
- REALTYPE vel=VelF(velocity/127.0,Pvelsns);
+ REALTYPE vel = VelF(velocity / 127.0, Pvelsns);
//compute the velocity offset
- vel+=(Pveloffs-64.0)/64.0;
- if (vel<0.0) vel=0.0;
- else if (vel>1.0) vel=1.0;
+ vel += (Pveloffs - 64.0) / 64.0;
+ if(vel < 0.0)
+ vel = 0.0;
+ else
+ if(vel > 1.0)
+ vel = 1.0;
//compute the keyshift
- int partkeyshift=(int)Pkeyshift-64;
- int keyshift=masterkeyshift+partkeyshift;
+ int partkeyshift = (int)Pkeyshift - 64;
+ int keyshift = masterkeyshift + partkeyshift;
//initialise note frequency
REALTYPE notebasefreq;
- if (Pdrummode==0) {
- notebasefreq=microtonal->getnotefreq(note,keyshift);
- if (notebasefreq<0.0) return;//the key is no mapped
- } else {
- notebasefreq=440.0*pow(2.0,(note-69.0)/12.0);
- };
+ if(Pdrummode == 0) {
+ notebasefreq = microtonal->getnotefreq(note, keyshift);
+ if(notebasefreq < 0.0)
+ return; //the key is no mapped
+ }
+ else
+ notebasefreq = 440.0 * pow(2.0, (note - 69.0) / 12.0);
+ ;
//Portamento
- if (oldfreq<1.0) oldfreq=notebasefreq;//this is only the first note is played
+ if(oldfreq < 1.0)
+ oldfreq = notebasefreq; //this is only the first note is played
// For Mono/Legato: Force Portamento Off on first
// notes. That means it is required that the previous note is
// still held down or sustained for the Portamento to activate
// (that's like Legato).
- int portamento=0;
- if ((Ppolymode!=0) || (not ismonofirstnote)) {
+ int portamento = 0;
+ if((Ppolymode != 0) || (not ismonofirstnote))
// I added a third argument to the
// ctl.initportamento(...) function to be able
// to tell it if we're doing a legato note.
- portamento=ctl.initportamento(oldfreq,notebasefreq,doinglegato);
- }
+ portamento = ctl.initportamento(oldfreq, notebasefreq, doinglegato);
- if (portamento!=0) ctl.portamento.noteusing=pos;
- oldfreq=notebasefreq;
+ if(portamento != 0)
+ ctl.portamento.noteusing = pos;
+ oldfreq = notebasefreq;
- lastpos=pos; // Keep a trace of used pos.
+ lastpos = pos; // Keep a trace of used pos.
- if (doinglegato) {
+ if(doinglegato) {
// Do Legato note
- if (Pkitmode==0) { // "normal mode" legato note
- if ((kit[0].Padenabled!=0)
- && (partnote[pos].kititem[0].adnote!=NULL)
- && (partnote[posb].kititem[0].adnote!=NULL)) {
- partnote[pos].kititem[0].adnote->ADlegatonote(notebasefreq, vel, portamento, note, true);//'true' is to tell it it's being called from here.
- partnote[posb].kititem[0].adnote->ADlegatonote(notebasefreq, vel, portamento, note, true);
+ if(Pkitmode == 0) { // "normal mode" legato note
+ if((kit[0].Padenabled != 0)
+ && (partnote[pos].kititem[0].adnote != NULL)
+ && (partnote[posb].kititem[0].adnote != NULL)) {
+ partnote[pos].kititem[0].adnote->ADlegatonote(notebasefreq,
+ vel,
+ portamento,
+ note,
+ true); //'true' is to tell it it's being called from here.
+ partnote[posb].kititem[0].adnote->ADlegatonote(notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
}
- if ((kit[0].Psubenabled!=0)
- && (partnote[pos].kititem[0].subnote!=NULL)
- && (partnote[posb].kititem[0].subnote!=NULL)) {
- partnote[pos].kititem[0].subnote->SUBlegatonote(notebasefreq, vel, portamento, note, true);
- partnote[posb].kititem[0].subnote->SUBlegatonote(notebasefreq, vel, portamento, note, true);
+ if((kit[0].Psubenabled != 0)
+ && (partnote[pos].kititem[0].subnote != NULL)
+ && (partnote[posb].kititem[0].subnote != NULL)) {
+ partnote[pos].kititem[0].subnote->SUBlegatonote(
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
+ partnote[posb].kititem[0].subnote->SUBlegatonote(
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
}
- if ((kit[0].Ppadenabled!=0)
- && (partnote[pos].kititem[0].padnote!=NULL)
- && (partnote[posb].kititem[0].padnote!=NULL)) {
- partnote[pos].kititem[0].padnote->PADlegatonote(notebasefreq, vel, portamento, note, true);
- partnote[posb].kititem[0].padnote->PADlegatonote(notebasefreq, vel, portamento, note, true);
+ if((kit[0].Ppadenabled != 0)
+ && (partnote[pos].kititem[0].padnote != NULL)
+ && (partnote[posb].kititem[0].padnote != NULL)) {
+ partnote[pos].kititem[0].padnote->PADlegatonote(
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
+ partnote[posb].kititem[0].padnote->PADlegatonote(
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
}
+ }
+ else { // "kit mode" legato note
+ int ci = 0;
+ for(int item = 0; item < NUM_KIT_ITEMS; item++) {
+ if(kit[item].Pmuted != 0)
+ continue;
+ if((note < kit[item].Pminkey) || (note > kit[item].Pmaxkey))
+ continue;
- } else { // "kit mode" legato note
- int ci=0;
- for (int item=0;itemkit[item].Pmaxkey)) continue;
-
- if ((lastnotecopykit[item].Pmaxkey))
+ if((lastnotecopy < kit[item].Pminkey)
+ || (lastnotecopy > kit[item].Pmaxkey))
continue; // We will not perform legato across 2 key regions.
- partnote[pos].kititem[ci].sendtoparteffect=( kit[item].PsendtoparteffectADlegatonote(notebasefreq,vel,portamento,note,true);
- partnote[posb].kititem[ci].adnote->ADlegatonote(notebasefreq,vel,portamento,note,true);
+ if((kit[item].Padenabled != 0) && (kit[item].adpars != NULL)
+ && (partnote[pos].kititem[ci].adnote != NULL)
+ && (partnote[posb].kititem[ci].adnote != NULL)) {
+ partnote[pos].kititem[ci].adnote->ADlegatonote(
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
+ partnote[posb].kititem[ci].adnote->ADlegatonote(
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
}
- if ((kit[item].Psubenabled!=0) && (kit[item].subpars!=NULL)
- && (partnote[pos].kititem[ci].subnote!=NULL)
- && (partnote[posb].kititem[ci].subnote!=NULL)) {
- partnote[pos].kititem[ci].subnote->SUBlegatonote(notebasefreq,vel,portamento,note,true);
- partnote[posb].kititem[ci].subnote->SUBlegatonote(notebasefreq,vel,portamento,note,true);
+ if((kit[item].Psubenabled != 0)
+ && (kit[item].subpars != NULL)
+ && (partnote[pos].kititem[ci].subnote != NULL)
+ && (partnote[posb].kititem[ci].subnote != NULL)) {
+ partnote[pos].kititem[ci].subnote->SUBlegatonote(
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
+ partnote[posb].kititem[ci].subnote->SUBlegatonote(
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
}
- if ((kit[item].Ppadenabled!=0) && (kit[item].padpars!=NULL)
- && (partnote[pos].kititem[ci].padnote!=NULL)
- && (partnote[posb].kititem[ci].padnote!=NULL)) {
- partnote[pos].kititem[ci].padnote->PADlegatonote(notebasefreq,vel,portamento,note,true);
- partnote[posb].kititem[ci].padnote->PADlegatonote(notebasefreq,vel,portamento,note,true);
+ if((kit[item].Ppadenabled != 0)
+ && (kit[item].padpars != NULL)
+ && (partnote[pos].kititem[ci].padnote != NULL)
+ && (partnote[posb].kititem[ci].padnote != NULL)) {
+ partnote[pos].kititem[ci].padnote->PADlegatonote(
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
+ partnote[posb].kititem[ci].padnote->PADlegatonote(
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
}
- if ((kit[item].adpars!=NULL)||(kit[item].subpars!=NULL)||(kit[item].padpars!=NULL)) {
+ if((kit[item].adpars != NULL)
+ || (kit[item].subpars != NULL)
+ || (kit[item].padpars != NULL)) {
ci++;
- if ( ((kit[item].Padenabled!=0)||(kit[item].Psubenabled!=0)||(kit[item].Ppadenabled!=0)) && (Pkitmode==2) ) break;
+ if(((kit[item].Padenabled != 0)
+ || (kit[item].Psubenabled != 0)
+ || (kit[item].Ppadenabled != 0)) && (Pkitmode == 2))
+ break;
}
}
- if (ci==0) {
+ if(ci == 0) {
// No legato were performed at all, so pretend nothing happened:
monomemnotes.pop_back(); // Remove last note from the list.
- lastnote=lastnotecopy; // Set lastnote back to previous value.
+ lastnote = lastnotecopy; // Set lastnote back to previous value.
}
}
return; // Ok, Legato note done, return.
}
- partnote[pos].itemsplaying=0;
- if (legatomodevalid) partnote[posb].itemsplaying=0;
+ partnote[pos].itemsplaying = 0;
+ if(legatomodevalid)
+ partnote[posb].itemsplaying = 0;
- if (Pkitmode==0) {//init the notes for the "normal mode"
- partnote[pos].kititem[0].sendtoparteffect=0;
- if (kit[0].Padenabled!=0) partnote[pos].kititem[0].adnote=new ADnote(kit[0].adpars,&ctl,notebasefreq,vel,portamento,note,false);
- if (kit[0].Psubenabled!=0) partnote[pos].kititem[0].subnote=new SUBnote(kit[0].subpars,&ctl,notebasefreq,vel,portamento,note,false);
- if (kit[0].Ppadenabled!=0) partnote[pos].kititem[0].padnote=new PADnote(kit[0].padpars,&ctl,notebasefreq,vel,portamento,note,false);
- if ((kit[0].Padenabled!=0)||(kit[0].Psubenabled!=0)||(kit[0].Ppadenabled!=0)) partnote[pos].itemsplaying++;
+ if(Pkitmode == 0) { //init the notes for the "normal mode"
+ partnote[pos].kititem[0].sendtoparteffect = 0;
+ if(kit[0].Padenabled != 0)
+ partnote[pos].kititem[0].adnote = new ADnote(kit[0].adpars,
+ &ctl,
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ false);
+ if(kit[0].Psubenabled != 0)
+ partnote[pos].kititem[0].subnote = new SUBnote(kit[0].subpars,
+ &ctl,
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ false);
+ if(kit[0].Ppadenabled != 0)
+ partnote[pos].kititem[0].padnote = new PADnote(kit[0].padpars,
+ &ctl,
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ false);
+ if((kit[0].Padenabled != 0) || (kit[0].Psubenabled != 0)
+ || (kit[0].Ppadenabled != 0))
+ partnote[pos].itemsplaying++;
// Spawn another note (but silent) if legatomodevalid==true
- if (legatomodevalid) {
- partnote[posb].kititem[0].sendtoparteffect=0;
- if (kit[0].Padenabled!=0) partnote[posb].kititem[0].adnote=new ADnote(kit[0].adpars,&ctl,notebasefreq,vel,portamento,note,true);//true for silent.
- if (kit[0].Psubenabled!=0) partnote[posb].kititem[0].subnote=new SUBnote(kit[0].subpars,&ctl,notebasefreq,vel,portamento,note,true);
- if (kit[0].Ppadenabled!=0) partnote[posb].kititem[0].padnote=new PADnote(kit[0].padpars,&ctl,notebasefreq,vel,portamento,note,true);
- if ((kit[0].Padenabled!=0)||(kit[0].Psubenabled!=0)||(kit[0].Ppadenabled!=0)) partnote[posb].itemsplaying++;
+ if(legatomodevalid) {
+ partnote[posb].kititem[0].sendtoparteffect = 0;
+ if(kit[0].Padenabled != 0)
+ partnote[posb].kititem[0].adnote = new ADnote(kit[0].adpars,
+ &ctl,
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true); //true for silent.
+ if(kit[0].Psubenabled != 0)
+ partnote[posb].kititem[0].subnote = new SUBnote(
+ kit[0].subpars,
+ &ctl,
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
+ if(kit[0].Ppadenabled != 0)
+ partnote[posb].kititem[0].padnote = new PADnote(
+ kit[0].padpars,
+ &ctl,
+ notebasefreq,
+ vel,
+ portamento,
+ note,
+ true);
+ if((kit[0].Padenabled != 0) || (kit[0].Psubenabled != 0)
+ || (kit[0].Ppadenabled != 0))
+ partnote[posb].itemsplaying++;
}
+ }
+ else { //init the notes for the "kit mode"
+ for(int item = 0; item < NUM_KIT_ITEMS; item++) {
+ if(kit[item].Pmuted != 0)
+ continue;
+ if((note < kit[item].Pminkey) || (note > kit[item].Pmaxkey))
+ continue;
- } else {//init the notes for the "kit mode"
- for (int item=0;itemkit[item].Pmaxkey)) continue;
+ int ci = partnote[pos].itemsplaying; //ci=current item
- int ci=partnote[pos].itemsplaying;//ci=current item
+ partnote[pos].kititem[ci].sendtoparteffect =
+ (kit[item].Psendtoparteffect < NUM_PART_EFX ?
+ kit[item].
+ Psendtoparteffect : NUM_PART_EFX); //if this parameter is 127 for "unprocessed"
- partnote[pos].kititem[ci].sendtoparteffect=( kit[item].Psendtoparteffect=0;i--) { //first note in, is first out if there are same note multiple times
- if ((partnote[i].status==KEY_PLAYING)&&(partnote[i].note==note)) {
- if (ctl.sustain.sustain==0) { //the sustain pedal is not pushed
- if ((Ppolymode==0) && (not monomemnotes.empty())) {
+ for(i = POLIPHONY - 1; i >= 0; i--) //first note in, is first out if there are same note multiple times
+ if((partnote[i].status == KEY_PLAYING) && (partnote[i].note == note)) {
+ if(ctl.sustain.sustain == 0) { //the sustain pedal is not pushed
+ if((Ppolymode == 0) && (not monomemnotes.empty()))
MonoMemRenote(); // To play most recent still held note.
- } else {
+ else
RelaseNotePos(i);
/// break;
- }
- } else {//the sustain pedal is pushed
- partnote[i].status=KEY_RELASED_AND_SUSTAINED;
}
+ else //the sustain pedal is pushed
+ partnote[i].status = KEY_RELASED_AND_SUSTAINED;
}
- }
-};
+}
/*
* Controllers
*/
-void Part::SetController(unsigned int type,int par)
+void Part::SetController(unsigned int type, int par)
{
- switch (type) {
+ switch(type) {
case C_pitchwheel:
ctl.setpitchwheel(par);
break;
case C_expression:
ctl.setexpression(par);
- setPvolume(Pvolume);//update the volume
+ setPvolume(Pvolume); //update the volume
break;
case C_portamento:
ctl.setportamento(par);
break;
case C_panning:
ctl.setpanning(par);
- setPpanning(Ppanning);//update the panning
+ setPpanning(Ppanning); //update the panning
break;
case C_filtercutoff:
ctl.setfiltercutoff(par);
@@ -529,32 +722,38 @@ void Part::SetController(unsigned int type,int par)
break;
case C_volume:
ctl.setvolume(par);
- if (ctl.volume.receive!=0) volume=ctl.volume.volume;
- else setPvolume(Pvolume);
+ if(ctl.volume.receive != 0)
+ volume = ctl.volume.volume;
+ else
+ setPvolume(Pvolume);
break;
case C_sustain:
ctl.setsustain(par);
- if (ctl.sustain.sustain==0) RelaseSustainedKeys();
+ if(ctl.sustain.sustain == 0)
+ RelaseSustainedKeys();
break;
case C_allsoundsoff:
- AllNotesOff();//Panic
+ AllNotesOff(); //Panic
break;
case C_resetallcontrollers:
ctl.resetall();
RelaseSustainedKeys();
- if (ctl.volume.receive!=0) volume=ctl.volume.volume;
- else setPvolume(Pvolume);
- setPvolume(Pvolume);//update the volume
- setPpanning(Ppanning);//update the panning
+ if(ctl.volume.receive != 0)
+ volume = ctl.volume.volume;
+ else
+ setPvolume(Pvolume);
+ setPvolume(Pvolume); //update the volume
+ setPpanning(Ppanning); //update the panning
- for (int item=0;itemGlobalPar.Reson->
- sendcontroller(C_resonance_center,1.0);
+ sendcontroller(C_resonance_center, 1.0);
kit[item].adpars->GlobalPar.Reson->
- sendcontroller(C_resonance_bandwidth,1.0);
- };
+ sendcontroller(C_resonance_bandwidth, 1.0);
+ }
//more update to add here if I add controllers
break;
case C_allnotesoff:
@@ -562,19 +761,20 @@ void Part::SetController(unsigned int type,int par)
break;
case C_resonance_center:
ctl.setresonancecenter(par);
- for (int item=0;itemGlobalPar.Reson->
- sendcontroller(C_resonance_center,ctl.resonancecenter.relcenter);
- };
+ sendcontroller(C_resonance_center, ctl.resonancecenter.relcenter);
+ }
break;
case C_resonance_bandwidth:
ctl.setresonancebw(par);
kit[0].adpars->GlobalPar.Reson->
- sendcontroller(C_resonance_bandwidth,ctl.resonancebandwidth.relbw);
+ sendcontroller(C_resonance_bandwidth, ctl.resonancebandwidth.relbw);
break;
- };
-};
+ }
+}
/*
* Relase the sustained keys
*/
@@ -582,13 +782,14 @@ void Part::SetController(unsigned int type,int par)
void Part::RelaseSustainedKeys()
{
// Let's call MonoMemRenote() on some conditions:
- if ((Ppolymode==0) && (not monomemnotes.empty()))
- if (monomemnotes.back()!=lastnote) // Sustain controller manipulation would cause repeated same note respawn without this check.
+ if((Ppolymode == 0) && (not monomemnotes.empty()))
+ if(monomemnotes.back() != lastnote) // Sustain controller manipulation would cause repeated same note respawn without this check.
MonoMemRenote(); // To play most recent still held note.
- for (int i=0;irelasekey();
- if (partnote[pos].kititem[j].subnote!=NULL)
- if (partnote[pos].kititem[j].subnote!=NULL)
+ if(partnote[pos].kititem[j].subnote != NULL)
+ if(partnote[pos].kititem[j].subnote != NULL)
partnote[pos].kititem[j].subnote->relasekey();
- if (partnote[pos].kititem[j].padnote!=NULL)
- if (partnote[pos].kititem[j].padnote)
+ if(partnote[pos].kititem[j].padnote != NULL)
+ if(partnote[pos].kititem[j].padnote)
partnote[pos].kititem[j].padnote->relasekey();
- };
- partnote[pos].status=KEY_RELASED;
-};
+ }
+ partnote[pos].status = KEY_RELASED;
+}
/*
@@ -646,30 +844,30 @@ void Part::RelaseNotePos(int pos)
*/
void Part::KillNotePos(int pos)
{
- partnote[pos].status=KEY_OFF;
- partnote[pos].note=-1;
- partnote[pos].time=0;
- partnote[pos].itemsplaying=0;
+ partnote[pos].status = KEY_OFF;
+ partnote[pos].note = -1;
+ partnote[pos].time = 0;
+ partnote[pos].itemsplaying = 0;
- for (int j=0;jPkeylimit=Pkeylimit;
- int keylimit=Pkeylimit;
- if (keylimit==0) keylimit=POLIPHONY-5;
+ this->Pkeylimit = Pkeylimit;
+ int keylimit = Pkeylimit;
+ if(keylimit == 0)
+ keylimit = POLIPHONY - 5;
//release old keys if the number of notes>keylimit
- if (Ppolymode!=0) {
- int notecount=0;
- for (int i=0;ikeylimit) {//find out the oldest note
- for (int i=0;imaxtime)) {
- maxtime=partnote[i].time;
- oldestnotepos=i;
- };
- };
- };
- if (oldestnotepos!=-1) RelaseNotePos(oldestnotepos);
- };
-};
+ ;
+ int oldestnotepos = -1, maxtime = 0;
+ if(notecount > keylimit) { //find out the oldest note
+ for(int i = 0; i < POLIPHONY; i++) {
+ if(((partnote[i].status == KEY_PLAYING)
+ || (partnote[i].status == KEY_RELASED_AND_SUSTAINED))
+ && (partnote[i].time > maxtime)) {
+ maxtime = partnote[i].time;
+ oldestnotepos = i;
+ }
+ }
+ }
+ if(oldestnotepos != -1)
+ RelaseNotePos(oldestnotepos);
+ }
+}
/*
@@ -708,8 +910,8 @@ void Part::setkeylimit(unsigned char Pkeylimit)
*/
void Part::AllNotesOff()
{
- killallnotes=1;
-};
+ killallnotes = 1;
+}
/*
@@ -717,266 +919,287 @@ void Part::AllNotesOff()
*/
void Part::ComputePartSmps()
{
- int i,k;
- int noteplay;//0 if there is nothing activated
- for (int nefx=0;nefxready!=0) adnote->noteout(&tmpoutl[0],&tmpoutr[0]);
- else for (i=0;ifinished()!=0) {
+ if(adnote->ready != 0)
+ adnote->noteout(&tmpoutl[0], &tmpoutr[0]);
+ else
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ tmpoutl[i] = 0.0;
+ tmpoutr[i] = 0.0;
+ }
+ ;
+ if(adnote->finished() != 0) {
delete (adnote);
- partnote[k].kititem[item].adnote=NULL;
- };
- for (i=0;iready!=0) subnote->noteout(&tmpoutl[0],&tmpoutr[0]);
- else for (i=0;iready != 0)
+ subnote->noteout(&tmpoutl[0], &tmpoutr[0]);
+ else
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ tmpoutl[i] = 0.0;
+ tmpoutr[i] = 0.0;
+ }
+ ;
- for (i=0;ifinished()!=0) {
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) { //add the SUBnote to part(mix)
+ partfxinputl[sendcurrenttofx][i] += tmpoutl[i];
+ partfxinputr[sendcurrenttofx][i] += tmpoutr[i];
+ }
+ if(subnote->finished() != 0) {
delete (subnote);
- partnote[k].kititem[item].subnote=NULL;
- };
- };
+ partnote[k].kititem[item].subnote = NULL;
+ }
+ }
//get from the PADnote
- if (padnote!=NULL) {
+ if(padnote != NULL) {
noteplay++;
- if (padnote->ready!=0) padnote->noteout(&tmpoutl[0],&tmpoutr[0]);
- else for (i=0;ifinished()!=0) {
+ if(padnote->ready != 0)
+ padnote->noteout(&tmpoutl[0], &tmpoutr[0]);
+ else
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ tmpoutl[i] = 0.0;
+ tmpoutr[i] = 0.0;
+ }
+ ;
+ if(padnote->finished() != 0) {
delete (padnote);
- partnote[k].kititem[item].padnote=NULL;
- };
- for (i=0;iout(partfxinputl[nefx],partfxinputr[nefx]);
- if (Pefxroute[nefx]==2) {
- for (i=0;iefxoutl[i];
- partfxinputr[nefx+1][i]+=partefx[nefx]->efxoutr[i];
- };
- };
- };
- int routeto=((Pefxroute[nefx]==0) ? nefx+1 : NUM_PART_EFX);
- for (i=0;iout(partfxinputl[nefx], partfxinputr[nefx]);
+ if(Pefxroute[nefx] == 2) {
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ partfxinputl[nefx + 1][i] += partefx[nefx]->efxoutl[i];
+ partfxinputr[nefx + 1][i] += partefx[nefx]->efxoutr[i];
+ }
+ }
+ }
+ int routeto = ((Pefxroute[nefx] == 0) ? nefx + 1 : NUM_PART_EFX);
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ partfxinputl[routeto][i] += partfxinputl[nefx][i];
+ partfxinputr[routeto][i] += partfxinputr[nefx][i];
+ }
+ }
+ for(i = 0; i < SOUND_BUFFER_SIZE; i++) {
+ partoutl[i] = partfxinputl[NUM_PART_EFX][i];
+ partoutr[i] = partfxinputr[NUM_PART_EFX][i];
+ }
//Kill All Notes if killallnotes!=0
- if (killallnotes!=0) {
- for (i=0;icleanup();
- };
- };
+ ;
+ }
ctl.updateportamento();
-};
+}
/*
* Parameter control
*/
void Part::setPvolume(char Pvolume_)
{
- Pvolume=Pvolume_;
- volume=dB2rap((Pvolume-96.0)/96.0*40.0)*ctl.expression.relvolume;
-};
+ Pvolume = Pvolume_;
+ volume = dB2rap((Pvolume - 96.0) / 96.0 * 40.0) * ctl.expression.relvolume;
+}
void Part::setPpanning(char Ppanning_)
{
- Ppanning=Ppanning_;
- panning=Ppanning/127.0+ctl.panning.pan;
- if (panning<0.0) panning=0.0;
- else if (panning>1.0) panning=1.0;
-
-};
+ Ppanning = Ppanning_;
+ panning = Ppanning / 127.0 + ctl.panning.pan;
+ if(panning < 0.0)
+ panning = 0.0;
+ else
+ if(panning > 1.0)
+ panning = 1.0;
+}
/*
* Enable or disable a kit item
*/
-void Part::setkititemstatus(int kititem,int Penabled_)
+void Part::setkititemstatus(int kititem, int Penabled_)
{
- if ((kititem==0)&&(kititem>=NUM_KIT_ITEMS)) return;//nonexistent kit item and the first kit item is always enabled
- kit[kititem].Penabled=Penabled_;
+ if((kititem == 0) && (kititem >= NUM_KIT_ITEMS))
+ return; //nonexistent kit item and the first kit item is always enabled
+ kit[kititem].Penabled = Penabled_;
- bool resetallnotes=false;
- if (Penabled_==0) {
- if (kit[kititem].adpars!=NULL) delete (kit[kititem].adpars);
- if (kit[kititem].subpars!=NULL) delete (kit[kititem].subpars);
- if (kit[kititem].padpars!=NULL) {
+ bool resetallnotes = false;
+ if(Penabled_ == 0) {
+ if(kit[kititem].adpars != NULL)
+ delete (kit[kititem].adpars);
+ if(kit[kititem].subpars != NULL)
+ delete (kit[kititem].subpars);
+ if(kit[kititem].padpars != NULL) {
delete (kit[kititem].padpars);
- resetallnotes=true;
- };
- kit[kititem].adpars=NULL;
- kit[kititem].subpars=NULL;
- kit[kititem].padpars=NULL;
- kit[kititem].Pname[0]='\0';
- } else {
- if (kit[kititem].adpars==NULL) kit[kititem].adpars=new ADnoteParameters(fft);
- if (kit[kititem].subpars==NULL) kit[kititem].subpars=new SUBnoteParameters();
- if (kit[kititem].padpars==NULL) kit[kititem].padpars=new PADnoteParameters(fft,mutex);
- };
+ resetallnotes = true;
+ }
+ kit[kititem].adpars = NULL;
+ kit[kititem].subpars = NULL;
+ kit[kititem].padpars = NULL;
+ kit[kititem].Pname[0] = '\0';
+ }
+ else {
+ if(kit[kititem].adpars == NULL)
+ kit[kititem].adpars = new ADnoteParameters(fft);
+ if(kit[kititem].subpars == NULL)
+ kit[kititem].subpars = new SUBnoteParameters();
+ if(kit[kititem].padpars == NULL)
+ kit[kititem].padpars = new PADnoteParameters(fft, mutex);
+ }
- if (resetallnotes) for (int k=0;kbeginbranch("INFO");
- xml->addparstr("name",(char *)Pname);
- xml->addparstr("author",(char *)info.Pauthor);
- xml->addparstr("comments",(char *)info.Pcomments);
- xml->addpar("type",info.Ptype);
+ xml->addparstr("name", (char *)Pname);
+ xml->addparstr("author", (char *)info.Pauthor);
+ xml->addparstr("comments", (char *)info.Pcomments);
+ xml->addpar("type", info.Ptype);
xml->endbranch();
xml->beginbranch("INSTRUMENT_KIT");
- xml->addpar("kit_mode",Pkitmode);
- xml->addparbool("drum_mode",Pdrummode);
+ xml->addpar("kit_mode", Pkitmode);
+ xml->addparbool("drum_mode", Pdrummode);
- for (int i=0;ibeginbranch("INSTRUMENT_KIT_ITEM",i);
- xml->addparbool("enabled",kit[i].Penabled);
- if (kit[i].Penabled!=0) {
- xml->addparstr("name",(char *)kit[i].Pname);
+ for(int i = 0; i < NUM_KIT_ITEMS; i++) {
+ xml->beginbranch("INSTRUMENT_KIT_ITEM", i);
+ xml->addparbool("enabled", kit[i].Penabled);
+ if(kit[i].Penabled != 0) {
+ xml->addparstr("name", (char *)kit[i].Pname);
- xml->addparbool("muted",kit[i].Pmuted);
- xml->addpar("min_key",kit[i].Pminkey);
- xml->addpar("max_key",kit[i].Pmaxkey);
+ xml->addparbool("muted", kit[i].Pmuted);
+ xml->addpar("min_key", kit[i].Pminkey);
+ xml->addpar("max_key", kit[i].Pmaxkey);
- xml->addpar("send_to_instrument_effect",kit[i].Psendtoparteffect);
+ xml->addpar("send_to_instrument_effect", kit[i].Psendtoparteffect);
- xml->addparbool("add_enabled",kit[i].Padenabled);
- if ((kit[i].Padenabled!=0)&&(kit[i].adpars!=NULL)) {
+ xml->addparbool("add_enabled", kit[i].Padenabled);
+ if((kit[i].Padenabled != 0) && (kit[i].adpars != NULL)) {
xml->beginbranch("ADD_SYNTH_PARAMETERS");
kit[i].adpars->add2XML(xml);
xml->endbranch();
- };
+ }
- xml->addparbool("sub_enabled",kit[i].Psubenabled);
- if ((kit[i].Psubenabled!=0)&&(kit[i].subpars!=NULL)) {
+ xml->addparbool("sub_enabled", kit[i].Psubenabled);
+ if((kit[i].Psubenabled != 0) && (kit[i].subpars != NULL)) {
xml->beginbranch("SUB_SYNTH_PARAMETERS");
kit[i].subpars->add2XML(xml);
xml->endbranch();
- };
+ }
- xml->addparbool("pad_enabled",kit[i].Ppadenabled);
- if ((kit[i].Ppadenabled!=0)&&(kit[i].padpars!=NULL)) {
+ xml->addparbool("pad_enabled", kit[i].Ppadenabled);
+ if((kit[i].Ppadenabled != 0) && (kit[i].padpars != NULL)) {
xml->beginbranch("PAD_SYNTH_PARAMETERS");
kit[i].padpars->add2XML(xml);
xml->endbranch();
- };
-
- };
+ }
+ }
xml->endbranch();
- };
+ }
xml->endbranch();
xml->beginbranch("INSTRUMENT_EFFECTS");
- for (int nefx=0;nefxbeginbranch("INSTRUMENT_EFFECT",nefx);
+ for(int nefx = 0; nefx < NUM_PART_EFX; nefx++) {
+ xml->beginbranch("INSTRUMENT_EFFECT", nefx);
xml->beginbranch("EFFECT");
partefx[nefx]->add2XML(xml);
xml->endbranch();
- xml->addpar("route",Pefxroute[nefx]);
- partefx[nefx]->setdryonly(Pefxroute[nefx]==2);
- xml->addparbool("bypass",Pefxbypass[nefx]);
+ xml->addpar("route", Pefxroute[nefx]);
+ partefx[nefx]->setdryonly(Pefxroute[nefx] == 2);
+ xml->addparbool("bypass", Pefxbypass[nefx]);
xml->endbranch();
- };
+ }
xml->endbranch();
-};
+}
void Part::add2XML(XMLwrapper *xml)
{
//parameters
- xml->addparbool("enabled",Penabled);
- if ((Penabled==0)&&(xml->minimal)) return;
+ xml->addparbool("enabled", Penabled);
+ if((Penabled == 0) && (xml->minimal))
+ return;
- xml->addpar("volume",Pvolume);
- xml->addpar("panning",Ppanning);
+ xml->addpar("volume", Pvolume);
+ xml->addpar("panning", Ppanning);
- xml->addpar("min_key",Pminkey);
- xml->addpar("max_key",Pmaxkey);
- xml->addpar("key_shift",Pkeyshift);
- xml->addpar("rcv_chn",Prcvchn);
+ xml->addpar("min_key", Pminkey);
+ xml->addpar("max_key", Pmaxkey);
+ xml->addpar("key_shift", Pkeyshift);
+ xml->addpar("rcv_chn", Prcvchn);
- xml->addpar("velocity_sensing",Pvelsns);
- xml->addpar("velocity_offset",Pveloffs);
+ xml->addpar("velocity_sensing", Pvelsns);
+ xml->addpar("velocity_offset", Pveloffs);
- xml->addparbool("note_on",Pnoteon);
- xml->addparbool("poly_mode",Ppolymode);
- xml->addpar("legato_mode",Plegatomode);
- xml->addpar("key_limit",Pkeylimit);
+ xml->addparbool("note_on", Pnoteon);
+ xml->addparbool("poly_mode", Ppolymode);
+ xml->addpar("legato_mode", Plegatomode);
+ xml->addpar("key_limit", Pkeylimit);
xml->beginbranch("INSTRUMENT");
add2XMLinstrument(xml);
@@ -985,154 +1208,163 @@ void Part::add2XML(XMLwrapper *xml)
xml->beginbranch("CONTROLLER");
ctl.add2XML(xml);
xml->endbranch();
-};
+}
int Part::saveXML(char *filename)
{
XMLwrapper *xml;
- xml=new XMLwrapper();
+ xml = new XMLwrapper();
xml->beginbranch("INSTRUMENT");
add2XMLinstrument(xml);
xml->endbranch();
- int result=xml->saveXMLfile(filename);
+ int result = xml->saveXMLfile(filename);
delete (xml);
- return(result);
-};
+ return result;
+}
int Part::loadXMLinstrument(const char *filename)
{
- XMLwrapper *xml=new XMLwrapper();
- if (xml->loadXMLfile(filename)<0) {
- delete(xml);
- return(-1);
- };
+ XMLwrapper *xml = new XMLwrapper();
+ if(xml->loadXMLfile(filename) < 0) {
+ delete (xml);
+ return -1;
+ }
- if (xml->enterbranch("INSTRUMENT")==0) return(-10);
+ if(xml->enterbranch("INSTRUMENT") == 0)
+ return -10;
getfromXMLinstrument(xml);
xml->exitbranch();
- delete(xml);
- return(0);
-};
+ delete (xml);
+ return 0;
+}
void Part::applyparameters()
{
- for (int n=0;napplyparameters(true);
- };
-};
+ for(int n = 0; n < NUM_KIT_ITEMS; n++)
+ if((kit[n].padpars != NULL) && (kit[n].Ppadenabled != 0))
+ kit[n].padpars->applyparameters(true);
+ ;
+}
void Part::getfromXMLinstrument(XMLwrapper *xml)
{
- if (xml->enterbranch("INFO")) {
- xml->getparstr("name",(char *)Pname,PART_MAX_NAME_LEN);
- xml->getparstr("author",(char *)info.Pauthor,MAX_INFO_TEXT_SIZE);
- xml->getparstr("comments",(char *)info.Pcomments,MAX_INFO_TEXT_SIZE);
- info.Ptype=xml->getpar("type",info.Ptype,0,16);
+ if(xml->enterbranch("INFO")) {
+ xml->getparstr("name", (char *)Pname, PART_MAX_NAME_LEN);
+ xml->getparstr("author", (char *)info.Pauthor, MAX_INFO_TEXT_SIZE);
+ xml->getparstr("comments", (char *)info.Pcomments, MAX_INFO_TEXT_SIZE);
+ info.Ptype = xml->getpar("type", info.Ptype, 0, 16);
xml->exitbranch();
- };
+ }
- if (xml->enterbranch("INSTRUMENT_KIT")) {
- Pkitmode=xml->getpar127("kit_mode",Pkitmode);
- Pdrummode=xml->getparbool("drum_mode",Pdrummode);
+ if(xml->enterbranch("INSTRUMENT_KIT")) {
+ Pkitmode = xml->getpar127("kit_mode", Pkitmode);
+ Pdrummode = xml->getparbool("drum_mode", Pdrummode);
- setkititemstatus(0,0);
- for (int i=0;ienterbranch("INSTRUMENT_KIT_ITEM",i)==0) continue;
- setkititemstatus(i,xml->getparbool("enabled",kit[i].Penabled));
- if (kit[i].Penabled==0) {
+ setkititemstatus(0, 0);
+ for(int i = 0; i < NUM_KIT_ITEMS; i++) {
+ if(xml->enterbranch("INSTRUMENT_KIT_ITEM", i) == 0)
+ continue;
+ setkititemstatus(i, xml->getparbool("enabled", kit[i].Penabled));
+ if(kit[i].Penabled == 0) {
xml->exitbranch();
continue;
- };
+ }
- xml->getparstr("name",(char *)kit[i].Pname,PART_MAX_NAME_LEN);
+ xml->getparstr("name", (char *)kit[i].Pname, PART_MAX_NAME_LEN);
- kit[i].Pmuted=xml->getparbool("muted",kit[i].Pmuted);
- kit[i].Pminkey=xml->getpar127("min_key",kit[i].Pminkey);
- kit[i].Pmaxkey=xml->getpar127("max_key",kit[i].Pmaxkey);
+ kit[i].Pmuted = xml->getparbool("muted", kit[i].Pmuted);
+ kit[i].Pminkey = xml->getpar127("min_key", kit[i].Pminkey);
+ kit[i].Pmaxkey = xml->getpar127("max_key", kit[i].Pmaxkey);
- kit[i].Psendtoparteffect=xml->getpar127("send_to_instrument_effect",kit[i].Psendtoparteffect);
+ kit[i].Psendtoparteffect = xml->getpar127(
+ "send_to_instrument_effect",
+ kit[i].Psendtoparteffect);
- kit[i].Padenabled=xml->getparbool("add_enabled",kit[i].Padenabled);
- if (xml->enterbranch("ADD_SYNTH_PARAMETERS")) {
+ kit[i].Padenabled = xml->getparbool("add_enabled",
+ kit[i].Padenabled);
+ if(xml->enterbranch("ADD_SYNTH_PARAMETERS")) {
kit[i].adpars->getfromXML(xml);
xml->exitbranch();
- };
+ }
- kit[i].Psubenabled=xml->getparbool("sub_enabled",kit[i].Psubenabled);
- if (xml->enterbranch("SUB_SYNTH_PARAMETERS")) {
+ kit[i].Psubenabled = xml->getparbool("sub_enabled",
+ kit[i].Psubenabled);
+ if(xml->enterbranch("SUB_SYNTH_PARAMETERS")) {
kit[i].subpars->getfromXML(xml);
xml->exitbranch();
- };
+ }
- kit[i].Ppadenabled=xml->getparbool("pad_enabled",kit[i].Ppadenabled);
- if (xml->enterbranch("PAD_SYNTH_PARAMETERS")) {
+ kit[i].Ppadenabled = xml->getparbool("pad_enabled",
+ kit[i].Ppadenabled);
+ if(xml->enterbranch("PAD_SYNTH_PARAMETERS")) {
kit[i].padpars->getfromXML(xml);
xml->exitbranch();
- };
+ }
xml->exitbranch();
- };
+ }
xml->exitbranch();
- };
+ }
- if (xml->enterbranch("INSTRUMENT_EFFECTS")) {
- for (int nefx=0;nefxenterbranch("INSTRUMENT_EFFECT",nefx)==0) continue;
- if (xml->enterbranch("EFFECT")) {
+ if(xml->enterbranch("INSTRUMENT_EFFECTS")) {
+ for(int nefx = 0; nefx < NUM_PART_EFX; nefx++) {
+ if(xml->enterbranch("INSTRUMENT_EFFECT", nefx) == 0)
+ continue;
+ if(xml->enterbranch("EFFECT")) {
partefx[nefx]->getfromXML(xml);
xml->exitbranch();
- };
+ }
- Pefxroute[nefx]=xml->getpar("route",Pefxroute[nefx],0,NUM_PART_EFX);
- partefx[nefx]->setdryonly(Pefxroute[nefx]==2);
- Pefxbypass[nefx]=xml->getparbool("bypass",Pefxbypass[nefx]);
+ Pefxroute[nefx] = xml->getpar("route",
+ Pefxroute[nefx],
+ 0,
+ NUM_PART_EFX);
+ partefx[nefx]->setdryonly(Pefxroute[nefx] == 2);
+ Pefxbypass[nefx] = xml->getparbool("bypass", Pefxbypass[nefx]);
xml->exitbranch();
- };
+ }
xml->exitbranch();
- };
-
-};
+ }
+}
void Part::getfromXML(XMLwrapper *xml)
{
- Penabled=xml->getparbool("enabled",Penabled);
+ Penabled = xml->getparbool("enabled", Penabled);
- setPvolume(xml->getpar127("volume",Pvolume));
- setPpanning(xml->getpar127("panning",Ppanning));
+ setPvolume(xml->getpar127("volume", Pvolume));
+ setPpanning(xml->getpar127("panning", Ppanning));
- Pminkey=xml->getpar127("min_key",Pminkey);
- Pmaxkey=xml->getpar127("max_key",Pmaxkey);
- Pkeyshift=xml->getpar127("key_shift",Pkeyshift);
- Prcvchn=xml->getpar127("rcv_chn",Prcvchn);
+ Pminkey = xml->getpar127("min_key", Pminkey);
+ Pmaxkey = xml->getpar127("max_key", Pmaxkey);
+ Pkeyshift = xml->getpar127("key_shift", Pkeyshift);
+ Prcvchn = xml->getpar127("rcv_chn", Prcvchn);
- Pvelsns=xml->getpar127("velocity_sensing",Pvelsns);
- Pveloffs=xml->getpar127("velocity_offset",Pveloffs);
+ Pvelsns = xml->getpar127("velocity_sensing", Pvelsns);
+ Pveloffs = xml->getpar127("velocity_offset", Pveloffs);
- Pnoteon=xml->getparbool("note_on",Pnoteon);
- Ppolymode=xml->getparbool("poly_mode",Ppolymode);
- Plegatomode=xml->getparbool("legato_mode",Plegatomode);//older versions
- if (!Plegatomode) Plegatomode=xml->getpar127("legato_mode",Plegatomode);
- Pkeylimit=xml->getpar127("key_limit",Pkeylimit);
+ Pnoteon = xml->getparbool("note_on", Pnoteon);
+ Ppolymode = xml->getparbool("poly_mode", Ppolymode);
+ Plegatomode = xml->getparbool("legato_mode", Plegatomode); //older versions
+ if(!Plegatomode)
+ Plegatomode = xml->getpar127("legato_mode", Plegatomode);
+ Pkeylimit = xml->getpar127("key_limit", Pkeylimit);
- if (xml->enterbranch("INSTRUMENT")) {
+ if(xml->enterbranch("INSTRUMENT")) {
getfromXMLinstrument(xml);
xml->exitbranch();
- };
+ }
- if (xml->enterbranch("CONTROLLER")) {
+ if(xml->enterbranch("CONTROLLER")) {
ctl.getfromXML(xml);
xml->exitbranch();
- };
-
-};
-
-
+ }
+}
diff --git a/plugins/zynaddsubfx/src/Misc/Part.h b/plugins/zynaddsubfx/src/Misc/Part.h
index 1ac12a50b..66169e3e3 100644
--- a/plugins/zynaddsubfx/src/Misc/Part.h
+++ b/plugins/zynaddsubfx/src/Misc/Part.h
@@ -43,159 +43,163 @@
/** Part implementation*/
class Part
{
+ public:
+ /**Constructor
+ * @param microtonal_ Pointer to the microtonal object
+ * @param fft_ Pointer to the FFTwrapper
+ * @param mutex_ Pointer to the master pthread_mutex_t*/
+ Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_);
+ /**Destructor*/
+ ~Part();
-public:
- /**Constructor
- * @param microtonal_ Pointer to the microtonal object
- * @param fft_ Pointer to the FFTwrapper
- * @param mutex_ Pointer to the master pthread_mutex_t*/
- Part(Microtonal *microtonal_,FFTwrapper *fft_,pthread_mutex_t *mutex_);
- /**Destructor*/
- ~Part();
+ // Midi commands implemented
+ void NoteOn(unsigned char note,
+ unsigned char velocity,
+ int masterkeyshift);
+ void NoteOff(unsigned char note);
+ void AllNotesOff(); //panic
+ void SetController(unsigned int type, int par);
+ void RelaseSustainedKeys(); //this is called when the sustain pedal is relased
+ void RelaseAllKeys(); //this is called on AllNotesOff controller
- // Midi commands implemented
- void NoteOn(unsigned char note,unsigned char velocity,int masterkeyshift);
- void NoteOff(unsigned char note);
- void AllNotesOff();//panic
- void SetController(unsigned int type,int par);
- void RelaseSustainedKeys();//this is called when the sustain pedal is relased
- void RelaseAllKeys();//this is called on AllNotesOff controller
+ /* The synthesizer part output */
+ void ComputePartSmps(); //Part output
- /* The synthesizer part output */
- void ComputePartSmps();//Part output
-
- //instrumentonly: 0 - save all, 1 - save only instrumnet, 2 - save only instrument without the name(used in bank)
+ //instrumentonly: 0 - save all, 1 - save only instrumnet, 2 - save only instrument without the name(used in bank)
- //saves the instrument settings to a XML file
- //returns 0 for ok or <0 if there is an error
- int saveXML(char *filename);
- int loadXMLinstrument(const char *filename);
+ //saves the instrument settings to a XML file
+ //returns 0 for ok or <0 if there is an error
+ int saveXML(char *filename);
+ int loadXMLinstrument(const char *filename);
- void add2XML(XMLwrapper *xml);
- void add2XMLinstrument(XMLwrapper *xml);
+ void add2XML(XMLwrapper *xml);
+ void add2XMLinstrument(XMLwrapper *xml);
- void defaults();
- void defaultsinstrument();
+ void defaults();
+ void defaultsinstrument();
- void applyparameters();
+ void applyparameters();
- void getfromXML(XMLwrapper *xml);
- void getfromXMLinstrument(XMLwrapper *xml);
+ void getfromXML(XMLwrapper *xml);
+ void getfromXMLinstrument(XMLwrapper *xml);
- void cleanup();
+ void cleanup();
// ADnoteParameters *ADPartParameters;
// SUBnoteParameters *SUBPartParameters;
- //the part's kit
- struct {
- unsigned char Penabled,Pmuted,Pminkey,Pmaxkey;
- unsigned char *Pname;
- unsigned char Padenabled,Psubenabled,Ppadenabled;
- unsigned char Psendtoparteffect;
- ADnoteParameters *adpars;
- SUBnoteParameters *subpars;
- PADnoteParameters *padpars;
- } kit[NUM_KIT_ITEMS];
-
-
- //Part parameters
- void setkeylimit(unsigned char Pkeylimit);
- void setkititemstatus(int kititem,int Penabled_);
-
- unsigned char Penabled;/** monomemnotes; // A list to remember held notes.
- struct {
- unsigned char velocity;
- int mkeyshift;// I'm not sure masterkeyshift should be remembered.
- } monomem[256]; /* 256 is to cover all possible note values.
- monomem[] is used in conjunction with the list to
- store the velocity and masterkeyshift values of a
- given note (the list only store note values).
- For example 'monomem[note].velocity' would be the
- velocity value of the note 'note'.
- */
+ //Part parameters
+ void setkeylimit(unsigned char Pkeylimit);
+ void setkititemstatus(int kititem, int Penabled_);
- PartNotes partnote[POLIPHONY];
+ unsigned char Penabled; /** monomemnotes; // A list to remember held notes.
+ struct {
+ unsigned char velocity;
+ int mkeyshift; // I'm not sure masterkeyshift should be remembered.
+ } monomem[256]; /* 256 is to cover all possible note values.
+ monomem[] is used in conjunction with the list to
+ store the velocity and masterkeyshift values of a
+ given note (the list only store note values).
+ For example 'monomem[note].velocity' would be the
+ velocity value of the note 'note'.
+ */
+
+ PartNotes partnote[POLIPHONY];
+
+ REALTYPE *tmpoutl; //used to get the note
+ REALTYPE *tmpoutr;
+
+ REALTYPE oldfreq; //this is used for portamento
+ Microtonal *microtonal;
+ FFTwrapper *fft;
};
#endif
diff --git a/plugins/zynaddsubfx/src/Misc/Stereo.cpp b/plugins/zynaddsubfx/src/Misc/Stereo.cpp
index fde296043..928be6e29 100644
--- a/plugins/zynaddsubfx/src/Misc/Stereo.cpp
+++ b/plugins/zynaddsubfx/src/Misc/Stereo.cpp
@@ -19,19 +19,20 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-template
+template
Stereo::Stereo(const T &left, const T &right)
- :leftChannel(left),rightChannel(right)
+ :leftChannel(left), rightChannel(right)
{}
-template
+template
Stereo::Stereo(const T &val)
- :leftChannel(val),rightChannel(val)
+ :leftChannel(val), rightChannel(val)
{}
-template
-void Stereo::operator=(const Stereo & nstr)
+template
+void Stereo::operator=(const Stereo &nstr)
{
- leftChannel=nstr.leftChannel;
- rightChannel=nstr.rightChannel;
+ leftChannel = nstr.leftChannel;
+ rightChannel = nstr.rightChannel;
}
+
diff --git a/plugins/zynaddsubfx/src/Misc/Stereo.h b/plugins/zynaddsubfx/src/Misc/Stereo.h
index b9c71b359..8bdf43017 100644
--- a/plugins/zynaddsubfx/src/Misc/Stereo.h
+++ b/plugins/zynaddsubfx/src/Misc/Stereo.h
@@ -21,46 +21,45 @@
#ifndef STEREO_H
#define STEREO_H
-template