[beast: 72/73] Merge branch 'wip/soundfont' from http://space.twc.de/public/git/stwbeast.git



commit 5e8e36e1fe2ac7c6177564f825596980b7d29881
Merge: ef06806 9990c8a
Author: Tim Janik <timj gnu org>
Date:   Thu Mar 23 22:14:02 2017 +0100

    Merge branch 'wip/soundfont' from http://space.twc.de/public/git/stwbeast.git
    
    * wip/soundfont:
      BSE: fix String and string_format references outside of Bse namespace
      MISC: Dockerfile-apt.in: install libfluidsynth-dev for building beast
      BSE: bsemidireceiver.cc: avoid conditional indentation of switch() statement
        To simplify merging, restore the code indentation of the big switch statement
        in midi_receiver_process_event_L(), essentially undoing the reindentation
        caused by commit d6ad6a22d8dcc060e6daebce6839378115f2a999:
            BSE: added code which allows modules to get midi events from receiver
      BSE: SF2: disable unimportant fluid messages
      BSE: SF2: fix make check by using sample path to locate soundfonts
        This only makes a difference for relative paths.
      BSE: SF2: move remaining data members from SoundFontRepo to Impl
      BSE: SF2: move more fluid* data members to SoundFontRepoImpl
      BSE: SF2: move sound_fonts GList to SoundFontRepoImpl and use std::vector
      BSE: SF2: move preset vector to SoundFontImpl object
      BSE: SF2: store sound font presets in std::vector instead of GList
      TESTS: add required sf2 files to EXTRA_DIST
      BSE: SF2: move more data members from BseSoundFont to Bse::SoundFontImpl
      BSE: SF2: fix extremely rare temp file name collions; use better prefix
        - bse storage blobs are prefixed with bse-storage-blob- now
        - collision probablility is now as low as an SHA1 collision probability
      BSE: SF2: store tmp files under $XDG_CACHE_HOME/libbse or ~/.cache/libbse
      TESTS: audio: add soundfont-test, which tests basic sound font replay
        minfluid.sf2 was created to be a extremely small soundfont which can be used
        for testing, based on the FluidR3_GM.sf2 soundfont, see minfluid.sf2.LICENSE
      BSE: SF2: BseStorage::Blob: replace C style API with C++ style API
      BSE: SF2: use std::shared_ptr for blob reference counting
      BSE: SF2: use std::vector for BseStorage blobs instead of g_renew
      BSE: SF2: replace lock/unlock based repo locking with std::lock_guard code
      BSE: SF2: replace std::list with std::vector in midi receiver code
      BSE: SF2: move mutex to C++ soundfont repo c++ impl class
      BSE: SF2: use std::vector for oscs|channel_map instead of manual allocation
      BSE: SF2: replace manually allocated repo arrays with std::vector
      BSE: SF2: remove extern "C" from header
      BEAST: SF2: remove G_BEGIN_DECLS|G_END_DECLS from headers
      BSE: SF2: remove G_BEGIN_DECLS|G_END_DECLS from headers
      Merge branch 'master' of github.com/tim-janik/beast into soundfont
        Synchronize with beast master so that patches against the newer codebase can be applied.
      BSE: SF2: Fix a few signedness warnings in sound font code
      BSE: SF2: remove generated file which should not have been checked in
      Merge branch 'master' of github.com/tim-janik/beast into soundfont
        Replace old .proc files with proper bseapi.idl entries.
      BSE: SF2: set fluid synth gain to 1.0 (default is 0.2)
        Soundfont instruments should be (approximately) as loud as beast synthesis
        network instruments.
      BSE: SF2: move sound-font-snet from zintern to res; fixes sf2 playback
      BSE: SF2: replace g_object_new() with bse_object_new()
        Creating objects with g_object_new() in bse is no longer possible.
      Merge branch 'master' of github.com/tim-janik/beast into soundfont
        This merge creates a version of the soundfont branch that cleanly applies
        to the current master branch.
      BSE: bsestorage: use Rapicorn::string_format() for bse_storage_printf()
      BSE: bsestorage: whitespace fixes
      BSE: bsestorage: replace g_strdup_printf with g_strdup_format()
      BSE: SF2: upgrade sound-font-snet.bse to version 0.8.1
      BSE: SF2: use C++ inheritance for GObject struct derivation
      BSE: SF2: port storage blob to Rapicorn Mutex
      BSE: SF2: use Bse::TickStamp instead of old gsl API
      BSE: SF2: fix missing bse_sound_font_repo_finalize and use Rapicorn Mutex
      BSE: SF2: add documentation how the fluidsynth engine is used in sound font osc modules
      BSE: SF2: use mixfreq to compute number of silent samples required for done output
      BEAST: SF2: adapt code to c++ified beast codebase
      BSE: SF2: adapt code to c++ified beast codebase
      Merge branch 'master' of github.com/tim-janik/beast into soundfont
        Synchronize with beast master so that patches against the newer codebase can be applied.
        This resolves a number of build rule and license header conflicts.
      BEAST-GTK: remove sound font related debugging code
      BUILD: include the right sound font header file into beast_headers
      BEAST-GTK: Added necessary gui support for browsing sound fonts
      BEAST-GTK: added new sound font view radget
      BEAST-GTK: added sound font view as widget
      BEAST-GTK: implemented browsing and selection of available sound fonts
        Selecting sound font presets in now supported as an alternative to synth
        and wave selection.
      BEAST-GTK: added code for sound font repository super class
      BEAST-GTK: added file dialog support for loading sound fonts
      BUILD: added beast-gtk files for sound font support
      BSE: implemented BseSoundFontOsc, which wraps fluid synth computations.
      BSE: added sound font support for bse projects wrapping fluid synths structures.
      BSE: added zintern snet for sound font preset replay
      BSE: allow sound font presets as instruments for a track.
      BSE: implemented new concept: BseStorageBlob
        A blob is a binary large object, that is some binary data which is stored along
        with the other data. It was designed to store sound font files within .bse
        files, while still allowing fluid synth to access the file directly. Temp files
        are used to give fluid synth direct access to a file.
      BSE: fixed typo in bse server
      BSE: fixed typo in bse source
      BSE: added global sound font repository to each project
        This repo is similar to the wave repo; it contains sound fonts used by a
        project.
      BSE: added code which allows modules to get midi events from receiver
        This is implemented by registering a midi event handler function. Sound font
        support via fluid synth needs this possibility.
      BSE: fixed typos
      BSE: added BseSoundFont* typedefs
      BSE: removed unnecessary code in constant module
      BUILD: added new files for sound font support
      BUILD: added configure check for libfluidsynth, required for SoundFonts
    
    Signed-off-by: Tim Janik <timj gnu org>

 beast-gtk/Makefile.am               |    2 +
 beast-gtk/bstfiledialog.cc          |   49 +++-
 beast-gtk/bstfiledialog.hh          |   39 ++-
 beast-gtk/bstsoundfontpresetview.cc |   31 ++
 beast-gtk/bstsoundfontpresetview.hh |   33 ++
 beast-gtk/bstsoundfontview.cc       |  143 ++++++++
 beast-gtk/bstsoundfontview.hh       |   36 ++
 beast-gtk/bstsupershell.cc          |   17 +
 beast-gtk/bsttracksynthdialog.cc    |   31 ++-
 beast-gtk/bsttracksynthdialog.hh    |    9 +-
 beast-gtk/bsttrackview.cc           |   30 ++-
 beast-gtk/bstutils.cc               |    3 +
 beast-gtk/res/radgets-beast.xml     |   19 +
 bse/Makefile.am                     |    2 +
 bse/bseapi.idl                      |   10 +
 bse/bsedefs.hh                      |    6 +
 bse/bsemidireceiver.cc              |  132 +++++++-
 bse/bsemidireceiver.hh              |   14 +
 bse/bseobject.cc                    |    6 +
 bse/bseproject.cc                   |   35 ++-
 bse/bseproject.hh                   |    2 +
 bse/bsesoundfont.cc                 |  424 ++++++++++++++++++++++
 bse/bsesoundfont.hh                 |   45 +++
 bse/bsesoundfontosc.cc              |  677 +++++++++++++++++++++++++++++++++++
 bse/bsesoundfontosc.hh              |   40 ++
 bse/bsesoundfontpreset.cc           |  179 +++++++++
 bse/bsesoundfontpreset.hh           |   26 ++
 bse/bsesoundfontrepo.cc             |  482 +++++++++++++++++++++++++
 bse/bsesoundfontrepo.hh             |   87 +++++
 bse/bsestorage.cc                   |  307 +++++++++++++++-
 bse/bsestorage.hh                   |   31 ++
 bse/bsetrack.cc                     |  109 +++++-
 bse/bsetrack.hh                     |    5 +
 bse/res/Makefile.am                 |    1 +
 bse/res/sound-font-snet.bse         |   17 +
 configure.ac                        |    1 +
 misc/Dockerfile-apt.in              |    2 +-
 po/POTSCAN                          |    2 +
 tests/audio/Makefile.am             |   14 +
 tests/audio/minfluid.sf2            |  Bin 0 -> 84512 bytes
 tests/audio/minfluid.sf2.LICENSE    |   63 ++++
 tests/audio/soundfont-test.bse      |   50 +++
 tests/audio/soundfont-test.ref      |  292 +++++++++++++++
 43 files changed, 3447 insertions(+), 56 deletions(-)
