Skip to content

Commit

Permalink
nice little switch for activating the tuner
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Mar 13, 2024
1 parent 5c6a6d6 commit 5f4f83d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
6 changes: 3 additions & 3 deletions app/src/main/cpp/Meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int Meter::attached_thread = 0 ;
bool Meter::engine_running = false ;
//LockFreeQueue<Meter::buffer_t*, LOCK_FREE_SIZE> Meter::lockFreeQueue;
int Meter::bufferUsed = 0;
bool Meter::tunerEnabled = true;
bool Meter::tunerEnabled = false;
int Meter::bufferUsedOutput = 0;
float Meter::tunerBuffer [1024 * 4] ;
int Meter::tunerIndex = 0;
Expand Down Expand Up @@ -193,11 +193,11 @@ int Meter::updateMeterOutput (AudioBuffer * buffer) {
}
*/

if (jfloatArray1_index >= TUNER_ARRAY_SIZE) {
if ((jfloatArray1_index + samples) >= TUNER_ARRAY_SIZE) {
envOutput->CallStaticVoidMethod(mainActivityOutput, setTuner, jfloatArray1, false);
jfloatArray1_index = 0 ;
} else {
envOutput->SetFloatArrayRegion(jfloatArray1, jfloatArray1_index, jfloatArray1_index + samples, raw);
envOutput->SetFloatArrayRegion(jfloatArray1, jfloatArray1_index, samples, raw);
jfloatArray1_index += samples;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public class MainActivity extends AppCompatActivity implements ActivityCompat.On
ToggleButton record;
boolean triggerRecord = false ;
public Handler handler;
public boolean tunerEnabled = true;
public boolean tunerEnabled = false;

enum RequestCode {
TRACK_AUDIO_FILE (1001);
Expand Down
12 changes: 7 additions & 5 deletions app/src/main/java/com/shajikhan/ladspa/amprack/Rack.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,24 @@ public void run() {
});

mainActivity.tuner = mainActivity.findViewById(R.id.patch_label);
mainActivity.tuner.setOnClickListener(new View.OnClickListener() {
Switch tunerSwitch = mainActivity.findViewById(R.id.tuner_switch);
tunerSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onClick(View v) {
TextView _v = (TextView) v ;
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
TextView _v = (TextView) mainActivity.tuner ;
_v.setText("Please wait ...");
mainActivity.tunerEnabled = ! AudioEngine.getTunerEnabled() ;
mainActivity.tunerEnabled = isChecked;
if (!mainActivity.tunerEnabled) {
AudioEngine.setTunerEnabled(false);
mainActivity.tuner.setText("Tap to activate Tuner");
mainActivity.tuner.setText("Tuner");
} else {
if (! mainActivity.onOff.isChecked()) {
mainActivity.toast ("Starting audio engine");
patchDown.performClick();
}
AudioEngine.setTunerEnabled(true);
}

}
});

Expand Down
29 changes: 20 additions & 9 deletions app/src/main/res/layout/rack.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,26 @@
android:id="@+id/patch_master"
android:layout_weight="1">

<TextView
android:textStyle="bold"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/gruppo"
android:id="@+id/patch_label"
android:text="Tap to activate Tuner"
android:textSize="25dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textStyle="bold"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/gruppo"
android:id="@+id/patch_label"
android:text="Tuner"
android:textSize="25dp" />

<Switch
android:id="@+id/tuner_switch"
android:fontFamily="@font/comfortaa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

</LinearLayout>


<TextView
Expand Down

0 comments on commit 5f4f83d

Please sign in to comment.