-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
164 lines (122 loc) · 4.13 KB
/
Copy pathapp.js
File metadata and controls
164 lines (122 loc) · 4.13 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
let start = false;
let firstClick = false;
let counter;
let prevCounter;
// Create AudioContext
let WAContext = window.AudioContext || window.webkitAudioContext;
let context;
let device;
//vai ser ativado com mouse clicked
const setupRNBO = async () => {
context = new WAContext();
let rawPatcher = await fetch("patch.export.json");
let patcher = await rawPatcher.json();
let dependencies = await fetch("dependencies.json");
dependencies = await dependencies.json();
device = await RNBO.createDevice({ context, patcher });
// This connects the device to audio output, but you may still need to call context.resume()
// from a user-initiated function.
device.node.connect(context.destination);
// Load the exported dependencies.json file
// Load the dependencies into the device
const results = await device.loadDataBufferDependencies(dependencies);
results.forEach(result => {
if (result.type === "success") {
console.log(`Successfully loaded buffer with id ${result.id}`);
} else {
console.log(`Failed to load buffer with id ${result.id}, ${result.error}`);
}
});
//Recebe do RNBO (modulos.js)
eventosOuts();
//envios para o RNBO
const granGain = device.parametersById.get("granGain");
granGain.value = -13.2;
const notesGain = device.parametersById.get("notesGain");
notesGain.value = -5;
const droneGain = device.parametersById.get("droneGain");
droneGain.value = -2;
const onsetSensitivity = device.parametersById.get("onset/sensitivity");
onsetSensitivity.value = 0.20;
//para imprimir os parâmetros de controlo do rnbo: a forma assíncrona fá-lo automáticamente
printParams();
};
const printParams = async () => {
// Print the names of all the top-level parameters in the device.
device.parameters.forEach(parameter => {
// Each parameter has an ID as well as a name. The ID will include
// the full path to the parameter, including the names of any parent
// patchers if the parameter is in a subpatcher. So if the path contains
// any "/" characters, you know that it's not a top level parameter.
// Uncomment this line to include only top level parameters.
// if (parameter.id.includes("/")) return;
console.log(parameter.id);
console.log(parameter.name);
});
//para fazer reset aos parâmetros dos knobs e fazer start
interfaceSetup();
start = true;
};
//Ativar o RNBO e BLE
async function mouseClicked() {
if (!firstClick) {
// connectToBle();
await setupRNBO();
await context.resume();
firstClick = true;
}
}
async function touchStarted() {
if (!firstClick) {
connectToBle();
await setupRNBO();
await context.resume();
firstClick = true;
}
return false;
}
function setup() {
frameRate(60);
canvasCreation();
textFont('Courier Prime');
// Create a p5ble class
myBLE = new p5ble();
interfaceSetup();
criarPresets();
}
// WINDOW — CANVAS
function canvasCreation() {
canvas = createCanvas(windowWidth, windowHeight); // actualiza o tamanho da janela caso se diminua ou aumente
canvas.position(0, 0);
}
function windowResized() {
canvasCreation();
interfaceSetup();
atualizarPosPresets();
}
function draw() {
cursor(ARROW)
background(coresInterface.background);
counter = millis();
if (firstClick) {
//simulação visual do drone – tem de estar desativada para simular a bola
// sim_Drone()
//simulação da bola com o rato
sim_Full()
interfaceInterativa();
presetsDisplay();
presetsExect()
recordPresets();
if (!maisInfoDisplay) {
drone();
triggerNotas();
}
} else {
textAlign(CENTER);
textSize(constrain(width / 20, 15, 38))
fill(coresInterface.texto)
text('D I G I B A L L W E B . A P P', width / 2, height / 2 - 26);
textSize(constrain(width / 20, 10, 24))
text('CONECTAR & COMEÇAR', width / 2, height / 2 + 26);
}
}