-Updated testing, debugging and error code

This commit is contained in:
Harry van Haaren 2013-09-17 12:07:25 +01:00
parent 5b38d9b3c5
commit a3020cf1e2
8 changed files with 41 additions and 55 deletions

2
run.sh
View file

@ -1,4 +1,4 @@
#!/bin/bash
set -e
xterm -e "sleep 1 && aj-snapshot -r .ajsnapshot" & bin/luppp
make && xterm -e "sleep 1 && aj-snapshot -r .ajsnapshot" & bin/luppp

View file

@ -24,8 +24,8 @@ DiskWriter::DiskWriter()
void DiskWriter::initialize(std::string path, std::string name )
{
sessionPath = path;
sessionName = name;
sessionPath = getenv("HOME");
sessionName = "lupppSession";
session = cJSON_CreateObject();
sample = cJSON_CreateObject();
@ -37,20 +37,9 @@ int DiskWriter::writeAudioBuffer(int track, int scene, AudioBuffer* ab )
stringstream filename;
filename << "t_" << track << "_s_" << scene << ".wav";
/*
// add the track / scene / name combo to session JSON node
cJSON* clip = cJSON_CreateObject();
cJSON_AddItemToObject(session, "clip", clip );
cJSON_AddNumberToObject(clip,"track", track);
cJSON_AddNumberToObject(clip,"scene", scene);
cJSON_AddStringToObject(clip,"file", filename.str().c_str());
*/
// store the clip in clipData, we will write the session JSON for it in writeSession
clipData.push_back( ClipData( track, scene, filename.str() ) );
// add the AudioBuffer metadata to the sample JSON node
cJSON* sampleClip = cJSON_CreateObject();
cJSON_AddItemToObject(sample, filename.str().c_str(), sampleClip );
@ -62,18 +51,19 @@ int DiskWriter::writeAudioBuffer(int track, int scene, AudioBuffer* ab )
// FIXME: trim trailing / sessionPath from session path if its there
stringstream path;
path << sessionPath << "/" << sessionName << "/samples/" << filename.str();
path << sessionPath << sessionName << "/samples/" << filename.str();
SndfileHandle outfile( path.str(), SFM_WRITE, SF_FORMAT_WAV | SF_FORMAT_FLOAT, 1, 44100);
cout << "Worker::writeSample() " << path.str() << " size: " << ab->getAudioFrames() << endl;
// FIXME: the size of the buffer is bigger than the audio contained in it:
// calculate the length that needs saving using getBeats() * framesPerBeat
outfile.write( &ab->getData()[0], ab->getAudioFrames() );
// de allocate the AudioBuffer
delete ab;
if ( ab->getAudioFrames() > 0 )
outfile.write( &ab->getData()[0], ab->getAudioFrames() );
else
{
LUPPP_WARN("%s","Sample has zero samples");
}
return LUPPP_RETURN_OK;
}
@ -98,17 +88,6 @@ void DiskWriter::writeMaster()
cJSON_AddItemToArray( sceneNames, sceneName );
}
// reverb
/*
Avtk::Reverb* rev = master->getReverb();
cJSON* reverb = cJSON_CreateObject();
cJSON_AddItemToObject( masterTrack, "reverb", reverb );
cJSON_AddNumberToObject( reverb, "active", rev->getActive() );
cJSON_AddNumberToObject( reverb, "size", rev->size() );
cJSON_AddNumberToObject( reverb, "wet", rev->wet() );
cJSON_AddNumberToObject( reverb, "damping", rev->damping() );
*/
}
int DiskWriter::writeSession( std::string path, std::string sessionName )

View file

@ -112,6 +112,8 @@ void handleGuiEvents()
cout << "EventSaveBuffer: " << ev.track << " " << ev.scene << " " << ev.ab->getID() << endl;
#endif
gui->getDiskWriter()->writeAudioBuffer( ev.track, ev.scene, ev.ab );
// de allocate the AudioBuffer
delete ev.ab;
} break; }
case Event::STATE_SAVE_FINISH: {

View file

@ -60,8 +60,8 @@ static void gui_header_callback(Fl_Widget *w, void *data)
}
else if ( strcmp(m->label(), "New Session") == 0 )
{
int no = fl_choice("Start a new session?","Cancel","Yes",0);
if ( no )
int yes = fl_choice("Start a new session?","Cancel","Yes",0);
if ( yes )
{
EventStateReset ev;
writeToDspRingbuffer( &ev );
@ -128,8 +128,8 @@ void Gui::selectLoadSample( int track, int scene )
Gui::Gui() :
window(1110,650),
diskReader( new DiskReader ),
diskWriter( new DiskWriter )
diskReader( new DiskReader() ),
diskWriter( new DiskWriter() )
{
LUPPP_NOTE( "%s", "Gui()" );
window.color(FL_BLACK);

View file

@ -69,8 +69,8 @@ void LooperClip::reset()
EventGuiPrint e( buffer );
writeToGuiRingbuffer( &e );
//EventRequestSaveBuffer e2( track, scene, _buffer->getAudioFrames() );
//writeToGuiRingbuffer( &e2 );
// set "progress" to zero as there's no clip anymore
jack->getControllerUpdater()->setTrackSceneProgress(track, scene, 0 );
}
else
{
@ -78,7 +78,7 @@ void LooperClip::reset()
}
init();
cout << *_buffer << endl;
//cout << *_buffer << endl;
}
/// loads a sample: eg from disk, unloading current sample if necessary

View file

@ -48,22 +48,18 @@ int main(int argc, char** argv)
#ifdef BUILD_TESTS
if ( runTests )
{
// counts failures
int testResult = 0;
// setup the testing Gui / JACK
gui = new Gui();
jack = new Jack();
// test offline functionality
gui->getDiskWriter()->runTests();
delete gui;
delete jack;
gui = new Gui();
jack = new Jack();
testResult += gui->getDiskWriter()->runTests();
// test realtime functionality
jack->getGridLogic()->runTests();
testResult += jack->getGridLogic()->runTests();
delete gui;
delete jack;
@ -71,8 +67,7 @@ int main(int argc, char** argv)
#ifdef BUILD_COVERAGE_TEST
if ( stopAfterTest )
{
LUPPP_NOTE("%s","Done testing, quitting!");
return 0;
return testResult;
}
#endif
}
@ -85,5 +80,7 @@ int main(int argc, char** argv)
jack->activate();
gui->show();
return 0;
}

View file

@ -11,16 +11,20 @@
#include "qunit.hxx"
extern Gui* gui;
extern bool testsPassed;
int DiskWriter::runTests()
{
QUnit::UnitTest qunit( QUnit::normal );
//AudioBuffer ab;
//QUNIT_IS_TRUE( gui->getDiskWriter()->writeAudioBuffer(0, 0, &ab) == LUPPP_RETURN_OK );
// set the session path to /tmp for test writing
AudioBuffer ab(440);
QUNIT_IS_TRUE( gui->getDiskWriter()->writeAudioBuffer(0, 0, &ab) == LUPPP_RETURN_OK );
QUNIT_IS_TRUE( gui->getDiskWriter()->writeSession("/tmp","luppTestSession") == LUPPP_RETURN_OK );
return 0;
return qunit.errors();
}
#endif

10
test.sh
View file

@ -15,9 +15,13 @@
#set -e
./bin/luppp -test -stopAfterTest
make && ./bin/luppp -test -stopAfterTest
if [ $? -eq 0 ]; then
notify-send -t 5 "Luppp: Tests passed..."
echo OK
else
notify-send -t 10 -u critical "Luppp: Build / Test Failed!"
fi