Skip to content

Commit

Permalink
fix [sfload] when file has more channels than arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
porres committed Feb 4, 2025
1 parent 2505c7a commit de9d393
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Source/Control/sfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,33 @@ void* sfload_read_audio_threaded(void *arg){ // read audio into array
}

void sfload_update_arrays(t_sfload* x){
// post("x_channel = %d / x->x_num_channels = %d", x->x_channel, x->x_num_channels);
for(int ch = 0; ch < x->x_num_channels; ch++){
// post("ch = %d", ch);
if(x->x_channel != -1 && ch != x->x_channel)
continue;
// post("continue");
char channel_name[MAXPDSTRING];
snprintf(channel_name, MAXPDSTRING, "%i-%s", ch, x->x_arr_name->s_name);
t_garray* garray = (t_garray*)pd_findbyclass(gensym(channel_name), garray_class);
if(garray){
// post("if(garray)");
garray_resize_long(garray, x->x_nsamps);
t_word* vec = ((t_word*)garray_vec(garray));
for(int i = 0; i < x->x_nsamps; i++)
vec[i].w_float = x->x_all_out[ch][i];
garray_redraw(garray);
}
else{
// post("else");
garray = (t_garray*)pd_findbyclass(x->x_arr_name, garray_class);
garray_resize_long(garray, x->x_nsamps);
t_word* vec = ((t_word*)garray_vec(garray));
for(int i = 0; i < x->x_nsamps; i++)
vec[i].w_float = x->x_all_out[ch][i];
garray_redraw(garray);
if(garray){
garray_resize_long(garray, x->x_nsamps);
t_word* vec = ((t_word*)garray_vec(garray));
for(int i = 0; i < x->x_nsamps; i++)
vec[i].w_float = x->x_all_out[ch][i];
garray_redraw(garray);
}
}
}
}
Expand Down

0 comments on commit de9d393

Please sign in to comment.