Skip to content

Commit

Permalink
add support for zita-convolver4 fix Bug #63
Browse files Browse the repository at this point in the history
  • Loading branch information
brummer10 committed Jun 19, 2018
1 parent 7278d18 commit d10a284
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 35 deletions.
5 changes: 5 additions & 0 deletions trunk/src/LV2/DSP/gx_compiler.h
@@ -1,7 +1,12 @@
#ifndef SRC_HEADERS_GX_COMPILER_H_
#define SRC_HEADERS_GX_COMPILER_H_

#ifdef __APPLE__
#define __rt_func __attribute__((section("TEXT,.rt.text")))
#define __rt_data __attribute__((section("DATA,.rt.data")))
#else
#define __rt_func __attribute__((section(".rt.text")))
#define __rt_data __attribute__((section(".rt.data")))
#endif

#endif // SRC_HEADERS_GX_COMPILER_H_
24 changes: 24 additions & 0 deletions trunk/src/LV2/DSP/gx_convolver.cc
Expand Up @@ -181,12 +181,20 @@ bool GxSimpleConvolver::configure(int32_t count, float *impresp, uint32_t imprat
{
bufsize = Convproc::MINPART;
}
#if ZITA_CONVOLVER_VERSION == 4
if (Convproc::configure(1, 1, count, buffersize,
bufsize, Convproc::MAXPART,0.0)) {
printf("no configure\n");
return false;
}
#else
if (Convproc::configure(1, 1, count, buffersize,
bufsize, bufsize)) // Convproc::MAXPART
{
printf("no configure\n");
return false;
}
#endif
if (impdata_create(0, 0, 1, impresp, 0, count))
{
printf("no impdata_create()\n");
Expand All @@ -205,6 +213,9 @@ bool GxSimpleConvolver::update(int32_t count, float *impresp, uint32_t imprate)
{
return false;
}
#if ZITA_CONVOLVER_VERSION == 4
impdata_clear(0, 0);
#endif
if (impdata_update(0, 0, 1, impresp, 0, count))
{
return false;
Expand Down Expand Up @@ -293,12 +304,21 @@ bool GxSimpleConvolver::configure_stereo(int32_t count, float *impresp, uint32_t
{
bufsize = Convproc::MINPART;
}
#if ZITA_CONVOLVER_VERSION == 4
if (Convproc::configure(2, 2, count, buffersize,
bufsize, bufsize,0.0)) // Convproc::MAXPART
{
printf("no configure\n");
return false;
}
#else
if (Convproc::configure(2, 2, count, buffersize,
bufsize, bufsize)) // Convproc::MAXPART
{
printf("no configure\n");
return false;
}
#endif
if (impdata_create(0, 0, 1, impresp, 0, count) & impdata_create(1, 1, 1, impresp, 0, count))
{
printf("no impdata_create()\n");
Expand All @@ -317,6 +337,10 @@ bool GxSimpleConvolver::update_stereo(int32_t count, float *impresp, uint32_t im
{
return false;
}
#if ZITA_CONVOLVER_VERSION == 4
impdata_clear(0, 0);
impdata_clear(1, 1);
#endif
if (impdata_update(0, 0, 1, impresp, 0, count) & impdata_update(1, 1, 1, impresp, 0, count))
{
return false;
Expand Down
1 change: 1 addition & 0 deletions trunk/src/LV2/DSP/gx_convolver.h
Expand Up @@ -26,6 +26,7 @@
#include <zita-convolver.h>
#include <stdint.h>
#include "gx_resampler.h"
#include "../../config.h"
/* GxConvolver */


Expand Down
4 changes: 4 additions & 0 deletions trunk/src/LV2/DSP/gx_mlock.cc
Expand Up @@ -39,6 +39,7 @@ class GX_LOCK
};

void GX_LOCK::lock_rt_memory() {
#ifndef __APPLE__
extern char __rt_text__start[], __rt_text__end[];
extern char __rt_data__start[], __rt_data__end[];
rt_lock regions[] = {
Expand All @@ -54,9 +55,11 @@ void GX_LOCK::lock_rt_memory() {
}
}
fprintf(stderr,"mlock %ld bytes\n",total_size);
#endif
}

void GX_LOCK::unlock_rt_memory() {
#ifndef __APPLE__
extern char __rt_text__start[], __rt_text__end[];
extern char __rt_data__start[], __rt_data__end[];
rt_lock regions[] = {
Expand All @@ -72,5 +75,6 @@ void GX_LOCK::unlock_rt_memory() {
}
}
fprintf(stderr,"munlock %ld bytes\n",total_size);
#endif
}
#endif
12 changes: 12 additions & 0 deletions trunk/src/LV2/gx_jcm800pre.lv2/gx_presence.cc
Expand Up @@ -105,12 +105,21 @@ bool GxPresence::configure(int32_t count, float *impresp, uint32_t imprate)
{
bufsize = Convproc::MINPART;
}
#if ZITA_CONVOLVER_VERSION == 4
if (Convproc::configure(1, 1, count, buffersize,
bufsize, bufsize,0.0)) // Convproc::MAXPART
{
printf("no configure\n");
return false;
}
#else
if (Convproc::configure(1, 1, count, buffersize,
bufsize, bufsize)) // Convproc::MAXPART
{
printf("no configure\n");
return false;
}
#endif
if (impdata_create(0, 0, 1, impresp, 0, count))
{
printf("no impdata_create()\n");
Expand All @@ -129,6 +138,9 @@ bool GxPresence::update(int32_t count, float *impresp, uint32_t imprate)
{
return false;
}
#if ZITA_CONVOLVER_VERSION == 4
impdata_clear(0, 0);
#endif
if (impdata_update(0, 0, 1, impresp, 0, count))
{
return false;
Expand Down
12 changes: 12 additions & 0 deletions trunk/src/LV2/gx_jcm800pre_st.lv2/gx_presence.cc
Expand Up @@ -105,12 +105,21 @@ bool GxPresence::configure(int32_t count, float *impresp, uint32_t imprate)
{
bufsize = Convproc::MINPART;
}
#if ZITA_CONVOLVER_VERSION == 4
if (Convproc::configure(1, 1, count, buffersize,
bufsize, bufsize,0.0)) // Convproc::MAXPART
{
printf("no configure\n");
return false;
}
#else
if (Convproc::configure(1, 1, count, buffersize,
bufsize, bufsize)) // Convproc::MAXPART
{
printf("no configure\n");
return false;
}
#endif
if (impdata_create(0, 0, 1, impresp, 0, count))
{
printf("no impdata_create()\n");
Expand All @@ -129,6 +138,9 @@ bool GxPresence::update(int32_t count, float *impresp, uint32_t imprate)
{
return false;
}
#if ZITA_CONVOLVER_VERSION == 4
impdata_clear(0, 0);
#endif
if (impdata_update(0, 0, 1, impresp, 0, count))
{
return false;
Expand Down
77 changes: 58 additions & 19 deletions trunk/src/gx_head/engine/gx_convolver.cpp
Expand Up @@ -416,10 +416,17 @@ bool GxConvolver::configure(
delay = round(delay * f);
ldelay = round(ldelay * f);
}
if (Convproc::configure(2, 2, size, buffersize, bufsize, Convproc::MAXPART)) {
gx_print_error("convolver", "error in Convproc::configure ");
return false;
}
#if ZITA_CONVOLVER_VERSION == 4
if (Convproc::configure(2, 2, size, buffersize, bufsize, Convproc::MAXPART, 0.0)) {
gx_print_error("convolver", "error in Convproc::configure ");
return false;
}
#else
if (Convproc::configure(2, 2, size, buffersize, bufsize, Convproc::MAXPART)) {
gx_print_error("convolver", "error in Convproc::configure ");
return false;
}
#endif

float gain_a[2] = {gain, lgain};
unsigned int delay_a[2] = {delay, ldelay};
Expand Down Expand Up @@ -479,10 +486,17 @@ bool GxConvolver::configure(string fname, float gain, unsigned int delay, unsign
size = round(size * f) + 2; // 2 is safety margin for rounding differences
delay = round(delay * f);
}
if (Convproc::configure(1, 1, size, buffersize, bufsize, Convproc::MAXPART)) {
gx_print_error("convolver", "error in Convproc::configure ");
return false;
}
#if ZITA_CONVOLVER_VERSION == 4
if (Convproc::configure(1, 1, size, buffersize, bufsize, Convproc::MAXPART,0.0)) {
gx_print_error("convolver", "error in Convproc::configure ");
return false;
}
#else
if (Convproc::configure(1, 1, size, buffersize, bufsize, Convproc::MAXPART)) {
gx_print_error("convolver", "error in Convproc::configure ");
return false;
}
#endif

float gain_a[1] = {gain};
unsigned int delay_a[1] = {delay};
Expand Down Expand Up @@ -556,11 +570,19 @@ bool GxSimpleConvolver::configure(int count, float *impresp, unsigned int imprat
if (bufsize < Convproc::MINPART) {
bufsize = Convproc::MINPART;
}
if (Convproc::configure(1, 1, count, buffersize,
bufsize, Convproc::MAXPART)) {
gx_print_error("convolver", "error in Convproc::configure");
return false;
}
#if ZITA_CONVOLVER_VERSION == 4
if (Convproc::configure(1, 1, count, buffersize,
bufsize, Convproc::MAXPART,0.0)) {
gx_print_error("convolver", "error in Convproc::configure");
return false;
}
#else
if (Convproc::configure(1, 1, count, buffersize,
bufsize, Convproc::MAXPART)) {
gx_print_error("convolver", "error in Convproc::configure");
return false;
}
#endif
if (impdata_create(0, 0, 1, impresp, 0, count)) {
gx_print_error("convolver", "out of memory");
return false;
Expand All @@ -574,6 +596,9 @@ bool GxSimpleConvolver::update(int count, float *impresp, unsigned int imprate)
if (!impresp) {
return false;
}
#if ZITA_CONVOLVER_VERSION == 4
impdata_clear(0, 0);
#endif
if (impdata_update(0, 0, 1, impresp, 0, count)) {
gx_print_error("convolver", "update: internal error");
return false;
Expand Down Expand Up @@ -620,12 +645,22 @@ bool GxSimpleConvolver::configure_stereo(int count, float *impresp, unsigned int
{
bufsize = Convproc::MINPART;
}
if (Convproc::configure(2, 2, count, buffersize,
bufsize, bufsize)) // Convproc::MAXPART
{
printf("no configure\n");
return false;
}
#if ZITA_CONVOLVER_VERSION == 4
if (Convproc::configure(2, 2, count, buffersize,
bufsize, bufsize,0.0)) // Convproc::MAXPART
{
printf("no configure\n");
return false;
}

#else
if (Convproc::configure(2, 2, count, buffersize,
bufsize, bufsize)) // Convproc::MAXPART
{
printf("no configure\n");
return false;
}
#endif
if (impdata_create(0, 0, 1, impresp, 0, count) & impdata_create(1, 1, 1, impresp, 0, count))
{
printf("no impdata_create()\n");
Expand All @@ -644,6 +679,10 @@ bool GxSimpleConvolver::update_stereo(int count, float *impresp, unsigned int im
{
return false;
}
#if ZITA_CONVOLVER_VERSION == 4
impdata_clear(0, 0);
impdata_clear(1, 1);
#endif
if (impdata_update(0, 0, 1, impresp, 0, count) & impdata_update(1, 1, 1, impresp, 0, count))
{
return false;
Expand Down
55 changes: 39 additions & 16 deletions trunk/wscript
Expand Up @@ -541,26 +541,49 @@ def check_zita_convolver(opt, conf):
conf.env['CONVOLVER_FFMPEG'] = False
if opt.includeconvolver:
conf.env['ZITA_CONVOLVER'] = False
conf.define ('ZITA_CONVOLVER_VERSION', 3)
elif opt.convolver_ffmpeg:
conf.env['ZITA_CONVOLVER'] = False
conf.env['CONVOLVER_FFMPEG'] = True
conf.define ('ZITA_CONVOLVER_VERSION', 3)
else:
expected_zita_convolver_version = 3
code="""
#include <zita-convolver.h>
#if ZITA_CONVOLVER_MAJOR_VERSION != %d
#error
#endif
int main(){ return 0; }
""" % expected_zita_convolver_version
conf.check_cxx(
fragment=code,
lib="zita-convolver",
uselib_store='ZITA_CONVOLVER',
msg='Checking for zita-convolver >= %d.0' % expected_zita_convolver_version,
errmsg="Zita-convolver version %d not found" % expected_zita_convolver_version,
mandatory=True,
define_name="ZITA_CONVOLVER")
try:
expected_zita_convolver_version = 3
code="""
#include <zita-convolver.h>
#if ZITA_CONVOLVER_MAJOR_VERSION != %d
#error
#endif
int main(){ return 0; }
""" % expected_zita_convolver_version
conf.check_cxx(
fragment=code,
lib="zita-convolver",
uselib_store='ZITA_CONVOLVER',
msg='Checking for zita-convolver >= %d.0' % expected_zita_convolver_version,
errmsg="Zita-convolver version %d not found, trying version 4" % expected_zita_convolver_version,
mandatory=True,
define_name="ZITA_CONVOLVER")
conf.define ('ZITA_CONVOLVER_VERSION', 3)
except ConfigurationError:
expected_zita_convolver_version = 4
code="""
#include <zita-convolver.h>
#if ZITA_CONVOLVER_MAJOR_VERSION != %d
#error
#endif
int main(){ return 0; }
""" % expected_zita_convolver_version
conf.check_cxx(
fragment=code,
lib="zita-convolver",
uselib_store='ZITA_CONVOLVER',
msg='Checking for zita-convolver >= %d.0' % expected_zita_convolver_version,
errmsg="Zita-convolver version %d not found" % expected_zita_convolver_version,
mandatory=True,
define_name="ZITA_CONVOLVER")
conf.define ('ZITA_CONVOLVER_VERSION', 4)


def check_zita_resampler(opt, conf):
if opt.includeresampler:
Expand Down

0 comments on commit d10a284

Please sign in to comment.