Skip to content

Commit 16e3f0d

Browse files
committed
ok
1 parent 0e5db16 commit 16e3f0d

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

clients/oooooooo/src/KeyboardHandler.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,14 @@ void KeyboardHandler::handleKeyDown(SDL_Keycode key, bool isRepeat,
9999
json["loop" + std::to_string(i)] = params_[i].toJSON();
100100
}
101101
std::cerr << "Saving parameters to file" << std::endl;
102+
// create folder oooooooo if it doesn't exist
103+
std::string folder = "oooooooo";
104+
if (!std::filesystem::exists(folder)) {
105+
std::filesystem::create_directory(folder);
106+
}
107+
102108
// write it to a file
103-
std::ofstream file("parameters.json");
109+
std::ofstream file("oooooooo/parameters.json");
104110
if (file.is_open()) {
105111
file << json.dump(4);
106112
file.close();
@@ -114,17 +120,26 @@ void KeyboardHandler::handleKeyDown(SDL_Keycode key, bool isRepeat,
114120
case SDLK_o:
115121
if (!isRepeat) {
116122
if (keysHeld_[SDLK_LCTRL] || keysHeld_[SDLK_RCTRL]) {
123+
// load every loop audio folder
124+
for (int i = 0; i < numVoices_; i++) {
125+
std::string path = "oooooooo/loop_" + std::to_string(i) + ".wav";
126+
softcut_->loadBufferToLoop(path, i);
127+
}
117128
} else {
118129
// load the parameters
119130
JSON json;
120-
std::ifstream file("parameters.json");
131+
std::ifstream file("oooooooo/parameters.json");
121132
if (file.is_open()) {
122133
file >> json;
123134
file.close();
124135
std::cerr << "Parameters loaded from parameters.json" << std::endl;
125136
for (int i = 0; i < numVoices_; i++) {
126137
params_[i].fromJSON(json["loop" + std::to_string(i)]);
127138
}
139+
// bang parameters
140+
for (int i = 0; i < numVoices_; i++) {
141+
params_[i].Bang();
142+
}
128143
} else {
129144
std::cerr << "Error opening file for reading" << std::endl;
130145
}

clients/oooooooo/src/Parameters.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ class Parameters : public Serializable {
8989

9090
void Update();
9191

92+
void Bang() {
93+
for (int i = 0; i < PARAM_COUNT; i++) {
94+
param_[i].Bang();
95+
}
96+
}
97+
9298
float GetRaw(ParameterName p) { return param_[p].GetRaw(); }
9399
float GetValue(ParameterName p) { return param_[p].GetValue(); }
94100
float GetRawMin(ParameterName p) { return param_[p].GetRawMin(); }

clients/oooooooo/src/SoftcutClient.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef CRONE_CUTCLIENT_H
66
#define CRONE_CUTCLIENT_H
77

8+
#include <filesystem>
89
#include <iostream>
910

1011
#include "BufDiskWorker.h"
@@ -210,8 +211,13 @@ class SoftcutClient : public JackClient<2, 2> {
210211
float cutDuration = getLoopDuration();
211212
int bufSrc = loop < 4 ? 0 : 1;
212213
float startSrc = loopMin[loop];
214+
// create folder oooooooo if it doesn't exist
215+
std::string folder = "oooooooo";
216+
if (!std::filesystem::exists(folder)) {
217+
std::filesystem::create_directory(folder);
218+
}
213219
// generate random file name
214-
std::string path = "loop_" + std::to_string(loop) + ".wav";
220+
std::string path = "oooooooo/loop_" + std::to_string(loop) + ".wav";
215221
// write buffer to file
216222
writeBufferMono(path, startSrc, cutDuration, bufSrc);
217223
std::cerr << "dumpBufferFromLoop: " << path << std::endl;

0 commit comments

Comments
 (0)