Skip to content

Commit

Permalink
Add envelope extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
glguida committed May 11, 2020
1 parent b5d8f2f commit d464178
Show file tree
Hide file tree
Showing 2 changed files with 152,019 additions and 152,001 deletions.
19 changes: 18 additions & 1 deletion raw2plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,32 @@

FILE *in, *out;

static float env(float f)
{
static float lmax = 0, pf = 0, diff = 0;
float pdiff;

pdiff = diff;
diff = f - pf;
if (pdiff >= 0 && diff < 0)
{
/* f > lmax or derivative changed sign into negative (zero case a *bit* edgy): local maximum. */
lmax = pf;
}
pf = f;
return lmax;
}

static void print(void)
{
unsigned long i;
ssize_t r;
float f;

fprintf(out, "sample out env\n");
i = 0;
while ((r = fread(&f, sizeof(float), 1, in)) == 1)
fprintf(out, "%ld %f\n", i++, f);
fprintf(out, "%ld %f %f\n", i++, f, env(f));
}

int main(int argc, char *argv[])
Expand Down
Loading

0 comments on commit d464178

Please sign in to comment.