Changeset 34
- Timestamp:
- 05/09/07 22:49:56 (2 years ago)
- Files:
-
- nekostring/trunk/src/neko_ensemble.c (modified) (3 diffs)
- nekostring/trunk/src/neko_synth.h (modified) (1 diff)
- nekostring/trunk/src/neko_voice_render.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nekostring/trunk/src/neko_ensemble.c
r33 r34 21 21 { 22 22 unsigned long sample; 23 24 23 unsigned long sample_rate = synth->sample_rate; 25 26 24 unsigned long buffer_pos = synth->buffer_pos; 27 25 28 26 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); 33 33 34 34 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; 36 37 float y1 = synth->ens_y1; 37 38 39 40 38 39 float depth1=3; 40 float depth2=1.85; 41 float mix=0.75; 41 42 float s1, s2; // samples from the buffer 42 43 43 44 float s_mix_1; //, s_mix_2, s_mix_3; // mix for antialiasing 44 45 45 float so1,so2,so3; 46 float d1,d2; 46 47 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; 50 49 51 //printf("% f %f %f %f\n",x1,y1,xomega,yomega);50 //printf("%d %d %d %d\n",x1,y1,xomega,yomega); 52 51 for (sample = 0; sample < sample_count; sample++) 53 52 { … … 57 56 synth->ens_buffer[buffer_pos] = left[sample]; 58 57 59 // calculate the delay in samples60 // I have no idea what I did here originally61 // "select on test" is the order of the day62 63 64 // urgh. Let's make a start65 58 // we have two LFOs, a fast one for the vibrato and a slow one for the chorus 66 59 // we need to create three delays, each modulated by the LFOs but offset by 120 degrees 67 60 68 61 //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)]); 70 66 delay_1 = 1100 + (d1*depth1+d2*depth2 * dr); 71 67 //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; 73 69 delay_2 = 1000 + (d1*depth1+d2*depth2 * dr); 74 70 //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; 76 72 delay_3 = 1200 + (d1*depth1+d2*depth2 * dr); 77 73 … … 83 79 s_mix_1 = delay_1 - (int) delay_1; 84 80 so1=(1-s_mix_1)*s1+s_mix_1*s2; 81 85 82 s1 = synth->ens_buffer[(buffer_pos - (int) delay_2) & BUF_MASK]; 86 83 s2 = synth->ens_buffer[((buffer_pos - (int) delay_2) - 1) & BUF_MASK]; 87 84 s_mix_1 = delay_2 - (int) delay_2; 88 85 so2=(1-s_mix_1)*s1+s_mix_1*s2; 86 89 87 s1 = synth->ens_buffer[(buffer_pos - (int) delay_3) & BUF_MASK]; 90 88 s2 = synth->ens_buffer[((buffer_pos - (int) delay_3) - 1) & BUF_MASK]; 91 89 s_mix_1 = delay_3 - (int) delay_3; 92 90 so3=(1-s_mix_1)*s1+s_mix_1*s2; 91 93 92 // mix is the wet/dry proportion 94 93 right[sample] = (left[sample] * (1 - mix)) + ((so1+so2)/2 * mix); nekostring/trunk/src/neko_synth.h
r33 r34 34 34 #define WAVE_POINTS 1024 /* must be a power of two */ 35 35 36 static float sine_wave[], 37 triangle_wave[]; 36 //float sine_wave[], triangle_wave[]; 37 38 float sine_wave[4 + WAVE_POINTS + 1], triangle_wave[4 + WAVE_POINTS + 1]; 38 39 39 40 /* nekostring/trunk/src/neko_voice_render.c
r33 r34 32 32 33 33 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]; 36 35 37 36 #define pitch_ref_note 69 … … 58 57 /* oscillator waveforms */ 59 58 for (i = 0; i <= WAVE_POINTS; ++i) { 60 sine_wave[i] = sinf(M_2PI_F * (float)i / (float)WAVE_POINTS) 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 */ 63 62 64 63 qn = WAVE_POINTS / 4;