| 1 |
/** |
| 2 |
* Furnace Tracker - multi-system chiptune tracker |
| 3 |
* Copyright (C) 2021-2025 tildearrow and contributors |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "engine.h" |
| 21 |
#include "effect/dummy.h" |
| 22 |
|
| 23 |
void DivEffectContainer::preAcquire(size_t count) { |
| 24 |
if (!count) return; |
| 25 |
|
| 26 |
int inCount=effect->getInputCount(); |
| 27 |
|
| 28 |
if (inLen<count) { |
| 29 |
for (int i=0; i<inCount; i++) { |
| 30 |
if (in[i]!=NULL) { |
| 31 |
delete[] in[i]; |
| 32 |
in[i]=new float[count]; |
| 33 |
} |
| 34 |
} |
| 35 |
inLen=count; |
| 36 |
} |
| 37 |
|
| 38 |
for (int i=0; i<inCount; i++) { |
| 39 |
if (in[i]==NULL) { |
| 40 |
in[i]=new float[count]; |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
void DivEffectContainer::acquire(size_t count) { |
| 46 |
if (!count) return; |
| 47 |
|
| 48 |
int outCount=effect->getOutputCount(); |
| 49 |
|
| 50 |
if (outLen<count) { |
| 51 |
for (int i=0; i<outCount; i++) { |
| 52 |
if (out[i]!=NULL) { |
| 53 |
delete[] out[i]; |
| 54 |
out[i]=new float[count]; |
| 55 |
} |
| 56 |
} |
| 57 |
outLen=count; |
| 58 |
} |
| 59 |
|
| 60 |
for (int i=0; i<outCount; i++) { |
| 61 |
if (out[i]==NULL) { |
| 62 |
out[i]=new float[count]; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
effect->acquire(in,out,count); |
| 67 |
} |
| 68 |
|
| 69 |
bool DivEffectContainer::init(DivEffectType effectType, DivEngine* eng, double rate, unsigned short version, const unsigned char* data, size_t len) { |
| 70 |
switch (effectType) { |
| 71 |
case DIV_EFFECT_DUMMY: |
| 72 |
default: |
| 73 |
effect=new DivEffectDummy; |
| 74 |
} |
| 75 |
return effect->init(eng,rate,version,data,len); |
| 76 |
} |
| 77 |
|
| 78 |
void DivEffectContainer::quit() { |
| 79 |
effect->quit(); |
| 80 |
delete effect; |
| 81 |
effect=NULL; |
| 82 |
|
| 83 |
for (int i=0; i<DIV_MAX_OUTPUTS; i++) { |
| 84 |
if (in[i]) { |
| 85 |
delete[] in[i]; |
| 86 |
in[i]=NULL; |
| 87 |
} |
| 88 |
if (out[i]) { |
| 89 |
delete[] out[i]; |
| 90 |
out[i]=NULL; |
| 91 |
} |
| 92 |
} |
| 93 |
inLen=0; |
| 94 |
outLen=0; |
| 95 |
} |