[beast: 65/73] BSE: SF2: move remaining data members from SoundFontRepo to Impl



commit 3d989f1c68cb91453656f00bbc8799e91d20db75
Author: Stefan Westerfeld <stefan space twc de>
Date:   Mon Feb 13 17:13:26 2017 +0100

    BSE: SF2: move remaining data members from SoundFontRepo to Impl
    
    Signed-off-by: Stefan Westerfeld <stefan space twc de>

 bse/bsesoundfontosc.cc  |   37 +++++++++++++++++++------------------
 bse/bsesoundfontrepo.cc |   32 +++++++++++++++-----------------
 bse/bsesoundfontrepo.hh |   15 ++++++++-------
 3 files changed, 42 insertions(+), 42 deletions(-)
---
diff --git a/bse/bsesoundfontosc.cc b/bse/bsesoundfontosc.cc
index 06a41d4..2d3eda0 100644
--- a/bse/bsesoundfontosc.cc
+++ b/bse/bsesoundfontosc.cc
@@ -358,18 +358,18 @@ process_fluid_L (BseSoundFontRepo   *sfrepo,
 {
   Bse::SoundFontRepoImpl *sfrepo_impl = sfrepo->as<Bse::SoundFontRepoImpl *>();
 
-  float **channel_values_left = (float **) g_alloca (sfrepo->n_fluid_channels * sizeof (float *));
-  float **channel_values_right = (float **) g_alloca (sfrepo->n_fluid_channels * sizeof (float *));
+  float **channel_values_left = (float **) g_alloca (sfrepo_impl->n_fluid_channels * sizeof (float *));
+  float **channel_values_right = (float **) g_alloca (sfrepo_impl->n_fluid_channels * sizeof (float *));
   float null_fx[BSE_STREAM_MAX_VALUES];
   float *channel_fx_null[2] = { null_fx, null_fx };
 
-  g_return_if_fail (now_tick_stamp > sfrepo->channel_values_tick_stamp);
-  sfrepo->channel_values_tick_stamp = now_tick_stamp;
+  g_return_if_fail (now_tick_stamp > sfrepo_impl->channel_values_tick_stamp);
+  sfrepo_impl->channel_values_tick_stamp = now_tick_stamp;
 
   /* Sample precise timing: If events don't occur at block boundary, the block
      is partially calculated, then the event is executed, and then the rest of
      the block (until the next event) is calculated, and so on */
-  for (guint i = 0; i < sfrepo->n_fluid_channels; i++)
+  for (guint i = 0; i < sfrepo_impl->n_fluid_channels; i++)
     {
       channel_values_left[i] = &sfrepo_impl->channel_state[i].values_left[0];
       channel_values_right[i] = &sfrepo_impl->channel_state[i].values_right[0];
@@ -380,9 +380,9 @@ process_fluid_L (BseSoundFontRepo   *sfrepo,
       /* get 1st event tick stamp */
       BseFluidEvent *event = NULL;
       guint64 event_tick_stamp;
-      if (sfrepo->fluid_events)
+      if (sfrepo_impl->fluid_events)
        {
-         event = (BseFluidEvent *) sfrepo->fluid_events->data;
+         event = (BseFluidEvent *) sfrepo_impl->fluid_events->data;
          event_tick_stamp = event->tick_stamp;
        }
       else
@@ -411,7 +411,7 @@ process_fluid_L (BseSoundFontRepo   *sfrepo,
                                                        event->arg1, event->arg2);
                                        break;
            }
-         sfrepo->fluid_events = sfi_ring_remove_node (sfrepo->fluid_events, sfrepo->fluid_events);
+         sfrepo_impl->fluid_events = sfi_ring_remove_node (sfrepo_impl->fluid_events, 
sfrepo_impl->fluid_events);
          g_free (event);
        }
       else                                                  /* future event tick stamp: process audio until 
then */
@@ -422,7 +422,7 @@ process_fluid_L (BseSoundFontRepo   *sfrepo,
                                    channel_fx_null, channel_fx_null);
          values_remaining -= values_todo;
          now_tick_stamp += values_todo;
-         for (guint i = 0; i < sfrepo->n_fluid_channels; i++)          /* increment fluid synth output 
buffer pointers */
+         for (guint i = 0; i < sfrepo_impl->n_fluid_channels; i++)          /* increment fluid synth output 
buffer pointers */
            {
              channel_values_left[i] += values_todo;
              channel_values_right[i] += values_todo;
@@ -448,7 +448,7 @@ sound_font_osc_process (BseModule *module,
       flmod->last_update_preset = flmod->config.update_preset;
     }
   guint64 now_tick_stamp = Bse::TickStamp::current();
-  if (sfrepo->channel_values_tick_stamp != now_tick_stamp)
+  if (sfrepo_impl->channel_values_tick_stamp != now_tick_stamp)
     process_fluid_L (sfrepo, fluid_synth, now_tick_stamp);
 
   auto& cstate = sfrepo_impl->channel_state[sfrepo_impl->oscs[flmod->config.osc_id].channel];
@@ -476,7 +476,7 @@ sound_font_osc_process (BseModule *module,
        cstate.n_silence_samples += n_values;
       else
        cstate.n_silence_samples = 0;
-      float done = (cstate.n_silence_samples > flmod->config.silence_bound && sfrepo->fluid_events == NULL) 
? 1.0 : 0.0;
+      float done = (cstate.n_silence_samples > flmod->config.silence_bound && sfrepo_impl->fluid_events == 
NULL) ? 1.0 : 0.0;
       BSE_MODULE_OSTREAM (module, BSE_SOUND_FONT_OSC_OCHANNEL_DONE_OUT).values = bse_engine_const_values 
(done);
     }
 }
@@ -555,7 +555,7 @@ sound_font_osc_process_midi (gpointer            null,
     {
       fluid_event->tick_stamp = event->delta_time;
       fluid_event->channel = sfrepo_impl->oscs[flmod->config.osc_id].channel;
-      flmod->config.sfrepo->fluid_events = sfi_ring_insert_sorted (flmod->config.sfrepo->fluid_events, 
fluid_event, event_cmp, NULL);
+      sfrepo_impl->fluid_events = sfi_ring_insert_sorted (sfrepo_impl->fluid_events, fluid_event, event_cmp, 
NULL);
     }
 }
 
@@ -588,7 +588,7 @@ event_handler_setup_func (BseModule *module,
   fluid_event->arg2 = flmod->config.program;
   fluid_event->sfont_id = flmod->config.sfont_id;
   fluid_event->tick_stamp = 0; /* now */
-  flmod->config.sfrepo->fluid_events = sfi_ring_insert_sorted (flmod->config.sfrepo->fluid_events, 
fluid_event, event_cmp, NULL);
+  sfrepo_impl->fluid_events = sfi_ring_insert_sorted (sfrepo_impl->fluid_events, fluid_event, event_cmp, 
NULL);
 }
 
 static void
@@ -635,9 +635,10 @@ bse_sound_font_osc_context_create (BseSource *source,
   BseSoundFontOsc *self = BSE_SOUND_FONT_OSC (source);
   std::lock_guard<Bse::Mutex> guard (bse_sound_font_repo_mutex (self->config.sfrepo));
   fluid_synth_t *fluid_synth = bse_sound_font_repo_fluid_synth (self->config.sfrepo);
-  if (self->config.sfrepo->n_channel_oscs_active == 0)
+  Bse::SoundFontRepoImpl *sfrepo_impl = self->config.sfrepo->as<Bse::SoundFontRepoImpl *>();
+  if (sfrepo_impl->n_channel_oscs_active == 0)
     fluid_synth_system_reset (fluid_synth);
-  self->config.sfrepo->n_channel_oscs_active++;
+  sfrepo_impl->n_channel_oscs_active++;
 }
 
 static void
@@ -656,7 +657,7 @@ bse_sound_font_osc_context_dismiss (BseSource                *source,
                                           module);
   /* remove old events from the event queue */
   std::lock_guard<Bse::Mutex> guard (bse_sound_font_repo_mutex (self->config.sfrepo));
-  SfiRing *fluid_events = self->config.sfrepo->fluid_events;
+  SfiRing *fluid_events = sfrepo_impl->fluid_events;
   SfiRing *node = fluid_events;
   while (node)
     {
@@ -669,8 +670,8 @@ bse_sound_font_osc_context_dismiss (BseSource                *source,
        }
       node = next_node;
     }
-  self->config.sfrepo->n_channel_oscs_active--;
-  self->config.sfrepo->fluid_events = fluid_events;
+  sfrepo_impl->n_channel_oscs_active--;
+  sfrepo_impl->fluid_events = fluid_events;
   /* chain parent class' handler */
   BSE_SOURCE_CLASS (parent_class)->context_dismiss (source, context_handle, trans);
 }
diff --git a/bse/bsesoundfontrepo.cc b/bse/bsesoundfontrepo.cc
index 6b90064..b2367b8 100644
--- a/bse/bsesoundfontrepo.cc
+++ b/bse/bsesoundfontrepo.cc
@@ -98,13 +98,6 @@ bse_sound_font_repo_class_init (BseSoundFontRepoClass *klass)
 static void
 bse_sound_font_repo_init (BseSoundFontRepo *sfrepo)
 {
-  sfrepo->fluid_events = NULL;
-  sfrepo->fluid_mix_freq = 0;
-
-  sfrepo->n_fluid_channels = 0;
-
-  sfrepo->n_channel_oscs_active = 0;
-  sfrepo->channel_values_tick_stamp = 0;
 }
 
 static gboolean
@@ -138,7 +131,7 @@ bse_sound_font_repo_prepare (BseSource *source)
        o.channel = channels_required++;
     }
   guint mix_freq = bse_engine_sample_freq();
