fp universal library ?

classic Classic list List threaded Threaded
36 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

fredvs
Hello.

Here next episode of the conversion of a useful unit into a universal library.
In a recent topic i was taking about the total victory of the conversion in Linux OS.
Now im fighting to do it in Windows.
I have Windows 7-64 bit.
If compiling the library with fpc-64bit, all is working perfectly. A 64bit-program can access all the functions of the library.
But, compiling the library with fpc-32bit, if a 32bit-program try to access the 32bit-library, i get that error message :
 
C:\Users\moi>gdb c:\uoslibwin\src\uoslibtest.exe
(gdb) run
Starting program: c:\uoslibwin\src\uoslibtest.exe
[New Thread 3060.0x2b0]
Program received signal SIGSEGV, Segmentation fault.
0x10002c40 in uos_AddDSPVolumeIn () from c:\uoslibwin\src\uos.dll
(gdb)
 
And here with extended  gdb
Program received signal SIGSEGV, Segmentation fault.
0x10002cf0 in SYSTEM_$$_CPUINCLOCKED$LONGINT () from c:\uoslibwin\src\uos.dll
(gdb)
 
I have changed all  cdecl  into stdcall but without luck...
 
Does the fpc-32 bit libraries work only on a Windows-32bit system (or did i do something wrong ?)
Will it be the same for Linux-32bit (inside a multi-arch 64bit system) ?

Many thanks.

Fred.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

Sven Barth-2
Am 11.02.2014 00:53, schrieb Fred van Stappen:
I have changed all  cdecl  into stdcall but without luck...
Did you change the calling convention for both the import and the export code? (just a sidenote: on Linux you should use cdecl no matter what if you want your library to be used by other languages and preferably stdcall on Windows (makes a difference only on i386 as for ARM and x86_64 (and other CPUs) stdcall maps to cdecl))
Does the fpc-32 bit libraries work only on a Windows-32bit system (or did i do something wrong ?)
Will it be the same for Linux-32bit (inside a multi-arch 64bit system) ?
Without some code it's hard to tell what the problem might be. Normally it should work, so likely there's a problem in your code that only manifests on Win32 or there is (less likely) a bug in the compiler/RTL. So if you could minimize your code as much as possible and test then, this would be favorable.

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

fredvs
>I have changed all  cdecl  into stdcall but without luck...
>Did you change the calling convention for both the import and the export
> code? (just a sidenote: on Linux you should use cdecl no matter what ifnt >your library to be used by other languages and preferably stdcall on
> Windows (makes a difference only on i386 as for ARM and x86_64 (and
> other CPUs) stdcall maps to cdecl))
>Does the fpc-32 bit libraries work only on a Windows-32bit system
>(or did i do something wrong ?)
>Will it be the same for Linux-32bit (inside a multi-arch 64bit
>system) ?
>Without some code it's hard to tell what the problem might be. Normally it
>should work, so likely there's a problem in your code that only manifests on >Win32 or there is (less likely) a bug in the compiler/RTL. So if you could >minimize your code as much as possible and test then, this would be >favorable.

Many thanks Sven.

I have changed stdcall <> cdecl in both import-export, with no luck.
I will do a "Hello World" library to see if problem is still there (because the code of uos is big.).

See you later with the result.

Fred


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

fredvs
In reply to this post by Sven Barth-2
Hello.

Here next adventure of uos library...

I have good news for fpc. ;-)
I have try with a "hello world" 32bit library in Windows 7 64bit.
It works, a 32bit program can access a 32bit fpc library.

But i have bad news for me. :-(

I have try with uoslib, and try, and try, changing everything, but still same error message:
Program received signal SIGSEGV, Segmentation fault.
0x10002cf0 in SYSTEM_$$_CPUINCLOCKED$LONGINT () from c:\uoslibwin\src\uos.dll

I do not see the solution.

If a brave heart could try it, he will be my hero. ;-)

This is very easy.
All is included, you dont have to install anything...

First download the source here :

>> https://sites.google.com/site/fiensprototyping/uoslibtest.tar.gz

Unzip it and in /uoslibtest/src :

1) Compile uoslib.pas (or uoslib.lpi) => it will create uos.dll in /src.
2) Compile and run libconsoleplay.pas (or libconsoleplay.lpi) => it will test the library.

