Recent

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

Bas

  • New member
  • *
  • Posts: 8
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: 1106
    • 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 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

Fred vS

  • Hero Member
  • *****
  • Posts: 1779
    • 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.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Bas

  • New member
  • *
  • Posts: 8
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: 1779
    • 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.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Bas

  • New member
  • *
  • Posts: 8
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: 1779
    • 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.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Bas

  • New member
  • *
  • Posts: 8
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: 1779
    • 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.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

 

TinyPortal © 2005-2018