diff options
| -rw-r--r-- | src/audiofile.cc | 55 | ||||
| -rw-r--r-- | src/drumgizmo.cc | 10 | ||||
| -rw-r--r-- | src/drumkitloader.cc | 13 | ||||
| -rw-r--r-- | src/drumkitparser.cc | 17 | ||||
| -rw-r--r-- | src/instrumentparser.cc | 22 | 
5 files changed, 64 insertions, 53 deletions
| diff --git a/src/audiofile.cc b/src/audiofile.cc index b0180cb..67481b2 100644 --- a/src/audiofile.cc +++ b/src/audiofile.cc @@ -76,17 +76,19 @@ void AudioFile::unload()  }  #define SIZE 512*4  -void AudioFile::init() { -//  printf("Initializing %p\n", this); +void AudioFile::init() +{ +  //DEBUG(audiofile,"Initializing %p\n", this);    if(data) {  -//    printf("\t already initialized\n"); +    //DEBUG(audiofile,"\t already initialized\n");      return;    }    SF_INFO sf_info;    SNDFILE *fh = sf_open(filename.c_str(), SFM_READ, &sf_info);    if(!fh) { -    printf("SNDFILE Error (%s): %s\n", filename.c_str(), sf_strerror(fh)); +    ERR(audiofile,"SNDFILE Error (%s): %s\n", +        filename.c_str(), sf_strerror(fh));      return;    } @@ -96,7 +98,7 @@ void AudioFile::init() {    size = sf_read_float(fh, data, size);  -//  printf("Lazy loaded %d samples\n", size); +  //DEBUG(audiofile,"Lazy loaded %d samples\n", size);    sf_close(fh);    mutex.lock(); @@ -110,14 +112,15 @@ void AudioFile::init() {  void AudioFile::loadNext()  {    if(this->data != this->preloaded_data) { -//    printf("Already completely loaded %p\n", this); +    //DEBUG(audiofile,"Already completely loaded %p\n", this);      return;    }    SF_INFO sf_info;    SNDFILE *fh = sf_open(filename.c_str(), SFM_READ, &sf_info);    if(!fh) { -    printf("SNDFILE Error (%s): %s\n", filename.c_str(), sf_strerror(fh)); +    ERR(audiofile,"SNDFILE Error (%s): %s\n", +        filename.c_str(), sf_strerror(fh));      return;    } @@ -129,39 +132,40 @@ void AudioFile::loadNext()    sf_seek(fh, this->size, SEEK_SET);  //  sample_t* data_buf = new sample_t[SIZE];    while(this->size < sf_info.frames) { -//    printf("Accumulated %d of %llu\n", size_accum, sf_info.frames); -//    if( (r = sf_read_float(fh, data_buf, SIZE)) < 0) { +    //DEBUG(audiofile,"Accumulated %d of %llu\n", size_accum, sf_info.frames); +    //if( (r = sf_read_float(fh, data_buf, SIZE)) < 0) {      if( (r = sf_read_float(fh, &data[this->size], SIZE)) < 0) { -      printf("Error reading sound file\n"); +      ERR(audiofile,"Error reading sound file\n");        break;      } -//    size_accum += r; -//    memcpy(data+size_accum, data_buf, sizeof(sample_t) * r); +    //size_accum += r; +    //memcpy(data+size_accum, data_buf, sizeof(sample_t) * r);      this->size += r;    } -//  delete data_buf; +  //delete data_buf; -//  printf("Finished loading %d samples %p\n", size, this); +  //DEBUG(audiofile,"Finished loading %d samples %p\n", size, this);    sf_close(fh); -//  mutex.lock(); -//  this->data = data; -//  this->size = size; -//  mutex.unlock(); +  //mutex.lock(); +  //this->data = data; +  //this->size = size; +  //mutex.unlock();  } -void AudioFile::reset() { -//  printf("Resetting audio file %p\n", this); +void AudioFile::reset() +{ +  //DEBUG(audiofile,"Resetting audio file %p\n", this);    if(this->data == this->preloaded_data) { -//     printf("\tNot completely loaded - skipping %p\n", this); -     return; +    //DEBUG(audiofile,"\tNot completely loaded - skipping %p\n", this); +    return;    }    mutex.lock();    volatile sample_t* old_data = data;    this->size = SIZE;    this->data = this->preloaded_data; -//  printf("Deleting data %p\n", this); +  //DEBUG(audiofile,"Deleting data %p\n", this);    delete old_data;     mutex.unlock();  } @@ -179,7 +183,8 @@ void AudioFile::load()    SF_INFO sf_info;    SNDFILE *fh = sf_open(filename.c_str(), SFM_READ, &sf_info);    if(!fh) { -    printf("SNDFILE Error (%s): %s\n", filename.c_str(), sf_strerror(fh)); +    ERR(audiofile,"SNDFILE Error (%s): %s\n", +        filename.c_str(), sf_strerror(fh));      return;    } @@ -188,7 +193,7 @@ void AudioFile::load()    sample_t* data = new sample_t[size];     size = sf_read_float(fh, data, size);  -  printf("Loaded %d samples %p\n", size, this); +  DEBUG(audiofile,"Loaded %d samples %p\n", size, this);    sf_close(fh); diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 88436ec..e0be30b 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -332,12 +332,12 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples)          Channel &ch = *j;          AudioFile *af = s->getAudioFile(&ch);          if(af) { -//      LAZYLOAD: -//          printf("Requesting preparing of audio file\n"); -//          loader.prepare(af); +          // LAZYLOAD: +          // DEBUG(drumgizmo,"Requesting preparing of audio file\n"); +          // loader.prepare(af);          }          if(af == NULL || !af->isValid()) { -          //printf("Missing AudioFile.\n"); +          //DEBUG(drumgizmo,"Missing AudioFile.\n");          } else {            //DEBUG(drumgizmo, "Adding event %d.\n", evs[e].offset);            Event *evt = new EventSample(ch.num, 1.0, af, i->group(), i); @@ -432,7 +432,7 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz)          if(evt->rampdown == NO_RAMPDOWN) {  #ifdef SSE -//          printf("%d\n", evt->t); fflush(stdout); +//          DEBUG(drumgizmo,"%d\n", evt->t); fflush(stdout);           size_t optend = ((end - n) / N) * N + n;           for(; n < optend; n += N) {              *(vNsf*)&(s[n]) += *(vNsf*)&(af->data[evt->t]); diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc index 6516c7d..41b56a1 100644 --- a/src/drumkitloader.cc +++ b/src/drumkitloader.cc @@ -82,8 +82,10 @@ void DrumKitLoader::loadKit(DrumKit *kit)    semaphore.post();  } -void DrumKitLoader::prepare(AudioFile* af) { -  printf("Preparing audiofile %p (%d in queue)\n", af, load_queue.size()); +void DrumKitLoader::prepare(AudioFile* af) +{ +  DEBUG(loader, "Preparing audiofile %p (%d in queue)\n", +        af, load_queue.size());    mutex.lock();    af->ref_count++;    load_queue.push_back(af); @@ -97,7 +99,8 @@ void DrumKitLoader::prepare(AudioFile* af) {    semaphore.post();  } -void DrumKitLoader::reset(AudioFile* af) { +void DrumKitLoader::reset(AudioFile* af) +{    mutex.lock();    af->ref_count--;    reset_queue.push_back(af); @@ -125,7 +128,7 @@ void DrumKitLoader::thread_main()      }      if(!load_queue.empty()) { -      printf("Loading remaining of audio file\n");  +      DEBUG(loader, "Loading remaining of audio file\n");         AudioFile* af = load_queue.front();        mutex.lock();        load_queue.pop_front(); @@ -143,7 +146,7 @@ void DrumKitLoader::thread_main()        mutex.unlock();      }      else { // Initialize drum kit -      printf("Initializing drum kit\n"); +      DEBUG(loader, "Initializing drum kit\n");        unsigned int count = 0;        if(kit && !kit->isValid()) goto finish; diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc index 99dc06e..9100b5b 100644 --- a/src/drumkitparser.cc +++ b/src/drumkitparser.cc @@ -28,6 +28,7 @@  #include <string.h>  #include <stdio.h> +#include <hugin.hpp>  #include "instrumentparser.h"  #include "path.h" @@ -40,7 +41,7 @@ DrumKitParser::DrumKitParser(const std::string &kitfile, DrumKit &k)    fd = fopen(kitfile.c_str(), "r"); -  //  printf("Parsing drumkit in %s\n", kitfile.c_str()); +  //  DEBUG(kitparser, "Parsing drumkit in %s\n", kitfile.c_str());    if(!fd) return;  } @@ -65,7 +66,7 @@ void DrumKitParser::startTag(std::string name,    if(name == "channel") {      if(attr.find("name") == attr.end()) { -      printf("Missing channel name.\n"); +      DEBUG(kitparser, "Missing channel name.\n");        return;      }      Channel c(attr["name"]); @@ -78,11 +79,11 @@ void DrumKitParser::startTag(std::string name,    if(name == "instrument") {      if(attr.find("name") == attr.end()) { -      printf("Missing name in instrument tag.\n"); +      DEBUG(kitparser, "Missing name in instrument tag.\n");        return;      }      if(attr.find("file") == attr.end()) { -      printf("Missing file in instrument tag.\n"); +      DEBUG(kitparser, "Missing file in instrument tag.\n");        return;      } @@ -94,12 +95,12 @@ void DrumKitParser::startTag(std::string name,    if(name == "channelmap") {      if(attr.find("in") == attr.end()) { -      printf("Missing 'in' in channelmap tag.\n"); +      DEBUG(kitparser, "Missing 'in' in channelmap tag.\n");        return;      }      if(attr.find("out") == attr.end()) { -      printf("Missing 'out' in channelmap tag.\n"); +      DEBUG(kitparser, "Missing 'out' in channelmap tag.\n");        return;      } @@ -129,11 +130,11 @@ void DrumKitParser::endTag(std::string name)          if(kit.channels[cnt].name == cname) c->num = kit.channels[cnt].num;        }        if(c->num == NO_CHANNEL) { -        printf("Missing channel '%s' in instrument '%s'\n", +        DEBUG(kitparser, "Missing channel '%s' in instrument '%s'\n",                 c->name.c_str(), i->name().c_str());        } else {          /* -          printf("Assigned channel '%s' to number %d in instrument '%s'\n", +          DEBUG(kitparser, "Assigned channel '%s' to number %d in instrument '%s'\n",               c->name.c_str(), c->num, i.name().c_str());          */        } diff --git a/src/instrumentparser.cc b/src/instrumentparser.cc index 1445cbe..15195e1 100644 --- a/src/instrumentparser.cc +++ b/src/instrumentparser.cc @@ -29,13 +29,15 @@  #include <string.h>  #include <stdio.h> +#include <hugin.hpp> +  #include "path.h"  InstrumentParser::InstrumentParser(const std::string &file, Instrument &i)    : instrument(i)  {    s = NULL; -  //  printf("Parsing instrument in %s\n", file.c_str()); +  //  DEBUG(instrparser,"Parsing instrument in %s\n", file.c_str());    path = getPath(file);    fd = fopen(file.c_str(), "r");    if(!fd) return; @@ -62,7 +64,7 @@ void InstrumentParser::startTag(std::string name,    if(name == "sample") {      if(attr.find("name") == attr.end()) { -      printf("Missing required attribute 'name'.\n"); +      DEBUG(instrparser,"Missing required attribute 'name'.\n");        return;      }      s = new Sample(attr["name"]); @@ -70,17 +72,17 @@ void InstrumentParser::startTag(std::string name,    if(name == "audiofile") {      if(s == NULL) { -      printf("Missing Sample!\n"); +      DEBUG(instrparser,"Missing Sample!\n");        return;      }      if(attr.find("file") == attr.end()) { -      printf("Missing required attribute 'file'.\n"); +      DEBUG(instrparser,"Missing required attribute 'file'.\n");        return;      }      if(attr.find("channel") == attr.end()) { -      printf("Missing required attribute 'channel'.\n"); +      DEBUG(instrparser,"Missing required attribute 'channel'.\n");        return;      } @@ -96,12 +98,12 @@ void InstrumentParser::startTag(std::string name,    if(name == "velocity") {      if(attr.find("lower") == attr.end()) { -      printf("Missing required attribute 'lower'.\n"); +      DEBUG(instrparser,"Missing required attribute 'lower'.\n");        return;      }      if(attr.find("upper") == attr.end()) { -      printf("Missing required attribute 'upper'.\n"); +      DEBUG(instrparser,"Missing required attribute 'upper'.\n");        return;      } @@ -111,7 +113,7 @@ void InstrumentParser::startTag(std::string name,    if(name == "sampleref") {      if(attr.find("name") == attr.end()) { -      printf("Missing required attribute 'name'.\n"); +      DEBUG(instrparser,"Missing required attribute 'name'.\n");        return;      } @@ -126,7 +128,7 @@ void InstrumentParser::startTag(std::string name,      }      if(sample == NULL) { -      printf("Samplref pointed at non-existing sample.\n"); +      DEBUG(instrparser,"Samplref pointed at non-existing sample.\n");        return;      } @@ -138,7 +140,7 @@ void InstrumentParser::endTag(std::string name)  {    if(name == "sample") {      if(s == NULL) { -      printf("Missing Sample.\n"); +      DEBUG(instrparser,"Missing Sample.\n");        return;      } | 
