From 689723566135f7eba06a5bff688c4928ee0a48e9 Mon Sep 17 00:00:00 2001 From: Shoichi Tamuki Date: Thu, 25 Mar 2004 05:51:51 +0000 Subject: [PATCH] =?utf8?q?hange=20specification=20of=20-EFns=3D=3F=20optio?= =?utf8?q?n=20(for=2016-bit)?= --- ChangeLog | 11 ++++++ doc/C/timidity.1 | 22 ++++++++++- doc/ja_JP.eucJP/timidity.1 | 23 ++++++++++-- timidity/effect.c | 92 +++++++++++++++++++++++----------------------- timidity/timidity.c | 8 ++-- 5 files changed, 102 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index 609333f9..5a2e4611 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-03-25 TAMUKI Shoichi + + * doc/C/timidity.1, doc/ja_JP.eucJP/timidity.1, + timidity/effect.c, timidity/timidity.c: + Change specification of -EFns=? option (for 16-bit) + -EFns=0 : no noise shaping + -EFns=1 : traditional noise shaping + -EFns=2 : overdrive-like soft-clipping + new noise shaping + -EFns=3 : tube-amplifier-like soft-clipping + new noise shaping + -EFns=4 : new noise shaping (default) + 2004-03-24 TAMUKI Shoichi * interface/w32g.h, interface/w32g_c.c, interface/w32g_i.c: diff --git a/doc/C/timidity.1 b/doc/C/timidity.1 index 20a892d8..ebfa50c0 100644 --- a/doc/C/timidity.1 +++ b/doc/C/timidity.1 @@ -1,4 +1,4 @@ -.TH timidity 1 "March 01 2004" "2.13.0" +.TH timidity 1 "March 25 2004" "2.13.0" .SH NAME TiMidity++ \- MIDI\-to\-WAVE converter and player .SH SYNOPSIS @@ -371,7 +371,25 @@ increases because it shifts to a high frequency. In case of 8\-bit linear encoding, valid values of \fIn\fP are in the interval from \fB0\fP (min) to \fB4\fP (max). Default value is \fB4\fP. In case of 16\-bit linear encoding, valid values of n are in the interval from -\fB0\fP to \fB2\fP. Default value is \fB2\fP. +\fB0\fP to \fB4\fP. According to the value, it works as following. +Default value is \fB4\fP. +.RS +.TP +.B 0 +no noise shaping +.TP +.B 1 +traditional noise shaping +.TP +.B 2 +overdrive-like soft-clipping + new noise shaping +.TP +.B 3 +tube-amplifier-like soft-clipping + new noise shaping +.TP +.B 4 +new noise shaping +.RE .TP .BI "resamp=, \-\-resample " (d|l|c|L|n|g) .RS diff --git a/doc/ja_JP.eucJP/timidity.1 b/doc/ja_JP.eucJP/timidity.1 index 72d5bfb2..60ac3d63 100644 --- a/doc/ja_JP.eucJP/timidity.1 +++ b/doc/ja_JP.eucJP/timidity.1 @@ -1,4 +1,4 @@ -.TH timidity 1 "2004ǯ03·î01Æü" "2.13.0" +.TH timidity 1 "2004ǯ03·î25Æü" "2.13.0" .SH ̾Á° TiMidity++ \- MIDI\-to\-WAVEÊÑ´¹¤ª¤è¤Ó¥×¥ì¡¼¥ä¡¼ .SH ½ñ¼° @@ -389,8 +389,25 @@ Moog ¥ÈÀþ·ÁÉä¹æ²½¤Î¤È¤­¡¤\fIn\fP ¤Ë¤Ï \fB0\fP ¤«¤é \fB4\fP ¤Þ¤Ç¤ÎÃͤò»ØÄꤹ ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£\fB0\fP ¤Î¤È¤­¥Õ¥£¥ë¥¿¤Ïµ¡Ç½¤»¤º¡¤\fB4\fP ¤Î¤È¤­ºÇÂç ¤Î¸ú¤­Êý¤È¤Ê¤ê¤Þ¤¹¡£¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï \fB4\fP ¤Ç¤¹¡£16 ¥Ó¥Ã¥ÈÀþ·ÁÉä¹æ²½¤Î -¤È¤­¡¤\fIn\fP ¤Ë¤Ï \fB0\fP ¤«¤é \fB2\fP ¤Þ¤Ç¤ÎÃͤò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ -¤¹¡£¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï \fB2\fP ¤Ç¤¹¡£ +¤È¤­¡¤\fIn\fP ¤Ë¤Ï \fB0\fP ¤«¤é \fB4\fP ¤Þ¤Ç¤ÎÃͤò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ +¤¹¡£Ãͤˤè¤Ã¤Æ¡¤²¼µ­¤ÎÆ°ºî¤Ë¤Ê¤ê¤Þ¤¹¡£¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï \fB4\fP ¤Ç¤¹¡£ +.RS +.TP +.B 0 +¥Î¥¤¥º¥·¥§¡¼¥Ô¥ó¥°¤Ê¤· +.TP +.B 1 +½¾Íè¤Î¥Î¥¤¥º¥·¥§¡¼¥Ô¥ó¥° +.TP +.B 2 +Overdrive É÷¥½¥Õ¥È¥¯¥ê¥Ã¥Ô¥ó¥° + ¿·¥Î¥¤¥º¥·¥§¡¼¥Ô¥ó¥° +.TP +.B 3 +Tube Amplifier É÷¥½¥Õ¥È¥¯¥ê¥Ã¥Ô¥ó¥° + ¿·¥Î¥¤¥º¥·¥§¡¼¥Ô¥ó¥° +.TP +.B 4 +¿·¥Î¥¤¥º¥·¥§¡¼¥Ô¥ó¥° +.RE .TP .BI "resamp=, \-\-resample " (d|l|c|L|n|g) .RS diff --git a/timidity/effect.c b/timidity/effect.c index c47e5109..4c83ba55 100644 --- a/timidity/effect.c +++ b/timidity/effect.c @@ -1,6 +1,6 @@ /* TiMidity++ -- MIDI to WAVE converter and player - Copyright (C) 1999-2002 Masanao Izumo + Copyright (C) 1999-2004 Masanao Izumo Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify @@ -15,15 +15,15 @@ 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 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA effect.c - To apply sound effects. - Mainly written by Masanao Izumo + Mainly written by Masanao Izumo - * Interfaces: - * void init_effect(void); - * do_effect(int32* buf, int32 count); - */ + Interfaces: + void init_effect(void); + do_effect(int32* buf, int32 count); +*/ #ifdef HAVE_CONFIG_H #include "config.h" @@ -57,9 +57,9 @@ static void init_ns_tap16(void); static void ns_shaping8(int32 *, int32); static void ns_shaping16(int32 *, int32); static void ns_shaping16_trad(int32 *, int32); -static void ns_shaping16_9(int32 *, int32); static void do_soft_clipping1(int32 *, int32); static void do_soft_clipping2(int32 *, int32); +static void ns_shaping16_9(int32 *, int32); static inline unsigned long frand(void); static inline int32 my_mod(int32, int32); @@ -325,7 +325,7 @@ static void ns_shaping8(int32 *lp, int32 c) default: return; } - if (!(play_mode->encoding & PE_MONO)) + if (! (play_mode->encoding & PE_MONO)) c *= 2; for (i = 0; i < c; i++) { /* applied noise-shaping filter */ @@ -357,25 +357,25 @@ static void ns_shaping8(int32 *lp, int32 c) static void ns_shaping16(int32 *lp, int32 c) { - if (!(play_mode->encoding & PE_MONO)) {c *= 2;} + if (! (play_mode->encoding & PE_MONO)) + c *= 2; switch (noise_sharp_type) { case 1: ns_shaping16_trad(lp, c); break; case 2: - case 3: - case 4: - ns_shaping16_9(lp, c); - break; - case 5: do_soft_clipping1(lp, c); ns_shaping16_9(lp, c); break; - case 6: + case 3: do_soft_clipping2(lp, c); ns_shaping16_9(lp, c); break; - default: break; + case 4: + ns_shaping16_9(lp, c); + break; + default: + break; } } @@ -416,6 +416,36 @@ static void ns_shaping16_trad(int32 *lp, int32 c) } } +#define WS_AMP_MAX ((int32) 0x0fffffff) +#define WS_AMP_MIN ((int32)-0x0fffffff) + +static void do_soft_clipping1(int32 *buf, int32 count) +{ + int32 i, x; + int32 ai = TIM_FSCALE(1.5f, 24), bi = TIM_FSCALE(0.5f, 24); + + for (i = 0; i < count; i++) { + x = buf[i]; + x = (x > WS_AMP_MAX) ? WS_AMP_MAX + : ((x < WS_AMP_MIN) ? WS_AMP_MIN : x); + x = imuldiv24(x, ai) - imuldiv24(imuldiv28(imuldiv28(x, x), x), bi); + buf[i] = x; + } +} + +static void do_soft_clipping2(int32 *buf, int32 count) +{ + int32 i, x; + + for (i = 0; i < count; i++) { + x = buf[i]; + x = (x > WS_AMP_MAX) ? WS_AMP_MAX + : ((x < WS_AMP_MIN) ? WS_AMP_MIN : x); + x = signlong(x) * ((abs(x) << 1) - imuldiv28(x, x)); + buf[i] = x; + } +} + static void ns_shaping16_9(int32 *lp, int32 c) { int32 i, l, sample, output; @@ -489,34 +519,6 @@ static void ns_shaping16_9(int32 *lp, int32 c) } } -#define WS_AMP_MAX ((int32) 0x0fffffff) -#define WS_AMP_MIN ((int32)-0x0fffffff) - -static void do_soft_clipping1(int32 *buf, int32 count) -{ - int32 i, x; - int32 ai = TIM_FSCALE(1.5f, 24), bi = TIM_FSCALE(0.5f, 24); - for (i = 0; i < count; i++) { - x = buf[i]; - x = (x > WS_AMP_MAX) ? WS_AMP_MAX - : (x < WS_AMP_MIN) ? WS_AMP_MIN : x; - x = imuldiv24(x, ai) - imuldiv24(imuldiv28(imuldiv28(x, x), x), bi); - buf[i] = x; - } -} - -static void do_soft_clipping2(int32 *buf, int32 count) -{ - int32 i, x; - for (i = 0; i < count; i++) { - x = buf[i]; - x = (x > WS_AMP_MAX) ? WS_AMP_MAX - : (x < WS_AMP_MIN) ? WS_AMP_MIN : x; - x = signlong(x) * ((abs(x) << 1) - imuldiv28(x, x)); - buf[i] = x; - } -} - static inline unsigned long frand(void) { return genrand_int32(); diff --git a/timidity/timidity.c b/timidity/timidity.c index 7c373427..2fea88d8 100644 --- a/timidity/timidity.c +++ b/timidity/timidity.c @@ -1,6 +1,6 @@ /* TiMidity++ -- MIDI to WAVE converter and player - Copyright (C) 1999-2003 Masanao Izumo + Copyright (C) 1999-2004 Masanao Izumo Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify @@ -15,7 +15,7 @@ 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 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H @@ -3575,9 +3575,9 @@ static inline int parse_opt_h(const char *arg) " -EFvlpf=d Disable voice LPF" NLS " -EFvlpf=c Enable Chamberlin resonant LPF (12dB/oct) (default)" NLS " -EFvlpf=m Enable Moog resonant lowpass VCF (24dB/oct)" NLS -" -EFns=n Enable the n th degree noise shaping filter" NLS +" -EFns=n Enable the n th degree (type) noise shaping filter" NLS " n:[0..4] (for 8-bit linear encoding, default is 4)" NLS -" n:[0..2] (for 16-bit linear encoding, default is 2)" NLS, fp); +" n:[0..4] (for 16-bit linear encoding, default is 4)" NLS, fp); #ifndef FIXED_RESAMPLATION fputs( " -EFresamp=d Disable resamplation" NLS -- 2.11.0