1function example_drc(); 2 3% Set the parameters here 4tplg_fn = "../../topology/topology1/m4/drc_coef_default.m4"; % Control Bytes File 5% Use those files with sof-ctl to update the component's configuration 6blob_fn = "../../ctl/drc_coef.blob"; % Blob binary file 7alsa_fn = "../../ctl/drc_coef.txt"; % ALSA CSV format file 8 9endian = "little"; 10 11sample_rate = 48000; 12 13% The parameters of the DRC compressor 14% enabled: 1 to enable the compressor, 0 to disable it 15params.enabled = 0; 16% threshold: The value above which the compression starts, in dB 17params.threshold = -24; 18% knee: The value above which the knee region starts, in dB 19params.knee = 30; 20% ratio: The input/output dB ratio after the knee region 21params.ratio = 12; 22% attack: The time to reduce the gain by 10dB, in seconds 23params.attack = 0.003; 24% release: The time to increase the gain by 10dB, in seconds 25params.release = 0.25; 26% pre_delay: The lookahead time for the compressor, in seconds 27params.pre_delay = 0.006; 28% release_zone[4]: The adaptive release curve parameters 29params.release_zone = [0.09 0.16 0.42 0.98]; 30% release_spacing: The value of spacing per frame while releasing, in dB 31params.release_spacing = 5; 32% post_gain: The static boost value in output, in dB 33params.post_gain = 0; 34 35% Generate coefficients for DRC with the given parameters 36coefs = drc_gen_coefs(params, sample_rate); 37 38% Convert coefficients to sof_drc_config struct 39config = drc_generate_config(coefs); 40 41% Convert struct to binary blob 42blob8 = drc_build_blob(config, endian); 43 44% Generate output files 45addpath ./../common 46 47tplg_write(tplg_fn, blob8, "DRC"); 48blob_write(blob_fn, blob8); 49alsactl_write(alsa_fn, blob8); 50 51% Plot x-y response in dB 52drc_plot_db_curve(coefs); 53 54rmpath ./../common 55 56endfunction 57