For me, it works if i compile both library and example with fpc 64 bit.
But it crash if i compile both library and example with fpc 32 bit.

In /src there is also unitconsoleplay.pas (and unitconsoleplay.lpi).
This program uses directly uos-unit, not via uoslib library.
And, this one on Windows 7 64bit, works compiled with fpc 32bit...

Many thanks.
Fred.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

Sandro Cumerlato
Hello Fred,
change these two lines:

uos.pas line 1086:
    RTLeventSetEvent(evPause);

uoslib.pas line 41:
function uos_loadlib(PortAudioFileName: string; SndFileFileName:
string; Mpg123FileName: string; SoundTouchFileName: string) : integer;
cdecl;

Sandro



On 11 February 2014 16:52, Fred van Stappen <[hidden email]> wrote:

> Hello.
>
> Here next adventure of uos library...
>
> I have good news for fpc. ;-)
> I have try with a "hello world" 32bit library in Windows 7 64bit.
> It works, a 32bit program can access a 32bit fpc library.
>
> But i have bad news for me. :-(
>
> I have try with uoslib, and try, and try, changing everything, but still
> same error message:
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x10002cf0 in SYSTEM_$$_CPUINCLOCKED$LONGINT () from
> c:\uoslibwin\src\uos.dll
>
> I do not see the solution.
>
> If a brave heart could try it, he will be my hero. ;-)
>
> This is very easy.
> All is included, you dont have to install anything...
>
> First download the source here :
>
>>> https://sites.google.com/site/fiensprototyping/uoslibtest.tar.gz
>
> Unzip it and in /uoslibtest/src :
>
> 1) Compile uoslib.pas (or uoslib.lpi) => it will create uos.dll in /src.
> 2) Compile and run libconsoleplay.pas (or libconsoleplay.lpi) => it will
> test the library.
>
> For me, it works if i compile both library and example with fpc 64 bit.
> But it crash if i compile both library and example with fpc 32 bit.
>
> In /src there is also unitconsoleplay.pas (and unitconsoleplay.lpi).
> This program uses directly uos-unit, not via uoslib library.
> And, this one on Windows 7 64bit, works compiled with fpc 32bit...
>
> Many thanks.
> Fred.
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

Tomas Hajny-2
In reply to this post by fredvs
On Tue, February 11, 2014 16:52, Fred van Stappen wrote:
 .
 .
> First download the source here :
>
>>> https://sites.google.com/site/fiensprototyping/uoslibtest.tar.gz
>
> Unzip it and in /uoslibtest/src :
>
> 1) Compile uoslib.pas (or uoslib.lpi) => it will create uos.dll in /src.
 .
 .

It might be better to mention the necessary compiler options (-Mobjfpc
-Sh) or even better include them directly in the respective sources.

In addition, compiling "uoslib.pas" results in "uoslib.dll", whereas you
try to load uos.dll from libconsoleplay.pas.

GDB gives the following backtrace:

0x10002950 in SYSTEM_CPUINCLOCKED$LONGINT () from D:\TEMP\T\src\uoslib.dll
(gdb) bt
#0  0x10002950 in SYSTEM_CPUINCLOCKED$LONGINT () from
D:\TEMP\T\src\uoslib.dll
#1  0x10005195 in fpc_ansistr_incr_ref () from D:\TEMP\T\src\uoslib.dll
#2  0x10001577 in UOS_LOADLIB (
    PORTAUDIOFILENAME=0x10001560
'U'#137'ĺ'#131'ě8'#137'Eü'#137'Uř'#137'Mô'#139'Eüčů;',
    SNDFILEFILENAME=0x10000000 'MZ'#144, MPG123FILENAME=0x10000000 'MZ'#144,
    SOUNDTOUCHFILENAME=0x90ae8
'D:\TEMP\T\src\lib\Windows\32bit\LibPortaudio-32.dll')
    at uoslib.pas:43
#3  0x0040d6b1 in UOS_LOADLIBS (UOSLIBFILENAME=0x68028
'D:\TEMP\T\src\uoslib.dll',
    PORTAUDIOFILENAME=0x90ae8
'D:\TEMP\T\src\lib\Windows\32bit\LibPortaudio-32.dll',
    SNDFILEFILENAME=0x90b28
