-Working on saving all master track details

main
Harry van Haaren 2013-09-05 14:28:11 +01:00
parent e64d94ba15
commit 637e545f27
7 changed files with 85 additions and 22 deletions

View File

@ -151,6 +151,11 @@ class ClipSelector : public Fl_Button
redraw();
}
std::string clipName(int clip)
{
return clips[clip].getName();
}
void draw()
{
if (damage() & FL_DAMAGE_ALL)

View File

@ -55,6 +55,10 @@ class Reverb : public Fl_Slider
void wet(float v) { amp = v; redraw(); }
void damping(float v){damp = v; redraw();}
float size(){return s;}
float wet (){return amp;}
float damping(){return damp;}
bool getActive(){return active;}
void setActive(bool a){active = a; redraw();}

View File

@ -48,10 +48,6 @@ void DiskReader::readSession( std::string path )
char *sampleString = new char[file_length];
sampleFile.read(sampleString, file_length);
//cout << "sessionFile string:\n " << sessionString << endl;
//cout << "sampleFile string: \n " << sampleString << endl;
// create cJSON nodes from strings
session = cJSON_Parse( sessionString );
if (!session) {
@ -63,10 +59,38 @@ void DiskReader::readSession( std::string path )
printf("Error in Sample JSON before: [%s]\n",cJSON_GetErrorPtr());
return;
}
//cout << "readSample: " << cJSON_Print( sample ) << endl;
//cout << "session: " << cJSON_Print( session ) << endl;
//cout << "sample: " << cJSON_Print( sample ) << endl;
readGrid();
// cleanup
cJSON_Delete( session );
cJSON_Delete( sample );
free ( sessionString );
free ( sampleString );
}
void DiskReader::readMaster()
{
cJSON* master = cJSON_GetObjectItem( session, "master");
if ( master )
{
cJSON* volume = cJSON_GetObjectItem( master, "volume");
}
}
void DiskReader::readGrid()
{
cJSON* tracks = cJSON_GetObjectItem( session, "tracks");
if ( tracks )
{
@ -88,7 +112,7 @@ void DiskReader::readSession( std::string path )
if ( !strcmp(clip->valuestring, "") == 0 )
{
stringstream sampleFilePath;
sampleFilePath << path << "/samples/" << clip->valuestring;
sampleFilePath << sessionPath << "/samples/" << clip->valuestring;
#ifdef DEBUG_LOAD
cout << "clip " << sampleFilePath.str() << endl;
#endif
@ -115,8 +139,7 @@ void DiskReader::readSession( std::string path )
} // nClips loop
}
}
} // nTracks loop
}
@ -124,12 +147,4 @@ void DiskReader::readSession( std::string path )
{
cout << "DiskReader: Error getting clip" << endl;
}
// cleanup
cJSON_Delete( session );
cJSON_Delete( sample );
free ( sessionString );
free ( sampleString );
}

View File

@ -33,6 +33,10 @@ class DiskReader
std::string sessionName;
std::string sessionPath;
// convinience functions
void readGrid();
void readMaster();
};
#endif // LUPPP_DISK_READER_H

View File

@ -9,7 +9,11 @@
#include <cstdlib>
#include <sys/stat.h>
#include "gui.hxx"
#include "worker.hxx"
#include "gmastertrack.hxx"
extern Gui* gui;
using namespace std;
@ -61,6 +65,39 @@ void DiskWriter::writeAudioBuffer(int track, int scene, AudioBuffer* ab )
delete ab;
}
void DiskWriter::writeMaster()
{
// Master track stuff
cJSON* masterTrack = cJSON_CreateObject();
cJSON_AddItemToObject(session, "master", masterTrack );
GMasterTrack* master = gui->getMasterTrack();
cJSON_AddNumberToObject( masterTrack, "fader", master->getVolume()->value() );
// scene names
Avtk::ClipSelector* clipSelector = master->getClipSelector();
cJSON* sceneNames = cJSON_CreateArray();
cJSON_AddItemToObject( masterTrack, "sceneNames", sceneNames );
for(int i = 0; i < NSCENES; i++)
{
cJSON* sceneName = cJSON_CreateString( clipSelector->clipName(i).c_str() );
cJSON_AddItemToArray( sceneNames, sceneName );
}
// reverb
Avtk::Reverb* rev = master->getReverb();
cJSON* reverb = cJSON_CreateObject();
cJSON_AddItemToObject( masterTrack, "reverb", reverb );
cJSON_AddNumberToObject( reverb, "size", rev->size() );
cJSON_AddNumberToObject( reverb, "wet", rev->wet() );
cJSON_AddNumberToObject( reverb, "damping", rev->damping() );
cJSON_AddNumberToObject( reverb, "wet", rev->wet() );
cJSON_AddNumberToObject( reverb, "damping", rev->damping() );
}
void DiskWriter::writeSession( std::string path, std::string sessionName )
{
// add session metadata
@ -70,9 +107,7 @@ void DiskWriter::writeSession( std::string path, std::string sessionName )
cJSON_AddNumberToObject( session, "version_patch", 0 );
cJSON_AddNumberToObject( session, "bpm", 120 );
// Master track stuff
cJSON* masterTrack = cJSON_CreateObject();
cJSON_AddItemToObject(session, "master", masterTrack );
writeMaster();

View File

@ -46,6 +46,8 @@ class DiskWriter
std::vector<ClipData> clipData;
// convienice functions for code separation
void writeMaster();
};
#endif // LUPPP_DISK_WRITER_H

View File

@ -71,8 +71,6 @@ class GMasterTrack : public Fl_Group
source(x+5, y+26, 140, 100, ""),
volBox(x+5, y+422, 140, 172, ""),
tapTempo(x + 25 + 52, y + 26 + 4, 63, 29,"Tap"),
metronomeButton(x + 9,y + 26 + 4, 64, 29,"Metro"),
@ -126,7 +124,7 @@ class GMasterTrack : public Fl_Group
source.color( FL_BLACK );
source.selection_color( FL_BLUE );
volume.amplitude( 0.75, 0.8 );
volume.amplitude( 0.0, 0.0 );
end(); // close the group
}