Skip to content

Commit

Permalink
spinner set value on preset load
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Jun 2, 2024
1 parent a7eb0c1 commit d6e3c56
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 56 deletions.
Binary file modified app/release/app-release.aab
Binary file not shown.
66 changes: 65 additions & 1 deletion app/src/main/assets/lv2/libGxSloopyBlue.lv2.so/_sloopyblue_.json
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
{"-1": {"http://xmlns.com/foaf/0.1/Person": true, "http://www.w3.org/2000/01/rdf-schema#seeAlso": "http://guitarix.sourceforge.net", "http://xmlns.com/foaf/0.1/mbox": "mailto:[email protected]", "http://xmlns.com/foaf/0.1/name": "Guitarix team", "pluginName": "GxSloopyBlue"}, "0": {"AudioPort": true, "OutputPort": true, "index": 0, "name": "Out", "symbol": "out"}, "1": {"AudioPort": true, "InputPort": true, "index": 1, "name": "In", "symbol": "in"}, "2": {"InputPort": true, "ControlPort": true, "default": "1.0", "designation": "http://lv2plug.in/ns/lv2core#enabled", "index": 2, "maximum": "1.0", "minimum": "0.0", "name": "BYPASS", "portProperty": "http://lv2plug.in/ns/lv2core#toggled", "symbol": "BYPASS"}, "3": {"InputPort": true, "ControlPort": true, "default": "0.5", "index": 3, "maximum": "1.0", "minimum": "0.0", "name": "GAIN", "symbol": "GAIN"}, "4": {"InputPort": true, "ControlPort": true, "default": "0.5", "index": 4, "maximum": "1.0", "minimum": "0.0", "name": "TONE", "symbol": "TONE"}, "5": {"InputPort": true, "ControlPort": true, "default": "0.5", "index": 5, "maximum": "1.0", "minimum": "0.0", "name": "VOLUME", "symbol": "VOLUME"}}
{
"-1": {
"http://xmlns.com/foaf/0.1/Person": true,
"http://www.w3.org/2000/01/rdf-schema#seeAlso": "http://guitarix.sourceforge.net",
"http://xmlns.com/foaf/0.1/mbox": "mailto:[email protected]",
"http://xmlns.com/foaf/0.1/name": "Guitarix team",
"pluginName": "GxSloopyBlue"
},
"0": {
"AudioPort": true,
"OutputPort": true,
"index": 0,
"name": "Out",
"symbol": "out"
},
"1": {
"AudioPort": true,
"InputPort": true,
"index": 1,
"name": "In",
"symbol": "in"
},
"2": {
"InputPort": true,
"ControlPort": true,
"default": "1.0",
"designation": "http://lv2plug.in/ns/lv2core#enabled",
"index": 2,
"maximum": "1.0",
"minimum": "0.0",
"name": "BYPASS",
"portProperty": "http://lv2plug.in/ns/lv2core#toggled",
"symbol": "BYPASS"
},
"3": {
"InputPort": true,
"ControlPort": true,
"default": "0.5",
"index": 3,
"maximum": "1.0",
"minimum": "0.0",
"name": "GAIN",
"symbol": "GAIN"
},
"4": {
"InputPort": true,
"ControlPort": true,
"default": "0.5",
"index": 4,
"maximum": "1.0",
"minimum": "0.0",
"name": "TONE",
"symbol": "TONE"
},
"5": {
"InputPort": true,
"ControlPort": true,
"default": "0.5",
"index": 5,
"maximum": "1.0",
"minimum": "0.0",
"name": "VOLUME",
"symbol": "VOLUME"
}
}
2 changes: 1 addition & 1 deletion app/src/main/assets/presets/Default
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"0":{"active":false,"controls":[2,3,-20,0.5,0.002,1],"name":"GxCompressor"},"1":{"active":false,"controls":[0,0,1,0,1,0,20,0.25,0.5,0.5,0.5,10,5,0],"name":"GxAmplifier"},"2":{"active":false,"controls":[0.5,10.5,0,0,0],"name":"GxMetalAmp"},"3":{"active":false,"controls":[50,1000.5],"name":"echodsp"},"4":{"active":false,"controls":[2500,0,0,1,1,1,1,0],"name":"TAP Reverberator"},"5":{"active":false,"controls":[0,0,0],"name":"DJ EQ (mono)"},"6":{"active":false,"controls":[0.5,5,0.2,-0.707,100,0],"name":"Gx_flanger"},"7":{"active":false,"controls":[0.5,0.02,0.02,3,1],"name":"GxChorus-Stereo"},"8":{"active":false,"controls":[1,0,0],"name":"SWH Impulse convolver"},"9":{"active":false,"controls":[0,0.25,0.5,0.5],"name":"Dyson compressor"}}
{"0":{"active":false,"controls":[2,3,-20,0.5,0.002,1],"name":"GxCompressor"},"1":{"active":false,"controls":[1,0.5,0.5,0.5],"name":"GxSloopyBlue"},"2":{"active":false,"controls":[0.5,10.5,0,0,0],"name":"GxMetalAmp"},"3":{"active":false,"controls":[0,0,1,0,1,0,20,0.25,0.5,0.5,0.5,10,5,0],"name":"GxAmplifier"},"4":{"active":false,"controls":[50,1000.5],"name":"echodsp"},"5":{"active":false,"controls":[2500,0,0,1,1,1,1,0],"name":"TAP Reverberator"},"6":{"active":false,"controls":[0,0,0],"name":"DJ EQ (mono)"},"7":{"active":false,"controls":[0.5,5,0.2,-0.707,100,0],"name":"Gx_flanger"},"8":{"active":false,"controls":[0.5,0.02,0.02,3,1],"name":"GxChorus-Stereo"},"9":{"active":false,"controls":[1,0,0],"name":"SWH Impulse convolver"},"10":{"active":false,"controls":[0,0.25,0.5,0.5],"name":"Dyson compressor"}}
122 changes: 78 additions & 44 deletions app/src/main/assets/voice.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,63 +54,38 @@
}
}
},

