artboard audio, save audio with project json

not stable yet
This commit is contained in:
jrkb 2023-10-20 13:29:15 +02:00
parent 922834161f
commit 5f1f5a10a1
11 changed files with 172 additions and 27 deletions

View file

@ -137,6 +137,7 @@ shared_ptr <VariableEditor::ofApp> app;
dir.listDir();
ofDirectory userFonts("/idbfs/fonts");
ofDirectory userAudio("/idbfs/audio"); // possibly rename to media?
nlohmann::json json;
json["files"] = nlohmann::json::array();
@ -157,6 +158,15 @@ shared_ptr <VariableEditor::ofApp> app;
if(!file.moveTo(userFonts)){
std::cout << "Module::importProjectAsZip" << " - cannot move font " << file.getFileName();
}
}else if(ofToLower(file.getExtension()) == "mp3"
|| ofToLower(file.getExtension()) == "m4a"
|| ofToLower(file.getExtension()) == "wav"
|| ofToLower(file.getExtension()) == "webm"
|| ofToLower(file.getExtension()) == "aac"
|| ofToLower(file.getExtension()) == "ogg"){
if(!file.moveTo(userAudio)){
std::cout << "Module::importProjectAsZip" << " - cannot move audiofile " << file.getFileName();
}
}else{
file.remove();
}

View file

@ -50,6 +50,7 @@ class ZipProjectSaver : public ofThread {
this->projectName = projectName;
this->projectJsonString = projectJsonString;
this->userFontsPath = "/idbfs/fonts";
this->userAudioPath = "/idbfs/audio";
this->timestamp = ofGetTimestampString();
this->filename = projectName + "_project_" + timestamp + ".zip";
}
@ -93,6 +94,28 @@ class ZipProjectSaver : public ofThread {
ofBuffer buffy = file.readToBuffer();
zip.addBuffer(fontFilename, buffy.getData(), buffy.size());
}
ofDirectory userAudio(userAudioPath);
userAudio.sort();
userAudio.allowExt("mp3");
userAudio.allowExt("ogg");
userAudio.allowExt("wav");
userAudio.allowExt("webm");
userAudio.allowExt("m4a");
userAudio.listDir();
for(int i = 0; i < userAudio.size(); i++){
std::string audioFilename = userAudio.getName(i);
std::string audioFilepath = userAudioPath + "/" + audioFilename;
ofFile file = userAudio.getFile(i);
ofStringReplace(audioFilepath, "/idbfs/", "idbfs/");
if(of::filesystem::exists(audioFilepath)){
//cout << "huuurrayy " << audioFilepath << " exists" << endl;
}else{
cout << "ofApp::downloadProject() trying to load " << audioFilepath << " but it does not exist." << endl;
}
file.open(audioFilepath);
ofBuffer buffy = file.readToBuffer();
zip.addBuffer(audioFilename, buffy.getData(), buffy.size());
}
buffer = NULL;
buffer_size = 0;
zip.getOutputBuffer(&buffer, buffer_size);
@ -107,6 +130,7 @@ class ZipProjectSaver : public ofThread {
string projectName;
string projectJsonString;
string userFontsPath;
string userAudioPath;
string timestamp;
string filename;
char * buffer;