Skip to content

Commit

Permalink
remove bloops_track_at from public C API
Browse files Browse the repository at this point in the history
  • Loading branch information
MenTaLguY authored and localhost committed Jun 5, 2011
1 parent d44f635 commit dffcc04
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 71 deletions.
16 changes: 14 additions & 2 deletions c/bloopsaphone.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static void bloops_synth(int, float *);
static int bloops_port_callback(const void *, void *,
unsigned long, const PaStreamCallbackTimeInfo *,
PaStreamCallbackFlags, void *);
static void bloops_set_track_at(bloops *B, bloopsatrack *track, int num);

float
frnd(float range)
Expand Down Expand Up @@ -131,7 +132,7 @@ bloops_clear(bloops *B)
{
int i;
for (i = 0; i < BLOOPS_MAX_TRACKS; i++) {
bloops_track_at(B, NULL, i);
bloops_set_track_at(B, NULL, i);
}
}

Expand All @@ -142,7 +143,7 @@ bloops_tempo(bloops *B, int tempo)
}

void
bloops_track_at(bloops *B, bloopsatrack *track, int num)
bloops_set_track_at(bloops *B, bloopsatrack *track, int num)
{
bloopsatrack *old_track;
old_track = B->tracks[num];
Expand All @@ -155,6 +156,17 @@ bloops_track_at(bloops *B, bloopsatrack *track, int num)
}
}

void
_bloops_track_add(bloops *B, bloopsatrack *track) {
int i;
for (i = 0; i < BLOOPS_MAX_TRACKS; i++) {
if (B->tracks[i] == NULL) {
bloops_set_track_at(B, track, i);
break;
}
}
}

int
bloops_is_done(bloops *B)
{
Expand Down
2 changes: 0 additions & 2 deletions c/bloopsaphone.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ void bloops_play(bloops *);
void bloops_stop(bloops *);
int bloops_is_done(bloops *);

void bloops_track_at(bloops *, bloopsatrack *, int);

bloopsatrack *bloops_track(bloops *, bloopsaphone *, char *, int);
bloopsatrack *bloops_track2(bloops *, bloopsaphone *, char *);
void bloops_track_ref(bloopsatrack *);
Expand Down
106 changes: 55 additions & 51 deletions c/notation.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ static const int bloopnotes_en_main = 111;
#line 154 "c/notation.rl"


extern void _bloops_track_add(bloops *B, bloopsatrack *track);

bloopsatrack *
bloops_track(bloops *B, bloopsaphone *P, char *track, int tracklen)
{
Expand All @@ -407,16 +409,16 @@ bloops_track(bloops *B, bloopsaphone *P, char *track, int tracklen)
pe = track + tracklen + 1;


#line 411 "c/notation.c"
#line 413 "c/notation.c"
{
cs = bloopnotes_start;
ts = 0;
te = 0;
act = 0;
}
#line 174 "c/notation.rl"
#line 176 "c/notation.rl"

#line 420 "c/notation.c"
#line 422 "c/notation.c"
{
int _klen;
unsigned int _trans;
Expand All @@ -437,7 +439,7 @@ bloops_track(bloops *B, bloopsaphone *P, char *track, int tracklen)
#line 1 "c/notation.rl"
{ts = p;}
break;
#line 441 "c/notation.c"
#line 443 "c/notation.c"
}
}

Expand Down Expand Up @@ -719,7 +721,7 @@ bloops_track(bloops *B, bloopsaphone *P, char *track, int tracklen)
#line 147 "c/notation.rl"
{{p = ((te))-1;}{ NEXT(); }}
break;
#line 723 "c/notation.c"
#line 725 "c/notation.c"
}
}

Expand All @@ -732,7 +734,7 @@ bloops_track(bloops *B, bloopsaphone *P, char *track, int tracklen)
#line 1 "c/notation.rl"
{ts = 0;}
break;
#line 736 "c/notation.c"
#line 738 "c/notation.c"
}
}

