Skip to content

Commit

Permalink
pt3: have test_pt3 take a command line argument
Browse files Browse the repository at this point in the history
  • Loading branch information
deater committed Aug 28, 2019
1 parent 665cc29 commit 6f3baa8
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions stm32L476/chiptune_dac_dma/test_pt3.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ static struct pt3_song_t pt3,pt3_2;
static ayemu_ay_reg_frame_t frame;


struct pt3_image_t pt3_image= {
.data=__I2_PT3, .length=__I2_PT3_len,
};
struct pt3_image_t pt3_image;


//struct pt3_image_t pt3_image= {
// .data=__EA_PT3, .length=__EA_PT3_len,
Expand Down Expand Up @@ -153,6 +152,37 @@ void play (void) {

int main (int argc, char **argv) {

unsigned char *pt3_data;
int fd,size;

if (argc<2) {
pt3_image.data=__I2_PT3;
pt3_image.length=__I2_PT3_len;
}
else {
pt3_data=calloc(16384,sizeof(unsigned char));
if (pt3_data==NULL) {
fprintf(stderr,"Error allocating space!\n");
return -1;
}
fd=open(argv[1],O_RDONLY);
if (fd<0) {
fprintf(stderr,"Error opening file %s!\n",argv[1]);
return -1;
}
size=read(fd,pt3_data,16384);
if (size==16384) {
fprintf(stderr,"File too big %s!\n",argv[1]);
return -1;
}
if (size<0) {
fprintf(stderr,"Error reading file %s!\n",argv[1]);
return -1;
}
pt3_image.data=pt3_data;
pt3_image.length=size;
}

init_oss();
if (DEBUG) {
printf ("OSS sound system initialization success: "
Expand Down

0 comments on commit 6f3baa8

Please sign in to comment.