Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No sound plays on win10 x64 build using CMake and VS2015 #563

Closed
maestrocoder opened this issue Sep 23, 2019 · 14 comments
Closed

No sound plays on win10 x64 build using CMake and VS2015 #563

maestrocoder opened this issue Sep 23, 2019 · 14 comments
Labels

Comments

@maestrocoder
Copy link

I was successful building and playing SF2 using fluidsynth on MAC.

On Windows10, I cannot and wondering what my problem is. When I start the fluidsynth.exe program I hear a small "click" when it starts and again when it ends, so it's trying to work but when I run a simple "load myfont.sf2" and "noteon 0 60 100" I do not hear any piano note.

Here's what I did.

  1. Latest fluidsynth source
  2. followed instructions all for Building with MinGW on Windows - https://github.com/FluidSynth/fluidsynth/wiki/BuildingWithCMake#building-with-mingw-on-windows
  3. installed latest CMake and run CMake GUI, set source, build dir, configure for vs2015, generate, open in vs2015, Build All
    3a) note* i tried this 2 ways
    3a.1) with copy of dsound.h into c:\freesw\include - BUT not sure how this is getting LINKED?
    3a.2) already have DirectX SDK 2010 installed from some VS install before because when I tried to install again gave an "DirectX Error S1023" have existing VC++ 2010 redistributable
  4. run the fluidsynth.exe

get the "click" sound.

  1. since having sound play is my issue, I'm wondering how to LINK in the dsound.h - where in the build process does this go? in CMAke config or inside VS2015 proj/sln?
  2. is the directx error s1023 the issue and i need to uninstall previous "Microsoft Visual C++ 2010 Redistributable" before the "June 2010 DirectX SDK"

Thanks in advance!

@derselbst
Copy link
Member

Clean the build folder, run cmake again and provide the cmake log output pls.

@jjceresa
Copy link
Collaborator

@maestrocoder . Just for infos:

  • In Cmake GUI ,after choosing CMAKE_BUILD_TYPE = Debug and enable-dsound checked.
  • During Configure step you should expect that dsoud.h will be found. (i.e Looking for dsound.h dsound.h - found).

The result of cmake output should be:
Build Summary:
Build type: Debug

Audio / MIDI driver support:
ALSA: no
CoreAudio: no
CoreMIDI: no
DSound: yes
JACK: no
MidiShare: no
Oboe: no
OpenSLES: no
OS/2 DART: no
OSS: no
PortAudio: no
PulseAudio: no
SDL2: no
WaveOut: yes
WinMidi: yes

When build with Debug build type, Fluidsynth.exe should displays more information when you start it. For example:

FluidSynth runtime version 2.0.6
Copyright (C) 2000-2019 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.

fluidsynth: debug: Testing audio device: SB Live! Audio [CE00]
fluidsynth: debug: Testing audio device: Realtek HD Audio output
fluidsynth: debug: Testing audio device: SB PCI
fluidsynth: debug: Testing audio device: Audio Bluetooth
fluidsynth: debug: Using 'dsound' audio driver
fluidsynth: debug: Selected 16 bit sample format
fluidsynth: debug: Testing audio device: PÚriphÚrique audio principal
fluidsynth: debug: Testing audio device: SB Live! Audio [CE00]
fluidsynth: debug: Testing audio device: Realtek HD Audio output
fluidsynth: debug: Testing audio device: SB PCI
fluidsynth: debug: Testing audio device: Audio Bluetooth
fluidsynth: debug: Using 'winmidi' midi driver
Type 'help' for help topics.

You can use the settings command to see what is actual audio.driver settings. For example:

info audio.driver
audio.driver:
Type: string
Value: dsound
Default value:
Options: dsound, file, waveout
Real-time: no

@maestrocoder
Copy link
Author

Cleaned build folder; ran again for VS2015 - here's the output:

I did this twice and I think I was careful to make sure Debug is in the Config, both the CMAKE_BUILD_TYPE = Debug and enable-dsound checked -

  • I deleted CMake Cache
  • ran configure
  • edited the debug vars
  • ran configure again
  • then generate
  • open project
  • then in VS made sure I'm on Debug configuration and Build All.

But I don't see Debug info in the fluidsynth like you show - no fluidsynth: debug: lines...

there are a few "No package 'x' found" like "No package 'sndfile' found" but not sure if I need that on PC?

I installed the MinGW packages into c:\freesw\bin and added to PATH. I also checked I have this

