reverted:
--- gramofile-1.6/debian/20-Makefile.dpatch
+++ gramofile-1.6.orig/debian/20-Makefile.dpatch
@@ -1,14 +0,0 @@
-# Unknown decent. Probably from previous maintainer? Not sure why it's
-# needed anyway. [dk]
-#PATCHOPTIONS: -p1
---- gramofile-1.6.orig/Makefile.orig	Sat May  5 16:32:40 2001
-+++ gramofile-1.6/Makefile	Sat May  5 16:32:53 2001
-@@ -50,7 +50,7 @@
- makebplay: yesnowindow.o boxes.o buttons.o textwindow.o errorwindow.o \
-            clrscr.o secshms.o
- 	$(MAKE) -C bplaysrc
--	-rm bplay_gramo brec_gramo
-+	-rm -f bplay_gramo brec_gramo
- 	cp $(COPY_A) bplaysrc/bplay ./bplay_gramo
- 	ln -s bplay_gramo brec_gramo
- 
reverted:
--- gramofile-1.6/debian/20-no-busy-wait-after-rec.dpatch
+++ gramofile-1.6.orig/debian/20-no-busy-wait-after-rec.dpatch
@@ -1,13 +0,0 @@
-# Do not busy wait for confirmation after recording. [dk]
-#PATCHOPTIONS: -p0
---- bplaysrc/shmbuf.c.orig	2005-03-01 16:48:14.000000000 +0100
-+++ bplaysrc/shmbuf.c	2005-03-01 16:48:31.000000000 +0100
-@@ -443,7 +443,7 @@
- 	cleanupsems();
- 
- #ifdef VUMETER
--	nodelay(stdscr, TRUE);
-+	nodelay(stdscr, FALSE);
- 
- 	/* child has displayed informative data */
- 	do
reverted:
--- gramofile-1.6/debian/20-overflow-fixes.dpatch
+++ gramofile-1.6.orig/debian/20-overflow-fixes.dpatch
@@ -1,59 +0,0 @@
-# Patch by James Tappin <james@xena.uklinux.net>
-# Rediffed into unified format. [dk]
-#PATCHOPTIONS: -p1
-diff -ur gramofile-1.6.orig/signpr_cmf2.c gramofile-1.6/signpr_cmf2.c
---- gramofile-1.6.orig/signpr_cmf2.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/signpr_cmf2.c	Fri Jun  8 10:35:39 2001
-@@ -646,19 +646,25 @@
- 
-   /* Should be /64, but the signal is extremely soft, so divide by less to
-      get more quantization levels (more accurate) */
--  sum.left /= 10;
--  sum.right /= 10;
-+  sum.left /= 4;
-+  sum.right /= 4;
- #endif
- 
--  if (sum.left < 32767)
--    sample.left = sum.left;
--  else
-+  if (sum.left > 32767)
-     sample.left = 32767;
--
--  if (sum.right < 32767)
--    sample.right = sum.right;
-+  else if (sum.left < -32768)
-+    sample.left = -32768;
-   else
-+    sample.left = sum.left;
-+
-+
-+  if (sum.right > 32767)
-     sample.right = 32767;
-+  else if (sum.right < -32768)
-+    sample.right = -32768;
-+  else 
-+    sample.right = sum.right;
-+
- 
-   return sample;
- }
-@@ -762,6 +768,9 @@
-     b_t.left;
-   if (i > 32767)
-     i = 32767;
-+  else if (i < -32768)
-+    i = -32768;
-+
-   returnval.left = i;
- 
-   i = (labs (w_t.right - b_t.right) * 1000)
-@@ -769,6 +778,8 @@
-     b_t.right;
-   if (i > 32767)
-     i = 32767;
-+  else if (i < -32768)
-+    i = -32768;
-   returnval.right = i;
- 
-   return returnval;
reverted:
--- gramofile-1.6/debian/20-shell-quoting.dpatch
+++ gramofile-1.6.orig/debian/20-shell-quoting.dpatch
@@ -1,45 +0,0 @@
-#Patch by Jon Schewe <jpschewe@eggplant.mtu.net>
-#PATCHOPTIONS: -p1
-diff -ur gramofile-1.6P.orig/playwav.c gramofile-1.6P/playwav.c
---- gramofile-1.6P.orig/playwav.c	Tue Mar 28 15:07:25 2000
-+++ gramofile-1.6P/playwav.c	Wed Dec 27 11:17:25 2000
-@@ -44,11 +44,11 @@
-     case FILE_EXISTS:
- 
-       if (usebeginendtime)
--	sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld %s",
-+	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);
-+	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 (: */
- 
-@@ -771,11 +771,11 @@
-       def_prog_mode ();		/* save terminal state */
- 
-       if (usebeginendtime)
--	sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld %s",
-+	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);
-+	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 */
- 
-diff -ur gramofile-1.6P.orig/reclp_main.c gramofile-1.6P/reclp_main.c
---- gramofile-1.6P.orig/reclp_main.c	Tue Mar 28 15:07:25 2000
-+++ gramofile-1.6P/reclp_main.c	Wed Dec 27 01:17:45 2000
-@@ -30,7 +30,7 @@
- 
-   def_prog_mode ();		/* save terminal state */
- 
--  sprintf (shellcmd, "brec_gramo -S -s 44100 -b 16 -t 6000 -w %s",
-+  sprintf (shellcmd, "brec_gramo -S -s 44100 -b 16 -t 6000 -w \"%s\"",
- 	   filename);
-   system (shellcmd);
- 
reverted:
--- gramofile-1.6/debian/20-via-kludge.dpatch
+++ gramofile-1.6.orig/debian/20-via-kludge.dpatch
@@ -1,31 +0,0 @@
-# Patch by Joerg Specht <joerg.specht@ins.uni-stuttgart.de>
-# Cleaned up some cruft in @@ lines--weird. [dk]
-#PATCHOPTIONS: -p1
---- gramofile-1.6/bplaysrc/sndfunc.c.ori	Wed Mar 21 22:29:27 2001
-+++ gramofile-1.6/bplaysrc/sndfunc.c	Wed Mar 21 22:40:04 2001
-@@ -22,6 +22,7 @@
- 
- /* Globals */
- int audio, abuf_size, fmt_mask;
-+int audio_recorder;
- 
- /* Prototypes */
- void sync_audio(void);
-@@ -36,6 +37,7 @@
- void init_sound(int recorder)
- {
-     /* Attempt to open the audio device */
-+    audio_recorder = recorder;
-     audio = open(AUDIO, (recorder)? O_RDONLY : O_WRONLY);
-     if (audio == -1)
- 	ErrDie(AUDIO);
-@@ -76,6 +78,9 @@
- 
- void sync_audio(void)
- {
-+    /* at least Linux' via82cxxx_audio-driver reports error	*/
-+    /* when trying to SNDCTL_DSP_SYNC in O_RDONLY mode		*/
-     if (ioctl (audio, SNDCTL_DSP_SYNC, NULL) < 0)
-+      if (!audio_recorder)
- 	ErrDie(AUDIO);
- }
reverted:
--- gramofile-1.6/debian/20-warning-fixes.dpatch
+++ gramofile-1.6.orig/debian/20-warning-fixes.dpatch
@@ -1,199 +0,0 @@
-# Patch by Tom Harvey <TomHarvey@IndustryFigure.com>
-# Rediffed. [dk]
-# Also changed return type of bplay.c. [dk]
-#PATCHOPTIONS: -p1
-diff -ur gramofile-1.6.orig/bplaysrc/bplay.c gramofile-1.6/bplaysrc/bplay.c
---- gramofile-1.6.orig/bplaysrc/bplay.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/bplaysrc/bplay.c	Fri Jun  8 10:06:42 2001
-@@ -91,7 +91,7 @@
- extern void cleanupsems(void);
- 
- 
--void main(int argc, char *argv[])
-+int main(int argc, char *argv[])
- {
- 	
- 	int recorder = 0;		/* 1 if recording, 0 else */
-@@ -398,6 +398,7 @@
- 	}
- 
- 	finish_curses(0);
-+	exit(0);	/* Not reached, but keeps compiler happy. */
- }
- 
- void Usage(void)
-diff -ur gramofile-1.6.orig/clrscr.c gramofile-1.6/clrscr.c
---- gramofile-1.6.orig/clrscr.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/clrscr.c	Fri Jun  8 10:02:42 2001
-@@ -8,6 +8,7 @@
-  */
- 
- #include "clrscr.h"
-+#include <string.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
- #else
-diff -ur gramofile-1.6.orig/errorwindow.c gramofile-1.6/errorwindow.c
---- gramofile-1.6.orig/errorwindow.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/errorwindow.c	Fri Jun  8 10:02:42 2001
-@@ -11,6 +11,8 @@
- #include "buttons.h"
- #include "boxes.h"
- #include "textwindow.h"
-+
-+#include <string.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
- #else
-diff -ur gramofile-1.6.orig/gramofile.c gramofile-1.6/gramofile.c
---- gramofile-1.6.orig/gramofile.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/gramofile.c	Fri Jun  8 10:02:42 2001
-@@ -42,7 +42,7 @@
-   exit (0);
- }
- 
--void
-+int
- main (void)
- {
-   char startdir[250];
-@@ -63,4 +63,5 @@
-   mainmenu (startdir);
- 
-   finishmenu (0);
-+  return 0;
- }
-diff -ur gramofile-1.6.orig/mainmenu.c gramofile-1.6/mainmenu.c
---- gramofile-1.6.orig/mainmenu.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/mainmenu.c	Fri Jun  8 10:02:42 2001
-@@ -21,6 +21,7 @@
- #include "tracksplit.h"
- #include <stdlib.h>
- #include <unistd.h>
-+#include <string.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
- #else
-diff -ur gramofile-1.6.orig/signpr_cmf.c gramofile-1.6/signpr_cmf.c
---- gramofile-1.6.orig/signpr_cmf.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/signpr_cmf.c	Fri Jun  8 10:02:42 2001
-@@ -30,6 +30,7 @@
- #include "yesnowindow.h"
- #include <stdlib.h>
- #include <stdio.h>
-+#include <string.h>
- #include <math.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
-@@ -88,8 +89,8 @@
-   {
-     " ^: no neat interpolation.              v: broad ticks not filtered out.       ",
-     " ^: less ticks detected.                v: not all of tick interpolated.       ",
--    " ^: bad following of dynamics.          v: less ticks detected.                ",
--    " ^: bad following of dynamics.          v: less ticks detected.                ",
-+    " ^: bad following of dynamics.          v: fewer ticks detected.               ",
-+    " ^: bad following of dynamics.          v: fewer ticks detected.               ",
-     " ^: only strong ticks detected.         v: music-ticks also filtered out.      ",
-     " Discard changes.                                                              ",
-     " Reset default values.                                                         ",
-diff -ur gramofile-1.6.orig/signpr_cmf2.c gramofile-1.6/signpr_cmf2.c
---- gramofile-1.6.orig/signpr_cmf2.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/signpr_cmf2.c	Fri Jun  8 10:02:42 2001
-@@ -32,6 +32,7 @@
- #include "yesnowindow.h"
- #include <stdlib.h>
- #include <stdio.h>
-+#include <string.h>
- #include <math.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
-@@ -90,9 +91,9 @@
- 
-   char *helplines[8] =
-   {
--    " ^: less ticks detected.                v: not all of tick interpolated.       ",
--    " ^: bad following of dynamics.          v: less ticks detected.                ",
--    " ^: bad following of dynamics.          v: less ticks detected.                ",
-+    " ^: fewer ticks detected.               v: not all of tick interpolated.       ",
-+    " ^: bad following of dynamics.          v: fewer ticks detected.               ",
-+    " ^: bad following of dynamics.          v: fewer ticks detected.               ",
-     " ^: detected tick length too short      v: detected tick length longer.        ",
-     " ^: only strong ticks detected.         v: music-ticks also filtered out.      ",
-     " Discard changes.                                                              ",
-diff -ur gramofile-1.6.orig/signpr_doubmed.c gramofile-1.6/signpr_doubmed.c
---- gramofile-1.6.orig/signpr_doubmed.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/signpr_doubmed.c	Fri Jun  8 10:02:42 2001
-@@ -17,6 +17,7 @@
- #include "helpline.h"
- #include <stdlib.h>
- #include <stdio.h>
-+#include <string.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
- #else
-diff -ur gramofile-1.6.orig/signpr_mean.c gramofile-1.6/signpr_mean.c
---- gramofile-1.6.orig/signpr_mean.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/signpr_mean.c	Fri Jun  8 10:02:42 2001
-@@ -17,6 +17,7 @@
- #include "helpline.h"
- #include <stdlib.h>
- #include <stdio.h>
-+#include <string.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
- #else
-diff -ur gramofile-1.6.orig/signpr_median.c gramofile-1.6/signpr_median.c
---- gramofile-1.6.orig/signpr_median.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/signpr_median.c	Fri Jun  8 10:02:42 2001
-@@ -17,6 +17,7 @@
- #include "helpline.h"
- #include <stdlib.h>
- #include <stdio.h>
-+#include <string.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
- #else
-diff -ur gramofile-1.6.orig/signpr_rms.c gramofile-1.6/signpr_rms.c
---- gramofile-1.6.orig/signpr_rms.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/signpr_rms.c	Fri Jun  8 10:02:42 2001
-@@ -17,6 +17,7 @@
- #include "helpline.h"
- #include <stdlib.h>
- #include <stdio.h>
-+#include <string.h>
- #include <math.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
-diff -ur gramofile-1.6.orig/stringinput.c gramofile-1.6/stringinput.c
---- gramofile-1.6.orig/stringinput.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/stringinput.c	Fri Jun  8 10:02:42 2001
-@@ -8,6 +8,7 @@
-  */
- 
- #include "stringinput.h"
-+#include <string.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
- #else
-diff -ur gramofile-1.6.orig/tracksplit_parammenu.c gramofile-1.6/tracksplit_parammenu.c
---- gramofile-1.6.orig/tracksplit_parammenu.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/tracksplit_parammenu.c	Fri Jun  8 10:02:42 2001
-@@ -16,6 +16,7 @@
- #include "helpline.h"
- #include <stdlib.h>
- #include <stdio.h>
-+#include <string.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
- #else
-diff -ur gramofile-1.6.orig/yesnowindow.c gramofile-1.6/yesnowindow.c
---- gramofile-1.6.orig/yesnowindow.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/yesnowindow.c	Fri Jun  8 10:02:42 2001
-@@ -11,6 +11,7 @@
- #include "buttons.h"
- #include "boxes.h"
- #include "textwindow.h"
-+#include <string.h>
- #ifndef OLD_CURSES
- #include <ncurses.h>
- #else
reverted:
--- gramofile-1.6/debian/30-basename-fix.dpatch
+++ gramofile-1.6.orig/debian/30-basename-fix.dpatch
@@ -1,68 +0,0 @@
-# <30-basename-fix.dpatch> by Daniel Kobras <kobras@debian.org>
-#
-# Use the POSIX basename(3), get rid of private prototype that wasn't used
-# anyway. Remove the now unneeded REDHAT50 define from the Makefile.
-#
-# Explanation: Previously, the code used glibc's basename but didn't realise
-# it was a GNU extension. Alternatively, one could define _GNU_SOURCE, but
-# I opted for the--hopefully--more portable POSIX version. (Unlike the GNU
-# version, the POSIX version may potentially modify its argument.)
-#
-#PATCHOPTIONS: -p1
---- gramofile-1.6.orig/bplaysrc/bplay.c	2001-05-05 16:13:55.000000000 +0200
-+++ gramofile-1.6/bplaysrc/bplay.c	2004-01-07 18:34:49.000000000 +0100
-@@ -20,6 +20,10 @@
- #include <sys/time.h>
- #include <sys/resource.h>
- 
-+#ifdef linux
-+#include <libgen.h>
-+#endif
-+
- #ifndef __FreeBSD__
- #include <sys/soundcard.h>
- #else
-@@ -53,16 +57,6 @@
- 
- /* Prototypes */
- 
--#ifdef linux
--/* This is in libc, but not in the header files. -- but it IS in
--   Red Hat 5.0.... Libc6?
--   well i'd guess its not in the headers because its nonstandard, i.e.
--   (probably) only exists on linux...  -nox */
--#ifndef REDHAT50
--extern char *basename(char *name);
--#endif
--#endif
--
- void Usage(void);
- void ErrDie(char *err);
- void Die(char *err);
-@@ -107,11 +101,14 @@
- 	sndf_t filetype;		/* The file type */
- 	int mods;			/* So user can override */
- 	int optc;			/* For getopt */
-+	char *tmp = NULL;		/* Do not clobber argv[0] */
- 
- 	init_curses();
- 
- #ifdef linux
--	progname = basename(argv[0]);	/* For errors */
-+	tmp = strdup(argv[0]);		/* POSIX basename may modify its arg */
-+	progname = basename(tmp);	/* For errors */
-+	free(tmp);
- #else
- 	progname = strrchr(argv[0], '/');  /* Replacement for e.g. FreeBSD */
- 	if (!progname || !*++progname)
---- gramofile-1.6.orig/bplaysrc/Makefile	2001-05-05 16:13:55.000000000 +0200
-+++ gramofile-1.6/bplaysrc/Makefile	2004-01-07 19:08:31.000000000 +0100
-@@ -12,7 +12,7 @@
- ########## CHOOSE YOUR ARCHITECTURE:    (NOTE: also see ../Makefile!)
- 
- # For Linux (and maybe others), use these:
--CFLAGS = -Wall -O2 -DUSEBUFFLOCK -DREDHAT50 -DLP2CD -DVUMETER # -DDEBUG
-+CFLAGS = -Wall -O2 -DUSEBUFFLOCK -DLP2CD -DVUMETER # -DDEBUG
- LIBS = -lncurses
- 
- # For FreeBSD (and maybe others), use these:
reverted:
--- gramofile-1.6/debian/40-fast-swap-and-buffer.dpatch
+++ gramofile-1.6.orig/debian/40-fast-swap-and-buffer.dpatch
@@ -1,151 +0,0 @@
-# Patch by J. Dru Lemley.
-#PATCHOPTIONS: -p1
-diff -Nuar gramofile-1.6/Makefile mygramofile-1.6/Makefile
---- gramofile-1.6/Makefile	Tue Mar 28 14:23:58 2000
-+++ mygramofile-1.6/Makefile	Fri Mar  2 11:51:15 2001
-@@ -19,7 +19,7 @@
- ########## CHOOSE YOUR ARCHITECTURE:    (NOTE: also see bplaysrc/Makefile!)
- 
- # For Linux (and maybe others), use these:
--CFLAGS = -Wall -O2 -DTURBO_MEDIAN -DTURBO_BUFFER
-+CFLAGS = -Wall -O2 -funroll-loops -DTURBO_MEDIAN -DTURBO_BUFFER
- DEPS = $(OBJS) makebplay
- LIBS = -lncurses -lm
- COPY_A = -a
-diff -Nuar gramofile-1.6/endian.h mygramofile-1.6/endian.h
---- gramofile-1.6/endian.h	Thu Mar 29 22:17:08 2001
-+++ mygramofile-1.6/endian.h	Thu Mar 29 21:37:41 2001
-@@ -10,4 +10,10 @@
- extern uint32_t SwapFourBytes (uint32_t);
- extern sample_t SwapSample (sample_t);
- 
-+/* macro to swap endianness of values in a sample_t with */
-+/* a few 32-bit operations -- very fast                  */
-+#define SWAPSAMPLEREF(s) *((uint32_t *)(s)) = \
-+	((*((uint32_t *)(s)) & 0xff00ff00) >> 8) | \
-+	((*((uint32_t *)(s)) & 0x00ff00ff) << 8)
-+
- #endif
-diff -Nuar gramofile-1.6/signpr_wav.c mygramofile-1.6/signpr_wav.c
---- gramofile-1.6/signpr_wav.c	Tue Mar 28 15:07:26 2000
-+++ mygramofile-1.6/signpr_wav.c	Thu Mar 29 21:38:28 2001
-@@ -22,6 +22,8 @@
- /* ----- SOURCE & READING -------------------------------------------------- */
- 
- FILE *sourcefile;
-+int num_read_samples_buffered = 0;
-+sample_t readsamplebuffer[44100];
- 
- int
- openwavsource (char *filename)
-@@ -106,6 +108,7 @@
-     }
- 
-   /* Well, everything seems to be OK */
-+  num_read_samples_buffered = 0;
-   return 1;
- }
- 
-@@ -113,6 +116,7 @@
- closewavsource ()
- {
-   fclose (sourcefile);
-+  num_read_samples_buffered = 0; 
- }
- 
- int
-@@ -121,6 +125,9 @@
- {
-   struct stat buf;
- 
-+  /* throw away buffer on fseek */
-+  num_read_samples_buffered = 0; 
-+
-   if (fstat (fileno (sourcefile), &buf))
-     return 0;
- 
-@@ -135,22 +142,28 @@
- 
- sample_t
- readsamplesource ()
--{
--  sample_t sample;
--
--  if (fread (&sample, 1, 4, sourcefile) != 4)
--    {
--      /* reading after end of file - this just happens when using
--         pre-read buffers! */
--      sample.left = 0;
--      sample.right = 0;
--    }
-+{ 
-+  /* millions of calls to fread sure slow things down.... buffer it a little */
-+  static int i;
-+
-+  if (i >= num_read_samples_buffered)
-+  {  
-+    num_read_samples_buffered = fread(readsamplebuffer, 4, sizeof(readsamplebuffer)/4, sourcefile); 
-+    i = 0; 
-+    if (!num_read_samples_buffered)
-+      {
-+        /* reading after end of file - this just happens when using
-+           pre-read buffers! */
-+        readsamplebuffer[0].left = 0;
-+        readsamplebuffer[0].right = 0;
-+    	return readsamplebuffer[0];
-+      }
-+  }
- 
- #ifdef SWAP_ENDIAN
--  sample = SwapSample (sample);
-+  SWAPSAMPLEREF (readsamplebuffer+i);
- #endif
--
--  return sample;
-+  return readsamplebuffer[i++];
- }
- 
- 
-@@ -158,6 +171,8 @@
- 
- FILE *destfile;
- int destfileispipe;		/* remember open() - - -> close() */
-+int num_write_samples_buffered = 0;
-+sample_t writesamplebuffer[44100];
- 
- int
- openwavdest (char *filename, long bcount)
-@@ -216,12 +231,20 @@
- 
-   fwrite (&header, sizeof (header), 1, destfile);
- 
-+  num_write_samples_buffered = 0;  /* just in case */
-   return 1;
- }
- 
-+void flushwritebuffer()
-+{ 
-+	fwrite(writesamplebuffer, 4 * num_write_samples_buffered, 1, destfile); 
-+	num_write_samples_buffered = 0;
-+}
-+
- void
- closewavdest ()
- {
-+  flushwritebuffer(); 
-   if (destfileispipe)
-     pclose (destfile);
-   else
-@@ -233,8 +256,9 @@
- {
- 
- #ifdef SWAP_ENDIAN
--  sample = SwapSample (sample);
-+  SWAPSAMPLEREF(&sample);
- #endif
--
--  fwrite (&sample, 4, 1, destfile);
-+  if (num_write_samples_buffered == (sizeof (writesamplebuffer) / 4))
-+	flushwritebuffer(); 
-+  writesamplebuffer[num_write_samples_buffered++] = sample;
- }
reverted:
--- gramofile-1.6/debian/50-cmf3.dpatch
+++ gramofile-1.6.orig/debian/50-cmf3.dpatch
@@ -1,1329 +0,0 @@
-# Patch by James Tappin <james@xena.uklinux.net>
-# Rediffed to unified format. [dk]
-# Case changes to name of doc file to comply with rest of docs. [dk]
-#PATCHOPTIONS: -p1
-diff -urN gramofile-1.6.orig/Makefile gramofile-1.6/Makefile
---- gramofile-1.6.orig/Makefile	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/Makefile	Fri Jun  8 10:40:18 2001
-@@ -7,7 +7,8 @@
-         signpr_general.c signpr_median.c signpr_filtmenu.c signpr_wav.c	\
- 	secshms.c playwav.c signpr_cmf.c signpr_mean.c signpr_doubmed.c	\
- 	splashscr.c tracksplit.c tracksplit_filenm.c			\
--        tracksplit_parammenu.c signpr_cmf2.c signpr_rms.c signpr_copy.c	\
-+        tracksplit_parammenu.c signpr_cmf2.c  signpr_cmf3.c             \
-+	signpr_rms.c signpr_copy.c	\
-         signpr_exper.c endian.c signpr_mono.c signpr_l1fit.c
- 
- OBJS = $(SRCS:.c=.o)
-@@ -21,19 +22,19 @@
- # For Linux (and maybe others), use these:
- CFLAGS = -Wall -O2 -DTURBO_MEDIAN -DTURBO_BUFFER
- DEPS = $(OBJS) makebplay
--LIBS = -lncurses -lm
-+LIBS = -lncurses -lrfftw -lfftw -lm
- COPY_A = -a
- 
- # For FreeBSD (and maybe others), use these:
- #CFLAGS = -Wall -O2 -DTURBO_MEDIAN -DTURBO_BUFFER
- #DEPS = $(OBJS) makebplay
--#LIBS = -lncurses -lm
-+#LIBS = -lncurses  -lrfftw -lfftw -lm
- #COPY_A = -p
- 
- # For IRIX (and maybe others), use these:
- #CFLAGS = -Wall -O2 -DTURBO_MEDIAN -DTURBO_BUFFER -DSWAP_ENDIAN -DOLD_CURSES
- #DEPS = $(OBJS)
--#LIBS = -lcurses -lm
-+#LIBS = -lcurses  -lrfftw -lfftw -lm
- #COPY_A = -a
- 
- ##########
-diff -urN gramofile-1.6.orig/Signpr_cmf3.txt gramofile-1.6/Signpr_cmf3.txt
---- gramofile-1.6.orig/Signpr_cmf3.txt	Thu Jan  1 01:00:00 1970
-+++ gramofile-1.6/Signpr_cmf3.txt	Fri Jun  8 10:40:18 2001
-@@ -0,0 +1,42 @@
-+SIGNPR_CMF3
-+===========
-+
-+James Tappin: April 2001
-+
-+Signpr_cmf3 is a modification of signpr_cmf2, which uses a
-+frequency-domain method to fill in the ticks.
-+
-+Why?: Because although cmf2 does an excellent job of detecting ticks,
-+it makes a horrid mess of interpolating those that are close the peak
-+of a sound wave (a situation which occurs very often on some 78's --
-+indeed on some of my record the majority of the clicks are on peaks)
-+and the resulting sound can then be worse than the original.
-+
-+What to do?: Since cmf2 does a very good job of picking out ticks that
-+bit is unchanged, my goal here was to find a way that would smooth over
-+the tick without cutting off more-or-less a half-cycle of the sound
-+wave. Since the tick is located at the peak, and zeroth (the original
-+cmf2) or first (FANCY_FILL) order interpolation will cut off the peak
-+and thus cause an acoustically unpleasant breakup of the
-+sound. Therefore I have here attempted to take a FFT of a region around
-+the tick then exclude frequencies corresponding to features of the
-+length of the tick or smaller. In the present version this is done by
-+setting the components above this frequency to zero.
-+
-+Problems: It's slow -- If I could see a way to do 1 fft per tick rather
-+than 1 fft per interpolated point it could go much quicker, but I don't
-+see that this can be done within the gramofile buffers framework.
-+
-+What does it need: The fft's are done using the "fastest fourier
-+transform in the west" http://www.fftw.org/ which attempts to find an
-+optimum  way of doing the fft for the architecture and the size of the
-+transform. In order to hold the fft plans and the length of the fft, 3
-+new fields are added to the parampointer variable.
-+
-+Settings: The tick identification algorithm is identical with that used
-+in cmf2 and the settings are therefore the same. The choice of fft
-+length is determined as: Too large a value will slow the computation
-+(remember fft is an n log(n) process), while too small a value results
-+in a poor smoothing as the side lobes of the tick are have a larger
-+effect on the values. The default is 2^9 (512).
-+
-diff -urN gramofile-1.6.orig/signpr_cmf3.c gramofile-1.6/signpr_cmf3.c
---- gramofile-1.6.orig/signpr_cmf3.c	Thu Jan  1 01:00:00 1970
-+++ gramofile-1.6/signpr_cmf3.c	Fri Jun  8 10:40:18 2001
-@@ -0,0 +1,1085 @@
-+/* Conditional Median Filter - Better Version
-+ *                             Using fft and eliminating high frequencies 
-+ *                             to fill over the ticks.
-+ *
-+ * Copyright (C) 1998 J.A. Bezemer
-+ *               2001 S.J. Tappin
-+ *
-+ * Licensed under the terms of the GNU General Public License.
-+ * ABSOLUTELY NO WARRANTY.
-+ * See the file `COPYING' in this directory.
-+ */
-+
-+/* Remove the `dont' to get the gate instead of the normal output - useful
-+   for verifying properties. */
-+#define dontVIEW_INTERNALS
-+
-+/* Choose the highpass filter: */
-+#define noSECOND_ORDER
-+#define FOURTH_ORDER
-+#define noSIXTH_ORDER
-+
-+#define noDEBUGFILE
-+
-+#include "signpr_cmf3.h"
-+#include "signpr_general.h"
-+#include "signpr_l1fit.h"
-+#include "errorwindow.h"
-+#include "stringinput.h"
-+#include "buttons.h"
-+#include "clrscr.h"
-+#include "boxes.h"
-+#include "helpline.h"
-+#include "yesnowindow.h"
-+#include <stdlib.h>
-+#include <stdio.h>
-+#include <math.h>
-+#ifndef OLD_CURSES
-+#include <ncurses.h>
-+#else
-+#include <curses.h>
-+#endif
-+
-+#ifdef DEBUGFILE
-+static FILE *debugf=NULL;
-+#endif
-+
-+#ifndef M_PIl
-+# define M_PIl          3.1415926535897932384626433832795029L  /* pi */ 
-+#endif
-+
-+void
-+cond_median3_param_defaults (parampointer_t parampointer)
-+{
-+  parampointer->postlength2 = 4;
-+  parampointer->prelength2 = 4;
-+  parampointer->postlength3 = 5;
-+  parampointer->prelength3 = 5;
-+  parampointer->postlength4 = 256;
-+  parampointer->prelength4 = 255;
-+
-+  parampointer->int1 = 12;
-+  parampointer->int2 = 9;      /* This could be derived from
-+				  postlength4 and prelength4, 
-+				  but it's messy */
-+#if defined (SECOND_ORDER)
-+  parampointer->long1 = 1000;	/* Threshold to detect precise tick length. */
-+  parampointer->long2 = 2500;	/* Must be above this to be a tick. */
-+#elif defined (FOURTH_ORDER)
-+  parampointer->long1 = 2000;
-+  parampointer->long2 = 8500;
-+#elif defined (SIXTH_ORDER)
-+  parampointer->long1 = 1500;
-+  parampointer->long2 = 7500;
-+#else
-+#error A Highpass version must be defined (signpr_cmf3.c)
-+#endif
-+
-+}
-+
-+
-+#ifdef FOURTH_ORDER
-+#undef SIGNPR_CMF3_PARAMSCR_HEADERTEXT
-+#define SIGNPR_CMF3_PARAMSCR_HEADERTEXT "CMF IIF [FOURTH ORDER] - Parameters"
-+#endif
-+
-+#ifdef SIXTH_ORDER
-+#undef SIGNPR_CMF3_PARAMSCR_HEADERTEXT
-+#define SIGNPR_CMF3_PARAMSCR_HEADERTEXT "CMF IIF [SIXTH ORDER] - Parameters"
-+#endif
-+
-+void
-+cond_median3_param_screen (parampointer_t parampointer)
-+{
-+  stringinput_t rmslengthstr, rmflengthstr, decimatestr, threshold1str;
-+  stringinput_t threshold2str, fftstr;
-+  button_t ok_button, cancel_button, defaults_button;
-+  int dont_stop = TRUE;
-+  int focus = 0;
-+  int in_ch;
-+  int i;
-+  long helplong;
-+
-+  char *helplines[9] =
-+  {
-+    " ^: less ticks detected.                v: not all of tick interpolated.       ",
-+    " ^: bad following of dynamics.          v: less ticks detected.                ",
-+    " ^: bad following of dynamics.          v: less ticks detected.                ",
-+    " ^: detected tick length too short      v: detected tick length longer.        ",
-+    " ^: only strong ticks detected.         v: music-ticks also filtered out.      ",
-+    " ^: Slower interpolation                v: possible problems with long ticks   ",
-+    " Discard changes.                                                              ",
-+    " Reset default values.                                                         ",
-+    " Accept changes.                                                               "};
-+
-+  rmslengthstr.maxlen = 500;
-+  rmslengthstr.string = (char *) malloc (rmslengthstr.maxlen *
-+					 sizeof (char));
-+  sprintf (rmslengthstr.string, "%ld", parampointer->prelength2 +
-+	   parampointer->postlength2 + 1);
-+  rmslengthstr.y = 6;
-+  rmslengthstr.x = 59;
-+  rmslengthstr.w = 19;
-+  rmslengthstr.cursorpos = strlen (rmslengthstr.string);
-+  rmslengthstr.firstcharonscreen = 0;
-+
-+  rmflengthstr.maxlen = 500;
-+  rmflengthstr.string = (char *) malloc (rmflengthstr.maxlen *
-+					 sizeof (char));
-+  sprintf (rmflengthstr.string, "%ld", parampointer->prelength3 +
-+	   parampointer->postlength3 + 1);
-+  rmflengthstr.y = 8;
-+  rmflengthstr.x = 59;
-+  rmflengthstr.w = 19;
-+  rmflengthstr.cursorpos = strlen (rmflengthstr.string);
-+  rmflengthstr.firstcharonscreen = 0;
-+
-+  decimatestr.maxlen = 500;
-+  decimatestr.string = (char *) malloc (decimatestr.maxlen *
-+					sizeof (char));
-+  sprintf (decimatestr.string, "%d", parampointer->int1);
-+  decimatestr.y = 10;
-+  decimatestr.x = 59;
-+  decimatestr.w = 19;
-+  decimatestr.cursorpos = strlen (decimatestr.string);
-+  decimatestr.firstcharonscreen = 0;
-+
-+  threshold1str.maxlen = 500;
-+  threshold1str.string = (char *) malloc (threshold1str.maxlen *
-+					  sizeof (char));
-+  sprintf (threshold1str.string, "%ld", parampointer->long1);
-+  threshold1str.y = 12;
-+  threshold1str.x = 59;
-+  threshold1str.w = 19;
-+  threshold1str.cursorpos = strlen (threshold1str.string);
-+  threshold1str.firstcharonscreen = 0;
-+
-+  threshold2str.maxlen = 500;
-+  threshold2str.string = (char *) malloc (threshold2str.maxlen *
-+					  sizeof (char));
-+  sprintf (threshold2str.string, "%ld", parampointer->long2);
-+  threshold2str.y = 14;
-+  threshold2str.x = 59;
-+  threshold2str.w = 19;
-+  threshold2str.cursorpos = strlen (threshold2str.string);
-+  threshold2str.firstcharonscreen = 0;
-+
-+  fftstr.maxlen = 500;
-+  fftstr.string = (char *) malloc (fftstr.maxlen *
-+					  sizeof (char));
-+  sprintf (fftstr.string, "%d", parampointer->int2);
-+  fftstr.y = 16;
-+  fftstr.x = 59;
-+  fftstr.w = 19;
-+  fftstr.cursorpos = strlen (fftstr.string);
-+  fftstr.firstcharonscreen = 0;
-+
-+
-+  ok_button.text = " OK ";
-+  ok_button.y = 20;
-+  ok_button.x = 71;
-+  ok_button.selected = FALSE;
-+
-+  cancel_button.text = " Cancel ";
-+  cancel_button.y = 20;
-+  cancel_button.x = 5;
-+  cancel_button.selected = FALSE;
-+
-+  defaults_button.text = " Defaults ";
-+  defaults_button.y = 20;
-+  defaults_button.x = 36;
-+  defaults_button.selected = FALSE;
-+
-+  clearscreen (SIGNPR_CMF3_PARAMSCR_HEADERTEXT);
-+
-+  do
-+    {
-+      header (SIGNPR_CMF3_PARAMSCR_HEADERTEXT);
-+
-+      if (focus == 6)
-+	cancel_button.selected = TRUE;
-+      else
-+	cancel_button.selected = FALSE;
-+
-+      if (focus == 7)
-+	defaults_button.selected = TRUE;
-+      else
-+	defaults_button.selected = FALSE;
-+
-+      if (focus == 8)
-+	ok_button.selected = TRUE;
-+      else
-+	ok_button.selected = FALSE;
-+
-+      mvprintw (3, 2,
-+       "See also the Signproc.txt file for the meaning of the parameters.");
-+
-+      stringinput_display (&rmslengthstr);
-+      mvprintw (rmslengthstr.y, 2,
-+		"Length of the RMS operation (samples):");
-+
-+      stringinput_display (&rmflengthstr);
-+      mvprintw (rmflengthstr.y, 2,
-+		"Length of the recursive median operation (samples):");
-+
-+      stringinput_display (&decimatestr);
-+      mvprintw (decimatestr.y, 2,
-+		"Decimation factor for the recursive median:");
-+
-+      stringinput_display (&threshold1str);
-+      mvprintw (threshold1str.y, 2,
-+		"Fine threshold for tick start/end (thousandths):");
-+
-+      stringinput_display (&threshold2str);
-+      mvprintw (threshold2str.y, 2,
-+		"Threshold for detection of tick presence (thousandths):");
-+
-+      stringinput_display (&fftstr);
-+      mvprintw (fftstr.y, 2,
-+		"Length for fft to interpolate (2^n):");
-+
-+      button_display (&cancel_button);
-+      mybox (cancel_button.y - 1, cancel_button.x - 1,
-+	     3, strlen (cancel_button.text) + 2);
-+      button_display (&defaults_button);
-+      mybox (defaults_button.y - 1, defaults_button.x - 1,
-+	     3, strlen (defaults_button.text) + 2);
-+      button_display (&ok_button);
-+      mybox (ok_button.y - 1, ok_button.x - 1,
-+	     3, strlen (ok_button.text) + 2);
-+
-+      helpline (helplines[focus]);
-+
-+      switch (focus)
-+	{
-+	case 0:
-+	  stringinput_display (&rmslengthstr);
-+	  break;
-+	case 1:
-+	  stringinput_display (&rmflengthstr);
-+	  break;
-+	case 2:
-+	  stringinput_display (&decimatestr);
-+	  break;
-+	case 3:
-+	  stringinput_display (&threshold1str);
-+	  break;
-+	case 4:
-+	  stringinput_display (&threshold2str);
-+	  break;
-+	case 5:
-+	  stringinput_display (&fftstr);
-+	  break;
-+	default:
-+	  move (0, 79);
-+	}
-+
-+      refresh ();
-+
-+      in_ch = getch ();
-+
-+      switch (focus)
-+	{
-+	case 0:		/* rmslengthstr */
-+	  stringinput_stdkeys (in_ch, &rmslengthstr);
-+	  switch (in_ch)
-+	    {
-+	    case KEY_ENTER:
-+	    case 13:
-+	      i = sscanf (rmslengthstr.string, "%li", &helplong);
-+	      if (i < 1 || helplong < 1 || helplong % 2 == 0)
-+		error_window ("A whole, odd number, greater than 0, must \
-+be specified.");
-+	      else
-+		focus++;
-+	      break;
-+
-+	    case KEY_UP:
-+	      focus--;
-+	      break;
-+	    case KEY_DOWN:
-+	      focus++;
-+	      break;
-+	    }
-+	  break;
-+
-+	case 1:		/* rmflengthstr */
-+	  stringinput_stdkeys (in_ch, &rmflengthstr);
-+	  switch (in_ch)
-+	    {
-+	    case KEY_ENTER:
-+	    case 13:
-+	      i = sscanf (rmflengthstr.string, "%li", &helplong);
-+	      if (i < 1 || helplong < 1 || helplong % 2 == 0)
-+		error_window ("A whole, odd number, greater than 0, must \
-+be specified.");
-+	      else
-+		focus++;
-+	      break;
-+
-+	    case KEY_UP:
-+	      focus--;
-+	      break;
-+	    case KEY_DOWN:
-+	      focus++;
-+	      break;
-+	    }
-+	  break;
-+
-+	case 2:		/* decimatestr */
-+	  stringinput_stdkeys (in_ch, &decimatestr);
-+	  switch (in_ch)
-+	    {
-+	    case KEY_ENTER:
-+	    case 13:
-+	      i = sscanf (decimatestr.string, "%li", &helplong);
-+	      if (i < 1 || helplong < 1)
-+		error_window ("A whole number, greater than 0, must \
-+be specified.");
-+	      else
-+		focus++;
-+	      break;
-+
-+	    case KEY_UP:
-+	      focus--;
-+	      break;
-+	    case KEY_DOWN:
-+	      focus++;
-+	      break;
-+	    }
-+	  break;
-+
-+	case 3:		/* threshold1str */
-+	  stringinput_stdkeys (in_ch, &threshold1str);
-+	  switch (in_ch)
-+	    {
-+	    case KEY_ENTER:
-+	    case 13:
-+	      i = sscanf (threshold1str.string, "%li", &helplong);
-+	      if (i < 1 || helplong < 1)
-+		error_window ("A whole, positive number must be specified.");
-+	      else
-+		focus++;
-+	      break;
-+
-+	    case KEY_UP:
-+	      focus--;
-+	      break;
-+	    case KEY_DOWN:
-+	      focus++;
-+	      break;
-+	    }
-+	  break;
-+
-+	case 4:		/* threshold2str */
-+	  stringinput_stdkeys (in_ch, &threshold2str);
-+	  switch (in_ch)
-+	    {
-+	    case KEY_ENTER:
-+	    case 13:
-+	      i = sscanf (threshold2str.string, "%li", &helplong);
-+	      if (i < 1 || helplong < 1)
-+		error_window ("A whole, positive number must be specified.");
-+	      else
-+		focus++;
-+	      break;
-+
-+	    case KEY_UP:
-+	      focus--;
-+	      break;
-+	    case KEY_DOWN:
-+	      focus++;
-+	      break;
-+	    }
-+	  break;
-+
-+	case 5:		/* fft length */
-+	  stringinput_stdkeys (in_ch, &fftstr);
-+	  switch (in_ch)
-+	    {
-+	    case KEY_ENTER:
-+	    case 13:
-+	      i = sscanf (fftstr.string, "%li", &helplong);
-+	      if (i < 1 || helplong > 12 || helplong < 6)
-+		error_window ("A number between 6 and 12 must be specified.");
-+	      else
-+		focus = 8;
-+	      break;
-+
-+	    case KEY_UP:
-+	      focus--;
-+	      break;
-+	    case KEY_DOWN:
-+	      focus++;
-+	      break;
-+	    }
-+	  break;
-+
-+	case 6:		/* Cancel */
-+	  switch (in_ch)
-+	    {
-+	    case KEY_ENTER:
-+	    case 13:
-+	      dont_stop = FALSE;
-+	      break;
-+
-+	    case KEY_LEFT:
-+	    case KEY_UP:
-+	      focus--;
-+	      break;
-+	    case KEY_RIGHT:
-+	    case KEY_DOWN:
-+	      focus++;
-+	      break;
-+	    }
-+	  break;
-+
-+	case 7:		/* Defaults */
-+	  switch (in_ch)
-+	    {
-+	    case KEY_ENTER:
-+	    case 13:
-+	      if (yesno_window ("Restore default parameters?", " Yes ",
-+				" No ", 0))
-+		{
-+		  cond_median3_param_defaults (parampointer);
-+		  dont_stop = FALSE;
-+		}
-+	      break;
-+
-+	    case KEY_LEFT:
-+	    case KEY_UP:
-+	      focus--;
-+	      break;
-+	    case KEY_RIGHT:
-+	    case KEY_DOWN:
-+	      focus++;
-+	      break;
-+	    }
-+	  break;
-+
-+	case 8:		/* OK */
-+	  switch (in_ch)
-+	    {
-+	    case KEY_ENTER:
-+	    case 13:
-+
-+	      i = sscanf (rmslengthstr.string, "%li", &helplong);
-+	      if (i < 1 || helplong < 1 || helplong % 2 == 0)
-+		{
-+		  error_window ("A whole, odd number, greater than 0, must \
-+be specified as RMS length.");
-+		  rmslengthstr.cursorpos =
-+		    strlen (rmslengthstr.string);
-+		  focus = 0;
-+		  break;
-+		}
-+
-+	      parampointer->prelength2 = (helplong - 1) / 2;
-+	      parampointer->postlength2 = (helplong - 1) / 2;
-+
-+	      i = sscanf (rmflengthstr.string, "%li", &helplong);
-+	      if (i < 1 || helplong < 1 || helplong % 2 == 0)
-+		{
-+		  error_window ("A whole, odd number, greater than 0, must \
-+be specified as length of the recursive median.");
-+		  rmflengthstr.cursorpos =
-+		    strlen (rmflengthstr.string);
-+		  focus = 1;
-+		  break;
-+		}
-+
-+	      parampointer->prelength3 = (helplong - 1) / 2;
-+	      parampointer->postlength3 = (helplong - 1) / 2;
-+
-+	      i = sscanf (decimatestr.string, "%li", &helplong);
-+	      if (i < 1 || helplong < 1)
-+		{
-+		  error_window ("A whole number, greater than 0, must \
-+be specified as decimation factor.");
-+		  decimatestr.cursorpos =
-+		    strlen (decimatestr.string);
-+		  focus = 2;
-+		  break;
-+		}
-+
-+	      parampointer->int1 = helplong;
-+
-+	      i = sscanf (threshold1str.string, "%li", &helplong);
-+	      if (i < 1 || helplong < 1)
-+		{
-+		  error_window ("A whole, positive number must be \
-+specified as threshold.");
-+		  threshold1str.cursorpos =
-+		    strlen (threshold1str.string);
-+		  focus = 3;
-+		  break;
-+		}
-+
-+	      parampointer->long1 = helplong;
-+
-+	      i = sscanf (threshold2str.string, "%li", &helplong);
-+	      if (i < 1 || helplong < 1000)
-+		{
-+		  error_window ("A whole, positive number must be \
-+specified as threshold.");
-+		  threshold2str.cursorpos =
-+		    strlen (threshold2str.string);
-+		  focus = 4;
-+		  break;
-+		}
-+
-+	      parampointer->long2 = helplong;
-+
-+	      i = sscanf (fftstr.string, "%li", &helplong);
-+	      if (i < 1 || helplong > 12 || helplong < 6) {
-+		error_window ("A number between 6 and 12 must be specified \
-+as fft length");
-+		fftstr.cursorpos = strlen(fftstr.string);
-+		focus = 5;
-+		break;
-+	      }
-+
-+	      parampointer->int2 = helplong;
-+	      parampointer->prelength4 = 1;
-+	      for (i=1; i < parampointer->int2; i++) parampointer->prelength4 *= 2;
-+	      parampointer->postlength4 = parampointer->prelength4-1;
-+
-+	      dont_stop = FALSE;
-+	      break;
-+
-+	    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 > 8)
-+	focus = 0;
-+      if (focus < 0)
-+	focus = 8;
-+    }
-+  while (dont_stop);
-+
-+  free (rmslengthstr.string);
-+  free (rmflengthstr.string);
-+  free (decimatestr.string);
-+  free (threshold1str.string);
-+  free (threshold2str.string);
-+}
-+
-+void
-+init_cond_median3_filter (int filterno, parampointer_t parampointer)
-+{
-+  long total_post;
-+  long total_pre;
-+  long l;
-+
-+  total_post = parampointer->postlength4 + parampointer->prelength4 + 1 + 4;
-+  /* +1+4=+5 : for highpass, max. 11th order */
-+
-+  total_pre = parampointer->postlength4 + parampointer->prelength4 + 1;
-+  l = parampointer->prelength4 + parampointer->prelength3 *
-+    parampointer->int1 + parampointer->prelength2 + 5;
-+  /* + 5 : for highpass, max. 11th order */
-+  if (l > total_pre)
-+    total_pre = l;
-+
-+  parampointer->buffer = init_buffer (total_post, total_pre);
-+  parampointer->buffer2 = init_buffer (parampointer->postlength2,
-+				       parampointer->prelength2);
-+  parampointer->buffer3 = init_buffer (parampointer->postlength3,
-+			     parampointer->prelength3 * parampointer->int1);
-+  parampointer->buffer4 = init_buffer (parampointer->postlength4,
-+				       parampointer->prelength4);
-+
-+  parampointer->filterno = filterno;
-+
-+  /* Set up the FFT plans here. Since we expect to do lots of FFTs,
-+     we take the time to MEASURE the best way to do them [SJT] */
-+
-+  parampointer->planf = rfftw_create_plan(parampointer->postlength4 +
-+					  parampointer->prelength4 + 1,
-+					  FFTW_REAL_TO_COMPLEX,
-+					  FFTW_MEASURE);
-+  parampointer->planr = rfftw_create_plan(parampointer->postlength4 +
-+					  parampointer->prelength4 + 1,
-+					  FFTW_COMPLEX_TO_REAL,
-+					  FFTW_MEASURE);
-+
-+#ifdef DEBUGFILE
-+  debugf = fopen("./gram.txt","w");
-+#endif
-+
-+
-+}
-+
-+
-+void
-+delete_cond_median3_filter (parampointer_t parampointer)
-+{
-+  delete_buffer (&parampointer->buffer);
-+  delete_buffer (&parampointer->buffer2);
-+  delete_buffer (&parampointer->buffer3);
-+  delete_buffer (&parampointer->buffer4);
-+
-+  rfftw_destroy_plan(parampointer->planf);
-+  rfftw_destroy_plan(parampointer->planr);
-+
-+#ifdef DEBUGFILE
-+  fclose(debugf);
-+#endif
-+}
-+
-+
-+sample_t
-+cond_median3_highpass (long offset, long offset_zero,
-+		       parampointer_t parampointer)
-+{
-+  sample_t sample;
-+  longsample_t sum;
-+
-+  offset += offset_zero;	/* middle for highpass filter in
-+				   'big buffer' */
-+  sum.left = 0;
-+  sum.right = 0;
-+
-+#if defined (SECOND_ORDER)
-+#define notTEST_DAVE_PLATT
-+#ifndef TEST_DAVE_PLATT
-+  /* Original: */
-+  sample = get_from_buffer (&parampointer->buffer, offset - 1);
-+  sum.left += sample.left;
-+  sum.right += sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset);
-+  sum.left -= 2 * (long) sample.left;
-+  sum.right -= 2 * (long) sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset + 1);
-+  sum.left += sample.left;
-+  sum.right += sample.right;
-+
-+  sum.left /= 4;
-+  sum.right /= 4;
-+#else /* TEST_DAVE_PLATT */
-+  /* Testing, suggested by Dave Platt. Invert phase of one channel, then
-+     do tick detection using the sum signal. This is because most ticks
-+     are out-of-phase signals. I've not really tested this - it might
-+     require other settings for thresholds etc.
-+     Note: implemented for second_order only! */
-+  sample = get_from_buffer (&parampointer->buffer, offset - 1);
-+  sum.left += sample.left;
-+  sum.left -= sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset);
-+  sum.left -= 2 * (long) sample.left;
-+  sum.left += 2 * (long) sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset + 1);
-+  sum.left += sample.left;
-+  sum.left -= sample.right;
-+
-+  /* just in case L/R: 32000/-32000 -32000/32000 32000/-32000 : */
-+  sum.left /= 8;
-+  sum.right = sum.left;
-+#endif /* TEST_DAVE_PLATT */
-+
-+#elif defined (FOURTH_ORDER)
-+  sample = get_from_buffer (&parampointer->buffer, offset - 2);
-+  sum.left += sample.left;
-+  sum.right += sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset - 1);
-+  sum.left -= 4 * (long) sample.left;
-+  sum.right -= 4 * (long) sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset);
-+  sum.left += 6 * (long) sample.left;
-+  sum.right += 6 * (long) sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset + 1);
-+  sum.left -= 4 * (long) sample.left;
-+  sum.right -= 4 * (long) sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset + 2);
-+  sum.left += sample.left;
-+  sum.right += sample.right;
-+
-+  sum.left /= 4;
-+  sum.right /= 4;
-+
-+#elif defined (SIXTH_ORDER)
-+  sample = get_from_buffer (&parampointer->buffer, offset - 3);
-+  sum.left -= sample.left;
-+  sum.right -= sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset - 2);
-+  sum.left += 6 * (long) sample.left;
-+  sum.right += 6 * (long) sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset - 1);
-+  sum.left -= 15 * (long) sample.left;
-+  sum.right -= 15 * (long) sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset);
-+  sum.left += 20 * (long) sample.left;
-+  sum.right += 20 * (long) sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset + 1);
-+  sum.left -= 15 * (long) sample.left;
-+  sum.right -= 15 * (long) sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset + 2);
-+  sum.left += 6 * (long) sample.left;
-+  sum.right += 6 * (long) sample.right;
-+  sample = get_from_buffer (&parampointer->buffer, offset + 3);
-+  sum.left -= sample.left;
-+  sum.right -= sample.right;
-+
-+  /* Should be /64, but the signal is extremely soft, so divide by less to
-+     get more quantization levels (more accurate) */
-+  sum.left /= 4;
-+  sum.right /= 4;
-+#endif
-+
-+  if (sum.left > 32767)
-+    sample.left = 32767;
-+  else if (sum.left < -32768)
-+    sample.left = -32768;
-+  else
-+    sample.left = sum.left;
-+
-+
-+  if (sum.right > 32767)
-+    sample.right = 32767;
-+  else if (sum.right < -32768)
-+    sample.right = -32768;
-+  else 
-+    sample.right = sum.right;
-+
-+
-+  return sample;
-+}
-+
-+fillfuncpointer_t cond_median3_highpass_pointer = cond_median3_highpass;
-+
-+sample_t
-+cond_median3_rms (long offset, long offset_zero,
-+		  parampointer_t parampointer)
-+{
-+  sample_t sample;
-+  doublesample_t doublesample;
-+  doublesample_t sum;
-+  long i;
-+
-+  advance_current_pos_custom (&parampointer->buffer2,
-+			      cond_median3_highpass_pointer,
-+			      offset + offset_zero,
-+			      parampointer);
-+
-+  sum.left = 0;
-+  sum.right = 0;
-+
-+  for (i = -parampointer->postlength2; i <= parampointer->prelength2;
-+       i++)
-+    {
-+      sample = get_from_buffer (&parampointer->buffer2, i);
-+      doublesample.left = sample.left;
-+      doublesample.right = sample.right;
-+      sum.left += doublesample.left * doublesample.left;
-+      sum.right += doublesample.right * doublesample.right;
-+    }
-+
-+  sum.left /= (parampointer->postlength2 +
-+	       parampointer->prelength2 + 1);
-+  sum.right /= (parampointer->postlength2 +
-+		parampointer->prelength2 + 1);
-+
-+  sample.left = sqrt (sum.left + 1);
-+  sample.right = sqrt (sum.right + 1);
-+
-+  return sample;
-+}
-+
-+fillfuncpointer_t cond_median3_rms_pointer = cond_median3_rms;
-+
-+sample_t
-+cond_median3_gate (long offset, long offset_zero,
-+		   parampointer_t parampointer)
-+/* Well, not a `gate' any more - just (w[t]-b[t])/b[t], comparision to
-+   make the real gate is done later. */
-+{
-+  sample_t sample;
-+  sample_t w_t;
-+  sample_t b_t;
-+  sample_t returnval;
-+  signed short list1[parampointer->postlength3 +
-+		     parampointer->prelength3 * parampointer->int1 + 1];
-+  signed short list2[parampointer->postlength3 +
-+		     parampointer->prelength3 * parampointer->int1 + 1];
-+  long i, j;
-+
-+  advance_current_pos_custom (&parampointer->buffer3,
-+			      cond_median3_rms_pointer,
-+			      offset + offset_zero,
-+			      parampointer);
-+
-+  w_t = get_from_buffer (&parampointer->buffer3, 0);
-+
-+  /* The RMF Filter */
-+
-+  for (i = 0; i < parampointer->postlength3; i++)
-+    {
-+      sample = get_from_buffer (&parampointer->buffer3,
-+				i - parampointer->postlength3);
-+      list1[i] = sample.left;
-+      list2[i] = sample.right;
-+    }
-+
-+  j = i;
-+
-+  for (; i <= parampointer->postlength3 +
-+       parampointer->prelength3 * parampointer->int1;
-+       i += parampointer->int1)
-+    {
-+      sample = get_from_buffer (&parampointer->buffer3,
-+				i - parampointer->postlength3);
-+      list1[j] = sample.left;
-+      list2[j] = sample.right;
-+      j++;
-+    }
-+
-+  b_t.left = median (list1, j);
-+  b_t.right = median (list2, j);
-+
-+  put_in_buffer (&parampointer->buffer3, 0, b_t);
-+
-+
-+  i = (labs (w_t.left - b_t.left) * 1000)
-+    /
-+    b_t.left;
-+  if (i > 32767)
-+    i = 32767;
-+  else if (i < -32768)
-+    i = -32768;
-+
-+  returnval.left = i;
-+
-+  i = (labs (w_t.right - b_t.right) * 1000)
-+    /
-+    b_t.right;
-+  if (i > 32767)
-+    i = 32767;
-+  else if (i < -32768)
-+    i = -32768;
-+  returnval.right = i;
-+
-+  return returnval;
-+}
-+
-+fillfuncpointer_t cond_median3_gate_pointer = cond_median3_gate;
-+
-+sample_t
-+cond_median3_filter (parampointer_t parampointer)
-+{
-+  sample_t sample, gate, returnval;
-+  /* Length of the fft we'll do to get the smoothed interpolate */
-+
-+  fftw_real list3[parampointer->postlength4 +
-+		 parampointer->prelength4 + 1];
-+  fftw_real list4[parampointer->postlength4 +
-+		 parampointer->prelength4 + 1];
-+
-+  long fft_l = parampointer->postlength4 + parampointer->prelength4 + 1;
-+  long i;
-+  int toleft, toright, nfreq;
-+  signed short maxval;
-+
-+  advance_current_pos (&parampointer->buffer, parampointer->filterno);
-+
-+  advance_current_pos_custom (&parampointer->buffer4,
-+			      cond_median3_gate_pointer,
-+			      0,
-+			      parampointer);
-+
-+  gate = get_from_buffer (&parampointer->buffer4, 0);
-+
-+#ifdef VIEW_INTERNALS
-+  returnval.left = 0;
-+  returnval.right = 0;
-+#else
-+  /* 'Default' value - unchanged if there is no tick */
-+  returnval = get_from_buffer (&parampointer->buffer, 0);
-+#endif
-+
-+  if (gate.left > parampointer->long1)
-+    {
-+      maxval = gate.left;
-+
-+      toleft = -1;
-+      sample.left = 0;
-+      do
-+	{
-+	  toleft++;
-+	  if (toleft < parampointer->postlength4)
-+	    {
-+	      sample = get_from_buffer (&parampointer->buffer4, -toleft - 1);
-+	      if (sample.left > maxval)
-+		/* if so, the `while' will continue anyway, so maxval may
-+		   be adjusted here already (if necessary) */
-+		maxval = sample.left;
-+	    }
-+	}
-+      while (toleft < parampointer->postlength4 &&
-+	     sample.left > parampointer->long1);
-+
-+      toright = -1;
-+      sample.left = 0;
-+      do
-+	{
-+	  toright++;
-+	  if (toright < parampointer->prelength4)
-+	    {
-+	      sample = get_from_buffer (&parampointer->buffer4, toright + 1);
-+	      if (sample.left > maxval)
-+		/* if so, the `while' will continue anyway, so maxval may
-+		   be adjusted here already (if necessary) */
-+		maxval = sample.left;
-+	    }
-+	}
-+      while (toright < parampointer->prelength4 &&
-+	     sample.left > parampointer->long1);
-+
-+      /* only interpolate if there really is a tick */
-+      if (maxval > parampointer->long2)
-+	{
-+
-+#ifdef VIEW_INTERNALS
-+	  returnval.left = (toright + toleft + 1) * 500;
-+#else
-+
-+	  /* Use a HANNING window here for the time being; note that
-+	     the FFT is centred at the middle of the tick not at the
-+	     point we are interpolating.  */
-+	  for (i = 0; i < fft_l; i++)
-+	    {
-+	      list3[i] = get_from_buffer(&parampointer->buffer,
-+					 i - parampointer->prelength4 +
-+					 (toright - toleft + 1)/2).left * 
-+		(2.-cos(2.*M_PIl*(double) i/ ((double) fft_l - 1.)))/2.;
-+	    }
-+	  rfftw_one(parampointer->planf, list3, list4);
-+	  nfreq=floor((double) fft_l/(double) (2*(toleft+toright+1)));
-+	  for (i = 2*nfreq; i <= fft_l - 2*nfreq; i++) list4[i] = 0.;
-+	  for (i = nfreq; i<2*nfreq && i< fft_l/2; i++) {
-+	    list4[i] *= (1. - (double) (i-nfreq)/ (double) nfreq);
-+	    list4[fft_l-i] *= (1. - (double) (i-nfreq)/ (double) nfreq);
-+	  }
-+	  rfftw_one(parampointer->planr, list4, list3);
-+	  returnval.left = (signed short) (list3[parampointer->prelength4 -
-+						(toright - toleft + 1)/2]/
-+					   (double) fft_l);
-+
-+	  /* DON'T ASK !!! -- I have NO idea why I have to MULTIPLY by 
-+	     the hanning window here. Everything sensible says DIVIDE, but
-+	     multiply works, divide doesn't */
-+
-+	  returnval.left *= (2.-cos(2.*M_PIl*(double) ((toright - toleft + 1)/2) /
-+				    ((double) fft_l - 1.)))/2.;
-+#ifdef DEBUGFILE
-+	  fprintf(debugf, "L: %ld %d %ld %ld\n",
-+		  fft_l, (toleft+toright+1), nfreq,
-+		  fft_l-nfreq);
-+#endif
-+
-+#endif
-+	}
-+    }
-+
-+  if (gate.right > parampointer->long1)
-+    {
-+      maxval = gate.right;
-+
-+      toleft = -1;
-+      sample.right = 0;
-+      do
-+	{
-+	  toleft++;
-+	  if (toleft < parampointer->postlength4)
-+	    {
-+	      sample = get_from_buffer (&parampointer->buffer4, -toleft - 1);
-+	      if (sample.right > maxval)
-+		/* if so, the `while' will continue anyway, so maxval may
-+		   be adjusted here already (if necessary) */
-+		maxval = sample.right;
-+	    }
-+	}
-+      while (toleft < parampointer->postlength4 &&
-+	     sample.right > parampointer->long1);
-+
-+      toright = -1;
-+      sample.right = 0;
-+      do
-+	{
-+	  toright++;
-+	  if (toright < parampointer->prelength4)
-+	    {
-+	      sample = get_from_buffer (&parampointer->buffer4, toright + 1);
-+	      if (sample.right > maxval)
-+		/* if so, the `while' will continue anyway, so maxval may
-+		   be adjusted here already (if necessary) */
-+		maxval = sample.right;
-+	    }
-+	}
-+      while (toright < parampointer->prelength4 &&
-+	     sample.right > parampointer->long1);
-+
-+      /* only interpolate if there really is a tick */
-+      if (maxval > parampointer->long2)
-+	{
-+
-+#ifdef VIEW_INTERNALS
-+	  returnval.right = (toright + toleft + 1) * 500;
-+#else
-+	  /* Use a HANNING window here for the time being; note that
-+	     the FFT is centred at the middle of the tick not at the
-+	     point we are interpolating.  */
-+	  for (i = 0; i < fft_l; i++)
-+	    {
-+	      list3[i] = get_from_buffer(&parampointer->buffer,
-+					 i - parampointer->prelength4 +
-+					 (toright - toleft + 1)/2).right * 
-+		(2.-cos(2.*M_PIl*(double) i/ ((double) fft_l - 1.)))/2.;
-+	    }
-+	  rfftw_one(parampointer->planf, list3, list4);
-+	  
-+	  nfreq=floor((double) fft_l/(double) (2*(toleft+toright+1)));
-+	  for (i = 2*nfreq; i <= fft_l - 2*nfreq; i++) list4[i] = 0.;
-+	  for (i = nfreq; i<2*nfreq && i<fft_l/2; i++) {
-+	    list4[i] *= (1. - (double) (i-nfreq)/ (double) nfreq);
-+	    list4[fft_l-i] *= (1. - (double) (i-nfreq)/ (double) nfreq);
-+	  }
-+
-+	  rfftw_one(parampointer->planr, list4, list3);
-+	  returnval.right = (signed short) (list3[parampointer->prelength4 -
-+						 (toright - toleft + 1)/2]/
-+					    (double) fft_l) ;
-+
-+	  /* DON'T ASK !!! -- I have NO idea why I have to MULTIPLY by 
-+	     the hanning window here. Everything sensible says DIVIDE, but
-+	     multiply works, divide doesn't */
-+
-+	  returnval.right *= (2.-cos(2.*M_PIl*(double) ((toright - toleft + 1)/2) /
-+				     ((double) fft_l - 1.)))/2.;
-+#ifdef DEBUGFILE
-+	  fprintf(debugf, "R: %ld %d %ld %ld\n",
-+		  fft_l, (toleft+toright+1), nfreq,
-+		  fft_l - nfreq);
-+#endif
-+
-+#endif
-+	}
-+    }
-+
-+  return returnval;
-+}
-diff -urN gramofile-1.6.orig/signpr_cmf3.h gramofile-1.6/signpr_cmf3.h
---- gramofile-1.6.orig/signpr_cmf3.h	Thu Jan  1 01:00:00 1970
-+++ gramofile-1.6/signpr_cmf3.h	Fri Jun  8 10:40:18 2001
-@@ -0,0 +1,29 @@
-+/* Simple Median Filter - Better Version - Header
-+
-+ * 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.
-+ */
-+
-+#ifndef HAVE_SIGNPR_CMF3_H
-+#define HAVE_SIGNPR_CMF3_H
-+
-+
-+#include "signpr_general.h"
-+
-+#define SIGNPR_CMF3_PARAMSCR_HEADERTEXT "Conditional Median Filter IIF - Parameters"
-+
-+void cond_median3_param_defaults (parampointer_t parampointer);
-+
-+void cond_median3_param_screen (parampointer_t parampointer);
-+
-+void init_cond_median3_filter (int filterno, parampointer_t parampointer);
-+
-+void delete_cond_median3_filter (parampointer_t parampointer);
-+
-+sample_t cond_median3_filter (parampointer_t parampointer);
-+
-+
-+#endif /* HAVE_SIGNPR_CMF3_H */
-diff -urN gramofile-1.6.orig/signpr_general.c gramofile-1.6/signpr_general.c
---- gramofile-1.6.orig/signpr_general.c	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/signpr_general.c	Fri Jun  8 10:40:18 2001
-@@ -14,6 +14,7 @@
- #include "signpr_wav.h"
- #include "signpr_cmf.h"
- #include "signpr_cmf2.h"
-+#include "signpr_cmf3.h"
- #include "signpr_mean.h"
- #include "signpr_doubmed.h"
- #include "signpr_rms.h"
-@@ -511,6 +512,13 @@
-   add_to_filterlist (filtlist,
- 		     filtnumbers,
- 		     helptexts,
-+		     COND_MEDIAN3_FILTER,
-+		     COND_MEDIAN3_NAME,
-+		     COND_MEDIAN3_HELPTEXT);
-+
-+  add_to_filterlist (filtlist,
-+		     filtnumbers,
-+		     helptexts,
- 		     EXPERIMENT_FILTER,
- 		     EXPERIMENT_NAME,
- 		     EXPERIMENT_HELPTEXT);
-@@ -559,6 +567,10 @@
- 	return monoize_filter (parampointerarray[filterno]);
- 	break;
- 
-+      case COND_MEDIAN3_FILTER:
-+	return cond_median3_filter (parampointerarray[filterno]);
-+	break;
-+
-       case EXPERIMENT_FILTER:
- 	return experiment_filter (parampointerarray[filterno]);
- 	break;
-@@ -615,6 +627,10 @@
- 	init_monoize_filter (i, parampointerarray[i]);
- 	break;
- 
-+      case COND_MEDIAN3_FILTER:
-+	init_cond_median3_filter (i, parampointerarray[i]);
-+	break;
-+
-       case EXPERIMENT_FILTER:
- 	init_experiment_filter (i, parampointerarray[i]);
- 	break;
-@@ -671,6 +687,10 @@
- 	delete_monoize_filter (parampointerarray[i]);
- 	break;
- 
-+      case COND_MEDIAN3_FILTER:
-+	delete_cond_median3_filter (parampointerarray[i]);
-+	break;
-+
-       case EXPERIMENT_FILTER:
- 	delete_experiment_filter (parampointerarray[i]);
- 	break;
-@@ -724,6 +744,10 @@
-       monoize_param_defaults (parampointer);
-       break;
- 
-+    case COND_MEDIAN3_FILTER:
-+      cond_median3_param_defaults (parampointer);
-+      break;
-+
-     case EXPERIMENT_FILTER:
-       experiment_param_defaults (parampointer);
-       break;
-@@ -775,6 +799,10 @@
- 
-     case MONOIZE_FILTER:
-       monoize_param_screen (parampointer);
-+      break;
-+
-+    case COND_MEDIAN3_FILTER:
-+      cond_median3_param_screen (parampointer);
-       break;
- 
-     case EXPERIMENT_FILTER:
-diff -urN gramofile-1.6.orig/signpr_general.h gramofile-1.6/signpr_general.h
---- gramofile-1.6.orig/signpr_general.h	Sat May  5 16:07:15 2001
-+++ gramofile-1.6/signpr_general.h	Fri Jun  8 10:40:18 2001
-@@ -13,6 +13,9 @@
- 
- #include "scrollmenu.h"
- 
-+/* This has to be here, otherwise the FFT interpolating filter
-+   can't keep its plans [SJT] */
-+#include <rfftw.h>
- 
- /* SAMPLES */
- 
-@@ -70,9 +73,12 @@
-     signed short *sslist1;
-     signed short *sslist2;
- 
--    int int1;
-+    int int1, int2;
-     long long1;
-     long long2;
-+
-+    rfftw_plan planf, planr;
-+
-   }
- param_t;
- 
-@@ -221,7 +227,12 @@
- #define MONOIZE_HELPTEXT        \
- "Average left & right signals."
- 
--#define EXPERIMENT_FILTER	9
-+#define COND_MEDIAN3_FILTER	9
-+#define COND_MEDIAN3_NAME	"Conditional Median Filter IIF"
-+#define COND_MEDIAN3_HELPTEXT	\
-+"Remove ticks while not changing rest of signal - Using freq domain interp."
-+
-+#define EXPERIMENT_FILTER	10
- #define EXPERIMENT_NAME		"Experimenting Filter"
- #define EXPERIMENT_HELPTEXT	\
- "The filter YOU are experimenting with (in signpr_exper.c)"
reverted:
--- gramofile-1.6/debian/60-bplay_in_gramo.dpatch
+++ gramofile-1.6.orig/debian/60-bplay_in_gramo.dpatch
@@ -1,104 +0,0 @@
-# Call bplay and brec from dedicated locations rather than from the standard
-# path. Good for the Debian package, maybe not that desirable for the
-# upstream package. [dk]
-#PATCHOPTIONS: -p0
---- playwav.c.orig	Sat May  5 16:07:15 2001
-+++ playwav.c	Mon Sep 17 18:06:03 2001
-@@ -32,23 +32,47 @@
- #include <curses.h>
- #endif
- 
-+#define BPLAYCMD "/usr/lib/gramofile/bplay_gramo"
- 
- void
- playwav_playit (char *filename, int usebeginendtime, double begintime,
- 		double endtime)
- {
--  char shellcmd[500];
--
-+  char shellcmd[500], *tmp;
-+  int len, ret;
-+  
-   switch (checkfile (filename))
-     {
-     case FILE_EXISTS:
--
-+	    
-+      tmp = shellcmd;
-+      len = 500;
-+retry:
-       if (usebeginendtime)
--	sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld \"%s\"",
-+	ret = snprintf (tmp, len,
-+	          BPLAYCMD " -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);
-+	ret = snprintf (tmp, len,
-+	                BPLAYCMD " -S -s 44100 -b 16 \"%s\"", filename);
-+
-+      if (ret > len)
-+        {
-+	   tmp = alloca(ret);
-+	   len = ret;
-+	   if (tmp)
-+	     goto retry;
-+           error_window ("The system ran out of memory");
-+	   break;
-+	}
-+	   
-+      if (ret == -1)
-+	{
-+	   error_window ("Cannot handle file names this long. Sorry.");
-+	   break;
-+	}
-+
-       /* defaults for raw files (but no -r, so .wav's supply their own
-          parameters) - you can even listen to executables in CD quality (: */
- 
---- reclp_main.c.orig	Sat May  5 16:07:15 2001
-+++ reclp_main.c	Mon Sep 17 18:05:44 2001
-@@ -18,20 +18,39 @@
- #include <curses.h>
- #endif
- 
-+#define BRECCMD "/usr/lib/gramofile/brec_gramo"
- 
- void
- record_from_lp (char *startdir)
- {
-   char filename[250];
--  char shellcmd[500];
-+  char shellcmd[500], *tmp;
-+  int ret, len;
- 
-   if (!record_from_lp_get_filename (startdir, filename))
-     return;
- 
-   def_prog_mode ();		/* save terminal state */
- 
--  sprintf (shellcmd, "brec_gramo -S -s 44100 -b 16 -t 6000 -w \"%s\"",
--	   filename);
-+  tmp = shellcmd;
-+  len = 500;
-+
-+retry:  
-+  ret = snprintf (tmp, 500, BRECCMD " -S -s 44100 -b 16 -t 6000 -w \"%s\"",
-+	          filename);
-+
-+  if (ret > len)
-+    {
-+       tmp = alloca(ret);
-+       len = ret;
-+       if (tmp)
-+         goto retry;
-+       return;
-+    }
-+
-+  if (ret == -1)
-+    return;
-+  
-   system (shellcmd);
- 
-   reset_prog_mode ();		/* reset terminal state */
reverted:
--- gramofile-1.6/debian/70-endian-fixes.dpatch
+++ gramofile-1.6.orig/debian/70-endian-fixes.dpatch
@@ -1,470 +0,0 @@
-# Fix endianness bugs in WAV and VOC headers on big-endian archs.
-# Use POSIX size types to avoid broken headers on 64bit archs.
-# Disable padding in structs that read/write raw on-disk data.
-# Merged with endianness patch by Tom Harvey <TomHarvey@IndustryFigure.com>
-# [dk]
-#PATCHOPTIONS: -p0
-Index: bplaysrc/bplay.c
-===================================================================
-RCS file: /home/kobras/cvsroot/debian/gramofile/bplaysrc/bplay.c,v
-retrieving revision 1.1.1.2
-diff -u -r1.1.1.2 bplay.c
---- bplaysrc/bplay.c	2001/05/05 14:07:15	1.1.1.2
-+++ bplaysrc/bplay.c	2005/01/31 15:54:06
-@@ -26,6 +26,30 @@
- #include <machine/soundcard.h>
- #endif
- 
-+/* Needed for BYTE_ORDER and BIG/LITTLE_ENDIAN macros. */
-+#ifndef _BSD_SOURCE
-+# define _BSD_SOURCE
-+# include <endian.h>
-+# undef  _BSD_SOURCE
-+#else
-+# include <endian.h>
-+#endif
-+
-+#include <sys/types.h>
-+#include <byteswap.h>
-+
-+/* Adapted from the byteorder macros in the Linux kernel. */
-+#if BYTE_ORDER == LITTLE_ENDIAN
-+#define cpu_to_le32(x) (x)
-+#define cpu_to_le16(x) (x)
-+#else
-+#define cpu_to_le32(x) bswap_32((x))
-+#define cpu_to_le16(x) bswap_16((x))
-+#endif
-+
-+#define le32_to_cpu(x)	cpu_to_le32((x))
-+#define le16_to_cpu(x)	cpu_to_le16((x))
-+
- #include "fmtheaders.h"
- 
- #include "../yesnowindow.h"
-@@ -290,23 +314,26 @@
- 				char *data = "data";
- 
- 				memcpy(&(header.main_chunk), riff, 4);
--				header.length = sizeof(wavhead) - 8 + bcount;
-+				header.length = cpu_to_le32(sizeof(wavhead)
-+						- 8 + bcount);
- 				memcpy(&(header.chunk_type), wave, 4);
- 
- 				memcpy(&(header.sub_chunk), fmt, 4);
--				header.sc_len = 16;
--				header.format = 1;
--				header.modus = stereo + 1;
--				header.sample_fq = speed;
--				header.byte_p_sec = ((bits > 8)? 2:1)*(stereo+1)*speed;
-+				header.sc_len = cpu_to_le32(16);
-+				header.format = cpu_to_le16(1);
-+				header.modus = cpu_to_le16(stereo + 1);
-+				header.sample_fq = cpu_to_le32(speed);
-+				header.byte_p_sec = cpu_to_le32(((bits > 8)?
-+						2:1)*(stereo+1)*speed);
- /* Correction by J.A. Bezemer: */
--				header.byte_p_spl = ((bits > 8)? 2:1)*(stereo+1);
-+				header.byte_p_spl = cpu_to_le16(((bits > 8)?
-+						2:1)*(stereo+1));
- 			/* was: header.byte_p_spl = (bits > 8)? 2:1; */
- 
--				header.bit_p_spl = bits;
-+				header.bit_p_spl = cpu_to_le16(bits);
- 
- 				memcpy(&(header.data_chunk), data, 4);
--				header.data_length = bcount;
-+				header.data_length = cpu_to_le32(bcount);
- 				write(thefd, &header, sizeof(header));
- 			}
- 		case F_RAW:
-@@ -336,9 +363,9 @@
- 
- 				for (i=0;i<20;i++)
- 					header.Magic[i] = VOC_MAGIC[i];
--				header.BlockOffset = 0x1a;
--				header.Version = 0x0114;
--				header.IDCode = 0x111F;
-+				header.BlockOffset = cpu_to_le16(0x1a);
-+				header.Version = cpu_to_le16(0x0114);
-+				header.IDCode = cpu_to_le16(0x111F);
- 				write(thefd, &header, sizeof(vochead));
- 
- 				snd_parm(speed, bits, stereo);
-@@ -349,10 +376,10 @@
- 				ablk.BlockLen[0] = (i + 12) & 0xFF;
- 				ablk.BlockLen[1] = ((i + 12) >> 8) & 0xFF;
- 				ablk.BlockLen[2] = ((i + 12) >> 16) & 0xFF;
--				bblk.SamplesPerSec = speed;
-+				bblk.SamplesPerSec = cpu_to_le32(speed);
- 				bblk.BitsPerSample = bits;
- 				bblk.Channels = stereo + 1;
--				bblk.Format = (bits == 8)? 0 : 4;
-+				bblk.Format = cpu_to_le16((bits == 8)? 0 : 4);
- 				write(thefd, &ablk, sizeof(ablk));
- 				write(thefd, &bblk, sizeof(bblk));
- 				shmrec(thefd, i, 1);
-@@ -476,6 +503,17 @@
- 
-     memcpy((void*)&wavhd, (void*)hd_buf, 20);
-     count = read(thefd, ((char*)&wavhd)+20, sizeof(wavhd) - 20);
-+
-+    wavhd.length = le32_to_cpu(wavhd.length);
-+    wavhd.sc_len = le32_to_cpu(wavhd.sc_len);
-+    wavhd.format = le16_to_cpu(wavhd.format);
-+    wavhd.modus = le16_to_cpu(wavhd.modus);
-+    wavhd.sample_fq = le32_to_cpu(wavhd.sample_fq);
-+    wavhd.byte_p_sec = le32_to_cpu(wavhd.byte_p_sec);
-+    wavhd.byte_p_spl = le16_to_cpu(wavhd.byte_p_spl);
-+    wavhd.bit_p_spl = le16_to_cpu(wavhd.bit_p_spl);
-+    wavhd.data_length = le32_to_cpu(wavhd.data_length);
-+
-     if(wavhd.format != 1) Die("Input is not a PCM WAV file");
- #ifndef LP2CD
-     if (! (mods&MSPEED))
-@@ -518,6 +556,11 @@
-     fprintf(stderr, "Playing Creative Labs Voice file ...\n");
-     memcpy((void*)&vochd, (void*)hd_buf, 20);
-     count = read(thefd, ((char*)&vochd)+20, sizeof(vochd) - 20);
-+
-+    vochd.BlockOffset = le16_to_cpu(vochd.BlockOffset);
-+    vochd.Version = le16_to_cpu(vochd.Version);
-+    vochd.IDCode = le16_to_cpu(vochd.IDCode);
-+    
-     fprintf(stderr, "Format version %d.%d\n", vochd.Version>>8,
- 	vochd.Version&0xFF);
-     if (vochd.IDCode != (~vochd.Version+0x1234))
-@@ -566,6 +609,9 @@
- 	{
- 	blockT8 tblock;
- 	read(thefd, (char*)&tblock, sizeof(tblock));
-+
-+	tblock.TimeConstant = le16_to_cpu(tblock.TimeConstant);
-+	
- 	if(tblock.PackMethod != 0) Die("Non PCM VOC block");
- 	speed = 256000000/(65536 - tblock.TimeConstant);
- 	bits = 8;
-@@ -578,6 +624,10 @@
- 	{
- 	blockT9 tblock;
- 	read(thefd, (char*)&tblock, sizeof(tblock));
-+
-+	tblock.SamplesPerSec = le32_to_cpu(tblock.SamplesPerSec);
-+	tblock.Format = le16_to_cpu(tblock.Format);
-+	
- 	if(tblock.Format != 0 && tblock.Format != 4)
- 	    Die("Non PCM VOC block");
- 	speed = tblock.SamplesPerSec;
-Index: bplaysrc/fmtheaders.h
-===================================================================
-RCS file: /home/kobras/cvsroot/debian/gramofile/bplaysrc/fmtheaders.h,v
-retrieving revision 1.1.1.1
-diff -u -r1.1.1.1 fmtheaders.h
---- bplaysrc/fmtheaders.h	2001/05/05 13:52:25	1.1.1.1
-+++ bplaysrc/fmtheaders.h	2005/01/31 15:54:06
-@@ -3,44 +3,50 @@
- 
- #include <sys/types.h>
- 
-+#ifdef __GNUC__
-+# define PACKED(x)      __attribute__((packed)) x
-+#else
-+# define PACKED(x)	x
-+#endif
-+
- /* Definitions for .VOC files */
- 
- #define VOC_MAGIC	"Creative Voice File\032"
- 
--#define DATALEN(bp)	((u_long)(bp.BlockLen[0]) | \
--                         ((u_long)(bp.BlockLen[1]) << 8) | \
--                         ((u_long)(bp.BlockLen[2]) << 16) )
-+#define DATALEN(bp)	((u_int32_t)(bp.BlockLen[0]) | \
-+                         ((u_int32_t)(bp.BlockLen[1]) << 8) | \
-+                         ((u_int32_t)(bp.BlockLen[2]) << 16) )
- 
- typedef struct vochead {
--  u_char  Magic[20];	/* must be VOC_MAGIC */
--  u_short BlockOffset;	/* Offset to first block from top of file */
--  u_short Version;	/* VOC-file version */
--  u_short IDCode;	/* complement of version + 0x1234 */
--} vochead;
-+  u_int8_t  Magic[20];	/* must be VOC_MAGIC */
-+  u_int16_t BlockOffset;	/* Offset to first block from top of file */
-+  u_int16_t Version;	/* VOC-file version */
-+  u_int16_t IDCode;	/* complement of version + 0x1234 */
-+} PACKED(vochead);
- 
- typedef struct blockTC {
--  u_char  BlockID;
--  u_char  BlockLen[3];	/* low, mid, high byte of length of rest of block */
--} blockTC;
-+  u_int8_t  BlockID;
-+  u_int8_t  BlockLen[3];	/* low, mid, high byte of length of rest of block */
-+} PACKED(blockTC);
- 
- typedef struct blockT1 {
--  u_char  TimeConstant;
--  u_char  PackMethod;
--} blockT1;
-+  u_int8_t  TimeConstant;
-+  u_int8_t  PackMethod;
-+} PACKED(blockT1);
- 
- typedef struct blockT8 {
--  u_short TimeConstant;
--  u_char  PackMethod;
--  u_char  VoiceMode;
--} blockT8;
-+  u_int16_t TimeConstant;
-+  u_int8_t  PackMethod;
-+  u_int8_t  VoiceMode;
-+} PACKED(blockT8);
- 
- typedef struct blockT9 {
--  u_int   SamplesPerSec;
--  u_char  BitsPerSample;
--  u_char  Channels;
--  u_short Format;
--  u_char   reserved[4];
--} blockT9;
-+  u_int32_t SamplesPerSec;
-+  u_int8_t  BitsPerSample;
-+  u_int8_t  Channels;
-+  u_int16_t Format;
-+  u_int8_t  reserved[4];
-+} PACKED(blockT9);
-   
- 
- 
-@@ -51,21 +57,21 @@
-    it works on all WAVE-file I have
- */
- typedef struct wavhead {
--  u_long	main_chunk;	/* 'RIFF' */
--  u_long	length;		/* Length of rest of file */
--  u_long	chunk_type;	/* 'WAVE' */
--
--  u_long	sub_chunk;	/* 'fmt ' */
--  u_long	sc_len;		/* length of sub_chunk, =16 (rest of chunk) */
--  u_short	format;		/* should be 1 for PCM-code */
--  u_short	modus;		/* 1 Mono, 2 Stereo */
--  u_long	sample_fq;	/* frequence of sample */
--  u_long	byte_p_sec;
--  u_short	byte_p_spl;	/* samplesize; 1 or 2 bytes */
--  u_short	bit_p_spl;	/* 8, 12 or 16 bit */ 
--
--  u_long	data_chunk;	/* 'data' */
--  u_long	data_length;	/* samplecount (lenth of rest of block?)*/
--} wavhead;
-+  u_int32_t	main_chunk;	/* 'RIFF' */
-+  u_int32_t	length;		/* Length of rest of file */
-+  u_int32_t	chunk_type;	/* 'WAVE' */
-+
-+  u_int32_t	sub_chunk;	/* 'fmt ' */
-+  u_int32_t	sc_len;		/* length of sub_chunk, =16 (rest of chunk) */
-+  u_int16_t	format;		/* should be 1 for PCM-code */
-+  u_int16_t	modus;		/* 1 Mono, 2 Stereo */
-+  u_int32_t	sample_fq;	/* frequence of sample */
-+  u_int32_t	byte_p_sec;
-+  u_int16_t	byte_p_spl;	/* samplesize; 1 or 2 bytes */
-+  u_int16_t	bit_p_spl;	/* 8, 12 or 16 bit */ 
-+
-+  u_int32_t	data_chunk;	/* 'data' */
-+  u_int32_t	data_length;	/* samplecount (lenth of rest of block?)*/
-+} PACKED(wavhead);
- 
- #endif
-Index: bplaysrc/sndfunc.c
-===================================================================
-RCS file: /home/kobras/cvsroot/debian/gramofile/bplaysrc/sndfunc.c,v
-retrieving revision 1.1.1.2
-diff -u -r1.1.1.2 sndfunc.c
---- bplaysrc/sndfunc.c	2001/05/05 14:07:15	1.1.1.2
-+++ bplaysrc/sndfunc.c	2005/01/31 15:54:06
-@@ -64,6 +64,9 @@
- 	sync_audio();
- 
- 	/* Set the sample speed, size and stereoness */
-+	/* We only use values of 8 and 16 for bits. This implies
-+	 * unsigned data for 8 bits, and little-endian signed for 16 bits.
-+	 */
- 	if (ioctl(audio, SNDCTL_DSP_SAMPLESIZE, &bits) < 0)
- 	    ErrDie(AUDIO);
- 	if (ioctl(audio, SNDCTL_DSP_STEREO, &stereo) < 0)
-diff -ur endian.c endian.c
---- endian.c	Sat May  5 15:52:25 2001
-+++ endian.c	Fri Jun  8 09:51:44 2001
-@@ -24,10 +24,10 @@
-   return (tmp);
- }
- 
--u_long
--SwapFourBytes (u_long dw)
-+u_int32_t
-+SwapFourBytes (u_int32_t dw)
- {
--  register u_long tmp;
-+  register u_int32_t tmp;
-   tmp = (dw & 0x000000FF);
-   tmp = ((dw & 0x0000FF00) >> 0x08) | (tmp << 0x08);
-   tmp = ((dw & 0x00FF0000) >> 0x10) | (tmp << 0x08);
-diff -ur endian.h endian.h
---- endian.h	Sat May  5 15:52:25 2001
-+++ endian.h	Fri Jun  8 09:57:11 2001
-@@ -4,8 +4,10 @@
- #ifndef _GETBIG
- #define _GETBIG 1
- 
-+#include <sys/types.h>
-+
- extern u_short SwapTwoBytes (u_short);
--extern u_long SwapFourBytes (u_long);
-+extern u_int32_t SwapFourBytes (u_int32_t);
- extern sample_t SwapSample (sample_t);
- 
- #endif
-diff -ur fmtheaders.h fmtheaders.h
---- fmtheaders.h	2001-05-05 15:52:25.000000000 +0200
-+++ fmtheaders.h	2005-03-01 14:48:54.000000000 +0100
-@@ -3,55 +3,51 @@
- 
- #include <sys/types.h>
- 
-+#ifdef __GNUC__
-+# define PACKED(x)      __attribute__((packed)) x
-+#else
-+# define PACKED(x)	x
-+#endif
-+
- /* Definitions for .VOC files */
- 
- #define VOC_MAGIC	"Creative Voice File\032"
- 
--#define DATALEN(bp)	((u_long)(bp.BlockLen[0]) | \
--                         ((u_long)(bp.BlockLen[1]) << 8) | \
--                         ((u_long)(bp.BlockLen[2]) << 16) )
--
--typedef struct vochead
--  {
--    u_char Magic[20];		/* must be VOC_MAGIC */
--    u_short BlockOffset;	/* Offset to first block from top of file */
--    u_short Version;		/* VOC-file version */
--    u_short IDCode;		/* complement of version + 0x1234 */
--  }
--vochead;
--
--typedef struct blockTC
--  {
--    u_char BlockID;
--    u_char BlockLen[3];		/* low, mid, high byte of length of rest of block */
--  }
--blockTC;
--
--typedef struct blockT1
--  {
--    u_char TimeConstant;
--    u_char PackMethod;
--  }
--blockT1;
--
--typedef struct blockT8
--  {
--    u_short TimeConstant;
--    u_char PackMethod;
--    u_char VoiceMode;
--  }
--blockT8;
--
--typedef struct blockT9
--  {
--    u_int SamplesPerSec;
--    u_char BitsPerSample;
--    u_char Channels;
--    u_short Format;
--    u_char reserved[4];
--  }
--blockT9;
--
-+#define DATALEN(bp)	((u_int32_t)(bp.BlockLen[0]) | \
-+                         ((u_int32_t)(bp.BlockLen[1]) << 8) | \
-+                         ((u_int32_t)(bp.BlockLen[2]) << 16) )
-+
-+typedef struct vochead {
-+  u_int8_t  Magic[20];	/* must be VOC_MAGIC */
-+  u_int16_t BlockOffset;	/* Offset to first block from top of file */
-+  u_int16_t Version;	/* VOC-file version */
-+  u_int16_t IDCode;	/* complement of version + 0x1234 */
-+} PACKED(vochead);
-+
-+typedef struct blockTC {
-+  u_int8_t  BlockID;
-+  u_int8_t  BlockLen[3];	/* low, mid, high byte of length of rest of block */
-+} PACKED(blockTC);
-+
-+typedef struct blockT1 {
-+  u_int8_t  TimeConstant;
-+  u_int8_t  PackMethod;
-+} PACKED(blockT1);
-+
-+typedef struct blockT8 {
-+  u_int16_t TimeConstant;
-+  u_int8_t  PackMethod;
-+  u_int8_t  VoiceMode;
-+} PACKED(blockT8);
-+
-+typedef struct blockT9 {
-+  u_int32_t SamplesPerSec;
-+  u_int8_t  BitsPerSample;
-+  u_int8_t  Channels;
-+  u_int16_t Format;
-+  u_int8_t  reserved[4];
-+} PACKED(blockT9);
-+  
- 
- 
- /* Definitions for Microsoft WAVE format */
-@@ -59,25 +55,23 @@
- /* it's in chunks like .voc and AMIGA iff, but my source say there
-    are in only in this combination, so I combined them in one header;
-    it works on all WAVE-file I have
-- */
--typedef struct wavhead
--  {
--    u_long main_chunk;		/* 'RIFF' */
--    u_long length;		/* Length of rest of file */
--    u_long chunk_type;		/* 'WAVE' */
--
--    u_long sub_chunk;		/* 'fmt ' */
--    u_long sc_len;		/* length of sub_chunk, =16 (rest of chunk) */
--    u_short format;		/* should be 1 for PCM-code */
--    u_short modus;		/* 1 Mono, 2 Stereo */
--    u_long sample_fq;		/* frequence of sample */
--    u_long byte_p_sec;
--    u_short byte_p_spl;		/* samplesize; 1 or 2 bytes */
--    u_short bit_p_spl;		/* 8, 12 or 16 bit */
--
--    u_long data_chunk;		/* 'data' */
--    u_long data_length;		/* samplecount (lenth of rest of block?) */
--  }
--wavhead;
-+*/
-+typedef struct wavhead {
-+  u_int32_t	main_chunk;	/* 'RIFF' */
-+  u_int32_t	length;		/* Length of rest of file */
-+  u_int32_t	chunk_type;	/* 'WAVE' */
-+
-+  u_int32_t	sub_chunk;	/* 'fmt ' */
-+  u_int32_t	sc_len;		/* length of sub_chunk, =16 (rest of chunk) */
-+  u_int16_t	format;		/* should be 1 for PCM-code */
-+  u_int16_t	modus;		/* 1 Mono, 2 Stereo */
-+  u_int32_t	sample_fq;	/* frequence of sample */
-+  u_int32_t	byte_p_sec;
-+  u_int16_t	byte_p_spl;	/* samplesize; 1 or 2 bytes */
-+  u_int16_t	bit_p_spl;	/* 8, 12 or 16 bit */ 
-+
-+  u_int32_t	data_chunk;	/* 'data' */
-+  u_int32_t	data_length;	/* samplecount (lenth of rest of block?)*/
-+} PACKED(wavhead);
- 
- #endif
reverted:
--- gramofile-1.6/debian/80_fix_wav_length.dpatch
+++ gramofile-1.6.orig/debian/80_fix_wav_length.dpatch
@@ -1,48 +0,0 @@
-# Add post-recording fixup of length fields in wav header to reflect
-# correct file size when recording was stopped prematurely by the user.
-#PATCHOPTIONS: -p0
---- bplaysrc/bplay.c.orig	2005-03-01 19:17:34.000000000 +0100
-+++ bplaysrc/bplay.c	2005-03-01 19:18:17.000000000 +0100
-@@ -297,14 +297,14 @@
- 			filetype = F_RAW;	/* Change to change default */
- 		switch(filetype)
- 		{
-+			wavhead header;
-+
- 		case F_WAV:
- 			/* Spit out header here... */
- #ifndef LP2CD
- 			fprintf(stderr, "Writing MS WAV sound file");
- #endif
- 			{
--				wavhead header;
--
- 				char *riff = "RIFF";
- 				char *wave = "WAVE";
- 				char *fmt = "fmt ";
-@@ -346,6 +346,25 @@
- 			initsems(0, 1);
- 
- 			shmrec(thefd, bcount, 1);
-+
-+			/* Rewrite header with updated length fields now
-+			 * that we know the true file size. Writing is done
-+			 * in a separate process, so it's easiest to gather
-+			 * the number of bytes written from fstat(). [dk]
-+			 */
-+			if (filetype == F_WAV &&
-+			    lseek(thefd, 0, SEEK_SET) != -1) {
-+				struct stat st;
-+				if (fstat(thefd, &st) != -1) {
-+					header.length = cpu_to_le32(
-+						(u_int32_t) (st.st_size - 8));
-+					header.data_length = cpu_to_le32(
-+						(u_int32_t) (st.st_size -
-+							sizeof(header)));
-+					write(thefd, &header, sizeof(header));
-+				}
-+			}
-+				
- 			break;
- 		case F_VOC:
- 			/* Spit out header here... */
reverted:
--- gramofile-1.6/debian/90_report_recording_errors.dpatch
+++ gramofile-1.6.orig/debian/90_report_recording_errors.dpatch
@@ -1,139 +0,0 @@
-# Report errors during recording to the user. [dk]
-#PATCHOPTIONS: -p0
---- bplaysrc/shmbuf.c.orig	2005-03-02 12:24:48.000000000 +0100
-+++ bplaysrc/shmbuf.c	2005-03-02 12:34:36.000000000 +0100
-@@ -80,10 +80,12 @@
- static char **buffarr;
- static int numbuffs, numsemblks;
- static blockinf_t *buffinf;
-+static volatile int stoprecording;
- 
- /* prototypes */
- void cleanupsems(void);
- static void sighandler(int i);
-+static void childerrhandler(int i);
- 
- /* Extern globals */
- extern int abuf_size;
-@@ -194,6 +196,8 @@
-     }
-     /* Catch some signals, so we clean up semaphores */
-     signal(SIGINT, sighandler);
-+    /* Out of disk space errors are handled explicitly already. */
-+    signal(SIGXFSZ, SIG_IGN);
- }
- 
- 
-@@ -240,6 +244,7 @@
-     {
- 	int cbuff = 0;
- 	long totalrd = 0; /* we need it here too... */
-+	int err = 0;
- 
- #ifdef VUMETER
- 	signed short *ssptr;
-@@ -276,6 +281,13 @@
-                 totalrd += count;
- 	    }
- 
-+	    if (count == -1 && errno != EINTR) {
-+		    err = errno;
-+		    for (i = 0; i < numbuffs; i++)
-+			    up(sndsemid, i);
-+		    break;
-+	    }
-+
- #ifdef VUMETER
- 	    maxleft = 0;
- 	    maxright = 0;
-@@ -342,19 +354,27 @@
- 
- 	printw("\n\n");
- 	printw("      Recording information:\n\n\n");
--	fsec2hmsf ( (double) totalrd / (4 * 44100) , timestring);
--	printw("    Recorded time    : %s\n", timestring);
--	printw("    Recorded samples : %11ld\n", totalrd / 4);
--	printw("    Recorded bytes   : %11ld  (excl. header)\n", totalrd);
--	printw("\n");
--	printw("    Samples above 50%% of max. volume  : %9ld  (%5.1f%%)\n",
--          samplesabove50pct, samplesabove50pct * 100. / (totalrd/4));
--	printw("    Samples above 90%% of max. volume  : %9ld  (%5.1f%%)\n",
--          samplesabove90pct, samplesabove90pct * 100. / (totalrd/4));
--	printw("    Samples above 99%% of max. volume  : %9ld  (%5.1f%%)\n",
--          samplesabove99pct, samplesabove99pct * 100. / (totalrd/4));
--	printw("    Really too loud (clipped) samples : %9ld  (%5.1f%%)\n",
--          samplestooloud, samplestooloud * 100. / (totalrd/4));
-+
-+	if (!err) {
-+		
-+	  fsec2hmsf ( (double) totalrd / (4 * 44100) , timestring);
-+	  printw("    Recorded time    : %s\n", timestring);
-+	  printw("    Recorded samples : %11ld\n", totalrd / 4);
-+	  printw("    Recorded bytes   : %11ld  (excl. header)\n", totalrd);
-+	  printw("\n");
-+	  printw("    Samples above 50%% of max. volume  : %9ld  (%5.1f%%)\n",
-+            samplesabove50pct, samplesabove50pct * 100. / (totalrd/4));
-+	  printw("    Samples above 90%% of max. volume  : %9ld  (%5.1f%%)\n",
-+            samplesabove90pct, samplesabove90pct * 100. / (totalrd/4));
-+	  printw("    Samples above 99%% of max. volume  : %9ld  (%5.1f%%)\n",
-+            samplesabove99pct, samplesabove99pct * 100. / (totalrd/4));
-+	  printw("    Really too loud (clipped) samples : %9ld  (%5.1f%%)\n",
-+            samplestooloud, samplestooloud * 100. / (totalrd/4));
-+
-+	} else {
-+		printw("    Recording has terminated due to an error.\n");
-+		printw("    Operating system reports: %s\n", strerror(err));
-+	}
- 
- #if 0
- 	/* The computation of the avg volume is not simple. One approach
-@@ -379,6 +399,11 @@
-                3, strlen (ok_button.text) + 2);
- 	move (0, 79);
- 	refresh();
-+
-+	/* Tell parent to stop recording */
-+	if (err)
-+		kill(getppid(), SIGUSR1);
-+	
- #endif
- 
- 	exit(0);
-@@ -389,9 +414,10 @@
- 	int cbuff = 0;
- 	long totalrd = 0;
- 
--	int stoprecording=0;
- 	int in_ch;
- 
-+	signal(SIGUSR1, childerrhandler);
-+
- 	while (totalrd < totalcount && !stoprecording)
- 	{
- 	    long trgt, count, numrd;
-@@ -401,11 +427,15 @@
- 		trgt = abuf_size;
- 	    /* Get the buffer. Blocks until OK to do so */
- 	    down(sndsemid, cbuff);
-+	    if (stoprecording)
-+		    break;
-+	    
- 	    /* Read a block of data */
- 	    numrd = 0;
- 	    tmpptr = buffarr[cbuff];
- 	    while( (numrd < trgt) &&
--		((count = read(audio, tmpptr, trgt - numrd)) > 0) )
-+		((count = read(audio, tmpptr, trgt - numrd)) > 0) &&
-+		!stoprecording)
- 	    {
- 		numrd += count;
- 		tmpptr += count;
-@@ -674,3 +704,8 @@
-     finish_curses(1);
-     exit(1);
- }
-+
-+static void childerrhandler(int i)
-+{
-+	stoprecording = 1;
-+}
reverted:
--- gramofile-1.6/debian/91_rename_cdrecord_wodim.dpatch
+++ gramofile-1.6.orig/debian/91_rename_cdrecord_wodim.dpatch
@@ -1,43 +0,0 @@
-# This patch removes all occurences of "cdrecord" in the source and documentation.
-# This includes removing a link to a (not existing anymore) site of Schilling. 
-#
-# Also changes the packagefile to suggest wodim instead of cdrecord.
-#
-#  by Tobias Frost, tobi@coldtobi.de, 12-31-2006
-#PATCHOPTIONS -p1
-
-diff -pur -p1 gramofile-1.6.orig/mainmenu.c gramofile-1.6-patched/mainmenu.c
---- gramofile-1.6.orig/mainmenu.c	2006-12-31 11:42:45.000000000 +0100
-+++ gramofile-1.6-patched/mainmenu.c	2006-12-31 11:34:58.000000000 +0100
-@@ -221,3 +221,3 @@ will be generated, each containing one t
- 
--    "This option is not implemented yet. You can use the `cdrecord' \
-+    "This option is not implemented yet. You can use the `wodim' \
- or `xcdroast' program to create CDs from sound files on the harddisk.",
-diff -pur -p1 gramofile-1.6.orig/README gramofile-1.6-patched/README
---- gramofile-1.6.orig/README	2000-03-28 23:06:32.000000000 +0200
-+++ gramofile-1.6-patched/README	2006-12-31 11:38:49.000000000 +0100
-@@ -219,15 +219,12 @@ Write an audio CD: 
-  - This option is not yet implemented. There are some plans to program a
--    uniform user interface to the cdrecord(1) program here. You have to
-+    uniform user interface to the wodim(1) program here. You have to
-     use the bare program for this moment. Try something like
- 
--    cdrecord -v speed=2 dev=0,2,0 -audio -pad track01.wav track02.wav ... 
-+    wodim -v speed=2 dev=0,2,0 -audio -pad track01.wav track02.wav ... 
- 
--    Actual information on cdrecord may be found on:
--    http://www.fokus.gmd.de/research/cc/glone/employees/
--                                     joerg.schilling/private/cdrecord.html
--
--    If you like a graphical front-end to write CD's, try the xcdroast
--    program:
--    http://www.fh-muenchen.de/rz/xcdroast
--    (Note: you may have to use the wav2cdr utility.)
-+    Please check out the wodim package or the cdrkit-doc package for 
-+    details.
-+    
-+    You always can use a graphical front-end to write CD's, like the 
-+    xcdroast program. See the xcdroast package for details.
- 
-
diff -u gramofile-1.6/debian/changelog gramofile-1.6/debian/changelog
--- gramofile-1.6/debian/changelog
+++ gramofile-1.6/debian/changelog
@@ -1,3 +1,24 @@
+gramofile (1.6-9) unstable; urgency=low
+
+  [ Cyril Brulebois ]
+  * QA upload.
+  * Apply Gergely's patch from the BTS (changelog entry kept below for
+    reference), with the following tweaks:
+    - Stay with 1.0 format, 3.0 (quilt) makes my head hurt.
+    - Use the quilt sequence, and add quilt to Build-Depends.
+    - Move patches from debian/*.dpatch to debian/patches/*.patch.
+  * Orphan the package, since it has been RC buggy for a while, and has
+    seen no sign of maintainer action in a very long while.
+  * Thanks to IRILL for sponsoring this BSP in Paris.
+
+  [ Gergely Nagy ]
+  * Converted the build system from yada to debhelper (Closes: #636885).
+      + This resulted in converting to Format: 3.0 (quilt).
+      + Standards-Version bumped to 3.9.2.
+      + All patches quilt refreshed to apply cleanly.
+
+ -- Cyril Brulebois <kibi@debian.org>  Fri, 17 Feb 2012 10:13:50 +0000
+
 gramofile (1.6-8) unstable; urgency=medium
 
   * 91_rename_cdrecord_wodim.dpatch: Follow renaming of cdrecord to
diff -u gramofile-1.6/debian/control gramofile-1.6/debian/control
--- gramofile-1.6/debian/control
+++ gramofile-1.6/debian/control
@@ -1,13 +1,13 @@
 Source: gramofile
-Maintainer: Daniel Kobras <kobras@debian.org>
+Maintainer: Debian QA Group <packages@qa.debian.org>
 Section: sound
 Priority: extra
-Standards-Version: 3.7.2
-Build-Depends: libncurses5-dev, fftw-dev (>= 2.1.3-10), yada (>= 0.52)
+Standards-Version: 3.9.2
+Build-Depends: libncurses5-dev, fftw-dev (>= 2.1.3-10), debhelper (>= 8), quilt
 
 Package: gramofile
 Architecture: any
-Depends: ${gramofile:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}
 Recommends: mctools-lite
 Suggests: wodim
 Description: Transfer sound from gramophone records to CD
reverted:
--- gramofile-1.6/debian/packages
+++ gramofile-1.6.orig/debian/packages
@@ -1,111 +0,0 @@
-# Packages file for gramofile
-# Copyright 1999 by Charles Briscoe-Smith.  Licenced according to the GNU GPL.
-
-Source: gramofile
-Section: sound
-Priority: extra
-Packager: Charles Briscoe-Smith <cpbs@debian.org>
-Maintainer: Daniel Kobras <kobras@debian.org>
-Standards-Version: 3.7.2
-Description: GramoFile
-Upstream-Source: <URL:http://panic.et.tudelft.nl/~costar/gramofile/>
-Home-Page: <URL:http://panic.et.tudelft.nl/~costar/gramofile/>
-Packaged-For: Debian GNU/Linux
-Build-Sequence: conserve-space
-Build-Depends: libncurses5-dev, fftw-dev (>= 2.1.3-10)
-Build: sh
- make
-Clean: sh
- make clean || :
-Patches: *.dpatch
-Major-Changes: Included several semi-major patches as published on the
- GramoFile home page. See the Debian changelog for details.
-Copyright: GPL
- GramoFile - Gramophone records to CDs, Tick Reduction, Track Splitting
- Copyright (C) 1998 J.A. Bezemer
- .
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2 of the License, or (at your option)
- any later version. 
- .
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- for more details. 
- .
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
- .
- AUTHORS
- .
- GramoFile was developed by Anne Bezemer and Ton Le, students of the
- department of Information Technology and Systems (ITS), sub-department of
- Electrical Engineering (ET) of the Delft University of Technology (TU
- Delft). The first major part was written during the `Integraal Project
- Practicum' (IPP) in the spring of 1998. However, development has continued
- unofficially thereafter (so now we have track splitting operational :).
- Total development time is about 7 weeks full-time. 
- .
- The following persons have been very helpful and/or supportive during the
- `official' part of the project: A.P. Thijssen, E.A. Hendriks, A. Redert,
- J.A.H. Snelders, L.  Meijs and R.J. de Gruijl. Other persons are mentioned
- in the ChangeLog file. 
- .
- Any questions, comments, suggestions and bugfixes may be mailed to
- J.A.Bezemer@ITS.TUDelft.NL (or try costar@panic.et.tudelft.nl or
- mcbzmr@dds.nl). But please understand that I'm a student with very limited
- time to do the more pleasant things in life.
- .
- Have fun!
- .
- --
- All mentioned trademarks and registered trademarks are the property of their
- respective owners. 
-
-Package: gramofile
-Architecture: any
-Depends: [/usr/bin/*]
-Recommends: mctools-lite
-Suggests: wodim
-Description: Transfer sound from gramophone records to CD
- GramoFile enables you to record audio from (for example) gramophone
- records, process the signal and listen to the results. Because sound
- files in .WAV-format are used, it is possible to exchange the files
- with many other programs. Wodim(1) can burn CD-Recordables of these,
- so you can make CDs with the music of your favorite records.  The user
- interface of GramoFile has a windows-like look-and-feel, making it
- fairly easy to use.
- .
- One of the most important parts of GramoFile is the ability to process
- digital audio signals. Through the application of several filters it
- is possible to accomplish a significant reduction of disturbances like
- ticks and scratches. These filters have been programmed in such a fashion
- that they can be applied in any order (and multiple times) in a single
- run, thus avoiding the use of temporary files. It is possible to adjust
- the properties of each filter independently, so in every situation an
- optimal result can be achieved.
- .
- Another interesting feature is the track splitting. Just make one .wav
- file of an entire side of an record and GramoFile will detect where
- the individual tracks are located. This happens fully automatically,
- without need to set any options. More experienced users may fine-tune
- the algorithm, or change the detected track starts and ends, but
- generally that will not be necessary. Track-times are saved in an
- editable (plaintext) .tracks file, that will be used during the signal
- processing to produce one processed .wav file for each individual track.
- .
- To record and play .wav files, modified versions of brec(1) and bplay(1)
- by David Monro are included. These programs provide buffered recording
- and playback, so all will go well even on a highly loaded system. Both
- programs have been modified to support the standard GramoFile user
- interface.  Brec also got a `graphical' peak level meter, and bplay a
- running time display.
-Install: sh
- yada install -bin gramofile
- yada install -lib -exec -subdir gramofile bplay_gramo
- ln -s bplay_gramo $ROOT/usr/lib/gramofile/brec_gramo
- yada install -man debian/gramofile.1
- yada install -doc ChangeLog -as changelog
- yada install -doc README TODO *.txt
diff -u gramofile-1.6/debian/rules gramofile-1.6/debian/rules
--- gramofile-1.6/debian/rules
+++ gramofile-1.6/debian/rules
@@ -1,248 +1,4 @@
-#!/usr/bin/make -f
-# Generated automatically from debian/packages
-# by yada v0.52, of Fri,  8 Dec 2006
+#! /usr/bin/make -f
 
-DEB_HOST_ARCH        := $(shell dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null)
-DEB_HOST_ARCH_OS     := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
-DEB_HOST_ARCH_CPU    := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null)
-DEB_HOST_GNU_CPU     := $(shell dpkg-architecture -qDEB_HOST_GNU_CPU 2>/dev/null)
-DEB_HOST_GNU_TYPE    := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE 2>/dev/null)
-DEB_HOST_GNU_SYSTEM  := $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM 2>/dev/null)
-
-DEB_BUILD_ARCH       := $(shell dpkg-architecture -qDEB_BUILD_ARCH 2>/dev/null)
-DEB_BUILD_ARCH_OS    := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS 2>/dev/null)
-DEB_BUILD_ARCH_CPU   := $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU 2>/dev/null)
-DEB_BUILD_GNU_CPU    := $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU 2>/dev/null)
-DEB_BUILD_GNU_TYPE   := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE 2>/dev/null)
-DEB_BUILD_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM 2>/dev/null)
-
-# Take account of old dpkg-architecture output.
-ifeq ($(DEB_HOST_ARCH_CPU),)
-  DEB_HOST_ARCH_CPU := $(DEB_HOST_GNU_CPU))
-  ifeq ($(DEB_HOST_ARCH_CPU),i486)
-    DEB_HOST_ARCH_OS := i386
-  else
-  ifeq ($(DEB_HOST_ARCH_CPU),x86_64)
-    DEB_HOST_ARCH_OS := amd64
-  endif
-  endif
-endif
-ifeq ($(DEB_HOST_ARCH_OS),)
-  DEB_HOST_ARCH_OS := $(subst -gnu,,$(DEB_HOST_GNU_SYSTEM))
-  ifeq ($(DEB_HOST_ARCH_OS),gnu)
-    DEB_HOST_ARCH_OS := hurd
-  endif
-endif
-ifeq ($(DEB_BUILD_ARCH_CPU),)
-  DEB_BUILD_ARCH_CPU := $(DEB_BUILD_GNU_CPU))
-  ifeq ($(DEB_BUILD_ARCH_CPU),i486)
-    DEB_BUILD_ARCH_OS := i386
-  else
-  ifeq ($(DEB_BUILD_ARCH_CPU),x86_64)
-    DEB_BUILD_ARCH_OS := amd64
-  endif
-  endif
-endif
-ifeq ($(DEB_BUILD_ARCH_OS),)
-  DEB_BUILD_ARCH_OS := $(subst -gnu,,$(DEB_BUILD_GNU_SYSTEM))
-  ifeq ($(DEB_BUILD_ARCH_OS),gnu)
-    DEB_BUILD_ARCH_OS := hurd
-  endif
-endif
-
-LEFT_PARENTHESIS:=(
-VERSION:=$(shell head -n1 debian/changelog | sed -e "s/^[0-9a-zA-Z.-]* $(LEFT_PARENTHESIS)//" -e "s/[^0-9a-zA-Z.:+~-].*//")
-
-SHELL=/bin/bash
-
-.PHONY: default
-default:
-	@echo "Specify a target:"; \
-	echo " build              compile the package"; \
-	echo " build-arch         compile the architecture-dependent package"; \
-	echo " build-indep        compile the architecture-independent package"; \
-	echo " binary             make all binary packages"; \
-	echo " binary-arch        make all architecture-dependent binary packages"; \
-	echo " binary-indep       make all architecture-independent binary packages"; \
-	echo " clean              clean up the source package"; \
-	echo; \
-	echo " clean-install-tree clean up only under debian/"; \
-	echo
-
-# Build the package and prepare the install tree
-
-.PHONY: build-only build
-build-only: debian/build-stamp
-build: build-only
-
-.PHONY: build-arch-only build-arch
-build-arch-only: debian/build-arch-stamp
-build-arch: build-arch-only
-
-.PHONY: build-indep-only build-indep
-build-indep-only: debian/build-indep-stamp
-build-indep: build-indep-only
-
-# Make sure these rules and the control file are up-to-date
-
-.PHONY: rules control templates
-rules: debian/rules
-debian/rules: $(shell which yada) debian/packages-tmp
-	yada rebuild rules
-
-control: debian/control
-debian/control: $(shell which yada) debian/packages-tmp
-	yada rebuild control
-
-templates: debian/templates debian/po/POTFILES.in
-debian/templates: $(shell which yada) debian/packages-tmp
-	yada rebuild templates
-debian/po/POTFILES.in: $(shell which yada) debian/packages-tmp
-	yada rebuild templates
-
-debian/build-stamp: debian/build-arch-stamp debian/build-indep-stamp
-	@[ -f $(shell which yada) -a -f debian/rules ]
-	yada patch "debian/*.dpatch"
-	@umask 022 \
-	  && export pwd="$$(pwd)" \
-	  && export TMPROOT="$$(pwd)/debian/tmp" \
-	  && export SOURCE="gramofile" \
-	  && export VERSION="$(VERSION)" \
-	  && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
-	  && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
-	  && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
-	  && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
-	  && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
-	  && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" && (\
-	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
-	echo -E 'make') | /bin/sh
-	touch debian/build-stamp
-
-debian/build-arch-stamp:
-	@[ -f $(shell which yada) -a -f debian/rules ]
-	yada patch "debian/*.dpatch"
-	touch debian/build-arch-stamp
-
-debian/build-indep-stamp: debian/build-arch-stamp
-	@[ -f $(shell which yada) -a -f debian/rules ]
-	yada patch "debian/*.dpatch"
-	touch debian/build-indep-stamp
-
-.PHONY: install-tree
-install-tree: install-tree-any
-install-tree-any: \
-	debian/tmp-gramofile/DEBIAN/control
-
-debian/tmp-gramofile/DEBIAN/control: debian/build-stamp debian/control
-	rm -rf debian/tmp-gramofile
-	umask 022 && install -d debian/tmp-gramofile/DEBIAN
-	install -d debian/tmp-gramofile/usr/share/doc/gramofile
-	umask 022; yada generate copyright \
-	  > debian/tmp-gramofile/usr/share/doc/gramofile/copyright
-	install -m 644 -p debian/changelog \
-	  debian/tmp-gramofile/usr/share/doc/gramofile/changelog.Debian
-	@umask 022 \
-	  && export pwd="$$(pwd)" \
-	  && export ROOT="$$(pwd)/debian/tmp-gramofile" \
-	  && export TMPROOT="$$(pwd)/debian/tmp" \
-	  && export CONTROL="$$(pwd)/debian/tmp-gramofile/DEBIAN" \
-	  && export PACKAGE="gramofile" \
-	  && export SOURCE="gramofile" \
-	  && export VERSION="$(VERSION)" \
-	  && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
-	  && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
-	  && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
-	  && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
-	  && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
-	  && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" && (\
-	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
-	echo -E 'yada install -bin gramofile';\
-	echo -E 'yada install -lib -exec -subdir gramofile bplay_gramo';\
-	echo -E 'ln -s bplay_gramo $$ROOT/usr/lib/gramofile/brec_gramo';\
-	echo -E 'yada install -man debian/gramofile.1';\
-	echo -E 'yada install -doc ChangeLog -as changelog';\
-	echo -E 'yada install -doc README TODO *.txt') | /bin/sh
-	@umask 022 \
-	  && export pwd="$$(pwd)" \
-	  && export ROOT="$$(pwd)/debian/tmp-gramofile" \
-	  && export TMPROOT="$$(pwd)/debian/tmp" \
-	  && export CONTROL="$$(pwd)/debian/tmp-gramofile/DEBIAN" \
-	  && export PACKAGE="gramofile" \
-	  && export SOURCE="gramofile" \
-	  && export VERSION="$(VERSION)" && (\
-	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
-	echo -E 'yada perl';\
-	echo -E 'yada python';\
-	echo -E 'yada strip';\
-	echo -E 'yada shlibdeps') | /bin/sh
-	rm -f debian/shlibs.local || true
-	test -f debian/tmp-gramofile/DEBIAN/shlibs && cat debian/tmp-gramofile/DEBIAN/shlibs | while read lib ver pkg; do echo $$lib $$ver; done >> debian/shlibs.local || true
-	LD_LIBRARY_PATH="$$LD_LIBRARY_PATH:debian/tmp-gramofile/lib:debian/tmp-gramofile/usr/lib" dpkg-shlibdeps -pshlibs:gramofile -dDepends debian/tmp-gramofile/usr/bin/*
-	yada compress gramofile
-	yada generate maintscripts gramofile
-	find debian/tmp-gramofile -type f -print \
-	  | sed -n 's/^debian\/tmp-gramofile\(\/etc\/.*\)$$/\1/p' \
-	  > debian/tmp-gramofile/DEBIAN/conffiles
-	test -s debian/tmp-gramofile/DEBIAN/conffiles || rm -f debian/tmp-gramofile/DEBIAN/conffiles
-	yada rebuild control
-	yada generate substvars gramofile
-	umask 022 && dpkg-gencontrol -isp -pgramofile -Pdebian/tmp-gramofile
-
-# Build package files
-
-.PHONY: binary binary-arch binary-indep
-binary: binary-arch binary-indep
-binary-arch: binary-arch-any
-
-.PHONY: binary-arch-any
-binary-arch-any: \
-	binary-package-gramofile
-binary-indep:
-
-.PHONY: binary-package-gramofile
-binary-package-gramofile: check-root debian/tmp-gramofile/DEBIAN/control
-	@[ -f $(shell which yada) -a -f debian/rules ]
-	chown -R 0.0 debian/tmp-gramofile
-	chmod -R u=rwX,go=rX debian/tmp-gramofile
-	@if [ -d debian/tmp-gramofile/usr/doc/gramofile ]; then \
-	  echo "*** Yada warning: /usr/doc/gramofile should be /usr/share/doc/gramofile";\
-	fi
-	dpkg-deb --build debian/tmp-gramofile ..
-
-.PHONY: check-root
-check-root:
-	@[ `id -u` = 0 ] || (echo "You must be root to do this!"; false)
-
-debian/packages-tmp: debian/packages 
-	yada rebuild packages
-
-## Clean up afterwards
-
-.PHONY: clean clean-install-tree clean-build
-
-clean: clean-install-tree clean-build debian/control debian/rules
-	rm -f debian/packages-tmp debian/packages-tmp-new debian/packages-tmp-include
-
-clean-build:
-	@[ -f $(shell which yada) -a -f debian/rules ]
-	rm -f debian/build-stamp debian/build-arch-stamp debian/build-indep-stamp
-	@umask 022 \
-	  && export pwd="$$(pwd)" \
-	  && export TMPROOT="$$(pwd)/debian/tmp" \
-	  && export SOURCE="gramofile" \
-	  && export VERSION="$(VERSION)" \
-	  && export DEB_HOST_GNU_CPU="$(DEB_HOST_GNU_CPU)" \
-	  && export DEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
-	  && export DEB_HOST_GNU_SYSTEM="$(DEB_HOST_GNU_SYSTEM)" \
-	  && export DEB_BUILD_GNU_CPU="$(DEB_BUILD_GNU_CPU)" \
-	  && export DEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
-	  && export DEB_BUILD_GNU_SYSTEM="$(DEB_BUILD_GNU_SYSTEM)" && (\
-	echo -E 'eval "yada () { perl $$(which yada) \"\$$@\"; }"; set -e; set -v';\
-	echo -E 'make clean || :') | /bin/sh
-	yada unpatch
-	rm -rf debian/tmp
-
-clean-install-tree: debian/rules
-	@[ -f $(shell which yada) -a -f debian/rules ]
-	rm -f debian/install-tree-stamp
-	rm -rf debian/tmp-* debian/files* debian/substvars debian/shlibs.local debian/ucf
+%:
+	dh $@ --with quilt
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/gramofile.manpages
+++ gramofile-1.6/debian/gramofile.manpages
@@ -0,0 +1 @@
+debian/gramofile.1
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/gramofile.docs
+++ gramofile-1.6/debian/gramofile.docs
@@ -0,0 +1,3 @@
+README
+TODO
+*.txt
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/compat
+++ gramofile-1.6/debian/compat
@@ -0,0 +1 @@
+8
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/copyright
+++ gramofile-1.6/debian/copyright
@@ -0,0 +1,59 @@
+This is the Debian GNU/Linux prepackaged version of GramoFile.  It was
+originally Debianised by Charles Briscoe-Smith <cpbs@debian.org>, and is
+currently maintained by Daniel Kobras <kobras@debian.org>, using files
+obtained from <URL:http://panic.et.tudelft.nl/~costar/gramofile/>.
+
+More information about GramoFile is available from
+<URL:http://panic.et.tudelft.nl/~costar/gramofile/>
+
+Changes were made as follows:
+  Included several semi-major patches as published on the
+  GramoFile home page. See the Debian changelog for details.
+
+Copyright and licence notice:
+
+  GramoFile - Gramophone records to CDs, Tick Reduction, Track Splitting
+  Copyright (C) 1998 J.A. Bezemer
+  
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by the Free
+  Software Foundation; either version 2 of the License, or (at your option)
+  any later version.
+  
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+  for more details.
+  
+  You should have received a copy of the GNU General Public License along
+  with this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+  
+  AUTHORS
+  
+  GramoFile was developed by Anne Bezemer and Ton Le, students of the
+  department of Information Technology and Systems (ITS), sub-department of
+  Electrical Engineering (ET) of the Delft University of Technology (TU
+  Delft). The first major part was written during the `Integraal Project
+  Practicum' (IPP) in the spring of 1998. However, development has continued
+  unofficially thereafter (so now we have track splitting operational :).
+  Total development time is about 7 weeks full-time.
+  
+  The following persons have been very helpful and/or supportive during the
+  `official' part of the project: A.P. Thijssen, E.A. Hendriks, A. Redert,
+  J.A.H. Snelders, L.  Meijs and R.J. de Gruijl. Other persons are mentioned
+  in the ChangeLog file.
+  
+  Any questions, comments, suggestions and bugfixes may be mailed to
+  J.A.Bezemer@ITS.TUDelft.NL (or try costar@panic.et.tudelft.nl or
+  mcbzmr@dds.nl). But please understand that I'm a student with very limited
+  time to do the more pleasant things in life.
+  
+  Have fun!
+  
+  --
+  All mentioned trademarks and registered trademarks are the property of their
+  respective owners.
+
+On any Debian system, you can find the complete text of the GNU GPL
+(GNU General Public License) in the file /usr/share/common-licenses/GPL-2
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/gramofile.install
+++ gramofile-1.6/debian/gramofile.install
@@ -0,0 +1,3 @@
+gramofile		usr/bin
+bplay_gramo		usr/lib/gramofile
+brec_gramo		usr/lib/gramofile
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/70-endian-fixes.patch
+++ gramofile-1.6/debian/patches/70-endian-fixes.patch
@@ -0,0 +1,463 @@
+# Fix endianness bugs in WAV and VOC headers on big-endian archs.
+# Use POSIX size types to avoid broken headers on 64bit archs.
+# Disable padding in structs that read/write raw on-disk data.
+# Merged with endianness patch by Tom Harvey <TomHarvey@IndustryFigure.com>
+# [dk]
+Index: gramofile/bplaysrc/bplay.c
+===================================================================
+--- gramofile.orig/bplaysrc/bplay.c	2011-08-14 13:27:15.593217482 +0200
++++ gramofile/bplaysrc/bplay.c	2011-08-14 13:27:16.377717882 +0200
+@@ -30,6 +30,30 @@
+ #include <machine/soundcard.h>
+ #endif
+ 
++/* Needed for BYTE_ORDER and BIG/LITTLE_ENDIAN macros. */
++#ifndef _BSD_SOURCE
++# define _BSD_SOURCE
++# include <endian.h>
++# undef  _BSD_SOURCE
++#else
++# include <endian.h>
++#endif
++
++#include <sys/types.h>
++#include <byteswap.h>
++
++/* Adapted from the byteorder macros in the Linux kernel. */
++#if BYTE_ORDER == LITTLE_ENDIAN
++#define cpu_to_le32(x) (x)
++#define cpu_to_le16(x) (x)
++#else
++#define cpu_to_le32(x) bswap_32((x))
++#define cpu_to_le16(x) bswap_16((x))
++#endif
++
++#define le32_to_cpu(x)	cpu_to_le32((x))
++#define le16_to_cpu(x)	cpu_to_le16((x))
++
+ #include "fmtheaders.h"
+ 
+ #include "../yesnowindow.h"
+@@ -287,23 +311,26 @@
+ 				char *data = "data";
+ 
+ 				memcpy(&(header.main_chunk), riff, 4);
+-				header.length = sizeof(wavhead) - 8 + bcount;
++				header.length = cpu_to_le32(sizeof(wavhead)
++						- 8 + bcount);
+ 				memcpy(&(header.chunk_type), wave, 4);
+ 
+ 				memcpy(&(header.sub_chunk), fmt, 4);
+-				header.sc_len = 16;
+-				header.format = 1;
+-				header.modus = stereo + 1;
+-				header.sample_fq = speed;
+-				header.byte_p_sec = ((bits > 8)? 2:1)*(stereo+1)*speed;
++				header.sc_len = cpu_to_le32(16);
++				header.format = cpu_to_le16(1);
++				header.modus = cpu_to_le16(stereo + 1);
++				header.sample_fq = cpu_to_le32(speed);
++				header.byte_p_sec = cpu_to_le32(((bits > 8)?
++						2:1)*(stereo+1)*speed);
+ /* Correction by J.A. Bezemer: */
+-				header.byte_p_spl = ((bits > 8)? 2:1)*(stereo+1);
++				header.byte_p_spl = cpu_to_le16(((bits > 8)?
++						2:1)*(stereo+1));
+ 			/* was: header.byte_p_spl = (bits > 8)? 2:1; */
+ 
+-				header.bit_p_spl = bits;
++				header.bit_p_spl = cpu_to_le16(bits);
+ 
+ 				memcpy(&(header.data_chunk), data, 4);
+-				header.data_length = bcount;
++				header.data_length = cpu_to_le32(bcount);
+ 				write(thefd, &header, sizeof(header));
+ 			}
+ 		case F_RAW:
+@@ -333,9 +360,9 @@
+ 
+ 				for (i=0;i<20;i++)
+ 					header.Magic[i] = VOC_MAGIC[i];
+-				header.BlockOffset = 0x1a;
+-				header.Version = 0x0114;
+-				header.IDCode = 0x111F;
++				header.BlockOffset = cpu_to_le16(0x1a);
++				header.Version = cpu_to_le16(0x0114);
++				header.IDCode = cpu_to_le16(0x111F);
+ 				write(thefd, &header, sizeof(vochead));
+ 
+ 				snd_parm(speed, bits, stereo);
+@@ -346,10 +373,10 @@
+ 				ablk.BlockLen[0] = (i + 12) & 0xFF;
+ 				ablk.BlockLen[1] = ((i + 12) >> 8) & 0xFF;
+ 				ablk.BlockLen[2] = ((i + 12) >> 16) & 0xFF;
+-				bblk.SamplesPerSec = speed;
++				bblk.SamplesPerSec = cpu_to_le32(speed);
+ 				bblk.BitsPerSample = bits;
+ 				bblk.Channels = stereo + 1;
+-				bblk.Format = (bits == 8)? 0 : 4;
++				bblk.Format = cpu_to_le16((bits == 8)? 0 : 4);
+ 				write(thefd, &ablk, sizeof(ablk));
+ 				write(thefd, &bblk, sizeof(bblk));
+ 				shmrec(thefd, i, 1);
+@@ -474,6 +501,17 @@
+ 
+     memcpy((void*)&wavhd, (void*)hd_buf, 20);
+     count = read(thefd, ((char*)&wavhd)+20, sizeof(wavhd) - 20);
++
++    wavhd.length = le32_to_cpu(wavhd.length);
++    wavhd.sc_len = le32_to_cpu(wavhd.sc_len);
++    wavhd.format = le16_to_cpu(wavhd.format);
++    wavhd.modus = le16_to_cpu(wavhd.modus);
++    wavhd.sample_fq = le32_to_cpu(wavhd.sample_fq);
++    wavhd.byte_p_sec = le32_to_cpu(wavhd.byte_p_sec);
++    wavhd.byte_p_spl = le16_to_cpu(wavhd.byte_p_spl);
++    wavhd.bit_p_spl = le16_to_cpu(wavhd.bit_p_spl);
++    wavhd.data_length = le32_to_cpu(wavhd.data_length);
++
+     if(wavhd.format != 1) Die("Input is not a PCM WAV file");
+ #ifndef LP2CD
+     if (! (mods&MSPEED))
+@@ -516,6 +554,11 @@
+     fprintf(stderr, "Playing Creative Labs Voice file ...\n");
+     memcpy((void*)&vochd, (void*)hd_buf, 20);
+     count = read(thefd, ((char*)&vochd)+20, sizeof(vochd) - 20);
++
++    vochd.BlockOffset = le16_to_cpu(vochd.BlockOffset);
++    vochd.Version = le16_to_cpu(vochd.Version);
++    vochd.IDCode = le16_to_cpu(vochd.IDCode);
++    
+     fprintf(stderr, "Format version %d.%d\n", vochd.Version>>8,
+ 	vochd.Version&0xFF);
+     if (vochd.IDCode != (~vochd.Version+0x1234))
+@@ -564,6 +607,9 @@
+ 	{
+ 	blockT8 tblock;
+ 	read(thefd, (char*)&tblock, sizeof(tblock));
++
++	tblock.TimeConstant = le16_to_cpu(tblock.TimeConstant);
++	
+ 	if(tblock.PackMethod != 0) Die("Non PCM VOC block");
+ 	speed = 256000000/(65536 - tblock.TimeConstant);
+ 	bits = 8;
+@@ -576,6 +622,10 @@
+ 	{
+ 	blockT9 tblock;
+ 	read(thefd, (char*)&tblock, sizeof(tblock));
++
++	tblock.SamplesPerSec = le32_to_cpu(tblock.SamplesPerSec);
++	tblock.Format = le16_to_cpu(tblock.Format);
++	
+ 	if(tblock.Format != 0 && tblock.Format != 4)
+ 	    Die("Non PCM VOC block");
+ 	speed = tblock.SamplesPerSec;
+Index: gramofile/bplaysrc/fmtheaders.h
+===================================================================
+--- gramofile.orig/bplaysrc/fmtheaders.h	2011-08-14 13:21:45.189217975 +0200
++++ gramofile/bplaysrc/fmtheaders.h	2011-08-14 13:27:16.377717882 +0200
+@@ -3,44 +3,50 @@
+ 
+ #include <sys/types.h>
+ 
++#ifdef __GNUC__
++# define PACKED(x)      __attribute__((packed)) x
++#else
++# define PACKED(x)	x
++#endif
++
+ /* Definitions for .VOC files */
+ 
+ #define VOC_MAGIC	"Creative Voice File\032"
+ 
+-#define DATALEN(bp)	((u_long)(bp.BlockLen[0]) | \
+-                         ((u_long)(bp.BlockLen[1]) << 8) | \
+-                         ((u_long)(bp.BlockLen[2]) << 16) )
++#define DATALEN(bp)	((u_int32_t)(bp.BlockLen[0]) | \
++                         ((u_int32_t)(bp.BlockLen[1]) << 8) | \
++                         ((u_int32_t)(bp.BlockLen[2]) << 16) )
+ 
+ typedef struct vochead {
+-  u_char  Magic[20];	/* must be VOC_MAGIC */
+-  u_short BlockOffset;	/* Offset to first block from top of file */
+-  u_short Version;	/* VOC-file version */
+-  u_short IDCode;	/* complement of version + 0x1234 */
+-} vochead;
++  u_int8_t  Magic[20];	/* must be VOC_MAGIC */
++  u_int16_t BlockOffset;	/* Offset to first block from top of file */
++  u_int16_t Version;	/* VOC-file version */
++  u_int16_t IDCode;	/* complement of version + 0x1234 */
++} PACKED(vochead);
+ 
+ typedef struct blockTC {
+-  u_char  BlockID;
+-  u_char  BlockLen[3];	/* low, mid, high byte of length of rest of block */
+-} blockTC;
++  u_int8_t  BlockID;
++  u_int8_t  BlockLen[3];	/* low, mid, high byte of length of rest of block */
++} PACKED(blockTC);
+ 
+ typedef struct blockT1 {
+-  u_char  TimeConstant;
+-  u_char  PackMethod;
+-} blockT1;
++  u_int8_t  TimeConstant;
++  u_int8_t  PackMethod;
++} PACKED(blockT1);
+ 
+ typedef struct blockT8 {
+-  u_short TimeConstant;
+-  u_char  PackMethod;
+-  u_char  VoiceMode;
+-} blockT8;
++  u_int16_t TimeConstant;
++  u_int8_t  PackMethod;
++  u_int8_t  VoiceMode;
++} PACKED(blockT8);
+ 
+ typedef struct blockT9 {
+-  u_int   SamplesPerSec;
+-  u_char  BitsPerSample;
+-  u_char  Channels;
+-  u_short Format;
+-  u_char   reserved[4];
+-} blockT9;
++  u_int32_t SamplesPerSec;
++  u_int8_t  BitsPerSample;
++  u_int8_t  Channels;
++  u_int16_t Format;
++  u_int8_t  reserved[4];
++} PACKED(blockT9);
+   
+ 
+ 
+@@ -51,21 +57,21 @@
+    it works on all WAVE-file I have
+ */
+ typedef struct wavhead {
+-  u_long	main_chunk;	/* 'RIFF' */
+-  u_long	length;		/* Length of rest of file */
+-  u_long	chunk_type;	/* 'WAVE' */
+-
+-  u_long	sub_chunk;	/* 'fmt ' */
+-  u_long	sc_len;		/* length of sub_chunk, =16 (rest of chunk) */
+-  u_short	format;		/* should be 1 for PCM-code */
+-  u_short	modus;		/* 1 Mono, 2 Stereo */
+-  u_long	sample_fq;	/* frequence of sample */
+-  u_long	byte_p_sec;
+-  u_short	byte_p_spl;	/* samplesize; 1 or 2 bytes */
+-  u_short	bit_p_spl;	/* 8, 12 or 16 bit */ 
+-
+-  u_long	data_chunk;	/* 'data' */
+-  u_long	data_length;	/* samplecount (lenth of rest of block?)*/
+-} wavhead;
++  u_int32_t	main_chunk;	/* 'RIFF' */
++  u_int32_t	length;		/* Length of rest of file */
++  u_int32_t	chunk_type;	/* 'WAVE' */
++
++  u_int32_t	sub_chunk;	/* 'fmt ' */
++  u_int32_t	sc_len;		/* length of sub_chunk, =16 (rest of chunk) */
++  u_int16_t	format;		/* should be 1 for PCM-code */
++  u_int16_t	modus;		/* 1 Mono, 2 Stereo */
++  u_int32_t	sample_fq;	/* frequence of sample */
++  u_int32_t	byte_p_sec;
++  u_int16_t	byte_p_spl;	/* samplesize; 1 or 2 bytes */
++  u_int16_t	bit_p_spl;	/* 8, 12 or 16 bit */ 
++
++  u_int32_t	data_chunk;	/* 'data' */
++  u_int32_t	data_length;	/* samplecount (lenth of rest of block?)*/
++} PACKED(wavhead);
+ 
+ #endif
+Index: gramofile/bplaysrc/sndfunc.c
+===================================================================
+--- gramofile.orig/bplaysrc/sndfunc.c	2011-08-14 13:27:15.113717191 +0200
++++ gramofile/bplaysrc/sndfunc.c	2011-08-14 13:27:16.377717882 +0200
+@@ -66,6 +66,9 @@
+ 	sync_audio();
+ 
+ 	/* Set the sample speed, size and stereoness */
++	/* We only use values of 8 and 16 for bits. This implies
++	 * unsigned data for 8 bits, and little-endian signed for 16 bits.
++	 */
+ 	if (ioctl(audio, SNDCTL_DSP_SAMPLESIZE, &bits) < 0)
+ 	    ErrDie(AUDIO);
+ 	if (ioctl(audio, SNDCTL_DSP_STEREO, &stereo) < 0)
+Index: gramofile/endian.c
+===================================================================
+--- gramofile.orig/endian.c	2011-08-14 13:21:45.181217123 +0200
++++ gramofile/endian.c	2011-08-14 13:27:16.377717882 +0200
+@@ -24,10 +24,10 @@
+   return (tmp);
+ }
+ 
+-u_long
+-SwapFourBytes (u_long dw)
++u_int32_t
++SwapFourBytes (u_int32_t dw)
+ {
+-  register u_long tmp;
++  register u_int32_t tmp;
+   tmp = (dw & 0x000000FF);
+   tmp = ((dw & 0x0000FF00) >> 0x08) | (tmp << 0x08);
+   tmp = ((dw & 0x00FF0000) >> 0x10) | (tmp << 0x08);
+Index: gramofile/endian.h
+===================================================================
+--- gramofile.orig/endian.h	2011-08-14 13:27:15.777717640 +0200
++++ gramofile/endian.h	2011-08-14 13:27:16.377717882 +0200
+@@ -4,8 +4,10 @@
+ #ifndef _GETBIG
+ #define _GETBIG 1
+ 
++#include <sys/types.h>
++
+ extern u_short SwapTwoBytes (u_short);
+-extern u_long SwapFourBytes (u_long);
++extern u_int32_t SwapFourBytes (u_int32_t);
+ extern sample_t SwapSample (sample_t);
+ 
+ /* macro to swap endianness of values in a sample_t with */
+Index: gramofile/fmtheaders.h
+===================================================================
+--- gramofile.orig/fmtheaders.h	2011-08-14 13:21:45.173217473 +0200
++++ gramofile/fmtheaders.h	2011-08-14 13:27:16.377717882 +0200
+@@ -3,55 +3,51 @@
+ 
+ #include <sys/types.h>
+ 
++#ifdef __GNUC__
++# define PACKED(x)      __attribute__((packed)) x
++#else
++# define PACKED(x)	x
++#endif
++
+ /* Definitions for .VOC files */
+ 
+ #define VOC_MAGIC	"Creative Voice File\032"
+ 
+-#define DATALEN(bp)	((u_long)(bp.BlockLen[0]) | \
+-                         ((u_long)(bp.BlockLen[1]) << 8) | \
+-                         ((u_long)(bp.BlockLen[2]) << 16) )
+-
+-typedef struct vochead
+-  {
+-    u_char Magic[20];		/* must be VOC_MAGIC */
+-    u_short BlockOffset;	/* Offset to first block from top of file */
+-    u_short Version;		/* VOC-file version */
+-    u_short IDCode;		/* complement of version + 0x1234 */
+-  }
+-vochead;
+-
+-typedef struct blockTC
+-  {
+-    u_char BlockID;
+-    u_char BlockLen[3];		/* low, mid, high byte of length of rest of block */
+-  }
+-blockTC;
+-
+-typedef struct blockT1
+-  {
+-    u_char TimeConstant;
+-    u_char PackMethod;
+-  }
+-blockT1;
+-
+-typedef struct blockT8
+-  {
+-    u_short TimeConstant;
+-    u_char PackMethod;
+-    u_char VoiceMode;
+-  }
+-blockT8;
+-
+-typedef struct blockT9
+-  {
+-    u_int SamplesPerSec;
+-    u_char BitsPerSample;
+-    u_char Channels;
+-    u_short Format;
+-    u_char reserved[4];
+-  }
+-blockT9;
+-
++#define DATALEN(bp)	((u_int32_t)(bp.BlockLen[0]) | \
++                         ((u_int32_t)(bp.BlockLen[1]) << 8) | \
++                         ((u_int32_t)(bp.BlockLen[2]) << 16) )
++
++typedef struct vochead {
++  u_int8_t  Magic[20];	/* must be VOC_MAGIC */
++  u_int16_t BlockOffset;	/* Offset to first block from top of file */
++  u_int16_t Version;	/* VOC-file version */
++  u_int16_t IDCode;	/* complement of version + 0x1234 */
++} PACKED(vochead);
++
++typedef struct blockTC {
++  u_int8_t  BlockID;
++  u_int8_t  BlockLen[3];	/* low, mid, high byte of length of rest of block */
++} PACKED(blockTC);
++
++typedef struct blockT1 {
++  u_int8_t  TimeConstant;
++  u_int8_t  PackMethod;
++} PACKED(blockT1);
++
++typedef struct blockT8 {
++  u_int16_t TimeConstant;
++  u_int8_t  PackMethod;
++  u_int8_t  VoiceMode;
++} PACKED(blockT8);
++
++typedef struct blockT9 {
++  u_int32_t SamplesPerSec;
++  u_int8_t  BitsPerSample;
++  u_int8_t  Channels;
++  u_int16_t Format;
++  u_int8_t  reserved[4];
++} PACKED(blockT9);
++  
+ 
+ 
+ /* Definitions for Microsoft WAVE format */
+@@ -59,25 +55,23 @@
+ /* it's in chunks like .voc and AMIGA iff, but my source say there
+    are in only in this combination, so I combined them in one header;
+    it works on all WAVE-file I have
+- */
+-typedef struct wavhead
+-  {
+-    u_long main_chunk;		/* 'RIFF' */
+-    u_long length;		/* Length of rest of file */
+-    u_long chunk_type;		/* 'WAVE' */
+-
+-    u_long sub_chunk;		/* 'fmt ' */
+-    u_long sc_len;		/* length of sub_chunk, =16 (rest of chunk) */
+-    u_short format;		/* should be 1 for PCM-code */
+-    u_short modus;		/* 1 Mono, 2 Stereo */
+-    u_long sample_fq;		/* frequence of sample */
+-    u_long byte_p_sec;
+-    u_short byte_p_spl;		/* samplesize; 1 or 2 bytes */
+-    u_short bit_p_spl;		/* 8, 12 or 16 bit */
+-
+-    u_long data_chunk;		/* 'data' */
+-    u_long data_length;		/* samplecount (lenth of rest of block?) */
+-  }
+-wavhead;
++*/
++typedef struct wavhead {
++  u_int32_t	main_chunk;	/* 'RIFF' */
++  u_int32_t	length;		/* Length of rest of file */
++  u_int32_t	chunk_type;	/* 'WAVE' */
++
++  u_int32_t	sub_chunk;	/* 'fmt ' */
++  u_int32_t	sc_len;		/* length of sub_chunk, =16 (rest of chunk) */
++  u_int16_t	format;		/* should be 1 for PCM-code */
++  u_int16_t	modus;		/* 1 Mono, 2 Stereo */
++  u_int32_t	sample_fq;	/* frequence of sample */
++  u_int32_t	byte_p_sec;
++  u_int16_t	byte_p_spl;	/* samplesize; 1 or 2 bytes */
++  u_int16_t	bit_p_spl;	/* 8, 12 or 16 bit */ 
++
++  u_int32_t	data_chunk;	/* 'data' */
++  u_int32_t	data_length;	/* samplecount (lenth of rest of block?)*/
++} PACKED(wavhead);
+ 
+ #endif
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/20-overflow-fixes.patch
+++ gramofile-1.6/debian/patches/20-overflow-fixes.patch
@@ -0,0 +1,59 @@
+# Patch by James Tappin <james@xena.uklinux.net>
+# Rediffed into unified format. [dk]
+Index: gramofile/signpr_cmf2.c
+===================================================================
+--- gramofile.orig/signpr_cmf2.c	2011-08-14 13:21:45.869218469 +0200
++++ gramofile/signpr_cmf2.c	2011-08-14 13:27:14.797217296 +0200
+@@ -646,19 +646,25 @@
+ 
+   /* Should be /64, but the signal is extremely soft, so divide by less to
+      get more quantization levels (more accurate) */
+-  sum.left /= 10;
+-  sum.right /= 10;
++  sum.left /= 4;
++  sum.right /= 4;
+ #endif
+ 
+-  if (sum.left < 32767)
+-    sample.left = sum.left;
+-  else
++  if (sum.left > 32767)
+     sample.left = 32767;
+-
+-  if (sum.right < 32767)
+-    sample.right = sum.right;
++  else if (sum.left < -32768)
++    sample.left = -32768;
+   else
++    sample.left = sum.left;
++
++
++  if (sum.right > 32767)
+     sample.right = 32767;
++  else if (sum.right < -32768)
++    sample.right = -32768;
++  else 
++    sample.right = sum.right;
++
+ 
+   return sample;
+ }
+@@ -762,6 +768,9 @@
+     b_t.left;
+   if (i > 32767)
+     i = 32767;
++  else if (i < -32768)
++    i = -32768;
++
+   returnval.left = i;
+ 
+   i = (labs (w_t.right - b_t.right) * 1000)
+@@ -769,6 +778,8 @@
+     b_t.right;
+   if (i > 32767)
+     i = 32767;
++  else if (i < -32768)
++    i = -32768;
+   returnval.right = i;
+ 
+   return returnval;
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/20-shell-quoting.patch
+++ gramofile-1.6/debian/patches/20-shell-quoting.patch
@@ -0,0 +1,46 @@
+#Patch by Jon Schewe <jpschewe@eggplant.mtu.net>
+Index: gramofile/playwav.c
+===================================================================
+--- gramofile.orig/playwav.c	2011-08-14 13:21:45.809217714 +0200
++++ gramofile/playwav.c	2011-08-14 13:27:14.941717336 +0200
+@@ -44,11 +44,11 @@
+     case FILE_EXISTS:
+ 
+       if (usebeginendtime)
+-	sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld %s",
++	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);
++	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 (: */
+ 
+@@ -771,11 +771,11 @@
+       def_prog_mode ();		/* save terminal state */
+ 
+       if (usebeginendtime)
+-	sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld %s",
++	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);
++	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 */
+ 
+Index: gramofile/reclp_main.c
+===================================================================
+--- gramofile.orig/reclp_main.c	2011-08-14 13:21:45.817217244 +0200
++++ gramofile/reclp_main.c	2011-08-14 13:27:14.941717336 +0200
+@@ -30,7 +30,7 @@
+ 
+   def_prog_mode ();		/* save terminal state */
+ 
+-  sprintf (shellcmd, "brec_gramo -S -s 44100 -b 16 -t 6000 -w %s",
++  sprintf (shellcmd, "brec_gramo -S -s 44100 -b 16 -t 6000 -w \"%s\"",
+ 	   filename);
+   system (shellcmd);
+ 
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/20-no-busy-wait-after-rec.patch
+++ gramofile-1.6/debian/patches/20-no-busy-wait-after-rec.patch
@@ -0,0 +1,14 @@
+# Do not busy wait for confirmation after recording. [dk]
+Index: gramofile/bplaysrc/shmbuf.c
+===================================================================
+--- gramofile.orig/bplaysrc/shmbuf.c	2011-08-14 13:21:45.933217744 +0200
++++ gramofile/bplaysrc/shmbuf.c	2011-08-14 13:27:14.625717934 +0200
+@@ -443,7 +443,7 @@
+ 	cleanupsems();
+ 
+ #ifdef VUMETER
+-	nodelay(stdscr, TRUE);
++	nodelay(stdscr, FALSE);
+ 
+ 	/* child has displayed informative data */
+ 	do
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/20-warning-fixes.patch
+++ gramofile-1.6/debian/patches/20-warning-fixes.patch
@@ -0,0 +1,212 @@
+# Patch by Tom Harvey <TomHarvey@IndustryFigure.com>
+# Rediffed. [dk]
+# Also changed return type of bplay.c. [dk]
+Index: gramofile/bplaysrc/bplay.c
+===================================================================
+--- gramofile.orig/bplaysrc/bplay.c	2011-08-14 13:21:45.689217780 +0200
++++ gramofile/bplaysrc/bplay.c	2011-08-14 13:27:15.277217351 +0200
+@@ -91,7 +91,7 @@
+ extern void cleanupsems(void);
+ 
+ 
+-void main(int argc, char *argv[])
++int main(int argc, char *argv[])
+ {
+ 	
+ 	int recorder = 0;		/* 1 if recording, 0 else */
+@@ -398,6 +398,7 @@
+ 	}
+ 
+ 	finish_curses(0);
++	exit(0);	/* Not reached, but keeps compiler happy. */
+ }
+ 
+ void Usage(void)
+Index: gramofile/clrscr.c
+===================================================================
+--- gramofile.orig/clrscr.c	2011-08-14 13:21:45.617217700 +0200
++++ gramofile/clrscr.c	2011-08-14 13:27:15.277217351 +0200
+@@ -8,6 +8,7 @@
+  */
+ 
+ #include "clrscr.h"
++#include <string.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+ #else
+Index: gramofile/errorwindow.c
+===================================================================
+--- gramofile.orig/errorwindow.c	2011-08-14 13:21:45.593217717 +0200
++++ gramofile/errorwindow.c	2011-08-14 13:27:15.277217351 +0200
+@@ -11,6 +11,8 @@
+ #include "buttons.h"
+ #include "boxes.h"
+ #include "textwindow.h"
++
++#include <string.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+ #else
+Index: gramofile/gramofile.c
+===================================================================
+--- gramofile.orig/gramofile.c	2011-08-14 13:21:45.701217735 +0200
++++ gramofile/gramofile.c	2011-08-14 13:27:15.277217351 +0200
+@@ -42,7 +42,7 @@
+   exit (0);
+ }
+ 
+-void
++int
+ main (void)
+ {
+   char startdir[250];
+@@ -63,4 +63,5 @@
+   mainmenu (startdir);
+ 
+   finishmenu (0);
++  return 0;
+ }
+Index: gramofile/mainmenu.c
+===================================================================
+--- gramofile.orig/mainmenu.c	2011-08-14 13:21:45.657217528 +0200
++++ gramofile/mainmenu.c	2011-08-14 13:27:15.277217351 +0200
+@@ -21,6 +21,7 @@
+ #include "tracksplit.h"
+ #include <stdlib.h>
+ #include <unistd.h>
++#include <string.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+ #else
+Index: gramofile/signpr_cmf.c
+===================================================================
+--- gramofile.orig/signpr_cmf.c	2011-08-14 13:21:45.665217476 +0200
++++ gramofile/signpr_cmf.c	2011-08-14 13:27:15.277217351 +0200
+@@ -30,6 +30,7 @@
+ #include "yesnowindow.h"
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <string.h>
+ #include <math.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+@@ -88,8 +89,8 @@
+   {
+     " ^: no neat interpolation.              v: broad ticks not filtered out.       ",
+     " ^: less ticks detected.                v: not all of tick interpolated.       ",
+-    " ^: bad following of dynamics.          v: less ticks detected.                ",
+-    " ^: bad following of dynamics.          v: less ticks detected.                ",
++    " ^: bad following of dynamics.          v: fewer ticks detected.               ",
++    " ^: bad following of dynamics.          v: fewer ticks detected.               ",
+     " ^: only strong ticks detected.         v: music-ticks also filtered out.      ",
+     " Discard changes.                                                              ",
+     " Reset default values.                                                         ",
+Index: gramofile/signpr_cmf2.c
+===================================================================
+--- gramofile.orig/signpr_cmf2.c	2011-08-14 13:27:14.797217296 +0200
++++ gramofile/signpr_cmf2.c	2011-08-14 13:27:15.277217351 +0200
+@@ -32,6 +32,7 @@
+ #include "yesnowindow.h"
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <string.h>
+ #include <math.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+@@ -90,9 +91,9 @@
+ 
+   char *helplines[8] =
+   {
+-    " ^: less ticks detected.                v: not all of tick interpolated.       ",
+-    " ^: bad following of dynamics.          v: less ticks detected.                ",
+-    " ^: bad following of dynamics.          v: less ticks detected.                ",
++    " ^: fewer ticks detected.               v: not all of tick interpolated.       ",
++    " ^: bad following of dynamics.          v: fewer ticks detected.               ",
++    " ^: bad following of dynamics.          v: fewer ticks detected.               ",
+     " ^: detected tick length too short      v: detected tick length longer.        ",
+     " ^: only strong ticks detected.         v: music-ticks also filtered out.      ",
+     " Discard changes.                                                              ",
+Index: gramofile/signpr_doubmed.c
+===================================================================
+--- gramofile.orig/signpr_doubmed.c	2011-08-14 13:21:45.601217590 +0200
++++ gramofile/signpr_doubmed.c	2011-08-14 13:27:15.277217351 +0200
+@@ -17,6 +17,7 @@
+ #include "helpline.h"
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <string.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+ #else
+Index: gramofile/signpr_mean.c
+===================================================================
+--- gramofile.orig/signpr_mean.c	2011-08-14 13:21:45.625217703 +0200
++++ gramofile/signpr_mean.c	2011-08-14 13:27:15.277217351 +0200
+@@ -17,6 +17,7 @@
+ #include "helpline.h"
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <string.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+ #else
+Index: gramofile/signpr_median.c
+===================================================================
+--- gramofile.orig/signpr_median.c	2011-08-14 13:21:45.641217543 +0200
++++ gramofile/signpr_median.c	2011-08-14 13:27:15.277217351 +0200
+@@ -17,6 +17,7 @@
+ #include "helpline.h"
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <string.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+ #else
+Index: gramofile/signpr_rms.c
+===================================================================
+--- gramofile.orig/signpr_rms.c	2011-08-14 13:21:45.633217367 +0200
++++ gramofile/signpr_rms.c	2011-08-14 13:27:15.277217351 +0200
+@@ -17,6 +17,7 @@
+ #include "helpline.h"
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <string.h>
+ #include <math.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+Index: gramofile/stringinput.c
+===================================================================
+--- gramofile.orig/stringinput.c	2011-08-14 13:21:45.681217673 +0200
++++ gramofile/stringinput.c	2011-08-14 13:27:15.277217351 +0200
+@@ -8,6 +8,7 @@
+  */
+ 
+ #include "stringinput.h"
++#include <string.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+ #else
+Index: gramofile/tracksplit_parammenu.c
+===================================================================
+--- gramofile.orig/tracksplit_parammenu.c	2011-08-14 13:21:45.673228036 +0200
++++ gramofile/tracksplit_parammenu.c	2011-08-14 13:27:15.277217351 +0200
+@@ -16,6 +16,7 @@
+ #include "helpline.h"
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <string.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+ #else
+Index: gramofile/yesnowindow.c
+===================================================================
+--- gramofile.orig/yesnowindow.c	2011-08-14 13:21:45.609217554 +0200
++++ gramofile/yesnowindow.c	2011-08-14 13:27:15.277217351 +0200
+@@ -11,6 +11,7 @@
+ #include "buttons.h"
+ #include "boxes.h"
+ #include "textwindow.h"
++#include <string.h>
+ #ifndef OLD_CURSES
+ #include <ncurses.h>
+ #else
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/20-Makefile.patch
+++ gramofile-1.6/debian/patches/20-Makefile.patch
@@ -0,0 +1,15 @@
+# Unknown decent. Probably from previous maintainer? Not sure why it's
+# needed anyway. [dk]
+Index: gramofile/Makefile
+===================================================================
+--- gramofile.orig/Makefile	2011-08-14 13:22:34.293217619 +0200
++++ gramofile/Makefile	2011-08-14 13:27:14.449217214 +0200
+@@ -50,7 +50,7 @@
+ makebplay: yesnowindow.o boxes.o buttons.o textwindow.o errorwindow.o \
+            clrscr.o secshms.o
+ 	$(MAKE) -C bplaysrc
+-	-rm bplay_gramo brec_gramo
++	-rm -f bplay_gramo brec_gramo
+ 	cp $(COPY_A) bplaysrc/bplay ./bplay_gramo
+ 	ln -s bplay_gramo brec_gramo
+ 
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/60-bplay_in_gramo.patch
+++ gramofile-1.6/debian/patches/60-bplay_in_gramo.patch
@@ -0,0 +1,107 @@
+# Call bplay and brec from dedicated locations rather than from the standard
+# path. Good for the Debian package, maybe not that desirable for the
+# upstream package. [dk]
+Index: gramofile/playwav.c
+===================================================================
+--- gramofile.orig/playwav.c	2011-08-14 13:27:14.941717336 +0200
++++ gramofile/playwav.c	2011-08-14 13:27:16.193217596 +0200
+@@ -32,23 +32,47 @@
+ #include <curses.h>
+ #endif
+ 
++#define BPLAYCMD "/usr/lib/gramofile/bplay_gramo"
+ 
+ void
+ playwav_playit (char *filename, int usebeginendtime, double begintime,
+ 		double endtime)
+ {
+-  char shellcmd[500];
+-
++  char shellcmd[500], *tmp;
++  int len, ret;
++  
+   switch (checkfile (filename))
+     {
+     case FILE_EXISTS:
+-
++	    
++      tmp = shellcmd;
++      len = 500;
++retry:
+       if (usebeginendtime)
+-	sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld \"%s\"",
++	ret = snprintf (tmp, len,
++	          BPLAYCMD " -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);
++	ret = snprintf (tmp, len,
++	                BPLAYCMD " -S -s 44100 -b 16 \"%s\"", filename);
++
++      if (ret > len)
++        {
++	   tmp = alloca(ret);
++	   len = ret;
++	   if (tmp)
++	     goto retry;
++           error_window ("The system ran out of memory");
++	   break;
++	}
++	   
++      if (ret == -1)
++	{
++	   error_window ("Cannot handle file names this long. Sorry.");
++	   break;
++	}
++
+       /* defaults for raw files (but no -r, so .wav's supply their own
+          parameters) - you can even listen to executables in CD quality (: */
+ 
+Index: gramofile/reclp_main.c
+===================================================================
+--- gramofile.orig/reclp_main.c	2011-08-14 13:27:14.941717336 +0200
++++ gramofile/reclp_main.c	2011-08-14 13:27:16.193217596 +0200
+@@ -18,20 +18,39 @@
+ #include <curses.h>
+ #endif
+ 
++#define BRECCMD "/usr/lib/gramofile/brec_gramo"
+ 
+ void
+ record_from_lp (char *startdir)
+ {
+   char filename[250];
+-  char shellcmd[500];
++  char shellcmd[500], *tmp;
++  int ret, len;
+ 
+   if (!record_from_lp_get_filename (startdir, filename))
+     return;
+ 
+   def_prog_mode ();		/* save terminal state */
+ 
+-  sprintf (shellcmd, "brec_gramo -S -s 44100 -b 16 -t 6000 -w \"%s\"",
+-	   filename);
++  tmp = shellcmd;
++  len = 500;
++
++retry:  
++  ret = snprintf (tmp, 500, BRECCMD " -S -s 44100 -b 16 -t 6000 -w \"%s\"",
++	          filename);
++
++  if (ret > len)
++    {
++       tmp = alloca(ret);
++       len = ret;
++       if (tmp)
++         goto retry;
++       return;
++    }
++
++  if (ret == -1)
++    return;
++  
+   system (shellcmd);
+ 
+   reset_prog_mode ();		/* reset terminal state */
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/90_report_recording_errors.patch
+++ gramofile-1.6/debian/patches/90_report_recording_errors.patch
@@ -0,0 +1,140 @@
+# Report errors during recording to the user. [dk]
+Index: gramofile/bplaysrc/shmbuf.c
+===================================================================
+--- gramofile.orig/bplaysrc/shmbuf.c	2011-08-14 13:27:14.625717934 +0200
++++ gramofile/bplaysrc/shmbuf.c	2011-08-14 13:27:16.773717474 +0200
+@@ -80,10 +80,12 @@
+ static char **buffarr;
+ static int numbuffs, numsemblks;
+ static blockinf_t *buffinf;
++static volatile int stoprecording;
+ 
+ /* prototypes */
+ void cleanupsems(void);
+ static void sighandler(int i);
++static void childerrhandler(int i);
+ 
+ /* Extern globals */
+ extern int abuf_size;
+@@ -194,6 +196,8 @@
+     }
+     /* Catch some signals, so we clean up semaphores */
+     signal(SIGINT, sighandler);
++    /* Out of disk space errors are handled explicitly already. */
++    signal(SIGXFSZ, SIG_IGN);
+ }
+ 
+ 
+@@ -240,6 +244,7 @@
+     {
+ 	int cbuff = 0;
+ 	long totalrd = 0; /* we need it here too... */
++	int err = 0;
+ 
+ #ifdef VUMETER
+ 	signed short *ssptr;
+@@ -276,6 +281,13 @@
+                 totalrd += count;
+ 	    }
+ 
++	    if (count == -1 && errno != EINTR) {
++		    err = errno;
++		    for (i = 0; i < numbuffs; i++)
++			    up(sndsemid, i);
++		    break;
++	    }
++
+ #ifdef VUMETER
+ 	    maxleft = 0;
+ 	    maxright = 0;
+@@ -342,19 +354,27 @@
+ 
+ 	printw("\n\n");
+ 	printw("      Recording information:\n\n\n");
+-	fsec2hmsf ( (double) totalrd / (4 * 44100) , timestring);
+-	printw("    Recorded time    : %s\n", timestring);
+-	printw("    Recorded samples : %11ld\n", totalrd / 4);
+-	printw("    Recorded bytes   : %11ld  (excl. header)\n", totalrd);
+-	printw("\n");
+-	printw("    Samples above 50%% of max. volume  : %9ld  (%5.1f%%)\n",
+-          samplesabove50pct, samplesabove50pct * 100. / (totalrd/4));
+-	printw("    Samples above 90%% of max. volume  : %9ld  (%5.1f%%)\n",
+-          samplesabove90pct, samplesabove90pct * 100. / (totalrd/4));
+-	printw("    Samples above 99%% of max. volume  : %9ld  (%5.1f%%)\n",
+-          samplesabove99pct, samplesabove99pct * 100. / (totalrd/4));
+-	printw("    Really too loud (clipped) samples : %9ld  (%5.1f%%)\n",
+-          samplestooloud, samplestooloud * 100. / (totalrd/4));
++
++	if (!err) {
++		
++	  fsec2hmsf ( (double) totalrd / (4 * 44100) , timestring);
++	  printw("    Recorded time    : %s\n", timestring);
++	  printw("    Recorded samples : %11ld\n", totalrd / 4);
++	  printw("    Recorded bytes   : %11ld  (excl. header)\n", totalrd);
++	  printw("\n");
++	  printw("    Samples above 50%% of max. volume  : %9ld  (%5.1f%%)\n",
++            samplesabove50pct, samplesabove50pct * 100. / (totalrd/4));
++	  printw("    Samples above 90%% of max. volume  : %9ld  (%5.1f%%)\n",
++            samplesabove90pct, samplesabove90pct * 100. / (totalrd/4));
++	  printw("    Samples above 99%% of max. volume  : %9ld  (%5.1f%%)\n",
++            samplesabove99pct, samplesabove99pct * 100. / (totalrd/4));
++	  printw("    Really too loud (clipped) samples : %9ld  (%5.1f%%)\n",
++            samplestooloud, samplestooloud * 100. / (totalrd/4));
++
++	} else {
++		printw("    Recording has terminated due to an error.\n");
++		printw("    Operating system reports: %s\n", strerror(err));
++	}
+ 
+ #if 0
+ 	/* The computation of the avg volume is not simple. One approach
+@@ -379,6 +399,11 @@
+                3, strlen (ok_button.text) + 2);
+ 	move (0, 79);
+ 	refresh();
++
++	/* Tell parent to stop recording */
++	if (err)
++		kill(getppid(), SIGUSR1);
++	
+ #endif
+ 
+ 	exit(0);
+@@ -389,9 +414,10 @@
+ 	int cbuff = 0;
+ 	long totalrd = 0;
+ 
+-	int stoprecording=0;
+ 	int in_ch;
+ 
++	signal(SIGUSR1, childerrhandler);
++
+ 	while (totalrd < totalcount && !stoprecording)
+ 	{
+ 	    long trgt, count, numrd;
+@@ -401,11 +427,15 @@
+ 		trgt = abuf_size;
+ 	    /* Get the buffer. Blocks until OK to do so */
+ 	    down(sndsemid, cbuff);
++	    if (stoprecording)
++		    break;
++	    
+ 	    /* Read a block of data */
+ 	    numrd = 0;
+ 	    tmpptr = buffarr[cbuff];
+ 	    while( (numrd < trgt) &&
+-		((count = read(audio, tmpptr, trgt - numrd)) > 0) )
++		((count = read(audio, tmpptr, trgt - numrd)) > 0) &&
++		!stoprecording)
+ 	    {
+ 		numrd += count;
+ 		tmpptr += count;
+@@ -674,3 +704,8 @@
+     finish_curses(1);
+     exit(1);
+ }
++
++static void childerrhandler(int i)
++{
++	stoprecording = 1;
++}
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/series
+++ gramofile-1.6/debian/patches/series
@@ -0,0 +1,14 @@
+20-Makefile.patch
+20-no-busy-wait-after-rec.patch
+20-overflow-fixes.patch
+20-shell-quoting.patch
+20-via-kludge.patch
+20-warning-fixes.patch
+30-basename-fix.patch
+40-fast-swap-and-buffer.patch
+50-cmf3.patch
+60-bplay_in_gramo.patch
+70-endian-fixes.patch
+80_fix_wav_length.patch
+90_report_recording_errors.patch
+91_rename_cdrecord_wodim.patch
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/80_fix_wav_length.patch
+++ gramofile-1.6/debian/patches/80_fix_wav_length.patch
@@ -0,0 +1,49 @@
+# Add post-recording fixup of length fields in wav header to reflect
+# correct file size when recording was stopped prematurely by the user.
+Index: gramofile/bplaysrc/bplay.c
+===================================================================
+--- gramofile.orig/bplaysrc/bplay.c	2011-08-14 13:27:16.377717882 +0200
++++ gramofile/bplaysrc/bplay.c	2011-08-14 13:27:16.605717839 +0200
+@@ -297,14 +297,14 @@
+ 			filetype = F_RAW;	/* Change to change default */
+ 		switch(filetype)
+ 		{
++			wavhead header;
++
+ 		case F_WAV:
+ 			/* Spit out header here... */
+ #ifndef LP2CD
+ 			fprintf(stderr, "Writing MS WAV sound file");
+ #endif
+ 			{
+-				wavhead header;
+-
+ 				char *riff = "RIFF";
+ 				char *wave = "WAVE";
+ 				char *fmt = "fmt ";
+@@ -346,6 +346,25 @@
+ 			initsems(0, 1);
+ 
+ 			shmrec(thefd, bcount, 1);
++
++			/* Rewrite header with updated length fields now
++			 * that we know the true file size. Writing is done
++			 * in a separate process, so it's easiest to gather
++			 * the number of bytes written from fstat(). [dk]
++			 */
++			if (filetype == F_WAV &&
++			    lseek(thefd, 0, SEEK_SET) != -1) {
++				struct stat st;
++				if (fstat(thefd, &st) != -1) {
++					header.length = cpu_to_le32(
++						(u_int32_t) (st.st_size - 8));
++					header.data_length = cpu_to_le32(
++						(u_int32_t) (st.st_size -
++							sizeof(header)));
++					write(thefd, &header, sizeof(header));
++				}
++			}
++				
+ 			break;
+ 		case F_VOC:
+ 			/* Spit out header here... */
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/91_rename_cdrecord_wodim.patch
+++ gramofile-1.6/debian/patches/91_rename_cdrecord_wodim.patch
@@ -0,0 +1,52 @@
+# This patch removes all occurences of "cdrecord" in the source and documentation.
+# This includes removing a link to a (not existing anymore) site of Schilling. 
+#
+# Also changes the packagefile to suggest wodim instead of cdrecord.
+#
+#  by Tobias Frost, tobi@coldtobi.de, 12-31-2006
+#PATCHOPTIONS -p1
+
+Index: gramofile/mainmenu.c
+===================================================================
+--- gramofile.orig/mainmenu.c	2011-08-14 13:27:15.277217351 +0200
++++ gramofile/mainmenu.c	2011-08-14 13:27:16.945717435 +0200
+@@ -219,7 +219,7 @@
+ separation points are computed (previous option), separate audio files \
+ will be generated, each containing one track.",
+ 
+-    "This option is not implemented yet. You can use the `cdrecord' \
++    "This option is not implemented yet. You can use the `wodim' \
+ or `xcdroast' program to create CDs from sound files on the harddisk.",
+ 
+     "(Parts of) sound files can be played with this option."
+Index: gramofile/README
+===================================================================
+--- gramofile.orig/README	2011-08-14 13:21:45.009217561 +0200
++++ gramofile/README	2011-08-14 13:27:16.945717435 +0200
+@@ -217,19 +217,16 @@
+ 
+ Write an audio CD: 
+  - This option is not yet implemented. There are some plans to program a
+-    uniform user interface to the cdrecord(1) program here. You have to
++    uniform user interface to the wodim(1) program here. You have to
+     use the bare program for this moment. Try something like
+ 
+-    cdrecord -v speed=2 dev=0,2,0 -audio -pad track01.wav track02.wav ... 
++    wodim -v speed=2 dev=0,2,0 -audio -pad track01.wav track02.wav ... 
+ 
+-    Actual information on cdrecord may be found on:
+-    http://www.fokus.gmd.de/research/cc/glone/employees/
+-                                     joerg.schilling/private/cdrecord.html
+-
+-    If you like a graphical front-end to write CD's, try the xcdroast
+-    program:
+-    http://www.fh-muenchen.de/rz/xcdroast
+-    (Note: you may have to use the wav2cdr utility.)
++    Please check out the wodim package or the cdrkit-doc package for 
++    details.
++    
++    You always can use a graphical front-end to write CD's, like the 
++    xcdroast program. See the xcdroast package for details.
+ 
+ Play an audio file: 
+  - Make sure the PCM and Master volumes are set high enough, and your
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/20-via-kludge.patch
+++ gramofile-1.6/debian/patches/20-via-kludge.patch
@@ -0,0 +1,32 @@
+# Patch by Joerg Specht <joerg.specht@ins.uni-stuttgart.de>
+# Cleaned up some cruft in @@ lines--weird. [dk]
+Index: gramofile/bplaysrc/sndfunc.c
+===================================================================
+--- gramofile.orig/bplaysrc/sndfunc.c	2011-08-14 13:21:45.753217822 +0200
++++ gramofile/bplaysrc/sndfunc.c	2011-08-14 13:27:15.113717191 +0200
+@@ -22,6 +22,7 @@
+ 
+ /* Globals */
+ int audio, abuf_size, fmt_mask;
++int audio_recorder;
+ 
+ /* Prototypes */
+ void sync_audio(void);
+@@ -36,6 +37,7 @@
+ void init_sound(int recorder)
+ {
+     /* Attempt to open the audio device */
++    audio_recorder = recorder;
+     audio = open(AUDIO, (recorder)? O_RDONLY : O_WRONLY);
+     if (audio == -1)
+ 	ErrDie(AUDIO);
+@@ -76,6 +78,9 @@
+ 
+ void sync_audio(void)
+ {
++    /* at least Linux' via82cxxx_audio-driver reports error	*/
++    /* when trying to SNDCTL_DSP_SYNC in O_RDONLY mode		*/
+     if (ioctl (audio, SNDCTL_DSP_SYNC, NULL) < 0)
++      if (!audio_recorder)
+ 	ErrDie(AUDIO);
+ }
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/50-cmf3.patch
+++ gramofile-1.6/debian/patches/50-cmf3.patch
@@ -0,0 +1,1334 @@
+# Patch by James Tappin <james@xena.uklinux.net>
+# Rediffed to unified format. [dk]
+# Case changes to name of doc file to comply with rest of docs. [dk]
+Index: gramofile/Makefile
+===================================================================
+--- gramofile.orig/Makefile	2011-08-14 13:27:15.777717640 +0200
++++ gramofile/Makefile	2011-08-14 13:27:15.969717630 +0200
+@@ -7,7 +7,8 @@
+         signpr_general.c signpr_median.c signpr_filtmenu.c signpr_wav.c	\
+ 	secshms.c playwav.c signpr_cmf.c signpr_mean.c signpr_doubmed.c	\
+ 	splashscr.c tracksplit.c tracksplit_filenm.c			\
+-        tracksplit_parammenu.c signpr_cmf2.c signpr_rms.c signpr_copy.c	\
++        tracksplit_parammenu.c signpr_cmf2.c  signpr_cmf3.c             \
++	signpr_rms.c signpr_copy.c	\
+         signpr_exper.c endian.c signpr_mono.c signpr_l1fit.c
+ 
+ OBJS = $(SRCS:.c=.o)
+@@ -21,19 +22,19 @@
+ # For Linux (and maybe others), use these:
+ CFLAGS = -Wall -O2 -funroll-loops -DTURBO_MEDIAN -DTURBO_BUFFER
+ DEPS = $(OBJS) makebplay
+-LIBS = -lncurses -lm
++LIBS = -lncurses -lrfftw -lfftw -lm
+ COPY_A = -a
+ 
+ # For FreeBSD (and maybe others), use these:
+ #CFLAGS = -Wall -O2 -DTURBO_MEDIAN -DTURBO_BUFFER
+ #DEPS = $(OBJS) makebplay
+-#LIBS = -lncurses -lm
++#LIBS = -lncurses  -lrfftw -lfftw -lm
+ #COPY_A = -p
+ 
+ # For IRIX (and maybe others), use these:
+ #CFLAGS = -Wall -O2 -DTURBO_MEDIAN -DTURBO_BUFFER -DSWAP_ENDIAN -DOLD_CURSES
+ #DEPS = $(OBJS)
+-#LIBS = -lcurses -lm
++#LIBS = -lcurses  -lrfftw -lfftw -lm
+ #COPY_A = -a
+ 
+ ##########
+Index: gramofile/Signpr_cmf3.txt
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ gramofile/Signpr_cmf3.txt	2011-08-14 13:27:15.969717630 +0200
+@@ -0,0 +1,42 @@
++SIGNPR_CMF3
++===========
++
++James Tappin: April 2001
++
++Signpr_cmf3 is a modification of signpr_cmf2, which uses a
++frequency-domain method to fill in the ticks.
++
++Why?: Because although cmf2 does an excellent job of detecting ticks,
++it makes a horrid mess of interpolating those that are close the peak
++of a sound wave (a situation which occurs very often on some 78's --
++indeed on some of my record the majority of the clicks are on peaks)
++and the resulting sound can then be worse than the original.
++
++What to do?: Since cmf2 does a very good job of picking out ticks that
++bit is unchanged, my goal here was to find a way that would smooth over
++the tick without cutting off more-or-less a half-cycle of the sound
++wave. Since the tick is located at the peak, and zeroth (the original
++cmf2) or first (FANCY_FILL) order interpolation will cut off the peak
++and thus cause an acoustically unpleasant breakup of the
++sound. Therefore I have here attempted to take a FFT of a region around
++the tick then exclude frequencies corresponding to features of the
++length of the tick or smaller. In the present version this is done by
++setting the components above this frequency to zero.
++
++Problems: It's slow -- If I could see a way to do 1 fft per tick rather
++than 1 fft per interpolated point it could go much quicker, but I don't
++see that this can be done within the gramofile buffers framework.
++
++What does it need: The fft's are done using the "fastest fourier
++transform in the west" http://www.fftw.org/ which attempts to find an
++optimum  way of doing the fft for the architecture and the size of the
++transform. In order to hold the fft plans and the length of the fft, 3
++new fields are added to the parampointer variable.
++
++Settings: The tick identification algorithm is identical with that used
++in cmf2 and the settings are therefore the same. The choice of fft
++length is determined as: Too large a value will slow the computation
++(remember fft is an n log(n) process), while too small a value results
++in a poor smoothing as the side lobes of the tick are have a larger
++effect on the values. The default is 2^9 (512).
++
+Index: gramofile/signpr_cmf3.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ gramofile/signpr_cmf3.c	2011-08-14 13:27:15.969717630 +0200
+@@ -0,0 +1,1085 @@
++/* Conditional Median Filter - Better Version
++ *                             Using fft and eliminating high frequencies 
++ *                             to fill over the ticks.
++ *
++ * Copyright (C) 1998 J.A. Bezemer
++ *               2001 S.J. Tappin
++ *
++ * Licensed under the terms of the GNU General Public License.
++ * ABSOLUTELY NO WARRANTY.
++ * See the file `COPYING' in this directory.
++ */
++
++/* Remove the `dont' to get the gate instead of the normal output - useful
++   for verifying properties. */
++#define dontVIEW_INTERNALS
++
++/* Choose the highpass filter: */
++#define noSECOND_ORDER
++#define FOURTH_ORDER
++#define noSIXTH_ORDER
++
++#define noDEBUGFILE
++
++#include "signpr_cmf3.h"
++#include "signpr_general.h"
++#include "signpr_l1fit.h"
++#include "errorwindow.h"
++#include "stringinput.h"
++#include "buttons.h"
++#include "clrscr.h"
++#include "boxes.h"
++#include "helpline.h"
++#include "yesnowindow.h"
++#include <stdlib.h>
++#include <stdio.h>
++#include <math.h>
++#ifndef OLD_CURSES
++#include <ncurses.h>
++#else
++#include <curses.h>
++#endif
++
++#ifdef DEBUGFILE
++static FILE *debugf=NULL;
++#endif
++
++#ifndef M_PIl
++# define M_PIl          3.1415926535897932384626433832795029L  /* pi */ 
++#endif
++
++void
++cond_median3_param_defaults (parampointer_t parampointer)
++{
++  parampointer->postlength2 = 4;
++  parampointer->prelength2 = 4;
++  parampointer->postlength3 = 5;
++  parampointer->prelength3 = 5;
++  parampointer->postlength4 = 256;
++  parampointer->prelength4 = 255;
++
++  parampointer->int1 = 12;
++  parampointer->int2 = 9;      /* This could be derived from
++				  postlength4 and prelength4, 
++				  but it's messy */
++#if defined (SECOND_ORDER)
++  parampointer->long1 = 1000;	/* Threshold to detect precise tick length. */
++  parampointer->long2 = 2500;	/* Must be above this to be a tick. */
++#elif defined (FOURTH_ORDER)
++  parampointer->long1 = 2000;
++  parampointer->long2 = 8500;
++#elif defined (SIXTH_ORDER)
++  parampointer->long1 = 1500;
++  parampointer->long2 = 7500;
++#else
++#error A Highpass version must be defined (signpr_cmf3.c)
++#endif
++
++}
++
++
++#ifdef FOURTH_ORDER
++#undef SIGNPR_CMF3_PARAMSCR_HEADERTEXT
++#define SIGNPR_CMF3_PARAMSCR_HEADERTEXT "CMF IIF [FOURTH ORDER] - Parameters"
++#endif
++
++#ifdef SIXTH_ORDER
++#undef SIGNPR_CMF3_PARAMSCR_HEADERTEXT
++#define SIGNPR_CMF3_PARAMSCR_HEADERTEXT "CMF IIF [SIXTH ORDER] - Parameters"
++#endif
++
++void
++cond_median3_param_screen (parampointer_t parampointer)
++{
++  stringinput_t rmslengthstr, rmflengthstr, decimatestr, threshold1str;
++  stringinput_t threshold2str, fftstr;
++  button_t ok_button, cancel_button, defaults_button;
++  int dont_stop = TRUE;
++  int focus = 0;
++  int in_ch;
++  int i;
++  long helplong;
++
++  char *helplines[9] =
++  {
++    " ^: less ticks detected.                v: not all of tick interpolated.       ",
++    " ^: bad following of dynamics.          v: less ticks detected.                ",
++    " ^: bad following of dynamics.          v: less ticks detected.                ",
++    " ^: detected tick length too short      v: detected tick length longer.        ",
++    " ^: only strong ticks detected.         v: music-ticks also filtered out.      ",
++    " ^: Slower interpolation                v: possible problems with long ticks   ",
++    " Discard changes.                                                              ",
++    " Reset default values.                                                         ",
++    " Accept changes.                                                               "};
++
++  rmslengthstr.maxlen = 500;
++  rmslengthstr.string = (char *) malloc (rmslengthstr.maxlen *
++					 sizeof (char));
++  sprintf (rmslengthstr.string, "%ld", parampointer->prelength2 +
++	   parampointer->postlength2 + 1);
++  rmslengthstr.y = 6;
++  rmslengthstr.x = 59;
++  rmslengthstr.w = 19;
++  rmslengthstr.cursorpos = strlen (rmslengthstr.string);
++  rmslengthstr.firstcharonscreen = 0;
++
++  rmflengthstr.maxlen = 500;
++  rmflengthstr.string = (char *) malloc (rmflengthstr.maxlen *
++					 sizeof (char));
++  sprintf (rmflengthstr.string, "%ld", parampointer->prelength3 +
++	   parampointer->postlength3 + 1);
++  rmflengthstr.y = 8;
++  rmflengthstr.x = 59;
++  rmflengthstr.w = 19;
++  rmflengthstr.cursorpos = strlen (rmflengthstr.string);
++  rmflengthstr.firstcharonscreen = 0;
++
++  decimatestr.maxlen = 500;
++  decimatestr.string = (char *) malloc (decimatestr.maxlen *
++					sizeof (char));
++  sprintf (decimatestr.string, "%d", parampointer->int1);
++  decimatestr.y = 10;
++  decimatestr.x = 59;
++  decimatestr.w = 19;
++  decimatestr.cursorpos = strlen (decimatestr.string);
++  decimatestr.firstcharonscreen = 0;
++
++  threshold1str.maxlen = 500;
++  threshold1str.string = (char *) malloc (threshold1str.maxlen *
++					  sizeof (char));
++  sprintf (threshold1str.string, "%ld", parampointer->long1);
++  threshold1str.y = 12;
++  threshold1str.x = 59;
++  threshold1str.w = 19;
++  threshold1str.cursorpos = strlen (threshold1str.string);
++  threshold1str.firstcharonscreen = 0;
++
++  threshold2str.maxlen = 500;
++  threshold2str.string = (char *) malloc (threshold2str.maxlen *
++					  sizeof (char));
++  sprintf (threshold2str.string, "%ld", parampointer->long2);
++  threshold2str.y = 14;
++  threshold2str.x = 59;
++  threshold2str.w = 19;
++  threshold2str.cursorpos = strlen (threshold2str.string);
++  threshold2str.firstcharonscreen = 0;
++
++  fftstr.maxlen = 500;
++  fftstr.string = (char *) malloc (fftstr.maxlen *
++					  sizeof (char));
++  sprintf (fftstr.string, "%d", parampointer->int2);
++  fftstr.y = 16;
++  fftstr.x = 59;
++  fftstr.w = 19;
++  fftstr.cursorpos = strlen (fftstr.string);
++  fftstr.firstcharonscreen = 0;
++
++
++  ok_button.text = " OK ";
++  ok_button.y = 20;
++  ok_button.x = 71;
++  ok_button.selected = FALSE;
++
++  cancel_button.text = " Cancel ";
++  cancel_button.y = 20;
++  cancel_button.x = 5;
++  cancel_button.selected = FALSE;
++
++  defaults_button.text = " Defaults ";
++  defaults_button.y = 20;
++  defaults_button.x = 36;
++  defaults_button.selected = FALSE;
++
++  clearscreen (SIGNPR_CMF3_PARAMSCR_HEADERTEXT);
++
++  do
++    {
++      header (SIGNPR_CMF3_PARAMSCR_HEADERTEXT);
++
++      if (focus == 6)
++	cancel_button.selected = TRUE;
++      else
++	cancel_button.selected = FALSE;
++
++      if (focus == 7)
++	defaults_button.selected = TRUE;
++      else
++	defaults_button.selected = FALSE;
++
++      if (focus == 8)
++	ok_button.selected = TRUE;
++      else
++	ok_button.selected = FALSE;
++
++      mvprintw (3, 2,
++       "See also the Signproc.txt file for the meaning of the parameters.");
++
++      stringinput_display (&rmslengthstr);
++      mvprintw (rmslengthstr.y, 2,
++		"Length of the RMS operation (samples):");
++
++      stringinput_display (&rmflengthstr);
++      mvprintw (rmflengthstr.y, 2,
++		"Length of the recursive median operation (samples):");
++
++      stringinput_display (&decimatestr);
++      mvprintw (decimatestr.y, 2,
++		"Decimation factor for the recursive median:");
++
++      stringinput_display (&threshold1str);
++      mvprintw (threshold1str.y, 2,
++		"Fine threshold for tick start/end (thousandths):");
++
++      stringinput_display (&threshold2str);
++      mvprintw (threshold2str.y, 2,
++		"Threshold for detection of tick presence (thousandths):");
++
++      stringinput_display (&fftstr);
++      mvprintw (fftstr.y, 2,
++		"Length for fft to interpolate (2^n):");
++
++      button_display (&cancel_button);
++      mybox (cancel_button.y - 1, cancel_button.x - 1,
++	     3, strlen (cancel_button.text) + 2);
++      button_display (&defaults_button);
++      mybox (defaults_button.y - 1, defaults_button.x - 1,
++	     3, strlen (defaults_button.text) + 2);
++      button_display (&ok_button);
++      mybox (ok_button.y - 1, ok_button.x - 1,
++	     3, strlen (ok_button.text) + 2);
++
++      helpline (helplines[focus]);
++
++      switch (focus)
++	{
++	case 0:
++	  stringinput_display (&rmslengthstr);
++	  break;
++	case 1:
++	  stringinput_display (&rmflengthstr);
++	  break;
++	case 2:
++	  stringinput_display (&decimatestr);
++	  break;
++	case 3:
++	  stringinput_display (&threshold1str);
++	  break;
++	case 4:
++	  stringinput_display (&threshold2str);
++	  break;
++	case 5:
++	  stringinput_display (&fftstr);
++	  break;
++	default:
++	  move (0, 79);
++	}
++
++      refresh ();
++
++      in_ch = getch ();
++
++      switch (focus)
++	{
++	case 0:		/* rmslengthstr */
++	  stringinput_stdkeys (in_ch, &rmslengthstr);
++	  switch (in_ch)
++	    {
++	    case KEY_ENTER:
++	    case 13:
++	      i = sscanf (rmslengthstr.string, "%li", &helplong);
++	      if (i < 1 || helplong < 1 || helplong % 2 == 0)
++		error_window ("A whole, odd number, greater than 0, must \
++be specified.");
++	      else
++		focus++;
++	      break;
++
++	    case KEY_UP:
++	      focus--;
++	      break;
++	    case KEY_DOWN:
++	      focus++;
++	      break;
++	    }
++	  break;
++
++	case 1:		/* rmflengthstr */
++	  stringinput_stdkeys (in_ch, &rmflengthstr);
++	  switch (in_ch)
++	    {
++	    case KEY_ENTER:
++	    case 13:
++	      i = sscanf (rmflengthstr.string, "%li", &helplong);
++	      if (i < 1 || helplong < 1 || helplong % 2 == 0)
++		error_window ("A whole, odd number, greater than 0, must \
++be specified.");
++	      else
++		focus++;
++	      break;
++
++	    case KEY_UP:
++	      focus--;
++	      break;
++	    case KEY_DOWN:
++	      focus++;
++	      break;
++	    }
++	  break;
++
++	case 2:		/* decimatestr */
++	  stringinput_stdkeys (in_ch, &decimatestr);
++	  switch (in_ch)
++	    {
++	    case KEY_ENTER:
++	    case 13:
++	      i = sscanf (decimatestr.string, "%li", &helplong);
++	      if (i < 1 || helplong < 1)
++		error_window ("A whole number, greater than 0, must \
++be specified.");
++	      else
++		focus++;
++	      break;
++
++	    case KEY_UP:
++	      focus--;
++	      break;
++	    case KEY_DOWN:
++	      focus++;
++	      break;
++	    }
++	  break;
++
++	case 3:		/* threshold1str */
++	  stringinput_stdkeys (in_ch, &threshold1str);
++	  switch (in_ch)
++	    {
++	    case KEY_ENTER:
++	    case 13:
++	      i = sscanf (threshold1str.string, "%li", &helplong);
++	      if (i < 1 || helplong < 1)
++		error_window ("A whole, positive number must be specified.");
++	      else
++		focus++;
++	      break;
++
++	    case KEY_UP:
++	      focus--;
++	      break;
++	    case KEY_DOWN:
++	      focus++;
++	      break;
++	    }
++	  break;
++
++	case 4:		/* threshold2str */
++	  stringinput_stdkeys (in_ch, &threshold2str);
++	  switch (in_ch)
++	    {
++	    case KEY_ENTER:
++	    case 13:
++	      i = sscanf (threshold2str.string, "%li", &helplong);
++	      if (i < 1 || helplong < 1)
++		error_window ("A whole, positive number must be specified.");
++	      else
++		focus++;
++	      break;
++
++	    case KEY_UP:
++	      focus--;
++	      break;
++	    case KEY_DOWN:
++	      focus++;
++	      break;
++	    }
++	  break;
++
++	case 5:		/* fft length */
++	  stringinput_stdkeys (in_ch, &fftstr);
++	  switch (in_ch)
++	    {
++	    case KEY_ENTER:
++	    case 13:
++	      i = sscanf (fftstr.string, "%li", &helplong);
++	      if (i < 1 || helplong > 12 || helplong < 6)
++		error_window ("A number between 6 and 12 must be specified.");
++	      else
++		focus = 8;
++	      break;
++
++	    case KEY_UP:
++	      focus--;
++	      break;
++	    case KEY_DOWN:
++	      focus++;
++	      break;
++	    }
++	  break;
++
++	case 6:		/* Cancel */
++	  switch (in_ch)
++	    {
++	    case KEY_ENTER:
++	    case 13:
++	      dont_stop = FALSE;
++	      break;
++
++	    case KEY_LEFT:
++	    case KEY_UP:
++	      focus--;
++	      break;
++	    case KEY_RIGHT:
++	    case KEY_DOWN:
++	      focus++;
++	      break;
++	    }
++	  break;
++
++	case 7:		/* Defaults */
++	  switch (in_ch)
++	    {
++	    case KEY_ENTER:
++	    case 13:
++	      if (yesno_window ("Restore default parameters?", " Yes ",
++				" No ", 0))
++		{
++		  cond_median3_param_defaults (parampointer);
++		  dont_stop = FALSE;
++		}
++	      break;
++
++	    case KEY_LEFT:
++	    case KEY_UP:
++	      focus--;
++	      break;
++	    case KEY_RIGHT:
++	    case KEY_DOWN:
++	      focus++;
++	      break;
++	    }
++	  break;
++
++	case 8:		/* OK */
++	  switch (in_ch)
++	    {
++	    case KEY_ENTER:
++	    case 13:
++
++	      i = sscanf (rmslengthstr.string, "%li", &helplong);
++	      if (i < 1 || helplong < 1 || helplong % 2 == 0)
++		{
++		  error_window ("A whole, odd number, greater than 0, must \
++be specified as RMS length.");
++		  rmslengthstr.cursorpos =
++		    strlen (rmslengthstr.string);
++		  focus = 0;
++		  break;
++		}
++
++	      parampointer->prelength2 = (helplong - 1) / 2;
++	      parampointer->postlength2 = (helplong - 1) / 2;
++
++	      i = sscanf (rmflengthstr.string, "%li", &helplong);
++	      if (i < 1 || helplong < 1 || helplong % 2 == 0)
++		{
++		  error_window ("A whole, odd number, greater than 0, must \
++be specified as length of the recursive median.");
++		  rmflengthstr.cursorpos =
++		    strlen (rmflengthstr.string);
++		  focus = 1;
++		  break;
++		}
++
++	      parampointer->prelength3 = (helplong - 1) / 2;
++	      parampointer->postlength3 = (helplong - 1) / 2;
++
++	      i = sscanf (decimatestr.string, "%li", &helplong);
++	      if (i < 1 || helplong < 1)
++		{
++		  error_window ("A whole number, greater than 0, must \
++be specified as decimation factor.");
++		  decimatestr.cursorpos =
++		    strlen (decimatestr.string);
++		  focus = 2;
++		  break;
++		}
++
++	      parampointer->int1 = helplong;
++
++	      i = sscanf (threshold1str.string, "%li", &helplong);
++	      if (i < 1 || helplong < 1)
++		{
++		  error_window ("A whole, positive number must be \
++specified as threshold.");
++		  threshold1str.cursorpos =
++		    strlen (threshold1str.string);
++		  focus = 3;
++		  break;
++		}
++
++	      parampointer->long1 = helplong;
++
++	      i = sscanf (threshold2str.string, "%li", &helplong);
++	      if (i < 1 || helplong < 1000)
++		{
++		  error_window ("A whole, positive number must be \
++specified as threshold.");
++		  threshold2str.cursorpos =
++		    strlen (threshold2str.string);
++		  focus = 4;
++		  break;
++		}
++
++	      parampointer->long2 = helplong;
++
++	      i = sscanf (fftstr.string, "%li", &helplong);
++	      if (i < 1 || helplong > 12 || helplong < 6) {
++		error_window ("A number between 6 and 12 must be specified \
++as fft length");
++		fftstr.cursorpos = strlen(fftstr.string);
++		focus = 5;
++		break;
++	      }
++
++	      parampointer->int2 = helplong;
++	      parampointer->prelength4 = 1;
++	      for (i=1; i < parampointer->int2; i++) parampointer->prelength4 *= 2;
++	      parampointer->postlength4 = parampointer->prelength4-1;
++
++	      dont_stop = FALSE;
++	      break;
++
++	    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 > 8)
++	focus = 0;
++      if (focus < 0)
++	focus = 8;
++    }
++  while (dont_stop);
++
++  free (rmslengthstr.string);
++  free (rmflengthstr.string);
++  free (decimatestr.string);
++  free (threshold1str.string);
++  free (threshold2str.string);
++}
++
++void
++init_cond_median3_filter (int filterno, parampointer_t parampointer)
++{
++  long total_post;
++  long total_pre;
++  long l;
++
++  total_post = parampointer->postlength4 + parampointer->prelength4 + 1 + 4;
++  /* +1+4=+5 : for highpass, max. 11th order */
++
++  total_pre = parampointer->postlength4 + parampointer->prelength4 + 1;
++  l = parampointer->prelength4 + parampointer->prelength3 *
++    parampointer->int1 + parampointer->prelength2 + 5;
++  /* + 5 : for highpass, max. 11th order */
++  if (l > total_pre)
++    total_pre = l;
++
++  parampointer->buffer = init_buffer (total_post, total_pre);
++  parampointer->buffer2 = init_buffer (parampointer->postlength2,
++				       parampointer->prelength2);
++  parampointer->buffer3 = init_buffer (parampointer->postlength3,
++			     parampointer->prelength3 * parampointer->int1);
++  parampointer->buffer4 = init_buffer (parampointer->postlength4,
++				       parampointer->prelength4);
++
++  parampointer->filterno = filterno;
++
++  /* Set up the FFT plans here. Since we expect to do lots of FFTs,
++     we take the time to MEASURE the best way to do them [SJT] */
++
++  parampointer->planf = rfftw_create_plan(parampointer->postlength4 +
++					  parampointer->prelength4 + 1,
++					  FFTW_REAL_TO_COMPLEX,
++					  FFTW_MEASURE);
++  parampointer->planr = rfftw_create_plan(parampointer->postlength4 +
++					  parampointer->prelength4 + 1,
++					  FFTW_COMPLEX_TO_REAL,
++					  FFTW_MEASURE);
++
++#ifdef DEBUGFILE
++  debugf = fopen("./gram.txt","w");
++#endif
++
++
++}
++
++
++void
++delete_cond_median3_filter (parampointer_t parampointer)
++{
++  delete_buffer (&parampointer->buffer);
++  delete_buffer (&parampointer->buffer2);
++  delete_buffer (&parampointer->buffer3);
++  delete_buffer (&parampointer->buffer4);
++
++  rfftw_destroy_plan(parampointer->planf);
++  rfftw_destroy_plan(parampointer->planr);
++
++#ifdef DEBUGFILE
++  fclose(debugf);
++#endif
++}
++
++
++sample_t
++cond_median3_highpass (long offset, long offset_zero,
++		       parampointer_t parampointer)
++{
++  sample_t sample;
++  longsample_t sum;
++
++  offset += offset_zero;	/* middle for highpass filter in
++				   'big buffer' */
++  sum.left = 0;
++  sum.right = 0;
++
++#if defined (SECOND_ORDER)
++#define notTEST_DAVE_PLATT
++#ifndef TEST_DAVE_PLATT
++  /* Original: */
++  sample = get_from_buffer (&parampointer->buffer, offset - 1);
++  sum.left += sample.left;
++  sum.right += sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset);
++  sum.left -= 2 * (long) sample.left;
++  sum.right -= 2 * (long) sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset + 1);
++  sum.left += sample.left;
++  sum.right += sample.right;
++
++  sum.left /= 4;
++  sum.right /= 4;
++#else /* TEST_DAVE_PLATT */
++  /* Testing, suggested by Dave Platt. Invert phase of one channel, then
++     do tick detection using the sum signal. This is because most ticks
++     are out-of-phase signals. I've not really tested this - it might
++     require other settings for thresholds etc.
++     Note: implemented for second_order only! */
++  sample = get_from_buffer (&parampointer->buffer, offset - 1);
++  sum.left += sample.left;
++  sum.left -= sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset);
++  sum.left -= 2 * (long) sample.left;
++  sum.left += 2 * (long) sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset + 1);
++  sum.left += sample.left;
++  sum.left -= sample.right;
++
++  /* just in case L/R: 32000/-32000 -32000/32000 32000/-32000 : */
++  sum.left /= 8;
++  sum.right = sum.left;
++#endif /* TEST_DAVE_PLATT */
++
++#elif defined (FOURTH_ORDER)
++  sample = get_from_buffer (&parampointer->buffer, offset - 2);
++  sum.left += sample.left;
++  sum.right += sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset - 1);
++  sum.left -= 4 * (long) sample.left;
++  sum.right -= 4 * (long) sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset);
++  sum.left += 6 * (long) sample.left;
++  sum.right += 6 * (long) sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset + 1);
++  sum.left -= 4 * (long) sample.left;
++  sum.right -= 4 * (long) sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset + 2);
++  sum.left += sample.left;
++  sum.right += sample.right;
++
++  sum.left /= 4;
++  sum.right /= 4;
++
++#elif defined (SIXTH_ORDER)
++  sample = get_from_buffer (&parampointer->buffer, offset - 3);
++  sum.left -= sample.left;
++  sum.right -= sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset - 2);
++  sum.left += 6 * (long) sample.left;
++  sum.right += 6 * (long) sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset - 1);
++  sum.left -= 15 * (long) sample.left;
++  sum.right -= 15 * (long) sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset);
++  sum.left += 20 * (long) sample.left;
++  sum.right += 20 * (long) sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset + 1);
++  sum.left -= 15 * (long) sample.left;
++  sum.right -= 15 * (long) sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset + 2);
++  sum.left += 6 * (long) sample.left;
++  sum.right += 6 * (long) sample.right;
++  sample = get_from_buffer (&parampointer->buffer, offset + 3);
++  sum.left -= sample.left;
++  sum.right -= sample.right;
++
++  /* Should be /64, but the signal is extremely soft, so divide by less to
++     get more quantization levels (more accurate) */
++  sum.left /= 4;
++  sum.right /= 4;
++#endif
++
++  if (sum.left > 32767)
++    sample.left = 32767;
++  else if (sum.left < -32768)
++    sample.left = -32768;
++  else
++    sample.left = sum.left;
++
++
++  if (sum.right > 32767)
++    sample.right = 32767;
++  else if (sum.right < -32768)
++    sample.right = -32768;
++  else 
++    sample.right = sum.right;
++
++
++  return sample;
++}
++
++fillfuncpointer_t cond_median3_highpass_pointer = cond_median3_highpass;
++
++sample_t
++cond_median3_rms (long offset, long offset_zero,
++		  parampointer_t parampointer)
++{
++  sample_t sample;
++  doublesample_t doublesample;
++  doublesample_t sum;
++  long i;
++
++  advance_current_pos_custom (&parampointer->buffer2,
++			      cond_median3_highpass_pointer,
++			      offset + offset_zero,
++			      parampointer);
++
++  sum.left = 0;
++  sum.right = 0;
++
++  for (i = -parampointer->postlength2; i <= parampointer->prelength2;
++       i++)
++    {
++      sample = get_from_buffer (&parampointer->buffer2, i);
++      doublesample.left = sample.left;
++      doublesample.right = sample.right;
++      sum.left += doublesample.left * doublesample.left;
++      sum.right += doublesample.right * doublesample.right;
++    }
++
++  sum.left /= (parampointer->postlength2 +
++	       parampointer->prelength2 + 1);
++  sum.right /= (parampointer->postlength2 +
++		parampointer->prelength2 + 1);
++
++  sample.left = sqrt (sum.left + 1);
++  sample.right = sqrt (sum.right + 1);
++
++  return sample;
++}
++
++fillfuncpointer_t cond_median3_rms_pointer = cond_median3_rms;
++
++sample_t
++cond_median3_gate (long offset, long offset_zero,
++		   parampointer_t parampointer)
++/* Well, not a `gate' any more - just (w[t]-b[t])/b[t], comparision to
++   make the real gate is done later. */
++{
++  sample_t sample;
++  sample_t w_t;
++  sample_t b_t;
++  sample_t returnval;
++  signed short list1[parampointer->postlength3 +
++		     parampointer->prelength3 * parampointer->int1 + 1];
++  signed short list2[parampointer->postlength3 +
++		     parampointer->prelength3 * parampointer->int1 + 1];
++  long i, j;
++
++  advance_current_pos_custom (&parampointer->buffer3,
++			      cond_median3_rms_pointer,
++			      offset + offset_zero,
++			      parampointer);
++
++  w_t = get_from_buffer (&parampointer->buffer3, 0);
++
++  /* The RMF Filter */
++
++  for (i = 0; i < parampointer->postlength3; i++)
++    {
++      sample = get_from_buffer (&parampointer->buffer3,
++				i - parampointer->postlength3);
++      list1[i] = sample.left;
++      list2[i] = sample.right;
++    }
++
++  j = i;
++
++  for (; i <= parampointer->postlength3 +
++       parampointer->prelength3 * parampointer->int1;
++       i += parampointer->int1)
++    {
++      sample = get_from_buffer (&parampointer->buffer3,
++				i - parampointer->postlength3);
++      list1[j] = sample.left;
++      list2[j] = sample.right;
++      j++;
++    }
++
++  b_t.left = median (list1, j);
++  b_t.right = median (list2, j);
++
++  put_in_buffer (&parampointer->buffer3, 0, b_t);
++
++
++  i = (labs (w_t.left - b_t.left) * 1000)
++    /
++    b_t.left;
++  if (i > 32767)
++    i = 32767;
++  else if (i < -32768)
++    i = -32768;
++
++  returnval.left = i;
++
++  i = (labs (w_t.right - b_t.right) * 1000)
++    /
++    b_t.right;
++  if (i > 32767)
++    i = 32767;
++  else if (i < -32768)
++    i = -32768;
++  returnval.right = i;
++
++  return returnval;
++}
++
++fillfuncpointer_t cond_median3_gate_pointer = cond_median3_gate;
++
++sample_t
++cond_median3_filter (parampointer_t parampointer)
++{
++  sample_t sample, gate, returnval;
++  /* Length of the fft we'll do to get the smoothed interpolate */
++
++  fftw_real list3[parampointer->postlength4 +
++		 parampointer->prelength4 + 1];
++  fftw_real list4[parampointer->postlength4 +
++		 parampointer->prelength4 + 1];
++
++  long fft_l = parampointer->postlength4 + parampointer->prelength4 + 1;
++  long i;
++  int toleft, toright, nfreq;
++  signed short maxval;
++
++  advance_current_pos (&parampointer->buffer, parampointer->filterno);
++
++  advance_current_pos_custom (&parampointer->buffer4,
++			      cond_median3_gate_pointer,
++			      0,
++			      parampointer);
++
++  gate = get_from_buffer (&parampointer->buffer4, 0);
++
++#ifdef VIEW_INTERNALS
++  returnval.left = 0;
++  returnval.right = 0;
++#else
++  /* 'Default' value - unchanged if there is no tick */
++  returnval = get_from_buffer (&parampointer->buffer, 0);
++#endif
++
++  if (gate.left > parampointer->long1)
++    {
++      maxval = gate.left;
++
++      toleft = -1;
++      sample.left = 0;
++      do
++	{
++	  toleft++;
++	  if (toleft < parampointer->postlength4)
++	    {
++	      sample = get_from_buffer (&parampointer->buffer4, -toleft - 1);
++	      if (sample.left > maxval)
++		/* if so, the `while' will continue anyway, so maxval may
++		   be adjusted here already (if necessary) */
++		maxval = sample.left;
++	    }
++	}
++      while (toleft < parampointer->postlength4 &&
++	     sample.left > parampointer->long1);
++
++      toright = -1;
++      sample.left = 0;
++      do
++	{
++	  toright++;
++	  if (toright < parampointer->prelength4)
++	    {
++	      sample = get_from_buffer (&parampointer->buffer4, toright + 1);
++	      if (sample.left > maxval)
++		/* if so, the `while' will continue anyway, so maxval may
++		   be adjusted here already (if necessary) */
++		maxval = sample.left;
++	    }
++	}
++      while (toright < parampointer->prelength4 &&
++	     sample.left > parampointer->long1);
++
++      /* only interpolate if there really is a tick */
++      if (maxval > parampointer->long2)
++	{
++
++#ifdef VIEW_INTERNALS
++	  returnval.left = (toright + toleft + 1) * 500;
++#else
++
++	  /* Use a HANNING window here for the time being; note that
++	     the FFT is centred at the middle of the tick not at the
++	     point we are interpolating.  */
++	  for (i = 0; i < fft_l; i++)
++	    {
++	      list3[i] = get_from_buffer(&parampointer->buffer,
++					 i - parampointer->prelength4 +
++					 (toright - toleft + 1)/2).left * 
++		(2.-cos(2.*M_PIl*(double) i/ ((double) fft_l - 1.)))/2.;
++	    }
++	  rfftw_one(parampointer->planf, list3, list4);
++	  nfreq=floor((double) fft_l/(double) (2*(toleft+toright+1)));
++	  for (i = 2*nfreq; i <= fft_l - 2*nfreq; i++) list4[i] = 0.;
++	  for (i = nfreq; i<2*nfreq && i< fft_l/2; i++) {
++	    list4[i] *= (1. - (double) (i-nfreq)/ (double) nfreq);
++	    list4[fft_l-i] *= (1. - (double) (i-nfreq)/ (double) nfreq);
++	  }
++	  rfftw_one(parampointer->planr, list4, list3);
++	  returnval.left = (signed short) (list3[parampointer->prelength4 -
++						(toright - toleft + 1)/2]/
++					   (double) fft_l);
++
++	  /* DON'T ASK !!! -- I have NO idea why I have to MULTIPLY by 
++	     the hanning window here. Everything sensible says DIVIDE, but
++	     multiply works, divide doesn't */
++
++	  returnval.left *= (2.-cos(2.*M_PIl*(double) ((toright - toleft + 1)/2) /
++				    ((double) fft_l - 1.)))/2.;
++#ifdef DEBUGFILE
++	  fprintf(debugf, "L: %ld %d %ld %ld\n",
++		  fft_l, (toleft+toright+1), nfreq,
++		  fft_l-nfreq);
++#endif
++
++#endif
++	}
++    }
++
++  if (gate.right > parampointer->long1)
++    {
++      maxval = gate.right;
++
++      toleft = -1;
++      sample.right = 0;
++      do
++	{
++	  toleft++;
++	  if (toleft < parampointer->postlength4)
++	    {
++	      sample = get_from_buffer (&parampointer->buffer4, -toleft - 1);
++	      if (sample.right > maxval)
++		/* if so, the `while' will continue anyway, so maxval may
++		   be adjusted here already (if necessary) */
++		maxval = sample.right;
++	    }
++	}
++      while (toleft < parampointer->postlength4 &&
++	     sample.right > parampointer->long1);
++
++      toright = -1;
++      sample.right = 0;
++      do
++	{
++	  toright++;
++	  if (toright < parampointer->prelength4)
++	    {
++	      sample = get_from_buffer (&parampointer->buffer4, toright + 1);
++	      if (sample.right > maxval)
++		/* if so, the `while' will continue anyway, so maxval may
++		   be adjusted here already (if necessary) */
++		maxval = sample.right;
++	    }
++	}
++      while (toright < parampointer->prelength4 &&
++	     sample.right > parampointer->long1);
++
++      /* only interpolate if there really is a tick */
++      if (maxval > parampointer->long2)
++	{
++
++#ifdef VIEW_INTERNALS
++	  returnval.right = (toright + toleft + 1) * 500;
++#else
++	  /* Use a HANNING window here for the time being; note that
++	     the FFT is centred at the middle of the tick not at the
++	     point we are interpolating.  */
++	  for (i = 0; i < fft_l; i++)
++	    {
++	      list3[i] = get_from_buffer(&parampointer->buffer,
++					 i - parampointer->prelength4 +
++					 (toright - toleft + 1)/2).right * 
++		(2.-cos(2.*M_PIl*(double) i/ ((double) fft_l - 1.)))/2.;
++	    }
++	  rfftw_one(parampointer->planf, list3, list4);
++	  
++	  nfreq=floor((double) fft_l/(double) (2*(toleft+toright+1)));
++	  for (i = 2*nfreq; i <= fft_l - 2*nfreq; i++) list4[i] = 0.;
++	  for (i = nfreq; i<2*nfreq && i<fft_l/2; i++) {
++	    list4[i] *= (1. - (double) (i-nfreq)/ (double) nfreq);
++	    list4[fft_l-i] *= (1. - (double) (i-nfreq)/ (double) nfreq);
++	  }
++
++	  rfftw_one(parampointer->planr, list4, list3);
++	  returnval.right = (signed short) (list3[parampointer->prelength4 -
++						 (toright - toleft + 1)/2]/
++					    (double) fft_l) ;
++
++	  /* DON'T ASK !!! -- I have NO idea why I have to MULTIPLY by 
++	     the hanning window here. Everything sensible says DIVIDE, but
++	     multiply works, divide doesn't */
++
++	  returnval.right *= (2.-cos(2.*M_PIl*(double) ((toright - toleft + 1)/2) /
++				     ((double) fft_l - 1.)))/2.;
++#ifdef DEBUGFILE
++	  fprintf(debugf, "R: %ld %d %ld %ld\n",
++		  fft_l, (toleft+toright+1), nfreq,
++		  fft_l - nfreq);
++#endif
++
++#endif
++	}
++    }
++
++  return returnval;
++}
+Index: gramofile/signpr_cmf3.h
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ gramofile/signpr_cmf3.h	2011-08-14 13:27:15.969717630 +0200
+@@ -0,0 +1,29 @@
++/* Simple Median Filter - Better Version - Header
++
++ * 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.
++ */
++
++#ifndef HAVE_SIGNPR_CMF3_H
++#define HAVE_SIGNPR_CMF3_H
++
++
++#include "signpr_general.h"
++
++#define SIGNPR_CMF3_PARAMSCR_HEADERTEXT "Conditional Median Filter IIF - Parameters"
++
++void cond_median3_param_defaults (parampointer_t parampointer);
++
++void cond_median3_param_screen (parampointer_t parampointer);
++
++void init_cond_median3_filter (int filterno, parampointer_t parampointer);
++
++void delete_cond_median3_filter (parampointer_t parampointer);
++
++sample_t cond_median3_filter (parampointer_t parampointer);
++
++
++#endif /* HAVE_SIGNPR_CMF3_H */
+Index: gramofile/signpr_general.c
+===================================================================
+--- gramofile.orig/signpr_general.c	2011-08-14 13:21:45.289218120 +0200
++++ gramofile/signpr_general.c	2011-08-14 13:27:15.969717630 +0200
+@@ -14,6 +14,7 @@
+ #include "signpr_wav.h"
+ #include "signpr_cmf.h"
+ #include "signpr_cmf2.h"
++#include "signpr_cmf3.h"
+ #include "signpr_mean.h"
+ #include "signpr_doubmed.h"
+ #include "signpr_rms.h"
+@@ -511,6 +512,13 @@
+   add_to_filterlist (filtlist,
+ 		     filtnumbers,
+ 		     helptexts,
++		     COND_MEDIAN3_FILTER,
++		     COND_MEDIAN3_NAME,
++		     COND_MEDIAN3_HELPTEXT);
++
++  add_to_filterlist (filtlist,
++		     filtnumbers,
++		     helptexts,
+ 		     EXPERIMENT_FILTER,
+ 		     EXPERIMENT_NAME,
+ 		     EXPERIMENT_HELPTEXT);
+@@ -559,6 +567,10 @@
+ 	return monoize_filter (parampointerarray[filterno]);
+ 	break;
+ 
++      case COND_MEDIAN3_FILTER:
++	return cond_median3_filter (parampointerarray[filterno]);
++	break;
++
+       case EXPERIMENT_FILTER:
+ 	return experiment_filter (parampointerarray[filterno]);
+ 	break;
+@@ -615,6 +627,10 @@
+ 	init_monoize_filter (i, parampointerarray[i]);
+ 	break;
+ 
++      case COND_MEDIAN3_FILTER:
++	init_cond_median3_filter (i, parampointerarray[i]);
++	break;
++
+       case EXPERIMENT_FILTER:
+ 	init_experiment_filter (i, parampointerarray[i]);
+ 	break;
+@@ -671,6 +687,10 @@
+ 	delete_monoize_filter (parampointerarray[i]);
+ 	break;
+ 
++      case COND_MEDIAN3_FILTER:
++	delete_cond_median3_filter (parampointerarray[i]);
++	break;
++
+       case EXPERIMENT_FILTER:
+ 	delete_experiment_filter (parampointerarray[i]);
+ 	break;
+@@ -724,6 +744,10 @@
+       monoize_param_defaults (parampointer);
+       break;
+ 
++    case COND_MEDIAN3_FILTER:
++      cond_median3_param_defaults (parampointer);
++      break;
++
+     case EXPERIMENT_FILTER:
+       experiment_param_defaults (parampointer);
+       break;
+@@ -777,6 +801,10 @@
+       monoize_param_screen (parampointer);
+       break;
+ 
++    case COND_MEDIAN3_FILTER:
++      cond_median3_param_screen (parampointer);
++      break;
++
+     case EXPERIMENT_FILTER:
+       experiment_param_screen (parampointer);
+       break;
+Index: gramofile/signpr_general.h
+===================================================================
+--- gramofile.orig/signpr_general.h	2011-08-14 13:21:45.273217375 +0200
++++ gramofile/signpr_general.h	2011-08-14 13:27:15.969717630 +0200
+@@ -13,6 +13,9 @@
+ 
+ #include "scrollmenu.h"
+ 
++/* This has to be here, otherwise the FFT interpolating filter
++   can't keep its plans [SJT] */
++#include <rfftw.h>
+ 
+ /* SAMPLES */
+ 
+@@ -70,9 +73,12 @@
+     signed short *sslist1;
+     signed short *sslist2;
+ 
+-    int int1;
++    int int1, int2;
+     long long1;
+     long long2;
++
++    rfftw_plan planf, planr;
++
+   }
+ param_t;
+ 
+@@ -221,7 +227,12 @@
+ #define MONOIZE_HELPTEXT        \
+ "Average left & right signals."
+ 
+-#define EXPERIMENT_FILTER	9
++#define COND_MEDIAN3_FILTER	9
++#define COND_MEDIAN3_NAME	"Conditional Median Filter IIF"
++#define COND_MEDIAN3_HELPTEXT	\
++"Remove ticks while not changing rest of signal - Using freq domain interp."
++
++#define EXPERIMENT_FILTER	10
+ #define EXPERIMENT_NAME		"Experimenting Filter"
+ #define EXPERIMENT_HELPTEXT	\
+ "The filter YOU are experimenting with (in signpr_exper.c)"
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/40-fast-swap-and-buffer.patch
+++ gramofile-1.6/debian/patches/40-fast-swap-and-buffer.patch
@@ -0,0 +1,153 @@
+# Patch by J. Dru Lemley.
+Index: gramofile/Makefile
+===================================================================
+--- gramofile.orig/Makefile	2011-08-14 13:27:14.449217214 +0200
++++ gramofile/Makefile	2011-08-14 13:27:15.777717640 +0200
+@@ -19,7 +19,7 @@
+ ########## CHOOSE YOUR ARCHITECTURE:    (NOTE: also see bplaysrc/Makefile!)
+ 
+ # For Linux (and maybe others), use these:
+-CFLAGS = -Wall -O2 -DTURBO_MEDIAN -DTURBO_BUFFER
++CFLAGS = -Wall -O2 -funroll-loops -DTURBO_MEDIAN -DTURBO_BUFFER
+ DEPS = $(OBJS) makebplay
+ LIBS = -lncurses -lm
+ COPY_A = -a
+Index: gramofile/endian.h
+===================================================================
+--- gramofile.orig/endian.h	2011-08-14 13:21:45.369217735 +0200
++++ gramofile/endian.h	2011-08-14 13:27:15.777717640 +0200
+@@ -8,4 +8,10 @@
+ extern u_long SwapFourBytes (u_long);
+ extern sample_t SwapSample (sample_t);
+ 
++/* macro to swap endianness of values in a sample_t with */
++/* a few 32-bit operations -- very fast                  */
++#define SWAPSAMPLEREF(s) *((uint32_t *)(s)) = \
++	((*((uint32_t *)(s)) & 0xff00ff00) >> 8) | \
++	((*((uint32_t *)(s)) & 0x00ff00ff) << 8)
++
+ #endif
+Index: gramofile/signpr_wav.c
+===================================================================
+--- gramofile.orig/signpr_wav.c	2011-08-14 13:21:45.385217549 +0200
++++ gramofile/signpr_wav.c	2011-08-14 13:27:15.777717640 +0200
+@@ -22,6 +22,8 @@
+ /* ----- SOURCE & READING -------------------------------------------------- */
+ 
+ FILE *sourcefile;
++int num_read_samples_buffered = 0;
++sample_t readsamplebuffer[44100];
+ 
+ int
+ openwavsource (char *filename)
+@@ -106,6 +108,7 @@
+     }
+ 
+   /* Well, everything seems to be OK */
++  num_read_samples_buffered = 0;
+   return 1;
+ }
+ 
+@@ -113,6 +116,7 @@
+ closewavsource ()
+ {
+   fclose (sourcefile);
++  num_read_samples_buffered = 0; 
+ }
+ 
+ int
+@@ -121,6 +125,9 @@
+ {
+   struct stat buf;
+ 
++  /* throw away buffer on fseek */
++  num_read_samples_buffered = 0; 
++
+   if (fstat (fileno (sourcefile), &buf))
+     return 0;
+ 
+@@ -135,22 +142,28 @@
+ 
+ sample_t
+ readsamplesource ()
+-{
+-  sample_t sample;
+-
+-  if (fread (&sample, 1, 4, sourcefile) != 4)
+-    {
+-      /* reading after end of file - this just happens when using
+-         pre-read buffers! */
+-      sample.left = 0;
+-      sample.right = 0;
+-    }
++{ 
++  /* millions of calls to fread sure slow things down.... buffer it a little */
++  static int i;
++
++  if (i >= num_read_samples_buffered)
++  {  
++    num_read_samples_buffered = fread(readsamplebuffer, 4, sizeof(readsamplebuffer)/4, sourcefile); 
++    i = 0; 
++    if (!num_read_samples_buffered)
++      {
++        /* reading after end of file - this just happens when using
++           pre-read buffers! */
++        readsamplebuffer[0].left = 0;
++        readsamplebuffer[0].right = 0;
++    	return readsamplebuffer[0];
++      }
++  }
+ 
+ #ifdef SWAP_ENDIAN
+-  sample = SwapSample (sample);
++  SWAPSAMPLEREF (readsamplebuffer+i);
+ #endif
+-
+-  return sample;
++  return readsamplebuffer[i++];
+ }
+ 
+ 
+@@ -158,6 +171,8 @@
+ 
+ FILE *destfile;
+ int destfileispipe;		/* remember open() - - -> close() */
++int num_write_samples_buffered = 0;
++sample_t writesamplebuffer[44100];
+ 
+ int
+ openwavdest (char *filename, long bcount)
+@@ -216,12 +231,20 @@
+ 
+   fwrite (&header, sizeof (header), 1, destfile);
+ 
++  num_write_samples_buffered = 0;  /* just in case */
+   return 1;
+ }
+ 
++void flushwritebuffer()
++{ 
++	fwrite(writesamplebuffer, 4 * num_write_samples_buffered, 1, destfile); 
++	num_write_samples_buffered = 0;
++}
++
+ void
+ closewavdest ()
+ {
++  flushwritebuffer(); 
+   if (destfileispipe)
+     pclose (destfile);
+   else
+@@ -233,8 +256,9 @@
+ {
+ 
+ #ifdef SWAP_ENDIAN
+-  sample = SwapSample (sample);
++  SWAPSAMPLEREF(&sample);
+ #endif
+-
+-  fwrite (&sample, 4, 1, destfile);
++  if (num_write_samples_buffered == (sizeof (writesamplebuffer) / 4))
++	flushwritebuffer(); 
++  writesamplebuffer[num_write_samples_buffered++] = sample;
+ }
only in patch2:
unchanged:
--- gramofile-1.6.orig/debian/patches/30-basename-fix.patch
+++ gramofile-1.6/debian/patches/30-basename-fix.patch
@@ -0,0 +1,70 @@
+# <30-basename-fix.dpatch> by Daniel Kobras <kobras@debian.org>
+#
+# Use the POSIX basename(3), get rid of private prototype that wasn't used
+# anyway. Remove the now unneeded REDHAT50 define from the Makefile.
+#
+# Explanation: Previously, the code used glibc's basename but didn't realise
+# it was a GNU extension. Alternatively, one could define _GNU_SOURCE, but
+# I opted for the--hopefully--more portable POSIX version. (Unlike the GNU
+# version, the POSIX version may potentially modify its argument.)
+Index: gramofile/bplaysrc/bplay.c
+===================================================================
+--- gramofile.orig/bplaysrc/bplay.c	2011-08-14 13:27:15.277217351 +0200
++++ gramofile/bplaysrc/bplay.c	2011-08-14 13:27:15.593217482 +0200
+@@ -20,6 +20,10 @@
+ #include <sys/time.h>
+ #include <sys/resource.h>
+ 
++#ifdef linux
++#include <libgen.h>
++#endif
++
+ #ifndef __FreeBSD__
+ #include <sys/soundcard.h>
+ #else
+@@ -53,16 +57,6 @@
+ 
+ /* Prototypes */
+ 
+-#ifdef linux
+-/* This is in libc, but not in the header files. -- but it IS in
+-   Red Hat 5.0.... Libc6?
+-   well i'd guess its not in the headers because its nonstandard, i.e.
+-   (probably) only exists on linux...  -nox */
+-#ifndef REDHAT50
+-extern char *basename(char *name);
+-#endif
+-#endif
+-
+ void Usage(void);
+ void ErrDie(char *err);
+ void Die(char *err);
+@@ -107,11 +101,14 @@
+ 	sndf_t filetype;		/* The file type */
+ 	int mods;			/* So user can override */
+ 	int optc;			/* For getopt */
++	char *tmp = NULL;		/* Do not clobber argv[0] */
+ 
+ 	init_curses();
+ 
+ #ifdef linux
+-	progname = basename(argv[0]);	/* For errors */
++	tmp = strdup(argv[0]);		/* POSIX basename may modify its arg */
++	progname = basename(tmp);	/* For errors */
++	free(tmp);
+ #else
+ 	progname = strrchr(argv[0], '/');  /* Replacement for e.g. FreeBSD */
+ 	if (!progname || !*++progname)
+Index: gramofile/bplaysrc/Makefile
+===================================================================
+--- gramofile.orig/bplaysrc/Makefile	2011-08-14 13:21:45.449217435 +0200
++++ gramofile/bplaysrc/Makefile	2011-08-14 13:27:15.593217482 +0200
+@@ -12,7 +12,7 @@
+ ########## CHOOSE YOUR ARCHITECTURE:    (NOTE: also see ../Makefile!)
+ 
+ # For Linux (and maybe others), use these:
+-CFLAGS = -Wall -O2 -DUSEBUFFLOCK -DREDHAT50 -DLP2CD -DVUMETER # -DDEBUG
++CFLAGS = -Wall -O2 -DUSEBUFFLOCK -DLP2CD -DVUMETER # -DDEBUG
+ LIBS = -lncurses
+ 
+ # For FreeBSD (and maybe others), use these:
