Skip to content

Commit

Permalink
problem idenfitied: ring buffer takes char as input data type
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Feb 29, 2024
1 parent c30fbca commit a3c9115
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions app/src/main/cpp/FileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ void FileWriter::openFile () {
sf_strerror(NULL));
} else {
LOGD("[%s] Opened file %s", __PRETTY_FUNCTION__, filename.c_str());
sf_command (soundfile, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
}
}

Expand Down Expand Up @@ -322,7 +323,7 @@ void FileWriter::setBufferSize (int bufferSize) {
IN
block_size = bufferSize ;
buffer_size_in_bytes = ALIGN_UP_DOUBLE(sizeof(buffer_t) + block_size*num_channels*sizeof(float ));
buffer_size_in_bytes = buffer_size_in_bytes * 4 ;
// buffer_size_in_bytes = buffer_size_in_bytes * 4 ;

LOGD("setting buffer size: %d from block size: %d", buffer_size_in_bytes, block_size);

Expand Down Expand Up @@ -470,26 +471,27 @@ int FileWriter::process(int nframes, const float *arg) {
// bg_buffer->data = (float *) arg;

// LOGD("frames: %d", nframes);
if (bg_buffer->pos >= buffer_size_in_bytes - 1)
bg_buffer->pos = 0 ;
// if (bg_buffer->pos >= buffer_size_in_bytes - 1)
// bg_buffer->pos = 0 ;

for (int i = 0 ; i < nframes ; i ++) {
if (i >= block_size) {
HERE LOGF("more samples than we can handle! [%d]", nframes) ;
break ;
}

if (arg [i] < -10.0)
bg_buffer->data[bg_buffer->pos] = -10.0 ;
else if (arg [i] > 10.0)
bg_buffer->data[bg_buffer->pos] = 10.0 ;
else
bg_buffer->data[bg_buffer->pos] = arg [i] ;
// if (arg [i] < -1.0)
// bg_buffer->data[bg_buffer->pos] = -.95 ;
// else if (arg [i] > 1.0)
// bg_buffer->data[bg_buffer->pos] = .95 ;
// else
// LOGD("%f", arg [i]);
bg_buffer->data[i] = arg [i] ;

bg_buffer->pos ++ ;
// bg_buffer->pos ++ ;
}

// bg_buffer->pos = nframes;
bg_buffer->pos = nframes;
// bg_buffer->pos = nframes;
// current_buffer->data = (float *) arg;
// current_buffer->pos = nframes;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/cpp/vringbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void *vringbuffer_get_writing(vringbuffer_t *vrb) {
}

void vringbuffer_return_writing(vringbuffer_t *vrb, void *data) {
jack_ringbuffer_write(vrb->for_reader, (char *) &data, sizeof(void *));
jack_ringbuffer_write(vrb->for_reader, (float *) &data, sizeof(void *));
upwaker_wake_up(vrb->receiver_trigger);
}

Expand Down

0 comments on commit a3c9115

Please sign in to comment.