Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/hostext/PluginChannelAdapter.cpp @ 61:97c5ac99d725 host-factory-stuff
* install hostext headers to vamp-sdk/hostext/ rather than vamp-sdk/
* adjust timestamps in input-domain adapter so as to centre them on block
as required by Plugin documentation
* better handling for frequency-domain plugins that want non-power-of-two
blocksizes (can't handle them, but at least try offering them a power-of-two
alternative)
* couple of Plugin doc additions
* make PluginLoader capable of returning ready-wrapped plugins
author | cannam |
---|---|
date | Fri, 01 Jun 2007 13:53:42 +0000 |
parents | fa79c4ec847d |
children |
comparison
equal
deleted
inserted
replaced
60:087c16cca0d6 | 61:97c5ac99d725 |
---|---|
78 size_t minch = m_plugin->getMinChannelCount(); | 78 size_t minch = m_plugin->getMinChannelCount(); |
79 size_t maxch = m_plugin->getMaxChannelCount(); | 79 size_t maxch = m_plugin->getMaxChannelCount(); |
80 | 80 |
81 m_inputChannels = channels; | 81 m_inputChannels = channels; |
82 | 82 |
83 if (channels < minch) { | 83 if (m_inputChannels < minch) { |
84 | |
84 m_forwardPtrs = new const float *[minch]; | 85 m_forwardPtrs = new const float *[minch]; |
86 | |
85 if (m_inputChannels > 1) { | 87 if (m_inputChannels > 1) { |
86 // We need a set of zero-valued buffers to add to the | 88 // We need a set of zero-valued buffers to add to the |
87 // forwarded pointers | 89 // forwarded pointers |
88 m_buffer = new float*[minch - channels]; | 90 m_buffer = new float*[minch - channels]; |
89 for (size_t i = 0; i < minch; ++i) { | 91 for (size_t i = 0; i < minch; ++i) { |
91 for (size_t j = 0; j < blockSize; ++j) { | 93 for (size_t j = 0; j < blockSize; ++j) { |
92 m_buffer[i][j] = 0.f; | 94 m_buffer[i][j] = 0.f; |
93 } | 95 } |
94 } | 96 } |
95 } | 97 } |
98 | |
96 m_pluginChannels = minch; | 99 m_pluginChannels = minch; |
97 return m_plugin->initialise(minch, stepSize, blockSize); | |
98 } | |
99 | 100 |
100 if (channels > maxch) { | 101 std::cerr << "PluginChannelAdapter::initialise: expanding " << m_inputChannels << " to " << m_pluginChannels << " for plugin" << std::endl; |
102 | |
103 } else if (m_inputChannels > maxch) { | |
104 | |
101 // We only need m_buffer if we are mixing down to a single | 105 // We only need m_buffer if we are mixing down to a single |
102 // channel -- otherwise we can just forward the same float* as | 106 // channel -- otherwise we can just forward the same float* as |
103 // passed in to process(), expecting the excess to be ignored | 107 // passed in to process(), expecting the excess to be ignored |
108 | |
104 if (maxch == 1) { | 109 if (maxch == 1) { |
105 m_buffer = new float *[1]; | 110 m_buffer = new float *[1]; |
106 m_buffer[0] = new float[blockSize]; | 111 m_buffer[0] = new float[blockSize]; |
112 | |
113 std::cerr << "PluginChannelAdapter::initialise: mixing " << m_inputChannels << " to mono for plugin" << std::endl; | |
114 | |
115 } else { | |
116 | |
117 std::cerr << "PluginChannelAdapter::initialise: reducing " << m_inputChannels << " to " << m_pluginChannels << " for plugin" << std::endl; | |
107 } | 118 } |
119 | |
108 m_pluginChannels = maxch; | 120 m_pluginChannels = maxch; |
109 return m_plugin->initialise(maxch, stepSize, blockSize); | 121 |
122 } else { | |
123 | |
124 std::cerr << "PluginChannelAdapter::initialise: accepting given number of channels (" << m_inputChannels << ")" << std::endl; | |
125 m_pluginChannels = m_inputChannels; | |
110 } | 126 } |
111 | 127 |
112 m_pluginChannels = channels; | 128 return m_plugin->initialise(m_pluginChannels, stepSize, blockSize); |
113 return m_plugin->initialise(channels, stepSize, blockSize); | |
114 } | 129 } |
115 | 130 |
116 PluginChannelAdapter::FeatureSet | 131 PluginChannelAdapter::FeatureSet |
117 PluginChannelAdapter::process(const float *const *inputBuffers, | 132 PluginChannelAdapter::process(const float *const *inputBuffers, |
118 RealTime timestamp) | 133 RealTime timestamp) |
119 { | 134 { |
135 std::cerr << "PluginChannelAdapter::process: " << m_inputChannels << " -> " << m_pluginChannels << " channels" << std::endl; | |
136 | |
120 if (m_inputChannels < m_pluginChannels) { | 137 if (m_inputChannels < m_pluginChannels) { |
121 | 138 |
122 if (m_inputChannels == 1) { | 139 if (m_inputChannels == 1) { |
123 for (size_t i = 0; i < m_pluginChannels; ++i) { | 140 for (size_t i = 0; i < m_pluginChannels; ++i) { |
124 m_forwardPtrs[i] = inputBuffers[0]; | 141 m_forwardPtrs[i] = inputBuffers[0]; |
131 m_forwardPtrs[i] = m_buffer[i - m_inputChannels]; | 148 m_forwardPtrs[i] = m_buffer[i - m_inputChannels]; |
132 } | 149 } |
133 } | 150 } |
134 | 151 |
135 return m_plugin->process(m_forwardPtrs, timestamp); | 152 return m_plugin->process(m_forwardPtrs, timestamp); |
136 } | |
137 | 153 |
138 if (m_inputChannels > m_pluginChannels) { | 154 } else if (m_inputChannels > m_pluginChannels) { |
139 | 155 |
140 if (m_pluginChannels == 1) { | 156 if (m_pluginChannels == 1) { |
141 for (size_t j = 0; j < m_blockSize; ++j) { | 157 for (size_t j = 0; j < m_blockSize; ++j) { |
142 m_buffer[0][j] = inputBuffers[0][j]; | 158 m_buffer[0][j] = inputBuffers[0][j]; |
143 } | 159 } |
151 } | 167 } |
152 return m_plugin->process(m_buffer, timestamp); | 168 return m_plugin->process(m_buffer, timestamp); |
153 } else { | 169 } else { |
154 return m_plugin->process(inputBuffers, timestamp); | 170 return m_plugin->process(inputBuffers, timestamp); |
155 } | 171 } |
172 | |
173 } else { | |
174 | |
175 return m_plugin->process(inputBuffers, timestamp); | |
156 } | 176 } |
157 | |
158 return m_plugin->process(inputBuffers, timestamp); | |
159 } | 177 } |
160 | 178 |
161 } | 179 } |
162 | 180 |
163 } | 181 } |