New upstream version 0.14.6~dfsg1
authorIOhannes m zmölnig <zmoelnig@umlautS.umlaeute.mur.at>
Thu, 22 Mar 2018 13:17:44 +0000 (14:17 +0100)
committerIOhannes m zmölnig <zmoelnig@umlautS.umlaeute.mur.at>
Thu, 22 Mar 2018 13:17:44 +0000 (14:17 +0100)
68 files changed:
.travis/script.sh
ChangeLog
Makefile.am
configure.ac
src/core/channel.cpp
src/core/channel.h
src/core/conf.cpp
src/core/const.h
src/core/init.cpp
src/core/kernelAudio.cpp
src/core/midiDispatcher.cpp
src/core/patch.cpp
src/core/patch.h
src/core/sampleChannel.cpp
src/core/sampleChannel.h
src/core/wave.h
src/glue/channel.cpp
src/glue/channel.h
src/glue/io.cpp
src/glue/io.h
src/glue/sampleEditor.cpp
src/glue/storage.cpp
src/gui/dialogs/browser/browserBase.cpp
src/gui/dialogs/channelNameInput.cpp
src/gui/dialogs/gd_mainWindow.cpp
src/gui/dialogs/gd_mainWindow.h
src/gui/dialogs/midiIO/midiInputChannel.cpp
src/gui/dialogs/midiIO/midiInputChannel.h
src/gui/dialogs/midiIO/midiOutputSampleCh.cpp
src/gui/dialogs/midiIO/midiOutputSampleCh.h
src/gui/dialogs/sampleEditor.cpp
src/gui/elems/browser.cpp
src/gui/elems/browser.h
src/gui/elems/config/tabAudio.cpp
src/gui/elems/config/tabBehaviors.cpp
src/gui/elems/config/tabMidi.cpp
src/gui/elems/config/tabMisc.cpp
src/gui/elems/config/tabPlugins.cpp
src/gui/elems/mainWindow/keyboard/channel.cpp
src/gui/elems/mainWindow/keyboard/column.cpp
src/gui/elems/mainWindow/keyboard/keyboard.cpp
src/gui/elems/mainWindow/keyboard/midiChannel.cpp
src/gui/elems/mainWindow/keyboard/sampleChannel.cpp
src/gui/elems/mainWindow/keyboard/sampleChannel.h
src/gui/elems/mainWindow/keyboard/sampleChannelButton.cpp
src/gui/elems/mainWindow/mainTransport.cpp
src/gui/elems/sampleEditor/boostTool.cpp
src/gui/elems/sampleEditor/boostTool.h
src/gui/elems/sampleEditor/panTool.cpp
src/gui/elems/sampleEditor/pitchTool.cpp
src/gui/elems/sampleEditor/volumeTool.cpp
src/main.cpp
src/utils/fs.cpp
src/utils/fs.h
src/utils/math.cpp
src/utils/math.h
src/utils/string.cpp
src/utils/time.cpp
tests/conf.cpp
tests/main.cpp
tests/midiMapConf.cpp
tests/patch.cpp
tests/pluginHost.cpp
tests/recorder.cpp
tests/utils.cpp
tests/wave.cpp
tests/waveFx.cpp
tests/waveManager.cpp

index 49f67c4552b27304ba5428e628e35bfdfe0546fb..af3c70e05e24bd5f76b97a42d85aea324f92f9c6 100755 (executable)
@@ -2,4 +2,13 @@
 
 make -j 2
 make rename
