If I directly sample through the 7 analog pins in beaglebone through pru and electret mics, will I get similar performance. I am getting too much noise in this kid of recording
. What are the main reasons ? I am just trying to understand what kind of modifications Bela doing to make the audio cleaner ?
PRU Code:
#include <sys/time.h>
#include "../libpruio-0.2/src/c_wrapper/pruio.h"
#include "../libpruio-0.2/src/c_wrapper/pruio_pins.h"
#include <time.h>
#include <unistd.h>
#include <stdio.h>
int isleep(unsigned int mseconds)
{
fd_set set;
struct timeval timeout;
/* Initialize the file descriptor set. */
FD_ZERO(&set);
FD_SET(STDIN_FILENO, &set);
/* Initialize the timeout data structure. */
timeout.tv_sec = 0;
timeout.tv_usec = mseconds * 1000;
return 1;
//return TEMP_FAILURE_RETRY(select(FD_SETSIZE,
// &set, NULL, NULL,
// &timeout));
}
//! The main function.
int main(int argc, char **argv)
{
pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1); //! create new driver structure
//pruIo *io = pruio_new(io, 0, 0, 0);
do { // pseudo loop to avoid goto
if (io->Errr) {
printf("initialisation failed (%s)\n", io->Errr); break;}
if (pruio_config(io, 1, 0x1FE, 0, 4)) {
printf("config failed (%s)\n", io->Errr); break;}
//struct termios oldt, newt; // make terminal non-blocking
//tcgetattr( STDIN_FILENO, &oldt );
//newt = oldt;
//newt.c_lflag &= ~( ICANON | ECHO );
//newt.c_cc[VMIN] = 0;
// newt.c_cc[VTIME] = 0;
//tcsetattr(STDIN_FILENO, TCSANOW, &newt);
time_t secondsStart;
time_t secondsNow;
FILE* oFile;
//uint8 bDiv = 4, bStep;
//uint32 bSize = 1e6;
//uint32 bsSize = bSize/bDiv;
oFile = fopen("output.txt","w");
secondsStart = time(0);
int count_c=0;
printf("Start Time: %lld\n",(long long)secondsStart);
// while(!isleep(1)) { // run loop until keystroke
while(count_c<2000000){
//printf("%d %d %d %d %d %d %d\n", io->Adc->Value[0],io->Adc->Value[1],io->Adc->Value[2],io->Adc->Value[3],io->Adc->Value[4],io->Adc->Value[5],io->Adc->Value[6],io->Adc->Value[7]);
//int adc0 = io->Adc->Value[0];
//printf("%d\n",adc0);
int adc1 = io->Adc->Value[1];
int adc2 = io->Adc->Value[2];
int adc3 = io->Adc->Value[3];
int adc4 = io->Adc->Value[4];
int adc5 = io->Adc->Value[5];
int adc6 = io->Adc->Value[6];
int adc7 = io->Adc->Value[7];
int adc8 = io->Adc->Value[8];
//int adc5 = io->Adc->Value[5];
//int adc6 = io->Adc->Value[6];
int adc [8] = { adc1, adc2, adc3, adc4, adc5, adc6, adc7, adc8 };
//fflush(STDIN_FILENO);
//printf("\r%4X %4X %4X %4X\n",io->Adc->Value[2], io->Adc->Value[3], io->Adc->Value[4], io->Adc->Value[5]);
//usleep(1);
//fwrite(adc, sizeof(int), sizeof(adc), oFile);
//fwrite("\n", sizeof(char), 1, oFile);
secondsNow= time(0);
//(long long)secondsNow,
fprintf(oFile, "%d %d %d %d %d %d %d %d\n", adc[0], adc[1], adc[2], adc[3], adc[4], adc[5], adc[6], adc[7]);
count_c++;
}
secondsNow= time(0);
fclose(oFile);
printf("Start Time: %lld\n",(long long)secondsStart);
printf("End Time: %lld\n",(long long)secondsNow);
printf("COUNT IS: %d\n",count_c );
//tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // reset terminal
printf("\n");
} while (0);
pruio_destroy(io); /* destroy driver structure */
return 0;
}