*
*/
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
+/* dfb */
+#include <directfb.h>
+
#include "oss_api.h"
#include "hdrec.h"
+/* fourier */
+#include "fourier.h"
+
int usage(void) {
printf("usage:\n\n");
printf("-h \t\t print this help\n");
struct timeval fds_tv;
char c;
+ /* dfb */
+ IDirectFB *dfb;
+ IDirectFBSurface *primary;
+ DFBSurfaceDescription dsc;
+ int width,height;
+
+ /* fourier */
+ t_fourier fourier;
+ int sample;
+ int dx;
+ int a_f;
+
/* defaults */
strcpy(device,"");
set.format=AFMT_S16_LE;
perror("malloc");
return -1;
}
+
if((mode&RECORD) && (mode&PLAY)) {
if((buf2=malloc(set.bufsize*sizeof(unsigned char)))==NULL) {
printf("allocating 2nd memory failed :(\n");
}
if((mode&PLAY) && (!(mode&RECORD))) {
+
+ /* dfb */
+ DirectFBInit(&argc,&argv);
+ DirectFBCreate(&dfb);
+ dfb->SetCooperativeLevel(dfb,DFSCL_FULLSCREEN);
+ dsc.flags=DSDESC_CAPS;
+ dsc.caps=DSCAPS_PRIMARY|DSCAPS_FLIPPING;
+ dfb->CreateSurface(dfb,&dsc,&primary);
+ primary->GetSize(primary,&width,&height);
+ dprintf(1,"graphical equalizer dims: %dx%d\n",width,height);
+ primary->SetColor(primary,0x80,0x80,0xff,0xff);
+ //primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC);
+
+ /* fourier */
+ fourier_init(&fourier,1);
+ fourier.type=FWD|DFT;
+ fourier.dim=1;
+ fourier.data_len[0]=set.bufsize/(set.format&AFMT_S16_LE?4:2);
+ fourier_alloc_data(&fourier);
+ printf("debug: allocated size for %d samples to do dft\n",fourier.data_len[0]);
+ dx=8*width/fourier.data_len[0];
+ printf("debug: dx = %d ???\n",dx);
+
printf("playing file %s ...\n",play_file);
if(mode&REVERSED) printf("but we do it reversed!\n");
rw=1;
if(!(mode&REVERSED)) {
while(rw) {
+ /* read samples */
rw=read(pfile_fd,buf,set.bufsize);
+ /* do fourier trafo */
+ for(sample=0;sample<fourier.data_len[0];sample++) fourier.data[sample].r=*((signed short *)buf+(set.format&AFMT_S16_LE?2:1)*sample);
+ fourier_dft_1d(&fourier);
+ /* print graph */
+ primary->Clear(primary,0,0,0,0xff);
+ a_f=dx*fourier.data_len[0]*440/set.freq;
+ primary->DrawLine(primary,a_f,height,a_f,0);
+ for(sample=0;sample<fourier.data_len[0]/8;sample++) primary->FillRectangle(primary,sample*dx,0,dx,height*sqrt(fourier.ftdata[sample].r*fourier.ftdata[sample].r+fourier.ftdata[sample].i*fourier.ftdata[sample].i)/0x7fff);
+ primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC);
+ //fcount=0;
+
+ //}
+
write(audio_fd,buf,set.bufsize);
}
} else {
write(audio_fd,buf,set.bufsize);
}
}
+
+ /* dfb release */
+ primary->Release(primary);
+ dfb->Release(dfb);
+
}
if((mode&RECORD) && (!(mode&PLAY))) {