示例#1
0
alt_8 play_file(char no_args, char* arg_strings[])
{
	//first we need to open the file
	if(no_args!=1)
	{
		UART_write("This needs a file name\r\n");
		return -1;
	}
	euint8 FFound=0;
	SDfile File[200];
	SDfolder Folder[200];
	read_directory(File,Folder,currDir);
	euint16 i=0;
	for(i=0;i<20;i++)
	{
		if(File[i].valid==1)
		{
			euint8 fname[15];
			euint8 x=0,y=0;
			for(x=0;x<8;x++)
			{
				if(File[i].name[x]!=0x20 && File[i].name[x]!=0x00)
				{//if char is not null and is not space
					fname[y] = File[i].name[x];
					++y;
				}
				else
					x=12;
			}
			fname[y]='.';
			++y;
			for(x=0;x<3;x++)
			{
				if(File[i].extension[x]!=0x20 && File[i].extension[x]!=0x00)
				{//if char is not null and is not space
					fname[y] = File[i].extension[x];
					++y;
				}
				else
					x=12;
			}
			//file is a valid file
			fname[y]=0;//add null terminator
			if(strcompare2(fname,arg_strings[0])==0)
			{
				FFound=1;
				open_wav(File[i]);
			}
		}
	}
	/*
	euint8 buffer[512];
	read_file_chunk(File[6],buffer,512,0);
	*/
	if(FFound==0)
	{
		UART_write("That File cannot be found, check spelling and try again\r\n");
	}
	FFound=0;
}
示例#2
0
main(int argc,char *argv[])
  {

  if (argc<2)
     {
     puts("\nPouziti:  MGFSOUND film.mgf zvuk.wav [i]");
     puts("\nnebo:     MGFSOUND script.scr");
     puts("\nKde _i_ je komprimacni krivka (viz SNDPACK) (default:4)");
     exit(0);
     }
  if (argc>3)
     {
     sscanf(argv[3],"%d",&difftype);
     }
  Create_table_16();
  if (argc==2)
     call_script(argv[1]);
  else
     {
     open_wav(argv[2]);
     open_files(argv[1]);
     ozvuceni();
     }
  close_files();
  }
示例#3
0
void quisk_set_tx_mode(void)	// called when the mode rxMode is changed
{
	tx_filter(NULL, 0);
	tx_filter2(NULL, 0);
#ifdef TEST_TX_WAV_FILE
	if (!wavFp)			// convenient place to open file
		open_wav();
#endif
}
int effect_reset(struct razer_fx_render_node *render)
{
	//reopen input file
	char *filename = daemon_get_parameter_string(daemon_effect_get_parameter_by_index(render->effect,0));
	if(effect_input_file)
	{
		close_wav(effect_input_file);
		effect_input_file = NULL;
	}
	effect_input_file =open_wav(filename);
	#ifdef USE_DEBUGGING
		printf("(fft) opened input wav file:%s,%x\n",filename);
	#endif		
	if(effect_input_file)
		return(1);
	else
		return(0);
}
示例#5
0
/* Main program. */
int main(int argc, char* argv[]) {

	const int verbose = 0;

	if ((argc < 2) || (argc > 6)) {
		print_syntax(argv[0]);
		return 1;
	}

	const char* infile  = argv[1];
	const char* out_pmusic = NULL;
	const char* out_labels = NULL;
	double sm_segment_min_dur = 4.0f;
	double b_segment_min_dur = 4.0f;

	if (argc >= 3) {
		out_pmusic = argv[2];
	}

	if (argc >= 4) {
		out_labels = argv[3];
	}

	if (argc >= 5) {
		sm_segment_min_dur = atof(argv[4]);
	}

	if (argc >= 6) {
		b_segment_min_dur = atof(argv[5]);
	}

	/* Load file */
	
	WAVE* wave = open_wav(infile, verbose);
	
	if (wave == NULL) {
		return 1;
	}

	/* Init Opus encoder */

	OpusSM* sm = init_opus(wave);

	if (sm == NULL) {
		wclose(wave);
		return 1;
	}

	/* Open output files */

	FILE* ofp_pmusic = open_output_file(out_pmusic);
	if (ofp_pmusic == NULL) {
		wclose(wave);
		sm_destroy(sm);
		return 1;
	}

	FILE* ofp_labels = open_output_file(out_labels);
	if (ofp_labels == NULL) {
		wclose(wave);
		sm_destroy(sm);
		fclose(ofp_pmusic);
		return 1;
	}

	/* Processing */
	
	int error = process(infile,
	                    wave,
	                    sm,
	                    ofp_pmusic,
	                    ofp_labels,
	                    sm_segment_min_dur,
	                    b_segment_min_dur
	                   );

	/* Clean up */

	sm = sm_destroy(sm);
	wave = wclose(wave);
	fclose(ofp_pmusic);
	fclose(ofp_labels);

	return error;
}
示例#6
0
void interpret_line(FILE *f)
  {
  char line_buf[1024];
  char *c=line_buf;
  TVOLSTRUC *v;
  TCHANINFO *inf;
  int num;char fcid=0;

  fgets(line_buf,1024,f);
  while (c!=NULL)
     {
     while (*c==32) c++;
     if (!*c) break;
     if (*c=='@')
        {
        char command[24];

        c++;
        sscanf(c,"%23s",command);c=strchr(c,32);
        strupr(command);
        if (!strcmp(command,"ID"))
           {
           get_num(c,num);
           if (fcid) chaninfo[last_channel].id=num;
           fcid=0;
           if ((last_channel=find_channel_id(num))==-1) return;
           inf=chaninfo+last_channel;
           }
        else if (!strcmp(command,"R")) v=&inf->left;
        else if (!strcmp(command,"L")) v=&inf->right;
        else if (!strcmp(command,"VOL"))
           {
           get_num(c,num);
           v->volume=num*128;
           }
        else if (!strcmp(command,"VOLEND"))
           {
           get_num(c,num);
           v->volume_end=num*128;
           v->vls=0;
           }
        else if (!strcmp(command,"SPEED"))
           {
           get_num(c,v->vls);v->volsmax=1;v->volslow=1;
           if (v->volume>v->volume_end) v->vls=-v->vls;
           }
        else if (!strcmp(command,"SLOW"))
           {
           get_num(c,v->volsmax);v->vls=1;v->volslow=1;
           if (v->volume>v->volume_end) v->vls=-v->vls;
           }
        else if (!strcmp(command,"REPSTART")){ get_num(c,inf->repstart);}
        else if (!strcmp(command,"GLOBVOL")) {get_num(c,glob_volume);}
        }
     else
        {
        char filename[128];
        sscanf(c,"%127s",filename);
        c=strchr(c,32);
        open_wav(filename);
        inf=chaninfo+last_channel;
        fcid=1;
        }
     }
  }
