Skip to content

Commit eaa810c

Browse files
authored
Merge branch 'main' into midi-cc-ab-preset-selection
2 parents 7357e39 + 3947048 commit eaa810c

File tree

4 files changed

+182
-23
lines changed

4 files changed

+182
-23
lines changed

locator/Windows/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# macOS folder attributes
2+
.DS_Store
3+
4+
obj
5+
bin/Debug
6+
7+
8+

source/.clangd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CompileFlags:
2+
Remove: [-f*, -m*]

source/main/index.html

Lines changed: 129 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,30 @@
380380
display: none;
381381
}
382382

383+
.home-label {
384+
color: #ccc;
385+
text-align:center;
386+
}
387+
383388
.fx_icon_container {
384389
display: flex;
385390
justify-content: space-around; /* or space-evenly */
386391
width: 98%;
387392
margin: 0 auto;
388393
padding: 5px;
389394
}
395+
396+
.oscilloscope-container {
397+
display: flex;
398+
justify-content: center;
399+
align-items: center;
400+
width: 100%;
401+
height: 400px;
402+
}
403+
canvas {
404+
width: 100%;
405+
height: 300px;
406+
}
390407
</style>
391408

392409
<script>
@@ -793,13 +810,30 @@
793810
midiControlChangeAssociations.set(117, { param: "CABSIM BYPASS", value: { type: "TOGGLE" } })
794811
midiControlChangeAssociations.set(118, { param: "TEMPO SOURCE", value: { type: "TOGGLE" } })
795812
midiControlChangeAssociations.set(119, { param: "TUNING REFERENCE", value: { type: "RANGE" } })
813+
midiControlChangeAssociations.set(122, { param: "GLOBAL VOLUME", value: { type: "RANGE" } })
796814

797815
// tap tempo
798816
let globalTapTempo = new TapTempo();
799817

800818
// Init web socket when the page loads
801819
window.addEventListener('load', onload);
802820

821+
// waveform display
822+
let canvas = null;
823+
let ctx = null;
824+
825+
// Canvas dimensions
826+
let width = 0;
827+
let height = 0;
828+
829+
// Signal parameters
830+
let time = 0;
831+
let baseAmplitude = 50; // Base amplitude for the wave
832+
const baseFrequency = 0.06; // Base frequency for the wave
833+
const speed = 0.3; // Faster animation speed
834+
const noiseLevel = 5; // Subtle noise for audio-like randomness
835+
let variationTime = 2; // For amplitude/frequency variation
836+
803837
function onload(event) {
804838
// Get the element with id="defaultOpen" and click on it
805839
document.getElementById("defaultOpen").click();
@@ -824,6 +858,13 @@
824858
populateExternalFootswitches();
825859
populateInternalFootswitches();
826860
setEffectIcons();
861+
862+
// draw waveform
863+
canvas = document.getElementById('oscilloscopeCanvas');
864+
ctx = canvas.getContext('2d');
865+
width = canvas.width;
866+
height = canvas.height;
867+
drawSignal();
827868
}
828869

829870
function setEffectIcons() {
@@ -2967,6 +3008,69 @@
29673008
setToast('Ensure mDNS/Bonjour is<br>enabled on your router<br>before applying Station Mode!');
29683009
}
29693010
}
3011+
3012+
function drawSignal() {
3013+
// Clear the canvas
3014+
ctx.clearRect(0, 0, width, height);
3015+
3016+
// Draw oscilloscope grid
3017+
ctx.beginPath();
3018+
ctx.strokeStyle = 'rgba(48, 54, 61, 0.8)';
3019+
ctx.lineWidth = 1;
3020+
3021+
// Horizontal lines
3022+
const numHorizontal = 5;
3023+
const horizontalSpacing = height / (numHorizontal - 1);
3024+
for (let i = 0; i < numHorizontal; i++) {
3025+
const y = i * horizontalSpacing;
3026+
ctx.moveTo(0, y);
3027+
ctx.lineTo(width, y);
3028+
}
3029+
3030+
// Vertical lines
3031+
const numVertical = 10;
3032+
const verticalSpacing = width / (numVertical - 1);
3033+
for (let i = 0; i < numVertical; i++) {
3034+
const x = i * verticalSpacing;
3035+
ctx.moveTo(x, 0);
3036+
ctx.lineTo(x, height);
3037+
}
3038+
3039+
ctx.stroke();
3040+
3041+
// Calculate varying amplitude and frequency
3042+
const amplitude = baseAmplitude * (0.5 + 0.5 * Math.sin(variationTime * 0.1));
3043+
const frequency = baseFrequency * (0.8 + 0.4 * Math.cos(variationTime * 0.1));
3044+
3045+
// Draw the oscilloscope signal with fewer samples
3046+
ctx.beginPath();
3047+
ctx.strokeStyle = '#FB9230'; // Vibrant orange waveform
3048+
ctx.lineWidth = 2;
3049+
3050+
for (let x = 0; x < width; x += 5) { // Fewer samples with larger step size
3051+
// Combine multiple sine waves with noise for audio-like effect
3052+
const y = height / 2 + amplitude * (
3053+
0.6 * Math.sin(frequency * x + time) +
3054+
0.3 * Math.sin(frequency * 2 * x + time * 0.5) +
3055+
0.1 * Math.sin(frequency * 4 * x + time * 0.2)
3056+
) + (Math.random() - 0.5) * noiseLevel;
3057+
ctx.lineTo(x, y);
3058+
}
3059+
3060+
ctx.stroke();
3061+
3062+
// Update time for animation
3063+
time += speed;
3064+
variationTime += 0.6; // Faster variation
3065+
3066+
// Reset amplitude periodically to simulate new audio input
3067+
if (variationTime % 100 === 0) {
3068+
baseAmplitude = 30 + Math.random() * 40; // Random amplitude between 30 and 70
3069+
}
3070+
3071+
// Loop the animation
3072+
requestAnimationFrame(drawSignal);
3073+
}
29703074
</script>
29713075

