From b6e62c66545d84101e3f82d065862f75509f2d1e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 28 Sep 2016 10:47:10 -0500 Subject: [PATCH] move mode/scale/key definitions out of push2 code and into libardour; Aeolian is the same as Minor --- libs/ardour/ardour/mode.h | 76 +++++++++++++++++++++++++ libs/ardour/enums.cc | 41 +++++++++++++ libs/{surfaces/push2 => ardour}/mode.cc | 31 ++++++---- libs/ardour/wscript | 1 + libs/surfaces/push2/gui.h | 3 +- libs/surfaces/push2/mode.h | 59 ------------------- libs/surfaces/push2/push2.cc | 40 ------------- libs/surfaces/push2/push2.h | 2 +- libs/surfaces/push2/scale.cc | 5 +- libs/surfaces/push2/wscript | 1 - 10 files changed, 144 insertions(+), 115 deletions(-) create mode 100644 libs/ardour/ardour/mode.h rename libs/{surfaces/push2 => ardour}/mode.cc (90%) delete mode 100644 libs/surfaces/push2/mode.h diff --git a/libs/ardour/ardour/mode.h b/libs/ardour/ardour/mode.h new file mode 100644 index 0000000000..7f1d5e0b86 --- /dev/null +++ b/libs/ardour/ardour/mode.h @@ -0,0 +1,76 @@ +/* + Copyright (C) 1999-2016 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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 for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __ardour_mode_h__ +#define __ardour_mode_h__ + +#include + +class MusicalMode +{ + public: + enum Type { + Dorian, + IonianMajor, + AeolianMinor, + HarmonicMinor, + MelodicMinorAscending, + MelodicMinorDescending, + Phrygian, + Lydian, + Mixolydian, + Locrian, + PentatonicMajor, + PentatonicMinor, + Chromatic, + BluesScale, + NeapolitanMinor, + NeapolitanMajor, + Oriental, + DoubleHarmonic, + Enigmatic, + Hirajoshi, + HungarianMinor, + HungarianMajor, + Kumoi, + Iwato, + Hindu, + Spanish8Tone, + Pelog, + HungarianGypsy, + Overtone, + LeadingWholeTone, + Arabian, + Balinese, + Gypsy, + Mohammedan, + Javanese, + Persian, + Algerian + }; + + MusicalMode (Type t); + ~MusicalMode (); + + std::vector steps; + + private: + static void fill (MusicalMode&, Type); +}; + +#endif /* __ardour_mode_h__ */ diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index be468c2534..ad5dc5e6a7 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -31,6 +31,7 @@ #include "ardour/io.h" #include "ardour/location.h" #include "ardour/midi_model.h" +#include "ardour/mode.h" #include "ardour/mute_master.h" #include "ardour/presentation_info.h" #include "ardour/session.h" @@ -134,6 +135,7 @@ setup_enum_writer () BufferingPreset _BufferingPreset; AutoReturnTarget _AutoReturnTarget; PresentationInfo::Flag _PresentationInfo_Flag; + MusicalMode::Type mode; #define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear() #define REGISTER_BITS(e) enum_writer.register_bits (typeid(e).name(), i, s); i.clear(); s.clear() @@ -715,6 +717,45 @@ setup_enum_writer () REGISTER_CLASS_ENUM (PresentationInfo, Hidden); REGISTER_CLASS_ENUM (PresentationInfo, OrderSet); REGISTER_BITS (_PresentationInfo_Flag); + + REGISTER_CLASS_ENUM (MusicalMode,Dorian); + REGISTER_CLASS_ENUM (MusicalMode, IonianMajor); + REGISTER_CLASS_ENUM (MusicalMode, AeolianMinor); + REGISTER_CLASS_ENUM (MusicalMode, HarmonicMinor); + REGISTER_CLASS_ENUM (MusicalMode, MelodicMinorAscending); + REGISTER_CLASS_ENUM (MusicalMode, MelodicMinorDescending); + REGISTER_CLASS_ENUM (MusicalMode, Phrygian); + REGISTER_CLASS_ENUM (MusicalMode, Lydian); + REGISTER_CLASS_ENUM (MusicalMode, Mixolydian); + REGISTER_CLASS_ENUM (MusicalMode, Locrian); + REGISTER_CLASS_ENUM (MusicalMode, PentatonicMajor); + REGISTER_CLASS_ENUM (MusicalMode, PentatonicMinor); + REGISTER_CLASS_ENUM (MusicalMode, Chromatic); + REGISTER_CLASS_ENUM (MusicalMode, BluesScale); + REGISTER_CLASS_ENUM (MusicalMode, NeapolitanMinor); + REGISTER_CLASS_ENUM (MusicalMode, NeapolitanMajor); + REGISTER_CLASS_ENUM (MusicalMode, Oriental); + REGISTER_CLASS_ENUM (MusicalMode, DoubleHarmonic); + REGISTER_CLASS_ENUM (MusicalMode, Enigmatic); + REGISTER_CLASS_ENUM (MusicalMode, Hirajoshi); + REGISTER_CLASS_ENUM (MusicalMode, HungarianMinor); + REGISTER_CLASS_ENUM (MusicalMode, HungarianMajor); + REGISTER_CLASS_ENUM (MusicalMode, Kumoi); + REGISTER_CLASS_ENUM (MusicalMode, Iwato); + REGISTER_CLASS_ENUM (MusicalMode, Hindu); + REGISTER_CLASS_ENUM (MusicalMode, Spanish8Tone); + REGISTER_CLASS_ENUM (MusicalMode, Pelog); + REGISTER_CLASS_ENUM (MusicalMode, HungarianGypsy); + REGISTER_CLASS_ENUM (MusicalMode, Overtone); + REGISTER_CLASS_ENUM (MusicalMode, LeadingWholeTone); + REGISTER_CLASS_ENUM (MusicalMode, Arabian); + REGISTER_CLASS_ENUM (MusicalMode, Balinese); + REGISTER_CLASS_ENUM (MusicalMode, Gypsy); + REGISTER_CLASS_ENUM (MusicalMode, Mohammedan); + REGISTER_CLASS_ENUM (MusicalMode, Javanese); + REGISTER_CLASS_ENUM (MusicalMode, Persian); + REGISTER_CLASS_ENUM (MusicalMode, Algerian); + REGISTER (mode); } } /* namespace ARDOUR */ diff --git a/libs/surfaces/push2/mode.cc b/libs/ardour/mode.cc similarity index 90% rename from libs/surfaces/push2/mode.cc rename to libs/ardour/mode.cc index 99efc86c02..e3c37df78c 100644 --- a/libs/surfaces/push2/mode.cc +++ b/libs/ardour/mode.cc @@ -1,4 +1,23 @@ -#include "mode.h" +/* + Copyright (C) 1999-2016 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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 for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "ardour/mode.h" MusicalMode::MusicalMode (MusicalMode::Type t) { @@ -36,7 +55,7 @@ MusicalMode::fill (MusicalMode& m, MusicalMode::Type t) m.steps.push_back (4.5); m.steps.push_back (5.5); break; - case Minor: + case AeolianMinor: m.steps.push_back (1.0); m.steps.push_back (1.5); m.steps.push_back (2.5); @@ -102,14 +121,6 @@ MusicalMode::fill (MusicalMode& m, MusicalMode::Type t) m.steps.push_back (4.5); m.steps.push_back (5.0); break; - case Aeolian: - m.steps.push_back (1.0); - m.steps.push_back (1.5); - m.steps.push_back (2.5); - m.steps.push_back (3.5); - m.steps.push_back (4.0); - m.steps.push_back (5.0); - break; case Locrian: m.steps.push_back (0.5); m.steps.push_back (1.5); diff --git a/libs/ardour/wscript b/libs/ardour/wscript index a3ec926485..3ca15569ba 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -143,6 +143,7 @@ libardour_sources = [ 'mididm.cc', 'midiport_manager.cc', 'mix.cc', + 'mode.cc', 'monitor_control.cc', 'monitor_processor.cc', 'mtc_slave.cc', diff --git a/libs/surfaces/push2/gui.h b/libs/surfaces/push2/gui.h index fe50174277..c217d37039 100644 --- a/libs/surfaces/push2/gui.h +++ b/libs/surfaces/push2/gui.h @@ -37,8 +37,9 @@ namespace Gtk { class ListStore; } +#include "ardour/mode.h" + #include "push2.h" -#include "mode.h" namespace ArdourSurface { diff --git a/libs/surfaces/push2/mode.h b/libs/surfaces/push2/mode.h deleted file mode 100644 index 4f570f998d..0000000000 --- a/libs/surfaces/push2/mode.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __ardour_push2_mode_h__ -#define __ardour_push2_mode_h__ - -#include - -class MusicalMode -{ - public: - enum Type { - Dorian, - IonianMajor, - Minor, - HarmonicMinor, - MelodicMinorAscending, - MelodicMinorDescending, - Phrygian, - Lydian, - Mixolydian, - Aeolian, - Locrian, - PentatonicMajor, - PentatonicMinor, - Chromatic, - BluesScale, - NeapolitanMinor, - NeapolitanMajor, - Oriental, - DoubleHarmonic, - Enigmatic, - Hirajoshi, - HungarianMinor, - HungarianMajor, - Kumoi, - Iwato, - Hindu, - Spanish8Tone, - Pelog, - HungarianGypsy, - Overtone, - LeadingWholeTone, - Arabian, - Balinese, - Gypsy, - Mohammedan, - Javanese, - Persian, - Algerian - }; - - MusicalMode (Type t); - ~MusicalMode (); - - std::vector steps; - - private: - static void fill (MusicalMode&, Type); -}; - -#endif /* __ardour_push2_mode_h__ */ diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 47bff25580..73c871548b 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -75,50 +75,10 @@ register_enums () vector i; vector s; - MusicalMode::Type mode; #define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear() #define REGISTER_CLASS_ENUM(t,e) i.push_back (t::e); s.push_back (#e) - REGISTER_CLASS_ENUM (MusicalMode,Dorian); - REGISTER_CLASS_ENUM (MusicalMode, IonianMajor); - REGISTER_CLASS_ENUM (MusicalMode, Minor); - REGISTER_CLASS_ENUM (MusicalMode, HarmonicMinor); - REGISTER_CLASS_ENUM (MusicalMode, MelodicMinorAscending); - REGISTER_CLASS_ENUM (MusicalMode, MelodicMinorDescending); - REGISTER_CLASS_ENUM (MusicalMode, Phrygian); - REGISTER_CLASS_ENUM (MusicalMode, Lydian); - REGISTER_CLASS_ENUM (MusicalMode, Mixolydian); - REGISTER_CLASS_ENUM (MusicalMode, Aeolian); - REGISTER_CLASS_ENUM (MusicalMode, Locrian); - REGISTER_CLASS_ENUM (MusicalMode, PentatonicMajor); - REGISTER_CLASS_ENUM (MusicalMode, PentatonicMinor); - REGISTER_CLASS_ENUM (MusicalMode, Chromatic); - REGISTER_CLASS_ENUM (MusicalMode, BluesScale); - REGISTER_CLASS_ENUM (MusicalMode, NeapolitanMinor); - REGISTER_CLASS_ENUM (MusicalMode, NeapolitanMajor); - REGISTER_CLASS_ENUM (MusicalMode, Oriental); - REGISTER_CLASS_ENUM (MusicalMode, DoubleHarmonic); - REGISTER_CLASS_ENUM (MusicalMode, Enigmatic); - REGISTER_CLASS_ENUM (MusicalMode, Hirajoshi); - REGISTER_CLASS_ENUM (MusicalMode, HungarianMinor); - REGISTER_CLASS_ENUM (MusicalMode, HungarianMajor); - REGISTER_CLASS_ENUM (MusicalMode, Kumoi); - REGISTER_CLASS_ENUM (MusicalMode, Iwato); - REGISTER_CLASS_ENUM (MusicalMode, Hindu); - REGISTER_CLASS_ENUM (MusicalMode, Spanish8Tone); - REGISTER_CLASS_ENUM (MusicalMode, Pelog); - REGISTER_CLASS_ENUM (MusicalMode, HungarianGypsy); - REGISTER_CLASS_ENUM (MusicalMode, Overtone); - REGISTER_CLASS_ENUM (MusicalMode, LeadingWholeTone); - REGISTER_CLASS_ENUM (MusicalMode, Arabian); - REGISTER_CLASS_ENUM (MusicalMode, Balinese); - REGISTER_CLASS_ENUM (MusicalMode, Gypsy); - REGISTER_CLASS_ENUM (MusicalMode, Mohammedan); - REGISTER_CLASS_ENUM (MusicalMode, Javanese); - REGISTER_CLASS_ENUM (MusicalMode, Persian); - REGISTER_CLASS_ENUM (MusicalMode, Algerian); - REGISTER (mode); } Push2::Push2 (ARDOUR::Session& s) diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index 30422775d4..2d4f17417e 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -32,6 +32,7 @@ #include "midi++/types.h" +#include "ardour/mode.h" #include "ardour/types.h" #include "control_protocol/control_protocol.h" @@ -40,7 +41,6 @@ #include "canvas/colors.h" #include "midi_byte_array.h" -#include "mode.h" namespace Pango { class Layout; diff --git a/libs/surfaces/push2/scale.cc b/libs/surfaces/push2/scale.cc index 005efca3c1..424a480ed2 100644 --- a/libs/surfaces/push2/scale.cc +++ b/libs/surfaces/push2/scale.cc @@ -379,19 +379,18 @@ ScaleLayout::build_scale_menu () v.push_back ("Dorian"); v.push_back ("Ionian (Major)"); - v.push_back ("Minor"); + v.push_back ("Aeolian (Minor)"); v.push_back ("Harmonic Minor"); v.push_back ("MelodicMinor Asc."); v.push_back ("MelodicMinor Desc."); v.push_back ("Phrygian"); v.push_back ("Lydian"); v.push_back ("Mixolydian"); - v.push_back ("Aeolian"); v.push_back ("Locrian"); v.push_back ("Pentatonic Major"); v.push_back ("Pentatonic Minor"); v.push_back ("Chromatic"); - v.push_back ("BluesScale"); + v.push_back ("Blues Scale"); v.push_back ("Neapolitan Minor"); v.push_back ("Neapolitan Major"); v.push_back ("Oriental"); diff --git a/libs/surfaces/push2/wscript b/libs/surfaces/push2/wscript index a29ccd4492..0934ff5891 100644 --- a/libs/surfaces/push2/wscript +++ b/libs/surfaces/push2/wscript @@ -30,7 +30,6 @@ def build(bld): gui.cc knob.cc layout.cc - mode.cc menu.cc mix.cc scale.cc -- 2.30.2