示例#7
0
int main(int argc, char *argv[])
{
    int fd, fd_dec;
    int res, datasize,i;
    int nb_frames = 0;
#ifdef DUMP_RAW_FRAMES 
    char filename[15];
    int fd_out;
#endif
    int32_t outbuf[2048];
    uint16_t fs,sps,h;
    uint32_t packet_count;
    COOKContext q;
    RMContext rmctx;
    RMPacket pkt;

    memset(&q,0,sizeof(COOKContext));
    memset(&rmctx,0,sizeof(RMContext));
    memset(&pkt,0,sizeof(RMPacket));

    if (argc != 2) {
        DEBUGF("Incorrect number of arguments\n");
        return -1;
    }

    fd = open(argv[1],O_RDONLY);
    if (fd < 0) {
        DEBUGF("Error opening file %s\n", argv[1]);
        return -1;
    }
    
    /* copy the input rm file to a memory buffer */
    uint8_t * filebuf = (uint8_t *)calloc((int)filesize(fd),sizeof(uint8_t));
    res = read(fd,filebuf,filesize(fd)); 
 
    fd_dec = open_wav("output.wav");
    if (fd_dec < 0) {
        DEBUGF("Error creating output file\n");
        return -1;
    }
    res = real_parse_header(fd, &rmctx);
    packet_count = rmctx.nb_packets;
    rmctx.audio_framesize = rmctx.block_align;
    rmctx.block_align = rmctx.sub_packet_size;
    fs = rmctx.audio_framesize;
    sps= rmctx.block_align;
    h = rmctx.sub_packet_h;
    cook_decode_init(&rmctx,&q);
    
    /* change the buffer pointer to point at the first audio frame */
    advance_buffer(&filebuf, rmctx.data_offset+ DATA_HEADER_SIZE);
    while(packet_count)
    {  
        rm_get_packet(&filebuf, &rmctx, &pkt);
        //DEBUGF("total frames = %d packet count = %d output counter = %d \n",rmctx.audio_pkt_cnt*(fs/sps), packet_count,rmctx.audio_pkt_cnt);
        for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++)
        { 
            /* output raw audio frames that are sent to the decoder into separate files */
#ifdef DUMP_RAW_FRAMES 
              snprintf(filename,sizeof(filename),"dump%d.raw",++x);
              fd_out = open(filename,O_WRONLY|O_CREAT|O_APPEND, 0666);
              write(fd_out,pkt.frames[i],sps);  
              close(fd_out);
#endif
            nb_frames = cook_decode_frame(&rmctx,&q, outbuf, &datasize, pkt.frames[i] , rmctx.block_align);
            rmctx.frame_number++;
            res = write(fd_dec,outbuf,datasize);        
        }
        packet_count -= rmctx.audio_pkt_cnt;
        rmctx.audio_pkt_cnt = 0;
    }
    close_wav(fd_dec, &rmctx, &q);
    close(fd);


  return 0;
}