Skip to content

Commit

Permalink
bandsplitter: add samplerate independent mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Oct 23, 2023
1 parent a5ebdb9 commit 6620556
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
28 changes: 18 additions & 10 deletions Basics/BandSplitter.jsfx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
desc:Saike 4-pole BandSplitter
tags: bandsplitter
version: 0.20
version: 0.21
author: Joep Vanlier
changelog: Properly initialize first order phase matchers when preparing the FIR for 2p FIR mode (this lead to a volume increase when done incorrectly).
changelog: Add option to use absolute upper and lower limit for the frequency range (new default!)
provides:
BandJoiner.jsfx
BandSplitter_phasematcher.jsfx
Expand Down Expand Up @@ -43,6 +43,7 @@ slider8:Drive3=0<-40,60,.1>-Drive 3 (dB)
slider9:Drive4=0<-40,60,.1>-Drive 4 (dB)
slider10:Drive5=0<-40,60,.1>-Drive 5 (dB)

slider58:absolute_frequencies=1<0,1,1>-Fixed frequency range
slider59:abs_placement=0<0,1,1>-Absolute placement
slider60:FIR_quality=0<0,2,{Normal,High,Ultra}>-FIR Quality
slider61:FIR=0<0,1,1>-FIR mode
Expand Down Expand Up @@ -553,9 +554,9 @@ function drawGrid()
gfx_line(xx, y, xx, y+h);

( i < 100 ) ? (i += 20) :
( i < 1000 ) ? (i += 200) :
( i < 10000 ) ? (i += 2000) :
( i < 100000 ) ? (i += 20000);
( i < 1000 ) ? (i += 100) :
( i < 10000 ) ? (i += 1000) :
( i < 100000 ) ? (i += 10000);
);

gfx_set( grid_color_r, grid_color_g, grid_color_b, grid_color_a );
Expand Down Expand Up @@ -672,7 +673,7 @@ function fftWindow_processMouse(mouse_x, mouse_y, mouse_cap)
solo1, solo2, solo3, solo4, solo5,
driveMin, driveMax, maxCuts,
hinter.updateHintTime,
selectedBand, gfx_x, gfx_y, srate, abs_placement )
selectedBand, gfx_x, gfx_y, srate, abs_placement)
local(dx, dy, over, dys,
F1, F2, F3, F4,
leftClick, rightClick, doubleClick,
Expand Down Expand Up @@ -1498,7 +1499,8 @@ file_var(0, gmem_group);
(last_sent_f3 != Freq3) ||
(last_sent_f4 != Freq4) ||
(last_sent_slope != band_mode) ||
(last_sent_abs_placement != abs_placement) ? (
(last_sent_abs_placement != abs_placement) ||
(last_sent_absolute_frequencies != absolute_frequencies) ? (
last_gmem_group = gmem_group;
last_sent_cuts = Cuts;
last_sent_f1 = Freq1;
Expand All @@ -1507,9 +1509,10 @@ file_var(0, gmem_group);
last_sent_f4 = Freq4;
last_sent_abs_placement = abs_placement;
last_sent_slope = band_mode;
last_sent_absolute_frequencies = absolute_frequencies;

(gmem_group > 0) ? (
gm_ptr = 8 * (gmem_group - 1);
gm_ptr = 9 * (gmem_group - 1);
gmem[gm_ptr] = time_precise(); /* Identity */
gmem[gm_ptr + 1] = last_sent_cuts;
gmem[gm_ptr + 2] = last_sent_f1;
Expand All @@ -1518,11 +1521,12 @@ file_var(0, gmem_group);
gmem[gm_ptr + 5] = last_sent_f4;
gmem[gm_ptr + 6] = last_sent_abs_placement;
gmem[gm_ptr + 7] = last_sent_slope;
gmem[gm_ptr + 8] = last_sent_absolute_frequencies;
);
);

absolute_frequencies ? (
freq_max = 24000;
freq_max = 22050;
norm_freq_min = 20.0 / freq_max;
norm_freq_max = freq_max / srate;
) : (
Expand Down Expand Up @@ -2416,6 +2420,10 @@ solo5 ? play5 = 1;
absChoice.drawToggle(20, 60, 10, 10, abs_placement, 1, 0.2, 0.2, 0.8, 1.0, 0.2, 0.2, 0.8, "Absolute positioning.\n\nIn this mode the slider mapping is absolute.");
abs_placement = absChoice.processMouseToggle(mouse_x, mouse_y, mouse_cap);

absFrequency.label = "Absolute frequency range";
absFrequency.drawToggle(20, 80, 10, 10, absolute_frequencies, 1, 0.2, 0.2, 0.8, 1.0, 0.2, 0.2, 0.8, "Absolute frequency range.\n\nMakes settings project sample rate independent.");
absolute_frequencies = absFrequency.processMouseToggle(mouse_x, mouse_y, mouse_cap);

function setup_menu_string(str_var, value, start)
local(s, i)
global()
Expand All @@ -2436,7 +2444,7 @@ solo5 ? play5 = 1;
);

link.label = gmem_group > 0 ? sprintf(7, "Link group %d", gmem_group) : "Link";
link.drawToggle(20, 80, 10, 10, gmem_group > 0, 1, 0.2, 0.2, 0.8, 1.0, 0.2, 0.2, 0.8, "Link to phase matcher.\n\nClick this to link this bandsplitter to a phase matcher.");
link.drawToggle(20, 100, 10, 10, gmem_group > 0, 1, 0.2, 0.2, 0.8, 1.0, 0.2, 0.2, 0.8, "Link to phase matcher.\n\nClick this to link this bandsplitter to a phase matcher.");
link.processMouseToggle(mouse_x, mouse_y, mouse_cap);
(link.over && (mouse_cap == 1) && (last_cap == 0)) ? (
menu_selection = gfx_showmenu(sprintf(8, "%s", setup_menu_string(8, gmem_group, 0)));
Expand Down
16 changes: 11 additions & 5 deletions Basics/BandSplitter_phasematcher.jsfx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
desc:Saike 4-pole phase matcher for IIR BandSplitter
tags: phasematcher for bandsplitter
version: 0.09
version: 0.10
author: Joep Vanlier
changelog: Include filter slopes in the syncing.
changelog: Add option to use absolute frequency range independent of sample rate.
provides:
license: MIT

Expand Down Expand Up @@ -33,6 +33,7 @@ slider8:Drive3=0<-40,60,.1>-Drive 3 (dB)
slider9:Drive4=0<-40,60,.1>-Drive 4 (dB)
slider10:Drive5=0<-40,60,.1>-Drive 5 (dB)

slider58:absolute_frequencies=1<0,1,1>-Fixed frequency range
slider59:abs_placement=0<0,1,1>-Absolute placement

slider62:masterGainSlider=0<-26,26,.1>-Master Gain
Expand Down Expand Up @@ -1396,7 +1397,7 @@ file_var(0, gmem_group);
@block
// Listening?
(gmem_group > 0) ? (
gm_ptr = 8 * (gmem_group - 1);
gm_ptr = 9 * (gmem_group - 1);
(gmem[gm_ptr] != last_read_gmem) ? (
Cuts = gmem[gm_ptr + 1];
Freq1 = gmem[gm_ptr + 2];
Expand All @@ -1405,13 +1406,14 @@ file_var(0, gmem_group);
Freq4 = gmem[gm_ptr + 5];
abs_placement = gmem[gm_ptr + 6];
band_mode = gmem[gm_ptr + 7];
absolute_frequencies = gmem[ptr + 8];

last_read_gmem = gmem[gm_ptr];
);
);

absolute_frequencies ? (
freq_max = 24000;
freq_max = 22050;
norm_freq_min = 20.0 / freq_max;
norm_freq_max = freq_max / srate;
) : (
Expand Down Expand Up @@ -1914,6 +1916,10 @@ function drawToggle(_x, _y, _w, _h, _on, wr, wg, wb, wa, r, g, b, a, _str)
absChoice.drawToggle(20, 40, 10, 10, abs_placement, 1, 0.2, 0.2, 0.8, 1.0, 0.2, 0.2, 0.8, "Absolute positioning.\n\nIn this mode the slider mapping is absolute.");
abs_placement = absChoice.processMouseToggle(mouse_x, mouse_y, mouse_cap);

absFrequency.label = "Absolute frequency range";
absFrequency.drawToggle(20, 60, 10, 10, absolute_frequencies, 1, 0.2, 0.2, 0.8, 1.0, 0.2, 0.2, 0.8, "Absolute frequency range.\n\nMakes settings project sample rate independent.");
absolute_frequencies = absFrequency.processMouseToggle(mouse_x, mouse_y, mouse_cap);

function setup_menu_string(str_var, value, start)
local(s, i)
global()
Expand All @@ -1934,7 +1940,7 @@ function drawToggle(_x, _y, _w, _h, _on, wr, wg, wb, wa, r, g, b, a, _str)
);

link.label = gmem_group > 0 ? sprintf(7, "Read from group %d", gmem_group) : "Link";
link.drawToggle(20, 60, 10, 10, gmem_group > 0, 1, 0.2, 0.2, 0.8, 1.0, 0.2, 0.2, 0.8, "Link to bandsplitter.\n\nClick this to link this phase matcher to a bandsplitter.");
link.drawToggle(20, 80, 10, 10, gmem_group > 0, 1, 0.2, 0.2, 0.8, 1.0, 0.2, 0.2, 0.8, "Link to bandsplitter.\n\nClick this to link this phase matcher to a bandsplitter.");
link.processMouseToggle(mouse_x, mouse_y, mouse_cap);
(link.over && (mouse_cap == 1) && (last_cap == 0)) ? (
menu_selection = gfx_showmenu(sprintf(8, "%s", setup_menu_string(8, gmem_group, 0)));
Expand Down

0 comments on commit 6620556

Please sign in to comment.