Expand All @@ -751,14 +753,16 @@ bloops_track(bloops *B, bloopsaphone *P, char *track, int tracklen)

_out: {}
}
#line 175 "c/notation.rl"
#line 177 "c/notation.rl"

S->P = bloops_sound_dup(P);
if (S->P == NULL) {
free(S);
S = NULL;
}

_bloops_track_add(B, S);

return S;
}

Expand Down Expand Up @@ -971,7 +975,7 @@ bloops_note_freq(char note, int octave)
#define KEY(name) key = (void *)&P->name


#line 975 "c/notation.c"
#line 979 "c/notation.c"
static const char _bloopserial_actions[] = {
0, 1, 0, 1, 1, 1, 2, 1,
5, 1, 6, 1, 7, 1, 8, 1,
Expand Down Expand Up @@ -1278,7 +1282,7 @@ static const int bloopserial_error = 0;

static const int bloopserial_en_main = 142;

#line 446 "c/notation.rl"
#line 450 "c/notation.rl"


bloopsaphone *
Expand Down Expand Up @@ -1310,16 +1314,16 @@ bloops_sound_file(bloops *B, char *fname)

P = bloops_square();

#line 1314 "c/notation.c"
#line 1318 "c/notation.c"
{
cs = bloopserial_start;
ts = 0;
te = 0;
act = 0;
}
#line 477 "c/notation.rl"
#line 481 "c/notation.rl"

#line 1323 "c/notation.c"
#line 1327 "c/notation.c"
{
int _klen;
unsigned int _trans;
Expand All @@ -1340,7 +1344,7 @@ bloops_sound_file(bloops *B, char *fname)
#line 1 "c/notation.rl"
{ts = p;}
break;
#line 1344 "c/notation.c"
#line 1348 "c/notation.c"
}
}

