File: playwav.c

package info (click to toggle)
gramofile 1.6-7
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 840 kB
  • ctags: 538
  • sloc: ansic: 10,238; makefile: 55
file content (788 lines) | stat: -rw-r--r-- 19,028 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
/* Playing a sound file

 * Copyright (C) 1998 J.A. Bezemer
 *
 * Licensed under the terms of the GNU General Public License.
 * ABSOLUTELY NO WARRANTY.
 * See the file `COPYING' in this directory.
 */

#include "playwav.h"
#include "scrollmenu.h"
#include "stringinput.h"
#include "buttons.h"
#include "boxes.h"
#include "dirfilemenu.h"
#include "errorwindow.h"
#include "textwindow.h"
#include "checkfile.h"
#include "yesnowindow.h"
#include "helpline.h"
#include "clrscr.h"
#include "secshms.h"
#include "fmtheaders.h"
#include "signpr_main.h"

#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#ifndef OLD_CURSES
#include <ncurses.h>
#else
#include <curses.h>
#endif


void
playwav_playit (char *filename, int usebeginendtime, double begintime,
		double endtime)
{
  char shellcmd[500];

  switch (checkfile (filename))
    {
    case FILE_EXISTS:

      if (usebeginendtime)
	sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld %s",
		 (long) (begintime * 44100),
		 (long) ((endtime - begintime) * 44100), filename);
      else
	sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 %s", filename);
      /* defaults for raw files (but no -r, so .wav's supply their own
         parameters) - you can even listen to executables in CD quality (: */

      def_prog_mode ();		/* save terminal state */

      system (shellcmd);

      reset_prog_mode ();	/* reset terminal state */
      clear ();

      break;

    case DIR_EXISTS:
      error_window ("The specified name is of a directory. A \
file name must be specified.");
      break;

    case DIR_OK_NEW_FILE:
    case DIR_WRONG:
      error_window ("The specified file does not exist.");
      break;

    default:
      error_window ("Fell out of switch, playwav #2");
      break;
    }
}

#define PLAY_TRACK	1
#define PLAY_BEGINNING	2
#define PLAY_END	3
#define PLAY_BEFORE	4
#define PLAY_AFTER	5

/* These may be fractional, like 5.2, if you like that better. */
#define BEGINNING_SECS	5
#define END_SECS	4
#define BEFORE_SECS	3
#define AFTER_SECS	3

void
playwav_track (char *filename, int track, int action)
{
  beginendsample_t tracktimes[100];
  int number_of_tracks;
  double begintime, endtime;
  char helpstring[200];

  if (!load_track_times (filename, tracktimes, &number_of_tracks))
    return;

  if (track > number_of_tracks || track < 1)
    {
      sprintf (helpstring, "There are only %d tracks.", number_of_tracks);
      error_window (helpstring);
      return;
    }

  switch (action)
    {
    case PLAY_TRACK:
      begintime = tracktimes[track].begin;
      endtime = tracktimes[track].end;
      /* use samples here, convert to seconds after switch */
      break;

    case PLAY_BEGINNING:
      begintime = tracktimes[track].begin;
      endtime = tracktimes[track].begin + BEGINNING_SECS * 44100;
      break;

    case PLAY_END:
      begintime = tracktimes[track].end - END_SECS * 44100;
      endtime = tracktimes[track].end;
      break;

    case PLAY_BEFORE:
      begintime = tracktimes[track].begin - BEFORE_SECS * 44100;
      endtime = tracktimes[track].begin;
      break;

    case PLAY_AFTER:
      begintime = tracktimes[track].end;
      endtime = tracktimes[track].end + AFTER_SECS * 44100;
      break;

    default:
      error_window ("Fell out of switch, playwav #3");
      return;
    }

  if (begintime < 0)
    begintime = 0;
  if (endtime < 0)
    endtime = 0;
  if (begintime >= endtime)
    return;

  /* samples -> seconds here */
  playwav_playit (filename, 1, begintime / 44100, endtime / 44100);
}


int
playwav_select_file (char *startdir, char *selectedfile,
		     int *usebeginendtime, double *begintime,
		     double *endtime)