C:> pkg-config --list-all
gio-2.0 GIO - glib I/O library
gmodule-2.0 GModule - Dynamic module loader for GLib
glib-2.0 GLib - C Utility Library
gmodule-no-export-2.0 GModule - Dynamic module loader for GLib
gthread-2.0 GThread - Thread support for GLib
gobject-2.0 GObject - GLib Type, Object, Parameter and Signal Library

Lastly, I am running config and compiling as x64 - which is the version of libraries in my freesw/bin.

Now I'm even more stumped, why I don't get Debug when building debug.

And on the info audio.driver i do not see "waveout"?

===============================================
======= CMake output

Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.17134.
The C compiler identification is MSVC 19.0.24215.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Checking whether system has ANSI C header files
Looking for 8 include files dlfcn.h, ..., float.h
Looking for 8 include files dlfcn.h, ..., float.h - not found
ANSI C header files - not found
Looking for include file unistd.h
Looking for include file unistd.h - not found
Looking for DIR in sys/stat.h;sys/types.h;dirent.h
Looking for DIR in sys/stat.h;sys/types.h;dirent.h - not found.
Looking for string.h
Looking for string.h - found
Looking for stdlib.h
Looking for stdlib.h - found
Looking for stdio.h
Looking for stdio.h - found
Looking for math.h
Looking for math.h - found
Looking for errno.h
Looking for errno.h - found
Looking for stdarg.h
Looking for stdarg.h - found
Looking for memory.h
Looking for memory.h - found
Looking for sys/mman.h
Looking for sys/mman.h - not found
Looking for sys/types.h
Looking for sys/types.h - found
Looking for sys/time.h
Looking for sys/time.h - not found
Looking for sys/stat.h
Looking for sys/stat.h - found
Looking for sys/ioctl.h
Looking for sys/ioctl.h - not found
Looking for fcntl.h
Looking for fcntl.h - found
Looking for sys/socket.h
Looking for sys/socket.h - not found
Looking for netinet/in.h
Looking for netinet/in.h - not found
Looking for netinet/tcp.h
Looking for netinet/tcp.h - not found
Looking for arpa/inet.h
Looking for arpa/inet.h - not found
Looking for limits.h
Looking for limits.h - found
Looking for pthread.h
Looking for pthread.h - not found
Looking for signal.h
Looking for signal.h - found
Looking for getopt.h
Looking for getopt.h - not found
Looking for stdint.h
Looking for stdint.h - found
Performing Test _have_inline
Performing Test _have_inline - Success
Performing Test _have_vla
Performing Test _have_vla - Failed
Check if the system is big endian
Searching 16 bit integer
Looking for stddef.h
Looking for stddef.h - found
Check size of unsigned short
Check size of unsigned short - done
Using unsigned short
Check if the system is big endian - little endian
Looking for windows.h
Looking for windows.h - found
Looking for io.h
Looking for io.h - found
Looking for dsound.h
Looking for dsound.h - found
Looking for include files windows.h, mmsystem.h
Looking for include files windows.h, mmsystem.h - found
Looking for inet_ntop
Looking for inet_ntop - not found
Found PkgConfig: C:/freesw/bin/pkg-config.exe (found version "0.23")
Checking for modules 'glib-2.0>=2.6.5;gthread-2.0>=2.6.5'
Found glib-2.0, version 2.26.1
Found gthread-2.0, version 2.26.1
Checking for module 'sndfile>=1.0.0'
No package 'sndfile' found
Checking for module 'libpulse-simple>=0.9.8'
No package 'libpulse-simple' found
Checking for module 'jack'
No package 'jack' found
Checking for module 'dbus-1>=1.0.0'
No package 'dbus-1' found
Looking for ladspa.h
Looking for ladspa.h - not found
Could NOT find READLINE (missing: READLINE_INCLUDE_DIR READLINE_LIBRARIES)
Found OpenMP 200203
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)


Summary:
Build type: RelWithDebInfo
Install Prefix: C:/Program Files (x86)/FluidSynth
libsndfile: no (raw audio file rendering only)
D-Bus: no
PulseAudio: no
JACK: no
ALSA: no
PortAudio: no
OSS: no
MidiShare: no
CoreAudio: no
CoreMIDI: no
Windows: yes
DSound: yes
WinMidi support: yes
LADSPA support: no
LASH support: no
systemd support: no
OS/2 DART support: no
Audio to file driver: yes
NETWORK Support : yes
IPV6 Support : no
Readline: no
Samples type=float: no (using double)
Profiling: no
OpenMP 4.0: no
Multi-thread support yes
Debug: no
Trap on FPE (debug): no
Check FPE (debug): no


Configuring done

=======

then updated for Debug

