Recent

Author Topic: What am i missing when installing UOS  (Read 9546 times)

Bas

  • New Member
  • *
  • Posts: 16
What am i missing when installing UOS
« on: June 21, 2020, 01:02:35 am »
I installed UOS via package manager and the was looking for a small example. (I am a total newbie to UOS so probaly a very simple thing i'm missing)

I tried below code but then get the error : identifier not found uos_Loadlib. What am i missing ? Already tried adding uos to uses and also googled but cant find the solution.

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private

  public

  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  begin
    uos_LoadLib( pchar(PortAudioFileName), nil, nil, nil, nil, nil); // only PortAudio is needed.
    uos_CreatePlayer( 0 );
    uos_AddIntoDevOut( 0 );
    uos_AddFromDevIn( 0 );   // Input from IN Device
    uos_Play( 0 );           // Listen to your mic in your loudspeakers...
  end;
end;

end.
                   
     

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Re: What am i missing when installing UOS
« Reply #1 on: June 21, 2020, 01:56:51 am »
While I have no idea what UOS is, I think I can see your problem.

You have in your code several lines using something called uos_Loadlib but the compiler has no idea what it is.

Its probably a method declared in another unit, the one that provides the UOS thingy, and you need to add something to your uses statements that will cause the compiler to include it.

So, find out what the UOS unit is called (or try guessing, maybe its 'uos') and add a uses clause.  Its a good thing to keep it below the 'implementation' keyword if you can, a new line like this may do the trick.

Code: Pascal  [Select][+][-]
  1. uses uos;

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: What am i missing when installing UOS
« Reply #2 on: June 21, 2020, 03:49:12 am »
Hello.

Like dbannon explained, you should add uos_flat unit in the uses section.

Please, take a look at the examples in /uos/examples/.

If you use Lazarus, in menu Project-Open, choose demo /uos/examples/SimpleRecorder.lpi.
Compile and run it, it should work out of the box.

If you use only one button, your code should look something like this (but you may take a look at code of SimpleRecorder to tune the parameters) :

Code: Pascal  [Select][+][-]
  1. uses
  2. {$IFDEF UNIX}
  3.   cthreads,
  4.   cwstring, {$ENDIF}
  5.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, uos_flat;
  6.  
  7. type
  8.  
  9.   { TForm1 }
  10.  
  11.   TForm1 = class(TForm)
  12.     Button1: TButton;
  13.     procedure Button1Click(Sender: TObject);
  14.   private
  15.  
  16.   public
  17.  
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  PortAudioFileName : string;
  23.  
  24.  
  25. implementation
  26.  
  27. {$R *.lfm}
  28.  
  29. { TForm1 }
  30.  
  31. procedure TForm1.Button1Click(Sender: TObject);
  32. begin
  33.   begin
  34.     PortAudioFileName := '/the/directory/of/PortAudio.dll(so)';
  35.     uos_LoadLib( pchar(PortAudioFileName), nil, nil, nil, nil, nil); // only PortAudio is needed.
  36.     uos_CreatePlayer( 0 );
  37.     uos_AddIntoDevOut( 0 );
  38.     uos_AddFromDevIn( 0 );   // Input from IN Device
  39.     uos_Play( 0 );           // Listen to your mic in your loudspeakers...
  40.     sleep(3000); // wait 3 seconds of direct wiring.
  41.     uos_Stop( 0 );  
  42.     uos_free;   // to free all libraries
  43.   end;
  44. end;
  45.  
  46. end.
« Last Edit: June 25, 2020, 01:35:29 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Bas

  • New Member
  • *
  • Posts: 16
Re: What am i missing when installing UOS
« Reply #3 on: June 21, 2020, 12:10:42 pm »
I tried the uses uos and uses uos_flat but it cant find the inludes. So i started looking for where the packagemanager installed UOS and that apparently is in C:\Users\username\AppData\Local\lazarus\onlinepackagemanager\packages\uos. I tried an example and that works. But if i then look at the code, it refers to the files like below. Do i have to put this  in my code every time or can i just drop the dll's in the windows directory ? Also do have to copy all the .pas files like uos_flat in my project directory ? Works a bit different as all other packages i installed in Lazarus before.



 
Code: Pascal  [Select][+][-]
  1.  
  2.    ordir := IncludeTrailingBackslash(ExtractFilePath(ParamStr(0)));
  3.  
  4.  {$IFDEF Windows}
  5.      {$if defined(cpu64)}
  6.     PA_FileName := ordir + 'lib\Windows\64bit\LibPortaudio-64.dll';
  7.     SF_FileName := ordir + 'lib\Windows\64bit\LibSndFile-64.dll';
  8.     MP_FileName := ordir + 'lib\Windows\64bit\LibMpg123-64.dll';
  9.      {$else}
  10.     PA_FileName := ordir + 'lib\Windows\32bit\LibPortaudio-32.dll';
  11.     SF_FileName := ordir + 'lib\Windows\32bit\LibSndFile-32.dll';
  12.     MP_FileName := ordir + 'lib\Windows\32bit\LibMpg123-32.dll';
  13.      {$endif}
  14.     SoundFilename := ordir + 'sound\test.ogg';
  15.  {$ENDIF}
  16.  
  17.      {$if defined(cpu64) and defined(linux) }
  18.   SF_FileName := ordir + 'lib/Linux/64bit/LibSndFile-64.so';
  19.   PA_FileName := ordir + 'lib/Linux/64bit/LibPortaudio-64.so';
  20.    MP_FileName := ordir + 'lib/Linux/64bit/LibMpg123-64.so';
  21.     SoundFilename := ordir + 'sound/test.ogg';
  22.    {$ENDIF}
  23.    
  24.    {$if defined(cpu86) and defined(linux)}
  25.     PA_FileName := ordir + 'lib/Linux/32bit/LibPortaudio-32.so';
  26.     SF_FileName := ordir + 'lib/Linux/32bit/LibSndFile-32.so';
  27.      MP_FileName := ordir + 'lib/Linux/32bit/LibMpg123-32.so';
  28.    SoundFilename := ordir + 'sound/test.ogg';
  29.  {$ENDIF}
  30.  
  31.   {$if defined(linux) and defined(cpuarm)}
  32.     PA_FileName := ordir + 'lib/Linux/arm_raspberrypi/libportaudio-arm.so';
  33.     SF_FileName := ordir + 'lib/Linux/arm_raspberrypi/libsndfile-arm.so';
  34.      MP_FileName := ordir + 'lib/Linux/arm_raspberrypi/libmpg123-arm.so';
  35.       SoundFilename := ordir + 'sound/test.ogg';
  36.  {$ENDIF}
  37.  
  38.  {$IFDEF freebsd}
  39.     {$if defined(cpu64)}
  40.     PA_FileName := ordir + 'lib/FreeBSD/64bit/libportaudio-64.so';
  41.     SF_FileName := ordir + 'lib/FreeBSD/64bit/libsndfile-64.so';
  42.      MP_FileName := ordir + 'lib/FreeBSD/64bit/libmpg123-64.so';
  43.     {$else}
  44.     PA_FileName := ordir + 'lib/FreeBSD/32bit/libportaudio-32.so';
  45.     SF_FileName := ordir + 'lib/FreeBSD/32bit/libsndfile-32.so';
  46.       MP_FileName := ordir + 'lib/FreeBSD/32bit/libmpg123-32.so';
  47.     {$endif}
  48.     SoundFilename := ordir + 'sound/test.ogg';
  49.  {$ENDIF}
  50.  
  51.  {$IFDEF Darwin}
  52.     opath := ordir;
  53.     opath := copy(opath, 1, Pos('/UOS', opath) - 1);
  54.     PA_FileName := opath + '/lib/Mac/32bit/LibPortaudio-32.dylib';
  55.     SF_FileName := opath + '/lib/Mac/32bit/LibSndFile-32.dylib';
  56.      MP_FileName := ordir + 'lib/Mac/32bit/LibMpg123-32.dylib';
  57.     SoundFilename := opath + '/sound/test.ogg';
  58.  {$ENDIF}    
  59.  
  60.        FileNameEdit1.FileName:= SoundFilename;
  61.  
  62.      res := uos_LoadLib(Pchar(PA_FileName), Pchar(SF_FileName), pchar(MP_FileName), nil, nil, nil) ;
  63.   If Res<>0 Then                            
                                                       

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: What am i missing when installing UOS
« Reply #4 on: June 21, 2020, 04:38:28 pm »
Quote
Do i have to put this  in my code every time or can i just drop the dll's in the windows directory ?

You need to assign the path-filename of the libraries you will need, for example at initialization of the program.
If you put dll's in the windows directory, you can use pchar('system') as  path-filename of the library.

[EDIT] uos uses dynamic loading of library.
This has the advantage that you may choose the directory where to store the libraries, not only in Windows/system.
Also you may load-unload the libraries when you want.

Quote
Also do have to copy all the .pas files like uos_flat in my project directory ?

Yes, all the uos_***.pas files that you project will need, depend of what library you will use.

« Last Edit: June 21, 2020, 07:56:59 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Bas

  • New Member
  • *
  • Posts: 16
Re: What am i missing when installing UOS
« Reply #5 on: June 22, 2020, 06:24:51 am »
I'm getting closer but now getting another error. For now i dropped all the pas and dll's in my project directory. I'm trying to get the spectrum analyzer working in my own software. If i try to run it now i get an error in uos_flat : identifier not found "Tuos_Data". I think i probably forgot to copy a file but not a clue which one.

this is the code thats giving errors :

Code: Pascal  [Select][+][-]
  1.   type
  2.   TuosF_Data = Tuos_Data;
  3.   TuosF_FFT = Tuos_FFT ;
  4.   TuosF_BufferInfos = Tuos_BufferInfos;
  5.  

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: What am i missing when installing UOS
« Reply #6 on: June 22, 2020, 03:01:51 pm »
Hello.

You dont give lot of info!

Quote
this is the code thats giving errors :

That code seems to come from "uos_flat".

Did you add "uos.pas" too in the directory of your project?
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Bas

  • New Member
  • *
  • Posts: 16
Re: What am i missing when installing UOS
« Reply #7 on: June 24, 2020, 11:27:46 pm »
It was indeed as I wrote in UOS_flat. I removed everything and copied all files again and now it is working firne. In which file are those Tuos types defined ?

Regards,

Bas

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: What am i missing when installing UOS
« Reply #8 on: June 25, 2020, 12:56:27 am »
It was indeed as I wrote in UOS_flat. I removed everything and copied all files again and now it is working firne.

Ha, nice, I am happy that it works now.

In which file are those Tuos types defined ?

It is in uos.pas.

The most easy is to copy all the files that are in /uos/src/ into your project directory.

If you prefer use a custom directory for the uos source, use the fpc parameter:
 
Code: Pascal  [Select][+][-]
  1. -Fu/the/directory/of/uos/src

You may also tune define.inc and enable/disable the units needed at compilation, this according of what was used in your project:

Code: Pascal  [Select][+][-]
  1. {.$DEFINE debug} // uncomment for debugging. For console and Unix applications only.
  2.  
  3. {.$DEFINE consoleapp} // if FPC version < 2.7.1 uncomment for console application
  4. {.$DEFINE library}   // uncomment for building uos library (native and java)
  5. {.$DEFINE java}   // uncomment for building uos java library
  6. {.$DEFINE fpgui}   // uncomment if FPC version < 2.7.1 and using fpGUI widget
  7. {.$DEFINE mse}   // uncomment when using a mse project, use mse mseThread in place of fpc TThread.
  8. {$DEFINE portaudio} // uncomment to enable portaudio In/Out sound port
  9. {$DEFINE sndfile} // uncomment to enable sndfile (wav, ogg, flac audio file)
  10. {$DEFINE mpg123} // uncomment to enable mpg123 (mp3 audio file)
  11. {$DEFINE neaac} // uncomment to enable neaac (m4a audio file)
  12. {$DEFINE opus} // uncomment to enable opus (opus audio file)
  13. {.$DEFINE cdrom} // uncomment to enable cdrom audio decoder (cda)
  14. {$DEFINE soundtouch} // uncomment to enable Soundtouch tempo plugin
  15. {$DEFINE bs2b} // uncomment to enable bs2b stereo to binaural plugin
  16. {$DEFINE webstream} // uncomment to enable Internet Audio Streaming
  17. {.$DEFINE shout} // uncomment to enable IceCast-Shout audio web server.
  18. {$DEFINE noiseremoval} // uncomment to enable Noise Removal DSP
  19. {$DEFINE synthesizer} // uncomment to enable Synthesizer

Fre;D
« Last Edit: June 25, 2020, 05:33:01 am by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

funlw65

  • Full Member
  • ***
  • Posts: 149
    • Visual Pin Configurator for Nucleo 64pin boards
Re: What am i missing when installing UOS
« Reply #9 on: September 13, 2021, 04:25:50 pm »
It was indeed as I wrote in UOS_flat. I removed everything and copied all files again and now it is working firne. In which file are those Tuos types defined ?

Regards,

Bas

Because, at a moment in time - don't know when - this happens with the uos unit.:

Code: Pascal  [Select][+][-]
  1. { This file was automatically created by Lazarus. Do not edit!
  2.   This source is only used to compile and install the package.
  3.  }
  4. unit uos;
  5.  
  6.  
  7. {$warn 5023 off : no warning about unused units}
  8. interface
  9.  
  10. implementation
  11.          

So, Tuos_Data is nowhere to be found, even if uos unit is included.



Fred, I installed your uos package from the online package manager and then tried to install BGRAGames and it trows errors regarding not finding functions in uos_flat, even if that unit is already included. The compiler says that it cannot find that unit.

uos is the only package I have problems with, from the online package manager. I think the way you designed it, it trows a lot of problems.

Do a clean install of linux on another computer, install lazarus + fpc and try to install your package uos then the BGRAGames to see that there are problems. You have to do this, as you simulate the situation a new user is in.
FreePascal 3.2.2, C 10.2.1, D 1.24 under Linux(init,musl,glibc), DragonflyBSD, NetBSD
gui: gtk2, qt5, raylib4.x+raygui3.x, nanovg 
tui: freevision, tvision2, termbox2+widgets, finalcut
db: typhoon-1.11...

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: What am i missing when installing UOS
« Reply #10 on: September 13, 2021, 05:06:37 pm »
Because, at a moment in time - don't know when - this happens with the uos unit.:

Code: Pascal  [Select][+][-]
  1. { This file was automatically created by Lazarus. Do not edit!
  2.   This source is only used to compile and install the package.
  3.  }
  4. unit uos;
  5.  
  6.  
  7. {$warn 5023 off : no warning about unused units}
  8. interface
  9.  
  10. implementation
  11.          


Hello @funlw65

Hum, what is that?

It is not the orginal uos.pas
Code: Pascal  [Select][+][-]
  1. {This unit is part of United Openlibraries of Sound (uos)
  2.   This is the main uos unit.
  3.   License : modified LGPL.3
  4.   Fred van Stappen fiens@hotmail.com }
  5.  
  6. unit uos;
  7.  
  8. {$mode objfpc}{$H+}
  9. {$PACKRECORDS C}
  10.  
  11. // For custom configuration of directive to compiler --->  define.inc
  12. {$I define.inc}
  13.  
  14. interface
  15.  
  16. uses
  17.  

I dont know what goes with the opm version.

Maybe use the version from github, just clic on the green download button unzip it and test the demos.

Quote
Quote
Do a clean install of linux on another computer, install lazarus + fpc and try to install your package uos then the BGRAGames to see that there are problems. You have to do this, as you simulate the situation a new user is in.

I dont know well LCL but in the uos demos there are LCL-Lazarus projects and it works ok.

I use also BGRAbitmap + uos in some apps without problems.

Fre;D


I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: What am i missing when installing UOS
« Reply #11 on: September 13, 2021, 05:39:57 pm »
uos is the only package I have problems with, from the online package manager. I think the way you designed it, it trows a lot of problems.

I did not do the opm package.

And my pc is out of work to test it now.

But uos is for console and other widgets too, so there are no gui widgets in Lazarus component panel.

I was thinking that adding the uos component only added some -Fu targeted to uos src and external libraries.

But it seems it is not the case.

Sorry but I really cannot test what the opm-uos version does at the moment.

Fre,D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

balazsszekely

  • Guest
Re: What am i missing when installing UOS
« Reply #12 on: September 13, 2021, 05:50:00 pm »
Hi Fred vS,

Quote
  I did not do the opm package.

And my pc is out of work to test it now.

But uos is for console and other widgets too, so there are no gui widgets in Lazarus component panel.

I was thinking that adding the uos component only added some -Fu targeted to uos src and external libraries.

But it seems it is not the case.

Sorry but I really cannot test what the opm-uos version does at the moment

I would never put anything else in OPM, then the original repo. Of course I will double check UOS when I get home, but looking at @funlw65 uos unit:
Code: Pascal  [Select][+][-]
  1.  { This file was automatically created by Lazarus. Do not edit!
  2.   This source is only used to compile and install the package.
  3.  }
  4.  
it looks like he accidentally created a new package, the message is auto-generated by the IDE.

Fred vS

  • Hero Member
  • *****
  • Posts: 3736
    • StrumPract is the musicians best friend
Re: What am i missing when installing UOS
« Reply #13 on: September 13, 2021, 06:12:24 pm »
Hi Fred vS,
I would never put anything else in OPM, then the original repo. Of course I will double check UOS when I get home, but looking at @funlw65 uos unit:
Code: Pascal  [Select][+][-]
  1.  { This file was automatically created by Lazarus. Do not edit!
  2.   This source is only used to compile and install the package.
  3.  }
  4.  
it looks like he accidentally created a new package, the message is auto-generated by the IDE.

Hello GetMem.

Maybe when someone create a project named "uos" Lazarus create a uos.pas file that does conflct with the uos.pas from src.

Anyway, to use uos just add in unit uses section :   uos_flat

And in project optons, -FU/source/of/uos

Nothing more is needed to begin a uos project.

Thanks GetMem for your attention.

Fre,D
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1290
Re: What am i missing when installing UOS
« Reply #14 on: September 13, 2021, 06:17:10 pm »
hello,
in bgragames package there are references to  uos files in a  bgragames folder  -> conflict with uos package ? i have had a similar problem with tlazserial et synaser -> i have renamed the synaser files in my tlazserial package.

friendly, J.P
« Last Edit: September 13, 2021, 06:20:29 pm by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

 

TinyPortal © 2005-2018