예제 #1
0
파일: SndObj.cpp 프로젝트: johnglover/simpl
SndObj::SndObj(SndObj* input, int vecsize, double sr){
  m_output = NULL;
  SetVectorSize(vecsize);
  m_input = input;
  m_sr = sr;
  m_error = 0;
  for(m_vecpos = 0; m_vecpos < m_vecsize; m_vecpos++) m_output[m_vecpos]= 0.f;

  m_msgtable = new msg_link;
  m_msgtable->previous = 0;
  AddMsg("SR", 1);
  AddMsg("vector size", 2);
  AddMsg("input", 3);
  Enable();
}
예제 #2
0
파일: SndObj.cpp 프로젝트: johnglover/simpl
SndObj::SndObj(){
  m_output = NULL;
  SetVectorSize(DEF_VECSIZE);
  m_input = 0;
  m_sr = DEF_SR;
  m_error =0;
  for(m_vecpos = 0; m_vecpos < m_vecsize; m_vecpos++)
    m_output[m_vecpos]= 0.f;
  m_msgtable = new msg_link;
  m_msgtable->previous = 0;
  AddMsg("SR", 1);
  AddMsg("vector size", 2);
  AddMsg("input", 3);
  Enable();
}
예제 #3
0
파일: SndObj.cpp 프로젝트: johnglover/simpl
SndObj::SndObj(SndObj& obj){
  m_output = NULL;
  SetVectorSize(obj.GetVectorSize());
  SetSr(obj.GetSr());

  for(int n=0; n<m_vecsize;n++)m_output[n]=obj.Output(n);
  m_input = obj.GetInput();
  m_error =0;

  m_msgtable = new msg_link;
  m_msgtable->previous = 0;
  AddMsg("SR", 1);
  AddMsg("vector size", 2);
  AddMsg("input", 3);
  Enable();
}
예제 #4
0
파일: SndObj.cpp 프로젝트: johnglover/simpl
int
SndObj::Set(const char* mess, double value){

  switch (FindMsg(mess)){

  case 1:
    SetSr(value);
    return 1;

  case 2:
    SetVectorSize((int) value);
    return 1;

  default:
    return 0;

  }
}
예제 #5
0
short Synth::DoProcess(){
	long diffdur = 0;
	if(!m_error){
		if(m_ObjNo){
			SndObjList* temp; 
			if(m_enable){ 
				temp = m_InObj;
				if( GetDuration() < 0) {
					while(temp){ 
						(temp->obj)->DoProcess();
						temp = temp->next;					
					}
				} else {
					diffdur = GetDuration() - m_CurrentDur;
					if(diffdur > m_vecsize) {
						while(temp){ 
							(temp->obj)->DoProcess();
							temp = temp->next;
							
						}
						m_CurrentDur += m_vecsize;
					} else {
						SetVectorSize(diffdur);
						while(temp){ 
							(temp->obj)->DoProcess();
							temp = temp->next;
						}	
						Free();
					}
		
				}
				
			}
			return 1;
		}
		else {
			m_error = 11;
			return 0;
		}
	}
	else return 0;
}
예제 #6
0
파일: FFT.cpp 프로젝트: johnglover/simpl
FFT::FFT(){
  m_table = 0;

  // hopsize controls decimation
  // we have vecsize/hopsize overlapping frames
  // the vector size is also equal the fftsize
  // so that each call to DoProcess produces a
  // new fft frame at the output
  // since SndObj has already allocated the output
  // we have to reset the vector size

  m_fftsize = DEF_FFTSIZE;
  SetVectorSize(DEF_FFTSIZE);
  m_hopsize = DEF_VECSIZE;

  m_frames = m_fftsize/m_hopsize;

  m_sigframe = new double*[m_frames];
  m_counter = new int[m_frames];
  m_halfsize = m_fftsize/2;
  m_fund = m_sr/m_fftsize;
  int i;
  for(i = 0; i < m_frames; i++){
    m_sigframe[i] = new double[m_fftsize];
    memset(m_sigframe[i], 0, m_fftsize*sizeof(double));
    m_counter[i] = i*m_hopsize;
  }

  m_fftIn = (double*) fftw_malloc(sizeof(double) * m_fftsize);
  m_fftOut = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * m_fftsize);
  m_plan = fftw_plan_dft_r2c_1d(m_fftsize, m_fftIn, m_fftOut, FFTW_ESTIMATE);
  memset(m_fftIn, 0, m_fftsize*sizeof(double));


  AddMsg("scale", 21);
  AddMsg("fft size", 22);
  AddMsg("hop size", 23);
  AddMsg("window", 24);
  m_scale = 1.f;
  m_norm = m_fftsize;
  m_cur =0;
}
예제 #7
0
SpecMult::SpecMult(){
  SetVectorSize(DEF_FFTSIZE);
  m_input2 = 0;
  AddMsg("input 2", 21);
  AddMsg("table", 22);
}
예제 #8
0
SndSinIO::SndSinIO(char* name, int maxtracks, float threshold, int windowtype, short mode, 
		   short channels, int channelmask, short bits, int format,
		   SndObj** inputlist, float framepos, int hopsize, 
		   int fftsize, float sr):
  SndWaveX(name,mode,channels,channelmask, bits, format,
	   inputlist,framepos, maxtracks*3, sr)
{
	
  short cbsize;
  m_len = 64;
  m_format = WAVE_FORMAT_EXTENSIBLE;
  m_hdrsize = 84;
	
  if(mode != READ){ // if output
		
    int mask;
    short sbits;      
		
    m_hopsize = hopsize;
    SetVectorSize(maxtracks*3);
    GUID subfmt;
    cbsize = SHORT_LE((short)46);
    PutHeader(0,m_hdrsize,m_len, m_format);
    sbits = SHORT_LE((short)m_bits);
    mask = LONG_LE((long) (m_ChannelMask = channelmask));
    subfmt.Data1 = LONG_LE(0x443a4b58);
    subfmt.Data2 = SHORT_LE(0x21a2);
    subfmt.Data2 = SHORT_LE(0x324b); 
    subfmt.Data4[0] = 0x00;
    subfmt.Data4[1] =0x00;
    subfmt.Data4[2] = 0x00;
    subfmt.Data4[3] = 0x01;
    subfmt.Data4[4] = 0xAA;
    subfmt.Data4[5] = 0x02;
    subfmt.Data4[6] = 0xBB;
    subfmt.Data4[7] = 0x03;
    m_SubFormat = subfmt;
		
    m_sinheader.dwVersion =  LONG_LE(1);
    m_sinheader.data.wWordFormat =  SHORT_LE((short)(m_bits != 64 ? IEEE_FLOAT_T : IEEE_DOUBLE_T));  
    m_sinheader.data.wWindowType =  SHORT_LE((short)windowtype); 
    m_sinheader.data.dwWindowSize =  LONG_LE((long)fftsize);
    m_sinheader.data.wMaxtracks =SHORT_LE((short) maxtracks);
    m_sinheader.data.wHopsize =  LONG_LE((long)m_hopsize);
    m_sinheader.data.fAnalysisRate = FLOAT32_LE(m_sr/m_hopsize);
    m_sinheader.data.fThreshold = FLOAT32_LE(threshold);
		
    if(mode != APPEND){
      fseek(m_file, sizeof(wave_head), SEEK_SET);
      fwrite(&cbsize, sizeof(short), 1, m_file);
      fwrite(&sbits, sizeof(short), 1, m_file);
      fwrite(&mask, sizeof(int), 1, m_file);
      fwrite(&subfmt, sizeof(GUID), 1, m_file);
      fwrite(&m_sinheader, sizeof(sinusex), 1, m_file);  
      m_wchkpos = ftell(m_file);
      fwrite(&m_wdata, sizeof(wave_data), 1, m_file);
      m_datapos = ftell(m_file);
			
    } else m_wchkpos = sizeof(wave_head) + 22 + sizeof(sinusex) + 2;
		
  } // output
	
  else { // if INPUT
    m_tracks = new int[m_channels];
    m_trkindx = new int*[m_channels];
		
		
    fseek(m_file, sizeof(wave_head)+2+22, SEEK_SET); 	  
    fread(&m_sinheader, sizeof(sinusex),1, m_file);
		
    if(GUIDcheck(KSDATAFORMAT_SUBTYPE_SINUS)){ // check for GUID
      m_sinheader.dwVersion =  LONG_LE(m_sinheader.dwVersion );
      m_sinheader.data.wWordFormat =  SHORT_LE(m_sinheader.data.wWordFormat );
      m_sinheader.data.wHopsize =  SHORT_LE(m_sinheader.data.wHopsize );
      m_sinheader.data.wWindowType =  SHORT_LE(m_sinheader.data.wWindowType );
      m_sinheader.data.wMaxtracks =  SHORT_LE(m_sinheader.data.wMaxtracks);
      m_sinheader.data.dwWindowSize =  LONG_LE(m_sinheader.data.dwWindowSize );
      m_sinheader.data.fThreshold = FLOAT32_LE(m_sinheader.data.fThreshold);
			
    }
    fseek(m_file, m_datapos, SEEK_SET);
    if(framepos > 0) SetTimePos(framepos);    
    m_maxtracks = m_sinheader.data.wMaxtracks; 
    for(int i = 0; i < m_channels; i++) m_trkindx[i] = new int[m_maxtracks];
  }   // INPUT
}
예제 #9
0
파일: FFT.cpp 프로젝트: johnglover/simpl
void
FFT::SetFFTSize(int fftsize){
  SetVectorSize(m_fftsize = fftsize);
  ReInit();
}