static void speed_process (float * * data, int * samples) { double pitch = aud_get_double (CFGSECT, "pitch"); double speed = aud_get_double (CFGSECT, "speed"); /* Remove audio that has already been played from the output buffer. */ bufcut (& out, written); /* Copy the passed audio to the input buffer, scaled to adjust pitch. */ bufadd (& in, * data, * samples / curchans, 1.0 / pitch); /* If we are ending, add silence to the end of the input signal. */ if (ending) bufgrow (& in, in.len + width / 2); /* Calculate the spacing interval for input. */ int instep = round (outstep * speed / pitch); /* Run the speed change algorithm. */ int src = 0; int dst = 0; while (src + MAX (width, instep) <= in.len) { bufgrow (& out, dst + width); out.len = dst + width; for (int i = 0; i < width; i ++) for (int c = 0; c < curchans; c ++) OFFSET (out.mem, dst + i)[c] += OFFSET (in.mem, src + i)[c] * cosine[i]; src += instep; dst += outstep; } /* Remove processed audio from the input buffer. */ bufcut (& in, src); /* Trim silence from the beginning of the output buffer. */ if (trim > 0) { int cut = MIN (trim, dst); bufcut (& out, cut); dst -= cut; trim -= cut; } /* If we are ending, return all of the output buffer except the silence that * we trim from the end of it. */ if (ending) dst = out.len - width / 2; /* Return processed audio in the output buffer and mark it to be removed on * the next call. */ * data = out.mem; * samples = dst * curchans; written = dst; }
static void do_ramp (float * data, int length, float peak_a, float peak_b) { float center = aud_get_double ("compressor", "center"); float range = aud_get_double ("compressor", "range"); float a = powf (peak_a / center, range - 1); float b = powf (peak_b / center, range - 1); for (int count = 0; count < length; count ++) { * data = (* data) * (a * (length - count) + b * count) / length; data ++; } }
static void load_enabled_from_config (void) { int count = aud_get_int ("ladspa", "plugin_count"); for (int i = 0; i < count; i ++) { char key[32]; snprintf (key, sizeof key, "plugin%d_path", i); char * path = aud_get_string ("ladspa", key); snprintf (key, sizeof key, "plugin%d_label", i); char * label = aud_get_string ("ladspa", key); PluginData * plugin = find_plugin (path, label); if (plugin) { LoadedPlugin * loaded = enable_plugin_locked (plugin); int ccount = index_count (loaded->plugin->controls); for (int ci = 0; ci < ccount; ci ++) { snprintf (key, sizeof key, "plugin%d_control%d", i, ci); loaded->values[ci] = aud_get_double ("ladspa", key); } } g_free (path); g_free (label); } }
static gboolean init (void) { aud_config_set_defaults ("crystalizer", cryst_defaults); value = aud_get_double ("crystalizer", "intensity"); return TRUE; }
static void modplug_settings_load () { aud_config_set_defaults (MODPLUG_CFGID, modplug_defaults); modplug_settings.mBits = aud_get_int (MODPLUG_CFGID, "Bits"); modplug_settings.mChannels = aud_get_int (MODPLUG_CFGID, "Channels"); modplug_settings.mResamplingMode = aud_get_int (MODPLUG_CFGID, "ResamplingMode"); modplug_settings.mFrequency = aud_get_int (MODPLUG_CFGID, "Frequency"); modplug_settings.mReverb = aud_get_bool (MODPLUG_CFGID, "Reverb"); modplug_settings.mReverbDepth = aud_get_int (MODPLUG_CFGID, "ReverbDepth"); modplug_settings.mReverbDelay = aud_get_int (MODPLUG_CFGID, "ReverbDelay"); modplug_settings.mMegabass = aud_get_bool (MODPLUG_CFGID, "Megabass"); modplug_settings.mBassAmount = aud_get_int (MODPLUG_CFGID, "BassAmount"); modplug_settings.mBassRange = aud_get_int (MODPLUG_CFGID, "BassRange"); modplug_settings.mSurround = aud_get_bool (MODPLUG_CFGID, "Surround"); modplug_settings.mSurroundDepth = aud_get_int (MODPLUG_CFGID, "SurroundDepth"); modplug_settings.mSurroundDelay = aud_get_int (MODPLUG_CFGID, "SurroundDelay"); modplug_settings.mPreamp = aud_get_bool (MODPLUG_CFGID, "PreAmp"); modplug_settings.mPreampLevel = aud_get_double (MODPLUG_CFGID, "PreAmpLevel"); modplug_settings.mOversamp = aud_get_bool (MODPLUG_CFGID, "Oversampling"); modplug_settings.mNoiseReduction = aud_get_bool (MODPLUG_CFGID, "NoiseReduction"); modplug_settings.mGrabAmigaMOD = aud_get_bool (MODPLUG_CFGID, "GrabAmigaMOD"); modplug_settings.mLoopCount = aud_get_int (MODPLUG_CFGID, "LoopCount"); }
static void mp3_init(write_output_callback write_output_func) { aud_config_set_defaults ("filewriter_mp3", mp3_defaults); vbr_on = aud_get_int ("filewriter_mp3", "vbr_on"); vbr_type = aud_get_int ("filewriter_mp3", "vbr_type"); vbr_min_val = aud_get_int ("filewriter_mp3", "vbr_min_val"); vbr_max_val = aud_get_int ("filewriter_mp3", "vbr_max_val"); enforce_min_val = aud_get_int ("filewriter_mp3", "enforce_min_val"); vbr_quality_val = aud_get_int ("filewriter_mp3", "vbr_quality_val"); abr_val = aud_get_int ("filewriter_mp3", "abr_val"); toggle_xing_val = aud_get_int ("filewriter_mp3", "toggle_xing_val"); mark_original_val = aud_get_int ("filewriter_mp3", "mark_original_val"); mark_copyright_val = aud_get_int ("filewriter_mp3", "mark_copyright_val"); force_v2_val = aud_get_int ("filewriter_mp3", "force_v2_val"); only_v1_val = aud_get_int ("filewriter_mp3", "only_v1_val"); only_v2_val = aud_get_int ("filewriter_mp3", "only_v2_val"); algo_quality_val = aud_get_int ("filewriter_mp3", "algo_quality_val"); out_samplerate_val = aud_get_int ("filewriter_mp3", "out_samplerate_val"); bitrate_val = aud_get_int ("filewriter_mp3", "bitrate_val"); compression_val = aud_get_double ("filewriter_mp3", "compression_val"); enc_toggle_val = aud_get_int ("filewriter_mp3", "enc_toggle_val"); audio_mode_val = aud_get_int ("filewriter_mp3", "audio_mode_val"); enforce_iso_val = aud_get_int ("filewriter_mp3", "enforce_iso_val"); error_protect_val = aud_get_int ("filewriter_mp3", "error_protect_val"); if (write_output_func) write_output=write_output_func; }
static gboolean init (void) { aud_config_set_defaults ("extra_stereo", stereo_defaults); value = aud_get_double ("extra_stereo", "intensity"); return TRUE; }
static void vorbis_init(write_output_callback write_output_func) { aud_config_set_defaults ("filewriter_vorbis", vorbis_defaults); v_base_quality = aud_get_double ("filewriter_vorbis", "base_quality"); if (write_output_func) write_output=write_output_func; }
static void update_from_config (void * unused1, void * unused2) { button_set_active (equalizerwin_on, aud_get_bool (NULL, "equalizer_active")); eq_slider_set_val (equalizerwin_preamp, aud_get_double (NULL, "equalizer_preamp")); gdouble bands[AUD_EQUALIZER_NBANDS]; aud_eq_get_bands (bands); for (gint i = 0; i < AUD_EQUALIZER_NBANDS; i ++) eq_slider_set_val (equalizerwin_bands[i], bands[i]); eq_graph_update (equalizerwin_graph); }
static void slider_update (void * unused, GtkRange * slider) { int band = GPOINTER_TO_INT (g_object_get_data ((GObject *) slider, "band")); double value; if (band == -1) value = round (aud_get_double (NULL, "equalizer_preamp")); else value = round (aud_eq_get_band (band)); g_signal_handlers_block_by_func (slider, (void *) slider_moved, NULL); gtk_range_set_value (slider, -value); g_signal_handlers_unblock_by_func (slider, (void *) slider_moved, NULL); }
static void load_enabled_from_config (void) { int count = aud_get_int ("ladspa", "plugin_count"); for (int i = 0; i < count; i ++) { char key[32]; snprintf (key, sizeof key, "plugin%d_path", i); char * path = aud_get_str ("ladspa", key); snprintf (key, sizeof key, "plugin%d_label", i); char * label = aud_get_str ("ladspa", key); PluginData * plugin = find_plugin (path, label); if (plugin) { LoadedPlugin * loaded = enable_plugin_locked (plugin); snprintf (key, sizeof key, "plugin%d_controls", i); int ccount = index_count (loaded->plugin->controls); double temp[ccount]; char * controls = aud_get_str ("ladspa", key); if (str_to_double_array (controls, temp, ccount)) { for (int ci = 0; ci < ccount; ci ++) loaded->values[ci] = temp[ci]; } else { /* migrate from old config format */ for (int ci = 0; ci < ccount; ci ++) { snprintf (key, sizeof key, "plugin%d_control%d", i, ci); loaded->values[ci] = aud_get_double ("ladspa", key); aud_set_str ("ladspa", key, ""); } } str_unref (controls); } str_unref (path); str_unref (label); } }
static void update_sliders (void * unused, GtkWidget * window) { GtkWidget * preamp = g_object_get_data ((GObject *) window, "preamp"); set_slider (preamp, aud_get_double (NULL, "equalizer_preamp")); double values[AUD_EQUALIZER_NBANDS]; aud_eq_get_bands (values); for (int i = 0; i < AUD_EQUALIZER_NBANDS; i ++) { SPRINTF (slider_id, "slider%d", i); GtkWidget * slider = g_object_get_data ((GObject *) window, slider_id); set_slider (slider, values[i]); } }
gboolean sndstretch_init (void) { SS.fragsize=0; SS.chnr=2; SS.paused=0; SS.time_offs=0; SS.fmtsize=2; SS.fmt=FMT_S16_NE; SS.sampfreq=44100; SS.written=0; SS.bpsec=176400; SS.vol_r=50; SS.vol_l=50; SS.scale=1.0; aud_config_set_defaults ("sndstretch", sndstretch_defaults); SS.pitch = aud_get_double ("sndstretch", "pitch"); SS.speed = aud_get_double ("sndstretch", "speed"); SS.short_overlap = aud_get_bool ("sndstretch", "short_overlap"); SS.volume_corr = aud_get_bool ("sndstretch", "volume_corr"); return TRUE; }
static void stereo_process (float * * data, int * samples) { float value = aud_get_double ("extra_stereo", "intensity"); float * f, * end; float center; if (stereo_channels != 2 || samples == 0) return; end = (* data) + (* samples); for (f = * data; f < end; f += 2) { center = (f[0] + f[1]) / 2; f[0] = center + (f[0] - center) * value; f[1] = center + (f[1] - center) * value; } }
void compressor_config_load (void) { aud_config_set_defaults ("compressor", compressor_defaults); compressor_center = aud_get_double ("compressor", "center"); compressor_range = aud_get_double ("compressor", "range"); }
else klo = k; } h = xa[khi] - xa[klo]; a = (xa[khi] - x) / h; b = (x - xa[klo]) / h; return (a * ya[klo] + b * ya[khi] + ((a * a * a - a) * y2a[klo] + (b * b * b - b) * y2a[khi]) * (h * h) / 6.0); } DRAW_FUNC_BEGIN (eq_graph_draw) static const gdouble x[10] = {0, 11, 23, 35, 47, 59, 71, 83, 97, 109}; skin_draw_pixbuf (cr, SKIN_EQMAIN, 0, 294, 0, 0, 113, 19); skin_draw_pixbuf (cr, SKIN_EQMAIN, 0, 314, 0, 9 + (aud_get_double (NULL, "equalizer_preamp") * 9 + EQUALIZER_MAX_GAIN / 2) / EQUALIZER_MAX_GAIN, 113, 1); guint32 cols[19]; skin_get_eq_spline_colors(active_skin, cols); gdouble bands[AUD_EQUALIZER_NBANDS]; aud_eq_get_bands (bands); gdouble yf[10]; init_spline (x, bands, 10, yf); /* now draw a pixelated line with vector graphics ... -- jlindgren */ gint py = 0; for (gint i = 0; i < 109; i ++) { gint y = 9.5 - eval_spline (x, bands, yf, 10, i) * 9 / EQUALIZER_MAX_GAIN;
static int speed_adjust_delay (int delay) { /* Not sample-accurate, but should be a decent estimate. */ double speed = aud_get_double (CFGSECT, "speed"); return delay * speed + width * 1000 / currate; }
static void equalizerwin_create_widgets(void) { equalizerwin_on = button_new_toggle (25, 12, 10, 119, 128, 119, 69, 119, 187, 119, SKIN_EQMAIN, SKIN_EQMAIN); window_put_widget (equalizerwin, FALSE, equalizerwin_on, 14, 18); button_set_active (equalizerwin_on, aud_get_bool (NULL, "equalizer_active")); button_on_release (equalizerwin_on, eq_on_cb); equalizerwin_auto = button_new_toggle (33, 12, 35, 119, 153, 119, 94, 119, 212, 119, SKIN_EQMAIN, SKIN_EQMAIN); window_put_widget (equalizerwin, FALSE, equalizerwin_auto, 39, 18); button_set_active (equalizerwin_auto, aud_get_bool (NULL, "equalizer_autoload")); button_on_release (equalizerwin_auto, eq_auto_cb); equalizerwin_presets = button_new (44, 12, 224, 164, 224, 176, SKIN_EQMAIN, SKIN_EQMAIN); window_put_widget (equalizerwin, FALSE, equalizerwin_presets, 217, 18); button_on_release (equalizerwin_presets, eq_presets_cb); equalizerwin_close = button_new (9, 9, 0, 116, 0, 125, SKIN_EQMAIN, SKIN_EQMAIN); window_put_widget (equalizerwin, FALSE, equalizerwin_close, 264, 3); button_on_release (equalizerwin_close, (ButtonCB) equalizerwin_close_cb); equalizerwin_shade = button_new (9, 9, 254, 137, 1, 38, SKIN_EQMAIN, SKIN_EQ_EX); window_put_widget (equalizerwin, FALSE, equalizerwin_shade, 254, 3); button_on_release (equalizerwin_shade, (ButtonCB) equalizerwin_shade_toggle); equalizerwin_shaded_close = button_new (9, 9, 11, 38, 11, 47, SKIN_EQ_EX, SKIN_EQ_EX); window_put_widget (equalizerwin, TRUE, equalizerwin_shaded_close, 264, 3); button_on_release (equalizerwin_shaded_close, (ButtonCB) equalizerwin_close_cb); equalizerwin_shaded_shade = button_new (9, 9, 254, 3, 1, 47, SKIN_EQ_EX, SKIN_EQ_EX); window_put_widget (equalizerwin, TRUE, equalizerwin_shaded_shade, 254, 3); button_on_release (equalizerwin_shaded_shade, (ButtonCB) equalizerwin_shade_toggle); equalizerwin_graph = eq_graph_new (); window_put_widget (equalizerwin, FALSE, equalizerwin_graph, 86, 17); equalizerwin_preamp = eq_slider_new (_("Preamp")); window_put_widget (equalizerwin, FALSE, equalizerwin_preamp, 21, 38); eq_slider_set_val (equalizerwin_preamp, aud_get_double (NULL, "equalizer_preamp")); const gchar * const bandnames[AUD_EQUALIZER_NBANDS] = {N_("31 Hz"), N_("63 Hz"), N_("125 Hz"), N_("250 Hz"), N_("500 Hz"), N_("1 kHz"), N_("2 kHz"), N_("4 kHz"), N_("8 kHz"), N_("16 kHz") }; gdouble bands[AUD_EQUALIZER_NBANDS]; aud_eq_get_bands (bands); for (gint i = 0; i < AUD_EQUALIZER_NBANDS; i ++) { equalizerwin_bands[i] = eq_slider_new (_(bandnames[i])); window_put_widget (equalizerwin, FALSE, equalizerwin_bands[i], 78 + 18 * i, 38); eq_slider_set_val (equalizerwin_bands[i], bands[i]); } equalizerwin_volume = hslider_new (0, 94, SKIN_EQ_EX, 97, 8, 61, 4, 3, 7, 1, 30, 1, 30); window_put_widget (equalizerwin, TRUE, equalizerwin_volume, 61, 4); hslider_on_motion (equalizerwin_volume, eqwin_volume_motion_cb); hslider_on_release (equalizerwin_volume, eqwin_volume_release_cb); equalizerwin_balance = hslider_new (0, 39, SKIN_EQ_EX, 42, 8, 164, 4, 3, 7, 11, 30, 11, 30); window_put_widget (equalizerwin, TRUE, equalizerwin_balance, 164, 4); hslider_on_motion (equalizerwin_balance, eqwin_balance_motion_cb); hslider_on_release (equalizerwin_balance, eqwin_balance_release_cb); }