Expand Down Expand Up @@ -1406,150 +1410,150 @@ bloops_sound_file(bloops *B, char *fname)
switch ( *_acts++ )
{
case 0:
#line 400 "c/notation.rl"
#line 404 "c/notation.rl"
{
fval = ATOI(ts, p - ts) * 1.0f;
}
break;
case 1:
#line 404 "c/notation.rl"
#line 408 "c/notation.rl"
{
fval = ATOI(pf, p - pf) * pow(0.1f, p - pf);
}
break;
case 2:
#line 408 "c/notation.rl"
#line 412 "c/notation.rl"
{ pf = p; }
break;
case 3:
#line 409 "c/notation.rl"
#line 413 "c/notation.rl"
{ fval *= -1.0f; }
break;
case 4:
#line 410 "c/notation.rl"
#line 414 "c/notation.rl"
{ KEY(volume); }
break;
case 5:
#line 411 "c/notation.rl"
#line 415 "c/notation.rl"
{ KEY(arp); }
break;
case 6:
#line 412 "c/notation.rl"
#line 416 "c/notation.rl"
{ KEY(aspeed); }
break;
case 7:
#line 413 "c/notation.rl"
#line 417 "c/notation.rl"
{ KEY(attack); }
break;
case 8:
#line 414 "c/notation.rl"
#line 418 "c/notation.rl"
{ KEY(decay); }
break;
case 9:
#line 415 "c/notation.rl"
#line 419 "c/notation.rl"
{ KEY(dslide); }
break;
case 10:
#line 416 "c/notation.rl"
#line 420 "c/notation.rl"
{ KEY(freq); }
break;
case 11:
#line 417 "c/notation.rl"
#line 421 "c/notation.rl"
{ KEY(hpf); }
break;
case 12:
#line 418 "c/notation.rl"
#line 422 "c/notation.rl"
{ KEY(hsweep); }
break;
case 13:
#line 419 "c/notation.rl"
#line 423 "c/notation.rl"
{ KEY(limit); }
break;
case 14:
#line 420 "c/notation.rl"
#line 424 "c/notation.rl"
{ KEY(lpf); }
break;
case 15:
#line 421 "c/notation.rl"
#line 425 "c/notation.rl"
{ KEY(lsweep); }
break;
case 16:
#line 422 "c/notation.rl"
#line 426 "c/notation.rl"
{ KEY(phase); }
break;
case 17:
#line 423 "c/notation.rl"
#line 427 "c/notation.rl"
{ KEY(psweep); }
break;
case 18:
#line 424 "c/notation.rl"
#line 428 "c/notation.rl"
{ KEY(repeat); }
break;
case 19:
#line 425 "c/notation.rl"
#line 429 "c/notation.rl"
{ KEY(resonance); }
break;
case 20:
#line 426 "c/notation.rl"
#line 430 "c/notation.rl"
{ KEY(slide); }
break;
case 21:
#line 427 "c/notation.rl"
#line 431 "c/notation.rl"
{ KEY(square); }
break;
case 22:
#line 428 "c/notation.rl"
#line 432 "c/notation.rl"
{ KEY(sustain); }
break;
case 23:
#line 429 "c/notation.rl"
#line 433 "c/notation.rl"
{ KEY(sweep); }
break;
case 24:
#line 430 "c/notation.rl"
#line 434 "c/notation.rl"
{ KEY(punch); }
break;
case 25:
#line 431 "c/notation.rl"
#line 435 "c/notation.rl"
{ KEY(vibe); }
break;
case 26:
#line 432 "c/notation.rl"
#line 436 "c/notation.rl"
{ KEY(vspeed); }
break;
case 27:
#line 433 "c/notation.rl"
#line 437 "c/notation.rl"
{ KEY(vdelay); }
break;
case 28:
#line 434 "c/notation.rl"
#line 438 "c/notation.rl"
{ KEY(volume); }
break;
case 31:
#line 438 "c/notation.rl"
#line 442 "c/notation.rl"
{te = p+1;{ P->type = BLOOPS_SQUARE; }}
break;
case 32:
#line 439 "c/notation.rl"
#line 443 "c/notation.rl"
{te = p+1;{ P->type = BLOOPS_SAWTOOTH; }}
break;
case 33:
#line 440 "c/notation.rl"
#line 444 "c/notation.rl"
{te = p+1;{ P->type = BLOOPS_SINE; }}
break;
case 34:
#line 441 "c/notation.rl"
#line 445 "c/notation.rl"
{te = p+1;{ P->type = BLOOPS_NOISE; }}
break;
case 35:
#line 437 "c/notation.rl"
#line 441 "c/notation.rl"
{te = p;p--;{ *((float *)key) = fval; }}
break;
case 36:
#line 442 "c/notation.rl"
#line 446 "c/notation.rl"
{te = p;p--;}
break;
#line 1553 "c/notation.c"
#line 1557 "c/notation.c"
}
}

Expand All @@ -1562,7 +1566,7 @@ bloops_sound_file(bloops *B, char *fname)
#line 1 "c/notation.rl"
{ts = 0;}
break;
#line 1566 "c/notation.c"
#line 1570 "c/notation.c"
}
}

Expand All @@ -1581,7 +1585,7 @@ bloops_sound_file(bloops *B, char *fname)

_out: {}
}
#line 478 "c/notation.rl"
#line 482 "c/notation.rl"

done:
fclose(fp);
Expand Down
4 changes: 4 additions & 0 deletions c/notation.rl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@
write data nofinal;
}%%

extern void _bloops_track_add(bloops *B, bloopsatrack *track);

bloopsatrack *
bloops_track(bloops *B, bloopsaphone *P, char *track, int tracklen)
{
Expand All @@ -179,6 +181,8 @@ bloops_track(bloops *B, bloopsaphone *P, char *track, int tracklen)
S = NULL;
}

_bloops_track_add(B, S);

return S;
}

Expand Down
Loading

0 comments on commit dffcc04

Please sign in to comment.