summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/audiofile.cc4
-rw-r--r--src/jackclient.cc9
-rw-r--r--src/midimapper.cc4
3 files changed, 8 insertions, 9 deletions
diff --git a/src/audiofile.cc b/src/audiofile.cc
index 1c6ac86..d52e010 100644
--- a/src/audiofile.cc
+++ b/src/audiofile.cc
@@ -65,12 +65,12 @@ void AudioFile::load()
size = sf_seek(fh, 0, SEEK_END);
data = (jack_default_audio_sample_t*)malloc(sizeof(jack_default_audio_sample_t)*size);
- printf("Loading %s, %d samples\n", filename.c_str(), size);
+ // printf("Loading %s, %d samples\n", filename.c_str(), size);
sf_seek(fh, 0, SEEK_SET);
sf_read_float(fh, data, size);
- for(size_t i = 0; i < size; i++) data[i] *= 0.1;
+ // for(size_t i = 0; i < size; i++) data[i] *= 0.1;
sf_close(fh);
}
diff --git a/src/jackclient.cc b/src/jackclient.cc
index 1f91e6c..00eda52 100644
--- a/src/jackclient.cc
+++ b/src/jackclient.cc
@@ -128,7 +128,6 @@ int JackClient::process(jack_nframes_t nframes)
AudioFiles::iterator ai = sample->audiofiles.begin();
while(ai != sample->audiofiles.end()) {
- printf("!\n");
AudioFile *audiofile = ai->second;
audiofile->load();
@@ -171,12 +170,12 @@ int JackClient::process(jack_nframes_t nframes)
jack_default_audio_sample_t *buffer;
buffer = (jack_default_audio_sample_t *)jack_port_get_buffer(event.port, nframes);
- size_t size = (event.sample->size - event.duration) < nframes ?
- (event.sample->size - event.duration) - event.time : nframes - event.time;
+ size_t dtime = nframes - event.time; // how much buffer is left?
+ size_t size = event.sample->size - event.duration; // how much audio is left?
+ if(size > dtime) size = dtime;
for(size_t j = event.time; j < event.time + size; j++) {
- //memcpy(buffer + event.time, event.sample->data + event.duration, size);
- buffer[j] += event.sample->data[event.duration + j];
+ buffer[j] += event.sample->data[event.duration + j - event.time];
}
if(event.duration + size < event.sample->size) {
diff --git a/src/midimapper.cc b/src/midimapper.cc
index 727074b..10e038f 100644
--- a/src/midimapper.cc
+++ b/src/midimapper.cc
@@ -71,7 +71,7 @@ Sample *MidiMapper::map(jack_midi_event_t event)
int velocity = event.buffer[2];
if(velocity == 0) return NULL;
-
+ /*
// Parse midi event
printf("[ Time: %d Size: %d ", event.time, event.size);
for(size_t j = 0; j < event.size; j++) {
@@ -79,7 +79,7 @@ Sample *MidiMapper::map(jack_midi_event_t event)
printf(" Data: %d ", m);
}
printf("]\n");
-
+ */
if(drumkit->instruments.find(key) == drumkit->instruments.end()) return NULL;
Velocity *v = drumkit->instruments[key]->getVelocity(velocity);