Loopp/src/diskwriter.hxx

83 lines
1.8 KiB
C++
Raw Normal View History

2013-09-03 20:35:43 +02:00
#ifndef LUPPP_DISK_WRITER_H
#define LUPPP_DISK_WRITER_H
#include <string>
#include <vector>
2013-09-03 20:35:43 +02:00
#include "cjson/cJSON.h"
2013-09-03 20:35:43 +02:00
class AudioBuffer;
class Controller;
2013-09-03 20:35:43 +02:00
enum CONTROLLER_INFO
{
CONTROLLER_NAME,
CONTROLLER_AUTHOR,
CONTROLLER_LINK,
CONTROLLER_INFO_SIZE,
};
/// To hold data about loaded clips until we write the JSON out
class ClipData
{
public:
ClipData(int tr, int sc, std::string na) :
track(tr), scene(sc), name(na) {}
int track;
int scene;
std::string name;
};
2013-09-03 20:35:43 +02:00
/** DiskWriter
* This class writes soundfiles to disk, and keeps track of which filename was
* in which track/scene combo in the grid. This metadata is then written to the
* <sessionName>.luppp file.
**/
class DiskWriter
{
public:
DiskWriter();
/// sets up session write path etc
void initialize( std::string path, std::string sessionName );
2013-09-03 20:35:43 +02:00
/// writes a single audio buffer to disk
int writeAudioBuffer(int track, int scene, AudioBuffer* ab );
2013-09-03 20:35:43 +02:00
/// flush the JSON to disk, finalizing the save
int writeSession();
2013-09-18 12:46:25 +02:00
std::string getLastSaveName();
std::string getLastSavePath();
/// sets a piece of info to be written to the controller
void writeControllerInfo( CONTROLLER_INFO c, std::string s );
/// writes a controller definition .ctlr JSON file from a GenericMIDI instance
int writeControllerFile( Controller* c );
#ifdef BUILD_TESTS
int runTests();
#endif
2013-09-03 20:35:43 +02:00
private:
2013-09-23 10:42:08 +02:00
cJSON* sessionJson;
cJSON* audioJson;
2013-09-23 10:35:02 +02:00
bool foldersCreated;
std::string sessionName;
2013-09-23 12:54:54 +02:00
std::string sessionPath;
2013-09-23 10:42:08 +02:00
std::string audioDir;
2013-09-23 10:35:02 +02:00
std::string sessionDir;
std::vector<ClipData> clipData;
// convienice functions for code separation
void writeMaster();
std::string controllerInfo[CONTROLLER_INFO_SIZE];
2013-09-03 20:35:43 +02:00
};
#endif // LUPPP_DISK_WRITER_H