[beast: 9/13] BSE: move most Bse.EditableSample methods into bseapi.idl
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 9/13] BSE: move most Bse.EditableSample methods into bseapi.idl
- Date: Thu, 31 Aug 2017 23:04:04 +0000 (UTC)
commit 325b8e032647f20ba9880a52c187e3e161feda9d
Author: Tim Janik <timj gnu org>
Date: Fri Sep 1 00:12:34 2017 +0200
BSE: move most Bse.EditableSample methods into bseapi.idl
Signed-off-by: Tim Janik <timj gnu org>
bse/bseapi.idl | 10 ++--
bse/bseeditablesample.cc | 57 +++++++++++++++++++
bse/bseeditablesample.hh | 9 ++-
bse/bseeditablesample.proc | 134 --------------------------------------------
4 files changed, 69 insertions(+), 141 deletions(-)
---
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index 04761fd..721b8fc 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -818,11 +818,11 @@ interface EditableSample : Item {
* @return Block of samples
*/
//FloatSeq collect_stats (int64 voffset, float64 offset_scale, int64 block_size, int64 stepping, int64
max_pairs);
- //void close (); ///< Close an opened sample.
- //int64 get_length (); ///< Return the number of values in the sample.
- //int64 get_n_channels (); ///< Return the number of channels in the sample.
- //float64 get_osc_freq (); ///< Return the oscillator frequency for the sample.
- //Error open (); ///< Open the sample for reading.
+ void close (); ///< Close an opened sample.
+ int64 get_length (); ///< Return the number of values in the sample.
+ int64 get_n_channels (); ///< Return the number of channels in the sample.
+ float64 get_osc_freq (); ///< Return the oscillator frequency for the sample.
+ Error open (); ///< Open the sample for reading.
//signal void changed (); ///< Signal indicating all sorts of possible changes.
};
diff --git a/bse/bseeditablesample.cc b/bse/bseeditablesample.cc
index 6d9ebca..6235a58 100644
--- a/bse/bseeditablesample.cc
+++ b/bse/bseeditablesample.cc
@@ -181,4 +181,61 @@ EditableSampleImpl::EditableSampleImpl (BseObject *bobj) :
EditableSampleImpl::~EditableSampleImpl ()
{}
+void
+EditableSampleImpl::close ()
+{
+ BseEditableSample *self = as<BseEditableSample*>();
+ if (self->open_count)
+ {
+ self->open_count--;
+ if (!self->open_count)
+ gsl_wave_chunk_close (self->wchunk);
+ }
+}
+
+int64
+EditableSampleImpl::get_length ()
+{
+ BseEditableSample *self = as<BseEditableSample*>();
+ GslDataCache *dcache = NULL;
+ if (BSE_EDITABLE_SAMPLE_OPENED (self) && self->wchunk)
+ dcache = self->wchunk->dcache;
+ return dcache ? gsl_data_handle_length (dcache->dhandle) : 0;
+}
+
+int64
+EditableSampleImpl::get_n_channels ()
+{
+ BseEditableSample *self = as<BseEditableSample*>();
+ return self->wchunk ? self->wchunk->n_channels : 1;
+}
+
+double
+EditableSampleImpl::get_osc_freq ()
+{
+ BseEditableSample *self = as<BseEditableSample*>();
+ return self->wchunk ? self->wchunk->osc_freq : BSE_KAMMER_FREQUENCY;
+}
+
+Error
+EditableSampleImpl::open ()
+{
+ BseEditableSample *self = as<BseEditableSample*>();
+ Error error;
+ if (!self->wchunk)
+ error = Error::WAVE_NOT_FOUND;
+ else if (self->open_count)
+ {
+ self->open_count++;
+ error = Error::NONE;
+ }
+ else
+ {
+ error = gsl_wave_chunk_open (self->wchunk);
+ if (error == 0)
+ self->open_count++;
+ }
+ return error;
+}
+
} // Bse
diff --git a/bse/bseeditablesample.hh b/bse/bseeditablesample.hh
index 3d86167..28c76f4 100644
--- a/bse/bseeditablesample.hh
+++ b/bse/bseeditablesample.hh
@@ -30,9 +30,14 @@ namespace Bse {
class EditableSampleImpl : public ItemImpl, public virtual EditableSampleIface {
protected:
- virtual ~EditableSampleImpl ();
+ virtual ~EditableSampleImpl ();
public:
- explicit EditableSampleImpl (BseObject*);
+ explicit EditableSampleImpl (BseObject*);
+ virtual void close () override;
+ virtual int64 get_length () override;
+ virtual int64 get_n_channels () override;
+ virtual double get_osc_freq () override;
+ virtual Error open () override;
};
} // Bse
diff --git a/bse/bseeditablesample.proc b/bse/bseeditablesample.proc
index 8d8064a..3cbee1f 100644
--- a/bse/bseeditablesample.proc
+++ b/bse/bseeditablesample.proc
@@ -9,140 +9,6 @@
AUTHORS = "Tim Janik <timj gtk org>";
LICENSE = "GNU Lesser General Public License";
-METHOD (BseEditableSample, open) {
- HELP = ("Open the sample for reading.");
- IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
- BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
- OUT = bse_param_spec_genum ("error", "Error", NULL,
- BSE_TYPE_ERROR_TYPE, Bse::Error::NONE,
- SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
- const GValue *in_values,
- GValue *out_values)
-{
- /* extract parameter values */
- BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
- Bse::Error error;
-
- /* check parameters */
- if (!BSE_IS_EDITABLE_SAMPLE (esample))
- return Bse::Error::PROC_PARAM_INVAL;
-
- /* action */
- if (!esample->wchunk)
- error = Bse::Error::WAVE_NOT_FOUND;
- else if (esample->open_count)
- {
- esample->open_count++;
- error = Bse::Error::NONE;
- }
- else
- {
- error = gsl_wave_chunk_open (esample->wchunk);
- if (error == 0)
- esample->open_count++;
- }
-
- /* set output parameters */
- g_value_set_enum (out_values++, int (error));
-
- return Bse::Error::NONE;
-}
-
-METHOD (BseEditableSample, close) {
- HELP = ("Close an opened sample.");
- IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
- BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
- const GValue *in_values,
- GValue *out_values)
-{
- /* extract parameter values */
- BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
-
- /* check parameters */
- if (!BSE_IS_EDITABLE_SAMPLE (esample) || !esample->wchunk || !esample->open_count)
- return Bse::Error::PROC_PARAM_INVAL;
-
- /* action */
- esample->open_count--;
- if (!esample->open_count)
- gsl_wave_chunk_close (esample->wchunk);
-
- return Bse::Error::NONE;
-}
-
-METHOD (BseEditableSample, get-length) {
- HELP = ("Return the number of values in the sample.");
- IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
- BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
- OUT = sfi_pspec_int ("length", NULL, "Number of values",
- 1, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
- const GValue *in_values,
- GValue *out_values)
-{
- /* extract parameter values */
- BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
- GslDataCache *dcache = NULL;
-
- /* check parameters */
- if (!BSE_IS_EDITABLE_SAMPLE (esample))
- return Bse::Error::PROC_PARAM_INVAL;
-
- /* set output parameters */
- if (BSE_EDITABLE_SAMPLE_OPENED (esample) && esample->wchunk)
- dcache = esample->wchunk->dcache;
- sfi_value_set_int (out_values++, dcache ? gsl_data_handle_length (dcache->dhandle) : 0);
-
- return Bse::Error::NONE;
-}
-
-METHOD (BseEditableSample, get-n-channels) {
- HELP = ("Return the number of channels in the sample.");
- IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
- BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
- OUT = sfi_pspec_int ("n-channels", NULL, "Number of channels",
- 0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
- const GValue *in_values,
- GValue *out_values)
-{
- /* extract parameter values */
- BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
-
- /* check parameters */
- if (!BSE_IS_EDITABLE_SAMPLE (esample))
- return Bse::Error::PROC_PARAM_INVAL;
-
- /* set output parameters */
- sfi_value_set_int (out_values++, esample->wchunk ? esample->wchunk->n_channels : 1);
-
- return Bse::Error::NONE;
-}
-
-METHOD (BseEditableSample, get-osc-freq) {
- HELP = ("Return the oscillator frequency for the sample.");
- IN = bse_param_spec_object ("esample", "Editable Sample", NULL,
- BSE_TYPE_EDITABLE_SAMPLE, SFI_PARAM_STANDARD);
- OUT = bse_param_spec_freq_simple ("osc-freq", NULL, "Oscillator Frequency",
- SFI_PARAM_STANDARD);
-} BODY (BseProcedureClass *proc,
- const GValue *in_values,
- GValue *out_values)
-{
- /* extract parameter values */
- BseEditableSample *esample = (BseEditableSample*) bse_value_get_object (in_values++);
-
- /* check parameters */
- if (!BSE_IS_EDITABLE_SAMPLE (esample))
- return Bse::Error::PROC_PARAM_INVAL;
-
- /* set output parameters */
- sfi_value_set_real (out_values++, esample->wchunk ? esample->wchunk->osc_freq : BSE_KAMMER_FREQUENCY);
-
- return Bse::Error::NONE;
-}
METHOD (BseEditableSample, collect-stats) {
HELP = ("Collect statistics from sample blocks as (minimum, maximum) pairs.");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]