mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
#1241 Adds user preference to enable/disable audio normalization prior to MP3 encoding/recording. (#1242)
Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -24,11 +24,10 @@ import io.github.dsheirer.audio.convert.MP3Setting;
|
||||
import io.github.dsheirer.preference.Preference;
|
||||
import io.github.dsheirer.preference.PreferenceType;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import java.util.prefs.Preferences;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* User preferences for playlists
|
||||
*/
|
||||
@@ -36,11 +35,14 @@ public class MP3Preference extends Preference
|
||||
{
|
||||
private static final String PREFERENCE_KEY_AUDIO_MP3_SETTING = "audio.mp3.setting";
|
||||
private static final String PREFERENCE_KEY_AUDIO_MP3_SAMPLE_RATE = "audio.mp3.sample.rate";
|
||||
private static final String PREFERENCE_KEY_AUDIO_MP3_NORMALIZE_BEFORE_ENCODE = "audio.mp3.normalize.before.encode";
|
||||
private final static Logger mLog = LoggerFactory.getLogger(MP3Preference.class);
|
||||
private Preferences mPreferences = Preferences.userNodeForPackage(MP3Preference.class);
|
||||
private InputAudioFormat mInputAudioFormat;
|
||||
private MP3Setting mMP3Setting;
|
||||
|
||||
private Boolean mNormalizeAudio;
|
||||
|
||||
/**
|
||||
* Constructs this preference with an update listener
|
||||
* @param updateListener to receive notifications whenever these preferences change
|
||||
@@ -128,4 +130,29 @@ public class MP3Preference extends Preference
|
||||
mPreferences.put(PREFERENCE_KEY_AUDIO_MP3_SAMPLE_RATE, mInputAudioFormat.name());
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the user prefers to normalize audio before encoding to MP3
|
||||
* @return true to normalize
|
||||
*/
|
||||
public boolean isNormalizeAudioBeforeEncode()
|
||||
{
|
||||
if(mNormalizeAudio == null)
|
||||
{
|
||||
mNormalizeAudio = mPreferences.getBoolean(PREFERENCE_KEY_AUDIO_MP3_NORMALIZE_BEFORE_ENCODE, false);
|
||||
}
|
||||
|
||||
return mNormalizeAudio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preferenced to normalize audio before encoding to MP3.
|
||||
* @param normalizeAudio true to normalize
|
||||
*/
|
||||
public void setNormalizeAudioBeforeEncode(boolean normalizeAudio)
|
||||
{
|
||||
mNormalizeAudio = normalizeAudio;
|
||||
mPreferences.putBoolean(PREFERENCE_KEY_AUDIO_MP3_NORMALIZE_BEFORE_ENCODE, normalizeAudio);
|
||||
notifyPreferenceUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user