Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running libfluidsynth-3.dll with rundll32.exe as 64 bit and how to return values

Status
Not open for further replies.

Jan Flikweert

Programmer
Mar 20, 2022
85
NL
Hi all,

This regards fluidsynth.

First of all an important remark. The VFP code I provided is not a complete working piece of code, but in short to document my questions. I also included C code from an example to illustrate how it should be used.

So my question is not how to get this code working.

I have two questions:

1. Is there a way to load a 64 bit libfluidsynth-3.dll using Wscript?
2. How to process return values like in C settings = new_fluid_settings()?


Code:
PUBLIC WshShell AS Object,synth,settings,adriver,mdriver
WshShell = CreateObject("WScript.Shell")
PUBLIC a AS OBJECT,settings,synth,adriver,mdriver
oExec = WshShell.exec("c:\windows\system32\rundll32.exe .\bin\libfluidsynth-3.dll") 
[COLOR=#3465A4][b]oExec.StdIn.WriteLine("libfluidsynth.new_fluid_settings()")[/b][/color]
oExec.StdIn.WriteLine("libfluidsynth.new_fluid_audio_driver()")
oExec.StdIn.WriteLine("libfluidsynth.new_fluid_synth()")
oExec.StdOut.ReadAll()

C:
    settings = new_fluid_settings();
    synth = new_fluid_synth(settings);
    adriver = new_fluid_audio_driver(settings, synth);
    sfont_id = fluid_synth_sfload(synth, "example.sf2", 1);
Kind regards,


Jan Flikweert
 
For today I can only help you with running 64bit Wscript shell, or anything from the 64bit system executables:

Code:
oExec = WshShell.exec("c:\windows\[highlight]sysnative[/highlight]\rundll32.exe .\bin\libfluidsynth-3.dll")

Of course pointing to the 64bit libfluidsynth DLL.

You can see that SYSNATIVE is the magic world to let us call the 64bit executables in the Windows/System32 folder, to which calls are normally redirected to SysWow64 for 32bit processes.
I don't see direct benefits of the 64bit midi world, it's still the same interface, isn't it? And you don't need >4GB large file access, do you?

Are there versions only available in 64bit?

Regarding the more direct usage of this DLL, as you brought it up earlier in thread184-1814465, I think you will need a wrapper made in C++ as a VFP FLL, for example, to get hands on it.

Chriss
 
Hi Chriss,

Thanks for your reply.

I use a 64-bit because I need 1,6 GB memory. That is the size of the soundfont. The Digital Audio Work Station also uses 2 GB. Indeed there is a 32 bit version of libfluidsynth-3.

I suppose using 32-bit will not solve the problem of question 2: How to process return values like in C settings = new_fluid_settings()?

An other option is to use fluidsynth.exe The con of this option is you can not use the API commands. The next code produces the sound of 16 channels.

Code:
Close All
Clear All

#include fluidsynth.h

Declare Sleep In kernel32 Integer dwMilliseconds

PUBLIC oWSH AS Object,oExec AS OBJECT
oWSH = CreateObject("Wscript.Shell")
oExec = oWSH.Exec("[COLOR=#CC0000].\binx64\fluidsynth.exe 'C:\Domus gig\Hoofd_1.sf2'[/color] -r 48000 -o midi.winmidi.device='0:0'")
oExec.StdIn.WriteLine("set synth.midi-channels 128")
oExec.StdIn.WriteLine("set synth.midi-bank-select 'gm'")
oExec.StdIn.WriteLine("set synth.reverb.active 0")
oExec.StdIn.WriteLine("set synth.chorus.active 0")
oExec.StdIn.WriteLine("set synth.cpu-cores 5")
oExec.StdIn.WriteLine("set synth.sample-rate 48000")
oExec.StdIn.WriteLine("set synth.polyphony 1024")
oExec.StdIn.WriteLine("set synth.overflow.age 0.55")
oExec.StdIn.WriteLine("set synth.overflow.percussion 0.1")
oExec.StdIn.WriteLine("set synth.overflow.released 0.5")
oExec.StdIn.WriteLine("set synth.overflow.sustained 0.1")
oExec.StdIn.WriteLine("set synth.overflow.volume 0.4")
oExec.StdIn.WriteLine("set synth.gain 2")
oExec.StdIn.WriteLine("interp 7") 
oExec.StdIn.WriteLine("prog 0 0")  
oExec.StdIn.WriteLine("prog 1 1")  
oExec.StdIn.WriteLine("prog 2 2")  
oExec.StdIn.WriteLine("prog 3 3")  
oExec.StdIn.WriteLine("prog 4 4")  
oExec.StdIn.WriteLine("prog 5 5")  
oExec.StdIn.WriteLine("prog 6 6")  
oExec.StdIn.WriteLine("prog 7 7")  
oExec.StdIn.WriteLine("prog 8 8")  
oExec.StdIn.WriteLine("prog 9 9")  
oExec.StdIn.WriteLine("prog 10 10")  
oExec.StdIn.WriteLine("prog 11 11")  
oExec.StdIn.WriteLine("prog 12 12")  
oExec.StdIn.WriteLine("prog 13 13")  
oExec.StdIn.WriteLine("prog 14 14")  
oExec.StdIn.WriteLine("prog 15 15")  
oExec.StdIn.WriteLine("noteon 0 60 127")  
oExec.StdIn.WriteLine("noteon 1 60 127")  
oExec.StdIn.WriteLine("noteon 2 60 127")  
oExec.StdIn.WriteLine("noteon 3 60 127")  
oExec.StdIn.WriteLine("noteon 4 60 127")  
oExec.StdIn.WriteLine("noteon 5 60 127")  
oExec.StdIn.WriteLine("noteon 6 60 127")  
oExec.StdIn.WriteLine("noteon 7 60 127")  
oExec.StdIn.WriteLine("noteon 8 60 127")  
oExec.StdIn.WriteLine("noteon 9 60 127")  
oExec.StdIn.WriteLine("noteon 10 60 127")  
oExec.StdIn.WriteLine("noteon 11 60 127")  
oExec.StdIn.WriteLine("noteon 12 60 127")  
oExec.StdIn.WriteLine("noteon 13 60 127")  
oExec.StdIn.WriteLine("noteon 14 60 127")  
oExec.StdIn.WriteLine("noteon 15 60 127")  
oExec.StdOut.ReadAll()
READ EVENTS
testkeypress=.t.
DO WHILE testkeypress=.t.
	ON KEY testkeypress=.f.
	sleep(1)
ENDDO
Set Sysmenu To Default
Close All
Clear All
Release All
Cancel
Quit

The red marked code needs to be replaced with your own location of fuidsynth.exe and your own Soundfont.

Kind regards,

Jan Flikweert
 
Jan Flikweert said:
I suppose using 32-bit will not solve the problem of question 2
Well, 64 bit or 32 bit, no the return values you get from the DLL are addresses, I think we worked that out already, addresses to C structs. And you can't make much of that in VFP.

There's SYS(2600), but I don't think that's leading anywhere near to a usable interface to make use of the DLL, which is, as C sample code shows, easier to use in C and C++.

Regarding 1.6 GB in memory, a 32bit process can use up to 4GB, not just 2GB, so even adding in another 2GB of the Digital Audio Station. That's not breaking 32bit limits. Well, or do you get errors regarding insufficient memory?

Sysnative only overcomes the problem of file access to 64bit system executables. You see for yourself calling the 64bit .\binx64\fluidsynth.exe is possible, because that's not in a system folder redirecting access to it. You only need Sysnative to get to the 64bit rundll32.exe (and yes, that's still also named rundll[highlight ]32[/highlight].exe) and you only need that, as you "call" the DLL via the rundll interface and not DCLAREs.
And in VFP DCLARES can only use 32bit DLLs, as DLLs are always loaded into the same process as the user and so 64bit DLLs can't be used in VFP without such a helper that is the 64bit process.

That's still true with an FL, though, as that would need to be 32bit, too. A helper that uses the 64bit DLL has to be in a 64bit process. So a wrapper could also be a 64bit EXE that you start and communicate with to indirectly communicate with the 64bit DLL in that external 64bit process. Other than a rundll call you can have more control about what interface the 64bit process allows. Simply because you program that.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top