summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/main.c b/main.c
index 43bf52b..eb83b58 100644
--- a/main.c
+++ b/main.c
@@ -116,7 +116,7 @@ static inline Pulse
synthesize_wave(float theta)
{
- /* return -1.0f + fmod(theta, 2*M_PI)/M_PI; */
+ /* return -1.0 + fmod(theta, 2*M_PI)/M_PI; */
/* return sin(theta); */
@@ -124,17 +124,17 @@ synthesize_wave(float theta)
/* return pow(theta/2*M_PI, 2); */
- /* return sin(theta)+0.442f*sin(2.0f*theta)+0.315f*sin(3.0f*theta)
- * +0.083f*sin(4.0f*theta)+cos(theta)+0.442f*cos(2.0f*theta); */
+ /* return sin(theta)+0.442*sin(2.0*theta)+0.315*sin(3.0*theta)
+ * +0.083*sin(4.0*theta)+cos(theta)+0.442*cos(2.0*theta); */
/* piano like */
- /* return sin(theta)+1.869*sin(2.0f*theta)+0.042f*sin(3.0f*theta)
- * +0.022f*sin(4.0f*theta)+cos(theta); */
+ /* return sin(theta)+1.869*sin(2.0*theta)+0.042*sin(3.0*theta)
+ * +0.022*sin(4.0*theta)+cos(theta); */
/* excellent piano like */
- return ((0.65f*sin(theta)+0.5f*sin(2.0f*theta))*exp(-0.004f*theta));
+ return ((0.65*sin(theta)+0.5*sin(2.0*theta))*exp(-0.004*theta));
}
@@ -144,7 +144,7 @@ synthesize_wave(float theta)
* oscillator(Volume v, Hertz h, Seconds s, Instrument *ins)
* {
*
- * return 0.0f;
+ * return 0.0;
* } */
UHA_ATTR
@@ -159,10 +159,10 @@ static WaveFrag
hstow(Volume v, Hertz h, Seconds s)
{
LENT sample_num = (LENT) floor(SAMPLE_RATE * s);
- float attack_step = 1.0f / (float) (sample_num * ATTACK_P);
- float decay_step = 1.0f / (float) (sample_num * DECAY_P);
- float sustain_step = 1.0f / (float) (sample_num * SUSTAIN_P);
- float release_step = 1.0f / (float) (sample_num * RELEASE_P);
+ float attack_step = 1.0 / (float) (sample_num * ATTACK_P);
+ float decay_step = 1.0 / (float) (sample_num * DECAY_P);
+ float sustain_step = 1.0 / (float) (sample_num * SUSTAIN_P);
+ float release_step = 1.0 / (float) (sample_num * RELEASE_P);
float step = (float) (h * 2 * M_PI) / SAMPLE_RATE;
@@ -172,8 +172,8 @@ hstow(Volume v, Hertz h, Seconds s)
Wave w = MYALLOC(Pulse, sizeof(*w) * sample_num);
- float adsrcounter = 0.0f, counter = 0.0f, fm_counter = 0.0f;
- float theta = 0.0f, temp = 0.0f;
+ float adsrcounter = 0.0, counter = 0.0, fm_counter = 0.0;
+ float theta = 0.0, temp = 0.0;
for (LENT i = 0; i < sample_num; i++, counter += step, fm_counter += fm_step) {
/* theta = frequency_modulation(counter, (float) h*i/((float) SAMPLE_RATE), fm_counter); */
@@ -181,30 +181,30 @@ hstow(Volume v, Hertz h, Seconds s)
temp = synthesize_wave(theta);
temp += temp*temp*temp;
temp = synthesize_wave(temp);
- temp += theta*exp(-2.0f*theta);
+ temp += theta*exp(-2.0*theta);
*(w+i) = (float) v * temp;
/* (synthesize_wave(temp)/\* +
- * * 0.01*(2.0f*(float)rand()/(float) RAND_MAX - 1.0f) *\/) *//* *
+ * * 0.01*(2.0*(float)rand()/(float) RAND_MAX - 1.0) *\/) *//* *
* ((sustain_flag) ? SUSTAIN_LEVEL : adsrcounter) ;*/
switch (phase) {
case 0: /* attack phase */
adsrcounter += attack_step;
- if (adsrcounter >= 1.0f) {
- adsrcounter = 1.0f;
+ if (adsrcounter >= 1.0) {
+ adsrcounter = 1.0;
phase++;
}
break;
case 1: /* decay phase */
adsrcounter -= decay_step;
if (adsrcounter <= SUSTAIN_LEVEL) {
- adsrcounter = 0.0f;
+ adsrcounter = 0.0;
sustain_flag = 1;
phase++;
}
break;
case 2: /* sustain phase */
adsrcounter += sustain_step;
- if (adsrcounter >= 1.0f) {
+ if (adsrcounter >= 1.0) {
adsrcounter = SUSTAIN_LEVEL;
sustain_flag = 0;
phase++;
@@ -212,7 +212,7 @@ hstow(Volume v, Hertz h, Seconds s)
break;
default: /* release phase */
adsrcounter -= release_step;
- if (adsrcounter <= 0.0f) adsrcounter = 0.0f;
+ if (adsrcounter <= 0.0) adsrcounter = 0.0;
break;
}
}
@@ -296,10 +296,10 @@ read_sb(const char *str, int str_len,
if (nth % 2) {
/* odd */
- PUSH_NODE(b_len, bp, beats, temp, f);
+ PUSH_NODE(b_len, bp, beats, temp, n);
} else {
/* even */
- PUSH_NODE(semi_len, sp, semis, temp, f);
+ PUSH_NODE(semi_len, sp, semis, temp, n);
}
}
@@ -310,15 +310,15 @@ read_sb(const char *str, int str_len,
exit(1);
}
- *len = floor(nth/2.0f);
+ *len = floor(nth/2.0);
*sts = realloc(*sts, sizeof(float) * (*len));
*bs = realloc(*bs, sizeof(float) * (*len));
for (int i = 0; i < *len; i++) {
- POP_NODE(semi_len, temp, semis, sn, f);
+ POP_NODE(semi_len, temp, semis, sn, n);
*(*sts+*len-1-i) = temp;
- POP_NODE(b_len, temp, beats, bn, f);
+ POP_NODE(b_len, temp, beats, bn, n);
*(*bs+*len-1-i) = temp;
}
}
@@ -382,7 +382,7 @@ int main(int argc, char **argv)
/* return 0; */
- /* STD_BASE = (float) pow(2, 1.0f/12.0f); */
+ /* STD_BASE = (float) pow(2, 1.0/12.0); */
UNUSED int notes_len = 0;
@@ -418,10 +418,10 @@ int main(int argc, char **argv)
#endif
/* vs = MYALLOC(Volume, notes_len);
- * for (int i = 0; i < notes_len;) *(vs+i++) = 0.3f; */
+ * for (int i = 0; i < notes_len;) *(vs+i++) = 0.3; */
/* WaveFrag wf = compose(vs, sts, bs, notes_len); */
- WaveFrag wf = play_sheet(psh, 0.3f);
+ WaveFrag wf = play_sheet(psh, 0.3);
destroy_sheet(psh);