-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.cpp
More file actions
88 lines (71 loc) · 1.76 KB
/
Input.cpp
File metadata and controls
88 lines (71 loc) · 1.76 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
/*
* InputAtom.cpp
*
* Created on: Aug 17, 2016
* Author: josh
*/
#include <iostream>
#include "AudioBuffer.h"
#include "GlobalNoteStates.h"
#include "Input.h"
namespace AtomSynth
{
AtomController * createInputAtomController()
{
return new InputAtomController();
}
AtomControllerPreview InputAtomController::getPreview()
{
AtomControllerPreview toReturn = AtomController::getPreview();
toReturn.m_createFunction = createInputAtomController;
return toReturn;
}
InputAtomController::InputAtomController()
: AtomController(0, 3)
{
init();
}
InputAtomController::~InputAtomController()
{
}
Atom * InputAtomController::createAtom(int index)
{
return new InputAtom(* this, index); //Increment afterwards, hopefully.
}
InputAtom::InputAtom(InputAtomController & parent, int index)
: Atom(index, 0, 3),
m_parent(parent)
{
}
InputAtom::~InputAtom()
{
}
void InputAtom::execute()
{
Atom::execute();
//m_outputs[0].fill(GlobalNoteStates::getNoteState(m_index).frequency);
int multiplier = 0;
switch(GlobalNoteStates::getNoteState(m_index).status)
{
case NoteState::ACTIVE:
multiplier = 1;
break;
case NoteState::RELEASING:
multiplier = -1;
break;
case NoteState::SILENT:
multiplier = 0;
}
unsigned long int base = GlobalNoteStates::s_currentTimestamp - GlobalNoteStates::getNoteState(m_index).timestamp;
double time, frequency = GlobalNoteStates::getNoteState(m_index).frequency;
for(int c = 0; c < AudioBuffer::getChannels(); c++)
{
for(int s = 0; s < AudioBuffer::getSize(); s++)
{
time = (double(s + base) / m_sampleRate_f) * multiplier;
m_outputs[0].setValue(c, s, frequency);
m_outputs[1].setValue(c, s, time);
}
}
}
} /* namespace AtomSynth */