-  if (sfrepo->n_fluid_channels != channels_required || sfrepo->fluid_mix_freq != mix_freq)
+  if (sfrepo_impl->n_fluid_channels != channels_required || sfrepo_impl->fluid_mix_freq != mix_freq)
     {
       sfrepo_impl->channel_state.resize (channels_required);
 
@@ -149,8 +142,8 @@ bse_sound_font_repo_prepare (BseSource *source)
           cstate.values_right.resize (BSE_STREAM_MAX_VALUES);
         }
 
-      sfrepo->n_fluid_channels = channels_required;
-      sfrepo->fluid_mix_freq = mix_freq;
+      sfrepo_impl->n_fluid_channels = channels_required;
+      sfrepo_impl->fluid_mix_freq = mix_freq;
 
       fluid_settings_setnum (sfrepo_impl->fluid_settings, "synth.sample-rate", mix_freq);
       /* soundfont instruments should be as loud as beast synthesis network instruments */
@@ -185,13 +178,6 @@ bse_sound_font_repo_release_children (BseContainer *container)
 static void
 bse_sound_font_repo_dispose (GObject *object)
 {
-  BseSoundFontRepo *sfrepo = BSE_SOUND_FONT_REPO (object);
-
-  sfrepo->n_fluid_channels = 0;
-
-  if (sfrepo->fluid_events != NULL)
-    g_warning (G_STRLOC ": fluid event queue should be empty in dispose");
-
   /* chain parent class' handler */
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
@@ -354,6 +340,14 @@ SoundFontRepoImpl::SoundFontRepoImpl (BseObject *bobj) :
 {
   fluid_settings = new_fluid_settings();
   fluid_synth = new_fluid_synth (fluid_settings);
+
+  fluid_mix_freq = 0;
+  fluid_events = nullptr;
+
+  n_fluid_channels = 0;
+
+  n_channel_oscs_active = 0;
+  channel_values_tick_stamp = 0;
 }
 
 SoundFontRepoImpl::~SoundFontRepoImpl ()
@@ -378,6 +372,10 @@ SoundFontRepoImpl::~SoundFontRepoImpl ()
       delete_fluid_settings (fluid_settings);
       fluid_settings = NULL;
     }