29723076
<nav class="navbar navbar-dark bg-dark">
@@ -2991,7 +3095,8 @@
29913095
</div>
29923096

29933097
<div class="tab" id="MainMenu">
2994-
<button class="tablinks" onclick="openTab(event, 'NoiseGate')" id="defaultOpen">Gate</button>
3098+
<button class="tablinks" onclick="openTab(event, 'Home')" id="defaultOpen">Home</button>
3099+
<button class="tablinks" onclick="openTab(event, 'NoiseGate')">Gate</button>
29953100
<button class="tablinks" onclick="openTab(event, 'Compressor')">Comp</button>
29963101
<button class="tablinks" onclick="openTab(event, 'Equalisation')">EQ</button>
29973102
<button class="tablinks" onclick="openTab(event, 'Reverb')">Reverb</button>
@@ -3008,8 +3113,30 @@
30083113
<button class="tablinks" onclick="openTab(event, 'Miscellaneous')">Misc</button>
30093114
</div>
30103115

3116+
<div id="Home" class="tabcontent">
3117+
<div class="col py-3 text-white">
3118+
<div class="container" style="text-align: center;">
3119+
<label class="home-label">Tonex One and Tonex Pedal Controller</label>
3120+
</div>
3121+
<div class="container" style="text-align: center;">
3122+
<label class="home-label">Version V2.0.0.2</label>
3123+
</div>
3124+
<br>
3125+
<div class="container" style="text-align: center; color:#FB9230;">
3126+
<label>https://github.com/Builty/TonexOneController</label>
3127+
</div>
3128+
<div class="oscilloscope-container">
3129+
<canvas id="oscilloscopeCanvas"></canvas>
3130+
</div>
3131+
3132+
<div class="container" style="text-align: center; color:#777;">
3133+
<label>TONEX is a registered trademark of IK Multimedia Production Srl</label>
3134+
</div>
3135+
</div>
3136+
</div>
3137+
30113138
<div id="NoiseGate" class="tabcontent">
3012-
<div class="col py-3 text-white">
3139+
<div class="col py-3 text-white">
30133140
<h5 class="selected_text">Noise Gate</h5>
30143141
<p class="lead">
30153142
<div class="container">

source/main/midi_helper.c

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,14 @@ esp_err_t midi_helper_adjust_param_via_midi(uint8_t change_num, uint8_t midi_val
12591259
return ESP_OK;
12601260
} break;
12611261

1262-
case 127:
1262+
case 122:
1263+
{
1264+
param = TONEX_GLOBAL_MASTER_VOLUME;
1265+
value = midi_helper_scale_midi_to_float(param, midi_value);
1266+
value = tonex_params_clamp_value(param, value);
1267+
} break;
1268+
1269+
case 127:
12631270
{
12641271
// Custom case: use CC to change params.
12651272
if (midi_value >= (usb_get_max_presets_for_connected_modeller()))
@@ -1935,33 +1942,48 @@ uint16_t midi_helper_get_param_for_change_num(uint8_t change_num)
19351942
param = TONEX_PARAM_VIR_BLEND;
19361943
} break;
19371944

1938-
// below items not supported on bigger Tonex pedal, custom for this controller
1939-
case 116:
1940-
{
1941-
param = TONEX_GLOBAL_INPUT_TRIM;
1942-
} break;
1945+
// below items not supported on bigger Tonex pedal, custom for this controller
1946+
case 116:
1947+
{
1948+
param = TONEX_GLOBAL_INPUT_TRIM;
1949+
} break;
19431950

1944-
case 117:
1945-
{
1946-
param = TONEX_GLOBAL_CABSIM_BYPASS;
1947-
} break;
1951+
case 117:
1952+
{
1953+
param = TONEX_GLOBAL_CABSIM_BYPASS;
1954+
} break;
19481955

1949-
case 118:
1950-
{
1951-
param = TONEX_GLOBAL_TEMPO_SOURCE;
1952-
} break;
1956+
case 118:
1957+
{
1958+
param = TONEX_GLOBAL_TEMPO_SOURCE;
1959+
} break;
19531960

1954-
case 119:
1955-
{
1956-
param = TONEX_GLOBAL_TUNING_REFERENCE;
1957-
} break;
1961+
case 119:
1962+
{
1963+
param = TONEX_GLOBAL_TUNING_REFERENCE;
1964+
} break;
19581965

1959-
case 127:
1960-
{
1966+
case 120:
1967+
{
1968+
// reserved for setting preset in slot A
1969+
} break;
1970+
1971+
case 121:
1972+
{
1973+
// reserved for setting preset in slot B
1974+
} break;
1975+
1976+
case 122:
1977+
{
1978+
param = TONEX_GLOBAL_MASTER_VOLUME;
1979+
} break;
1980+
1981+
case 127:
1982+
{
19611983
// Need the CC value to use this, so this won't work for
19621984
// footswitches, and it's kind of irrelevant anyways.
19631985
ESP_LOGW(TAG, "Unsupported Midi change number %d", change_num);
1964-
}
1986+
}
19651987
}
19661988

19671989
return param;

0 commit comments

Comments
 (0)