[Bug] MIDI Out device problem

Discussion of development and patch submission.
Post Reply
basic2004
Posts: 124
Joined: Sun 08 Jan, 2017 5:59 pm

[Bug] MIDI Out device problem

Post by basic2004 »

PCem loading MIDI Out device only first device (id #0) from latest development version (rev #5d61552).
I select and saved 4th device(loopMIDI Port B), this can't load correctly.
my MIDI Out devices

1. VirtualMIDISynth #1
2. Microsoft GS Wavetable Synth
3. loopMIDI Port A
4. loopMIDI Port B

I saw this error from pclog.txt

Code: Select all

midiOutOpen error - 00000004
Rev #8694ad0 was loaded correctly, maybe this was last version of old config.
basic2004
Posts: 124
Joined: Sun 08 Jan, 2017 5:59 pm

Re: [Bug] MIDI Out device problem

Post by basic2004 »

I modify MIDI Out device, save setting and hard reset current machine, MIDI plays from modified device.
but quitting machine and restart PCem, MIDI plays from first device again.
Battler
Posts: 793
Joined: Sun 06 Jul, 2014 7:05 pm

Re: [Bug] MIDI Out device problem

Post by Battler »

- basic2004: I think SarahWalker moved the reading of the relevent variable from the configuration file elsewhere, but forgot to comment out the code in midi_reset() that reset MIDI out device to 0. Incidentally, I made the exact same mess up in 86Box, and I found and fixed it about an hour ago.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [Bug] MIDI Out device problem

Post by SarahWalker »

There's no such function as midi_reset(). midi_init() does load the MIDI ID from the current config file, and this does seem to be working, at least for me. Could you add the line

pclog("midi_id = %i\n", midi_id);

in win-midi.c, just after the 'midi_id = config_get_int()', and report back what it's trying to open?
basic2004
Posts: 124
Joined: Sun 08 Jan, 2017 5:59 pm

Re: [Bug] MIDI Out device problem

Post by basic2004 »

These are reports of pclog

1. Run PCem.exe and loaded machine (I selected 4th MIDI out device)

Code: Select all

midi_id = 3
midiOutOpen error - 00000004
2. Save and rerun PCem.exe and loaded same machine (I selected 3rd MIDI out device)

Code: Select all

midi_id = 2
midiOutOpen error - 00000004
3. Save and reset (didn't rerun PCem.exe only I changed to 4th MIDI out device)

Code: Select all

midi_id = 3
timer_reset
Case 3 detected correctly.
basic2004
Posts: 124
Joined: Sun 08 Jan, 2017 5:59 pm

Re: [Bug] MIDI Out device problem

Post by basic2004 »

Finally I solved this.

Code: Select all

--- src/win.c.orig	2017-07-23 16:41:24 +0900
+++ src/win.c	2017-07-24 14:27:57 +0900
@@ -702,7 +702,6 @@
                 keyboard_init();
                 mouse_init();
                 joystick_init();
-                midi_init();
         
                 if (start_in_fullscreen)
                 {
pcem-fix-midioutdevice.patch
(312 Bytes) Downloaded 396 times
I deleted midi_init() because this function already did from resetpchard() so MIDI detects correctly.
basic2004
Posts: 124
Joined: Sun 08 Jan, 2017 5:59 pm

Re: [Bug] MIDI Out device problem

Post by basic2004 »

And my pclog result.

Code: Select all

path = B:\PCem-test\
Config data :
[]
vid_resize = 0
vid_force_aspect_ratio = 0
vid_disc_indicator = 1
vid_api = 0
video_fullscreen_scale = 0
video_fullscreen_first = 1
window_w = 0
window_h = 0
window_x = 0
window_y = 0
window_remember = 0
sound_buf_len = 200
[Paths]
roms_paths = 
nvr_path = 
configs_path = 
logs_path = 
Config data :
[]
Config loaded
Starting with romset 13
timer_reset
Cannot open file '': Invalid argumentCannot open file '': Invalid argumentCannot open file '': Invalid argumentCannot open file '': Invalid argumentPath is \\.\
Starting with romset 0
romset 0 - 1
Starting with romset 1
romset 1 - 1
Starting with romset 2
romset 2 - 1
Starting with romset 3
romset 3 - 1
Starting with romset 4
romset 4 - 1
Starting with romset 5
romset 5 - 1
Starting with romset 6
romset 6 - 1
Starting with romset 7
romset 7 - 1
Starting with romset 8
romset 8 - 1
Starting with romset 9
romset 9 - 1
Starting with romset 10
romset 10 - 1
Starting with romset 11
Loading BIOS
FF FF FF
romset 11 - 1
Starting with romset 12
romset 12 - 1
Starting with romset 13
romset 13 - 1
Starting with romset 14
romset 14 - 1
Starting with romset 15
romset 15 - 1
Starting with romset 16
romset 16 - 1
Starting with romset 17
romset 17 - 1
Starting with romset 18
romset 18 - 1
Starting with romset 19
romset 19 - 1
Starting with romset 20
romset 20 - 1
Starting with romset 21
romset 21 - 1
Starting with romset 22
romset 22 - 1
Starting with romset 23
romset 23 - 1
Starting with romset 24
romset 24 - 1
Starting with romset 25
romset 25 - 1
Starting with romset 26
romset 26 - 1
Starting with romset 27
romset 27 - 1
Starting with romset 28
Failed to load ROM!
romset 28 - 0
Starting with romset 29
romset 29 - 1
Starting with romset 30
romset 30 - 1
Starting with romset 31
romset 31 - 1
Starting with romset 32
romset 32 - 1
Starting with romset 33
romset 33 - 1
Starting with romset 34
romset 34 - 1
Starting with romset 35
romset 35 - 1
Starting with romset 36
Load SIS496 ea ff
romset 36 - 1
Starting with romset 37
romset 37 - 1
Starting with romset 38
romset 38 - 1
Starting with romset 39
romset 39 - 1
Starting with romset 40
romset 40 - 1
Starting with romset 41
romset 41 - 1
Starting with romset 42
romset 42 - 1
Starting with romset 43
romset 43 - 1
Starting with romset 44
romset 44 - 1
Starting with romset 45
Failed to load ROM!
romset 45 - 0
Starting with romset 46
Failed to load ROM!
romset 46 - 0
Starting with romset 47
Failed to load ROM!
romset 47 - 0
Starting with romset 48
Failed to load ROM!
romset 48 - 0
Dir B:\PCem-test\configs/*.cfg
DlgDirSelectEx returned 0 486.
Config name B:\PCem-test\configs/486.cfg
Raw input registered!
Preparing scan code map list...
Done preparing!
path = B:\PCem-test\
Config data :
[]
vid_resize = 0
vid_force_aspect_ratio = 0
vid_disc_indicator = 1
vid_api = 0
video_fullscreen_scale = 0
video_fullscreen_first = 1
window_w = 0
window_h = 0
window_x = 0
window_y = 0
window_remember = 0
sound_buf_len = 200
[Paths]
roms_paths = 
nvr_path = 
configs_path = 
logs_path = 
Config data :
[]
gameblaster = 0
gus = 0
ssi2001 = 0
voodoo = 0
model = win486
cpu_manufacturer = 0
cpu = 10
cpu_use_dynarec = 0
cpu_waitstates = 0
gfxcard = px_trio64
video_speed = 4
sndcard = sb16
cpu_speed = 6
has_fpu = 1
disc_a = 
disc_b = 
hdd_controller = none
mem_size = 8192
cdrom_drive = 0
cdrom_enabled = 0
cdrom_channel = 2
cdrom_path = 
hdc_sectors = 63
hdc_heads = 16
hdc_cylinders = 4095
hdc_fn = O:\EMUL\Emulator - Computer\IBM-PC\HDDimage\pcat-msdos-drivec.img
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 = 0
enable_sync = 1
midi = 3
[Phoenix S3 Trio64]
memory = 4
[Joysticks]
joystick_0_nr = 0
joystick_1_nr = 0
[Sound Blaster 16]
opl_emu = 1
Starting with romset 34
Starting with romset 34
midi_id = 3
timer_reset
Loading :0  
Loading :1  
Initting as [486] AMI WinBIOS 486
io_init
Video_init 34 19
PCI burst=2 nonburst=8
hasfpu - 1
is486 - 1  10
x86 reset
znp8 b1 = 4 04
znp16 b1 = 4 04
znp16 65b1 = 4 04
Cannot open file '': Invalid argumentCannot open file '': Invalid argumentCannot open file '': Invalid argumentPath is \\.\
DDRAW_INIT complete
Keyboard initialized!
joystick_enum_callback : found joystick 0 : vJoy Device
joystick_init: joysticks_present=1
Joystick 0 :
 tszInstanceName = vJoy Device
 tszProductName = vJoy Device
 Axes = 8
 Buttons = 16
 POVs = 1
Axis 0 : X 軸  0 1000002
Axis 1 : Y 軸  4 1000102
Axis 2 : Z 軸  8 202
Axis 3 : X 回転  c 302
Axis 4 : Y 回転  10 402
Axis 5 : Z 回転  14 502
Axis 6 : スライダー  18 602
Axis 7 : ダイヤル  1c 702
POV 0 : Hat Switch  20 10
Button 0 : ボタン 0  38 2000004
Button 1 : ボタン 1  39 2000104
Button 2 : ボタン 2  3a 2000204
Button 3 : ボタン 3  3b 2000304
Button 4 : ボタン 4  3c 2000404
Button 5 : ボタン 5  3d 2000504
Button 6 : ボタン 6  3e 2000604
Button 7 : ボタン 7  3f 2000704
Button 8 : ボタン 8  40 2000804
Button 9 : ボタン 9  41 2000904
Button 10 : ボタン 10  42 2000a04
Button 11 : ボタン 11  43 2000b04
Button 12 : ボタン 12  44 2000c04
Button 13 : ボタン 13  45 2000d04
Button 14 : ボタン 14  46 2000e04
Button 15 : ボタン 15  47 2000f04
onesec
onesec
onesec
onesec
onesec
FIFO is now 01, threshold is 09
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
onesec
Dir B:\PCem-test\configs/*.cfg
PIC1 : MASK A8 PEND 00 INS 00 VECTOR 08
PIC2 : MASK 1D PEND 00 INS 00 VECTOR 70
Dumping rram.dmp
Dumping rram4.dmp
Dumping done
EAX=00000720 EBX=0008FFFF ECX=00000002 EDX=00000000
EDI=0015C0E0 ESI=00110040 EBP=00008E3C ESP=00000900
PC=16EC CS=C801 DS=0116 ES=029E SS=0116 FLAGS=7002
C801:16E5 0000:0000
215268363 ins
In V86 mode
CS : base=0C8010 limit=0000FFFF access=62  limit_low=00000000 limit_high=0000FFFF
DS : base=001160 limit=0000FFFF access=62  limit_low=00000000 limit_high=0000FFFF
ES : base=0029E0 limit=0000FFFF access=62  limit_low=00000000 limit_high=0000FFFF
FS : base=000000 limit=0000FFFF access=62  limit_low=00000000 limit_high=0000FFFF
GS : base=0029E0 limit=0000FFFF access=62  limit_low=00000000 limit_high=0000FFFF
SS : base=001160 limit=0000FFFF access=62  limit_low=00000000 limit_high=0000FFFF
GDT : base=154BB0 limit=0177
LDT : base=000000 limit=0000
IDT : base=1543B0 limit=07FF
TR  : base=150304 limit=FFFF
386 in 16-bit mode   stack in 16-bit mode
CR0=80000011 CR2=8004FFFF CR3=00118000 CR4=00000000
Entries in readlookup : 0    writelookup : 0
Entries in readlookup : 256    writelookup : 1
ST(0)=0.000000	ST(1)=0.000000	ST(2)=0.000000	ST(3)=0.000000	
ST(4)=0.000000	ST(5)=0.000000	ST(6)=0.000000	ST(7)=0.000000	
Status = 0000  Control = 037F  Tag = FFFF
MIDI out device detected correctly. no more midiOutOpen error - 00000004.

Code: Select all

midi_id = 3
timer_reset
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: [Bug] MIDI Out device problem

Post by SarahWalker »

I preferred to fix the other way - remove the calls in resetpchard() (as otherwise PCem will keep the MIDI device open when the configuration manager is in use). Can you try rev 817 and let me know if it works?
ndavis82
Posts: 47
Joined: Sun 25 Dec, 2016 5:54 am

Re: [Bug] MIDI Out device problem

Post by ndavis82 »

SarahWalker wrote:I preferred to fix the other way - remove the calls in resetpchard() (as otherwise PCem will keep the MIDI device open when the configuration manager is in use). Can you try rev 817 and let me know if it works?
Latest revision works. Thanks!
basic2004
Posts: 124
Joined: Sun 08 Jan, 2017 5:59 pm

Re: [Bug] MIDI Out device problem

Post by basic2004 »

SarahWalker wrote:I preferred to fix the other way - remove the calls in resetpchard() (as otherwise PCem will keep the MIDI device open when the configuration manager is in use). Can you try rev 817 and let me know if it works?
MIDI out device worked when starting PCem machine.
but it didn't work correctly when change MIDI out device and reset PCem.
basic2004
Posts: 124
Joined: Sun 08 Jan, 2017 5:59 pm

Re: [Bug] MIDI Out device problem

Post by basic2004 »

@SarahWalker: midi_init() should include in resetpchard() because PCem will doing hard reset after changing MIDI out device.
so I deleted duplicate call from win.c.
changedMidiOutDevice.png
changedMidiOutDevice.png (18.2 KiB) Viewed 10680 times
@ndavis82: Can you follow this with latest revision?
In my case, MIDI out device doesn't changed after change MIDI out device and reset.
ndavis82
Posts: 47
Joined: Sun 25 Dec, 2016 5:54 am

Re: [Bug] MIDI Out device problem

Post by ndavis82 »

You are correct. Midi out device does not change when resetting. However, it does change when quitting PCem and reloading.
basic2004
Posts: 124
Joined: Sun 08 Jan, 2017 5:59 pm

Re: [Bug] MIDI Out device problem

Post by basic2004 »

An other idea. add midi_close() before midi_init() in win.c, and reverted resetpchard() in pc.c.

Code: Select all

--- src/win.c.orig	2017-07-26 19:40:08 +0900
+++ src/win.c	2017-07-27 15:02:48 +0900
@@ -702,6 +702,7 @@
                 keyboard_init();
                 mouse_init();
                 joystick_init();
+                midi_close();
                 midi_init();
         
                 if (start_in_fullscreen)
MIDI out device detects after this patch too.
fix-midioutdevice-rev817.patch
(624 Bytes) Downloaded 378 times
Post Reply