Changeset 34

Show
Ignore:
Timestamp:
05/09/07 22:49:56 (2 years ago)
Author:
gordonjcp
Message:

uses sinetable, works but doesn't save much

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nekostring/trunk/src/neko_ensemble.c

    r33 r34  
    2121{ 
    2222  unsigned long sample; 
    23  
    2423  unsigned long sample_rate = synth->sample_rate; 
    25  
    2624  unsigned long buffer_pos = synth->buffer_pos; 
    2725 
    2826  float delay_1, delay_2, delay_3; 
    29   //float xomega = 6.2831852f * (0.5 / (float)sample_rate); 
    30   //float yomega = 6.2831852f * (5.75 / (float)sample_rate); 
    31   float xomega = 1024 * (0.5 / (float)sample_rate); 
    32   float yomega = 1024 * (5.75 / (float)sample_rate); 
     27 
     28//  float xomega = 6.2831852f * (0.5 / (float)sample_rate); 
     29//  float yomega = 6.2831852f * (5.75 / (float)sample_rate); 
     30 
     31  float xomega = 1024.0f * (0.5 / (float)sample_rate); 
     32  float yomega = 1024.0f * (5.75 / (float)sample_rate); 
    3333 
    3434  float dr =  0.5* 0.002 * (float)sample_rate * 0.5f;   // FIXME - identify this bit 
    35           float x1 = synth->ens_x1; 
     35 
     36  float x1 = synth->ens_x1; 
    3637  float y1 = synth->ens_y1; 
    37          
    38        float depth1=3; 
    39        float depth2=1.85; 
    40        float mix=0.75; 
     38 
     39  float depth1=3; 
     40  float depth2=1.85; 
     41  float mix=0.75; 
    4142  float s1, s2;                 // samples from the buffer 
    4243 
    4344  float s_mix_1; //, s_mix_2, s_mix_3;                  // mix for antialiasing 
    44        float so1,so2,so3; 
    45        float d1,d2; 
     45  float so1,so2,so3; 
     46  float d1,d2; 
    4647 
    47         // we don't need to do it this way 
    48         // it would be better if the lfo went up to 1024 
    49         //float mult = NUM_POINTS/6.28; 
     48  //float mult = WAVE_POINTS/6.28; 
    5049 
    51 //printf("%f %f %f %f\n",x1,y1,xomega,yomega); 
     50//printf("%d %d %d %d\n",x1,y1,xomega,yomega); 
    5251  for (sample = 0; sample < sample_count; sample++) 
    5352    { 
     
    5756      synth->ens_buffer[buffer_pos] = left[sample]; 
    5857 
    59 // calculate the delay in samples 
    60 // I have no idea what I did here originally 
    61 // "select on test" is the order of the day 
    62  
    63  
    64           // urgh.  Let's make a start 
    6558          // we have two LFOs, a fast one for the vibrato and a slow one for the chorus 
    6659          // we need to create three delays, each modulated by the LFOs but offset by 120 degrees 
    67            
     60 
    6861          //d1=200+20*sin(x1)+1.0f; d2=sin(y1)+1.0f; 
    69           d1=200+20*sine_wave[(int)x1]+1.0f; d2=sine_wave[(int)y1]+1.0f; 
     62          d1 = 200 + 20*sine_wave[(int)(x1)]+1.0f; d2 = 0.5*sine_wave[(int)(y1)] + 1.0f; 
     63          //d1=200; d2=1; 
     64          //printf("%f %f\n",d1,x1); 
     65          //printf("%f %f\n",d1,sine_wave[(int)(x1)]); 
    7066          delay_1 = 1100 + (d1*depth1+d2*depth2 * dr); 
    7167          //d1=200+20*sin(x1+2.1)+1.0f; d2=0.5*sin(y1+2.1)+1.0f; 
    72           d1=200+20*sine_wave[(int)(x1+341) % 1024]+1.0f; d2=0.5*sine_wave[(int)(y1+341) % 1024]+1.0f; 
     68          d1 = 200 + 20*sine_wave[(int)(x1+341)%1024]+1.0f; d2 = 0.5*sine_wave[(int)(y1+341)%1024] + 1.0f; 
    7369          delay_2 = 1000 + (d1*depth1+d2*depth2 * dr); 
    7470          //d1=200+20*sin(x1+4.2)+1.0f; d2=0.5*sin(y1+4.2)+1.0f; 
    75           d1=200+20*sine_wave[(int)(x1+682) % 1024]+1.0f; d2=0.5*sine_wave[(int)(y1+682) % 1024]+1.0f; 
     71          d1 = 200 + 20*sine_wave[(int)(x1+682)%1024]+1.0f; d2 = 0.5*sine_wave[(int)(y1+682)%1024] + 1.0f; 
    7672          delay_3 = 1200 + (d1*depth1+d2*depth2 * dr); 
    7773 
     
    8379    s_mix_1 = delay_1 - (int) delay_1; 
    8480        so1=(1-s_mix_1)*s1+s_mix_1*s2; 
     81 
    8582        s1 = synth->ens_buffer[(buffer_pos - (int) delay_2) & BUF_MASK]; 
    8683    s2 = synth->ens_buffer[((buffer_pos - (int) delay_2) - 1) & BUF_MASK]; 
    8784    s_mix_1 = delay_2 - (int) delay_2; 
    8885        so2=(1-s_mix_1)*s1+s_mix_1*s2; 
     86 
    8987        s1 = synth->ens_buffer[(buffer_pos - (int) delay_3) & BUF_MASK]; 
    9088    s2 = synth->ens_buffer[((buffer_pos - (int) delay_3) - 1) & BUF_MASK]; 
    9189    s_mix_1 = delay_3 - (int) delay_3; 
    9290        so3=(1-s_mix_1)*s1+s_mix_1*s2; 
     91 
    9392// mix is the wet/dry proportion 
    9493        right[sample] = (left[sample] * (1 - mix)) + ((so1+so2)/2 * mix); 
  • nekostring/trunk/src/neko_synth.h

    r33 r34  
    3434#define WAVE_POINTS 1024          /* must be a power of two */ 
    3535 
    36 static float sine_wave[], 
    37              triangle_wave[]; 
     36//float sine_wave[], triangle_wave[]; 
     37 
     38float sine_wave[4 + WAVE_POINTS + 1], triangle_wave[4 + WAVE_POINTS + 1]; 
    3839 
    3940/* 
  • nekostring/trunk/src/neko_voice_render.c

    r33 r34  
    3232 
    3333 
    34 static float sine_wave[4 + WAVE_POINTS + 1], 
    35              triangle_wave[4 + WAVE_POINTS + 1]; 
     34//static float sine_wave[4 + WAVE_POINTS + 1], triangle_wave[4 + WAVE_POINTS + 1]; 
    3635 
    3736#define pitch_ref_note 69 
     
    5857    /* oscillator waveforms */ 
    5958    for (i = 0; i <= WAVE_POINTS; ++i) { 
    60         sine_wave[i] = sinf(M_2PI_F * (float)i / (float)WAVE_POINTS) * 0.5f; 
    61     } 
    62     sine_wave[-1 + 4] = sine_wave[WAVE_POINTS - 1 + 4];  /* guard points both ends */ 
     59        sine_wave[i] = sinf(M_2PI_F * (float)i / (float)WAVE_POINTS); //* 0.5f; 
     60    } 
     61    //sine_wave[-1 + 4] = sine_wave[WAVE_POINTS - 1 + 4];  /* guard points both ends */ 
    6362 
    6463    qn = WAVE_POINTS / 4;