Beispiel #1
0
void sine_1(int sec)
{
  int i,size;
  size = 44100*sec;
  Sint16 buffer [size]; //buffer array
  s1.setFreq(110);
  s2.setFreq(440);
  s3.setFreq(1760);

  printf("Generate sine 1\n");

  for(i = 0; i < size; i++)
    {
      s1.setAmplitude(127);
      s2.setAmplitude(127);
      s3.setAmplitude(64);
      buffer[i]=s1.tick()-s2.tick()-s3.tick();
      buffer[i]=s1.tick()+s2.tick();
      //      buffer[i]=s1.tick();
    }

  FILE* fd=fopen("sine2","w+");
  
  for (int i=0; i< size ; i++)
    {      
      Sint16 d=buffer[i];
      fwrite(&d,sizeof(unsigned Sint16),1,fd);
    }

  fclose(fd);
  printf("closing sine 1\n");


}
Beispiel #2
0
void
runSineOscillator_FreqCtrl_AmpAudio(LADSPA_Handle Instance,
                                    unsigned long SampleCount) {
  SineOscillator * poSineOscillator = (SineOscillator *)Instance;
  poSineOscillator->setPhaseStepFromFrequency
    (*(poSineOscillator->m_pfFrequency));
  for (unsigned long lIndex = 0; lIndex < SampleCount; lIndex++) {
    poSineOscillator->m_pfOutput[lIndex]
      = (g_pfSineTable[poSineOscillator->m_lPhase >> SINE_TABLE_SHIFT]
         * poSineOscillator->m_pfAmplitude[lIndex]);
    poSineOscillator->m_lPhase 
      += poSineOscillator->m_lPhaseStep;
  }
}
Beispiel #3
0
void 
runSineOscillator_FreqAudio_AmpAudio(LADSPA_Handle Instance,
                                     unsigned long SampleCount) {
  SineOscillator * poSineOscillator = (SineOscillator *)Instance;
  for (unsigned long lIndex = 0; lIndex < SampleCount; lIndex++) {
    /* Extract frequency at this point to guarantee inplace
       support. */
    LADSPA_Data fFrequency
      = (poSineOscillator->m_pfFrequency[lIndex]);
    poSineOscillator->m_pfOutput[lIndex]
      = (g_pfSineTable[poSineOscillator->m_lPhase >> SINE_TABLE_SHIFT]
         * poSineOscillator->m_pfAmplitude[lIndex]);
    poSineOscillator->setPhaseStepFromFrequency(fFrequency);
    poSineOscillator->m_lPhase 
      += poSineOscillator->m_lPhaseStep;
  }
}
 void trigger(){
   sine->setFrequency(freq);
   chirp->setFrequency(freq*2);
   env1->setDecay(decay);
   env2->setDecay(decay*snare*0.5);
   chirp->setDecay(decay);
   env1->trigger();
   env2->trigger();
   chirp->trigger();
   impulse->trigger();
 }
  float getNextSample(){
    float vca1 = sine->getNextSample();
    vca1 += chirp->getNextSample();
    vca1 *= env1->getNextSample();

    float vca2 = 0.0f;
    vca2 += impulse->getNextSample();
    // vca2 += filter->process(noise->getNextSample());
    // vca2 *= env2->getNextSample();
    vca2 += noise->getNextSample();
    vca2 = filter->process(vca2);
    vca2 *= env2->getNextSample();
    
    float sample = vca1*(1.0-balance) + vca2*balance;
    return sample;
  }
Beispiel #6
0
 float getNextSample(float fm){
   return env.getNextSample()*index*osc.getNextSample(fm);
 }
Beispiel #7
0
 void setFrequency(float freq){
   osc.setFrequency(freq*ratio+offset);
   // osc.setFrequency(freq);
 }