Ejemplo n.º 1
0
static gboolean
xmms_vocoder_init (xmms_xform_t *xform)
{
	xmms_vocoder_data_t *priv;
	xmms_config_property_t *config;

	g_return_val_if_fail (xform, FALSE);

	priv = g_new0 (xmms_vocoder_data_t, 1);
	priv->winsize = 2048;
	priv->channels = xmms_xform_indata_get_int (xform, XMMS_STREAM_TYPE_FMT_CHANNELS);
	priv->bufsize = priv->winsize * priv->channels;

	priv->iobuf = g_malloc (priv->bufsize * sizeof (gint16));
	priv->procbuf = g_malloc (priv->bufsize * sizeof (pvocoder_sample_t));
	priv->resbuf = g_malloc (priv->bufsize * sizeof (gfloat));
	priv->outbuf = g_string_new (NULL);

	priv->pvoc = pvocoder_init (priv->winsize, priv->channels);
	g_return_val_if_fail (priv->pvoc, FALSE);

	priv->resampler = src_new (SRC_LINEAR, priv->channels, NULL);
	g_return_val_if_fail (priv->resampler, FALSE);

	xmms_xform_private_data_set (xform, priv);

	config = xmms_xform_config_lookup (xform, "enabled");
	g_return_val_if_fail (config, FALSE);
	xmms_config_property_callback_set (config, xmms_vocoder_config_changed, priv);
	priv->enabled = !!xmms_config_property_get_int (config);

	config = xmms_xform_config_lookup (xform, "speed");
	g_return_val_if_fail (config, FALSE);
	xmms_config_property_callback_set (config, xmms_vocoder_config_changed, priv);
	priv->speed = (gfloat) xmms_config_property_get_int (config) / 100.0;

	config = xmms_xform_config_lookup (xform, "pitch");
	g_return_val_if_fail (config, FALSE);
	xmms_config_property_callback_set (config, xmms_vocoder_config_changed, priv);
	priv->pitch = 100.0 / (gfloat) xmms_config_property_get_int (config);

	config = xmms_xform_config_lookup (xform, "attack_detection");
	g_return_val_if_fail (config, FALSE);
	xmms_config_property_callback_set (config, xmms_vocoder_config_changed, priv);
	priv->attack_detection = !!xmms_config_property_get_int (config);

	pvocoder_set_scale (priv->pvoc, priv->speed * priv->pitch);
	pvocoder_set_attack_detection (priv->pvoc, priv->attack_detection);

	priv->resdata.data_in = NULL;
	priv->resdata.input_frames = 0;
	priv->resdata.data_out = priv->resbuf;
	priv->resdata.output_frames = priv->winsize;
	priv->resdata.src_ratio = priv->pitch;
	priv->resdata.end_of_input = 0;

	xmms_xform_outdata_type_copy (xform);

	return TRUE;
}
Ejemplo n.º 2
0
static gboolean
xmms_normalize_init (xmms_xform_t *xform)
{
	xmms_config_property_t *cfgv;
	xmms_normalize_data_t *data;
	int i;

	g_return_val_if_fail (xform, FALSE);

	data = g_new0 (xmms_normalize_data_t, 1);

	for (i = 0; i < G_N_ELEMENTS (config_params); i++) {
		cfgv = xmms_xform_config_lookup (xform, config_params[i].key);
		xmms_config_property_callback_set (cfgv,
		                                   xmms_normalize_config_changed,
		                                   data);

		xmms_normalize_config_changed (XMMS_OBJECT (cfgv), NULL, data);
	}

	xmms_xform_outdata_type_copy (xform);

	data->dirty = FALSE;

	data->compress = compress_new (data->use_anticlip,
	                               data->target,
	                               data->max_gain,
	                               data->smooth,
	                               data->buckets);

	xmms_xform_private_data_set (xform, data);

	return TRUE;
}
Ejemplo n.º 3
0
static void
effect_callbacks_init (void)
{
	gint effect_no;

	xmms_config_property_t *cfg;
	xmms_xform_plugin_t *xform_plugin;
	xmms_plugin_t *plugin;
	gchar key[64];
	const gchar *name;

	for (effect_no = 0; ; effect_no++) {
		g_snprintf (key, sizeof (key), "effect.order.%i", effect_no);

		cfg = xmms_config_lookup (key);
		if (!cfg) {
			break;
		}
		xmms_config_property_callback_set (cfg, update_effect_properties,
		                                   GINT_TO_POINTER (effect_no));

		name = xmms_config_property_get_string (cfg);
		if (!name[0]) {
			continue;
		}

		plugin = xmms_plugin_find (XMMS_PLUGIN_TYPE_XFORM, name);
		if (!plugin) {
			xmms_log_error ("Couldn't find any effect named '%s'", name);
			continue;
		}

		xform_plugin = (xmms_xform_plugin_t *) plugin;
		xmms_xform_plugin_config_property_register (xform_plugin, "enabled",
		                                            "1", NULL, NULL);

		xmms_object_unref (plugin);
	}

	/* the name stored in the last present property was not "" or there was no
	   last present property */
	if ((!effect_no) || name[0]) {
			xmms_config_property_register (key, "", update_effect_properties,
			                               GINT_TO_POINTER (effect_no));
	}
}
Ejemplo n.º 4
0
static gboolean
xmms_eq_init (xmms_xform_t *xform)
{
	xmms_equalizer_data_t *priv;
	xmms_config_property_t *config;
	gint i, j, srate;
	gfloat gain;

	g_return_val_if_fail (xform, FALSE);

	priv = g_new0 (xmms_equalizer_data_t, 1);
	g_return_val_if_fail (priv, FALSE);

	xmms_xform_private_data_set (xform, priv);

	config = xmms_xform_config_lookup (xform, "enabled");
	g_return_val_if_fail (config, FALSE);
	xmms_config_property_callback_set (config, xmms_eq_config_changed, priv);
	priv->enabled = !!xmms_config_property_get_int (config);

	config = xmms_xform_config_lookup (xform, "bands");
	g_return_val_if_fail (config, FALSE);
	xmms_config_property_callback_set (config, xmms_eq_config_changed, priv);
	priv->bands = xmms_config_property_get_int (config);

	config = xmms_xform_config_lookup (xform, "extra_filtering");
	g_return_val_if_fail (config, FALSE);
	xmms_config_property_callback_set (config, xmms_eq_config_changed, priv);
	priv->extra_filtering = xmms_config_property_get_int (config);

	config = xmms_xform_config_lookup (xform, "use_legacy");
	g_return_val_if_fail (config, FALSE);
	xmms_config_property_callback_set (config, xmms_eq_config_changed, priv);
	priv->use_legacy = xmms_config_property_get_int (config);

	config = xmms_xform_config_lookup (xform, "preamp");
	g_return_val_if_fail (config, FALSE);
	xmms_config_property_callback_set (config, xmms_eq_gain_changed, priv);
	gain = xmms_config_property_get_float (config);

	for (i=0; i<EQ_CHANNELS; i++) {
		set_preamp (i, xmms_eq_gain_scale (gain, TRUE));
	}

	for (i=0; i<EQ_BANDS_LEGACY; i++) {
		gchar buf[16];

		g_snprintf (buf, sizeof (buf), "legacy%d", i);
		config = xmms_xform_config_lookup (xform, buf);
		g_return_val_if_fail (config, FALSE);

		priv->legacy[i] = config;
		xmms_config_property_callback_set (config, xmms_eq_gain_changed, priv);

		gain = xmms_config_property_get_float (config);
		if (priv->use_legacy) {
			for (j = 0; j < EQ_CHANNELS; j++) {
				set_gain (i, j, xmms_eq_gain_scale (gain, FALSE));
			}
		}
	}

	for (i=0; i<EQ_MAX_BANDS; i++) {
		gchar buf[16];

		g_snprintf (buf, sizeof (buf), "gain%02d", i);
		config = xmms_xform_config_lookup (xform, buf);
		g_return_val_if_fail (config, FALSE);

		priv->gain[i] = config;
		xmms_config_property_callback_set (config, xmms_eq_gain_changed, priv);

		gain = xmms_config_property_get_float (config);
		if (!priv->use_legacy) {
			for (j = 0; j < EQ_CHANNELS; j++) {
				set_gain (i, j, xmms_eq_gain_scale (gain, FALSE));
			}
		}
	}

	init_iir ();
	srate = xmms_xform_indata_get_int (xform, XMMS_STREAM_TYPE_FMT_SAMPLERATE);
	if (priv->use_legacy) {
		config_iir (srate, EQ_BANDS_LEGACY, 1);
	} else {
		config_iir (srate, priv->bands, 0);
	}

	xmms_xform_outdata_type_copy (xform);

	XMMS_DBG ("Equalizer initialized successfully!");

	return TRUE;
}
Ejemplo n.º 5
0
static gboolean
xmms_replaygain_init (xmms_xform_t *xform)
{
    xmms_replaygain_data_t *data;
    xmms_config_property_t *cfgv;
    xmms_sample_format_t fmt;

    g_return_val_if_fail (xform, FALSE);

    data = g_new0 (xmms_replaygain_data_t, 1);
    g_return_val_if_fail (data, FALSE);

    xmms_xform_private_data_set (xform, data);

    cfgv = xmms_xform_config_lookup (xform, "mode");
    xmms_config_property_callback_set (cfgv,
                                       xmms_replaygain_config_changed,
                                       xform);

    data->mode = parse_mode (xmms_config_property_get_string (cfgv));

    cfgv = xmms_xform_config_lookup (xform, "use_anticlip");
    xmms_config_property_callback_set (cfgv,
                                       xmms_replaygain_config_changed,
                                       xform);

    data->use_anticlip = !!xmms_config_property_get_int (cfgv);

    cfgv = xmms_xform_config_lookup (xform, "preamp");
    xmms_config_property_callback_set (cfgv,
                                       xmms_replaygain_config_changed,
                                       xform);

    data->preamp = pow (10.0, atof (xmms_config_property_get_string (cfgv)) / 20.0);

    cfgv = xmms_xform_config_lookup (xform, "enabled");
    xmms_config_property_callback_set (cfgv,
                                       xmms_replaygain_config_changed,
                                       xform);

    data->enabled = !!xmms_config_property_get_int (cfgv);

    xmms_xform_outdata_type_copy (xform);

    compute_gain (xform, data);

    fmt = xmms_xform_indata_get_int (xform, XMMS_STREAM_TYPE_FMT_FORMAT);

    switch (fmt) {
    case XMMS_SAMPLE_FORMAT_S8:
        data->apply = apply_s8;
        break;
    case XMMS_SAMPLE_FORMAT_U8:
        data->apply = apply_u8;
        break;
    case XMMS_SAMPLE_FORMAT_S16:
        data->apply = apply_s16;
        break;
    case XMMS_SAMPLE_FORMAT_U16:
        data->apply = apply_u16;
        break;
    case XMMS_SAMPLE_FORMAT_S32:
        data->apply = apply_s32;
        break;
    case XMMS_SAMPLE_FORMAT_U32:
        data->apply = apply_u32;
        break;
    case XMMS_SAMPLE_FORMAT_FLOAT:
        data->apply = apply_float;
        break;
    case XMMS_SAMPLE_FORMAT_DOUBLE:
        data->apply = apply_double;
        break;
    default:
        /* we shouldn't ever get here, since we told the daemon
         * earlier about this list of supported formats.
         */
        g_assert_not_reached ();
        break;
    }

    return TRUE;
}
Ejemplo n.º 6
0
static gboolean
xmms_modplug_init (xmms_xform_t *xform)
{
	xmms_modplug_data_t *data;
	const gchar *metakey;
	gint filesize;
	xmms_config_property_t *cfgv;
	gint i;

	g_return_val_if_fail (xform, FALSE);

	data = g_new0 (xmms_modplug_data_t, 1);

	xmms_xform_private_data_set (xform, data);

	for (i = 0; i < G_N_ELEMENTS (config_params); i++) {
		cfgv = xmms_xform_config_lookup (xform, config_params[i].key);
		xmms_config_property_callback_set (cfgv,
		                                   xmms_modplug_config_changed,
		                                   data);

		xmms_modplug_config_changed (XMMS_OBJECT (cfgv), NULL, data);
	}

	/* mFrequency and mResamplingMode are set in config_changed */
	data->settings.mChannels = 2;
	data->settings.mBits = 16;
	ModPlug_SetSettings (&data->settings);

	xmms_xform_outdata_type_add (xform,
	                             XMMS_STREAM_TYPE_MIMETYPE,
	                             "audio/pcm",
	                             XMMS_STREAM_TYPE_FMT_FORMAT,
	                             XMMS_SAMPLE_FORMAT_S16,
	                             XMMS_STREAM_TYPE_FMT_CHANNELS,
	                             2,
	                             XMMS_STREAM_TYPE_FMT_SAMPLERATE,
	                             data->settings.mFrequency,
	                             XMMS_STREAM_TYPE_END);

	data->buffer = g_string_new ("");

	for (;;) {
		xmms_error_t error;
		gchar buf[4096];
		gint ret;

		ret = xmms_xform_read (xform, buf, sizeof (buf), &error);
		if (ret == -1) {
			XMMS_DBG ("Error reading mod");
			return FALSE;
		}
		if (ret == 0) {
			break;
		}
		g_string_append_len (data->buffer, buf, ret);
	}

	data->mod = ModPlug_Load (data->buffer->str, data->buffer->len);
	if (!data->mod) {
		XMMS_DBG ("Error loading mod");
		return FALSE;
	}

	metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_SIZE;
	if (xmms_xform_metadata_get_int (xform, metakey, &filesize)) {
		metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_DURATION;
		xmms_xform_metadata_set_int (xform, metakey,
		                             ModPlug_GetLength (data->mod));
	}

	metakey = XMMS_MEDIALIB_ENTRY_PROPERTY_TITLE;
	xmms_xform_metadata_set_str (xform, metakey, ModPlug_GetName (data->mod));

	return TRUE;
}