"32400": {
"name": "Amplifier",
"21300": {
"name": "Overdrive",
"controls": {
"2": {
"InputPort": true,
"ControlPort": true,
"default": "20.0",
"index": 2,
"maximum": "100.0",
"minimum": "1.0",
"name": "Distortion",
"symbol": "Distortion"
},
"3": {
"InputPort": true,
"ControlPort": true,
"default": "0.25",
"default": "0.5",
"index": 3,
"maximum": "1.0",
"minimum": "0.01",
"name": "Drive",
"symbol": "Drive"
},
"8": {
"InputPort": true,
"ControlPort": true,
"default": "5.0",
"index": 8,
"maximum": "10.0",
"minimum": "0.0",
"name": "Presence",
"symbol": "Presence"
"name": "GAIN",
"symbol": "GAIN"
},
"9": {
"4": {
"InputPort": true,
"ControlPort": true,
"default": 0,
"index": 9,
"maximum": 18,
"minimum": 0,
"name": "Model",
"portProperty": "http://lv2plug.in/ns/lv2core#enumeration",
"scalePoint": "_:n9b565a7eacba47e48628b74fdc44504bb29",
"symbol": "model"
"default": "0.5",
"index": 4,
"maximum": "1.0",
"minimum": "0.0",
"name": "TONE",
"symbol": "TONE"
},
"10": {
"5": {
"InputPort": true,
"ControlPort": true,
"default": 1,
"index": 10,
"maximum": 26,
"minimum": 0,
"name": "Tonestack Model",
"portProperty": "http://lv2plug.in/ns/lv2core#enumeration",
"scalePoint": "_:n9b565a7eacba47e48628b74fdc44504bb57",
"symbol": "t_model"
"default": "0.5",
"index": 5,
"maximum": "1.0",
"minimum": "0.0",
"name": "VOLUME",
"symbol": "VOLUME"
}
}
},
Expand Down Expand Up @@ -170,6 +145,65 @@
}
}
},
"32400": {
"name": "Amplifier",
"controls": {
"2": {
"InputPort": true,
"ControlPort": true,
"default": "20.0",
"index": 2,
"maximum": "100.0",
"minimum": "1.0",
"name": "Distortion",
"symbol": "Distortion"
},
"3": {
"InputPort": true,
"ControlPort": true,
"default": "0.25",
"index": 3,
"maximum": "1.0",
"minimum": "0.01",
"name": "Drive",
"symbol": "Drive"
},
"8": {
"InputPort": true,
"ControlPort": true,
"default": "5.0",
"index": 8,
"maximum": "10.0",
"minimum": "0.0",
"name": "Presence",
"symbol": "Presence"
},
"9": {
"InputPort": true,
"ControlPort": true,
"default": 0,
"index": 9,
"maximum": 18,
"minimum": 0,
"name": "Model",
"portProperty": "http://lv2plug.in/ns/lv2core#enumeration",
"scalePoint": "_:n9b565a7eacba47e48628b74fdc44504bb29",
"symbol": "model"
},
"10": {
"InputPort": true,
"ControlPort": true,
"default": 1,
"index": 10,
"maximum": 26,
"minimum": 0,
"name": "Tonestack Model",
"portProperty": "http://lv2plug.in/ns/lv2core#enumeration",
"scalePoint": "_:n9b565a7eacba47e48628b74fdc44504bb57",
"symbol": "t_model"
}
}
},
"3600": {
"name": "Echo",
"controls": {
Expand Down
26 changes: 16 additions & 10 deletions app/src/main/java/org/acoustixaudio/tonesmith/DataAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
double min = controls.getDouble("minimum");
double max = controls.getDouble("maximum");
String cname = controls.getString("name");
Log.d(TAG, String.format ("[control]: %s [%f %f %f]",
cname,
def, min, max));
// Log.d(TAG, String.format ("[control]: %s [%f %f %f]",
// cname,
// def, min, max));
if (max < min) {
double t = max ;
max = min ;
Expand All @@ -169,7 +169,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
}

Log.d(TAG, String.format ("[control index]: %s", index));
// Log.d(TAG, String.format ("[control index]: %s", index));

TextView textView = new TextView(mainActivity);
textView.setText(cname);
Expand All @@ -183,20 +183,23 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
controlDefaults.add(controlDefault);
holder.sliders.add(slider);

Spinner spinner = new Spinner(context);
float spinnerValue = 0;

try {
float value = AudioEngine.getActivePluginValueByIndex(position, index.get(0)) ;
Log.i(TAG, name +
String.format (" value %d:%d %f", position, index.get(0), value));
slider.setValue(value);
spinnerValue = value;

slider.setValueTo((float) max);
slider.setValueFrom((float) min);
} catch (IllegalStateException e) {
Log.e(TAG, String.format("onBindViewHolder: error setting slider value: %d, %d", min, max), e);
}

boolean isSpinner = false;
Spinner spinner ;
spinner = new Spinner(context);

Button prev = new Button(context);
Button next = new Button(context);
Expand Down Expand Up @@ -227,6 +230,8 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);

spinner.setSelection((int) spinnerValue);

prev = new Button(context);
next = new Button(context);

Expand Down Expand Up @@ -268,6 +273,7 @@ public void onClick(View v) {
layout.addView(spinner);

slider.setVisibility(View.GONE);

spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
Expand Down Expand Up @@ -354,7 +360,7 @@ public String getPreset () {
JSONObject jsonObject = new JSONObject();
try {
for (int i = 0 ; i < holders.size() ; i ++) {
Log.d(TAG, String.format ("[%d]: {%s]", i, holders.get(i).pluginName.getText()));
// Log.d(TAG, String.format ("[%d]: {%s]", i, holders.get(i).pluginName.getText()));
JSONObject object = new JSONObject();
ViewHolder viewHolder = holders.get(i);

Expand Down Expand Up @@ -392,11 +398,11 @@ void loadPreset (JSONObject jsonObject) {
JSONObject object = jsonObject.getJSONObject(String.valueOf(key));
Iterator<String> controls = object.keys();

Log.d(TAG, String.format("[%d] %s", key, object));
// Log.d(TAG, String.format("[%d] %s", key, object));
while (controls.hasNext()) {
String control = controls.next();
if (object.get(control) instanceof JSONArray) {
Log.d(TAG, "loadPreset: " + object.getJSONArray(control));
// Log.d(TAG, "loadPreset: " + object.getJSONArray(control));
}

if (Objects.equals(control, "-1")) {
Expand All @@ -405,7 +411,7 @@ void loadPreset (JSONObject jsonObject) {
} else {
double value = object.getDouble(String.valueOf(control));
// Log.d(TAG, String.format ("[control]: %s [%f]", control, value));
Log.d(TAG, String.format ("[%s / %d]: [%s / %d]", key, holders.size(), control, holders.get(key).sliders.size()));
// Log.d(TAG, String.format ("[%s / %d]: [%s / %d]", key, holders.size(), control, holders.get(key).sliders.size()));
holders.get(key).sliders.get(Integer.parseInt(control)).setValue((float) value);
}
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file added app/src/main/jniLibs/x86/libGxSloopyBlue.lv2.so
Binary file not shown.
Binary file not shown.

0 comments on commit d6e3c56

Please sign in to comment.