/* Returns 0: canceled, 1: OK */
{
  scrollmenu_t dirfilelist;
  stringinput_t string;
  button_t ok_button, cancel_button;
  int dont_stop = TRUE;
  int returnval = 0;
  int focus;
  int in_ch;
  int i;
  char helpstring[500];
  char *charpointer;
  struct stat filestats;
  int oldselected;
  double tempdouble = 0;
  long templong;
  char tempstring[250];
  stringinput_t trackstring, begintimestring, endtimestring;
  button_t beginend_check;
  struct stat buf;

  char *helplines[8] =
  {
    " Select name of sound file to be played.                        TAB: Next field",
    " Enter: Play track    B/E: Beginning/End    F/A: beFore/After    +/-: Prev/Next",
    " Play only a part of the sound file.                            TAB: Next field",
    " Enter begin time of part to be played.                         TAB: Next field",
    " Enter end time of part to be played.                           TAB: Next field",
    " Enter name of sound file to be played.                         TAB: Next field",
    " Back to main menu.                                             TAB: Next field",
    " Play the specified (part of the) sound file.                   TAB: Next field"};

  dirfilelist.y = 3;
  dirfilelist.x = 5;
  dirfilelist.h = 12;
  dirfilelist.w = 32;
  dirfilelist.firstonscreen = 0;
  dirfilemenu (startdir, &dirfilelist);
  dirfilelist.selected = dirfilelist.last_of_1st_part + 1;

  string.maxlen = 500;
  string.string = (char *) malloc (string.maxlen * sizeof (char));
  if (selectedfile[0] == '\0')
    strcpy (string.string, startdir);
  else
    strcpy (string.string, selectedfile);
  string.y = 17;
  string.x = 5;
  string.w = 70;
  string.cursorpos = strlen (string.string);
  string.firstcharonscreen = strlen (string.string) - string.w + 2;
  if (string.firstcharonscreen < 0)
    string.firstcharonscreen = 0;

  ok_button.text = " Play ";
  ok_button.y = 20;
  ok_button.x = 69;
  ok_button.selected = FALSE;

  cancel_button.text = " Cancel ";
  cancel_button.y = 20;
  cancel_button.x = 5;
  cancel_button.selected = FALSE;

  trackstring.maxlen = 500;
  trackstring.string = (char *) malloc (
					 trackstring.maxlen * sizeof (char));
  strcpy (trackstring.string, "1");
  trackstring.y = 11;
  trackstring.x = 54;
  trackstring.w = 10;
  trackstring.cursorpos = strlen (trackstring.string);
  trackstring.firstcharonscreen = 0;

  begintimestring.maxlen = 500;
  begintimestring.string = (char *) malloc (
				    begintimestring.maxlen * sizeof (char));
  fsec2hmsf (*begintime, begintimestring.string);
  begintimestring.y = 14;
  begintimestring.x = 59;
  begintimestring.w = 18;
  begintimestring.cursorpos = strlen (begintimestring.string);
  begintimestring.firstcharonscreen = 0;

  endtimestring.maxlen = 500;
  endtimestring.string = (char *) malloc (
				      endtimestring.maxlen * sizeof (char));
  fsec2hmsf (*endtime, endtimestring.string);
  endtimestring.y = 15;
  endtimestring.x = 59;
  endtimestring.w = 18;
  endtimestring.cursorpos = strlen (endtimestring.string);
  endtimestring.firstcharonscreen = 0;

  beginend_check.text = "";	/* see below */
  beginend_check.y = 13;
  beginend_check.x = 42;
  beginend_check.selected = FALSE;

  clearscreen (PLAYWAV_HEADERTEXT);

  if (selectedfile[0] == '\0')
    focus = 0;
  else
    focus = 5;

  do
    {
      if (*usebeginendtime)
	beginend_check.text = "[X] Use begin and end times";
      else
	beginend_check.text = "[ ] Use begin and end times";

      if (focus == 2)
	beginend_check.selected = TRUE;
      else
	beginend_check.selected = FALSE;

      if (focus == 6)
	cancel_button.selected = TRUE;
      else
	cancel_button.selected = FALSE;

      if (focus == 7)
	ok_button.selected = TRUE;
      else
	ok_button.selected = FALSE;

      dirfilelist.hasfocus = (focus == 0);

      scrollmenu_display (&dirfilelist);
      mybox (dirfilelist.y - 1, dirfilelist.x - 1,
	     dirfilelist.h + 2, dirfilelist.w + 2);
      mvprintw (dirfilelist.y - 1, dirfilelist.x + 1,
		"Files and directories:");

      button_display (&beginend_check);

      stringinput_display (&trackstring);
      mvprintw (trackstring.y, trackstring.x - 7,
		"Track:");

      stringinput_display (&begintimestring);
      mvprintw (begintimestring.y, begintimestring.x - 12,
		"Begin time:");

      stringinput_display (&endtimestring);
      mvprintw (endtimestring.y, endtimestring.x - 12,
		"End time  :");

      stringinput_display (&string);
      mybox (string.y - 1, string.x - 1, 3, string.w + 2);
      mvprintw (string.y - 1, string.x + 1, "File name:");

      button_display (&cancel_button);
      mybox (cancel_button.y - 1, cancel_button.x - 1,
	     3, strlen (cancel_button.text) + 2);
      button_display (&ok_button);
      mybox (ok_button.y - 1, ok_button.x - 1,
	     3, strlen (ok_button.text) + 2);

      header (PLAYWAV_HEADERTEXT);
      helpline (helplines[focus]);

      /* this really should be a switch... */
      if (focus == 1)
	stringinput_display (&trackstring);
      else if (focus == 3)
	stringinput_display (&begintimestring);
      else if (focus == 4)
	stringinput_display (&endtimestring);
      else if (focus == 5)
	stringinput_display (&string);
      else
	move (0, 79);

      refresh ();

      in_ch = getch ();

      switch (focus)
	{
	case 0:		/* dirfilelist */
	  if (scrollmenu_stdkeys (in_ch, &dirfilelist) >= 0)
	    {
	      oldselected = dirfilelist.selected;
	      i = dirfilemenu_process_select (&dirfilelist,
					      helpstring);
	      if (i == 0)	/* filename in helpstring */
		{
		  strcpy (string.string, helpstring);
		  focus = 7;
		  string.cursorpos = strlen (string.string);
		  string.firstcharonscreen = 0;

		  if (!stat (helpstring, &buf))
		    {
		      *begintime = 0;
		      if (buf.st_size < sizeof (wavhead))
			*endtime = 0;
		      else
			*endtime = (buf.st_size - sizeof (wavhead))
			  / (2 * 2 * 44100.);

		      fsec2hmsf (*begintime, begintimestring.string);
		      begintimestring.cursorpos =
			strlen (begintimestring.string);
		      begintimestring.firstcharonscreen = 0;

		      fsec2hmsf (*endtime, endtimestring.string);
		      endtimestring.cursorpos = strlen (endtimestring.string);
		      endtimestring.firstcharonscreen = 0;
		    }
		}
	      else
		/* dir in helpstring */
		{
		  scrollmenu_delete_menu (&dirfilelist);
		  dirfilemenu (helpstring, &dirfilelist);
		  if (dirfilelist.number == 0)
		    {
		      error_window (
				   "No permission to read this directory.");
		      scrollmenu_delete_menu (&dirfilelist);
		      dirfilemenu (startdir, &dirfilelist);
		      dirfilelist.selected = oldselected;
		    }
		  else
		    {
		      strcpy (startdir, helpstring);
		      dirfilelist.firstonscreen = 0;

		      charpointer = strrchr (string.string, '/');
		      if (charpointer != NULL)
			strcat (helpstring, charpointer + 1);
		      else
			strcat (helpstring, string.string);
		      strcpy (string.string, helpstring);
		    }
		}
	    }
	  else
	    switch (in_ch)
	      {
	      case KEY_LEFT:
		focus--;
		break;
	      case KEY_RIGHT:
		focus++;
		break;
	      }
	  break;

	case 1:		/* tracks */
	  /* exclude keys like b,e,f,a,+,- */
	  if ((in_ch >= '0' && in_ch <= '9') || in_ch > 127)
	    stringinput_stdkeys (in_ch, &trackstring);

	  templong = atol (trackstring.string);

	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	      playwav_track (string.string, templong, PLAY_TRACK);
	      break;

	    case 'b':
	    case 'B':
	      playwav_track (string.string, templong, PLAY_BEGINNING);
	      break;

	    case 'e':
	    case 'E':
	      playwav_track (string.string, templong, PLAY_END);
	      break;

	    case 'f':
	    case 'F':
	      playwav_track (string.string, templong, PLAY_BEFORE);
	      break;

	    case 'a':
	    case 'A':
	      playwav_track (string.string, templong, PLAY_AFTER);
	      break;

	    case '+':
	    case '=':
	      if (templong < 99)
		templong++;
	      sprintf (trackstring.string, "%ld", templong);
	      trackstring.cursorpos = strlen (trackstring.string);
	      trackstring.firstcharonscreen = 0;
	      break;

	    case '-':
	    case '_':
	      if (templong > 1)
		templong--;
	      sprintf (trackstring.string, "%ld", templong);
	      trackstring.cursorpos = strlen (trackstring.string);
	      trackstring.firstcharonscreen = 0;
	      break;

	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_DOWN:
	      focus++;
	      break;
	    }

	  break;

	case 2:		/* Use begin/end times */
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	    case ' ':
	    case 'x':
	    case 'X':
	      *usebeginendtime = 1 - *usebeginendtime;
	      break;

	    case KEY_LEFT:
	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_RIGHT:
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 3:		/* begin time */
	  stringinput_stdkeys (in_ch, &begintimestring);
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	      strcpy (tempstring, begintimestring.string);
	      if (!hmsf2fsec (tempstring, &tempdouble))
		{
		  error_window ("Enter the time in the format hours:\
minutes:seconds.fractions, for example 0:04:26.740");
		  begintimestring.cursorpos =
		    strlen (begintimestring.string);
		}
	      else
		{
		  *begintime = tempdouble;
		  fsec2hmsf (tempdouble, begintimestring.string);
		  begintimestring.cursorpos =
		    strlen (begintimestring.string);
		  focus++;
		}
	      break;

	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;

	case 4:		/* end time */
	  stringinput_stdkeys (in_ch, &endtimestring);
	  switch (in_ch)
	    {
	    case KEY_ENTER:
	    case 13:
	      strcpy (tempstring, endtimestring.string);
	      if (!hmsf2fsec (tempstring, &tempdouble))
		{
		  error_window ("Enter the time in the format hours:\
minutes:seconds.fractions, for example 0:04:26.740");
		  endtimestring.cursorpos =
		    strlen (endtimestring.string);
		}
	      else
		{
		  *endtime = tempdouble;
		  fsec2hmsf (tempdouble, endtimestring.string);
		  endtimestring.cursorpos =
		    strlen (endtimestring.string);
		  focus = 5;
		}
	      break;

	    case KEY_UP:
	      focus--;
	      break;
	    case KEY_DOWN:
	      focus++;
	      break;
	    }
	  break;


	case 5:		/* string */
	  stringinput_stdkeys (in_ch, &string);
	  if (in_ch == KEY_ENTER || in_ch == 13)
	    {
	      strcpy (helpstring, string.string);

	      /* cut away last '/'-s */
	      while (strlen (helpstring) > 0 &&
		     helpstring[strlen (helpstring) - 1] == '/')
		helpstring[strlen (helpstring) - 1] = '\0';

	      strcat (helpstring, "/");

	      if (!stat (helpstring, &filestats) &&
		  S_ISDIR (filestats.st_mode))
		{
		  strcpy (startdir, helpstring);
		  scrollmenu_delete_menu (&dirfilelist);
		  dirfilemenu (startdir, &dirfilelist);
		  dirfilelist.firstonscreen = 0;
		  dirfilelist.selected =
		    dirfilelist.last_of_1st_part + 1;
		  strcpy (string.string, startdir);
		  string.cursorpos = strlen (string.string);
		  focus = 0;
		}
	      else
		/* it's a file */
		{
		  focus = 7;

		  if (!stat (string.string, &buf))
		    {
		      *begintime = 0;
		      if (buf.st_size < sizeof (wavhead))
			*endtime = 0;
		      else
			*endtime = (buf.st_size - sizeof (wavhead))
			  / (2 * 2 * 44100.);

		      fsec2hmsf (*begintime, begintimestring.string);
		      begintimestring.cursorpos =
			strlen (begintimestring.string);
		      begintimestring.firstcharonscreen = 0;

		      fsec2hmsf (*endtime, endtimestring.string);
		      endtimestring.cursorpos = strlen (endtimestring.string);
		      endtimestring.firstcharonscreen = 0;
		    }
		}
	    }
	  else
	    switch (in_ch)
	      {
	      case KEY_UP:
		focus--;
		break;
	      case KEY_DOWN:
		focus++;
		break;
	      }
	  break;

	case 6:		/* Cancel */
	  if (in_ch == KEY_ENTER || in_ch == 13)
	    {
	      returnval = 0;
	      dont_stop = FALSE;
	    }
	  else
	    switch (in_ch)
	      {
	      case KEY_LEFT:
	      case KEY_UP:
		focus--;
		break;
	      case KEY_RIGHT:
	      case KEY_DOWN:
		focus++;
		break;
	      }
	  break;

	case 7:		/* OK */
	  if (in_ch == KEY_ENTER || in_ch == 13)
	    {
	      strcpy (tempstring, begintimestring.string);
	      if (!hmsf2fsec (tempstring, &tempdouble))
		{
		  error_window ("Enter the begin time in the format hours:\
minutes:seconds.fractions, for example 0:04:26.740");
		  begintimestring.cursorpos =
		    strlen (begintimestring.string);
		  focus = 3;
		  break;
		}

	      *begintime = tempdouble;

	      strcpy (tempstring, endtimestring.string);
	      if (!hmsf2fsec (tempstring, &tempdouble))
		{
		  error_window ("Enter the end time in the format hours:\
minutes:seconds.fractions, for example 0:04:26.740");
		  endtimestring.cursorpos =
		    strlen (endtimestring.string);
		  focus = 4;
		  break;
		}

	      *endtime = tempdouble;

	      if (*begintime > *endtime)
		{
		  error_window ("The begin time is larger than the end time.");
		  fsec2hmsf (*begintime, begintimestring.string);
		  begintimestring.cursorpos =
		    strlen (begintimestring.string);
		  fsec2hmsf (*endtime, endtimestring.string);
		  endtimestring.cursorpos =
		    strlen (endtimestring.string);
		  focus = 3;
		  break;
		}

	      switch (checkfile (string.string))
		{
		case FILE_EXISTS:
		  /* strcpy (selectedfile, string.string);
		     returnval = 1;
		     dont_stop = FALSE; */

		  playwav_playit (string.string, *usebeginendtime, *begintime,
				  *endtime);
		  break;

		case DIR_EXISTS:
		  error_window ("The specified name is of a directory. A \
file name must be specified.");
		  string.cursorpos = strlen (string.string);
		  focus = 5;
		  break;

		case DIR_OK_NEW_FILE:
		case DIR_WRONG:
		  error_window ("The specified file does not exist.");
		  string.cursorpos = strlen (string.string);
		  focus = 5;
		  break;

		default:
		  error_window ("Fell out of switch, playwav #1");
		  break;
		}

	    }			/* if ENTER */
	  else
	    switch (in_ch)
	      {
	      case KEY_LEFT:
	      case KEY_UP:
		focus--;
		break;
	      case KEY_RIGHT:
	      case KEY_DOWN:
		focus++;
		break;
	      }
	  break;
	}

      if (in_ch == 9)		/* TAB */
	focus++;

      if (in_ch == 27)
	dont_stop = FALSE;

      if (focus > 7)
	focus = 0;
      if (focus < 0)
	focus = 7;
    }
  while (dont_stop);

  scrollmenu_delete_menu (&dirfilelist);
  free (string.string);

  return returnval;
}

void
playwav_main (char *startdir)
{
  char filename[250];
/*  char shellcmd[500]; */
  int usebeginendtime = 0;
  double begintime = 0, endtime = 0;

  filename[0] = '\0';

  while (1)
    {
      if (!playwav_select_file (startdir, filename, &usebeginendtime,
				&begintime, &endtime))
	return;

#if 0
/* not used any more - integrated in select_file */
      def_prog_mode ();		/* save terminal state */

      if (usebeginendtime)
	sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld %s",
		 (long) (begintime * 44100),
		 (long) ((endtime - begintime) * 44100), filename);
      else
	sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 %s", filename);
      /* defaults for raw files (but no -r, so .wav's supply their own
         parameters */

      system (shellcmd);

      reset_prog_mode ();	/* reset terminal state */
#endif /* 0 */

    }
}