<commit_before>/* GStreamer
 * Copyright (C) 2012 <NAME> <<EMAIL>>
 *
 * sidsynv.cc: c64 sid synthesizer voice
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "libgstbuzztard/propertymeta.h"
#include "libgstbuzztard/tempo.h"

#include "sidsynv.h"

#define GST_CAT_DEFAULT sid_syn_debug
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_DEFAULT);

enum
{
  PROP_NOTE = 1,
  PROP_SYNC,
  PROP_RING_MOD,
  PROP_TEST,
	PROP_WAVE,
	PROP_PULSE_WIDTH,
	PROP_FILTER_VOICE,
	PROP_ATTACK,
	PROP_DECAY,
	PROP_SUSTAIN,
	PROP_RELEASE  
};

#define GSTBT_TYPE_SID_SYN_WAVE (gst_sid_syn_wave_get_type())
static GType
gst_sid_syn_wave_get_type (void)
{
  static GType type = 0;
  static const GEnumValue enums[] = {
    {GSTBT_SID_SYN_WAVE_TRIANGLE, "Triangle", "triangle"},
    {GSTBT_SID_SYN_WAVE_SAW, "Saw", "saw"},
    {GSTBT_SID_SYN_WAVE_SAW_TRIANGLE, "Saw+Triangle", "saw-triangle"},
    {GSTBT_SID_SYN_WAVE_PULSE, "Pulse", "pulse"},
    {GSTBT_SID_SYN_WAVE_PULSE_TRIANGLE, "Pulse+Triangle", "pulse-triangle"},
    {GSTBT_SID_SYN_WAVE_PULSE_SAW, "Pulse+Saw", "pulse-saw"},
    {GSTBT_SID_SYN_WAVE_PULSE_SAW_TRIANGLE, "Pulse+Saw+Triangle", "pulse-saw-triangle"},
    {GSTBT_SID_SYN_WAVE_NOISE, "Noise", "noise"},
    {0, NULL, NULL},
  };

  if (G_UNLIKELY (!type)) {
    type = g_enum_register_static ("GstBtSidSynWave", enums);
  }
  return type;
}


G_DEFINE_TYPE (GstBtSidSynV, gstbt_sid_synv, GST_TYPE_OBJECT);

static void
gst_sid_synv_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstBtSidSynV *src = GSTBT_SID_SYNV (object);

  switch (prop_id) {
    case PROP_NOTE:
      src->note = (GstBtNote) g_value_get_enum (value);
      if (src->note) {
        src->note_set = TRUE;
      }
      break;
    case PROP_SYNC:
      src->sync = g_value_get_boolean (value);
      break;
    case PROP_RING_MOD:
      src->ringmod = g_value_get_boolean (value);
      break;
    case PROP_TEST:
      src->test = g_value_get_boolean (value);
      break;
    case PROP_WAVE:
      src->wave = (GstBtSidSynWave) g_value_get_enum (value);
      break;
    case PROP_PULSE_WIDTH:
      src->pulse_width = g_value_get_uint (value);<commit_msg>sidsyn: add property meta for human readable envelope times<commit_after>/* GStreamer
 * Copyright (C) 2012 <NAME> <<EMAIL>>
 *
 * sidsynv.cc: c64 sid synthesizer voice
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "libgstbuzztard/propertymeta.h"
#include "libgstbuzztard/tempo.h"

#include "sidsynv.h"

#define GST_CAT_DEFAULT sid_syn_debug
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_DEFAULT);

enum
{
  PROP_NOTE = 1,
  PROP_SYNC,
  PROP_RING_MOD,
  PROP_TEST,
	PROP_WAVE,
	PROP_PULSE_WIDTH,
	PROP_FILTER_VOICE,
	PROP_ATTACK,
	PROP_DECAY,
	PROP_SUSTAIN,
	PROP_RELEASE  
};

#define GSTBT_TYPE_SID_SYN_WAVE (gst_sid_syn_wave_get_type())
static GType
gst_sid_syn_wave_get_type (void)
{
  static GType type = 0;
  static const GEnumValue enums[] = {
    {GSTBT_SID_SYN_WAVE_TRIANGLE, "Triangle", "triangle"},
    {GSTBT_SID_SYN_WAVE_SAW, "Saw", "saw"},
    {GSTBT_SID_SYN_WAVE_SAW_TRIANGLE, "Saw+Triangle", "saw-triangle"},
    {GSTBT_SID_SYN_WAVE_PULSE, "Pulse", "pulse"},
    {GSTBT_SID_SYN_WAVE_PULSE_TRIANGLE, "Pulse+Triangle", "pulse-triangle"},
    {GSTBT_SID_SYN_WAVE_PULSE_SAW, "Pulse+Saw", "pulse-saw"},
    {GSTBT_SID_SYN_WAVE_PULSE_SAW_TRIANGLE, "Pulse+Saw+Triangle", "pulse-saw-triangle"},
    {GSTBT_SID_SYN_WAVE_NOISE, "Noise", "noise"},
    {0, NULL, NULL},
  };

  if (G_UNLIKELY (!type)) {
    type = g_enum_register_static ("GstBtSidSynWave", enums);
  }
  return type;
}

static void gst_sid_synv_property_meta_interface_init (gpointer const g_iface,
    gpointer const iface_data);

G_DEFINE_TYPE_WITH_CODE (GstBtSidSynV, gstbt_sid_synv, GST_TYPE_OBJECT,
    G_IMPLEMENT_INTERFACE (GSTBT_TYPE_PROPERTY_META,
        gst_sid_synv_property_meta_interface_init));

//-- property meta interface implementations


static gchar *
gst_sid_synv_property_meta_describe_property (GstBtPropertyMeta *property_meta,
  glong prop_id, GValue *value)
{
  //GstBtSidSynV *src = GSTBT_SID_SYNV (property_meta);
  gchar *res = NULL;
  static const gchar *attack[] = {
		"2 ms",	"8 ms",	"16 ms", "24 ms",	"38 ms", "56 ms", "68 ms", "80 ms",
		"100 ms",	"240 ms",	"500 ms",	"800 ms",	"1 s", "3 s", "5 s", "8 s"
  };
  static const gchar *decay_release[] = {
    "6 ms", "24 ms", "48 ms", "72 ms", "114 ms", "168 ms", "204 ms", "240 ms",
    "300 ms", "750 ms", "1.5 s", "2.4 s", "3 s", "9 s", "15 s", "24 s",
  };

  switch (prop_id + 1) {
    case PROP_ATTACK:
      res = g_strdup (attack [g_value_get_uint (value)]);
      break;
    case PROP_DECAY:
      res = g_strdup (decay_release [g_value_get_uint (value)]);
      break;
    case PROP_RELEASE:
      res = g_strdup (decay_release [g_value_get_uint (value)]);
      break;
    default:
      break;
  }
  return res;
}

static void
gst_sid_synv_property_meta_interface_init (gpointer const g_iface,
    gpointer const iface_data)
{
  GstBtPropertyMetaInterface *const iface = 
      (GstBtPropertyMetaInterface *const)g_iface;

  GST_INFO("initializing iface");

  iface->describe_property = gst_sid_synv_property_meta_describe_property;
}

//-- sid syn voice class implementation

static void
gst_sid_synv_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstBtSidSynV *src = GSTBT_SID_SYNV (object);

  switch (prop_id) {
    case PROP_NOTE:
      src->note = (GstBtNote) g_value_get_enum (value);
      if (src->note) {
        src->note_set = TRUE;
      }
      break;
    case PROP_SYNC:
      src->sync = g_value_get_boolean (value);
      break;
    case PROP_RING_MOD:
      src->ringmod = g_value_get_boolean (value);
      break;
    case PROP_TEST:
      src->test = g_value_get_boolean (value);
      break;
    case PROP_WAVE:
      src->wave = (GstBtSidSynWave) g_value_get_enum (value);
      break;
    case PROP_PULSE_WIDTH:
      src->pulse_width = g_value_get_uint (value);
{'fraction_non_alphanumeric': 0.10716201716738197, 'fraction_numerical': 0.01528969957081545, 'mean_word_length': 4.100547195622435, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1963744', 'n_tokens_mistral': 3039, 'n_tokens_neox': 2848, 'n_words': 705}