Skip to content

Commit

Permalink
support --float32-columns
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewschaaf committed Sep 29, 2010
1 parent 4547984 commit 01d518f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/arss.c
Expand Up @@ -335,6 +335,7 @@ int main(int argc, char *argv[])

srand(time(NULL));

int spectrogram_output_format = FORMAT_BMP;
for (i=1; i<argc; i++)
{
if (strcmp(argv[i], "/?")==0) // DOS friendly help
Expand All @@ -358,6 +359,9 @@ int main(int argc, char *argv[])
}
else // if the argument is a parameter
{
if (strcmp(argv[i], "--float32-columns") == 0)
spectrogram_output_format = FORMAT_FLOAT32_COLUMNS;

if (strcmp(argv[i], "--analysis")==0 || strcmp(argv[i], "-a")==0)
mode=1;

Expand Down Expand Up @@ -623,9 +627,15 @@ int main(int argc, char *argv[])

settingsinput(&Ysize, samplecount, &samplerate, &basefreq, maxfreq, &pixpersec, &bpo, Xsize, 0); // User settings input
image = anal(sound[0], samplecount, samplerate, &Xsize, Ysize, bpo, pixpersec, basefreq); // Analysis
if (brightness!=1.0)
if (brightness != 1.0) {
brightness_control(image, Ysize, Xsize, 1.0/brightness);
bmp_out(fout, image, Ysize, Xsize); // Image output
}
if (spectrogram_output_format == FORMAT_BMP) {
bmp_out(fout, image, Ysize, Xsize);
}
else if (spectrogram_output_format == FORMAT_FLOAT32_COLUMNS) {
float32_columns_out(fout, image, Ysize, Xsize);
}
}
if (mode==2 || mode==3)
{
Expand Down
15 changes: 14 additions & 1 deletion src/image_io.c
Expand Up @@ -42,7 +42,7 @@ double **bmp_in(FILE *bmpfile, int32_t *y, int32_t *x)
if (zerobytes==4)
zerobytes = 0;

for (iy=*y-1; iy!=-1; iy--) // backwards reading
for (iy=y-1; iy!=-1; iy--) // BMP pixels are ordered: ...bottom row (left-to-right)... ... ...top row (left-to-right)...
{
for (ix=0; ix<*x; ix++)
{
Expand All @@ -60,6 +60,19 @@ double **bmp_in(FILE *bmpfile, int32_t *y, int32_t *x)
return image;
}


void float32_columns_out(FILE *fout, double **image, int32_t y, int32_t x) {
int32_t i, iy, ix;
float val;
for (ix = 0; ix < x; ix++) {
for (iy = 0; iy < y; iy++) {
val = image[iy][ix];
fwrite(&val, 4, 1, fout);
}
}
}


void bmp_out(FILE *bmpfile, double **image, int32_t y, int32_t x)
{
int32_t i, iy, ix, ic; // various iterators
Expand Down
2 changes: 2 additions & 0 deletions src/image_io.h
Expand Up @@ -8,6 +8,8 @@
#include "util.h"

extern double **bmp_in(FILE *bmpfile, int32_t *y, int32_t *x);

extern void float32_columns_out(FILE *fout, double **image, int32_t y, int32_t x);
extern void bmp_out(FILE *bmpfile, double **image, int32_t y, int32_t x);

#endif
5 changes: 5 additions & 0 deletions src/util.h
Expand Up @@ -11,6 +11,11 @@

#include "dsp.h"


#define FORMAT_BMP 1
#define FORMAT_FLOAT32_COLUMNS 2


int32_t quiet;

extern void win_return();
Expand Down

0 comments on commit 01d518f

Please sign in to comment.