Add effect: echo funny tremolo

dev
xufuji456 4 years ago
parent 5475fd59df
commit 6dd2338a9b
  1. 40
      app/src/main/java/com/frank/ffmpeg/activity/EqualizerActivity.kt
  2. 40
      app/src/main/res/layout/activity_equalizer.xml
  3. 5
      app/src/main/res/values-en/strings.xml
  4. 7
      app/src/main/res/values/strings.xml

@ -5,6 +5,8 @@ import android.os.Environment
import android.util.Log import android.util.Log
import android.util.Pair import android.util.Pair
import android.view.View import android.view.View
import android.widget.RadioButton
import android.widget.RadioGroup
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.frank.ffmpeg.AudioPlayer import com.frank.ffmpeg.AudioPlayer
@ -54,6 +56,18 @@ class EqualizerActivity : BaseActivity(), OnSeeBarListener {
equalizerView.layoutManager = layoutManager equalizerView.layoutManager = layoutManager
equalizerAdapter = EqualizerAdapter(this, this) equalizerAdapter = EqualizerAdapter(this, this)
equalizerView.adapter = equalizerAdapter equalizerView.adapter = equalizerAdapter
val effectEcho: RadioButton = findViewById(R.id.btn_effect_echo)
val effectFunny: RadioButton = findViewById(R.id.btn_effect_funny)
val effectTremolo: RadioButton = findViewById(R.id.btn_effect_tremolo)
val effectGroup: RadioGroup = findViewById(R.id.group_audio_effect)
effectGroup.setOnCheckedChangeListener { group, checkedId ->
when (checkedId) {
effectEcho.id -> doAudioEffect(0)
effectFunny.id -> doAudioEffect(1)
effectTremolo.id -> doAudioEffect(2)
}
}
} }
private fun setupEqualizer() { private fun setupEqualizer() {
@ -98,6 +112,32 @@ class EqualizerActivity : BaseActivity(), OnSeeBarListener {
} }
} }
private fun getAudioEffect(index: Int) :String {
return when (index) {
0 -> "aecho=0.8:0.8:1000:0.5"
1 -> "atempo=2"
2 -> "tremolo=5:0.9"
else -> {
""
}
}
}
private fun doAudioEffect(index: Int) {
var effect = getAudioEffect(index)
if (effect.isEmpty()) return
val filter = ",superequalizer=6b=4:8b=5:10b=5"
effect += filter
if (filterThread == null) {
filterThread = Thread(Runnable {
mAudioPlayer!!.play(audioPath, effect)
})
filterThread!!.start()
} else {
mAudioPlayer!!.again(effect)
}
}
override fun onProgress(index: Int, progress: Int) { override fun onProgress(index: Int, progress: Int) {
doEqualize(index, progress) doEqualize(index, progress)
} }

@ -5,6 +5,42 @@
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:text="@string/audio_effect">
</TextView>
<RadioGroup
android:id="@+id/group_audio_effect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/btn_effect_echo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio_effect_echo"/>
<RadioButton
android:id="@+id/btn_effect_funny"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio_effect_funny"
android:layout_marginStart="5dp"/>
<RadioButton
android:id="@+id/btn_effect_tremolo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio_effect_tremolo"
android:layout_marginStart="5dp"/>
</RadioGroup>
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -15,7 +51,9 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_equalizer" android:id="@+id/list_equalizer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="50dp">
</androidx.recyclerview.widget.RecyclerView> </androidx.recyclerview.widget.RecyclerView>

@ -21,6 +21,11 @@
<string name="audio_reverb">Audio reverb:</string> <string name="audio_reverb">Audio reverb:</string>
<string name="audio_bass_boost">Bass boost:</string> <string name="audio_bass_boost">Bass boost:</string>
<string name="audio_voice_enhancer">Voice enhancer:</string> <string name="audio_voice_enhancer">Voice enhancer:</string>
<string name="audio_effect_echo">Ethereal</string>
<string name="audio_effect_funny">Funny</string>
<string name="audio_effect_tremolo">Tremolo</string>
<string name="audio_effect_lolita">Lolita</string>
<string name="audio_effect_uncle">Uncle</string>
<string name="audio_handle">Audio handle</string> <string name="audio_handle">Audio handle</string>
<string name="media_handle">Media handle</string> <string name="media_handle">Media handle</string>

@ -15,12 +15,17 @@
<string name="audio_silence">静音检测</string> <string name="audio_silence">静音检测</string>
<string name="audio_volume">修改音量</string> <string name="audio_volume">修改音量</string>
<string name="audio_add_equalizer">均衡器+</string> <string name="audio_add_equalizer">均衡器+</string>
<string name="audio_effect">乐均衡器</string> <string name="audio_effect"></string>
<string name="audio_equalizer">均衡器:</string> <string name="audio_equalizer">均衡器:</string>
<string name="audio_style">风格:</string> <string name="audio_style">风格:</string>
<string name="audio_reverb">混响:</string> <string name="audio_reverb">混响:</string>
<string name="audio_bass_boost">重低音:</string> <string name="audio_bass_boost">重低音:</string>
<string name="audio_voice_enhancer">声音增强:</string> <string name="audio_voice_enhancer">声音增强:</string>
<string name="audio_effect_echo">空灵</string>
<string name="audio_effect_funny">搞笑</string>
<string name="audio_effect_tremolo">惊悚</string>
<string name="audio_effect_lolita">萝莉</string>
<string name="audio_effect_uncle">大叔</string>
<string name="audio_handle">音频处理</string> <string name="audio_handle">音频处理</string>
<string name="media_handle">音视频处理</string> <string name="media_handle">音视频处理</string>

Loading…
Cancel
Save