---
diff --cc beast-gtk/Makefile.am
index bb59bb5,4c5e380..1df7b36
--- a/beast-gtk/Makefile.am
+++ b/beast-gtk/Makefile.am
@@@ -58,6 -59,8 +59,7 @@@ bst_cc_sources = $(strip 
        bstusermessage.cc       bstdial.cc      bsttracksynthdialog.cc  bstwaveeditor.cc    \
        bstzoomedwindow.cc     bstskinconfig.cc bstmsgabsorb.cc         bstsampleeditor.cc  \
                               bsttreestores.cc bstbseutils.cc          bstutils.cc         \
+       bstsoundfontview.cc     bstsoundfontpresetview.cc               \
 -      ../topbuildid.cc \
  )
  # BEAST sources that get included (don't have own .lo rules)
  beast_extra_files = $(strip                                           \
diff --cc bse/bsemidireceiver.cc
index 57ea060,021fff0..06dc383
--- a/bse/bsemidireceiver.cc
+++ b/bse/bsemidireceiver.cc
@@@ -1008,30 -1065,48 +1067,58 @@@ check_voice_input_improvement_L (VoiceI
  }
  
  void
 -MidiChannel::no_poly_voice (const gchar *event_name,
 -                            gfloat       freq)
 +MidiChannel::no_poly_voice (bool noteon, const char *event_name, float freq)
  {
    MidiChannel *mchannel = this;
 -  /* check whether warning is appropriate */
 -  VoiceSwitch *any_vswitch = mchannel->n_voices ? mchannel->voices[0] : NULL;
 -  if (any_vswitch &&                                            /* poly voices are present */
 -      !bse_module_is_scheduled (any_vswitch->vmodule))          /* but voices are (temporarily) 
disconnected */
 -    return;
 -  /* provide diagnostics */
 -  sfi_diag ("MidiChannel(%u): no voice available for %s (%fHz)",
 -            mchannel->midi_channel, event_name, freq);
 +  assert_return (mchannel->poly_enabled);
 +
 +  if (!noteon)
 +    warning ("MidiChannel(%u): failed to find voice for '%s' (%fHz)",
 +             mchannel->midi_channel, event_name, freq);
 +  else
 +    {
 +      size_t scheduled = 0, disconnected = 0;
 +      for (size_t i = 0; i < mchannel->n_voices; i++)
 +        {
 +          if (bse_module_is_scheduled (mchannel->voices[i]->vmodule))
 +            scheduled++;
 +          if (check_voice_switch_available_L (mchannel->voices[i]))
 +            disconnected++;
 +        }
 +      if (noteon)
 +        warning ("MidiChannel(%u): failed to allocate voice for '%s' (%fHz), %d/%d voices disconnected (%d 
scheduled)",
 +                 mchannel->midi_channel, event_name, freq, disconnected, mchannel->n_voices, scheduled);
 +    }
  }
  
