aboutsummaryrefslogtreecommitdiff
path: root/samples/drumthumper/src/main/java/com/plausibleaudio/drumthumper/DrumThumperActivity.kt
diff options
context:
space:
mode:
Diffstat (limited to 'samples/drumthumper/src/main/java/com/plausibleaudio/drumthumper/DrumThumperActivity.kt')
-rw-r--r--samples/drumthumper/src/main/java/com/plausibleaudio/drumthumper/DrumThumperActivity.kt28
1 files changed, 19 insertions, 9 deletions
diff --git a/samples/drumthumper/src/main/java/com/plausibleaudio/drumthumper/DrumThumperActivity.kt b/samples/drumthumper/src/main/java/com/plausibleaudio/drumthumper/DrumThumperActivity.kt
index b80b7e6d..1ec49059 100644
--- a/samples/drumthumper/src/main/java/com/plausibleaudio/drumthumper/DrumThumperActivity.kt
+++ b/samples/drumthumper/src/main/java/com/plausibleaudio/drumthumper/DrumThumperActivity.kt
@@ -48,7 +48,7 @@ class DrumThumperActivity : AppCompatActivity(),
private var mDeviceListener: DeviceListener = DeviceListener()
- private var mMixControlsShowing = false;
+ private var mMixControlsShowing = false
init {
// Load the library containing the a native code including the JNI functions
@@ -84,7 +84,7 @@ class DrumThumperActivity : AppCompatActivity(),
}
private fun resetOutput() {
- Log.i(TAG, "resetOutput() time:" + LocalDateTime.now() + " native reset:" + mDrumPlayer.getOutputReset());
+ Log.i(TAG, "resetOutput() time:" + LocalDateTime.now() + " native reset:" + mDrumPlayer.getOutputReset())
if (mDrumPlayer.getOutputReset()) {
// the (native) stream has been reset by the onErrorAfterClose() callback
mDrumPlayer.clearOutputReset()
@@ -107,8 +107,8 @@ class DrumThumperActivity : AppCompatActivity(),
//
// UI Helpers
//
- val GAIN_FACTOR = 100.0f;
- val MAX_PAN_POSITION = 200.0f;
+ val GAIN_FACTOR = 100.0f
+ val MAX_PAN_POSITION = 200.0f
val HALF_PAN_POSITION = MAX_PAN_POSITION / 2.0f
private fun gainPosToGainVal(pos: Int) : Float {
@@ -131,8 +131,8 @@ class DrumThumperActivity : AppCompatActivity(),
}
private fun showMixControls(show : Boolean) {
- mMixControlsShowing = show;
- val showFlag = if (mMixControlsShowing) View.VISIBLE else View.GONE;
+ mMixControlsShowing = show
+ val showFlag = if (mMixControlsShowing) View.VISIBLE else View.GONE
findViewById<LinearLayout>(R.id.kickMixControls).setVisibility(showFlag)
findViewById<LinearLayout>(R.id.snareMixControls).setVisibility(showFlag)
findViewById<LinearLayout>(R.id.hihatOpenMixControls).setVisibility(showFlag)
@@ -223,7 +223,7 @@ class DrumThumperActivity : AppCompatActivity(),
connectMixSliders(R.id.crashPan, R.id.crashGain, DrumPlayer.CRASHCYMBAL)
findViewById<Button>(R.id.mixCtrlBtn).setOnClickListener(this)
- showMixControls(false);
+ showMixControls(false)
}
override fun onStop() {
@@ -248,8 +248,18 @@ class DrumThumperActivity : AppCompatActivity(),
R.id.snarePad -> mDrumPlayer.trigger(DrumPlayer.SNAREDRUM)
R.id.midTomPad -> mDrumPlayer.trigger(DrumPlayer.MIDTOM)
R.id.lowTomPad -> mDrumPlayer.trigger(DrumPlayer.LOWTOM)
- R.id.hihatOpenPad -> mDrumPlayer.trigger(DrumPlayer.HIHATOPEN)
- R.id.hihatClosedPad -> mDrumPlayer.trigger(DrumPlayer.HIHATCLOSED)
+ R.id.hihatOpenPad -> {
+ mDrumPlayer.trigger(DrumPlayer.HIHATOPEN)
+ // For a real drum set, hi-hat can play either the open or the closed sound at any
+ // given time.
+ mDrumPlayer.stopTrigger(DrumPlayer.HIHATCLOSED)
+ }
+ R.id.hihatClosedPad -> {
+ mDrumPlayer.trigger(DrumPlayer.HIHATCLOSED)
+ // For a real drum set, hi-hat can play either the open or the closed sound at any
+ // given time.
+ mDrumPlayer.stopTrigger(DrumPlayer.HIHATOPEN)
+ }
R.id.ridePad -> mDrumPlayer.trigger(DrumPlayer.RIDECYMBAL)
R.id.crashPad -> mDrumPlayer.trigger(DrumPlayer.CRASHCYMBAL)
}