Permalink
Browse files

added fx mod (increment/decrement fx value)

example:
./bloopsawhat "16:D2[square + 0.200][volume 0.300] 16:D3[square + 0.200][volume - 0.100] 16:D4[square + 0.200][volume - 0.100] 16:D5[square + -0.200][hpf 0.800][volume + 0.500] D6[square - 0.400][hpf - 0.500][volume + -0.200] D5"
  • Loading branch information...
1 parent 9f053bc commit ebef1d05e7c9f96d5cf69eee1ac95027987702ea @localhost localhost committed Feb 27, 2009
Showing with 43 additions and 65 deletions.
  1. +30 −61 c/bloopsaphone.c
  2. +1 −0 c/bloopsaphone.h
  3. +12 −4 c/notation.rl
View
@@ -20,6 +20,16 @@
#define tempo2frames(tempo) ((float)SAMPLE_RATE / (tempo / 60.0f))
#define PI 3.14159265f
+#define FX(F, V) ({ \
+ if (F->mod == '+') V += F->val; \
+ else if (F->mod == '-') V -= F->val; \
+ else V = F->val; \
+ if (V > 1.0f) \
+ V = 1.0f; \
+ else if (V < -1.0f) \
+ V = -1.0f; \
+})
+
float
frnd(float range)
{
@@ -161,68 +171,27 @@ bloops_synth(bloops *B, int length, float* buffer)
bloopsafx *fx = (bloopsafx *)note->FX;
while (fx) {
switch (fx->cmd) {
- case BLOOPS_FX_VOLUME:
- A->P->volume = fx->val;
- break;
- case BLOOPS_FX_PUNCH:
- A->P->punch = fx->val;
- break;
- case BLOOPS_FX_ATTACK:
- A->P->attack = fx->val;
- break;
- case BLOOPS_FX_SUSTAIN:
- A->P->sustain = fx->val;
- break;
- case BLOOPS_FX_DECAY:
- A->P->decay = fx->val;
- break;
- case BLOOPS_FX_SQUARE:
- A->P->square = fx->val;
- break;
- case BLOOPS_FX_SWEEP:
- A->P->sweep = fx->val;
- break;
- case BLOOPS_FX_VIBE:
- A->P->vibe = fx->val;
- break;
- case BLOOPS_FX_VSPEED:
- A->P->vspeed = fx->val;
- break;
- case BLOOPS_FX_VDELAY:
- A->P->vibe = fx->val;
- break;
- case BLOOPS_FX_LPF:
- A->P->lpf = fx->val;
- break;
- case BLOOPS_FX_LSWEEP:
- A->P->lsweep = fx->val;
- break;
- case BLOOPS_FX_RESONANCE:
- A->P->resonance = fx->val;
- break;
- case BLOOPS_FX_HPF:
- A->P->hpf = fx->val;
- break;
- case BLOOPS_FX_HSWEEP:
- A->P->hsweep = fx->val;
- break;
- case BLOOPS_FX_ARP:
- A->P->arp = fx->val;
- break;
- case BLOOPS_FX_ASPEED:
- A->P->aspeed = fx->val;
- break;
- case BLOOPS_FX_PHASE:
- A->P->phase = fx->val;
- break;
- case BLOOPS_FX_PSWEEP:
- A->P->psweep = fx->val;
- break;
- case BLOOPS_FX_REPEAT:
- A->P->repeat = fx->val;
- break;
+ case BLOOPS_FX_VOLUME: FX(fx, A->P->volume); break;
+ case BLOOPS_FX_PUNCH: FX(fx, A->P->punch); break;
+ case BLOOPS_FX_ATTACK: FX(fx, A->P->attack); break;
+ case BLOOPS_FX_SUSTAIN: FX(fx, A->P->sustain); break;
+ case BLOOPS_FX_DECAY: FX(fx, A->P->decay); break;
+ case BLOOPS_FX_SQUARE: FX(fx, A->P->square); break;
+ case BLOOPS_FX_SWEEP: FX(fx, A->P->sweep); break;
+ case BLOOPS_FX_VIBE: FX(fx, A->P->vibe); break;
+ case BLOOPS_FX_VSPEED: FX(fx, A->P->vspeed); break;
+ case BLOOPS_FX_VDELAY: FX(fx, A->P->vdelay); break;
+ case BLOOPS_FX_LPF: FX(fx, A->P->lpf); break;
+ case BLOOPS_FX_LSWEEP: FX(fx, A->P->lsweep); break;
+ case BLOOPS_FX_RESONANCE: FX(fx, A->P->resonance); break;
+ case BLOOPS_FX_HPF: FX(fx, A->P->hpf); break;
+ case BLOOPS_FX_HSWEEP: FX(fx, A->P->hsweep); break;
+ case BLOOPS_FX_ARP: FX(fx, A->P->arp); break;
+ case BLOOPS_FX_ASPEED: FX(fx, A->P->aspeed); break;
+ case BLOOPS_FX_PHASE: FX(fx, A->P->phase); break;
+ case BLOOPS_FX_PSWEEP: FX(fx, A->P->psweep); break;
+ case BLOOPS_FX_REPEAT: FX(fx, A->P->repeat); break;
}
-
fx = (bloopsafx *)fx->next;
}
View
@@ -59,6 +59,7 @@ typedef struct {
typedef struct {
unsigned char cmd;
float val;
+ char mod;
struct bloopsafx *next;
} bloopsafx;
View
@@ -34,6 +34,8 @@
mod = 0; \
tone = 0; \
len = 4; \
+ fxval = 0; \
+ fxmod = 0; \
S->nlen++
%%{
@@ -92,6 +94,8 @@
fx->next = (struct bloopsafx *)NOTE.FX;
fx->cmd = fxcmd;
fx->val = fxval;
+ fx->mod = fxmod;
+ fxval = fxmod = 0;
NOTE.FX = (struct bloopsafx *)fx;
}
@@ -131,7 +135,8 @@
down = "-" %{ len = 1; } len?;
mod = [b#] %{ mod = p[-1]; };
oct = [1-8] %Aoct;
- fx = ("[" fxcmd (":"|space*) float "]" %Afx );
+ fxmod = ( ("+"|"-") %{ fxmod = p[-1]; } (":"|space*) )?;
+ fx = ("[" fxcmd (":"|space*) fxmod float "]" %Afx );
note = len? [a-gA-G] %{ tone = p[-1]; } mod? oct? fx* %Anote;
main := |*
@@ -153,7 +158,7 @@ bloops_track(bloops *B, bloopsaphone *P, char *track, int tracklen)
{
int cs, act, oct = 4, len = 4;
bloopsatrack *S = (bloopsatrack *)malloc(sizeof(bloopsatrack));
- char tone, mod, *p, *pe, *pf, *ts, *te, *eof = 0;
+ char tone, mod, fxmod, *p, *pe, *pf, *ts, *te, *eof = 0;
int fxcmd = 0;
float fxval = 0;
@@ -182,7 +187,7 @@ bloops_track_str(bloopsatrack *track)
{
int bufsize = sizeof(char) * (track->nlen * 6 + 1024);
char *str = (char *)malloc(bufsize), *ptr = str;
- int i, j, adv = 0;
+ int i, adv = 0;
for (i = 0; i < track->nlen; i++)
{
@@ -218,7 +223,10 @@ bloops_track_str(bloopsatrack *track)
ptr += adv;
bloopsafx *fx = (bloopsafx *)track->notes[i].FX;
while (fx) {
- adv = sprintf(ptr, "[%s %0.3f]", bloops_fxcmd_name(j), fx->val);
+ if (fx->mod == 0)
+ adv = sprintf(ptr, "[%s %0.3f]", bloops_fxcmd_name(fx->cmd), fx->val);
+ else
+ adv = sprintf(ptr, "[%s %c %0.3f]", bloops_fxcmd_name(fx->cmd), fx->mod, fx->val);
ptr += adv;
fx = (bloopsafx *)fx->next;
}

0 comments on commit ebef1d0

Please sign in to comment.