diff -urN bonk-0.6/bonk.cc bonk-0.6-shntool/bonk.cc --- bonk-0.6/bonk.cc 2002-06-22 23:58:57.000000000 -0400 +++ bonk-0.6-shntool/bonk.cc 2007-06-11 00:04:59.000000000 -0400 @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -540,25 +539,6 @@ } }; -FILE *open_dsp(int rate,bool stereo) { - int device = open(dsp_device,O_WRONLY); - if (device < 0) - throw error("Couldn't open sound device"); - - int format = AFMT_S16_NE; - if (ioctl(device,SNDCTL_DSP_SETFMT,&format) < 0) - throw error("Couldn't set up sound device"); - - int is_stereo = stereo ? 1 : 0; - if (ioctl(device,SNDCTL_DSP_STEREO,&is_stereo) < 0) - throw error("Couldn't set up sound device"); - - if (ioctl(device,SNDCTL_DSP_SPEED,&rate) < 0) - throw error("Couldn't set up sound device"); - - return fdopen(device,"wb"); -} - bool has_parameter(int &argc,char **&argv,char *name,char *&value) { for(int i=1;i 2) - throw error("Don't know how to play more than 2 channels"); - - FILE *f_out = open_dsp(deco.rate,deco.channels>1); - - while(deco.length_remaining) { - vector samples; - deco.read_packet(samples); - - vector little_samples(samples.size()); - for(int i=0;i 32767) - little_samples[i] = 32767; - else if (samples[i] < -32768) - little_samples[i] = -32768; - else - little_samples[i] = samples[i]; - } - fwrite(&(little_samples[0]),2,little_samples.size(),f_out); - fflush(f_out); - } - - fclose(f_in); - fclose(f_out); -} - -void do_play(int argc,char **argv) { - bool loop = false, random = false; - - for(;;) - if (has_flag(argc,argv,"-r")) - random = true; - else if (has_flag(argc,argv,"-l")) - loop = true; - else break; - - if (argc <= 2) - return; - - do { - if (random) - for(int i=2;i= 2 && strcmp(argv[1],"decode") == 0) { do_decode(argc,argv); - } else if (argc >= 2 && strcmp(argv[1],"play") == 0) { - do_play(argc,argv); } else { fprintf(stderr, "[ Bonk lossy/lossless audio compressor (version %s) ]\n\n" @@ -918,12 +851,7 @@ "[ Decoding back to WAV format ]\n\n" " bonk decode [options] file1.bonk file2.bonk ...\n\n" " Options:\n" - " -o file.wav Write output to file.wav\n\n" - "[ Playing BONK format files ]\n\n" - " bonk play [options] file1.bonk file2.bonk ...\n\n" - " Options:\n" - " -r Random order\n" - " -l Loop\n", + " -o file.wav Write output to file.wav\n\n", version ); }