-
Notifications
You must be signed in to change notification settings - Fork 0
/
AUConvolver.cpp
71 lines (56 loc) · 1.76 KB
/
AUConvolver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* AUConvolver.cpp
* Convolvotron
*
* Created by Seth Nickell on 8/7/09.
* Copyright 2009 Meatscience. All rights reserved.
*
*/
#include "AUConvolver.h"
#include <iostream>
using std::cerr;
using std::cout;
using std::endl;
using boost::shared_ptr;
using namespace Convolver;
AUConvolver::AUConvolver(AUEffectBase &au, shared_ptr<BlockPattern> blockPattern)
: Convolver(blockPattern, true), au(au)
{
//au.GetMaxFramesPerSlice()
}
void AUConvolver::setFilters(Filters &filters, float stereoSeparation)
{
uint32_t numChannels = (UInt32)au.GetNumberOfChannels();
bool changeOutChannels = false;
assert((numChannels == 1) || (numChannels == 2));
#if DEBUG
cout << "AUConvolver::setFilters() on " << filters.size() << " IRs" << endl;
#endif
if (numChannels == 1) {
setupMonoIn(filters, changeOutChannels, numChannels);
} else if (numChannels == 2) {
Convolver::setupStereoIn(filters, changeOutChannels, numChannels, stereoSeparation);
}
}
void AUConvolver::convolve(const AudioBufferList & inBuffer,
AudioBufferList & outBuffer,
UInt32 inFramesToProcess,
float dryGain,
float wetGain)
{
assert(sizeof(AudioSampleType) == sizeof(TimeSample));
uint32_t size = inBuffer.mNumberBuffers;
std::vector<const TimeSample *> in(size);
for (uint32_t i=0; i < size; i++) {
in[i] = (const TimeSample *)inBuffer.mBuffers[i].mData;
}
size = outBuffer.mNumberBuffers;
std::vector<TimeSample *> out(size);
for (uint32_t i=0; i < size; i++) {
#if DEBUG_CONVOLVE
cout << "AUConvolver::convolve() out channel: " << i << " pointer(" << (uint32_t)outBuffer.mBuffers[i].mData << ")" << endl;
#endif
out[i] = (TimeSample *)outBuffer.mBuffers[i].mData;
}
Convolver::convolve(in, out, inFramesToProcess, dryGain, wetGain);
}