'D:\TEMP\T\src\lib\Windows\32bit\LibSndFile-32.dll',
    MPG123FILENAME=0x0, SOUNDTOUCHFILENAME=0x0) at uoslib_h.pas:347
#4  0x00401670 in CONSOLEPLAY (this=0x98ab8) at libconsoleplay.pas:79
#5  0x00401864 in DORUN (this=0x98ab8) at libconsoleplay.pas:102
#6  0x004211f4 in CUSTAPP_TCUSTOMAPPLICATION_$__RUN ()
#7  0x00401a2f in main () at libconsoleplay.pas:127

It turns out that you missed to specify a matching calling convention for
uos_loadlib (you specified "cdecl" in uoslib_h, but not in uoslib). It
seems to work correctly after adding it at line 41 of uoslib.pas.

Tomas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

fredvs

> It might be better to mention the necessary compiler options (-Mobjfpc
> -Sh) or even better include them directly in the respective sources.
>
> In addition, compiling "uoslib.pas" results in "uoslib.dll", whereas you
> try to load uos.dll from libconsoleplay.pas.

Yep, sorry. But if you compile it from uoslib.lpi, it change uoslib.dll into uos.dll.
Also, compiling from uoslib.lpi include extrafpc.cfg, with required compiler options.


> It turns out that you missed to specify a matching calling convention for
> uos_loadlib (you specified "cdecl" in uoslib_h, but not in uoslib). It
> seems to work correctly after adding it at line 41 of uoslib.pas.

Houraaa, magnifique, marvellous, you find it.
Gigas of thanks, Tomas, you are my Hero.

Of course you get a big credit in the uoslib contributors.

Yep, it will be a good night for me...

Many, many thanks.

Fred.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

Tomas Hajny-2
On Tue, February 11, 2014 20:29, Fred van Stappen wrote:

>
>> It might be better to mention the necessary compiler options (-Mobjfpc
>> -Sh) or even better include them directly in the respective sources.
>>
>> In addition, compiling "uoslib.pas" results in "uoslib.dll", whereas you
>> try to load uos.dll from libconsoleplay.pas.
>
> Yep, sorry. But if you compile it from uoslib.lpi, it change uoslib.dll
> into uos.dll.
> Also, compiling from uoslib.lpi include extrafpc.cfg, with required
> compiler options.

I don't use Lazarus, i.e. .lpi files are of no use for me. The option
-fPIC isn't necessary for the Win32 target, i.e. I didn't miss that one
(but I was aware of it - at least it was well visible unlike the others
which I had to find by trial and error).


>> It turns out that you missed to specify a matching calling convention
>> for
>> uos_loadlib (you specified "cdecl" in uoslib_h, but not in uoslib). It
>> seems to work correctly after adding it at line 41 of uoslib.pas.
>
> Houraaa, magnifique, marvellous, you find it.
> Gigas of thanks, Tomas, you are my Hero.
>
> Of course you get a big credit in the uoslib contributors.

You're welcome, it wasn't that difficult after all. :-)

Tomas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

fredvs
> I don't use Lazarus, i.e. .lpi files are of no use for me. The option
> -fPIC isn't necessary for the Win32 target, i.e. I didn't miss that one
> (but I was aware of it - at least it was well visible unlike the others
> which I had to find by trial and error).

Ok and thanks to note it. Hum, i have adapted all the uos-unit-examples  for uoslib.

The good news :

All pure fpc programs and graphical using fpGUI are working perfectly.
The programs dealing with uoslib can access uoslib procedures and result of functions.
Perfect, perfect, perfect...
PS : I do not try yet  to access the uoslib from foreign language (C, Cnet, Java,...).
PS2 : Little bemol, (but i think i ask to much for the library here), the library cannot synchronize procedure of object from the program.

The bad news :

All programs using LCL (Lazarus widgetset) crash after thread.terminate inside the library...
I dont know why, it is the same code and the same library.
Maybe i have to do something but i dont know what.
Using directly the uos unit, without using the library, is ok for LCL.

> >> It turns out that you missed to specify a matching calling convention
> >> for
> >> uos_loadlib (you specified "cdecl" in uoslib_h, but not in uoslib). It
> >> seems to work correctly after adding it at line 41 of uoslib.pas.

Aaarg, it was at the first procedure, i read and re-read the code thousand times and dont see it... Many thanks to have better eyes than mine... ;-)

