예제 #1
0
  void insertData(float **outdata,int frames,int num_channels){
    if(frames+jp_playpos <= getSourceLength()){
      for(int ch=0;ch<num_channels;ch++){
	memcpy(outdata[ch],getSourceData(ch,jp_playpos,frames),sizeof(float)*frames);
      }
    }else{
      int len = getSourceLength() - jp_playpos;
      for(int ch=0;ch<num_channels;ch++){
	memcpy(outdata[ch],getSourceData(ch,jp_playpos,len),sizeof(float)*len);
	zeromem(outdata[ch]+len,sizeof(float)*(frames-len));
      }
    }
    jp_playpos+=frames;
    if(jp_playpos>=getSourceLength()){
      if(prefs_loop==true){
	jp_playpos=0;
      }else{
	isreadingdata=false;
      }
    }
  }
예제 #2
0
  void insertDataResample(float **outdata,int frames,int num_channels){
    static float nulldata[512]={0.0f};
    int last_consumed=0;
    double ratio=samplerate/getSourceRate();
    for(int ch=0;ch<num_channels;ch++){
      SRC_DATA src_data={
	mustrunonemore==true?nulldata:getSourceData(ch,jp_playpos,1024), outdata[ch],
	mustrunonemore==true?512:JP_MIN((long)(64+1.2*frames/ratio),getSourceLength()-jp_playpos), frames,
	0,0,
	0,
	ratio
      };
      src_process(src_states[ch],&src_data);

      // This check is probably not necessarry.
      if(ch>0 && last_consumed!=src_data.input_frames_used)
	fprintf(stderr,"Serious error in playback.\n");
      last_consumed=src_data.input_frames_used;

      if(ch==num_channels-1){
	if(mustrunonemore==true){
	  if(last_consumed>0){
	    mustrunonemore=false;
	    if(prefs_loop==true){
	      jp_playpos=0;
	    }else{
	      isreadingdata=false;
	    }
	  }
	}else{
	  jp_playpos+=src_data.input_frames_used;
	  if(jp_playpos>=getSourceLength())
	    mustrunonemore=true;
	}
	//printf("running_more: %d, consumed: %d %f %d\n",mustrunonemore,last_consumed,rate,(int)(frames/rate));
      }
    }
  }
예제 #3
0
void MyDeformObject::saveSourceData()
{
    getSourceData();
    QString out_file("/home/fox/Downloads/source_data_" + QDateTime::currentDateTime().toString() + ".png");
    saveSourceImage(p_source_intensy, out_file);
}