CMAKE_BUILD_TYPE = Debug and enable-dsound checked

=======

Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.17134.
Checking whether system has ANSI C header files
ANSI C header files - not found
Looking for inet_ntop
Looking for inet_ntop - not found
Checking for module 'sndfile>=1.0.0'
No package 'sndfile' found
Checking for module 'libpulse-simple>=0.9.8'
No package 'libpulse-simple' found
Checking for module 'jack'
No package 'jack' found
Checking for module 'dbus-1>=1.0.0'
No package 'dbus-1' found
Looking for ladspa.h
Looking for ladspa.h - not found
Could NOT find READLINE (missing: READLINE_INCLUDE_DIR READLINE_LIBRARIES)
Found OpenMP 200203
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)


Summary:
Build type: Debug
Install Prefix: C:/Program Files (x86)/FluidSynth
libsndfile: no (raw audio file rendering only)
D-Bus: no
PulseAudio: no
JACK: no
ALSA: no
PortAudio: no
OSS: no
MidiShare: no
CoreAudio: no
CoreMIDI: no
Windows: yes
DSound: yes
WinMidi support: yes
LADSPA support: no
LASH support: no
systemd support: no
OS/2 DART support: no
Audio to file driver: yes
NETWORK Support : yes
IPV6 Support : no
Readline: no
Samples type=float: no (using double)
Profiling: no
OpenMP 4.0: no
Multi-thread support yes
Debug: yes
Trap on FPE (debug): no
Check FPE (debug): no


Configuring done
Generating done

============

C:\SoundFonts\fluidsynth-2.0.6\build\src\Debug>fluidsynth.exe
FluidSynth runtime version 2.0.6
Copyright (C) 2000-2019 Peter Hanappe and others.
Distributed under the LGPL license.
SoundFont(R) is a registered trademark of E-mu Systems, Inc.

Type 'help' for help topics.

info audio.driver
audio.driver:
Type: string
Value: dsound
Default value:
Options: dsound, file
Real-time: no

===== VS2015 output ============

1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Debug x64 ------
1> Checking Build System
2>------ Rebuild All started: Project: gentables, Configuration: Debug x64 ------
2> Creating directories for 'gentables'
2> Building Custom Rule C:/SoundFonts/fluidsynth-2.0.6/src/CMakeLists.txt
2> No download step for 'gentables'
2> No update step for 'gentables'
2> No patch step for 'gentables'
2> Performing configure step for 'gentables'
2> -- Selecting Windows SDK version 10.0.14393.0 to target Windows 10.0.17134.
2> -- The C compiler identification is MSVC 19.0.24215.1
2> -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
2> -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
2> -- Detecting C compiler ABI info
2> -- Detecting C compiler ABI info - done
2> -- Detecting C compile features
2> -- Detecting C compile features - done
2> -- Configuring done
2> -- Generating done
2> -- Build files have been written to: C:/SoundFonts/fluidsynth-2.0.6/build/src/gentables
2> Performing build step for 'gentables'
2> Microsoft (R) Build Engine version 14.0.25420.1
2> Copyright (C) Microsoft Corporation. All rights reserved.
2>
2> Checking Build System
2> Building Custom Rule C:/SoundFonts/fluidsynth-2.0.6/src/gentables/CMakeLists.txt
2> make_tables.c
2> gen_conv.c
2> gen_rvoice_dsp.c
2> Generating Code...
2> make_tables.vcxproj -> C:\SoundFonts\fluidsynth-2.0.6\build\src\gentables\make_tables.exe
2> make_tables.vcxproj -> C:/SoundFonts/fluidsynth-2.0.6/build/src/gentables/make_tables.pdb (Full PDB)
2> Building Custom Rule C:/SoundFonts/fluidsynth-2.0.6/src/gentables/CMakeLists.txt
2> Performing install step for 'gentables'
2> Completed 'gentables'
3>------ Rebuild All started: Project: libfluidsynth-OBJ, Configuration: Debug x64 ------
3> Building Custom Rule C:/SoundFonts/fluidsynth-2.0.6/src/CMakeLists.txt
3> fluid_aufile.c
3> fluid_dsound.c
3> fluid_winmidi.c
3> fluid_conv.c
3> fluid_hash.c
3> fluid_list.c
3> fluid_ringbuffer.c
3> fluid_settings.c
3> fluid_sys.c
3> fluid_defsfont.c
3> fluid_sfont.c
3> fluid_sffile.c
3> fluid_samplecache.c
3> fluid_adsr_env.c
3> fluid_chorus.c
3> fluid_iir_filter.c
3> fluid_lfo.c
3> fluid_rvoice.c
3> fluid_rvoice_dsp.c
3> fluid_rvoice_event.c
3> Generating Code...
3> Compiling...
3> fluid_rvoice_mixer.c
3> fluid_rev.c
3> fluid_chan.c
3> fluid_event.c
3> fluid_gen.c
3> fluid_mod.c
3> fluid_synth.c
3> fluid_synth_monopoly.c
3> fluid_tuning.c
3> fluid_voice.c
3> fluid_midi.c
3>C:\SoundFonts\fluidsynth-2.0.6\src\midi\fluid_midi.c(148): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
3>C:\SoundFonts\fluidsynth-2.0.6\src\midi\fluid_midi.c(1473): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
3> fluid_midi_router.c
3> fluid_seqbind.c
3> fluid_seq.c
3> fluid_adriver.c
3> fluid_mdriver.c
3> fluid_cmd.c
3> fluid_filerenderer.c
3> fluid_ladspa.c
3> Generating Code...
3> libfluidsynth-OBJ.vcxproj -> C:\SoundFonts\fluidsynth-2.0.6\build\src\libfluidsynth-OBJ.dir\Debug\libfluidsynth-OBJ.lib
4>------ Rebuild All started: Project: libfluidsynth, Configuration: Debug x64 ------
4> Building Custom Rule C:/SoundFonts/fluidsynth-2.0.6/src/CMakeLists.txt
4> Creating library C:/SoundFonts/fluidsynth-2.0.6/build/src/Debug/fluidsynth.lib and object C:/SoundFonts/fluidsynth-2.0.6/build/src/Debug/fluidsynth.exp
4> libfluidsynth.vcxproj -> C:\SoundFonts\fluidsynth-2.0.6\build\src\Debug\libfluidsynth-2.dll
4> libfluidsynth.vcxproj -> C:/SoundFonts/fluidsynth-2.0.6/build/src/Debug/libfluidsynth-2.pdb (Full PDB)
5>------ Rebuild All started: Project: fluidsynth, Configuration: Debug x64 ------
5> Building Custom Rule C:/SoundFonts/fluidsynth-2.0.6/src/CMakeLists.txt
5> fluidsynth.c
5> fluidsynth.vcxproj -> C:\SoundFonts\fluidsynth-2.0.6\build\src\Debug\fluidsynth.exe
5> fluidsynth.vcxproj -> C:/SoundFonts/fluidsynth-2.0.6/build/src/Debug/fluidsynth.pdb (Full PDB)
========== Rebuild All: 5 succeeded, 0 failed, 0 skipped ==========

