From f42bd3fe47af66ad409423d43f8bdd02db9ba864 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 5 Aug 2020 16:02:19 -0600 Subject: [PATCH] add per-thread sample rate variable and libardour method to update it --- libs/ardour/superclock.cc | 28 ++++++++++++++++++++++++++++ libs/ardour/wscript | 3 ++- libs/temporal/superclock.cc | 24 ++++++++++++++++++++++++ libs/temporal/wscript | 2 +- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 libs/ardour/superclock.cc create mode 100644 libs/temporal/superclock.cc diff --git a/libs/ardour/superclock.cc b/libs/ardour/superclock.cc new file mode 100644 index 0000000000..563129bc12 --- /dev/null +++ b/libs/ardour/superclock.cc @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2020 Paul Davis + * + * This program 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; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "temporal/superclock.h" + +#include "ardour/audioengine.h" + +void +update_sample_rate () +{ + Temporal::_thread_sample_rate = ARDOUR::AudioEngine::instance()->sample_rate(); +} + diff --git a/libs/ardour/wscript b/libs/ardour/wscript index baf4c199a4..ce7121eaa7 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -251,7 +251,8 @@ libardour_sources = [ 'stripable.cc', 'step_sequencer.cc', 'strip_silence.cc', - 'system_exec.cc', + 'superclock.cc', + 'system_exec.cc', 'revision.cc', 'rt_midibuffer.cc', 'template_utils.cc', diff --git a/libs/temporal/superclock.cc b/libs/temporal/superclock.cc new file mode 100644 index 0000000000..d98883f996 --- /dev/null +++ b/libs/temporal/superclock.cc @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 Paul Davis + * + * This program 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; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "temporal/superclock.h" + +namespace Temporal { + thread_local uint32_t _thread_sample_rate = 0; +} + diff --git a/libs/temporal/wscript b/libs/temporal/wscript index 49b38eb766..b63d2b056e 100644 --- a/libs/temporal/wscript +++ b/libs/temporal/wscript @@ -24,7 +24,7 @@ APPNAME = 'temporal' VERSION = TEMPORAL_VERSION I18N_PACKAGE = 'libtemporal' -temporal_sources = [ 'time.cc', 'bbt_time.cc', 'tempo.cc', 'timeline.cc' ] +temporal_sources = [ 'time.cc', 'bbt_time.cc', 'tempo.cc', 'timeline.cc', 'superclock.cc' ] def options(opt): autowaf.set_options(opt)