add filters

This commit is contained in:
Alexey Kuznetsov 2018-03-16 17:02:31 +03:00
commit 32fc2c7b43
4 changed files with 32 additions and 4 deletions

View file

@ -55,5 +55,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.github.axet:android-audio-library:1.0.89' // compile project(':android-audio-library')
compile 'com.github.axet:android-audio-library:1.0.91' // compile project(':android-audio-library')
}

View file

@ -47,6 +47,8 @@ import com.github.axet.audiolibrary.encoders.EncoderInfo;
import com.github.axet.audiolibrary.encoders.Factory;
import com.github.axet.audiolibrary.encoders.FileEncoder;
import com.github.axet.audiolibrary.encoders.OnFlyEncoding;
import com.github.axet.audiolibrary.filters.AmplifierFilter;
import com.github.axet.audiolibrary.filters.VoiceFilter;
import com.github.axet.audiolibrary.widgets.PitchView;
import com.github.axet.audiorecorder.BuildConfig;
import com.github.axet.audiorecorder.R;
@ -990,6 +992,12 @@ public class RecordingActivity extends AppCompatThemeActivity {
encoder = new FileEncoder(this, in, fly);
if (shared.getBoolean(MainApplication.PREFERENCE_VOICE, false))
encoder.filters.add(new VoiceFilter(getInfo().hz));
float amp = shared.getFloat(MainApplication.PREFERENCE_VOLUME, 0);
if (amp > 0)
encoder.filters.add(new AmplifierFilter(1 + amp));
RecordingService.startService(this, Storage.getDocumentName(targetUri), thread != null, encoder != null);
final ProgressDialog d = new ProgressDialog(this);

View file

@ -24,11 +24,13 @@ import android.support.v7.preference.PreferenceManager;
import android.support.v7.preference.PreferenceScreen;
import android.view.MenuItem;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.Toast;
import com.github.axet.androidlibrary.widgets.AppCompatSettingsThemeActivity;
import com.github.axet.androidlibrary.widgets.NameFormatPreferenceCompat;
import com.github.axet.androidlibrary.widgets.OpenFileDialog;
import com.github.axet.androidlibrary.widgets.SeekBarPreference;
import com.github.axet.androidlibrary.widgets.SilencePreferenceCompat;
import com.github.axet.androidlibrary.widgets.StoragePathPreferenceCompat;
import com.github.axet.androidlibrary.widgets.ThemeUtils;
@ -77,7 +79,9 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
String stringValue = value.toString();
String key = preference.getKey();
if (preference instanceof NameFormatPreferenceCompat) {
if (preference instanceof SeekBarPreference) {
preference.setSummary(((SeekBarPreference) preference).format(Float.valueOf(stringValue)));
} else if (preference instanceof NameFormatPreferenceCompat) {
preference.setSummary(((NameFormatPreferenceCompat) preference).getFormatted(stringValue));
} else if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
@ -127,7 +131,7 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
.getAll().get(preference.getKey()));
}
@Override
@ -213,6 +217,10 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
NameFormatPreferenceCompat.show(caller, pref.getKey());
return true;
}
if (pref instanceof SeekBarPreference) {
SeekBarPreference.show(caller, pref.getKey());
return true;
}
return false;
}
@ -250,6 +258,7 @@ public class SettingsActivity extends AppCompatSettingsThemeActivity implements
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_THEME));
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_CHANNELS));
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_FORMAT));
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_VOLUME));
StoragePathPreferenceCompat s = (StoragePathPreferenceCompat) pm.findPreference(MainApplication.PREFERENCE_STORAGE);
s.setStorage(new Storage(getContext()));

View file

@ -57,7 +57,18 @@
android:summary="2015-12-31 22:11:34"
android:title="@string/pref_nameformat_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_filters">
<SwitchPreferenceCompat
android:defaultValue="false"
android:key="voice"
android:summary="@string/pref_voice_summary"
android:title="@string/pref_voice_title" />
<com.github.axet.androidlibrary.widgets.SeekBarPreference
android:defaultValue="0"
android:key="volume"
android:summary=""
android:title="@string/pref_volume_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_application">
<SwitchPreferenceCompat
android:defaultValue="false"