fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[fluid-dev] P.S. Some fluidsynth fixes


From: Henri Manson
Subject: [fluid-dev] P.S. Some fluidsynth fixes
Date: Fri, 17 Feb 2006 21:24:20 +0100
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

Hi all,

I introduced a bug in the fluid_ct2hz function and fixed it. Enclosed the corrected diff file

cvs diff -u -wb -- fluid_conv.c fluid_conv.h fluid_dll.c fluid_dsound.c 
fluid_voice.c (in directory D:\Data\C\fluid\fluidsynth\src\)
Empty password used - try 'cvs login' with a real password
Index: fluid_conv.c
===================================================================
RCS file: /sources/fluid/fluidsynth/src/fluid_conv.c,v
retrieving revision 1.4
diff -u -w -b -r1.4 fluid_conv.c
--- fluid_conv.c        11 Jun 2005 11:06:43 -0000      1.4
+++ fluid_conv.c        17 Feb 2006 17:16:07 -0000
@@ -96,42 +96,53 @@
  * fluid_ct2hz
  */
 fluid_real_t 
-fluid_ct2hz(fluid_real_t cents) 
+fluid_ct2hz_real(fluid_real_t cents) 
 {
-  /* Filter fc limit: SF2.01 page 48 # 8 */
-  if (cents >= 13500){
-    cents = 13500;             /* 20 kHz */
-  } else if (cents < 1500){
-    cents = 1500;              /* 20 Hz */
-  };
-  if ((cents >= 6900) && (cents < 8100)) {
+  if (cents < 900) {
+    return (fluid_real_t) 6.875 * fluid_ct2hz_tab[(int) (cents)];
+  } else if (cents < 2100) {
+    return (fluid_real_t) 13.75 * fluid_ct2hz_tab[(int) (cents - 900)];
+  } else if (cents < 3300) {
+    return (fluid_real_t) 27.5 * fluid_ct2hz_tab[(int) (cents - 2100)];
+  } else if (cents < 4500) {
+    return (fluid_real_t) 55.0 * fluid_ct2hz_tab[(int) (cents - 3300)];
+  } else if (cents < 5700) {
+    return (fluid_real_t) 110.0 * fluid_ct2hz_tab[(int) (cents - 4500)];
+  } else if (cents < 6900) {
+    return (fluid_real_t) 220.0 * fluid_ct2hz_tab[(int) (cents - 5700)];
+  } else if (cents < 8100) {
     return (fluid_real_t) 440.0 * fluid_ct2hz_tab[(int) (cents - 6900)];
-  } else if ((cents >= 8100) && (cents < 9300)) {
+  } else if (cents < 9300) {
     return (fluid_real_t) 880.0 * fluid_ct2hz_tab[(int) (cents - 8100)];
-  } else if ((cents >= 5700) && (cents < 6900)) {
-    return (fluid_real_t) 220.0 * fluid_ct2hz_tab[(int) (cents - 5700)];
-  } else if ((cents >= 9300) && (cents < 10500)) {
+  } else if (cents < 10500) {
     return (fluid_real_t) 1760.0 * fluid_ct2hz_tab[(int) (cents - 9300)];
-  } else if ((cents >= 4500) && (cents < 5700)) {
-    return (fluid_real_t) 110.0 * fluid_ct2hz_tab[(int) (cents - 4500)];
-  } else if ((cents >= 10500) && (cents < 11700)) {
+  } else if (cents < 11700) {
     return (fluid_real_t) 3520.0 * fluid_ct2hz_tab[(int) (cents - 10500)];
-  } else if ((cents >= 3300) && (cents < 4500)) {
-    return (fluid_real_t) 55.0 * fluid_ct2hz_tab[(int) (cents - 3300)];
-  } else if ((cents >= 11700) && (cents < 12900)) {
+  } else if (cents < 12900) {
     return (fluid_real_t) 7040.0 * fluid_ct2hz_tab[(int) (cents - 11700)];
-  } else if ((cents >= 2100) && (cents < 3300)) {
-    return (fluid_real_t) 27.5 * fluid_ct2hz_tab[(int) (cents - 2100)];
-  } else if ((cents >= 12900) && (cents < 14100)) {
+  } else if (cents < 14100) {
     return (fluid_real_t) 14080.0 * fluid_ct2hz_tab[(int) (cents - 12900)];
-  } else if ((cents >= 900) && (cents < 2100)) {
-    return (fluid_real_t) 13.75 * fluid_ct2hz_tab[(int) (cents - 900)];
   } else {
     return (fluid_real_t) 1.0; /* some loony trying to make you deaf */
   }
 }
 
 /*
+ * fluid_ct2hz
+ */
+fluid_real_t 
+fluid_ct2hz(fluid_real_t cents) 
+{
+  /* Filter fc limit: SF2.01 page 48 # 8 */
+  if (cents >= 13500){
+    cents = 13500;             /* 20 kHz */
+  } else if (cents < 1500){
+    cents = 1500;              /* 20 Hz */
+  }
+  return fluid_ct2hz_real(cents);
+}
+
+/*
  * fluid_cb2amp
  *
  * in: a value between 0 and 960, 0 is no attenuation
Index: fluid_conv.h
===================================================================
RCS file: /sources/fluid/fluidsynth/src/fluid_conv.h,v
retrieving revision 1.3
diff -u -w -b -r1.3 fluid_conv.h
--- fluid_conv.h        11 Jun 2005 11:06:43 -0000      1.3
+++ fluid_conv.h        17 Feb 2006 17:16:45 -0000
@@ -36,6 +36,7 @@
 
 void fluid_conversion_config(void);
 
+fluid_real_t fluid_ct2hz_real(fluid_real_t cents);
 fluid_real_t fluid_ct2hz(fluid_real_t cents);
 fluid_real_t fluid_cb2amp(fluid_real_t cb);
 fluid_real_t fluid_atten2amp(fluid_real_t atten);
Index: fluid_dll.c
===================================================================
RCS file: /sources/fluid/fluidsynth/src/fluid_dll.c,v
retrieving revision 1.1.1.1
diff -u -w -b -r1.1.1.1 fluid_dll.c
--- fluid_dll.c 11 Mar 2003 16:57:20 -0000      1.1.1.1
+++ fluid_dll.c 18 Jan 2006 13:50:31 -0000
@@ -23,13 +23,17 @@
 #include "fluidsynth_priv.h"
 #include "fluid_sys.h"
 
-HINSTANCE fluid_hinstance = NULL;
+static HINSTANCE fluid_hinstance = NULL;
+static HWND fluid_wnd = NULL;
+
+int fluid_win32_create_window(void);
 
 #ifndef FLUIDSYNTH_NOT_A_DLL
 BOOL WINAPI DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID 
lpReserved)
 {
   FLUID_LOG(FLUID_DBG, "DllMain\n");
   fluid_set_hinstance((void*) hModule);
+  fluid_win32_create_window();
   return TRUE;
 }
 #endif
@@ -46,5 +50,50 @@
 {
   return (void*) fluid_hinstance;
 }
+
+static long FAR PASCAL fluid_win32_wndproc(HWND hWnd, UINT message, WPARAM 
wParam, LPARAM lParam)
+{
+  switch (message) {
+  case WM_CREATE:
+    break;
+  case WM_DESTROY:
+    break;
+  default:
+    return DefWindowProc(hWnd, message, wParam, lParam);
+    break;
+  } 
+  return(0L);
+}
+
+int fluid_win32_create_window(void)
+{
+  WNDCLASS myClass;
+  myClass.hCursor = LoadCursor( NULL, IDC_ARROW );
+  myClass.hIcon = NULL; 
+  myClass.lpszMenuName = (LPSTR) NULL;
+  myClass.lpszClassName = (LPSTR) "FluidSynth";
+  myClass.hbrBackground = (HBRUSH)(COLOR_WINDOW);
+  myClass.hInstance = fluid_hinstance;
+  myClass.style = CS_GLOBALCLASS;
+  myClass.lpfnWndProc = fluid_win32_wndproc;
+  myClass.cbClsExtra = 0;
+  myClass.cbWndExtra = 0;
+  if (!RegisterClass(&myClass)) {
+    return -100;
+  }
+  fluid_wnd = CreateWindow((LPSTR) "FluidSynth", (LPSTR) "FluidSynth", 
WS_OVERLAPPEDWINDOW,
+                         CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, (HWND) NULL, 
(HMENU) NULL, 
+                         fluid_hinstance, (LPSTR) NULL);  
+  if (fluid_wnd == NULL) {
+    FLUID_LOG(FLUID_ERR, "Can't create window");
+    return -101;
+  }
+  return 0;
+}
+
+HWND fluid_win32_get_window(void)
+{
+       return fluid_wnd;
+}
 #endif
 
Index: fluid_dsound.c
===================================================================
RCS file: /sources/fluid/fluidsynth/src/fluid_dsound.c,v
retrieving revision 1.7
diff -u -w -b -r1.7 fluid_dsound.c
--- fluid_dsound.c      14 May 2004 13:45:22 -0000      1.7
+++ fluid_dsound.c      18 Jan 2006 13:52:53 -0000
@@ -30,17 +30,13 @@
 #include <mmsystem.h> 
 #include <dsound.h>
 
-static HWND fluid_wnd = NULL;
-
 fluid_audio_driver_t* 
 new_fluid_dsound_audio_driver(fluid_settings_t* settings, fluid_synth_t* 
synth);
 
 int delete_fluid_dsound_audio_driver(fluid_audio_driver_t* data);
 DWORD WINAPI fluid_dsound_audio_run(LPVOID lpParameter);
 
-int fluid_win32_create_window(void);
-int fluid_win32_destroy_window(void);
-long FAR PASCAL fluid_win32_wndproc(HWND hWnd, unsigned message, WPARAM 
wParam, LPARAM lParam);
+HWND fluid_win32_get_window(void);
 char* fluid_win32_error(HRESULT hr);
 
 
@@ -100,13 +96,14 @@
     return NULL;
   }
 
+/*
   if (fluid_wnd == NULL) {
     if (fluid_win32_create_window() != 0) {
       FLUID_LOG(FLUID_ERR, "Couldn't create window needed for DirectSound");
       return NULL;
     }
   }
-
+*/
   /* create and clear the driver data */
   dev = FLUID_NEW(fluid_dsound_audio_driver_t);
   if (dev == NULL) {
@@ -156,7 +153,7 @@
     goto error_recovery;
   }
 
-  hr = IDirectSound_SetCooperativeLevel(dev->direct_sound, fluid_wnd, 
DSSCL_PRIORITY);
+  hr = IDirectSound_SetCooperativeLevel(dev->direct_sound, 
fluid_win32_get_window(), DSSCL_PRIORITY);
   if (hr != DS_OK) {
     FLUID_LOG(FLUID_ERR, "Failed to set the cooperative level");
     goto error_recovery;
@@ -282,7 +279,7 @@
 
   FLUID_FREE(dev);
 
-  fluid_win32_destroy_window();
+//  fluid_win32_destroy_window();
 
   return 0;
 }
@@ -371,54 +368,3 @@
   }
   return s;
 }