-make check -j 2
\ No newline at end of file
+
+if [[ $TRAVIS_OS_NAME == 'linux' ]]; then
+       
+       xvfb-run make check -j 2
+
+else
+
+       make check -j 2
+
+fi
\ No newline at end of file
index dbca39f6812cfaa370ffcc6eb4b8f12647367ee8..76388e384b9737a201059f440ebf0fc270f70d40 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 --------------------------------------------------------------------------------
 
 
+0.14.6 --- 2018 . 03 . 15
+- MIDI velocity drives volume for one-shot sample channels
+- FLAC and Ogg support
+- Ability to use system-provided Catch library (GitHub #151)
+- Update Catch to version 2
+- Fix unreadable tabs title in Configuration Window (GitHub #168)
+- Fix crash on opening About window
+- Fix 'read actions' button behavior during ending and waiting statuses
+- Fix sound card initialization on MacOS
+- [Windows] Fix UI stuck on top-right corner
+- [Windows] Fix browsing for directories
+
+
 0.14.5 --- 2018 . 01 . 15
 - OS X builds on Travis CI
 - AppImage executable for Linux
index 3c2f529662e1090555c209947e21348434538c57..9d0cfec070a11aae4504b0fdc4b27bfc66a6f8fa 100644 (file)
@@ -23,19 +23,25 @@ extraSources += \
        src/deps/juce/modules/juce_gui_extra/juce_gui_extra.cpp
 
 cppFlags += \
-  -I./src/deps/juce/modules                \
-  -I./src/deps/vst                         \
-  -I/usr/include                           \
-  -I/usr/include/freetype2                 \
-  -DJUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1 \
-  -DJUCE_STANDALONE_APPLICATION=1          \
-  -DJUCE_PLUGINHOST_VST=1                  \
-  -DJUCE_PLUGINHOST_VST3=0                 \
-  -DJUCE_PLUGINHOST_AU=0                   \
+  -I$(top_srcdir)/src/deps/juce/modules      \
+  -I$(top_srcdir)/src/deps/vst               \
+  -I/usr/include                             \
+  -I/usr/include/freetype2                   \
+  -DJUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1   \
+  -DJUCE_STANDALONE_APPLICATION=1            \
+  -DJUCE_PLUGINHOST_VST=1                    \
+  -DJUCE_PLUGINHOST_VST3=0                   \
+  -DJUCE_PLUGINHOST_AU=0                     \
   -DJUCE_WEB_BROWSER=0 
 
 endif
 
+if !WITH_SYSTEM_CATCH
+
+cppFlags += -I$(top_srcdir)/tests/catch2/single_include
+
+endif
+
 if WINDOWS
 
 extraSources += \
@@ -50,9 +56,9 @@ extraSources += \
        resource.rc
 
 cppFlags += \
-       -I./src/deps/rtaudio-mod/include \
-       -D__WINDOWS_ASIO__               \
-       -D__WINDOWS_WASAPI__             \
+       -I$(top_srcdir)/src/deps/rtaudio-mod/include \
+       -D__WINDOWS_ASIO__                           \
+       -D__WINDOWS_WASAPI__                         \
        -D__WINDOWS_DS__
 
 cxxFlags += -Wno-error
@@ -60,7 +66,7 @@ cxxFlags += -Wno-error
 ldAdd += -ldsound -lwsock32 -lm -lfltk -lwininet -lgdi32 -lshell32 -lvfw32 \
   -lrpcrt4 -luuid -lcomctl32 -lole32 -lws2_32 -lsndfile -lsamplerate -lrtmidi \
   -lwinmm -lsetupapi -lksuser -ljansson -limm32 -lglu32 -lshell32 -lversion \
-  -lopengl32 -loleaut32 -lshlwapi -lcomdlg32
+  -lopengl32 -loleaut32 -lshlwapi -lcomdlg32 -lflac -lvorbis -logg -lvorbisenc
 
 # Generate a GUI application (-mwindows), make the build static (-static).
 ldFlags += -mwindows -static
@@ -85,6 +91,9 @@ if OSX
 
 extraSources += src/utils/cocoa.mm src/utils/cocoa.h
 
+# Add preprocessor flags to enable CoreAudio in RtAudio.
+cppFlags += -D__MACOSX_CORE__
+
 # -ObjC++: Juce requires to build some Objective C code
 cxxFlags += -ObjC++ -Wno-auto-var-id
 
index bc80952a66bcf05aeb3cf1c7b2cec84d551f8d19..9f6e959995e5b0abb53626b12b3aa1b5ec4bf38c 100644 (file)
@@ -55,6 +55,17 @@ AC_ARG_ENABLE(
        [AM_CONDITIONAL(WITH_VST, false)]
 )
 
+# ------------------------------------------------------------------------------
+
+# --enable-system-catch. If enabled, use the system-provided Catch. Use bundled
+# version otherwise (default mode).
+
+AC_ARG_ENABLE(
+       [system-catch],
+       AS_HELP_STRING([--enable-system-catch], [use system-provided Catch library]),
+  [AC_DEFINE(WITH_SYSTEM_CATCH) AM_CONDITIONAL(WITH_SYSTEM_CATCH, true)],
+       [AM_CONDITIONAL(WITH_SYSTEM_CATCH, false)]
+)
 
 # ------------------------------------------------------------------------------
 
index b11f82cbcafe76f90a9b4b71e36fcf87dab0bab4..a1dda462b24bd2592c43ee79f6ca6168257a08af 100644 (file)
@@ -54,13 +54,13 @@ Channel::Channel(int type, int status, int bufferSize)
        midiInFilter   (-1),
        previewMode    (G_PREVIEW_NONE),
        pan            (0.5f),
+       volume         (G_DEFAULT_VOL),
+       volume_i       (1.0f),
+       volume_d       (0.0f),
        armed          (false),
        type           (type),
        status         (status),
        key            (0),
-       volume         (G_DEFAULT_VOL),
-       volume_i       (1.0f),
-       volume_d       (0.0f),
        mute_i         (false),
        mute_s         (false),
        mute           (false),
@@ -437,6 +437,27 @@ float Channel::getPan() const
 /* -------------------------------------------------------------------------- */
 
 
+void Channel::setVolume(float v)
+{
+       volume = v;
+}
+
+
+void Channel::setVolumeI(float v)
+{
+       volume_i = v;
+}
+
+
+float Channel::getVolume() const
+{
+       return volume;
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
 float Channel::calcPanning(int ch)
 {
        if (pan == 0.5f) // center: nothing to do
index a43b15782d7654cb5abdb68e56ce2b1c8def96d9..d8394fbf34b9e1085380dbe9d0273882ab5d9204 100644 (file)
@@ -88,6 +88,9 @@ protected:
        int previewMode;
 
        float pan;
+       float volume;   // global volume
+       float volume_i; // internal volume
+       float volume_d; // delta volume (for envelope)
        bool armed;
        std::string name;
 
@@ -189,7 +192,8 @@ public:
        virtual void rewind() = 0;
 
        /* clear
-       Clears all memory buffers. This is actually useful to sample channels only. */
+       Clears all memory buffers. This is actually useful to sample channels only. 
+       TODO - please rename it to clearBuffers. */
 
        virtual void clear() = 0;
 
@@ -219,6 +223,7 @@ public:
 
        bool isPlaying() const;
        float getPan() const;
+       float getVolume() const;
        bool isArmed() const;
        std::string getName() const;
        bool isPreview() const;
@@ -238,6 +243,8 @@ public:
        void sendMidiLplay();
 
        void setPan(float v);
+       void setVolume(float v);
+       void setVolumeI(float v);
        void setArmed(bool b);
        void setName(const std::string& s);
        void setPreviewMode(int m);
@@ -259,9 +266,6 @@ public:
        int    type;                  // midi or sample
        int    status;                // status: see const.h
        int    key;                   // keyboard button
-       float  volume;                // global volume
-       float  volume_i;              // internal volume
-       float  volume_d;              // delta volume (for envelope)
        bool   mute_i;                // internal mute
        bool     mute_s;                // previous mute status after being solo'd
        bool   mute;                  // global mute
index 0914d96c7eaf8151ba784fb6201a0347f0a45944..b24b06dfffd91f7a8503a3cdbc6b3afbc3ed4f88 100644 (file)
@@ -26,6 +26,7 @@
 
 
 #include <string>
+#include <FL/Fl.H>
 #include "../utils/fs.h"
 #include "../utils/log.h"
 #include "storager.h"
@@ -189,10 +190,10 @@ string pluginPath = "";
 string patchPath  = "";
 string samplePath = "";
 
-int mainWindowX = 0;
-int mainWindowY = 0;
-int mainWindowW = G_GUI_WIDTH;
-int mainWindowH = G_GUI_HEIGHT;
+int mainWindowX = (Fl::w() / 2) - (G_MIN_GUI_WIDTH / 2);
+int mainWindowY = (Fl::h() / 2) - (G_MIN_GUI_HEIGHT / 2);
+int mainWindowW = G_MIN_GUI_WIDTH;
+int mainWindowH = G_MIN_GUI_HEIGHT;
 
 int browserX         = 0;
 int browserY         = 0;
index 78b8b9e33ed04dd5d01c0861d074855bfc77b2b1..a587117618b5bf10ff165da1126e61974e4ff220 100644 (file)
 
 /* -- version --------------------------------------------------------------- */
 #define G_APP_NAME      "Giada"
-#define G_VERSION_STR   "0.14.5"
+#define G_VERSION_STR   "0.14.6"
 #define G_VERSION_MAJOR 0
 #define G_VERSION_MINOR 14
-#define G_VERSION_PATCH 5
+#define G_VERSION_PATCH 6
 
 #define CONF_FILENAME "giada.conf"
 
 
 
 /* -- GUI ------------------------------------------------------------------- */
-#ifdef G_OS_WINDOWS
-       #define G_GUI_SLEEP                     1000/24
-#else
-       #define G_GUI_SLEEP                     1000000/24 // == 1.000.000 / 24 == 1/24 sec == 24 Hz
-#endif
-#define G_GUI_WIDTH                               816
-#define G_GUI_HEIGHT                      510
-#define G_GUI_PLUGIN_RATE    0.05  // refresh rate for plugin GUIs
+#define G_GUI_REFRESH_RATE   1000/24
+#define G_GUI_PLUGIN_RATE    0.05  // refresh rate for plugin GUI
 #define G_GUI_FONT_SIZE_BASE 12
 #define G_GUI_INNER_MARGIN   4
 #define G_GUI_OUTER_MARGIN   8
 #define G_MAX_GRID_VAL      64
 #define G_MIN_BUF_SIZE      8
 #define G_MAX_BUF_SIZE      4096
+#define G_MIN_GUI_WIDTH     816
+#define G_MIN_GUI_HEIGHT    510
 
 
 
@@ -369,6 +365,7 @@ const int MIDI_CHANS[16] = {
 #define PATCH_KEY_CHANNEL_VOLUME               "volume"
 #define PATCH_KEY_CHANNEL_PAN                  "pan"
 #define PATCH_KEY_CHANNEL_MIDI_IN              "midi_in"
+#define PATCH_KEY_CHANNEL_MIDI_IN_VELO_AS_VOL  "midi_in_velo_as_vol"
 #define PATCH_KEY_CHANNEL_MIDI_IN_KEYPRESS     "midi_in_keypress"
 #define PATCH_KEY_CHANNEL_MIDI_IN_KEYREL       "midi_in_keyrel"
 #define PATCH_KEY_CHANNEL_MIDI_IN_KILL         "midi_in_kill"
index 86fcf89bb6df5f738c1c10f619b85f2397fdb77e..5db174c0230ab9c5f04855235aaca42307641aae 100644 (file)
@@ -64,7 +64,6 @@ void init_prepareParser()
   time (&t);
        gu_log("[init] Giada " G_VERSION_STR " - %s", ctime(&t));
 
-  conf::init();
        conf::read();
        patch::init();
 
@@ -131,7 +130,7 @@ void init_prepareMidiMap()
 
 void init_startGUI(int argc, char** argv)
 {
-       G_MainWin = new gdMainWindow(G_GUI_WIDTH, G_GUI_HEIGHT, "", argc, argv);
+       G_MainWin = new gdMainWindow(G_MIN_GUI_WIDTH, G_MIN_GUI_HEIGHT, "", argc, argv);
        G_MainWin->resize(conf::mainWindowX, conf::mainWindowY, conf::mainWindowW,
     conf::mainWindowH);
 
index 15bb1ebd829404da431cdc2f89e17fad1a282eb9..421eb02ab01f429844f141fd0396bf0e026d5bda 100644 (file)
@@ -46,18 +46,18 @@ namespace kernelAudio
 {
 namespace
 {
-RtAudio *rtSystem = nullptr;
-bool status = false;
-unsigned numDevs = 0;
-bool inputEnabled = false;
-unsigned realBufsize = 0;              // reale bufsize from the soundcard
-int api = 0;
+RtAudio* rtSystem     = nullptr;
+bool     status       = false;
+unsigned numDevs      = 0;
+bool     inputEnabled = false;
+unsigned realBufsize  = 0;             // reale bufsize from the soundcard
+int      api          = 0;
 
 #ifdef __linux__
 
 JackState jackState;
 
-jack_client_t *jackGetHandle()
+jack_client_tjackGetHandle()
 {
        return static_cast<jack_client_t*>(rtSystem->rtapi_->__HACK__getJackClient());
 }
index c8a9d9437dcbfad3c054fe0b74034a4f67648dbb..1d49fc12f95f98d0fd5b3665952ba74961b35e6d 100644 (file)
@@ -114,33 +114,33 @@ void processChannels(const MidiEvent& midiEvent)
 
                if      (pure == ch->midiInKeyPress) {
                        gu_log("  >>> keyPress, ch=%d (pure=0x%X)\n", ch->index, pure);
-                       glue_keyPress(ch, false, false);
+                       c::io::keyPress(ch, false, false, midiEvent.getVelocity());
                }
                else if (pure == ch->midiInKeyRel) {
                        gu_log("  >>> keyRel ch=%d (pure=0x%X)\n", ch->index, pure);
-                       glue_keyRelease(ch, false, false);
+                       c::io::keyRelease(ch, false, false);
                }
                else if (pure == ch->midiInMute) {
                        gu_log("  >>> mute ch=%d (pure=0x%X)\n", ch->index, pure);
-                       glue_toggleMute(ch, false);
+                       c::channel::toggleMute(ch, false);
                }               
                else if (pure == ch->midiInKill) {
                        gu_log("  >>> kill ch=%d (pure=0x%X)\n", ch->index, pure);
-                       glue_kill(ch);
+                       c::channel::kill(ch);
                }               
                else if (pure == ch->midiInArm) {
                        gu_log("  >>> arm ch=%d (pure=0x%X)\n", ch->index, pure);
-                       glue_toggleArm(ch, false);
+                       c::channel::toggleArm(ch, false);
                }
                else if (pure == ch->midiInSolo) {
                        gu_log("  >>> solo ch=%d (pure=0x%X)\n", ch->index, pure);
-                       glue_toggleSolo(ch, false);
+                       c::channel::toggleSolo(ch, false);
                }
                else if (pure == ch->midiInVolume) {
                        float vf = midiEvent.getVelocity() / 127.0f;
                        gu_log("  >>> volume ch=%d (pure=0x%X, value=%d, float=%f)\n",
                                ch->index, pure, midiEvent.getVelocity(), vf);
-                       glue_setVolume(ch, vf, false);
+                       c::channel::setVolume(ch, vf, false);
                }
                else {
                        SampleChannel* sch = static_cast<SampleChannel*>(ch);
@@ -148,12 +148,12 @@ void processChannels(const MidiEvent& midiEvent)
                                float vf = midiEvent.getVelocity() / (127/4.0f); // [0-127] ~> [0.0-4.0]
                                gu_log("  >>> pitch ch=%d (pure=0x%X, value=%d, float=%f)\n",
                                        sch->index, pure, midiEvent.getVelocity(), vf);
-                               glue_setPitch(sch, vf);
+                               c::channel::setPitch(sch, vf);
                        }
                        else 
                        if (pure == sch->midiInReadActions) {
                                gu_log("  >>> toggle read actions ch=%d (pure=0x%X)\n", sch->index, pure);
-                               glue_toggleReadingRecs(sch, false);
+                               c::channel::toggleReadingRecs(sch, false);
                        }
                }
 
@@ -188,11 +188,11 @@ void processMaster(const MidiEvent& midiEvent)
        }
        else if (pure == conf::midiInActionRec) {
                gu_log("  >>> actionRec (master) (pure=0x%X)\n", pure);
-               glue_startStopActionRec(false);
+               c::io::startStopActionRec(false);
        }
        else if (pure == conf::midiInInputRec) {
                gu_log("  >>> inputRec (master) (pure=0x%X)\n", pure);
-               glue_startStopInputRec(false);
+               c::io::startStopInputRec(false);
        }
        else if (pure == conf::midiInMetronome) {
                gu_log("  >>> metronome (master) (pure=0x%X)\n", pure);
index d954ffb641b67b2f01d3e008dfcbc84a024e8e9a..dfdc9dc0f009cb7fe6f68d0cf4671e08613a254d 100644 (file)
@@ -216,6 +216,7 @@ bool readChannels(json_t* jContainer)
     if (!storager::setFloat (jChannel, PATCH_KEY_CHANNEL_VOLUME,               channel.volume)) return 0;
     if (!storager::setFloat (jChannel, PATCH_KEY_CHANNEL_PAN,                  channel.pan)) return 0;
     if (!storager::setBool  (jChannel, PATCH_KEY_CHANNEL_MIDI_IN,              channel.midiIn)) return 0;
+    if (!storager::setBool  (jChannel, PATCH_KEY_CHANNEL_MIDI_IN_VELO_AS_VOL,  channel.midiInVeloAsVol)) return 0;
     if (!storager::setUint32(jChannel, PATCH_KEY_CHANNEL_MIDI_IN_KEYPRESS,     channel.midiInKeyPress)) return 0;
     if (!storager::setUint32(jChannel, PATCH_KEY_CHANNEL_MIDI_IN_KEYREL,       channel.midiInKeyRel)) return 0;
     if (!storager::setUint32(jChannel, PATCH_KEY_CHANNEL_MIDI_IN_KILL,         channel.midiInKill)) return 0;
@@ -394,6 +395,7 @@ void writeChannels(json_t* jContainer, vector<channel_t>* channels)
     json_object_set_new(jChannel, PATCH_KEY_CHANNEL_VOLUME,               json_real(channel.volume));
     json_object_set_new(jChannel, PATCH_KEY_CHANNEL_PAN,                  json_real(channel.pan));
     json_object_set_new(jChannel, PATCH_KEY_CHANNEL_MIDI_IN,              json_boolean(channel.midiIn));
+    json_object_set_new(jChannel, PATCH_KEY_CHANNEL_MIDI_IN_VELO_AS_VOL,  json_boolean(channel.midiInVeloAsVol));
     json_object_set_new(jChannel, PATCH_KEY_CHANNEL_MIDI_IN_KEYPRESS,     json_integer(channel.midiInKeyPress));
     json_object_set_new(jChannel, PATCH_KEY_CHANNEL_MIDI_IN_KEYREL,       json_integer(channel.midiInKeyRel));
     json_object_set_new(jChannel, PATCH_KEY_CHANNEL_MIDI_IN_KILL,         json_integer(channel.midiInKill));
index 28b11d0533da736bfdc0f70cbd5af6c5364838ed..651c2af5ed78f425402552179fdf573c81ccaf88 100644 (file)
 
 #include <string>
 #include <vector>
-#ifdef __APPLE__  // our Clang still doesn't know about cstdint (c++11 stuff)
-       #include <stdint.h>
-#else
-       #include <cstdint>
-#endif
+#include <cstdint>
 
 
 namespace giada {
@@ -73,6 +69,7 @@ struct channel_t
        float       volume;
        float       pan;
        bool        midiIn;
+       bool        midiInVeloAsVol;
        uint32_t    midiInKeyPress;
        uint32_t    midiInKeyRel;
        uint32_t    midiInKill;
@@ -118,19 +115,19 @@ struct column_t
 
 extern std::string header;
 extern std::string version;
-extern int    versionMajor;
-extern int    versionMinor;
-extern int    versionPatch;
+extern int         versionMajor;
+extern int         versionMinor;
+extern int         versionPatch;
 extern std::string name;
-extern float  bpm;
-extern int    bars;
-extern int    beats;
-extern int    quantize;
-extern float  masterVolIn;
-extern float  masterVolOut;
-extern int    metronome;
-extern int    lastTakeId;
-extern int    samplerate;   // original samplerate when the patch was saved
+extern float       bpm;
+extern int         bars;
+extern int         beats;
+extern int         quantize;
+extern float       masterVolIn;
+extern float       masterVolOut;
+extern int         metronome;
+extern int         lastTakeId;
+extern int         samplerate;   // original samplerate when the patch was saved
 
 extern std::vector<column_t>  columns;
 extern std::vector<channel_t> channels;
index b875eebd817d15ae9ee95fcdd98cb0d340bef637..4ab37001f8c1f227c286ce647a4e67482681a414 100644 (file)
@@ -421,6 +421,10 @@ void SampleChannel::parseAction(recorder::action* a, int localFrame,
 
 void SampleChannel::sum(int frame, bool running)
 {
+       // TODO - Opaque channels' processing
+       // TODO - Opaque channels' processing
+       // TODO - Opaque channels' processing
+       
        if (wave == nullptr || status & ~(STATUS_PLAY | STATUS_ENDING))
                return;
 
@@ -714,7 +718,7 @@ void SampleChannel::setBoost(float v)
 }
 
 
-float SampleChannel::getBoost()
+float SampleChannel::getBoost() const
 {
        return boost;
 }
@@ -735,10 +739,10 @@ void SampleChannel::calcFadeoutStep()
 /* -------------------------------------------------------------------------- */
 
 
-void SampleChannel::setReadActions(bool v, bool recsStopOnChanHalt)
+void SampleChannel::setReadActions(bool v, bool killOnFalse)
 {
        readActions = v;
-       if (!readActions && recsStopOnChanHalt)
+       if (!readActions && killOnFalse)
                kill(0);  /// FIXME - wrong frame value
 }
 
@@ -866,6 +870,7 @@ void SampleChannel::process(float* outBuffer, float* inBuffer)
        pluginHost::processStack(vChan, pluginHost::CHANNEL, this);
 #endif
 
+       // TODO - Opaque channels' processing
   for (int j=0; j<bufferSize; j+=2) {
                outBuffer[j]   += vChan[j]   * volume * calcPanning(0) * boost;
                outBuffer[j+1] += vChan[j+1] * volume * calcPanning(1) * boost;
@@ -902,6 +907,7 @@ void SampleChannel::preview(float* outBuffer)
        else
                trackerPreview = fillChan(vChanPreview, trackerPreview, 0, false);
 
+       // TODO - Opaque channels' processing
        for (int j=0; j<bufferSize; j+=2) {
                outBuffer[j]   += vChanPreview[j]   * volume * calcPanning(0) * boost;
                outBuffer[j+1] += vChanPreview[j+1] * volume * calcPanning(1) * boost;
@@ -988,6 +994,7 @@ int SampleChannel::readPatch(const string& basePath, int i,
        boost             = pch->boost;
        readActions       = pch->recActive;
        recStatus         = readActions ? REC_READING : REC_STOPPED;
+       midiInVeloAsVol   = pch->midiInVeloAsVol;
        midiInReadActions = pch->midiInReadActions;
        midiInPitch       = pch->midiInPitch;
   inputMonitor      = pch->inputMonitor;
@@ -1170,7 +1177,7 @@ int SampleChannel::fillChan(float *dest, int start, int offset, bool rewind)
                }
        }
        else {
-
+               // TODO - Opaque channels count
                rsmp_data.data_in       = wave->getData()+start;    // source data
                rsmp_data.input_frames  = (end-start)/2;            // how many readable bytes
                rsmp_data.data_out      = dest+offset;              // destination (processed data)
index 54162b05c5026e4eb87b47535ec3665c25bc9414..b290640f841b2b4c7d065b90928e87374b4f6001 100644 (file)
@@ -129,6 +129,8 @@ public:
 
        int getTrackerPreview() const;
        int getShift() const;
+       float getBoost() const; 
+
        void setShift(int s);
 
        void reset(int frame);
@@ -173,13 +175,12 @@ public:
        void hardStop(int frame);
 
        /* setReadActions
-        * if enabled (v == true), recorder will read actions from this channel. If
-        * recsStopOnChanHalt == true, stop reading actions right away. */
+       If enabled (v == true), recorder will read actions from this channel. If 
+       killOnFalse == true and disabled, will also kill the channel. */
 
-       void setReadActions(bool v, bool recsStopOnChanHalt);
+       void setReadActions(bool v, bool killOnFalse);
 
        void setBoost(float v);
-       float getBoost();       
 
        void setOnEndPreviewCb(std::function<void()> f);
 
@@ -199,6 +200,7 @@ public:
 
        /* midi stuff */
 
+  bool     midiInVeloAsVol;
   uint32_t midiInReadActions;
   uint32_t midiInPitch;
 
index 300a43d1529d879eea9505a73d6f85691cb2b4e6..7491a14cbfa24bd4782f071058349f9f4ee19b66 100644 (file)
@@ -41,7 +41,7 @@ class Wave
 private:
 
        float* m_data;
-       int m_size;                 // Wave size in bytes (size in stereo: size / 2)
+       int m_size;                 // Wave size in bytes (size in frames: m_size / m_channels)
        int m_channels;
        int m_rate;
        int m_bits;
@@ -57,12 +57,6 @@ public:
        ~Wave();
        Wave(const Wave& other);
 
-       void setRate(int v);
-       void setChannels(int v);
-       void setData(float* data, int size);
-       void setLogical(bool l);
-       void setEdited(bool e);
-
        /* setPath
        Sets new path 'p'. If 'id' != -1 inserts a numeric id next to the file 
        extension, e.g. : /path/to/sample-[id].wav */
@@ -76,11 +70,17 @@ public:
        std::string getPath() const;    
        int getBits() const;
        float* getData() const;
-       int getSize() const;        // with channels count
+       int getSize() const;        // in frames
        int getDuration() const;
        bool isLogical() const;
        bool isEdited() const;
 
+       void setRate(int v);
+       void setChannels(int v);
+       void setData(float* data, int size);
+       void setLogical(bool l);
+       void setEdited(bool e);
+       
        /* clear
        Resets Wave to init state. */
 
index a2b0e6e3da570653689eaea09cbfe87377203628..9fbba3e78f53e52a783793f891af651779c19277 100644 (file)
@@ -66,14 +66,27 @@ extern gdMainWindow* G_MainWin;
 
 
 using std::string;
-using namespace giada::m;
 
 
-static bool __soloSession__ = false;
+namespace giada {
+namespace c     {
+namespace channel 
+{
+namespace
+{
+bool soloSession__ = false;
+} // {anonymous}
+
 
+/* -------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------- */
 
-int glue_loadChannel(SampleChannel* ch, const string& fname)
+
+int loadChannel(SampleChannel* ch, const string& fname)
 {
+       using namespace giada::m;
+
        /* Always stop a channel before loading a new sample in it. This will prevent
        issues if tracker is outside the boundaries of the new sample -> segfault. */
 
@@ -91,7 +104,7 @@ int glue_loadChannel(SampleChannel* ch, const string& fname)
                return result;
 
        if (wave->getRate() != conf::samplerate) {
-               gu_log("[glue_loadChannel] input rate (%d) != system rate (%d), conversion needed\n",
+               gu_log("[loadChannel] input rate (%d) != system rate (%d), conversion needed\n",
                        wave->getRate(), conf::samplerate);
                result = waveManager::resample(wave, conf::rsmpQuality, conf::samplerate); 
                if (result != G_RES_OK) {
@@ -111,9 +124,9 @@ int glue_loadChannel(SampleChannel* ch, const string& fname)
 /* -------------------------------------------------------------------------- */
 
 
-Channel* glue_addChannel(int column, int type, int size)
+Channel* addChannel(int column, int type, int size)
 {
-       Channel* ch    = mh::addChannel(type);
+       Channel* ch    = m::mh::addChannel(type);
        geChannel* gch = G_MainWin->keyboard->addChannel(column, ch, size);
        ch->guiChannel = gch;
        return ch;
@@ -123,8 +136,10 @@ Channel* glue_addChannel(int column, int type, int size)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_deleteChannel(Channel* ch)
+void deleteChannel(Channel* ch)
 {
+       using namespace giada::m;
+
        if (!gdConfirmWin("Warning", "Delete channel: are you sure?"))
                return;
        recorder::clearChan(ch->index);
@@ -143,7 +158,7 @@ void glue_deleteChannel(Channel* ch)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_freeChannel(Channel* ch)
+void freeChannel(Channel* ch)
 {
        if (ch->status == STATUS_PLAY) {
                if (!gdConfirmWin("Warning", "This action will stop the channel: are you sure?"))
@@ -154,7 +169,7 @@ void glue_freeChannel(Channel* ch)
                return;
 
        G_MainWin->keyboard->freeChannel(ch->guiChannel);
-       recorder::clearChan(ch->index);
+       m::recorder::clearChan(ch->index);
        ch->hasActions = false;
        ch->empty();
 
@@ -170,7 +185,7 @@ void glue_freeChannel(Channel* ch)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_toggleArm(Channel* ch, bool gui)
+void toggleArm(Channel* ch, bool gui)
 {
        ch->setArmed(!ch->isArmed());
        if (!gui)
@@ -181,7 +196,7 @@ void glue_toggleArm(Channel* ch, bool gui)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_toggleInputMonitor(Channel* ch)
+void toggleInputMonitor(Channel* ch)
 {
        SampleChannel* sch = static_cast<SampleChannel*>(ch);
        sch->inputMonitor = !sch->inputMonitor;
@@ -191,8 +206,10 @@ void glue_toggleInputMonitor(Channel* ch)
 /* -------------------------------------------------------------------------- */
 
 
-int glue_cloneChannel(Channel* src)
+int cloneChannel(Channel* src)
 {
+       using namespace giada::m;
+
        Channel* ch    = mh::addChannel(src->type);
        geChannel* gch = G_MainWin->keyboard->addChannel(src->guiChannel->getColumnIndex(), 
                ch, src->guiChannel->getSize());
@@ -208,14 +225,14 @@ int glue_cloneChannel(Channel* src)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_setVolume(Channel* ch, float v, bool gui, bool editor)
+void setVolume(Channel* ch, float v, bool gui, bool editor)
 {
-       ch->volume = v;
+       ch->setVolume(v);
 
        /* Changing channel volume? Update wave editor (if it's shown). */
 
        if (!editor) {
-               gdSampleEditor *gdEditor = (gdSampleEditor*) gu_getSubwindow(G_MainWin, WID_SAMPLE_EDITOR);
+               gdSampleEditor* gdEditor = static_cast<gdSampleEditor*>(gu_getSubwindow(G_MainWin, WID_SAMPLE_EDITOR));
                if (gdEditor) {
                        Fl::lock();
                        gdEditor->volumeTool->refresh();
@@ -234,7 +251,7 @@ void glue_setVolume(Channel* ch, float v, bool gui, bool editor)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_setPitch(SampleChannel* ch, float val)
+void setPitch(SampleChannel* ch, float val)
 {
        ch->setPitch(val);
        gdSampleEditor* gdEditor = static_cast<gdSampleEditor*>(gu_getSubwindow(G_MainWin, WID_SAMPLE_EDITOR));
@@ -249,7 +266,7 @@ void glue_setPitch(SampleChannel* ch, float val)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_setPanning(SampleChannel* ch, float val)
+void setPanning(SampleChannel* ch, float val)
 {
        ch->setPan(val);
        gdSampleEditor* gdEditor = static_cast<gdSampleEditor*>(gu_getSubwindow(G_MainWin, WID_SAMPLE_EDITOR));
@@ -264,8 +281,10 @@ void glue_setPanning(SampleChannel* ch, float val)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_toggleMute(Channel* ch, bool gui)
+void toggleMute(Channel* ch, bool gui)
 {
+       using namespace giada::m;
+
        if (recorder::active && recorder::canRec(ch, clock::isRunning(), mixer::recording)) {
                if (!ch->mute) {
                        recorder::startOverdub(ch->index, G_ACTION_MUTES, clock::getCurrentFrame(),
@@ -290,16 +309,16 @@ void glue_toggleMute(Channel* ch, bool gui)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_toggleSolo(Channel* ch, bool gui)
+void toggleSolo(Channel* ch, bool gui)
 {
-       ch->solo ? glue_setSoloOn(ch, gui) : glue_setSoloOff(ch, gui);
+       ch->solo ? setSoloOn(ch, gui) : setSoloOff(ch, gui);
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void glue_kill(Channel* ch)
+void kill(Channel* ch)
 {
        ch->kill(0); // on frame 0: it's a user-generated event
 }
@@ -308,17 +327,19 @@ void glue_kill(Channel* ch)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_setSoloOn(Channel* ch, bool gui)
+void setSoloOn(Channel* ch, bool gui)
 {
+       using namespace giada::m;
+
        /* if there's no solo session, store mute configuration of all chans
         * and start the session */
 
-       if (!__soloSession__) {
+       if (!soloSession__) {
                for (unsigned i=0; i<mixer::channels.size(); i++) {
                        Channel *och = mixer::channels.at(i);
                        och->mute_s  = och->mute;
                }
-               __soloSession__ = true;
+               soloSession__ = true;
        }
 
        ch->solo = !ch->solo;
@@ -354,13 +375,15 @@ void glue_setSoloOn(Channel* ch, bool gui)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_setSoloOff(Channel* ch, bool gui)
+void setSoloOff(Channel* ch, bool gui)
 {
+       using namespace giada::m;
+
        /* if this is uniqueSolo, stop solo session and restore mute status,
         * else mute this */
 
        if (mh::uniqueSolo(ch)) {
-               __soloSession__ = false;
+               soloSession__ = false;
                for (unsigned i=0; i<mixer::channels.size(); i++) {
                        Channel *och = mixer::channels.at(i);
                        if (och->mute_s) {
@@ -399,7 +422,7 @@ void glue_setSoloOff(Channel* ch, bool gui)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_setBoost(SampleChannel* ch, float val)
+void setBoost(SampleChannel* ch, float val)
 {
        ch->setBoost(val);
        gdSampleEditor *gdEditor = static_cast<gdSampleEditor*>(gu_getSubwindow(G_MainWin, WID_SAMPLE_EDITOR));
@@ -414,7 +437,7 @@ void glue_setBoost(SampleChannel* ch, float val)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_setName(Channel* ch, const string& name)
+void setName(Channel* ch, const string& name)
 {
        ch->setName(name);
        ch->guiChannel->update();
@@ -424,9 +447,10 @@ void glue_setName(Channel* ch, const string& name)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_toggleReadingRecs(SampleChannel* ch, bool gui)
+void toggleReadingRecs(SampleChannel* ch, bool gui)
 {
-       /* When you call glue_startReadingRecs with conf::treatRecsAsLoops, the
+
+       /* When you call startReadingRecs with conf::treatRecsAsLoops, the
        member value ch->readActions actually is not set to true immediately, because
        the channel is in wait mode (REC_WAITING). ch->readActions will become true on
        the next first beat. So a 'stop rec' command should occur also when
@@ -435,24 +459,26 @@ void glue_toggleReadingRecs(SampleChannel* ch, bool gui)
        then you press 'R' again to undo the status. */
 
        if (ch->readActions || (!ch->readActions && ch->recStatus == REC_WAITING))
-               glue_stopReadingRecs(ch, gui);
+               stopReadingRecs(ch, gui);
        else
-               glue_startReadingRecs(ch, gui);
+               startReadingRecs(ch, gui);
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void glue_startReadingRecs(SampleChannel* ch, bool gui)
+void startReadingRecs(SampleChannel* ch, bool gui)
 {
+       using namespace giada::m;
+
        if (conf::treatRecsAsLoops)
                ch->recStatus = REC_WAITING;
        else
                ch->setReadActions(true, conf::recsStopOnChanHalt);
        if (!gui) {
                Fl::lock();
-               ((geSampleChannel*)ch->guiChannel)->readActions->value(1);
+               static_cast<geSampleChannel*>(ch->guiChannel)->readActions->value(1);
                Fl::unlock();
        }
 }
@@ -461,17 +487,25 @@ void glue_startReadingRecs(SampleChannel* ch, bool gui)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_stopReadingRecs(SampleChannel* ch, bool gui)
+void stopReadingRecs(SampleChannel* ch, bool gui)
 {
-       /* First of all, if the mixer is not running just stop and disable everything.
+       using namespace giada::m;
+
+       /* First of all, if the clock is not running just stop and disable everything.
        Then if "treatRecsAsLoop" wait until the sequencer reaches beat 0, so put the
        channel in REC_ENDING status. */
 
        if (!clock::isRunning()) {
                ch->recStatus = REC_STOPPED;
-               ch->readActions = false;
+               ch->setReadActions(false, false);
        }
        else
+       if (ch->recStatus == REC_WAITING)
+               ch->recStatus = REC_STOPPED;
+       else
+       if (ch->recStatus == REC_ENDING)
+               ch->recStatus = REC_READING;
+       else
        if (conf::treatRecsAsLoops)
                ch->recStatus = REC_ENDING;
        else
@@ -479,7 +513,9 @@ void glue_stopReadingRecs(SampleChannel* ch, bool gui)
 
        if (!gui) {
                Fl::lock();
-               ((geSampleChannel*)ch->guiChannel)->readActions->value(0);
+               static_cast<geSampleChannel*>(ch->guiChannel)->readActions->value(0);
                Fl::unlock();
        }
 }
+
+}}}; // giada::c::channel::
\ No newline at end of file
index 6eac90d51cd73007a1bb159f240d01aae981c642..22286223bc83058a5549f38cf06c1cb527d02e41 100644 (file)
@@ -36,55 +36,60 @@ class Channel;
 class SampleChannel;
 class gdSampleEditor;
 
-
+namespace giada {
+namespace c     {
+namespace channel 
+{
 /* addChannel
- * add an empty new channel to the stack. Returns the new channel. */
+Adds an empty new channel to the stack. Returns the new channel. */
 
-Channel* glue_addChannel(int column, int type, int size);
+Channel* addChannel(int column, int type, int size);
 
 /* loadChannel
- * fill an existing channel with a wave. */
+Fills an existing channel with a wave. */
 
-int glue_loadChannel(SampleChannel* ch, const std::string& fname);
+int loadChannel(SampleChannel* ch, const std::string& fname);
 
 /* deleteChannel
- * Remove a channel from Mixer. */
+Removes a channel from Mixer. */
 
-void glue_deleteChannel(Channel* ch);
+void deleteChannel(Channel* ch);
 
 /* freeChannel
- * Unload the sample from a sample channel. */
+Unloads the sample from a sample channel. */
 
-void glue_freeChannel(Channel* ch);
+void freeChannel(Channel* ch);
 
 /* cloneChannel
- * Make an exact copy of Channel *ch. */
+Makes an exact copy of Channel *ch. */
 
-int glue_cloneChannel(Channel* ch);
+int cloneChannel(Channel* ch);
 
 /* toggle/set*
 Toggles or set several channel properties. If gui == true the signal comes from 
 a manual interaction on the GUI, otherwise it's a MIDI/Jack/external signal. */
 
-void glue_toggleArm(Channel* ch, bool gui=true);
-void glue_toggleInputMonitor(Channel* ch);
-void glue_kill(Channel* ch);
-void glue_toggleMute(Channel* ch, bool gui=true);
-void glue_setSoloOn(Channel* ch, bool gui=true);
-void glue_setSoloOff(Channel* ch, bool gui=true);
-void glue_toggleSolo(Channel* ch, bool gui=true);
-void glue_setVolume(Channel* ch, float v, bool gui=true, bool editor=false);
-void glue_setName(Channel* ch, const std::string& name);
-void glue_setPitch(SampleChannel* ch, float val);
-void glue_setPanning(SampleChannel* ch, float val);
-void glue_setBoost(SampleChannel* ch, float val);
+void toggleArm(Channel* ch, bool gui=true);
+void toggleInputMonitor(Channel* ch);
+void kill(Channel* ch);
+void toggleMute(Channel* ch, bool gui=true);
+void setSoloOn(Channel* ch, bool gui=true);
+void setSoloOff(Channel* ch, bool gui=true);
+void toggleSolo(Channel* ch, bool gui=true);
+void setVolume(Channel* ch, float v, bool gui=true, bool editor=false);
+void setName(Channel* ch, const std::string& name);
+void setPitch(SampleChannel* ch, float val);
+void setPanning(SampleChannel* ch, float val);
+void setBoost(SampleChannel* ch, float val);
 
 /* toggleReadingRecs
 Handles the 'R' button. If gui == true the signal comes from an user interaction
 on the GUI, otherwise it's a MIDI/Jack/external signal. */
 
-void glue_toggleReadingRecs(SampleChannel* ch, bool gui=true);
-void glue_startReadingRecs(SampleChannel* ch, bool gui=true);
-void glue_stopReadingRecs(SampleChannel* ch, bool gui=true);
+void toggleReadingRecs(SampleChannel* ch, bool gui=true);
+void startReadingRecs(SampleChannel* ch, bool gui=true);
+void stopReadingRecs(SampleChannel* ch, bool gui=true);
+
+}}}; // giada::c::channel::
 
 #endif
index 2f51a4ea5f2ee5876ba2ecee1230c4193ad2e68f..7e85d8033075bcb9eb9df1d06d587d07e6100436 100644 (file)
@@ -35,6 +35,7 @@
 #include "../gui/elems/mainWindow/keyboard/sampleChannel.h"
 #include "../utils/gui.h"
 #include "../utils/log.h"
+#include "../utils/math.h"
 #include "../core/recorder.h"
 #include "../core/kernelAudio.h"
 #include "../core/mixer.h"
 #include "io.h"
 
 
-extern gdMainWindow *G_MainWin;
+extern gdMainWindowG_MainWin;
 
 
-using namespace giada::m;
+namespace giada {
+namespace c     {
+namespace io 
+{
+namespace
+{
+void ctrlPress(SampleChannel* ch)
+{
+       c::channel::toggleMute(ch);
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void shiftPress(SampleChannel* ch)
+{
+       /* action recording on:
+                       if sequencer is running, rec a killchan
+                action recording off:
+                       if chan has recorded events:
+                       |        if seq is playing OR channel 'c' is stopped, de/activate recs
+                       |        else kill chan
+                       else kill chan. */
+
+       if (m::recorder::active) {
+               if (!m::clock::isRunning()) 
+                       return;
+               ch->kill(0); // on frame 0: user-generated event
+               if (m::recorder::canRec(ch, m::clock::isRunning(), m::mixer::recording) &&
+                               !(ch->mode & LOOP_ANY))
+               {   // don't record killChan actions for LOOP channels
+                       m::recorder::rec(ch->index, G_ACTION_KILL, m::clock::getCurrentFrame());
+                       ch->hasActions = true;
+               }
+       }
+       else {
+               if (ch->hasActions) {
+                       if (m::clock::isRunning() || ch->status == STATUS_OFF)
+                               ch->readActions ? c::channel::stopReadingRecs(ch) : c::channel::startReadingRecs(ch);
+                       else
+                               ch->kill(0);  // on frame 0: user-generated event
+               }
+               else
+                       ch->kill(0);    // on frame 0: user-generated event
+       }
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+void cleanPress(SampleChannel* ch, int velocity)
+{
+       /* Record now if the quantizer is off, otherwise let mixer to handle it when a
+       quantoWait has passed. Moreover, KEYPRESS and KEYREL are meaningless for loop 
+       modes. */
+
+       if (m::clock::getQuantize() == 0 &&
+                       m::recorder::canRec(ch, m::clock::isRunning(), m::mixer::recording) &&
+                       !(ch->mode & LOOP_ANY))
+       {
+               if (ch->mode == SINGLE_PRESS) {
+                       m::recorder::startOverdub(ch->index, G_ACTION_KEYS, m::clock::getCurrentFrame(),
+                               m::kernelAudio::getRealBufSize());
+                       ch->readActions = false;   // don't read actions while overdubbing
+               }
+               else {
+                       m::recorder::rec(ch->index, G_ACTION_KEYPRESS, m::clock::getCurrentFrame());
+                       ch->hasActions = true;
+
+                       /* Why return here? You record an action and then you call ch->start: 
+                       Mixer, which is on another thread, reads your newly recorded action if you 
+                       have readActions == true, and then ch->start kicks in right after it.
+                       The result: Mixer plays the channel (due to the new action) but ch->start
+                       kills it right away (because the sample is playing). Fix: call ch->start
+                       only if you are not recording anything, i.e. let Mixer play it. */
+
+                       if (ch->readActions)
+                               return;
+               }
+       }
+
+       /* This is a user-generated event, so it's on frame 0. For one-shot modes,
+       velocity drives the internal volume. */
 
+       if (ch->mode & SINGLE_ANY && ch->midiInVeloAsVol)
+               ch->setVolumeI(u::math::map((float)velocity, 0.0f, 127.0f, 0.0f, 1.0f));
 
-void glue_keyPress(Channel *ch, bool ctrl, bool shift)
+       ch->start(0, true, m::clock::getQuantize(), m::clock::isRunning(), false, true);
+}
+
+} // {anonymous}
+
+
+/* -------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------- */
+
+
+void keyPress(Channel* ch, bool ctrl, bool shift, int velocity)
 {
        if (ch->type == CHANNEL_SAMPLE)
-               glue_keyPress((SampleChannel*)ch, ctrl, shift);
+               keyPress(static_cast<SampleChannel*>(ch), ctrl, shift, velocity);
        else
-               glue_keyPress((MidiChannel*)ch, ctrl, shift);
+               keyPress(static_cast<MidiChannel*>(ch), ctrl, shift);
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void glue_keyRelease(Channel *ch, bool ctrl, bool shift)
+void keyRelease(Channel* ch, bool ctrl, bool shift)
 {
        if (ch->type == CHANNEL_SAMPLE)
-               glue_keyRelease((SampleChannel*)ch, ctrl, shift);
+               keyRelease(static_cast<SampleChannel*>(ch), ctrl, shift);
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void glue_keyPress(MidiChannel *ch, bool ctrl, bool shift)
+void keyPress(MidiChannel* ch, bool ctrl, bool shift)
 {
        if (ctrl)
-               glue_toggleMute(ch);
+               c::channel::toggleMute(ch);
        else
        if (shift)
                ch->kill(0);        // on frame 0: user-generated event
        else
-               ch->start(0, true, clock::getQuantize(), clock::isRunning(), false, true); // on frame 0: user-generated event
+               ch->start(0, true, m::clock::getQuantize(), m::clock::isRunning(), false, true); // on frame 0: user-generated event
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void glue_keyPress(SampleChannel *ch, bool ctrl, bool shift)
+void keyPress(SampleChannel* ch, bool ctrl, bool shift, int velocity)
 {
-       /* case CTRL */
-
        if (ctrl)
-               glue_toggleMute(ch);
-
-       /* case SHIFT
-        *
-        * action recording on:
-        *              if seq is playing, rec a killchan
-        * action recording off:
-        *              if chan has recorded events:
-        *              |        if seq is playing OR channel 'c' is stopped, de/activate recs
-        *              |        else kill chan
-        *              else kill chan */
-
+               ctrlPress(ch);
+       else if (shift)
+               shiftPress(ch);
        else
-       if (shift) {
-               if (recorder::active) {
-                       if (clock::isRunning()) {
-                               ch->kill(0); // on frame 0: user-generated event
-                               if (recorder::canRec(ch, clock::isRunning(), mixer::recording) &&
-            !(ch->mode & LOOP_ANY))
-        {   // don't record killChan actions for LOOP channels
-                                       recorder::rec(ch->index, G_ACTION_KILL, clock::getCurrentFrame());
-          ch->hasActions = true;
-        }
-                       }
-               }
-               else {
-                       if (ch->hasActions) {
-                               if (clock::isRunning() || ch->status == STATUS_OFF)
-                                       ch->readActions ? glue_stopReadingRecs(ch) : glue_startReadingRecs(ch);
-                               else
-                                       ch->kill(0);  // on frame 0: user-generated event
-                       }
-                       else
-                               ch->kill(0);    // on frame 0: user-generated event
-               }
-       }
-       else {  /* case no modifier */
-
-               /* record now if the quantizer is off, otherwise let mixer to handle it
-                * when a quantoWait has passed. Moreover, KEYPRESS and KEYREL are
-                * meaningless for loop modes */
-
-               if (clock::getQuantize() == 0 &&
-                   recorder::canRec(ch, clock::isRunning(), mixer::recording) &&
-             !(ch->mode & LOOP_ANY))
-               {
-                       if (ch->mode == SINGLE_PRESS) {
-                               recorder::startOverdub(ch->index, G_ACTION_KEYS, clock::getCurrentFrame(),
-          kernelAudio::getRealBufSize());
-        ch->readActions = false;   // don't read actions while overdubbing
-      }
-                       else {
-                               recorder::rec(ch->index, G_ACTION_KEYPRESS, clock::getCurrentFrame());
-        ch->hasActions = true;
-
-        /* Why return here? You record an action (as done on line 148) and then
-                               you call ch->start (line 165): Mixer, which is on another thread, reads
-        your newly recorded action if you have readActions == true, and then
-        ch->start kicks in right after it      (as done on     line 165).
-                               The result: Mixer plays the channel (due to the new action) but ch->start
-                               kills it right away (because the sample is playing). Fix: call ch->start
-                               only if you are not recording anything, i.e. let Mixer play it. */
-
-        if (ch->readActions)
-          return;
-                       }
-               }
-
-               /* This is a user-generated event, so it's on frame 0 */
-
-               ch->start(0, true, clock::getQuantize(), clock::isRunning(), false, true);
-       }
-
-       /* the GUI update is done by gui_refresh() */
+               cleanPress(ch, velocity);
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void glue_keyRelease(SampleChannel *ch, bool ctrl, bool shift)
+void keyRelease(SampleChannel* ch, bool ctrl, bool shift)
 {
+       using namespace giada::m;
+
        if (ctrl || shift)
                return;
 
@@ -190,7 +219,7 @@ void glue_keyRelease(SampleChannel *ch, bool ctrl, bool shift)
 
        if (ch->mode == SINGLE_PRESS && recorder::canRec(ch, clock::isRunning(), mixer::recording))
                recorder::stopOverdub(clock::getCurrentFrame(), clock::getTotalFrames(),
-      &mixer::mutex_recs);
+                       &mixer::mutex_recs);
 
        /* the GUI update is done by gui_refresh() */
 
@@ -200,17 +229,19 @@ void glue_keyRelease(SampleChannel *ch, bool ctrl, bool shift)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_startStopActionRec(bool gui)
+void startStopActionRec(bool gui)
 {
-       recorder::active ? glue_stopActionRec(gui) : glue_startActionRec(gui);
+       m::recorder::active ? stopActionRec(gui) : startActionRec(gui);
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void glue_startActionRec(bool gui)
+void startActionRec(bool gui)
 {
+       using namespace giada::m;
+
        if (kernelAudio::getStatus() == false)
                return;
 
@@ -230,21 +261,21 @@ void glue_startActionRec(bool gui)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_stopActionRec(bool gui)
+void stopActionRec(bool gui)
 {
        /* stop the recorder and sort new actions */
 
-       recorder::active = false;
-       recorder::sortActions();
+       m::recorder::active = false;
+       m::recorder::sortActions();
 
-       for (unsigned i=0; i<mixer::channels.size(); i++)
+       for (Channel* ch : m::mixer::channels)
        {
-               if (mixer::channels.at(i)->type == CHANNEL_MIDI)
+               if (ch->type == CHANNEL_MIDI)
                        continue;
-               SampleChannel *ch = (SampleChannel*) mixer::channels.at(i);
-               G_MainWin->keyboard->setChannelWithActions((geSampleChannel*)ch->guiChannel);
-               if (!ch->readActions && ch->hasActions)
-                       glue_startReadingRecs(ch, false);
+               SampleChannel* sch = static_cast<SampleChannel*>(ch);
+               G_MainWin->keyboard->setChannelWithActions(static_cast<geSampleChannel*>(sch->guiChannel));
+               if (!sch->readActions && sch->hasActions)
+                       c::channel::startReadingRecs(sch, false);
        }
 
        if (!gui) {
@@ -260,12 +291,12 @@ void glue_stopActionRec(bool gui)
 /* -------------------------------------------------------------------------- */
 
 
-void glue_startStopInputRec(bool gui)
+void startStopInputRec(bool gui)
 {
-       if (mixer::recording)
-               glue_stopInputRec(gui);
+       if (m::mixer::recording)
+               stopInputRec(gui);
        else
-       if (!glue_startInputRec(gui))
+       if (!startInputRec(gui))
                gdAlert("No channels armed/available for audio recording.");
 }
 
@@ -273,14 +304,16 @@ void glue_startStopInputRec(bool gui)
 /* -------------------------------------------------------------------------- */
 
 
-int glue_startInputRec(bool gui)
+int startInputRec(bool gui)
 {
+       using namespace giada::m;
+
        if (kernelAudio::getStatus() == false)
                return false;
 
        if (!mh::startInputRec()) {
-         Fl::lock();
-         G_MainWin->mainTransport->updateRecInput(0);  // set it off, anyway
+               Fl::lock();
+               G_MainWin->mainTransport->updateRecInput(0);  // set it off, anyway
                Fl::unlock();
                return false;
        }
@@ -288,17 +321,17 @@ int glue_startInputRec(bool gui)
        if (!clock::isRunning())
                glue_startSeq(false); // update gui anyway
 
-  Fl::lock();
-    if (!gui)
-                 G_MainWin->mainTransport->updateRecInput(1);
-    G_MainWin->mainTimer->setLock(true);
-  Fl::unlock();
+       Fl::lock();
+               if (!gui)
+                       G_MainWin->mainTransport->updateRecInput(1);
+               G_MainWin->mainTimer->setLock(true);
+       Fl::unlock();
 
-  /* Update sample name inside sample channels' main button. This is useless for
-  midi channel, but let's do it anyway. */
+       /* Update sample name inside sample channels' main button. This is useless for
+       midi channel, but let's do it anyway. */
 
-  for (unsigned i=0; i<mixer::channels.size(); i++)
-    mixer::channels.at(i)->guiChannel->update();
+       for (Channel* ch : m::mixer::channels)
+               ch->guiChannel->update();
 
        return true;
 }
@@ -307,14 +340,16 @@ int glue_startInputRec(bool gui)
 /* -------------------------------------------------------------------------- */
 
 
-int glue_stopInputRec(bool gui)
+int stopInputRec(bool gui)
 {
+       using namespace giada::m;
+       
        mh::stopInputRec();
 
        /* Start all sample channels in loop mode that were armed, i.e. that were
        recording stuff and not yet in play. They are also started in force mode, i.e.
-  they must start playing right away at the current frame, not at the next first
-  beat. */
+       they must start playing right away at the current frame, not at the next first
+       beat. */
 
        for (Channel* ch : mixer::channels) {
                if (ch->type == CHANNEL_MIDI)
@@ -322,14 +357,16 @@ int glue_stopInputRec(bool gui)
                SampleChannel* sch = static_cast<SampleChannel*>(ch);
                if (sch->mode & (LOOP_ANY) && sch->status == STATUS_OFF && sch->isArmed())
                        sch->start(clock::getCurrentFrame(), true, clock::getQuantize(),
-        clock::isRunning(), true, true);
+                               clock::isRunning(), true, true);
        }
 
-  Fl::lock();
-    if (!gui)
-                 G_MainWin->mainTransport->updateRecInput(0);
-    G_MainWin->mainTimer->setLock(false);
-  Fl::unlock();
+       Fl::lock();
+               if (!gui)
+                       G_MainWin->mainTransport->updateRecInput(0);
+               G_MainWin->mainTimer->setLock(false);
+       Fl::unlock();
 
        return 1;
 }
+
+}}} // giada::c::io::
\ No newline at end of file
index 3377be979783480afa679c4af0967feb6ed901b2..0dccf9e258bd416d1ce1898d68b6decdc2f3a2c1 100644 (file)
 #define G_GLUE_IO_H
 
 
+class Channel;
+class SampleChannel;
+class MidiChannel;
+
+namespace giada {
+namespace c     {
+namespace io 
+{
 /* keyPress / keyRelease
  * handle the key pressure, either via mouse/keyboard or MIDI. If gui
  * is true it means that the event comes from the main window (mouse,
  * keyb or MIDI), otherwise the event comes from the action recorder. */
 
-void glue_keyPress  (class Channel       *ch, bool ctrl=0, bool shift=0);
-void glue_keyPress  (class SampleChannel *ch, bool ctrl=0, bool shift=0);
-void glue_keyPress  (class MidiChannel   *ch, bool ctrl=0, bool shift=0);
-void glue_keyRelease(class Channel       *ch, bool ctrl=0, bool shift=0);
-void glue_keyRelease(class SampleChannel *ch, bool ctrl=0, bool shift=0);
+void keyPress  (Channel*       ch, bool ctrl, bool shift, int velocity);
+void keyPress  (SampleChannel* ch, bool ctrl, bool shift, int velocity);
+void keyPress  (MidiChannel*   ch, bool ctrl, bool shift);
+void keyRelease(Channel*       ch, bool ctrl, bool shift);
+void keyRelease(SampleChannel* ch, bool ctrl, bool shift);
 
 /* start/stopActionRec
 Handles the action recording. If gui == true the signal comes from an user
 interaction, otherwise it's a MIDI/Jack/external signal. */
 
-void glue_startStopActionRec(bool gui=true);
-void glue_startActionRec(bool gui=true);
-void glue_stopActionRec(bool gui=true);
+void startStopActionRec(bool gui=true);
+void startActionRec(bool gui=true);
+void stopActionRec(bool gui=true);
 
 /* start/stopInputRec
 Handles the input recording (take). If gui == true the signal comes from an
 internal interaction on the GUI, otherwise it's a MIDI/Jack/external signal. */
 
-void glue_startStopInputRec(bool gui=true);
-int  glue_startInputRec    (bool gui=true);
-int  glue_stopInputRec     (bool gui=true);
+void startStopInputRec(bool gui=true);
+int  startInputRec    (bool gui=true);
+int  stopInputRec     (bool gui=true);
 
+}}} // giada::c::io::
 
 #endif
index bd4e9f014b57c71352b6ff86a23add6694a3b8bb..da35360699b66ed9ae73082567d21f9210216fdc 100644 (file)
@@ -54,9 +54,6 @@
 extern gdMainWindow *G_MainWin;
 
 
-using namespace giada::m;
-
-
 namespace giada {
 namespace c     {
 namespace sampleEditor
@@ -105,7 +102,7 @@ void setBeginEnd(SampleChannel* ch, int b, int e)
 void cut(SampleChannel* ch, int a, int b)
 {
        copy(ch, a, b);
-       if (!wfx::cut(ch->wave, a, b)) {
+       if (!m::wfx::cut(ch->wave, a, b)) {
                gdAlert("Unable to cut the sample!");
                return;
        }
@@ -125,7 +122,7 @@ void copy(SampleChannel* ch, int a, int b)
        if (m_waveBuffer != nullptr)
                delete m_waveBuffer;
 
-       int result = waveManager::createFromWave(ch->wave, a, b, &m_waveBuffer);
+       int result = m::waveManager::createFromWave(ch->wave, a, b, &m_waveBuffer);
        if (result != G_RES_OK) {
                gu_log("[sampleEditor::copy] unable to create wave buffer!\n");
                return;
@@ -143,7 +140,7 @@ void paste(SampleChannel* ch, int a)
                return;
        }
        
-       wfx::paste(m_waveBuffer, ch->wave, a);
+       m::wfx::paste(m_waveBuffer, ch->wave, a);
 
        /* Shift begin/end points to keep the previous position. */
 
@@ -165,7 +162,7 @@ void paste(SampleChannel* ch, int a)
 
 void silence(SampleChannel* ch, int a, int b)
 {
-       wfx::silence(ch->wave, a, b);
+       m::wfx::silence(ch->wave, a, b);
        gdSampleEditor* gdEditor = getSampleEditorWindow();
        gdEditor->waveTools->waveform->refresh();
 }
@@ -176,7 +173,7 @@ void silence(SampleChannel* ch, int a, int b)
 
 void fade(SampleChannel* ch, int a, int b, int type)
 {
-       wfx::fade(ch->wave, a, b, type);
+       m::wfx::fade(ch->wave, a, b, type);
        gdSampleEditor* gdEditor = getSampleEditorWindow();
        gdEditor->waveTools->waveform->refresh();
 }
@@ -187,7 +184,7 @@ void fade(SampleChannel* ch, int a, int b, int type)
 
 void smoothEdges(SampleChannel* ch, int a, int b)
 {
-       wfx::smooth(ch->wave, a, b);
+       m::wfx::smooth(ch->wave, a, b);
        gdSampleEditor* gdEditor = getSampleEditorWindow();
        gdEditor->waveTools->waveform->refresh();
 }
@@ -198,7 +195,7 @@ void smoothEdges(SampleChannel* ch, int a, int b)
 
 void reverse(SampleChannel* ch, int a, int b)
 {
-       wfx::reverse(ch->wave, a, b);
+       m::wfx::reverse(ch->wave, a, b);
        gdSampleEditor* gdEditor = getSampleEditorWindow();
        gdEditor->waveTools->waveform->refresh();
 }
@@ -209,7 +206,7 @@ void reverse(SampleChannel* ch, int a, int b)
 
 void normalizeHard(SampleChannel* ch, int a, int b)
 {
-       wfx::normalizeHard(ch->wave, a, b);
+       m::wfx::normalizeHard(ch->wave, a, b);
        gdSampleEditor* gdEditor = getSampleEditorWindow();
        gdEditor->waveTools->waveform->refresh();
 }
@@ -220,7 +217,7 @@ void normalizeHard(SampleChannel* ch, int a, int b)
 
 void trim(SampleChannel* ch, int a, int b)
 {
-       if (!wfx::trim(ch->wave, a, b)) {
+       if (!m::wfx::trim(ch->wave, a, b)) {
                gdAlert("Unable to trim the sample!");
                return;
        }
@@ -272,11 +269,11 @@ void rewindPreview(SampleChannel* ch)
 
 void toNewChannel(SampleChannel* ch, int a, int b)
 {
-       SampleChannel* newCh = static_cast<SampleChannel*>(glue_addChannel(
+       SampleChannel* newCh = static_cast<SampleChannel*>(c::channel::addChannel(
                ch->guiChannel->getColumnIndex(), CHANNEL_SAMPLE, G_GUI_CHANNEL_H_1));
 
        Wave* wave = nullptr;
-       int result = waveManager::createFromWave(ch->wave, a, b, &wave);
+       int result = m::waveManager::createFromWave(ch->wave, a, b, &wave);
        if (result != G_RES_OK) {
                gdAlert("Unable to copy to new channel!");
                return;
@@ -301,7 +298,7 @@ bool isWaveBufferFull()
 
 void shift(SampleChannel* ch, int offset)
 {
-       wfx::shift(ch->wave, offset - ch->getShift());
+       m::wfx::shift(ch->wave, offset - ch->getShift());
        ch->setShift(offset);
        gdSampleEditor* gdEditor = getSampleEditorWindow();
        gdEditor->shiftTool->refresh();
index 726918e1d37d17723e575cfed3ab288da4d8b0b6..8fc44d8577c75ddae17572ef0373cef6b1b88949 100644 (file)
@@ -58,13 +58,15 @@ extern gdMainWindow *G_MainWin;
 
 using std::string;
 using std::vector;
-using namespace giada::m;
+using namespace giada;
 
 
 #ifdef WITH_VST
 
-static void glue_fillPatchGlobalsPlugins__(vector <Plugin *> *host, vector<patch::plugin_t> *patch)
+static void glue_fillPatchGlobalsPlugins__(vector <Plugin*>* host, vector<m::patch::plugin_t>* patch)
 {
+       using namespace giada::m;
+
        for (unsigned i=0; i<host->size(); i++) {
                Plugin *pl = host->at(i);
                patch::plugin_t ppl;
@@ -85,6 +87,8 @@ static void glue_fillPatchGlobalsPlugins__(vector <Plugin *> *host, vector<patch
 
 static void glue_fillPatchColumns__()
 {
+       using namespace giada::m;
+
        for (unsigned i=0; i<G_MainWin->keyboard->getTotalColumns(); i++) {
                geColumn *gCol = G_MainWin->keyboard->getColumn(i);
                patch::column_t pCol;
@@ -110,6 +114,8 @@ static void glue_fillPatchColumns__()
 
 static void glue_fillPatchChannels__(bool isProject)
 {
+       using namespace giada::m;
+
        for (unsigned i=0; i<mixer::channels.size(); i++) {
                mixer::channels.at(i)->writePatch(i, isProject);
        }
@@ -121,6 +127,8 @@ static void glue_fillPatchChannels__(bool isProject)
 
 static void glue_fillPatchGlobals__(const string &name)
 {
+       using namespace giada::m;
+
        patch::version      = G_VERSION_STR;
        patch::versionMajor = G_VERSION_MAJOR;
        patch::versionMinor = G_VERSION_MINOR;
@@ -151,6 +159,8 @@ static void glue_fillPatchGlobals__(const string &name)
 static bool glue_savePatch__(const string &fullPath, const string &name,
                bool isProject)
 {
+       using namespace giada::m;
+
        patch::init();
 
        glue_fillPatchGlobals__(name);
@@ -177,6 +187,8 @@ static string glue_makeSamplePath__(const string& base, const Wave* w, int k)
 
 static string glue_makeUniqueSamplePath__(const string& base, const SampleChannel* ch)
 {
+       using namespace giada::m;
+
        string path = base + G_SLASH + ch->wave->getBasename(true);
        if (mh::uniqueSamplePath(ch, path))
                return path;
@@ -208,7 +220,7 @@ void glue_savePatch(void* data)
                        return;
 
        if (glue_savePatch__(fullPath, name, false)) {  // false == not a project
-               conf::patchPath = gu_dirname(fullPath);
+               m::conf::patchPath = gu_dirname(fullPath);
                browser->do_callback();
        }
        else
@@ -221,6 +233,8 @@ void glue_savePatch(void* data)
 
 void glue_loadPatch(void* data)
 {
+       using namespace giada::m;
+
        gdBrowserLoad* browser = (gdBrowserLoad*) data;
        string fullPath        = browser->getSelectedItem();
        bool isProject         = gu_isProject(browser->getSelectedItem());
@@ -269,7 +283,7 @@ void glue_loadPatch(void* data)
                unsigned k = 0;
                for (const patch::channel_t& pch : patch::channels) {
                        if (pch.column == col.index) {
-                               Channel* ch = glue_addChannel(pch.column, pch.type, pch.size);
+                               Channel* ch = c::channel::addChannel(pch.column, pch.type, pch.size);
                                ch->readPatch(basePath, k, &mixer::mutex_plugins, conf::samplerate,
                                        conf::rsmpQuality);
                        }
@@ -317,6 +331,8 @@ void glue_loadPatch(void* data)
 
 void glue_saveProject(void* data)
 {
+       using namespace giada::m;
+
        gdBrowserSave* browser = (gdBrowserSave*) data;
        string name            = gu_stripExt(browser->getName());
        string folderPath      = browser->getCurrentPath();
@@ -378,11 +394,11 @@ void glue_loadSample(void* data)
        if (fullPath.empty())
                return;
 
-       int res = glue_loadChannel(static_cast<SampleChannel*>(browser->getChannel()), 
+       int res = c::channel::loadChannel(static_cast<SampleChannel*>(browser->getChannel()), 
                fullPath);
 
        if (res == G_RES_OK) {
-               conf::samplePath = gu_dirname(fullPath);
+               m::conf::samplePath = gu_dirname(fullPath);
                browser->do_callback();
                G_MainWin->delSubWindow(WID_SAMPLE_EDITOR); // if editor is open
        }
@@ -396,6 +412,8 @@ void glue_loadSample(void* data)
 
 void glue_saveSample(void *data)
 {
+       using namespace giada::m;
+
        gdBrowserSave* browser = (gdBrowserSave*) data;
        string name            = browser->getName();
        string folderPath      = browser->getCurrentPath();
index ed1f72b64e4d55f1fc26d0e6f874fbff7ab1289f..b0b05b528e4a2562fbc361400d8e58d459167eb0 100644 (file)
@@ -100,7 +100,7 @@ gdBrowserBase::~gdBrowserBase()
        conf::browserW = w();
        conf::browserH = h();
        conf::browserPosition = browser->position();
-       conf::browserLastPath = gu_dirname(browser->getSelectedItem());
+       conf::browserLastPath = browser->getCurrentDir();
        conf::browserLastValue = browser->value();
 }
 
@@ -118,22 +118,7 @@ void gdBrowserBase::cb_toggleHiddenFiles(Fl_Widget *v, void *p) { ((gdBrowserBas
 
 void gdBrowserBase::cb_up()
 {
-       string dir = browser->getCurrentDir();
-
-       /* Take 'dir' path and remove all chars up to the next slash, e.g.:
-               /path/to/my/dir -> /path/to/my
-       Make sure not to remove the leading '/' (OS X/Linux only). */
-
-       dir = dir.substr(0, dir.find_last_of(G_SLASH_STR));
-
-#if defined(G_OS_MAC) || defined(G_OS_LINUX)
-
-       if (dir.empty())
-               dir = G_SLASH_STR;
-
-#endif
-
-       browser->loadDir(dir);
+       browser->loadDir(gu_getUpDir(browser->getCurrentDir()));
        where->value(browser->getCurrentDir().c_str());
 }
 
index dca6fcaff70f18a140bb0f10971bdb286563ad5a..f2423a21b4713f8db2d842bd421e75f24f08ab0a 100644 (file)
 #include "channelNameInput.h"
 
 
-using namespace giada::m;
+using namespace giada;
 
 
 gdChannelNameInput::gdChannelNameInput(Channel* ch)
 : gdWindow(400, 64, "New channel name"),
   m_ch    (ch)
 {
+       using namespace giada::m;
+
        if (conf::nameX)
                resize(conf::nameX, conf::nameY, w(), h());
 
@@ -70,8 +72,8 @@ gdChannelNameInput::gdChannelNameInput(Channel* ch)
 
 gdChannelNameInput::~gdChannelNameInput()
 {
-       conf::nameX = x();
-       conf::nameY = y();
+       m::conf::nameX = x();
+       m::conf::nameY = y();
 }
 
 
@@ -96,6 +98,6 @@ void gdChannelNameInput::cb_cancel()
 
 void gdChannelNameInput::cb_update()
 {
-       glue_setName(m_ch, m_name->value());
+       c::channel::setName(m_ch, m_name->value());
        do_callback();
 }
index 1066099809a285bee0f7fc086e1ebdd411e944d7..d03714f075210833a5e0a64282bdabb0ea1006d0 100644 (file)
@@ -43,7 +43,7 @@
 extern gdMainWindow *G_MainWin;
 
 
-gdMainWindow::gdMainWindow(int W, int H, const char *title, int argc, char **argv)
+gdMainWindow::gdMainWindow(int W, int H, const char* title, int argc, char** argv)
        : gdWindow(W, H, title)
 {
        Fl::visible_focus(0);
@@ -58,7 +58,7 @@ gdMainWindow::gdMainWindow(int W, int H, const char *title, int argc, char **arg
   Fl::set_boxtype(FL_UP_BOX,     G_CUSTOM_UP_BOX);
   Fl::set_boxtype(FL_DOWN_BOX,   G_CUSTOM_DOWN_BOX);
 
-       size_range(G_GUI_WIDTH, G_GUI_HEIGHT);
+       size_range(G_MIN_GUI_WIDTH, G_MIN_GUI_HEIGHT);
 
        mainMenu      = new geMainMenu(8, -1);
        mainIO        = new geMainIO(412, 8);
@@ -69,21 +69,21 @@ gdMainWindow::gdMainWindow(int W, int H, const char *title, int argc, char **arg
 
        /* zone 1 - menus, and I/O tools */
 
-       Fl_Group *zone1 = new Fl_Group(8, 8, W-16, 20);
+       Fl_Groupzone1 = new Fl_Group(8, 8, W-16, 20);
        zone1->add(mainMenu);
        zone1->resizable(new Fl_Box(300, 8, 80, 20));
        zone1->add(mainIO);
 
        /* zone 2 - mainTransport and timing tools */
 
-       Fl_Group *zone2 = new Fl_Group(8, mainTransport->y(), W-16, mainTransport->h());
+       Fl_Groupzone2 = new Fl_Group(8, mainTransport->y(), W-16, mainTransport->h());
        zone2->add(mainTransport);
        zone2->resizable(new Fl_Box(mainTransport->x()+mainTransport->w()+4, zone2->y(), 80, 20));
        zone2->add(mainTimer);
 
        /* zone 3 - beat meter */
 
-       Fl_Group *zone3 = new Fl_Group(8, beatMeter->y(), W-16, beatMeter->h());
+       Fl_Groupzone3 = new Fl_Group(8, beatMeter->y(), W-16, beatMeter->h());
        zone3->add(beatMeter);
 
        /* zone 4 - the keyboard (Fl_Group is unnecessary here, keyboard is
@@ -105,13 +105,13 @@ gdMainWindow::gdMainWindow(int W, int H, const char *title, int argc, char **arg
 /* -------------------------------------------------------------------------- */
 
 
-void gdMainWindow::cb_endprogram(Fl_Widget *v, void *p) { G_MainWin->__cb_endprogram(); }
+void gdMainWindow::cb_endprogram(Fl_Widget* v, void* p) { G_MainWin->cb_endprogram(); }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void gdMainWindow::__cb_endprogram()
+void gdMainWindow::cb_endprogram()
 {
        if (!gdConfirmWin("Warning", "Quit Giada: are you sure?"))
                return;
index 64a6733106f9eb4b90cf5980e00691416e4ddd13..8d7616ec62f250c1ef18dc9bd5fd14061ee7fdaa 100644 (file)
@@ -45,19 +45,19 @@ class gdMainWindow : public gdWindow
 {
 private:
 
-       static void cb_endprogram  (Fl_Widget *v, void *p);
-       inline void __cb_endprogram();
+       static void cb_endprogram(Fl_Widget* v, void* p);
+       inline void cb_endprogram();
 
 public:
 
-       geKeyboard      *keyboard;
-       geBeatMeter     *beatMeter;
-       geMainMenu      *mainMenu;
-       geMainIO        *mainIO;
-  geMainTimer     *mainTimer;
-       geMainTransport *mainTransport;
+       geKeyboardkeyboard;
+       geBeatMeterbeatMeter;
+       geMainMenumainMenu;
+       geMainIOmainIO;
+  geMainTimermainTimer;
+       geMainTransportmainTransport;
 
-       gdMainWindow(int w, int h, const char *title, int argc, char **argv);
+       gdMainWindow(int w, int h, const char* title, int argc, char** argv);
 };
 
 
index 4992bb4ce779ffced4fde538c6ad885ba420f3b9..dffd2989111dab17a600e2332b588c8559fafc16 100644 (file)
@@ -59,18 +59,22 @@ gdMidiInputChannel::gdMidiInputChannel(Channel* ch)
        label(title.c_str());
        size_range(G_DEFAULT_MIDI_INPUT_UI_W, G_DEFAULT_MIDI_INPUT_UI_H);
 
-       Fl_Group* groupHeader = new Fl_Group(G_GUI_OUTER_MARGIN, G_GUI_OUTER_MARGIN, w(), 20);
+       int extra = ch->type == CHANNEL_SAMPLE ? 28 : 0;
+
+       Fl_Group* groupHeader = new Fl_Group(G_GUI_OUTER_MARGIN, G_GUI_OUTER_MARGIN, w(), 20 + extra);
        groupHeader->begin();
 
                enable = new geCheck(G_GUI_OUTER_MARGIN, G_GUI_OUTER_MARGIN, 120, G_GUI_UNIT, 
-                       "enable MIDI input");
+                       "Enable MIDI input");
                channel = new geChoice(enable->x()+enable->w()+44, G_GUI_OUTER_MARGIN, 120, G_GUI_UNIT);
+               veloAsVol = new geCheck(G_GUI_OUTER_MARGIN, enable->y()+enable->h()+G_GUI_OUTER_MARGIN  , 120, G_GUI_UNIT, 
+                       "Velocity drives volume (one-shot only)");
 
        groupHeader->resizable(nullptr);
        groupHeader->end();
 
-       container = new geScroll(G_GUI_OUTER_MARGIN, enable->y()+enable->h()+G_GUI_OUTER_MARGIN, 
-               w()-16, h()-76);
+       container = new geScroll(G_GUI_OUTER_MARGIN, groupHeader->y()+groupHeader->h()+G_GUI_OUTER_MARGIN, 
+               w()-16, h()-72-extra);
        container->begin();
 
                addChannelLearners();
@@ -94,6 +98,13 @@ gdMidiInputChannel::gdMidiInputChannel(Channel* ch)
        enable->value(ch->midiIn);
        enable->callback(cb_enable, (void*)this);
 
+       if (ch->type == CHANNEL_SAMPLE) {
+               veloAsVol->value(static_cast<SampleChannel*>(ch)->midiInVeloAsVol);
+               veloAsVol->callback(cb_veloAsVol, (void*)this); 
+       }
+       else
+               veloAsVol->hide();
+
        channel->add("Channel (any)");
        channel->add("Channel 1");
        channel->add("Channel 2");
@@ -201,6 +212,7 @@ void gdMidiInputChannel::addPluginLearners()
 
 void gdMidiInputChannel::cb_enable(Fl_Widget* w, void* p) { ((gdMidiInputChannel*)p)->cb_enable(); }
 void gdMidiInputChannel::cb_setChannel(Fl_Widget* w, void* p) { ((gdMidiInputChannel*)p)->cb_setChannel(); }
+void gdMidiInputChannel::cb_veloAsVol(Fl_Widget* w, void* p) { ((gdMidiInputChannel*)p)->cb_veloAsVol(); }
 
 
 /* -------------------------------------------------------------------------- */
@@ -216,6 +228,15 @@ void gdMidiInputChannel::cb_enable()
 /* -------------------------------------------------------------------------- */
 
 
+void gdMidiInputChannel::cb_veloAsVol()
+{
+       static_cast<SampleChannel*>(ch)->midiInVeloAsVol = veloAsVol->value();
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
 void gdMidiInputChannel::cb_setChannel()
 {
        ch->setMidiInFilter(channel->value() == 0 ? -1 : channel->value() - 1);
index 523ab66807a2a4f9ac094e2f818494de52a8db81..26e50bb56c6d021e2709a13dbcf3a35dc51160f1 100644 (file)
@@ -48,12 +48,15 @@ private:
 
        geScroll* container;
        geCheck*  enable;
+       geCheck*  veloAsVol;
        geChoice* channel;
 
        static void cb_enable(Fl_Widget* w, void* p);
        static void cb_setChannel(Fl_Widget* w, void* p);
+       static void cb_veloAsVol(Fl_Widget* w, void* p);
        void cb_enable();
        void cb_setChannel();
+       void cb_veloAsVol();
 
        void addChannelLearners();
 
index e02c1a63421f15d12e8a62bb43b03551d6f3c196..cd12d6ce66966c13e84ef8a929e5855daf2bc774 100644 (file)
@@ -61,13 +61,13 @@ gdMidiOutputSampleCh::gdMidiOutputSampleCh(SampleChannel* ch)
 /* -------------------------------------------------------------------------- */
 
 
-void gdMidiOutputSampleCh::cb_close(Fl_Widget *w, void *p) { ((gdMidiOutputSampleCh*)p)->__cb_close(); }
+void gdMidiOutputSampleCh::cb_close(Fl_Widget* w, void* p) { ((gdMidiOutputSampleCh*)p)->cb_close(); }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void gdMidiOutputSampleCh::__cb_close()
+void gdMidiOutputSampleCh::cb_close()
 {
        ch->midiOutL = enableLightning->value();
        do_callback();
index 3b956d319bc4aad1025a7e85255e0055b3c8208e..7b679b1e094adea00eafa1f50b520844993ec868 100644 (file)
@@ -39,17 +39,17 @@ class gdMidiOutputSampleCh : public gdMidiOutputBase
 {
 private:
 
-       SampleChannel *ch;
+       SampleChannelch;
 
-       /* __cb_close
-       override parent method, we need to do more stuff on close. */
+       /* cb_close
+       Override parent method, we need to do more stuff on close. */
 
-       static void cb_close  (Fl_Widget *w, void *p);
-       inline void __cb_close();
+       static void cb_close(Fl_Widget* w, void* p);
+       inline void cb_close();
 
 public:
 
-       gdMidiOutputSampleCh(SampleChannel *ch);
+       gdMidiOutputSampleCh(SampleChannelch);
 };
 
 #endif
index 9e98a716558774d08cffe558096fe624071e4e2d..275f5d7ae2409f29481924b5ac97308ac6b30830 100644 (file)
 
 
 using std::string;
-using namespace giada::m;
-using namespace giada::c;
+using namespace giada;
 
 
 gdSampleEditor::gdSampleEditor(SampleChannel* ch)
   : gdWindow(640, 480),
     ch(ch)
 {
+  using namespace giada::m;
+
   Fl_Group* upperBar = createUpperBar();
   
   waveTools = new geWaveTools(G_GUI_OUTER_MARGIN, upperBar->y()+upperBar->h()+G_GUI_OUTER_MARGIN, 
@@ -101,13 +102,13 @@ gdSampleEditor::gdSampleEditor(SampleChannel* ch)
 
 gdSampleEditor::~gdSampleEditor()
 {
-  conf::sampleEditorX = x();
-  conf::sampleEditorY = y();
-  conf::sampleEditorW = w();
-  conf::sampleEditorH = h();
-  conf::sampleEditorGridVal = atoi(grid->text());
-  conf::sampleEditorGridOn  = snap->value();
-  sampleEditor::setPreview(ch, G_PREVIEW_NONE);
+  m::conf::sampleEditorX = x();
+  m::conf::sampleEditorY = y();
+  m::conf::sampleEditorW = w();
+  m::conf::sampleEditorH = h();
+  m::conf::sampleEditorGridVal = atoi(grid->text());
+  m::conf::sampleEditorGridOn  = snap->value();
+  c::sampleEditor::setPreview(ch, G_PREVIEW_NONE);
 }
 
 
@@ -116,6 +117,8 @@ gdSampleEditor::~gdSampleEditor()
 
 Fl_Group* gdSampleEditor::createUpperBar()
 {
+  using namespace giada::m;
+
   Fl_Group* g = new Fl_Group(G_GUI_OUTER_MARGIN, G_GUI_OUTER_MARGIN, w()-16, G_GUI_UNIT);
   g->begin();
     grid    = new geChoice(g->x(), g->y(), 50, G_GUI_UNIT);
@@ -274,6 +277,8 @@ void gdSampleEditor::cb_enableSnap()
 
 void gdSampleEditor::cb_togglePreview()
 {
+  using namespace giada::c;
+
        if (play->value())
        sampleEditor::setPreview(ch, G_PREVIEW_NONE);
        else
@@ -283,7 +288,7 @@ void gdSampleEditor::cb_togglePreview()
 
 void gdSampleEditor::cb_rewindPreview()
 {
-       sampleEditor::rewindPreview(ch);
+       c::sampleEditor::rewindPreview(ch);
 }
 
 
@@ -292,16 +297,18 @@ void gdSampleEditor::cb_rewindPreview()
 
 void gdSampleEditor::cb_reload()
 {
+  using namespace giada::c;
+
   /* TODO - move to glue::sampleEditor */
   if (!gdConfirmWin("Warning", "Reload sample: are you sure?"))
     return;
 
-  if (glue_loadChannel(ch, ch->wave->getPath()) != G_RES_OK)
+  if (channel::loadChannel(ch, ch->wave->getPath()) != G_RES_OK)
     return;
 
-  glue_setBoost(ch, G_DEFAULT_BOOST);
-  glue_setPitch(ch, G_DEFAULT_PITCH);
-  glue_setPanning(ch, 0.5f);
+  channel::setBoost(ch, G_DEFAULT_BOOST);
+  channel::setPitch(ch, G_DEFAULT_PITCH);
+  channel::setPanning(ch, 0.5f);
 
   panTool->refresh();
   boostTool->refresh();
index ebc8837d08faf35d23815993df071a870543508c..00f95f1141afd6c7337ef7b6c3c00aaf62fb593a 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "../../core/const.h"
 #include "../../utils/string.h"
+#include "../../utils/fs.h"
 #include "../dialogs/browser/browserBase.h"
 #include "basics/boxtypes.h"
 #include "browser.h"
@@ -37,7 +38,7 @@ using std::string;
 
 geBrowser::geBrowser(int x, int y, int w, int h)
  : Fl_File_Browser(x, y, w, h),
-   showHiddenFiles(false)
+   m_showHiddenFiles(false)
 {
        box(G_CUSTOM_BORDER_BOX);
        textsize(G_GUI_FONT_SIZE_BASE);
@@ -65,18 +66,18 @@ geBrowser::geBrowser(int x, int y, int w, int h)
 
 void geBrowser::toggleHiddenFiles()
 {
-  showHiddenFiles = !showHiddenFiles;
-  loadDir(currentDir);
+  m_showHiddenFiles = !m_showHiddenFiles;
+  loadDir(m_currentDir);
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void geBrowser::loadDir(const string &dir)
+void geBrowser::loadDir(const stringdir)
 {
-  currentDir = dir;
-  load(currentDir.c_str());
+  m_currentDir = dir;
+  load(m_currentDir.c_str());
 
   /* Clean up unwanted elements. Hide "../" first, it just screws up things.
   Also remove hidden files, if requested. */
@@ -84,7 +85,7 @@ void geBrowser::loadDir(const string &dir)
   for (int i=size(); i>=0; i--) {
     if (text(i) == nullptr)
       continue;
-    if (strcmp(text(i), "../") == 0 || (!showHiddenFiles && strncmp(text(i), ".", 1) == 0))
+    if (strcmp(text(i), "../") == 0 || (!m_showHiddenFiles && strncmp(text(i), ".", 1) == 0))
       remove(i);
   }
 }
@@ -108,12 +109,12 @@ int geBrowser::handle(int e)
         select(value() - 1);
       else
       if (Fl::event_key(FL_Enter))
-        ((gdBrowserBase*) parent())->fireCallback();
+        static_cast<gdBrowserBase*>(parent())->fireCallback();
       ret = 1;
       break;
     case FL_PUSH:    // mouse
       if (Fl::event_clicks() > 0)  // double click
-        ((gdBrowserBase*) parent())->fireCallback();
+        static_cast<gdBrowserBase*>(parent())->fireCallback();
       ret = 1;
       break;
     case FL_RELEASE: // mouse
@@ -137,7 +138,7 @@ int geBrowser::handle(int e)
 
 string geBrowser::getCurrentDir()
 {
-  return normalize(gu_getRealPath(currentDir));
+  return normalize(gu_getRealPath(m_currentDir));
 }
 
 
@@ -150,9 +151,15 @@ string geBrowser::getSelectedItem(bool fullPath)
     return normalize(text(value()));
   else
   if (value() == 0)  // no rows selected? return current directory
-    return normalize(currentDir);
-  else
-    return normalize(gu_getRealPath(currentDir + G_SLASH + normalize(text(value()))));
+    return normalize(m_currentDir);
+  else {
+#ifdef G_OS_WINDOWS
+    string sep = m_currentDir != "" ? G_SLASH_STR : "";
+#else
+    string sep = G_SLASH_STR;
+#endif
+    return normalize(gu_getRealPath(m_currentDir + sep + normalize(text(value()))));
+  }
 }
 
 
@@ -169,20 +176,15 @@ void geBrowser::preselect(int pos, int line)
 /* -------------------------------------------------------------------------- */
 
 
-string geBrowser::normalize(const string &s)
+string geBrowser::normalize(const strings)
 {
   string out = s;
 
-  /* If string ends with G_SLASH, remove it. Don't do it if has length > 1, it
-  means that the string is just '/'. Note: our crappy version of Clang doesn't
-  seem to support std::string::back() */
-
-#ifdef __APPLE__
-  if (out[out.length() - 1] == G_SLASH && out.length() > 1)
-#else
-  if (out.back() == G_SLASH && out.length() > 1)
-#endif
+  /* If string ends with G_SLASH, remove it. Don't do it if is the root dir, 
+  that is '/' on Unix or '[x]:\' on Windows. */
 
+  //if (out.back() == G_SLASH && out.length() > 1)
+  if (out.back() == G_SLASH && !gu_isRootDir(s))
     out = out.substr(0, out.size()-1);
   return out;
 }
index ef0aa07c04fd560bcce8e7889bed8ad43b4a1ec3..25db7e83c4dac811446a7c926842f1fc621c004a 100644 (file)
@@ -39,11 +39,11 @@ class geBrowser : public Fl_File_Browser
 {
 private:
 
-       std::string currentDir;
-  bool showHiddenFiles;
+       std::string m_currentDir;
+  bool m_showHiddenFiles;
 
        /* normalize
-        * Make sure the std::string never ends with a trailing slash. */
+       Makes sure the std::string never ends with a trailing slash. */
 
        std::string normalize(const std::string &s);
 
@@ -54,13 +54,13 @@ public:
   void toggleHiddenFiles();
 
        /* init
-        * Initialize browser and show 'dir' as initial directory. */
+       Initializes browser and show 'dir' as initial directory. */
 
        void loadDir(const std::string &dir);
 
        /* getSelectedItem
-        * Return the full path or just the displayed name of the i-th selected item.
-        * Always with the trailing slash! */
+       Returns the full path or just the displayed name of the i-th selected item.
+       Always with the trailing slash! */
 
        std::string getSelectedItem(bool fullPath=true);
 
index 7c27e409cc645fb63914f73bb2301e21da99deb4..baf56d4355c5547d917626c3bd178ed074c2ebaa 100644 (file)
@@ -63,7 +63,9 @@ geTabAudio::geTabAudio(int X, int Y, int W, int H)
                 new geBox(x(), rsmpQuality->y()+rsmpQuality->h()+8, w(), 92,
                                                                                "Restart Giada for the changes to take effect.");
        end();
+
        labelsize(G_GUI_FONT_SIZE_BASE);
+       selection_color(G_COLOR_GREY_4);
 
        soundsys->add("(none)");
 
index 4c50efc0abdc7449afd74ef02b4b49dc6ab6d74b..b6a57c4c4c704e216e6338b5c88d0c6dcdab5dc7 100644 (file)
@@ -61,6 +61,7 @@ geTabBehaviors::geTabBehaviors(int X, int Y, int W, int H)
   end();
 
        labelsize(G_GUI_FONT_SIZE_BASE);
+       selection_color(G_COLOR_GREY_4);
 
        conf::recsStopOnChanHalt == 1 ? recsStopOnChanHalt_1->value(1) : recsStopOnChanHalt_0->value(1);
        conf::chansStopOnSeqHalt == 1 ? chansStopOnSeqHalt_1->value(1) : chansStopOnSeqHalt_0->value(1);
index dbe3e6accf2bc6cfdc39a4798243f5430a5e1655..b35e0d0ba67b80cbccb7869570263939c062b7ed 100644 (file)
@@ -60,6 +60,7 @@ geTabMidi::geTabMidi(int X, int Y, int W, int H)
        end();
 
        labelsize(G_GUI_FONT_SIZE_BASE);
+       selection_color(G_COLOR_GREY_4);
 
        system->callback(cb_changeSystem, (void*)this);
 
index 7f1ab07885d111cc5748dd56b0b33ec0a1720474..b1f4e2dc4fd607fbbd18d90118303c31b853b5dc 100644 (file)
@@ -46,6 +46,7 @@ geTabMisc::geTabMisc(int X, int Y, int W, int H)
        debugMsg->add("To file");
 
        labelsize(G_GUI_FONT_SIZE_BASE);
+       selection_color(G_COLOR_GREY_4);
 
        switch (conf::logMode) {
                case LOG_MODE_MUTE:
index 96b3acb67689855ba0fc88a555439b672af9e43b..d9074a67ca64cf54fae47c03262e8d4eb5ab0cf8 100644 (file)
@@ -67,6 +67,7 @@ geTabPlugins::geTabPlugins(int X, int Y, int W, int H)
        end();
 
        labelsize(G_GUI_FONT_SIZE_BASE);
+       selection_color(G_COLOR_GREY_4);
 
        m_info->label("Scan in progress. Please wait...");
        m_info->hide();
index 36c71401f905ff679c42df147c748e3816b2706c..a222174c105b83b9aa30e39ca82eb27dbd452039 100644 (file)
@@ -46,7 +46,7 @@
 extern gdMainWindow* G_MainWin;
 
 
-using namespace giada::m;
+using namespace giada;
 
 
 geChannel::geChannel(int X, int Y, int W, int H, int type, Channel* ch)
@@ -74,7 +74,7 @@ void geChannel::cb_openFxWindow(Fl_Widget* v, void* p) { ((geChannel*)p)->cb_ope
 
 void geChannel::cb_arm()
 {
-       glue_toggleArm(ch, true);
+       c::channel::toggleArm(ch, true);
 }
 
 
@@ -83,7 +83,7 @@ void geChannel::cb_arm()
 
 void geChannel::cb_mute()
 {
-       glue_toggleMute(ch);
+       c::channel::toggleMute(ch);
 }
 
 
@@ -92,7 +92,7 @@ void geChannel::cb_mute()
 
 void geChannel::cb_solo()
 {
-       solo->value() ? glue_setSoloOn(ch) : glue_setSoloOff(ch);
+       solo->value() ? c::channel::setSoloOn(ch) : c::channel::setSoloOff(ch);
 }
 
 
@@ -101,7 +101,7 @@ void geChannel::cb_solo()
 
 void geChannel::cb_changeVol()
 {
-       glue_setVolume(ch, vol->value());
+       c::channel::setVolume(ch, vol->value());
 }
 
 
@@ -111,7 +111,7 @@ void geChannel::cb_changeVol()
 #ifdef WITH_VST
 void geChannel::cb_openFxWindow()
 {
-       gu_openSubWindow(G_MainWin, new gdPluginList(pluginHost::CHANNEL, ch), WID_FX_LIST);
+       gu_openSubWindow(G_MainWin, new gdPluginList(m::pluginHost::CHANNEL, ch), WID_FX_LIST);
 }
 #endif
 
index 70c178c0c8d264f193e234520bf7828362ca384d..74861afef1c2879a1f109ce0c13ab1bc6924b232 100644 (file)
@@ -45,6 +45,7 @@
 
 using std::vector;
 using std::string;
+using namespace giada;
 
 
 geColumn::geColumn(int X, int Y, int W, int H, int index, geKeyboard* parent)
@@ -110,9 +111,9 @@ int geColumn::handle(int e)
                        int result = 0;
                        for (string& path : paths) {
                                gu_log("[geColumn::handle] loading %s...\n", path.c_str());
-                               SampleChannel* c = static_cast<SampleChannel*>(glue_addChannel(
+                               SampleChannel* c = static_cast<SampleChannel*>(c::channel::addChannel(
                                        m_index, CHANNEL_SAMPLE, G_GUI_CHANNEL_H_1));
-                               result = glue_loadChannel(c, gu_stripFileUrl(path));
+                               result = c::channel::loadChannel(c, gu_stripFileUrl(path));
                                if (result != G_RES_OK) {
                                        deleteChannel(c->guiChannel);
                                        fails = true;
@@ -255,7 +256,7 @@ void geColumn::__cb_addChannel()
        gu_log("[geColumn::__cb_addChannel] m_index = %d\n", m_index);
        int type = openTypeMenu();
        if (type)
-               glue_addChannel(m_index, type, G_GUI_CHANNEL_H_1);
+               c::channel::addChannel(m_index, type, G_GUI_CHANNEL_H_1);
 }
 
 
index 9872c669b9ef6e869200e30f780fe4ff83f2c2f1..5deaea930715d2223864d6cea86a1946829c884e 100644 (file)
@@ -214,6 +214,8 @@ so on should be moved to the proper widget: gdMainWindow or (better) geControlle
 
 int geKeyboard::handle(int e)
 {
+       using namespace giada::c;
+
        int ret = Fl_Group::handle(e);  // assume the buttons won't handle the Keyboard events
        switch (e) {
                case FL_FOCUS:
@@ -236,13 +238,13 @@ int geKeyboard::handle(int e)
                                }
                                else if (Fl::event_key() == FL_End && !endPressed) {
                                        endPressed = true;
-                                       glue_startStopInputRec(false);  // not from GUI
+                                       io::startStopInputRec(false);  // not from GUI
                                        ret = 1;
                                        break;
                                }
                                else if (Fl::event_key() == FL_Enter && !enterPressed) {
                                        enterPressed = true;
-                                       glue_startStopActionRec(false); // not from GUI
+                                       io::startStopActionRec(false); // not from GUI
                                        ret = 1;
                                        break;
                                }
index 5f17b2f49cad8e35db057cd6485f1ea575d3fe46..8e1957cd36341e8449427d9ab4c7a5ff790da61a 100644 (file)
@@ -55,7 +55,6 @@ extern gdMainWindow* G_MainWin;
 
 
 using std::string;
-using namespace giada;
 
 
 namespace
@@ -86,6 +85,8 @@ enum class Menu
 
 void menuCallback(Fl_Widget* w, void* v)
 {
+       using namespace giada;
+
        geMidiChannel* gch = static_cast<geMidiChannel*>(w);
        Menu selectedItem = (Menu) (intptr_t) v;
 
@@ -129,13 +130,13 @@ void menuCallback(Fl_Widget* w, void* v)
                        static_cast<geColumn*>(gch->parent())->repositionChannels();
                        break;
                case Menu::CLONE_CHANNEL:
-                       glue_cloneChannel(gch->ch);
+                       c::channel::cloneChannel(gch->ch);
                        break;          
                case Menu::RENAME_CHANNEL:
                        gu_openSubWindow(G_MainWin, new gdChannelNameInput(gch->ch), WID_SAMPLE_NAME);
                        break;
                case Menu::DELETE_CHANNEL:
-                       glue_deleteChannel(gch->ch);
+                       c::channel::deleteChannel(gch->ch);
                        break;
        }
 }
@@ -213,8 +214,10 @@ void geMidiChannel::cb_openMenu(Fl_Widget* v, void* p) { ((geMidiChannel*)p)->cb
 
 void geMidiChannel::cb_button()
 {
+       using namespace giada;
+       
        if (button->value())
-               glue_keyPress(ch, Fl::event_ctrl(), Fl::event_shift());
+               c::io::keyPress(static_cast<MidiChannel*>(ch), Fl::event_ctrl(), Fl::event_shift());
 }
 
 
@@ -299,7 +302,7 @@ void geMidiChannel::update()
 
        mainButton->label(label.c_str());
 
-       vol->value(mch->volume);
+       vol->value(mch->getVolume());
        mute->value(mch->mute);
        solo->value(mch->solo);
 
index c96b2eb40b4847fff015d4793e8187bdb10384be..08b582bc82d234b22cd77b47381711098f95818e 100644 (file)
@@ -61,9 +61,6 @@
 extern gdMainWindow* G_MainWin;
 
 
-using namespace giada;
-
-
 namespace
 {
 enum class Menu
@@ -100,12 +97,14 @@ enum class Menu
 
 void menuCallback(Fl_Widget* w, void* v)
 {
+       using namespace giada;
+
        geSampleChannel* gch = static_cast<geSampleChannel*>(w);
        Menu selectedItem = (Menu) (intptr_t) v;
 
        switch (selectedItem) {
                case Menu::INPUT_MONITOR: {
-                       glue_toggleInputMonitor(gch->ch);
+                       c::channel::toggleInputMonitor(gch->ch);
                        break;
                }
                case Menu::LOAD_SAMPLE: {
@@ -184,7 +183,7 @@ void menuCallback(Fl_Widget* w, void* v)
                        break;
                }
                case Menu::CLONE_CHANNEL: {
-                       glue_cloneChannel(gch->ch);
+                       c::channel::cloneChannel(gch->ch);
                        break;
                }
                case Menu::RENAME_CHANNEL: {
@@ -192,11 +191,11 @@ void menuCallback(Fl_Widget* w, void* v)
                        break;
                }
                case Menu::FREE_CHANNEL: {
-                       glue_freeChannel(gch->ch);
+                       c::channel::freeChannel(gch->ch);
                        break;
                }
                case Menu::DELETE_CHANNEL: {
-                       glue_deleteChannel(gch->ch);
+                       c::channel::deleteChannel(gch->ch);
                        break;
                }
        }
@@ -267,28 +266,32 @@ geSampleChannel::geSampleChannel(int X, int Y, int W, int H, SampleChannel* ch)
 /* -------------------------------------------------------------------------- */
 
 
-void geSampleChannel::cb_button      (Fl_Widget* v, void* p) { ((geSampleChannel*)p)->__cb_button(); }
-void geSampleChannel::cb_openMenu    (Fl_Widget* v, void* p) { ((geSampleChannel*)p)->__cb_openMenu(); }
-void geSampleChannel::cb_readActions (Fl_Widget* v, void* p) { ((geSampleChannel*)p)->__cb_readActions(); }
+void geSampleChannel::cb_button      (Fl_Widget* v, void* p) { ((geSampleChannel*)p)->cb_button(); }
+void geSampleChannel::cb_openMenu    (Fl_Widget* v, void* p) { ((geSampleChannel*)p)->cb_openMenu(); }
+void geSampleChannel::cb_readActions (Fl_Widget* v, void* p) { ((geSampleChannel*)p)->cb_readActions(); }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void geSampleChannel::__cb_button()
+void geSampleChannel::cb_button()
 {
-       if (button->value())    // pushed
-               glue_keyPress(ch, Fl::event_ctrl(), Fl::event_shift());
+       using namespace giada;
+
+       if (button->value())    // pushed, max velocity (127 i.e. 0x7f)
+               c::io::keyPress(ch, Fl::event_ctrl(), Fl::event_shift(), 0x7F);
        else                    // released
-               glue_keyRelease(ch, Fl::event_ctrl(), Fl::event_shift());
+               c::io::keyRelease(ch, Fl::event_ctrl(), Fl::event_shift());
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void geSampleChannel::__cb_openMenu()
+void geSampleChannel::cb_openMenu()
 {
+       using namespace giada;
+
        /* If you're recording (input or actions) no menu is allowed; you can't do
        anything, especially deallocate the channel */
 
@@ -357,9 +360,10 @@ void geSampleChannel::__cb_openMenu()
 /* -------------------------------------------------------------------------- */
 
 
-void geSampleChannel::__cb_readActions()
+void geSampleChannel::cb_readActions()
 {
-       glue_toggleReadingRecs(static_cast<SampleChannel*>(ch));
+       using namespace giada::c::channel;
+       toggleReadingRecs(static_cast<SampleChannel*>(ch));
 }
 
 
@@ -368,6 +372,8 @@ void geSampleChannel::__cb_readActions()
 
 void geSampleChannel::refresh()
 {
+       using namespace giada;
+       
        if (!mainButton->visible()) // mainButton invisible? status too (see below)
                return;
 
@@ -433,7 +439,7 @@ void geSampleChannel::update()
        modeBox->value(sch->mode);
        modeBox->redraw();
 
-       vol->value(sch->volume);
+       vol->value(sch->getVolume());
        mute->value(sch->mute);
        solo->value(sch->solo);
 
index 4cb99d0428f7d99889be994f6793f7a141085376..0d544c0f05348d41de217d5f151eedadffb517fd 100644 (file)
@@ -41,12 +41,12 @@ class geSampleChannel : public geChannel
 {
 private:
 
-       static void cb_button     (Fl_Widget* v, void* p);
-       static void cb_openMenu   (Fl_Widget* v, void* p);
+       static void cb_button(Fl_Widget* v, void* p);
+       static void cb_openMenu(Fl_Widget* v, void* p);
        static void cb_readActions(Fl_Widget* v, void* p);
-       void __cb_button     ();
-       void __cb_openMenu   ();
-       void __cb_readActions();
+       void cb_button();
+       void cb_openMenu();
+       void cb_readActions();
 
 public:
 
index 8ec528cd5a71d21eaf62ca69bc9bca81973b8e3a..405daa55c5699f5e8dd84014583ce985b76f3243 100644 (file)
@@ -40,6 +40,9 @@
 extern gdMainWindow* G_MainWin;
 
 
+using namespace giada;
+
+
 geSampleChannelButton::geSampleChannelButton(int x, int y, int w, int h,
        const char* l)
        : geChannelButton(x, y, w, h, l)
@@ -63,7 +66,7 @@ int geSampleChannelButton::handle(int e)
                case FL_PASTE: {
                        geSampleChannel* gch = static_cast<geSampleChannel*>(parent());
                        SampleChannel*   ch  = static_cast<SampleChannel*>(gch->ch);
-                       int result = glue_loadChannel(ch, gu_trim(gu_stripFileUrl(Fl::event_text())));
+                       int result = c::channel::loadChannel(ch, gu_trim(gu_stripFileUrl(Fl::event_text())));
                        if (result != G_RES_OK)
                                G_MainWin->keyboard->printChannelMessage(result);
                        ret = 1;
index 057ce67b094108bd9e9a8e0bbfdfbb0fec925c69..f61207d3ad77ef2ef401151cc5a488bffb49288d 100644 (file)
@@ -96,7 +96,8 @@ void geMainTransport::__cb_play()
 
 void geMainTransport::__cb_recAction()
 {
-       glue_startStopActionRec(true);
+       using namespace giada::c::io;
+       startStopActionRec(true);
 }
 
 
@@ -105,7 +106,8 @@ void geMainTransport::__cb_recAction()
 
 void geMainTransport::__cb_recInput()
 {
-       glue_startStopInputRec(true);
+       using namespace giada::c::io;
+       startStopInputRec(true);
 }
 
 
index f633afcd4c9d7aa9c8c907fdc5c91a05c99436bf..a0e1eaca563bf5771e32b6bd59317c0034deece2 100644 (file)
 #include "boostTool.h"
 
 
-using namespace giada::m;
-
-
-geBoostTool::geBoostTool(int X, int Y, SampleChannel *ch)
+geBoostTool::geBoostTool(int X, int Y, SampleChannel* ch)
   : Fl_Group(X, Y, 220, 20),
     ch      (ch)
 {
@@ -73,7 +70,9 @@ geBoostTool::geBoostTool(int X, int Y, SampleChannel *ch)
 
 void geBoostTool::refresh()
 {
-  input->value(gu_fToString(gu_linearToDB(ch->getBoost()), 2).c_str());  // 2 digits
+  using namespace giada::u;
+
+  input->value(gu_fToString(math::linearToDB(ch->getBoost()), 2).c_str());  // 2 digits
   // A dial greater than it's max value goes crazy
   dial->value(ch->getBoost() <= 10.0f ? ch->getBoost() : 10.0f);
 }
@@ -82,21 +81,23 @@ void geBoostTool::refresh()
 /* -------------------------------------------------------------------------- */
 
 
-void geBoostTool::cb_setBoost   (Fl_Widget *w, void *p) { ((geBoostTool*)p)->__cb_setBoost(); }
-void geBoostTool::cb_setBoostNum(Fl_Widget *w, void *p) { ((geBoostTool*)p)->__cb_setBoostNum(); }
-void geBoostTool::cb_normalize  (Fl_Widget *w, void *p) { ((geBoostTool*)p)->__cb_normalize(); }
+void geBoostTool::cb_setBoost   (Fl_Widget* w, void* p) { ((geBoostTool*)p)->cb_setBoost(); }
+void geBoostTool::cb_setBoostNum(Fl_Widget* w, void* p) { ((geBoostTool*)p)->cb_setBoostNum(); }
+void geBoostTool::cb_normalize  (Fl_Widget* w, void* p) { ((geBoostTool*)p)->cb_normalize(); }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-void geBoostTool::__cb_setBoost()
+void geBoostTool::cb_setBoost()
 {
+  using namespace giada::c;
+
   if (Fl::event() == FL_DRAG)
-    glue_setBoost(ch, dial->value());
+    channel::setBoost(ch, dial->value());
   else 
   if (Fl::event() == FL_RELEASE) {
-    glue_setBoost(ch, dial->value());
+    channel::setBoost(ch, dial->value());
     static_cast<gdSampleEditor*>(window())->waveTools->updateWaveform();
   }
 }
@@ -105,9 +106,11 @@ void geBoostTool::__cb_setBoost()
 /* -------------------------------------------------------------------------- */
 
 
-void geBoostTool::__cb_setBoostNum()
+void geBoostTool::cb_setBoostNum()
 {
-  glue_setBoost(ch, gu_dBtoLinear(atof(input->value())));
+  using namespace giada;
+
+  c::channel::setBoost(ch, u::math::dBtoLinear(atof(input->value())));
   static_cast<gdSampleEditor*>(window())->waveTools->updateWaveform();
 }
 
@@ -115,10 +118,12 @@ void geBoostTool::__cb_setBoostNum()
 /* -------------------------------------------------------------------------- */
 
 
-void geBoostTool::__cb_normalize()
+void geBoostTool::cb_normalize()
 {
-  float val = wfx::normalizeSoft(ch->wave);
-  glue_setBoost(ch, val); // it's like a fake user moving the dial 
+  using namespace giada;
+
+  float val = m::wfx::normalizeSoft(ch->wave);
+  c::channel::setBoost(ch, val); // it's like a fake user moving the dial 
   static_cast<gdSampleEditor*>(window())->waveTools->updateWaveform();
 }
 
index d3ce34028e65216590352c5435b9c32ed04f1611..1dc2d7cd9fc2ccf08a53ea7b5bbab6526f194bb6 100644 (file)
@@ -43,23 +43,23 @@ class geBoostTool : public Fl_Group
 {
 private:
 
-  SampleChannel *ch;
+  SampleChannelch;
 
-  geBox    *label;
-  geDial   *dial;
-  geInput  *input;
-  geButton *normalize;
+  geBox*    label;
+  geDial*   dial;
+  geInput*  input;
+  geButtonnormalize;
 
-  static void cb_setBoost   (Fl_Widget *w, void *p);
-  static void cb_setBoostNum(Fl_Widget *w, void *p);
-  static void cb_normalize  (Fl_Widget *w, void *p);
-  inline void __cb_setBoost   ();
-  inline void __cb_setBoostNum();
-  inline void __cb_normalize  ();
+  static void cb_setBoost(Fl_Widget* w, void* p);
+  static void cb_setBoostNum(Fl_Widget* w, void* p);
+  static void cb_normalize(Fl_Widget* w, void* p);
+  inline void cb_setBoost();
+  inline void cb_setBoostNum();
+  inline void cb_normalize();
 
 public:
 
-  geBoostTool(int x, int y, SampleChannel *ch);
+  geBoostTool(int x, int y, SampleChannelch);
 
   void refresh();
 };
index 9c638d4cedbabe0406f8b13bf7090bb095cda3f1..29e4530fc6f77bbeedbc173001f14a21a2be4318 100644 (file)
@@ -43,6 +43,7 @@
 
 
 using std::string;
+using namespace giada;
 
 
 gePanTool::gePanTool(int x, int y, SampleChannel *ch)
@@ -103,7 +104,7 @@ void gePanTool::cb_panReset(Fl_Widget *w, void *p) { ((gePanTool*)p)->__cb_panRe
 
 void gePanTool::__cb_panning()
 {
-  glue_setPanning(ch, dial->value());
+  c::channel::setPanning(ch, dial->value());
 }
 
 
@@ -112,5 +113,5 @@ void gePanTool::__cb_panning()
 
 void gePanTool::__cb_panReset()
 {
-  glue_setPanning(ch, 0.5f);
+  c::channel::setPanning(ch, 0.5f);
 }
\ No newline at end of file
index a9b7dfbd935a1eb067825f2337603373ec72bb85..33173ca4aca8901217e1cff7a3edae90626a3ed9 100644 (file)
@@ -41,7 +41,7 @@
 #include "pitchTool.h"
 
 
-using namespace giada::m;
+using namespace giada;
 
 
 gePitchTool::gePitchTool(int x, int y, SampleChannel* ch)
@@ -104,7 +104,7 @@ void gePitchTool::cb_setPitchNum   (Fl_Widget* w, void* p) { ((gePitchTool*)p)->
 
 void gePitchTool::__cb_setPitch()
 {
-  glue_setPitch(ch, dial->value());
+  c::channel::setPitch(ch, dial->value());
 }
 
 
@@ -113,7 +113,7 @@ void gePitchTool::__cb_setPitch()
 
 void gePitchTool::__cb_setPitchNum()
 {
-  glue_setPitch(ch, atof(input->value()));
+  c::channel::setPitch(ch, atof(input->value()));
 }
 
 
@@ -122,7 +122,7 @@ void gePitchTool::__cb_setPitchNum()
 
 void gePitchTool::__cb_setPitchHalf()
 {
-  glue_setPitch(ch, dial->value()/2);
+  c::channel::setPitch(ch, dial->value()/2);
 }
 
 
@@ -131,7 +131,7 @@ void gePitchTool::__cb_setPitchHalf()
 
 void gePitchTool::__cb_setPitchDouble()
 {
-  glue_setPitch(ch, dial->value()*2);
+  c::channel::setPitch(ch, dial->value()*2);
 }
 
 
@@ -141,7 +141,7 @@ void gePitchTool::__cb_setPitchDouble()
 void gePitchTool::__cb_setPitchToBar()
 {
   // TODO - opaque channel's count
-  glue_setPitch(ch, (ch->getEnd()*2) / (float) clock::getFramesPerBar());
+  c::channel::setPitch(ch, (ch->getEnd()*2) / (float) m::clock::getFramesPerBar());
 }
 
 
@@ -151,7 +151,7 @@ void gePitchTool::__cb_setPitchToBar()
 void gePitchTool::__cb_setPitchToSong()
 {
   // TODO - opaque channel's count
-  glue_setPitch(ch, (ch->getEnd()*2) / (float) clock::getTotalFrames());
+  c::channel::setPitch(ch, (ch->getEnd()*2) / (float) m::clock::getTotalFrames());
 }
 
 
@@ -160,5 +160,5 @@ void gePitchTool::__cb_setPitchToSong()
 
 void gePitchTool::__cb_resetPitch()
 {
-  glue_setPitch(ch, G_DEFAULT_PITCH);
+  c::channel::setPitch(ch, G_DEFAULT_PITCH);
 }
index 9fb8b46b6fc1af5ff20a9ad6fd39b08383ba57d9..ddcdfb3e16487eee09016c01c6eb0692abb09db6 100644 (file)
@@ -44,7 +44,7 @@
 using std::string;
 
 
-geVolumeTool::geVolumeTool(int X, int Y, SampleChannel *ch)
+geVolumeTool::geVolumeTool(int X, int Y, SampleChannelch)
   : Fl_Group(X, Y, 150, 20),
     ch      (ch)
 {
@@ -68,8 +68,10 @@ geVolumeTool::geVolumeTool(int X, int Y, SampleChannel *ch)
 
 void geVolumeTool::refresh()
 {
+  using namespace giada::u;
+
   string tmp;
-  float dB = gu_linearToDB(ch->volume);
+  float dB = math::linearToDB(ch->getVolume());
   if (dB > -INFINITY) tmp = gu_fToString(dB, 2);  // 2 digits
   else                tmp = "-inf";
   input->value(tmp.c_str());
@@ -80,8 +82,8 @@ void geVolumeTool::refresh()
 /* -------------------------------------------------------------------------- */
 
 
-void geVolumeTool::cb_setVolume   (Fl_Widget *w, void *p) { ((geVolumeTool*)p)->__cb_setVolume(); }
-void geVolumeTool::cb_setVolumeNum(Fl_Widget *w, void *p) { ((geVolumeTool*)p)->__cb_setVolumeNum(); }
+void geVolumeTool::cb_setVolume   (Fl_Widget* w, void* p) { ((geVolumeTool*)p)->__cb_setVolume(); }
+void geVolumeTool::cb_setVolumeNum(Fl_Widget* w, void* p) { ((geVolumeTool*)p)->__cb_setVolumeNum(); }
 
 
 /* -------------------------------------------------------------------------- */
@@ -89,7 +91,9 @@ void geVolumeTool::cb_setVolumeNum(Fl_Widget *w, void *p) { ((geVolumeTool*)p)->
 
 void geVolumeTool::__cb_setVolume()
 {
-  glue_setVolume(ch, dial->value(), false, true);
+  using namespace giada;
+
+  c::channel::setVolume(ch, dial->value(), false, true);
   refresh();
 }
 
@@ -99,7 +103,9 @@ void geVolumeTool::__cb_setVolume()
 
 void geVolumeTool::__cb_setVolumeNum()
 {
+  using namespace giada;
+
   float value = pow(10, (atof(input->value()) / 20)); // linear = 10^(dB/20)
-  glue_setVolume(ch, value, false, true);
+  c::channel::setVolume(ch, value, false, true);
   dial->value(ch->guiChannel->vol->value());
 }
index e168a5f21ab70dea35f214f9af50c09e52a3c4b7..cfa9e3288584708886d0ee5340be520e1a994cf3 100644 (file)
 #include "core/kernelMidi.h"
 #include "core/recorder.h"
 #include "utils/gui.h"
+#include "utils/time.h"
 #include "gui/dialogs/gd_mainWindow.h"
 #include "core/pluginHost.h"
 
 
 pthread_t     G_videoThread;
 bool          G_quit;
-gdMainWindow *G_MainWin;
+gdMainWindowG_MainWin;
 
 
-void *videoThreadCb(void *arg);
+void* videoThreadCb(void* arg);
 
 
-int main(int argc, char **argv)
+int main(int argc, char** argv)
 {
        G_quit = false;
 
@@ -83,16 +84,14 @@ int main(int argc, char **argv)
 }
 
 
-void *videoThreadCb(void *arg)
+void* videoThreadCb(void* arg)
 {
-       if (giada::m::kernelAudio::getStatus())
+       using namespace giada;
+
+       if (m::kernelAudio::getStatus())
                while (!G_quit) {
                        gu_refreshUI();
-#ifdef _WIN32
-                       Sleep(G_GUI_SLEEP);
-#else
-                       usleep(G_GUI_SLEEP);
-#endif
+                       u::time::sleep(G_GUI_REFRESH_RATE);
                }
        pthread_exit(nullptr);
        return 0;
index 4cbfba11c1ccc86f4087a9bfa2d23af2de32ce27..b29ba781e0de013a0b97cdf07329570196bcbe6d 100644 (file)
@@ -146,7 +146,7 @@ bool gu_mkdir(const string &path)
 /* -------------------------------------------------------------------------- */
 
 
-string gu_basename(const string &s)
+string gu_basename(const strings)
 {
        string out = s;
        out.erase(0, out.find_last_of(G_SLASH_STR) + 1);
@@ -157,7 +157,7 @@ string gu_basename(const string &s)
 /* -------------------------------------------------------------------------- */
 
 
-string gu_dirname(const string &path)
+string gu_dirname(const stringpath)
 {
        if (path.empty())
                return "";
@@ -187,7 +187,7 @@ string gu_getCurrentPath()
 /* -------------------------------------------------------------------------- */
 
 
-string gu_getExt(const string &file)
+string gu_getExt(const stringfile)
 {
        // TODO - use std functions
        int len = strlen(file.c_str());
@@ -207,7 +207,7 @@ string gu_getExt(const string &file)
 /* -------------------------------------------------------------------------- */
 
 
-string gu_stripExt(const string &s)
+string gu_stripExt(const strings)
 {
        return s.substr(0, s.find_last_of("."));
 }
@@ -216,7 +216,7 @@ string gu_stripExt(const string &s)
 /* -------------------------------------------------------------------------- */
 
 
-bool gu_isProject(const string &path)
+bool gu_isProject(const stringpath)
 {
        /** FIXME - checks too weak */
 
@@ -229,7 +229,7 @@ bool gu_isProject(const string &path)
 /* -------------------------------------------------------------------------- */
 
 
-string gu_stripFileUrl(const string &f)
+string gu_stripFileUrl(const stringf)
 {
        string out = f;
        out = gu_replace(out, "file://", "");
@@ -255,13 +255,13 @@ string gu_getHomePath()
 
 #elif defined(__APPLE__)
 
-       struct passwd *p = getpwuid(getuid());
+       struct passwdp = getpwuid(getuid());
        if (p == nullptr) {
                gu_log("[gu_getHomePath] unable to fetch user infos\n");
                return "";
        }
        else {
-               const char *home = p->pw_dir;
+               const charhome = p->pw_dir;
                snprintf(path, PATH_MAX, "%s/Library/Application Support/Giada", home);
        }
 
@@ -269,3 +269,40 @@ string gu_getHomePath()
 
        return string(path);
 }
+
+
+/* -------------------------------------------------------------------------- */
+
+
+bool gu_isRootDir(const std::string& s)
+{
+       if (s == "")
+               return false;
+
+#ifdef G_OS_WINDOWS
+
+       return s.length() <= 3 && s[1] == ':';  /* X: or X:\ */
+
+#else
+
+       return s == G_SLASH_STR;
+
+#endif
+}
+
+
+/* -------------------------------------------------------------------------- */
+
+
+std::string gu_getUpDir(const std::string& s)
+{
+#ifdef G_OS_WINDOWS
+
+       /* If root, let the user browse the drives list by returning "". */
+       if (gu_isRootDir(s))
+               return "";
+
+#endif
+
+       return s.substr(0, s.find_last_of(G_SLASH_STR)) + G_SLASH_STR;
+}
\ No newline at end of file
index 27b0d2ef7bd47bda95fddb07d6049feeed642819..2b9a21610dc2df9328e5f5d7426220c3cdb20715 100644 (file)
 bool gu_fileExists(const std::string& path);
 bool gu_dirExists(const std::string& path);
 bool gu_isDir(const std::string& path);
+
+/* isRootDir
+Tells whether 's' is '/' on Unix or '[X]:\' on Windows. */
+
+bool gu_isRootDir(const std::string& s);
+
 bool gu_isProject(const std::string& path);
 bool gu_mkdir(const std::string& path);
 std::string gu_getCurrentPath();
@@ -64,5 +70,11 @@ std::string gu_stripExt(const std::string& s);
 
 std::string gu_stripFileUrl(const std::string& s);
 
+/* gu_getUpDir
+Returns the upper directory:
+/path/to/my/directory -> /path/to/my/ */
+
+std::string gu_getUpDir(const std::string& s);
+
 
 #endif
index 402b16432647139519a55c5af8c6f6f9dc395efb..9bb7ca090cce1675e1798bea9ebb6b6194f9654a 100644 (file)
 #include "math.h"
 
 
-float gu_linearToDB(float f)
+namespace giada {
+namespace u     {
+namespace math 
 {
-  return 20 * std::log10(f);
+float linearToDB(float f)
+{
+       return 20 * std::log10(f);
 }
 
 
 /* -------------------------------------------------------------------------- */
 
 
-float gu_dBtoLinear(float f)
+float dBtoLinear(float f)
 {
-  return std::pow(10, f/20.0f); 
+       return std::pow(10, f/20.0f); 
 }
+
+}}}  // giada::u::math::
\ No newline at end of file
index 668c9f7862aae5b8a2a0ba3ae5ee26a6e275c6ee..c17d82da703e403f535f7c7ed2732d56a4296385 100644 (file)
 #define G_UTILS_MATH_H
 
 
-float gu_linearToDB(float f);
+namespace giada {
+namespace u     {
+namespace math 
+{
+float linearToDB(float f);
+float dBtoLinear(float f);
 
-float gu_dBtoLinear(float f);
+/* map (template)
+Maps 'x' in range [a, b] to a new range [w, z]. Source:
+       https://en.wikipedia.org/wiki/Linear_equation#Two-point_form*/
+
+template <typename T>
+T map(T x, T a, T b, T w, T z)
+{
+       return (((x - a) / (b - a)) * (z - w)) + w;
+}
+
+}}}  // giada::u::math::
 
 
 #endif
index fda5839af193b8fa6c8050d6c4c2e908a1476142..2fc883efc1466c03289af8b3514df94fee4743c0 100644 (file)
@@ -108,8 +108,10 @@ std::string gu_format(const char* format, ...)
        /* Compute the size of the new expanded string (i.e. with replacement taken
        into account). */
 
-       size_t size = vsnprintf(nullptr, 0, format, args);
-
+       va_start(args, format);
+       size_t size = vsnprintf(nullptr, 0, format, args) + 1;
+       va_end(args);
+       
        /* Create a new temporary char array to hold the new expanded string. */
 
        std::unique_ptr<char[]> tmp(new char[size]);
index ec3faa5656da61ad1ba0bc655d104bc48f4f770c..2667c8170eda4a1fa9e3903b222f8a498c0c79dc 100644 (file)
  * -------------------------------------------------------------------------- */
 
 
-#include "../core/const.h"
-#ifndef G_OS_MAC
-       #include <chrono>
-       #include <thread>
-#else
-       #include <unistd.h>
-#endif
+#include <chrono>
+#include <thread>
 #include "time.h"
 
 
@@ -43,10 +38,6 @@ namespace time
 {
 void sleep(int millisecs)
 {
-#ifndef G_OS_MAC
        std::this_thread::sleep_for(std::chrono::milliseconds(millisecs));
-#else
-       usleep(millisecs * 1000);
-#endif
 }
 }}};  // giada::u::time::
index a561d1a21f70337f78d44e6391a93c0b34e5e9a1..df9113c81678512ff190045e63f3f74772bb138a 100644 (file)
@@ -1,6 +1,6 @@
 #include "../src/core/const.h"
 #include "../src/core/conf.h"
-#include "catch/single_include/catch.hpp"
+#include <catch.hpp>
 
 
 using std::string;
index eb3c215a55ce34866ea956ac246f732ce7d7b537..37c527d3051c9bd84f4a002038f7d4c5b4488586 100644 (file)
@@ -1,3 +1,3 @@
 #define CATCH_CONFIG_MAIN
 #define CATCH_CONFIG_FAST_COMPILE
-#include "catch/single_include/catch.hpp"
+#include <catch.hpp>
index 28b3779e095ac7c75b119dcc4910b709eafe1983..5903fca4cd7eb1767f99cbf4c7f6c60b75b5e5de 100644 (file)
@@ -1,6 +1,6 @@
 #include "../src/core/const.h"
 #include "../src/core/midiMapConf.h"
-#include "catch/single_include/catch.hpp"
+#include <catch.hpp>
 
 
 using std::string;
index da5516258217b1f20fbc11208cb7a4cf7a59eee2..b7a0808c6014c8a194316c3e1807f8462380169a 100644 (file)
@@ -1,6 +1,6 @@
 #include "../src/core/patch.h"
 #include "../src/core/const.h"
-#include "catch/single_include/catch.hpp"
+#include <catch.hpp>
 
 
 using std::string;
index 43215bba4cc4520c465238629a2c3bd5dd1c9acf..bbdcbc0225ae15c4fbe57d2cb56c46b23998ab18 100644 (file)
@@ -5,7 +5,7 @@
 #if 0
 
 #include "../src/core/pluginHost.h"
-#include "catch/single_include/catch.hpp"
+#include <catch.hpp>
 
 
 TEST_CASE("Test PluginHost class")
index 49a988e48da89a84807bc8374cd938b5da84139b..6d29d85d08df625335499a89a30724b5ebddf9e0 100644 (file)
@@ -1,6 +1,6 @@
 #include "../src/core/recorder.h"
 #include "../src/core/const.h"
-#include "catch/single_include/catch.hpp"
+#include <catch.hpp>
 
 
 using std::string;
index 07fb31c1a9a4d769bb962f034fab2321c77a06ec..c17b51dafbb527d5ed257f181bd6704b77b94fc5 100644 (file)
@@ -1,40 +1,62 @@
 #include "../src/utils/fs.h"
 #include "../src/utils/string.h"
-#include "catch/single_include/catch.hpp"
-
-
-using std::vector;
+#include "../src/utils/math.h"
+#include <catch.hpp>
 
 
 TEST_CASE("Test filesystem utils")
 {
-  REQUIRE(gu_fileExists("giada_tests") == true);
-  REQUIRE(gu_fileExists("ghost_file") == false);
-  REQUIRE(gu_dirExists("src/") == true);
-  REQUIRE(gu_dirExists("ghost_dir/") == false);
-  REQUIRE(gu_isDir("src/") == true);
-  REQUIRE(gu_isDir("giada_tests") == false);
-  REQUIRE(gu_basename("tests/utils.cpp") == "utils.cpp");
-  REQUIRE(gu_dirname("tests/utils.cpp") == "tests");
-  REQUIRE(gu_getExt("tests/utils.cpp") == "cpp");
-  REQUIRE(gu_stripExt("tests/utils.cpp") == "tests/utils");
+       REQUIRE(gu_fileExists("README.md") == true);
+       REQUIRE(gu_fileExists("ghost_file") == false);
+       REQUIRE(gu_dirExists("src/") == true);
+       REQUIRE(gu_dirExists("ghost_dir/") == false);
+       REQUIRE(gu_isDir("src/") == true);
+       REQUIRE(gu_isDir("giada_tests") == false);
+       REQUIRE(gu_basename("tests/utils.cpp") == "utils.cpp");
+       REQUIRE(gu_dirname("tests/utils.cpp") == "tests");
+       REQUIRE(gu_getExt("tests/utils.cpp") == "cpp");
+       REQUIRE(gu_stripExt("tests/utils.cpp") == "tests/utils");
+#if defined(_WIN32)
+       REQUIRE(gu_isRootDir("C:\\") == true);
+       REQUIRE(gu_isRootDir("C:\\path\\to\\something") == false);
+       REQUIRE(gu_getUpDir("C:\\path\\to\\something") == "C:\\path\\to\\");
+       REQUIRE(gu_getUpDir("C:\\path") == "C:\\");
+       REQUIRE(gu_getUpDir("C:\\") == "");
+#else
+       REQUIRE(gu_isRootDir("/") == true);
+       REQUIRE(gu_isRootDir("/path/to/something") == false);
+       REQUIRE(gu_getUpDir("/path/to/something") == "/path/to/");
+       REQUIRE(gu_getUpDir("/path") == "/");
+       REQUIRE(gu_getUpDir("/") == "/");
+#endif
 }
 
 
 TEST_CASE("Test string utils")
 {
-  REQUIRE(gu_replace("Giada is cool", "cool", "hot") == "Giada is hot");
-  REQUIRE(gu_trim("   Giada is cool       ") == "Giada is cool");
-  REQUIRE(gu_iToString(666) == "666");
-  REQUIRE(gu_iToString(0x99AABB, true) == "99AABB");
-  REQUIRE(gu_fToString(3.14159, 2) == "3.14");
-  // Catch can't handle this so far?
-  //REQUIRE(gu_format("I see %d men with %s hats", 5, "strange") == "I see 5 men with strange hats");
-
-  vector<std::string> v;
-  gu_split("Giada is cool", " ", &v);
-  REQUIRE(v.size() == 3);
-  REQUIRE(v.at(0) == "Giada");
-  REQUIRE(v.at(1) == "is");
-  REQUIRE(v.at(2) == "cool");
+       using std::vector;
+
+       REQUIRE(gu_replace("Giada is cool", "cool", "hot") == "Giada is hot");
+       REQUIRE(gu_trim("   Giada is cool       ") == "Giada is cool");
+       REQUIRE(gu_iToString(666) == "666");
+       REQUIRE(gu_iToString(0x99AABB, true) == "99AABB");
+       REQUIRE(gu_fToString(3.14159, 2) == "3.14");
+       REQUIRE(gu_format("I see %d men with %s hats", 5, "strange") == "I see 5 men with strange hats");
+
+       vector<std::string> v;
+       gu_split("Giada is cool", " ", &v);
+       REQUIRE(v.size() == 3);
+       REQUIRE(v.at(0) == "Giada");
+       REQUIRE(v.at(1) == "is");
+       REQUIRE(v.at(2) == "cool");
 }
+
+
+TEST_CASE("Test math utils")
+{
+       using namespace giada::u::math;
+
+       REQUIRE(map( 0.0f, 0.0f, 30.0f, 0.0f, 1.0f) == 0.0f);
+       REQUIRE(map(30.0f, 0.0f, 30.0f, 0.0f, 1.0f) == 1.0f);
+       REQUIRE(map(15.0f, 0.0f, 30.0f, 0.0f, 1.0f) == Approx(0.5f));
+}
\ No newline at end of file
index 77290240c7da0b74350157fe130ba47078e0fe85..72cffa326a7b0cc57d8fd27afa4595c345b2abab 100644 (file)
@@ -1,6 +1,6 @@
 #include <memory>
 #include "../src/core/wave.h"
-#include "catch/single_include/catch.hpp"
+#include <catch.hpp>
 
 
 using std::string;
index 3032078317bd3cc6861a660eeb8ce6511ac1e4ad..9c16d280f994e7a823234fe04ca8ac947969af2d 100644 (file)
@@ -2,7 +2,7 @@
 #include "../src/core/const.h"
 #include "../src/core/wave.h"
 #include "../src/core/waveFx.h"
-#include "catch/single_include/catch.hpp"
+#include <catch.hpp>
 
 
 using std::string;
index 80089591f08da93c8254259fe6260f4a2904ac57..f9b2eb85420f1007d6c0f559459507821130744a 100644 (file)
@@ -2,7 +2,7 @@
 #include "../src/core/waveManager.h"
 #include "../src/core/wave.h"
 #include "../src/core/const.h"
-#include "catch/single_include/catch.hpp"
+#include <catch.hpp>
 
 
 using std::string;