Пример #1
0
static void *create_plugin_data(const SoundPluginType *plugin_type, SoundPlugin *plugin, hash_t *state, float sample_rate, int block_size){
  Data *data = (Data*)V_calloc(1,sizeof(Data));

  data->resampler_type = RESAMPLER_SINC1;

  for(int i=0;i<POLYPHONY;i++){
    Voice *voice = &data->voices[i];
    voice->resampler = RESAMPLER_create(RT_src_callback, 1, voice, data->resampler_type);
    RT_add_voice(&data->voices_not_playing, voice);
  }

  return data;
}
Пример #2
0
static bool load_sample(Data *data, const wchar_t *filename, int instrument_number){
  if(load_xi_instrument(data,filename)==false)
    if(load_sample_with_libsndfile(data,filename)==false)
      if(load_sf2_instrument(data,filename,instrument_number)==false)
        return false;
  
  //data->num_channels = data->samples[0].num_channels; // All samples must contain the same number of channels.

  generate_peaks(data);

  int i=0;
  for(i=0;i<POLYPHONY;i++){
    Voice *voice = &data->voices[i];

    voice->resampler = RESAMPLER_create(RT_src_callback, 1, voice, data->resampler_type);
    voice->adsr = ADSR_create(data->samplerate);

    RT_add_voice(&data->voices_not_playing, voice);
  }

  return true;
}
Пример #3
0
int main(int argc, char **argv){
  
  _mm_setcsr(_mm_getcsr() | 0x8040);

  int num_frames = atoi(argv[1]); // If we hardcode the value, the compiler is likely to optimize things which it wouldn't have done normally
  //fprintf(stderr, "num_frames: %d\n",num_frames);
  
  float *data = (float*)malloc(sizeof(float)*num_frames);
 
  for(int i=0;i<num_frames;i++){
    data[i] = (float)i / (float)num_frames; // Insert some some legal values.
  }

  void *resampler = RESAMPLER_create(src_callback, 1, NULL, RESAMPLER_CUBIC);

  int top = 1024*1024*8 * 64 / num_frames;
  
  for(int i=0 ; i < top ; i ++)
    RESAMPLER_read(resampler, scale(i,0,top,0.1,8.0), num_frames, data);
  
  //printf("hello\n");
  return 0;
}