+  n_fluid_channels = 0;
+
+  if (fluid_events != NULL)
+    g_warning (G_STRLOC ": fluid event queue should be empty in SoundFontRepoImpl destructor");
 }
 
 static Error
diff --git a/bse/bsesoundfontrepo.hh b/bse/bsesoundfontrepo.hh
index 568c333..6161ade 100644
--- a/bse/bsesoundfontrepo.hh
+++ b/bse/bsesoundfontrepo.hh
@@ -26,13 +26,6 @@ struct BseFluidEvent {
 };
 
 struct BseSoundFontRepo : BseSuper {
-  SfiRing           *fluid_events;
-  guint              fluid_mix_freq;
-
-  guint              n_fluid_channels;
-  guint64           channel_values_tick_stamp;
-
-  int               n_channel_oscs_active;       /* SoundFontOscs with an active module in the engine thread 
*/
 };
 
 struct BseSoundFontRepoClass : BseSuperClass
@@ -70,6 +63,14 @@ public:
 
   fluid_settings_t           *fluid_settings;
   fluid_synth_t              *fluid_synth;
+  guint                       fluid_mix_freq;
+
+  SfiRing                    *fluid_events;
+
+  guint                       n_fluid_channels;
+  guint64                    channel_values_tick_stamp;
+
+  int                        n_channel_oscs_active;      /* SoundFontOscs with an active module in the 
engine thread */
 
 protected:
 


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