> You're welcome, it wasn't that difficult after all. :-)

Maybe for you, but for me, i became crazy...

Re-thanks.

Fred


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

fredvs

>The bad news :

>All programs using LCL (Lazarus widgetset) crash after thread.terminate >inside the library...
>I dont know why, it is the same code and the same library.
>Maybe i have to do something but i dont know what.
>Using directly the uos unit, without using the library, is ok for LCL.

Ye, today good news for LCL.
I find the guilty. It is => cmem !
I used cmem in all LCL example and fp libraries do not like cmem...

PS: I will do a other topic to note it...

Conclusion : everything is working perfectly.

Thank you fpc...

Fred

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

fredvs
Hello everybody.

I am extremely happy to announce the birth of the universal uos library version 1.0.

uos (United Open-libraries of Sound) unifies the best open-source audio libraries.

With uos you can:

. Listen to mp3, ogg, wav, flac,... audio files.
. With 16, 32 or float 32 bit resolution.
. Record all types of input into file.
. Add DSP effects and filters, however many you want and record it.
. Listen to multiple inputs and outputs.

uos uses the SoundTouch, PortAudio, SndFile and Mpg123 audio libraries.

You may download the source here :
>> https://github.com/fredvs/uoslib

Here compiled examples :
>> https://sites.google.com/site/biotray/uoslib_sandro.zip

PS : Till now, there is only a Pascal header but, because uoslib is universal,  other headers for foreign languages (C, CNet, Java,...) are super-welcome.

Fred.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

Michael Schnell
On 02/25/2014 02:58 PM, Fred van Stappen wrote:

I am extremely happy to announce the birth of the universal uos library version 1.0.

uos (United Open-libraries of Sound) unifies the best open-source audio libraries.

GREAT !!!!

Any documentation to make this usable ?

-Michael

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

fredvs

> GREAT !!!!
> Any documentation to make this usable ?
> -Michael

All the examples have lot of explanations. ;-)

There is also a wiki for uos : >> http://wiki.lazarus.freepascal.org/uos

The only things to change for uoslib are:

In uses section, add uoslib_h in place of uos.

And to load libraries :
For uos library :
uos_LoadLibs(uoslibFilename, PortAudioFileName, SndFileFileName, Mpg123FileName, SoundTouchFileName);

in place of (for uos unit) :
uos_LoadLib(PortAudioFileName, SndFileFileName, Mpg123FileName, SoundTouchFileName);

Thanks.

Fred.

PS : I will do a wiki for uoslib too.





_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

Michael Schnell
On 02/26/2014 12:17 PM, Fred van Stappen wrote:

There is also a wiki for uos : >> http://wiki.lazarus.freepascal.org/uos
Looks nice.

I wonder if uos would allow for this use of DSP-Effects:

 - read a wav file and output it to a new wav file ("playing" it is not necessary/sensible here)
 - on the fly "insert" a DSP effect (i.e. run the samples through an effect processor)
 - the parameter(s) of the effect should be changed on the fly (with each sample)

 - in this case the DSP effect should be a low pass filter
 - the edge-frequency of the filter should be modified under control of the user program.

-Michael



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

fredvs
In reply to this post by fredvs
>> PS : I will do a wiki for uoslib too.

OK, updated >> http://wiki.lazarus.freepascal.org/uos

PS : I think that the code of the examples in  /fpc_examples from
>> https://github.com/fredvs/uoslib
are more self-explained...

Thanks.

Fred.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: fp universal library ?

fredvs
In reply to this post by Michael Schnell
 
>> I wonder if uos would allow for this use of DSP-Effects:
  >>- read a wav file and output it to a new wav file ("playing" it is not necessary/sensible here)
>>on the fly "insert" a DSP effect (i.e. run the samples through an effect processor)
>> the parameter(s) of the effect should be changed on the fly (with each sample)
 >> in this case the DSP effect should be a low pass filter
  >> the edge-frequency of the filter should be modified under control of the user program.

Hum, it seems to me that all that can already be done by uos.
For uoslib, the difficult thing is to find a "universal" way to parse parameters for custom dsp.
It is absolutely not impossible but i want to find a simple "look" for custom dsp.

But for filters or bild-in DSP, it works (have you try FilterPlayer, SimplePlayer and SimpleRecorder examples ?)

Thanks.

Fred.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
12