@derselbst
Copy link
Member

The way you've built it looks correct. DSound is found, Debug build type and configuration is selceted. You should at least get some

fluidsynth: debug: Using 'dsound' audio driver

log output. If not, delete the build folder and restart from scratch, this time, by setting CMAKE_BUILD_TYPE right from the beginning to Debug.

If you don't get sound try starting fluidsynth.exe with the -o audio.sample-format float flag.

If you still don't get any sound, download, compile and test fluidsynth 1.1.8 please.

@jjceresa
Copy link
Collaborator

there are a few "No package 'x' found" like "No package 'sndfile' found" but not sure if I need that on PC?

Actually in you case you don't need sndfile. This isn't related to your issue. This library is useful only if fluidsynth is used for MIDI file to audio file rendering. (this feature is configured at cmake time with enable-aufile option checked.).


And on the info audio.driver i do not see "waveout"?

waveout is another possible driver option (on Windows). This driver is selectable at cmake time (as for dsound driver) via the enable-waveout option.
In you example above, the cmake build summary shows DSound:Yes but not WaveOut:Yes. So, in this case it is normal that fuidsynth info audio.drivercommand doesn't display the waveout option.
Note that for fluidsynth to be able to produce sound on audio card only ONE driver is necessary (dsound or waveout).

@jjceresa
Copy link
Collaborator

Also, before invoking fluidsynth, maybe it worth to check that your audio subsystem works as expected.

@maestrocoder
Copy link
Author

same issues on 2.0.6 version - and still unable to get Debug output even with setting the CMake CMAKE_BUILD_TYPE and enable_debug before running any Configure. I still hear a "click" sound when fluidsynth starts and exits but no actual real sound fonts with "noteon 0 60 100".

Also -o audio.sample-format=float did not work.

But when I run the exact same steps I get sound working on version 1.1.8. SUCCESS!! :-)

Also my subsystem sound is working find for web, music, etc..

Curious what's different between the versions where it works on old version but not new version because of your suggestion to try the old version?

