--- gramofile-1.6.orig/debian/gramofile.manpages +++ gramofile-1.6/debian/gramofile.manpages @@ -0,0 +1 @@ +debian/gramofile.1 --- gramofile-1.6.orig/debian/gramofile.docs +++ gramofile-1.6/debian/gramofile.docs @@ -0,0 +1,3 @@ +README +TODO +*.txt --- gramofile-1.6.orig/debian/compat +++ gramofile-1.6/debian/compat @@ -0,0 +1 @@ +8 --- gramofile-1.6.orig/debian/rules +++ gramofile-1.6/debian/rules @@ -0,0 +1,4 @@ +#! /usr/bin/make -f + +%: + dh $@ --with quilt --- gramofile-1.6.orig/debian/changelog +++ gramofile-1.6/debian/changelog @@ -0,0 +1,137 @@ +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 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 + wodim in documentation and main menu. + * debian/packages: Likewise for Suggests. Both changes thanks to + Tobias Frost. Closes: #405101 + * debian/packages: Complies with version 3.7.2 of Debian policy. + * debian/packages: Update address of the Free Software Foundation + in the copyright notice. + + -- Daniel Kobras Sat, 6 Jan 2007 15:06:48 +0100 + +gramofile (1.6-7) unstable; urgency=high + + * 40-fast-swap-and-buffer.dpatch: Lower optimisation level to the + standard -O2. On arm, the assembler chokes on -O3. + + -- Daniel Kobras Fri, 29 Apr 2005 13:20:02 +0200 + +gramofile (1.6-6) unstable; urgency=high + + * 20-no-busy-wait-after-rec: Do not busy-wait when showing summary + screen with recording statistics. Closes: #283421 + * 20-long-vs-int.dpatch: Remove and merge with 70-endian-fixes to avoid + conflicts. + * 70-endian-fixes.dpatch: Fix several endian and word size bugs in + the WAV and VOC import and export code. Closes: #292137 + * 80_fix_wav_length.dpatch: Report correct file size in wav header if + recording was stopped prematurely. + * 90_report_recording_errors.dpatch: Errors during recording are + reported to the user now. Closes: #126389 + * debian/packages: Do not terminate build process if 'make clean' + fails. + + -- Daniel Kobras Tue, 1 Mar 2005 18:56:04 +0100 + +gramofile (1.6-5) unstable; urgency=low + + * 30-basename-fix.dpatch: Use POSIX implementation of basename(3) instead + of semi-consciously using the GNU extension. Closes: #226585 + * debian/packages: Bump standards version. + + -- Daniel Kobras Wed, 7 Jan 2004 19:21:48 +0100 + +gramofile (1.6-4) unstable; urgency=low + + * Versioned build dependency on fftw-dev. Fixes the single vs. double + precision woes. Closes: #128781 + + -- Daniel Kobras Mon, 14 Jan 2002 11:55:28 +0100 + +gramofile (1.6-3) unstable; urgency=low + + * Recommends mctools-lite to allow use of xmixer. Closes: #112350 + * Moved bplay_gramo and brec_gramo to /usr/lib/gramofile--they are + not intended for general use. + * Added brief man page. Closes: #38408 + + -- Daniel Kobras Mon, 17 Sep 2001 20:43:46 +0200 + +gramofile (1.6-2) unstable; urgency=low + + * Changed yada build-sequence to kludge around weirdness in dpkg-shlibdeps. + Fixes strange chown failure on some autobuilders. Closes: #96798 + * Added semi-official patches as suggested by upstream: + - Don't use long for 32bit types. + - Proper check for over-/underflow in sample values. + - Quote file name in bplay calls. + - Work around DSP_SYNC bug in some via audio drivers. + - Silence GCC warnings. + - Buffered reads and fast endianness swap. + - Improved CM filter (needs fftw). + + -- Daniel Kobras Fri, 8 Jun 2001 18:11:41 +0200 + +gramofile (1.6-1) unstable; urgency=low + + * New upstream version. Closes: #61375, #72562 + * Rebuilt with current ncurses. Closes: #93942 + * Added build dependency on libncurses5-dev. Closes: #84495 + * Rebuilt debian/rules with current yada. Uptodate standards version. + Uses proper install path for docs and man pages. Closes: #91160, #91481 + * Removed obsolete semun fix. + * Updated upstream download URL. + * New maintainer. + + -- Daniel Kobras Sun, 6 May 2001 16:33:11 +0200 + +gramofile (1.5-3) unstable; urgency=low + + * Fix bug 38943: define union semun if libc doesn't define it (as + glibc2.1 doesn't). + + -- Charles Briscoe-Smith Thu, 10 Jun 1999 12:50:55 +0100 + +gramofile (1.5-2) unstable; urgency=low + + * Updated yada to v0.5. + * Added undocumented symlinks for b{play,rec}_gramo and gramofile. + + -- Charles Briscoe-Smith Wed, 9 Jun 1999 11:41:16 +0100 + +gramofile (1.5-1) unstable; urgency=low + + * New upstream source. + * Redid packaging using a preliminary version of YADA, a debian/rules + generator. + + -- Charles Briscoe-Smith Fri, 26 Feb 1999 04:40:19 +0000 + +gramofile (1.4-1) unstable; urgency=low + + * First Debian version. + + -- Charles Briscoe-Smith Wed, 20 Jan 1999 14:30:32 +0000 + --- gramofile-1.6.orig/debian/control +++ gramofile-1.6/debian/control @@ -0,0 +1,45 @@ +Source: gramofile +Maintainer: Debian QA Group +Section: sound +Priority: extra +Standards-Version: 3.9.2 +Build-Depends: libncurses5-dev, fftw-dev (>= 2.1.3-10), debhelper (>= 8), quilt + +Package: gramofile +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +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. --- 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 , and is +currently maintained by Daniel Kobras , using files +obtained from . + +More information about GramoFile is available from + + +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 --- 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 --- gramofile-1.6.orig/debian/gramofile.1 +++ gramofile-1.6/debian/gramofile.1 @@ -0,0 +1,46 @@ +.\" GramoFile -- Sample and process analog recordings +.\" Copyright (c) 2001 Daniel Kobras +.\" +.\" This manual page 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.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +.\" +.\" This manual page was written especially for Debian Linux. +.\" +.TH GRAMOFILE 1 "17 September 2001" "Version 1.6" +.SH NAME +gramofile \- Sample and process analog recordings +.SH SYNOPSIS +.B gramofile +.SH DESCRIPTION +\fBGramoFile\fR provides an interactive, integrated front end to sample audio +data from gramophone records or similar sources, to analyse and enhance +them. While being text-based, it uses a menu system that yields easy +access to individual functions. Highlights include a mode for automatic +detection and splitting of single tracks from a larger recording, and +several filters to reduce ticks and other noise in the audio data. An +integrated help system offers context sensitive information. +.SH "OTHER INFO" +The official \fBGramoFile\fR web page is located at +\fIhttp://panic.et.tudelft.nl/~costar/gramofile/\fR. Technical details on some +of the filters can be found in the documentation accompanying \fBGramoFile\fR, +usually located in \fI/usr/share/doc/gramofile/\fR. +.SH "KNOWN BUGS" +This man page had better contain less marketing speak, but some actual +information on use of the program. +.SH AUTHORS +\fBGramoFile\fR was written by J.A. Bezemer . +.PP +This manual page was written by Daniel Kobras for the +Debian GNU/Linux system (but may be used by others). + --- 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 +# [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 + #endif + ++/* Needed for BYTE_ORDER and BIG/LITTLE_ENDIAN macros. */ ++#ifndef _BSD_SOURCE ++# define _BSD_SOURCE ++# include ++# undef _BSD_SOURCE ++#else ++# include ++#endif ++ ++#include ++#include ++ ++/* 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 + ++#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 ++ + 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 + ++#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 --- 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 +# 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; --- 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 +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); + --- 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 --- 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 +# 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 + #ifndef OLD_CURSES + #include + #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 + #ifndef OLD_CURSES + #include + #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 + #include ++#include + #ifndef OLD_CURSES + #include + #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 + #include ++#include + #include + #ifndef OLD_CURSES + #include +@@ -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 + #include ++#include + #include + #ifndef OLD_CURSES + #include +@@ -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 + #include ++#include + #ifndef OLD_CURSES + #include + #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 + #include ++#include + #ifndef OLD_CURSES + #include + #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 + #include ++#include + #ifndef OLD_CURSES + #include + #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 + #include ++#include + #include + #ifndef OLD_CURSES + #include +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 + #ifndef OLD_CURSES + #include + #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 + #include ++#include + #ifndef OLD_CURSES + #include + #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 + #ifndef OLD_CURSES + #include + #else --- 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 + --- 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 + #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 + #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 */ --- 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; ++} --- 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 --- 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... */ --- 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 --- 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 +# 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); + } --- 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 +# 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 ++#include ++#include ++#ifndef OLD_CURSES ++#include ++#else ++#include ++#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 (¶mpointer->buffer); ++ delete_buffer (¶mpointer->buffer2); ++ delete_buffer (¶mpointer->buffer3); ++ delete_buffer (¶mpointer->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 (¶mpointer->buffer, offset - 1); ++ sum.left += sample.left; ++ sum.right += sample.right; ++ sample = get_from_buffer (¶mpointer->buffer, offset); ++ sum.left -= 2 * (long) sample.left; ++ sum.right -= 2 * (long) sample.right; ++ sample = get_from_buffer (¶mpointer->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 (¶mpointer->buffer, offset - 1); ++ sum.left += sample.left; ++ sum.left -= sample.right; ++ sample = get_from_buffer (¶mpointer->buffer, offset); ++ sum.left -= 2 * (long) sample.left; ++ sum.left += 2 * (long) sample.right; ++ sample = get_from_buffer (¶mpointer->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 (¶mpointer->buffer, offset - 2); ++ sum.left += sample.left; ++ sum.right += sample.right; ++ sample = get_from_buffer (¶mpointer->buffer, offset - 1); ++ sum.left -= 4 * (long) sample.left; ++ sum.right -= 4 * (long) sample.right; ++ sample = get_from_buffer (¶mpointer->buffer, offset); ++ sum.left += 6 * (long) sample.left; ++ sum.right += 6 * (long) sample.right; ++ sample = get_from_buffer (¶mpointer->buffer, offset + 1); ++ sum.left -= 4 * (long) sample.left; ++ sum.right -= 4 * (long) sample.right; ++ sample = get_from_buffer (¶mpointer->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 (¶mpointer->buffer, offset - 3); ++ sum.left -= sample.left; ++ sum.right -= sample.right; ++ sample = get_from_buffer (¶mpointer->buffer, offset - 2); ++ sum.left += 6 * (long) sample.left; ++ sum.right += 6 * (long) sample.right; ++ sample = get_from_buffer (¶mpointer->buffer, offset - 1); ++ sum.left -= 15 * (long) sample.left; ++ sum.right -= 15 * (long) sample.right; ++ sample = get_from_buffer (¶mpointer->buffer, offset); ++ sum.left += 20 * (long) sample.left; ++ sum.right += 20 * (long) sample.right; ++ sample = get_from_buffer (¶mpointer->buffer, offset + 1); ++ sum.left -= 15 * (long) sample.left; ++ sum.right -= 15 * (long) sample.right; ++ sample = get_from_buffer (¶mpointer->buffer, offset + 2); ++ sum.left += 6 * (long) sample.left; ++ sum.right += 6 * (long) sample.right; ++ sample = get_from_buffer (¶mpointer->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 (¶mpointer->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 (¶mpointer->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 (¶mpointer->buffer3, ++ cond_median3_rms_pointer, ++ offset + offset_zero, ++ parampointer); ++ ++ w_t = get_from_buffer (¶mpointer->buffer3, 0); ++ ++ /* The RMF Filter */ ++ ++ for (i = 0; i < parampointer->postlength3; i++) ++ { ++ sample = get_from_buffer (¶mpointer->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 (¶mpointer->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 (¶mpointer->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 (¶mpointer->buffer, parampointer->filterno); ++ ++ advance_current_pos_custom (¶mpointer->buffer4, ++ cond_median3_gate_pointer, ++ 0, ++ parampointer); ++ ++ gate = get_from_buffer (¶mpointer->buffer4, 0); ++ ++#ifdef VIEW_INTERNALS ++ returnval.left = 0; ++ returnval.right = 0; ++#else ++ /* 'Default' value - unchanged if there is no tick */ ++ returnval = get_from_buffer (¶mpointer->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 (¶mpointer->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 (¶mpointer->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(¶mpointer->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 (¶mpointer->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 (¶mpointer->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(¶mpointer->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 && iplanr, 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 + + /* 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)" --- 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; + } --- 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 +# +# 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 + #include + ++#ifdef linux ++#include ++#endif ++ + #ifndef __FreeBSD__ + #include + #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: