Skip to content

Commit

Permalink
add active flag and basic OSC support
Browse files Browse the repository at this point in the history
  • Loading branch information
gisogrimm committed May 10, 2024
1 parent bd3bb12 commit f03675a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manual/apmodlevel2hsv.tex
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@
\end{tabularx}
}
\end{snugshade}

OSC control:

\input{oscdoc_tascar_ap_level2hsv.tex}
18 changes: 18 additions & 0 deletions manual/oscdoc_tascar_ap_level2hsv.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\definecolor{shadecolor}{RGB}{236,236,255}\begin{snugshade}
{\footnotesize
\label{osctab:tascaraplevel2hsv}
OSC variables:
\nopagebreak

\begin{tabularx}{\textwidth}{llllX}
\hline
path & fmt. & range & r. & description\\
\hline
\attr{/.../active} & i & bool & yes & \\
\attr{/.../hue} & f & & yes & Hue component (0-360 degree)\\
\attr{/.../saturation} & f & & yes & Saturation component (0-1)\\
\hline
\end{tabularx}
}
\end{snugshade}
\definecolor{shadecolor}{RGB}{255,230,204}
13 changes: 13 additions & 0 deletions plugins/src/tascar_ap_level2hsv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class level2hsv_t : public TASCAR::audioplugin_base_t {
level2hsv_t(const TASCAR::audioplugin_cfg_t& cfg);
void ap_process(std::vector<TASCAR::wave_t>& chunk, const TASCAR::pos_t& pos,
const TASCAR::zyx_euler_t&, const TASCAR::transport_t& tp);
void add_variables(TASCAR::osc_server_t* srv);
void configure();
void release();
~level2hsv_t();
Expand All @@ -50,6 +51,7 @@ class level2hsv_t : public TASCAR::audioplugin_base_t {
TASCAR::levelmeter::weight_t weight = TASCAR::levelmeter::Z;
std::vector<float> frange = {62.5f, 4000.0f};
std::vector<float> lrange = {40.0f, 90.0f};
bool active = true;
// float value = 0;
// derived variables:
levelmode_t imode = dbspl;
Expand All @@ -76,6 +78,7 @@ level2hsv_t::level2hsv_t(const TASCAR::audioplugin_cfg_t& cfg)
GET_ATTRIBUTE(tau, "s", "Leq duration, or 0 to use block size");
GET_ATTRIBUTE(hue, "degree", "Hue component (0-360)");
GET_ATTRIBUTE(saturation, "", "Saturation component (0-1)");
GET_ATTRIBUTE_BOOL(active, "start activated");
std::string mode("dbspl");
GET_ATTRIBUTE(mode, "", "Level mode [dbspl|rms|max]");
if(mode == "dbspl")
Expand Down Expand Up @@ -107,6 +110,16 @@ level2hsv_t::level2hsv_t(const TASCAR::audioplugin_cfg_t& cfg)
thread = std::thread(&level2hsv_t::sendthread, this);
}

void level2hsv_t::add_variables(TASCAR::osc_server_t* srv)
{
srv->set_variable_owner(
TASCAR::strrep(TASCAR::tscbasename(__FILE__), ".cc", ""));
srv->add_bool("/active", &active);
srv->add_float("/hue", &hue, "", "Hue component (0-360 degree)");
srv->add_float("/saturation", &saturation, "", "Saturation component (0-1)");
srv->unset_variable_owner();
}

void level2hsv_t::sendthread()
{
std::unique_lock<std::mutex> lk(mtx);
Expand Down

0 comments on commit f03675a

Please sign in to comment.