Skip to content

Commit

Permalink
add skeleton for recording level analyzer
Browse files Browse the repository at this point in the history
gisogrimm committed Jan 11, 2025
1 parent 74721d7 commit 5bebf95
Showing 3 changed files with 102 additions and 1 deletion.
2 changes: 2 additions & 0 deletions libtascar/include/audiochunks.h
Original file line number Diff line number Diff line change
@@ -97,6 +97,8 @@ namespace TASCAR {
void operator*=(const wave_t& src);
float* d;
uint32_t n;
float* begin() { return d; };
float* end() { return d + n; };

private:
bool own_pointer;
2 changes: 1 addition & 1 deletion plugins/Makefile
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ AUDIOPLUGINS = delay dummy gate hannenv identity lipsync \
level2osc const noise loopmachine pos2osc gain sndfileasync \
addchannel tubesim spkcalib sessiontime flanger timestamp \
burglatticelpc fence transportramp allpass bandlevel2osc level2hsv \
ringmodulator
ringmodulator reclevelanalyzer

MASKPLUGINS = fig8 multibeam sampledgain

99 changes: 99 additions & 0 deletions plugins/src/tascar_ap_reclevelanalyzer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* This file is part of the TASCAR software, see <http://tascar.org/>
*
* Copyright (c) 2025 Giso Grimm
*/
/*
* TASCAR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, version 3 of the License.
*
* TASCAR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHATABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License, version 3 for more details.
*
* You should have received a copy of the GNU General Public License,
* Version 3 along with TASCAR. If not, see <http://www.gnu.org/licenses/>.
*/

#include "audioplugin.h"
#include "errorhandling.h"
#include "ringbuffer.h"
#include <algorithm>

class reclevelanalyzer_t : public TASCAR::audioplugin_base_t {
public:
reclevelanalyzer_t(const TASCAR::audioplugin_cfg_t& cfg);
void ap_process(std::vector<TASCAR::wave_t>& chunk, const TASCAR::pos_t&,
const TASCAR::zyx_euler_t&, const TASCAR::transport_t&);
void add_variables(TASCAR::osc_server_t* srv);
~reclevelanalyzer_t();

private:
float tau_segment = 0.125;
float tau_analysis = 30.0;
float update_interval = 5.0;

TASCAR::ringbuffer_t* rb = NULL;
};

reclevelanalyzer_t::reclevelanalyzer_t(const TASCAR::audioplugin_cfg_t& cfg)
: audioplugin_base_t(cfg)
{
}

void reclevelanalyzer_t::add_variables(TASCAR::osc_server_t* srv)
{
srv->set_variable_owner(
TASCAR::strrep(TASCAR::tscbasename(__FILE__), ".cc", ""));
// srv->add_float_db("/gain", &gain);
// srv->add_float("/lingain", &gain);
// srv->add_method("/fade", "ff", osc_set_fade, this);
srv->unset_variable_owner();
}

reclevelanalyzer_t::~reclevelanalyzer_t() {}

void reclevelanalyzer_t::ap_process(std::vector<TASCAR::wave_t>& chunk,
const TASCAR::pos_t&,
const TASCAR::zyx_euler_t&,
const TASCAR::transport_t&)
{
if(!chunk.empty()) {
//uint32_t nch(chunk.size());
//uint32_t N(chunk[0].n);
//std::sort(chunk[0].begin(), chunk[0].end(), std::greater<float>());

// write to ringbuffer

}
}

// void updatethread()
// {
// while( runthread && (rb->read_size() > segment) ){
// rb->read( segment )
// peak = segment->maxabs();
// aweight.filter(segment);
// append_peak_and_rms;
// update_cnt++;
// if( update_cnt > num_segments_per_update_interval ){
// update_cnt = 0;
// copy_peak_and_rms_to_sortbuffer_then_sort;
// calc_percentiles;
// classify_results;
// }
// }
// }

REGISTER_AUDIOPLUGIN(reclevelanalyzer_t);

/*
* Local Variables:
* mode: c++
* c-basic-offset: 2
* indent-tabs-mode: nil
* compile-command: "make -C .."
* End:
*/

0 comments on commit 5bebf95

Please sign in to comment.