Page 1 of 1

[Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Sun 06 Aug, 2017 7:00 pm
by bit
These patches adds improvements and new additions to MIDI (patched against commit d3e175d).

The base patches (1 to 3) adds a few useful methods, updates soundopenal.c and changes MIDI to be handled as a device by PCem. After these patches MIDI device-selection is moved out from sb_16_config and sb_awe32_config and is instead configured separately, it should make it easy to enable it if more sound cards requires it or if an external MPU-401-card is emulated. With these changes it becomes much easier to add other types of MIDI-devices.

Patch 4 adds new deviceconfig-options: CONFIG_FILE and CONFIG_SPINNER. FILE adds an option for browsing for a file and SPINNER adds an up-down component with a configurable step-size. Unfortunately I couldn't figure out how to make it a spinner on Windows so it's an edit-box there.

Patches 5.1/5.1.1 adds built-in Roland MT-32 and CM-32L-emulation using MUNT 2.2.0. It requires mt32_pcm.rom and mt32_control in roms/mt32 for MT-32 and cm32l_pcm.rom and cm32l_control.rom in roms/cm32l for CM-32L.
Patch 5.2 adds support for FluidSynth. It is not built-in and has to be linked when building. On Linux add --enable-fluidsynth to the configure-command or add FLUIDSYNTH=1 if building from Makefile.* (works on Windows as well)

Patch 6.1 adds more options to sb_16_config and sb_awe32_config and support for intelligent-mode. It fixes for example a crash when trying to use MT-32 in Space Quest 3.
Patch 6.2 adds support for SBMIDI. This patch was provided by basic2004 (https://pcem-emulator.co.uk/phpBB3/view ... =150#p6136).

Unfortunately Allegro was left partially behind and it's not possible to configure MIDI through the GUI, but it should work if configured manually.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Mon 07 Aug, 2017 4:37 am
by basic2004
bit wrote:These patches adds improvements and new additions to MIDI (patched against commit d3e175d).
Thanks bit, I fixed to enable MIDI for mainline PCem and your branch.
Makefile.mingw-wx-sdl2-network.patch
(3.72 KiB) Downloaded 702 times
Apply this patch if you done applying all of these MIDI patches.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Mon 07 Aug, 2017 10:20 am
by Battler
What dependencies do I need for linking FluidSynth?

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Mon 07 Aug, 2017 6:53 pm
by bit
Battler wrote:What dependencies do I need for linking FluidSynth?
I haven't built FluidSynth for Windows myself so I'm not sure, but basic2004 has done it so maybe he can help you.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Mon 07 Aug, 2017 11:22 pm
by Battler
I built it fine now but the number of additional DLL's it needs is enormous. :-/

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Mon 07 Aug, 2017 11:41 pm
by basic2004
Battler wrote:What dependencies do I need for linking FluidSynth?
Sorry for late answers, I installed fluidsynth 1.1.6 using cmake in my MinGW.
and I copied libfluidsynth.dll.a to libfluidsynth.a in my mingw32/lib directory.
Battler wrote:I built it fine now but the number of additional DLL's it needs is enormous. :-/
These files needed for fluidsynth.

Code: Select all

libfluidsynth-1.dll
libgcc_s_dw2-1.dll
libglib-2.0-0.dll
libiconv-2.dll
libintl-8.dll
libpcre-1.dll
libstdc++-6.dll
libwinpthread-1.dll
I renamed libfluidsynth.dll to libfluidsynth-1.dll.
You should include these DLLs to make archive.

and, can you port Munt 2.2.0 to 86Box?
Munt 2.2.0 added Nice ramp settings.
Check Patches 5.1 and 5.1.1.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Tue 08 Aug, 2017 12:07 am
by basic2004
@bit: no more remove -Wall arguments for midi_fluidsynth.c.

If I included -Wall argument, midi_fluidsynth.c failed to compile

Code: Select all

gcc.exe -O3 -march=i686 -fomit-frame-pointer -msse2 -mstackrealign -Wall -Werror -fno-strict-aliasing -DUSE_NETWORKING -DPCEM_USE_FLUIDSYNTH -c midi_fluidsynth.c
midi_fluidsynth.c: In function 'fluidsynth_sysex':
midi_fluidsynth.c:107:37: error: pointer targets in passing argument 2 of 'fluid_synth_sysex' differ in signedness [-Werror=pointer-sign]
         fluid_synth_sysex(d->synth, data, len, 0, 0, 0, 0);
                                     ^~~~
In file included from G:/backup-drivec/msys-pcem-fs116/mingw32/i686-w64-mingw32/include/fluidsynth.h:81:0,
                 from midi_fluidsynth.c:4:
G:/backup-drivec/msys-pcem-fs116/mingw32/i686-w64-mingw32/include/fluidsynth/synth.h:76:20: note: expected 'const char *' but argument is of type 'uint8_t * {aka unsigned char *}'
 FLUIDSYNTH_API int fluid_synth_sysex(fluid_synth_t *synth, const char *data, int len,
                    ^~~~~~~~~~~~~~~~~
But this issue can solved, borrow from ported 86Box's source. Thanks, Battler.

I replaced fluidsynth.c line 107

Code: Select all

        fluid_synth_sysex(d->synth, data, len, 0, 0, 0, 0);
to

Code: Select all

        fluid_synth_sysex(d->synth, (const char *) data, len, 0, 0, 0, 0);
FluidSynth feature works very well, I tested.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Tue 08 Aug, 2017 10:23 am
by Battler
basic2004 wrote:and, can you port Munt 2.2.0 to 86Box?
Munt 2.2.0 added Nice ramp settings.
Check Patches 5.1 and 5.1.1.
I'm going to look into that.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Wed 09 Aug, 2017 3:54 am
by ndavis82
Excellent! This patch now allows my MT-32 to work on Intelligent mode games.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Sun 13 Aug, 2017 7:36 pm
by bit
These patches tweaks the buffer for MT-32 and FluidSynth so they sound better.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Sat 02 Sep, 2017 1:33 pm
by basic2004
My soundfont has overwrittten to PCem's machine setting file when using FluidSynth.
This is my setting and my overwrittten soundfont file.

Code: Select all

gameblaster = 0
gus = 0
ssi2001 = 0
voodoo = 0
model = 430vx
cpu_manufacturer = 0
cpu = 4
cpu_use_dynarec = 1
cpu_waitstates = 0
gfxcard = bahamas64
video_speed = 3
sndcard = sbawe32
midi_device = fluidsynth
cpu_speed = 14
has_fpu = 1
disc_a = 
disc_b = 
hdd_controller = none
mem_size = 32768
cdrom_drive = 0
cdrom_enabled = 0
cdrom_channel = 2
cdrom_path = 
hdc_sectors = 0
hdc_heads = 0
hdc_cylinders = 0
hdc_fn = 
hdd_sectors = 0
hdd_heads = 0
hdd_cylinders = 0
hdd_fn = 
hde_sectors = 0
hde_heads = 0
hde_cylinders = 0
hde_fn = 
hdf_sectors = 0
hdf_heads = 0
hdf_cylinders = 0
hdf_fn = 
drive_a_type = 5
drive_b_type = 0
bpb_disable = 0
joystick_type = 0
mouse_type = 3
enable_sync = 1
netcard = ne2000

[Sound Blaster AWE32]
onboard_ram = 28672
base401 = 816
irq401 = 9
mode401 = 1
opl_emu = 0

[Joysticks]
joystick_0_nr = 0
joystick_1_nr = 0

[FluidSynth]
sound_font = C:\soundfont\masquerade55v006.sf2
output_gain = 100
chorus = 1
chorus_voices = 3
chorus_level = 100
chorus_speed = 30
chorus_depth = 80
chorus_waveform = 0
reverb = 1
reverb_room_size = 20
reverb_damping = 0
reverb_width = 1
reverb_level = 90
interpolation = 2
This critical bug appears in 17 August, I compiled PCem-wx-SDL2 in 17 August too, after applied fluidsynth buffer patch.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Sun 03 Sep, 2017 7:38 am
by bit
basic2004 wrote:My soundfont has overwrittten to PCem's machine setting file when using FluidSynth.
This is my setting and my overwrittten soundfont file.

Code: Select all

gameblaster = 0
gus = 0
ssi2001 = 0
voodoo = 0
model = 430vx
cpu_manufacturer = 0
cpu = 4
cpu_use_dynarec = 1
cpu_waitstates = 0
gfxcard = bahamas64
video_speed = 3
sndcard = sbawe32
midi_device = fluidsynth
cpu_speed = 14
has_fpu = 1
disc_a = 
disc_b = 
hdd_controller = none
mem_size = 32768
cdrom_drive = 0
cdrom_enabled = 0
cdrom_channel = 2
cdrom_path = 
hdc_sectors = 0
hdc_heads = 0
hdc_cylinders = 0
hdc_fn = 
hdd_sectors = 0
hdd_heads = 0
hdd_cylinders = 0
hdd_fn = 
hde_sectors = 0
hde_heads = 0
hde_cylinders = 0
hde_fn = 
hdf_sectors = 0
hdf_heads = 0
hdf_cylinders = 0
hdf_fn = 
drive_a_type = 5
drive_b_type = 0
bpb_disable = 0
joystick_type = 0
mouse_type = 3
enable_sync = 1
netcard = ne2000

[Sound Blaster AWE32]
onboard_ram = 28672
base401 = 816
irq401 = 9
mode401 = 1
opl_emu = 0

[Joysticks]
joystick_0_nr = 0
joystick_1_nr = 0

[FluidSynth]
sound_font = C:\soundfont\masquerade55v006.sf2
output_gain = 100
chorus = 1
chorus_voices = 3
chorus_level = 100
chorus_speed = 30
chorus_depth = 80
chorus_waveform = 0
reverb = 1
reverb_room_size = 20
reverb_damping = 0
reverb_width = 1
reverb_level = 90
interpolation = 2
This critical bug appears in 17 August, I compiled PCem-wx-SDL2 in 17 August too, after applied fluidsynth buffer patch.
I looked at the source and I found that it can happen if the soundfont is configured when creating a new config on the normal Windows-version. Do you think this is what happened to you?
I've made some changes on my GitHub, please try it and see if it fixed your issue.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Sun 03 Sep, 2017 10:13 am
by basic2004
bit wrote:I looked at the source and I found that it can happen if the soundfont is configured when creating a new config on the normal Windows-version. Do you think this is what happened to you?
I've made some changes on my GitHub, please try it and see if it fixed your issue.
Thanks! this patch works well.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Sun 03 Sep, 2017 12:58 pm
by bit
basic2004 wrote:Thanks! this patch works well.
Great! I'm really sorry that it destroyed your SoundFont :(

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Sun 03 Sep, 2017 3:46 pm
by basic2004
bit wrote:
basic2004 wrote:Thanks! this patch works well.
Great! I'm really sorry that it destroyed your SoundFont :(
Don't worry, I used that was copied file(fast access for SSD), original was placed in another HDD.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Sun 03 Sep, 2017 6:42 pm
by bit
This patch modifies the configuration manager on Windows to prevent saveconfig to write to the wrong place when CONFIG_FILE has been used.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Sun 08 Oct, 2017 1:05 pm
by basic2004
I combined these MIDI patches from this thread against PCem rev#9c1822d.
I hope to implement new MIDI features(mt32emu, fluidsynth) into PCem v13.

* Munt mt32emu version is 2.2.0. this requires those ROM files.
* FluidSynth requires those libraries based 1.1.6 (FluidSynth 1.1.7 works, maybe...)

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Mon 09 Oct, 2017 3:34 am
by BoisterousSleet75
basic2004 wrote:I combined these MIDI patches from this thread against PCem rev#9c1822d.
I hope to implement new MIDI features(mt32emu, fluidsynth) into PCem v13.

* Munt mt32emu version is 2.2.0. this requires those ROM files.
* FluidSynth requires those libraries based 1.1.6 (FluidSynth 1.1.7 works, maybe...)
I'm also hope those MIDI features will be implemented to PCem v13.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Mon 09 Oct, 2017 5:08 pm
by SarahWalker
I don't think I really want to pull MUNT and FluidSynth into PCem, they seem like the sort of thing that should be external to the emulator.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Mon 09 Oct, 2017 5:19 pm
by amadama
Adding MUNT to PCEM will allow you to potentially add the Roland LAPC-1 as an internal sound card option.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Tue 10 Oct, 2017 1:45 am
by basic2004
SarahWalker wrote:I don't think I really want to pull MUNT and FluidSynth into PCem, they seem like the sort of thing that should be external to the emulator.
Well, I enough current MIDI out devices with Windows, using LoopMIDI(virtual MIDI device) and some VSTi(Munt and BASSMIDI(similar with FluidSynth) for VSTi) instead mt32emu and fluidsynth.
but I don't know about Linux, did PCem use MIDI with ALSA or JACK in Linux?
and Mac OS X... maybe this uses CoreMIDI for System MIDI.

currently, no need for support mt32emu and fluidsynth if PCem supports system MIDI with all operating systems.

I want these.
1. PCem should playing MIDI out device correctly.
2. support SBMIDI with current MPU-401 UART mode.
3. support MIDI out device for all Sound Blaster cards using SBMIDI.

P.S. Joystick feature working very well! No crashes and no messed-up mapping. I tested with my XBOX One S controller.

Re: [Patch] MIDI improvements, added MT-32, FluidSynth

Posted: Wed 11 Oct, 2017 7:31 pm
by SarahWalker
Okay, rev 879 gets MIDI working again with Windows, rev 880 adds Linux MIDI output via ALSA. For the latter, add '--enable-alsa' to the ./configure command line. It currently only supports hw devices, so you'll have to use VirMIDI to use software synths. I did confirm it works with Fluidsynth at least.