-
-
-long FAR PASCAL fluid_win32_wndproc(HWND hWnd, unsigned message, WPARAM 
wParam, LPARAM lParam)
-{
-  switch (message) {
-  case WM_CREATE:
-    break;
-  case WM_DESTROY:
-    break;
-  default:
-    return DefWindowProc(hWnd, message, wParam, lParam);
-    break;
-  } 
-  return(0L);
-}
-
-int fluid_win32_create_window(void)
-{
-  WNDCLASS myClass;
-  myClass.hCursor = LoadCursor( NULL, IDC_ARROW );
-  myClass.hIcon = NULL; 
-  myClass.lpszMenuName = (LPSTR) NULL;
-  myClass.lpszClassName = (LPSTR) "FluidSynth";
-  myClass.hbrBackground = (HBRUSH)(COLOR_WINDOW);
-  myClass.hInstance = FLUID_HINSTANCE;
-  myClass.style = CS_GLOBALCLASS;
-  myClass.lpfnWndProc = fluid_win32_wndproc;
-  myClass.cbClsExtra = 0;
-  myClass.cbWndExtra = 0;
-  if (!RegisterClass(&myClass)) {
-    return -100;
-  }
-  fluid_wnd = CreateWindow((LPSTR) "FluidSynth", (LPSTR) "FluidSynth", 
WS_OVERLAPPEDWINDOW,
-                         CW_USEDEFAULT, CW_USEDEFAULT, 400, 300, (HWND) NULL, 
(HMENU) NULL, 
-                         FLUID_HINSTANCE, (LPSTR) NULL);  
-  if (fluid_wnd == NULL) {
-    FLUID_LOG(FLUID_ERR, "Can't create window");
-    return -101;
-  }
-  return 0;
-}
-
-int fluid_win32_destroy_window(void)
-{
-  if (fluid_wnd != NULL) {
-    DestroyWindow(fluid_wnd);
-    fluid_wnd = NULL;
-    UnregisterClass((LPSTR) "FluidSynth", FLUID_HINSTANCE);
-  }
-  return 0;
-}
Index: fluid_voice.c
===================================================================
RCS file: /sources/fluid/fluidsynth/src/fluid_voice.c,v
retrieving revision 1.15
diff -u -w -b -r1.15 fluid_voice.c
--- fluid_voice.c       11 Jun 2005 11:06:43 -0000      1.15
+++ fluid_voice.c       17 Feb 2006 17:16:25 -0000
@@ -587,7 +587,7 @@
    * through the original waveform with each step in the output
    * buffer. It is the ratio between the frequencies of original
    * waveform and output waveform.*/
-  incr = fluid_ct2hz(voice->pitch
+  incr = fluid_ct2hz_real(voice->pitch
                    + voice->modlfo_val * voice->modlfo_to_pitch
                    + voice->viblfo_val * voice->viblfo_to_pitch
                    + voice->modenv_val * voice->modenv_to_pitch) / 
voice->root_pitch;

***** CVS exited normally with code 1 *****



reply via email to

[Prev in Thread] Current Thread [Next in Thread]