[beast/devel: 10/16] BSE: replace FBlock uses in IDL files with FloatSeq



commit e06f2e265cd4ad78c4993d5868d4d8edf34b9437
Author: Tim Janik <timj gnu org>
Date:   Wed Dec 26 22:46:27 2012 +0100

    BSE: replace FBlock uses in IDL files with FloatSeq

 beast-gtk/bstqsampler.cc    |   20 +++++++++---------
 beast-gtk/bstscrollgraph.cc |    2 +-
 bse/bsecore.idl             |    3 ++
 bse/bseeditablesample.proc  |   47 +++++++++++++++++++++++++-----------------
 bse/bseprobe.cc             |   11 ++++++---
 bse/bseprobe.idl            |    8 ++++--
 sfi/sfidl-parser.cc         |    2 +-
 tests/bse/testplugin.idl    |    2 +-
 8 files changed, 56 insertions(+), 39 deletions(-)
---
diff --git a/beast-gtk/bstqsampler.cc b/beast-gtk/bstqsampler.cc
index e92a193..d1b2797 100644
--- a/beast-gtk/bstqsampler.cc
+++ b/beast-gtk/bstqsampler.cc
@@ -1171,19 +1171,19 @@ qsampler_esample_filler (gpointer         data,
 			 BstQSampler     *qsampler)
 {
   ESampleFiller *fill = (ESampleFiller*) data;
-  SfiFBlock *fblock;
+  BseFloatSeq *fseq;
   voffset = voffset * fill->n_channels + fill->nth_channel;
-  fblock = bse_editable_sample_collect_stats (fill->esample,
-					      voffset,
-					      offset_scale * fill->n_channels,
-					      block_size * fill->n_channels,
-					      fill->n_channels,
-					      n_values);
+  fseq = bse_editable_sample_collect_stats (fill->esample,
+                                            voffset,
+                                            offset_scale * fill->n_channels,
+                                            block_size * fill->n_channels,
+                                            fill->n_channels,
+                                            n_values);
   uint i;
-  for (i = 0; i < fblock->n_values / 2; i++)
+  for (i = 0; i < fseq->n_values / 2; i++)
     {
-      values[i].min = fblock->values[i * 2] * 32767.9;
-      values[i].max = fblock->values[i * 2 + 1] * 32767.9;
+      values[i].min = fseq->values[i * 2] * 32767.9;
+      values[i].max = fseq->values[i * 2 + 1] * 32767.9;
     }
   return i;
 }
diff --git a/beast-gtk/bstscrollgraph.cc b/beast-gtk/bstscrollgraph.cc
index 735eb63..0af51c1 100644
--- a/beast-gtk/bstscrollgraph.cc
+++ b/beast-gtk/bstscrollgraph.cc
@@ -373,7 +373,7 @@ bst_scrollgraph_probes_notify (SfiProxy     source,
   if (probe && probe->probe_features->probe_fft && probe->fft_data->n_values == self->window_size)
     {
       gfloat *bar = BAR (self, self->n_bars - 1); /* update last bar */
-      SfiFBlock *fft = probe->fft_data;
+      BseFloatSeq *fft = probe->fft_data;
       for (i = 0; i < MIN (self->n_points, FFTSZ2POINTS (fft->n_values)); i++)
         {
           gfloat re, im;
diff --git a/bse/bsecore.idl b/bse/bsecore.idl
index 7dee200..c55457b 100644
--- a/bse/bsecore.idl
+++ b/bse/bsecore.idl
@@ -29,6 +29,9 @@ sequence TypeSeq {
 sequence StringSeq {
   String strings;
 };
+sequence FloatSeq {
+  Real values;
+};
 /* musical tunings: http://en.wikipedia.org/wiki/Musical_tuning */
 enum MusicalTuningType {
   /* Equal Temperament: http://en.wikipedia.org/wiki/Equal_temperament */
diff --git a/bse/bseeditablesample.proc b/bse/bseeditablesample.proc
index 6313ffd..c71ea95 100644
--- a/bse/bseeditablesample.proc
+++ b/bse/bseeditablesample.proc
@@ -1,8 +1,9 @@
 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
-#include        <bse/bseplugin.hh>
-#include        <bse/bseprocedure.hh>
-#include        <bse/bseeditablesample.hh>
-#include        <bse/gsldatahandle.hh>
+#include <bse/bseplugin.hh>
+#include <bse/bseprocedure.hh>
+#include <bse/bseeditablesample.hh>
+#include <bse/gsldatahandle.hh>
+#include "bsecxxplugin.hh"
 AUTHORS	= "Tim Janik <timj gtk org>";
 LICENSE = "GNU Lesser General Public License";
 METHOD (BseEditableSample, open) {
@@ -125,7 +126,7 @@ METHOD (BseEditableSample, read-samples) {
 				 BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
   IN	= sfi_pspec_int ("voffset", NULL, "Value offset",
 			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
-  OUT	= sfi_pspec_fblock ("sample_block", NULL, "Block of samples", SFI_PARAM_STANDARD);
+  OUT   = bse_param_spec_boxed ("sample_block", NULL, "Block of samples", BSE_TYPE_FLOAT_SEQ, SFI_PARAM_STANDARD);
 } BODY (BseProcedureClass *proc,
         const GValue      *in_values,
         GValue            *out_values)
@@ -134,27 +135,31 @@ METHOD (BseEditableSample, read-samples) {
   BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
   guint              voffset = sfi_value_get_int (in_values++);
   GslDataCache *dcache = NULL;
-  SfiFBlock *fblock;
+  BseFloatSeq *fseq;
   /* check parameters */
   if (!BSE_IS_EDITABLE_SAMPLE (esample))
     return BSE_ERROR_PROC_PARAM_INVAL;
   if (BSE_EDITABLE_SAMPLE_OPENED (esample) && esample->wchunk)
     dcache = esample->wchunk->dcache;
   if (!dcache || voffset >= gsl_data_handle_length (dcache->dhandle))
-    fblock = sfi_fblock_new_sized (1024);
+    {
+      fseq = bse_float_seq_new ();
+      bse_float_seq_resize (fseq, 1024);
+    }
   else
     {
       GslDataCacheNode *dnode = (GslDataCacheNode*) gsl_data_cache_ref_node (dcache, voffset, GSL_DATA_CACHE_DEMAND_LOAD);
       guint i, l, dnode_length = dcache->node_size;
       l = dnode_length - (voffset - dnode->offset) + dcache->padding;
       l = MIN (l, gsl_data_handle_length (dcache->dhandle) - voffset);
-      fblock = sfi_fblock_new_sized (l);
+      fseq = bse_float_seq_new ();
+      bse_float_seq_resize (fseq, l);
       for (i = 0; i < l; i++)
-	fblock->values[i] = dnode->data[voffset - dnode->offset + i];
+	fseq->values[i] = dnode->data[voffset - dnode->offset + i];
       gsl_data_cache_unref_node (dcache, dnode);
     }
   /* set output parameters */
-  sfi_value_take_fblock (out_values++, fblock);
+  g_value_take_boxed (out_values++, fseq);
   return BSE_ERROR_NONE;
 }
 METHOD (BseEditableSample, collect-stats) {
@@ -171,7 +176,7 @@ METHOD (BseEditableSample, collect-stats) {
 			 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
   IN	= sfi_pspec_int ("max_pairs", NULL, "Maximum number of (min, max) pairs to collect",
 			 1, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
-  OUT	= sfi_pspec_fblock ("sample_block", NULL, "Block of samples", SFI_PARAM_STANDARD);
+  OUT   = bse_param_spec_boxed ("sample_block", NULL, "Block of samples", BSE_TYPE_FLOAT_SEQ, SFI_PARAM_STANDARD);
 } BODY (BseProcedureClass *proc,
         const GValue      *in_values,
         GValue            *out_values)
@@ -184,23 +189,27 @@ METHOD (BseEditableSample, collect-stats) {
   guint              stepping   = sfi_value_get_int (in_values++);
   guint              max_pairs  = sfi_value_get_int (in_values++);
   GslDataCache *dcache = NULL;
-  SfiFBlock *fblock;
+  BseFloatSeq *fseq;
   /* check parameters */
   if (!BSE_IS_EDITABLE_SAMPLE (esample) || stepping < 1)
     return BSE_ERROR_PROC_PARAM_INVAL;
   if (BSE_EDITABLE_SAMPLE_OPENED (esample) && esample->wchunk)
     dcache = esample->wchunk->dcache;
   if (!dcache || voffset + block_size > gsl_data_handle_length (dcache->dhandle))
-    fblock = sfi_fblock_new_sized (max_pairs * 2);
+    {
+      fseq = bse_float_seq_new ();
+      bse_float_seq_resize (fseq, max_pairs * 2);
+    }
   else
     {
       GslDataCacheNode *dnode = gsl_data_cache_ref_node (dcache, voffset, GSL_DATA_CACHE_DEMAND_LOAD);
       guint j, dnode_length = dcache->node_size;
-      fblock = sfi_fblock_new_sized (max_pairs * 2);
+      fseq = bse_float_seq_new();
+      bse_float_seq_resize (fseq, max_pairs * 2);
       for (j = 0; j < max_pairs; j++)
 	{
 	  guint i, cur_offset = j * offs_scale;
-	  gfloat min = +1, max = -1;
+	  float min = +1, max = -1;
 	  /* keep alignment across offset scaling */
 	  cur_offset /= stepping;
 	  cur_offset = voffset + cur_offset * stepping;
@@ -220,14 +229,14 @@ METHOD (BseEditableSample, collect-stats) {
 	      min = MIN (min, dnode->data[pos]);
 	      max = MAX (max, dnode->data[pos]);
 	    }
-	  fblock->values[j * 2] = min;
-	  fblock->values[j * 2 + 1] = max;
+	  fseq->values[j * 2] = min;
+	  fseq->values[j * 2 + 1] = max;
 	}
       gsl_data_cache_unref_node (dcache, dnode);
     break_loops:
-      sfi_fblock_resize (fblock, j * 2);
+      bse_float_seq_resize (fseq, j * 2);
     }
   /* set output parameters */
-  sfi_value_take_fblock (out_values++, fblock);
+  g_value_take_boxed (out_values++, fseq);
   return BSE_ERROR_NONE;
 }
diff --git a/bse/bseprobe.cc b/bse/bseprobe.cc
index 63a9983..5a3557b 100644
--- a/bse/bseprobe.cc
+++ b/bse/bseprobe.cc
@@ -167,7 +167,7 @@ class ProbeQueue {
               rv[i] = ivalues[i] * blackman_window (i * reci_fft_size);
             gsl_power2_fftar (fft_size, rv, cv);
             probe.fft_data.resize (fft_size);
-            float *fvalues = probe.fft_data.fblock()->values;
+            double *fvalues = &probe.fft_data[0];
             reci_fft_size = 1.0 / fft_size;
             i = fft_size;
             while (i--) /* convert to float */
@@ -177,7 +177,7 @@ class ProbeQueue {
           {
             /* all raw floats are 0.0 and so will be the resulting fft */
             probe.fft_data.resize (fft_size);
-            bse_block_fill_float (fft_size, probe.fft_data.fblock()->values, 0.0);
+            bse_block_fill_0 (fft_size, &probe.fft_data[0]);
           }
         else
           probe_features.probe_fft = false;
@@ -190,9 +190,12 @@ class ProbeQueue {
         if (raw_floats)
           {
             /* if (probe_xrun) bse_block_fill_float (n_computed, raw_floats, 0.0); */
-            SfiFBlock *fblock = sfi_fblock_new_foreign (block_size, raw_floats, g_free);
+            probe.sample_data.resize (block_size);
+            double *fvalues = &probe.fft_data[0];
+            for (int i = 0; i < int (block_size); i++)
+              fvalues[i] = raw_floats[i];
+            g_free (raw_floats);
             raw_floats = NULL;
-            probe.sample_data.take (fblock);
           }
         else
           probe_features.probe_samples = false;
diff --git a/bse/bseprobe.idl b/bse/bseprobe.idl
index c4d7c34..8afe3cb 100644
--- a/bse/bseprobe.idl
+++ b/bse/bseprobe.idl
@@ -1,12 +1,14 @@
 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
 include "bsecxxmodule.idl";
 namespace Bse {
-record ProbeFeatures {
+
+  record ProbeFeatures {
   Bool          probe_range;
   Bool          probe_energie;
   Bool          probe_samples;
   Bool          probe_fft;
 };
+
 record Probe {
   Int           channel_id;
   Num           block_stamp;
@@ -15,8 +17,8 @@ record Probe {
   Real          min;			// FIXME: rename to range_min
   Real          max;
   Real          energie;
-  FBlock        sample_data;
-  FBlock        fft_data;
+  FloatSeq      sample_data;
+  FloatSeq      fft_data;
 };
 sequence ProbeSeq {
   Probe probes;
diff --git a/sfi/sfidl-parser.cc b/sfi/sfidl-parser.cc
index 2b4289e..9b0b535 100644
--- a/sfi/sfidl-parser.cc
+++ b/sfi/sfidl-parser.cc
@@ -743,7 +743,7 @@ bool Parser::parse (const String& filename)
   defineSymbol ("Real");
   defineSymbol ("String");
   // deprecated: defineSymbol ("BBlock");
-  defineSymbol ("FBlock");
+  // deprecated: defineSymbol ("FBlock");
   defineSymbol ("Rec");
   leaveNamespace ();
   GTokenType expected_token = G_TOKEN_NONE;
diff --git a/tests/bse/testplugin.idl b/tests/bse/testplugin.idl
index 512c747..e95fcc1 100644
--- a/tests/bse/testplugin.idl
+++ b/tests/bse/testplugin.idl
@@ -27,7 +27,7 @@ interface TestObject : Bse::Effect {
   property TestRecord r;
   property TestSequence s;
   // deprecated: property BBlock bb;
-  property FBlock fb;
+  // deprecated: property FBlock fb;
   property Rec rr;
   property Bse::Effect ef; // C++ Object 
   property Bse::Item it;   // C Object



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