COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 11-12-2017, 06:46 AM   #1
pressplay
Human being with feelings
 
pressplay's Avatar
 
Join Date: Sep 2017
Location: Berlin
Posts: 47
Default manipulating input buffers

Hi,

I have a class that can process audio buffers with this function:

Code:
void FilteredFeedbackDelay<S>::processAudio(double** inputs, double** outputs, int nFrames) { ... }
In ProcessDoubleReplacing I call this function, however, I'm passing the input buffers as inputs AND outputs, like this:

Code:
delay.processAudio(inputs, inputs, nFrames);
So basically, I'm manipulating the input buffers here and later I'm calling another function where the output buffers are calculated. In most cases I don't see/hear any problems. But sometimes there are glitches and feedback where I wouldn't expect them and I assume it's coming from this function call.

Is manipulating the input buffers "dangerous"? Is it better to store the samples in another array/container first?

Thanks
Peat
pressplay is offline   Reply With Quote
Old 11-12-2017, 07:25 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

It's best to assume the input buffers are owned by the host or the plugin framework and that one should not manipulate the data in them.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 11-12-2017, 08:53 AM   #3
pressplay
Human being with feelings
 
pressplay's Avatar
 
Join Date: Sep 2017
Location: Berlin
Posts: 47
Default

I don't want to allocate and deallocate new arrays and copy data in each processing block. And it seemed an elegant solution to use the input buffers as an intermediate storage and apply a dry/wet stage later. I will try to find a better way...

By the way, I'm pretty sure now that problems occur in debug mode only!
pressplay is offline   Reply With Quote
Old 11-13-2017, 12:33 AM   #4
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

You know the maximum buffer size in Reset() via GetBlockSize(), so you can (re)allocate internal buffers there. That way you don't have to don't have to reallocate all the time, but you would still have to copy data around.
Tale is offline   Reply With Quote
Old 11-14-2017, 01:37 AM   #5
pressplay
Human being with feelings
 
pressplay's Avatar
 
Join Date: Sep 2017
Location: Berlin
Posts: 47
Default

I would then prefer to use some standard containers instead of raw arrays. Unfortunatelly, this would also mean a lot of refactoring, as my "processing blocks" operate on arrays. I would do it like this: Copy **inputs into my own containers, do the processing, and at the end of ProcessDoubleReplacing copy results into **outputs. Good idea? Bad idea?
pressplay is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.