Permalink
Browse files

works more again

  • Loading branch information...
1 parent b8fa856 commit e46d78368d9036def095b0f6acde0a669f101c43 @yaxu yaxu committed Feb 18, 2012
Showing with 17 additions and 16 deletions.
  1. +1 −1 audio.c
  2. +12 −10 file.c
  3. +1 −1 file.h
  4. +3 −4 segment.c
View
@@ -204,7 +204,7 @@ inline void playback(float **buffers, int frame, jack_nframes_t frametime) {
for (channel = 0; channel < channels; ++channel) {
/* todo tween */
buffers[channel][frame] +=
- p->sound->sample->frames[(channels * ((int) p->position)) + channel];
+ p->sound->sample->items[(channels * ((int) p->position)) + channel];
}
p->position += p->speed;
View
22 file.c
@@ -45,17 +45,19 @@ void fix_samplerate (t_sample *sample) {
max_output_frames = sample->info->frames * data.src_ratio + 32;
- data.data_in = sample->frames;
- data.input_frames = sample->info->frames / channels;
+ data.data_in = sample->items;
+ data.input_frames = sample->info->frames;
data.data_out = (float *) calloc(1, sizeof(float)
* max_output_frames
+ * channels
);
data.output_frames = max_output_frames;
src_simple(&data, SRC_SINC_BEST_QUALITY, channels);
- sample->frames = data.data_out;
+ /* TODO - free old items */
+ sample->items = data.data_out;
sample->info->samplerate = samplerate;
sample->info->frames = data.output_frames_gen;
@@ -67,7 +69,7 @@ extern t_sample *file_get(char *samplename) {
char error[62];
t_sample *sample;
sf_count_t count;
- float *frames;
+ float *items;
SF_INFO *info;
char set[MAXPATHSIZE];
int set_n = 0;
@@ -103,25 +105,25 @@ extern t_sample *file_get(char *samplename) {
free(info);
}
else {
- frames = (float *) calloc(1, sizeof(float) * info->frames);
+ items = (float *) calloc(1, sizeof(float) * info->frames * info->channels);
/*snprintf(error, (size_t) 61, "hm: %d\n", sf_error(sndfile));
perror(error);*/
- count = sf_read_float(sndfile, frames, info->frames);
+ count = sf_read_float(sndfile, items, info->frames * info->channels);
/* snprintf(error, (size_t) 61, "hmm: %d vs %d %d\n", (int) count, (int) info->frames, sf_error(sndfile));
perror(error);*/
- if (count == info->frames) {
+ if (count == info->frames * info->channels) {
sample = (t_sample *) calloc(1, sizeof(t_sample));
strncpy(sample->name, samplename, MAXPATHSIZE - 1);
sample->info = info;
- sample->frames = frames;
+ sample->items = items;
samples[sample_count++] = sample;
}
else {
- snprintf(error, (size_t) 61, "didn't get the right number of frames: %d vs %d %d\n", (int) count, (int) info->frames, sf_error(sndfile));
+ snprintf(error, (size_t) 61, "didn't get the right number of items: %d vs %d %d\n", (int) count, (int) info->frames * info->channels, sf_error(sndfile));
perror(error);
free(info);
- free(frames);
+ free(items);
}
}
if (sample == NULL) {
View
2 file.h
@@ -9,7 +9,7 @@
typedef struct {
char name[MAXPATHSIZE];
SF_INFO *info;
- float *frames;
+ float *items;
int *onsets;
} t_sample;
View
@@ -49,16 +49,15 @@ int *aubio_process(t_sample *sound, float *input, sf_count_t nframes) {
unsigned int j, i; /*frames*/
int *result;
- int actual_frames = nframes / channels;
- for (j=0; j < actual_frames; j++) {
+ for (j=0; j < nframes; j++) {
for (i=0; i < channels; i++) {
/* write input to datanew */
fvec_write_sample(ibuf, input[channels*j+i], i, pos);
}
}
- for (j=0; j < actual_frames; j++) {
+ for (j=0; j < nframes; j++) {
/*time for fft*/
if ((pos % (overlap_size-1)) == 0) {
int isonset;
@@ -96,7 +95,7 @@ int *aubio_process(t_sample *sound, float *input, sf_count_t nframes) {
extern int *segment_get_onsets(t_sample *sound) {
int *result;
aubio_init(sound->info->channels);
- result = aubio_process(sound, sound->frames, sound->info->frames);
+ result = aubio_process(sound, sound->items, sound->info->frames);
aubio_destruct();
return(result);
}

0 comments on commit e46d783

Please sign in to comment.