-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheffect.cpp
More file actions
96 lines (81 loc) · 1.98 KB
/
effect.cpp
File metadata and controls
96 lines (81 loc) · 1.98 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "effect.h"
#include <QDebug>
#include <QList>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QComboBox>
#include "audio.h"
#include "effectmap.h"
#include "ports/port.h"
#include "ports/inport.h"
#include "ports/outport.h"
#include "GUI/gui_effect.h"
QAudioFormat Effect::format;
int Effect::step;
Effect::Effect(Audio* parent) : QObject(parent)
, m_ports(QVector<Port*>())
, m_parameters(QList<Parameter*>())
{
effectMap = parent->getEffectMap();
effectName = "Default Effect Name";
type = -1;
}
void Effect::applyEffect(char *in, char *out, int readLength)
{
//default stream/ no effect
for (int i = 0; i < readLength; i++){
out[i] = in[i];
}
}
//In and Out data buffers are the same
void Effect::applyEffect(char *data, int readLength){
applyEffect(data, data, readLength);
}
QList<Port *> Effect::getPorts()
{
return m_ports.toList();
}
char *Effect::getData(OutPort*, int readLength)
{
return nullptr;
}
void Effect::setAudioFormat(QAudioFormat audioformat)
{
format = audioformat;
step = format.sampleSize()/8;
}
void Effect::addPort(Port *port)
{
m_ports.append(port);
if (port->portType == 0){
inPorts.append(static_cast<InPort*>(port));
} else if (port->portType == 1){
outPorts.append(static_cast<OutPort*>(port));
}
}
char* Effect::getOutPortData(Port* port, int readLength){
char* outData = port->data;
if (port->dataLength < readLength){
// Initialise data container in output port
outData = new char[readLength];
// Copy over any data needed
//memcpy(outData, port->data, port->dataLength);
// Set new Outport data
port->data = outData;
port->dataLength = readLength;
}
return outData;
}
float Effect::getFloat(char* c){
float x = 0;
memcpy(&x, c, 4);
return x;
}
int16_t Effect::getInt(char* c){
int x = 0;
memcpy(&x, c, 2);
return x;
}