Happy to continue to help troubleshoot and test as I learn this cool project.

@jjceresa
Copy link
Collaborator

Curious what's different between the versions where it works on old version but not new version.

Also, what is curious is why the new version (2.0.6) on your system (Windows 10) have issues that doesn't occur on my system (Windows XP) when using dsound driver.

Please, have you tried and got the same issues with WaveOut driver instead of dsound driver ?

@derselbst
Copy link
Member

I knew that dsound worked in 1.1.8 on win7: #215

The last modification to the dsound driver was in #435, not sure if this is to blame. I need to investigate.

PS.: waveout is only available on recent master, while he was using 2.0.6 .

@jjceresa
Copy link
Collaborator

PS.: waveout is only available on recent master, while he was using 2.0.6 .

Ok, I wasn't aware about this !


I have made some try here with 2.0.6 (build realease on win XP):

  1. When invoking fluidsynth without parameter: fluidsynt.exe
    I got the same 4 issues than @maestrocoder :
    1.1) some sound clics when fluidsynth starts.
    1.2) No debug infos displayed on stdout.
    1.3) no sound on (noteon 0 60 127) command after loading (load GUGSv1_47.sf2) a soundfont.
    1.4) some sound clics when fluidsynt exits.

  2. When invoking fluidsynth wit a sounfont parameter: fluidsynt.exe GUGSv1_47.sf2
    I got only issue 2.2 (same as 1.2):

    2.1) no sound clics when fluidsynth starts.
    2.2) No debug infos displayed on stdout
    2.3) sound correct on (noteon 0 60 127) command.
    2.4) no sound clics when fluidsynth exits.

@jjceresa
Copy link
Collaborator

I got the same 4 issues than @maestrocoder :
1.1) some sound clics when fluidsynth starts.
1.2) No debug infos displayed on stdout.
1.3) no sound on (noteon 0 60 127) command after loading (load GUGSv1_47.sf2) a soundfont.
1.4) some sound clics when fluidsynt exits.

It seems these issues are introduced by commit 5351d9d.

@derselbst
Copy link
Member

Ok, forget about the debug messages, this is trivial.


After looking into this, I think 4f2be10 is to blame. I found that turning off reverb makes the sound work again. It seems that reverb continuously overflows the synthesized audio. But you are right, this only happens when loading the soundfont via load from the shell.

derselbst added a commit that referenced this issue Sep 27, 2019
The parameters (roomsize, level, etc.) of the reverb effects unit are initialized at the very end of `new_fluid_synth()` with `fluid_synth_set_reverb_full_LOCAL()`. This however only adds an update-event to the `rvoice_mixer` queue. The call to `fluid_synth_process_event_queue()` in `new_fluid_synth()` should make sure, that this event is dispatched and triggers the actual update, but it is not dispatched, because a call to the rvoice event queue has not been committed yet, that is, a call to `fluid_rvoice_eventhandler_flush()` is missing.

So, although a reverb param initialization event has been queued, the reverb params still are garbage initialized to some `-6.2774385622041925e+66`.

The next call to through the synth's public API will flush the queue and finally dispatch the update event, but when will it happen?

1. If the soundfont is specified as command-line argument, this call will happen before the audio driver starts rendering
2. If the soundfont is loaded via shell command `load`, the audio driver will first start rendering audio, after updating the reverb.

Case 1. is trivial, not change is noticeable / audible.
Case 2. is interesting. Since the synth already started rendering audio by using that uninitialized reverb unit, the reverb engine's internal buffer is completely filled up with noise. Before outputting that signal to sound card, the sound is clipped to `1.0f`. That's the click we hear at the beginning. And because the reverb is so loud, the rendered audio signal stays 1.0f for quite a long time (...or always, can't tell).

Why is it not reproducible on Linux? Because GCC and Clang (AFAIK) leave all values uninitialized after memory allocation. And because malloc() often return zero-initialized memory, the reverb params seem to be nicely zero-initialized. MSVC however, always initializes memory with garbage, which is why we "hear" this resonance disaster.

Solution: Just update the reverb params via public API, which implicitly calls `fluid_rvoice_eventhandler_flush()`.

Fixes #563.
@derselbst
Copy link
Member

Fix is ready. Short story: The reverb model may be partially uninitialized. Long story, see #565.

@maestrocoder Thx for the report. Pls. feel free to test:
https://github.com/FluidSynth/fluidsynth/archive/fix563.zip

@jjceresa
Copy link
Collaborator

fix563.zip fix these issues here on Windows XP. Not obvious to find that reverb was continuously overflowing audio output !. Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants