dfaust / soundkonverter

soundKonverter is in maintenance mode, PRs are welcome.
https://github.com/dfaust/soundkonverter/wiki
98 stars 27 forks source link

sox effects #11

Open cyberbeat opened 10 years ago

cyberbeat commented 10 years ago

I would like to apply sox effects to mp3s like "compand" and "norm". Would that be possible? I saw something about "effectwidget" in source code, but there is no possibility to display it? And the is also an input field "encoder params", which does nothing (parameters not appended to sox?).

When you tell me, what has to be done, I could help coding.

Another question: is it possible to only apply "mp3 gain"-normalizing without quality loss? If yes, how?

dfaust commented 10 years ago

The sox plugin (soundkonverter_filter_sox) is based on the class FilterPlugin which in turn is based on CodecPlugin - the base class for all converter plugins. All implementations of CodecPlugin provide the method newCodecWidget() which returns a CodecWidget (QWidget based) that is displayed in the conversion options dialog. Right underneath the CodecWidget you can find a list of FilterWidget. Each FilterWidget must be enabled individually in the "Backends" tab of the configuration dialog (look for "Filter"). The FilterWidget is returned by the method newFilterWidget() provided by all classes that implement FilterPlugin.

soundkonverter_filter_sox::newFilterWidget() returns a SoxFilterWidget (based on FilterWidget) which contains a few widgets to change the sampling rate, etc. and any number of SoxEffectWidget. By default only one SoxEffectWidget is shown - with the effect "disabled" chosen. But any number of effects can be added by the user (although currently only bass, treble and norm are implemented).

In order to implement new effects, you would have to edit soxeffectwidget.cpp and soundkonverter_filter_sox.cpp - look for the loop "foreach( const SoxFilterOptions::EffectData effectData, filterOptions->data.effects )" (line 450). That loop goes through all the data set by the effect widgets (SoxEffectWidget::currentEffectOptions()) and appends the necessary command line arguments.

If that all works there's a last file to edit and that is soxfilteroptions.cpp. The methods SoxFilterOptions::toXml() and fromXml() are used to save and load the conversion options with the file list - you can test it using the save/load action in the file menu.

I hope that this will help.

The input field "encoder params" is part of the sox CodecWidget and can be seen in the conversion options dialog when sox is selected as encoder. I just tested it and it worked. You can enter any parameter that sox can handle.

Regarding mp3 gain normalization, maybe this will help: https://github.com/HessiJames/soundkonverter/wiki/mp3gain

cyberbeat commented 10 years ago

The input field "encoder params" is part of the sox CodecWidget and can be seen in the conversion options dialog >when sox is selected as encoder. I just tested it and it worked. You can enter any parameter that sox can handle.

I think effect options don't work, because they have to be placed after the output file. for me, adding effect params did not work.

cliffsloane555 commented 8 years ago

I am using the frontend, and looking for normalization. On this site, it indicates that sox should be a choice in the Settings/Advanced window, but on mine, no choices are there for Filter. Which file should I edit, and what commands will I need, to add that to the options for Filter?

dfaust commented 8 years ago

Do you have sox installed? What does the log say?

cliffsloane555 commented 8 years ago

Good tip. Yes it is, but all formats are disabled.

loading plugin: SoX encode: 8svx (disabled) aiff (disabled) amr nb (disabled) amr wb (disabled) flac (disabled) mp2 (disabled) mp3 (disabled) ogg vorbis (disabled)

decode: 8svx (disabled) aiff (disabled) amr nb (disabled) amr wb (disabled) flac (disabled) mp2 (disabled) mp3 (disabled) ogg vorbis (disabled)

Furthermore, it is not on the list of plugins on the "Backends" window. Perhaps I need to re-install?

cliffsloane555 commented 8 years ago

Here is the plugin window: screenshot from 2016-07-29 08-48-46

dfaust commented 8 years ago

Looks like sox is not installed in any PATH. You have to install sox properly for soundkonverter to find it.

cliffsloane555 commented 8 years ago

sudo apt-get install sox done. Will return if something is amiss. Thank you, sir.