+ bool
+ MidiChannel::call_event_handlers (BseMidiEvent *event,
+                                   BseTrans     *trans)
+ {
+   bool success = false;
+   for (vector<EventHandler>::const_iterator hi = event_handlers.begin(); hi != event_handlers.end(); hi++)
+     {
+       int activated = 0;
+       for (guint i = 0; i < n_voices; i++)
+       {
+         if (voices[i] && voices[i]->n_vinputs)
+           {
+             if (check_voice_switch_available_L (voices[i]))
+               {
+                 activated++;
+                 VoiceSwitch *vswitch = voices[i];
+                 activate_voice_switch_L (vswitch, event->delta_time, trans);
+               }
+           }
+       }
+       if (!(activated <= 1))
+       g_warning (G_STRLOC ": midi event handling: assertion (activated <= 1) failed, activated = %d", 
activated);
+       hi->handler_func (hi->handler_data, hi->module, event, trans);
+       success = true;
+     }
+   return success;
+ }
+ 
  void
  MidiChannel::start_note (guint64         tick_stamp,
                           gfloat          freq,
@@@ -1953,14 -2059,19 +2074,19 @@@ midi_receiver_process_event_L (BseMidiR
    if (event->delta_time <= max_tick_stamp)
      {
        BseTrans *trans = bse_trans_open ();
+       MidiChannel *mchannel = self->peek_channel (event->channel);
        self->events = sfi_ring_remove_node (self->events, self->events);
-       switch (event->status)
+       uint event_status = event->status;
+       if (mchannel && mchannel->call_event_handlers (event, trans))
+         event_status = 0; // already handled
+       switch (event_status)
          {
-           MidiChannel *mchannel;
+         case 0:
+           // already handled by call_event_handlers()
+           break;
          case BSE_MIDI_NOTE_ON:
-           mchannel = self->peek_channel (event->channel);
 -          EDEBUG ("MidiChannel[%u]: NoteOn  %fHz Velo=%f (stamp:%llu)", event->channel,
 -                  event->data.note.frequency, event->data.note.velocity, event->delta_time);
 +          EDUMP ("MidiChannel[%u]: NoteOn  %fHz Velo=%f channel=%s (stamp:%llu)", event->channel,
 +                 event->data.note.frequency, event->data.note.velocity, mchannel ? string_from_int 
(event->channel) : "<unknown>", event->delta_time);
            if (mchannel)
              mchannel->start_note (event->delta_time,
                                    event->data.note.frequency,
diff --cc bse/bseproject.cc
index ba56f7d,51b9170..cf24691
--- a/bse/bseproject.cc
+++ b/bse/bseproject.cc
@@@ -16,8 -16,8 +16,9 @@@
  #include "bsemidinotifier.hh"
  #include "gslcommon.hh"
  #include "bseengine.hh"
 +#include "bsepcmwriter.hh"
  #include "bsemidifile.hh"
+ #include "bsesoundfontrepo.hh"
  #include <string.h>
  #include <stdlib.h>
  #include <fcntl.h>
diff --cc bse/bsetrack.cc
index df5e743,45ec612..0b610a0
--- a/bse/bsetrack.cc
+++ b/bse/bsetrack.cc
@@@ -15,10 -15,14 +15,14 @@@
  #include "bsemidivoice.hh"
  #include "bsemidireceiver.hh"
  #include "bsewaverepo.hh"
+ #include "bsesoundfontrepo.hh"
+ #include "bsesoundfontpreset.hh"
+ #include "bsesoundfont.hh"
  #include "bsecxxplugin.hh"
+ 
  #include <string.h>
  
 -#define XREF_DEBUG(...) BSE_KEY_DEBUG ("xref", __VA_ARGS__)
 +#define XREF_DEBUG(...) Bse::debug ("xref", __VA_ARGS__)
  
  #define upper_power2(uint_n)  sfi_alloc_upper_power2 (MAX ((uint_n), 4))
  #define parse_or_return               bse_storage_scanner_parse_or_return


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]