Sign in Join
Wiki copytemporary

uos: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: uos

OldNewLine
1+![](/wiki-images/6/62/Uoslogo.png)
2+
3+**uos** (United OpenLib of Sound) is a multi-platform package of audio handling routines that unifies the best open-source audio libraries.
4+
5+# Features
6+
7+- play .mp3, .ogg, .wav, .flac, .m4a, .opus and cdrom audio files.
8+- 16, 32 or float 32 bit resolution
9+- record all types of input into file, in 16 or 32 bit resolution, mono or stereo.
10+- add DSP effects and filters, however many you want and record it.
11+- play multiple inputs and outputs simultaneously
12+- internet audio streaming of mp3 and opus files.
13+- produce sound by the build-in synthesizer.
14+
15+Uos can use the [[SoundTouch]], [[PortAudio]], [[SndFile]], [[Mpg123]], [[Faad]], [[OpusFile]] and [[Mp4ff]] audio libraries.
16+
17+Included in the package: Examples and binary libraries for Linux 32/64, arm aarch64 Raspberry Pi, Windows 32/64, macOS 32/64 and FreeBSD 32/64.
18+
19+# Download
20+
21+- <http://fredvs.github.io/uos/>
22+- <https://github.com/fredvs/uos/tree/main>
23+
24+# Forum
25+
26+- <http://uos-forum.108.s1.nabble.com>
27+
28+# uoslib
29+
30+Pascal users should use uos instead.
31+
32+**uoslib** is the Universal Library version of **uos** unit and is accessible from Pascal and all other languages (C, Java, ...).
33+
34+Some methods of uos are not accessible.
35+
36+Included in the package: Examples and binary libraries for Linux 32/64, Windows 32/64, macOS 32/64 and FreeBSD 32/64.
37+
38+- <http://fredvs.github.io/uoslib/>
39+- <http://github.com/fredvs/uoslib/>
40+
41+# Install
42+
43+The best way to show how uos works is to look at the examples in /uos/examples package. All is included, you only have to compile the demos and run it...
44+
45+Here some examples how to use uos :
46+
47+- Copy all the files in /uos/src/ into the directory of your project.
48+- add *uos_flat* or *uos* in your uses section. (for uoslib add *uoslib_h*)
49+ - *uos_flat* =\> All is done by the unit. The procedures are more "universal", same syntax as uoslib.
50+ - *uos* =\> The application must declare uos class and variables. The procedures can be used as oop way.
51+- All the examples in uos packages use *uos_flat*. There is a example using only *uos* =\> SimplePlayer_noflat
52+
53+Those libraries can be used by uos:
54+
55+- PortAudio for dealing with audio devices of sound card,
56+- SndFile for decoding wav, flac, org audio files,
57+- Mpg123 for decoding mp3 audio files,
58+- Faad and Mp4ff for decoding m4a audio files,
59+- OpusFile for decoding opus audio files,
60+- SoundTouch plugin for changing tempo of any type of audio files,
61+- bs2b plugin to apply stereo to binaural effect.
62+
63+You may load those libraries with:
64+
65+`uos_LoadLib( pchar(PortAudioFileName), pchar(SndFileFileName), pchar(Mpg123FileName),  pchar(Mp4ffFileName), pchar(FaadFileName), pchar(OpusFileFileName) );`
66+
67+If some libraries are not needed, just replace the filename with "nil".
68+
69+If you replace the filename with pchar('system'), the library of the system will be used (if exists).
70+
71+WARNING: Do not forget to call **uos_free()** when application terminates.
72+
73+Play a file 'MySong.mp3':
74+
75+``` pascal
76+begin
77+ uos_LoadLib( PortAudioFileName, nil, Mpg123FileName, nil, nil, nil); // only PortAudio and Mpg123 are needed.
78+ uos_CreatePlayer( 0 ); // you may create how many players you want, from 0 to to what you computer can do...
79+ uos_AddIntoDevOut( 0 ); // Add Output with default parameters
80+ uos_AddFromFile( 0, 'MySong.mp3' ); // Input from audio file
81+ // And let's play it...
82+ uos_Play(0); // Play the song...
83+end;
84+...
85+uos_free; // Call this at end of application.
86+```
87+
88+Play a sound file with some dsp effects (only for uos, in future for uoslib too):
89+
90+``` pascal
91+begin
92+ uos_LoadLib( pchar(PortAudioFileName), nil, pchar(Mpg123FileName), nil, nil, nil); // only PortAudio and Mpg123 are needed.
93+ uos_CreatePlayer( 0 ); // First create the player:
94+ uos_AddIntoDevOut( 0 ); // Add Output with default parameters
95+ uos_AddFromFile( 0, 'MySong.mp3' ); // Input from audio file
96+ uos_InputAddDSP( 0, 1 ); // Add as many dsp effects you want
97+ uos_InputAddDSP( 0, 2 );
98+ uos_Play( 0 ); // Play the song with DSP effect...
99+end;
100+...
101+uos_free; // Call this at end of application.
102+```
103+
104+Listen to your mic into your loudspeakers (for uoslib too) :
105+
106+``` pascal
107+begin
108+ uos_LoadLib( pchar(PortAudioFileName), nil, nil, nil, nil, nil); // only PortAudio is needed.
109+ uos_CreatePlayer( 0 );
110+ uos_AddIntoDevOut( 0 );
111+ uos_AddFromDevIn( 0 ); // Input from IN Device
112+ uos_Play( 0 ); // Listen to your mic in your loudspeakers...
113+end;
114+...
115+uos_free; // Call this at end of application.
116+```
117+
118+Now, listen to your mic, listen to a mp3, apply some effects and record the mic into wav file at same time:
119+
120+``` pascal
121+begin
122+ uos_LoadLib( pchar(PortAudioFileName), pchar(SndFileFileName), pchar(Mpg123FileName), nil, nil, nil);
123+ uos_CreatePlayer( 0 );
124+ uos_AddIntoDevOut( 0 ) ; // Output into OUT Device
125+ uos_AddIntoFile( 0, 'Myrecord.wav' ); // Output into wav file
126+ uos_AddFromDevIn( 0 ); // Input from IN Device
127+ uos_InputAddDSP( 0, 1 ); // Add as many dsp's you want
128+ uos_InputAddDSP( 0, 2 );
129+ uos_CreatePlayer( 1 );
130+ uos_AddFromFile( 1, 'MySong.mp3' ); // the background audio file
131+ uos_AddIntoDevOut( 1 ) ; // Output into OUT1 Device;
132+
133+ uos_Play(0); // Listen your mic with DSP effects and record it ...
134+ uos_Play(1); // Listen to mp3 while recording
135+end;
136+...
137+uos_free; // Call this at end of application.
138+```
139+
140+# Syntax
141+
142+Here are the basic uos methods. Each method has its equivalent with arguments for custom parameters.
143+
144+Initialization methods:
145+
146+`uos_LoadLib( );              // Load dynamic libraries for uos  `\
147+`uos_LoadLibs( );             // Load dynamic libraries for uoslibs`\
148+`uos_UnLoadLib();             // To unload libraries.`\
149+`uos_Free;                    // To use when application terminate.`
150+
151+Output
152+
153+`uos_AddIntoDevOut();         // Output into OUT Device`\
154+`uos_AddIntoFile();           // Output into Wav File`\
155+`uos_AddIntoMemoryBuffer()    // Add a Output into memory buffer`\
156+`uos_AddIntoMemoryStream()    // Add a Output into memory stream`\
157+`uos_AddIntoIceServer()       // Add a Output into a IceCast server`\
158+`uos_AddIntoFileFromMem()     // Add a Output into audio wav file from TMemoryStream`
159+
160+Input
161+
162+`uos_AddFromDevIn();          // Input from IN device`\
163+`uos_AddFromFile();           // Input from Audio File`\
164+`uos_AddFromMemoryBuffer();   // Input from decoded pcm buffer`\
165+`uos_AddFromMemoryStream();   // Input from a TMemoryStream of Audio File`\
166+`uos_AddFromFileIntoMemory(); // Input from audio file and stored into memory buffer`\
167+`uos_AddFromURL();            // Input from internet URL mp3/opus files`\
168+`uos_AddFromSynth(;           // Input form built-in Synthesizer`\
169+`uos_InputLength();           // Length of Input in samples`\
170+`uos_InputPosition();         // Get position`\
171+`uos_InputSeek();             // Change position in byte`\
172+`uos_InputSeekTime();         // Change position in time`\
173+`uos_InputSeekSeconds();      // Change position in second`
174+
175+Player
176+
177+`uos_Play();                  // Start playing`\
178+`uos_PlayPaused();            // Start playing paused.`\
179+`uos_PlayNoFree();            // Start playing but do not free the player after stop.`\
180+`uos_PlayPausedNoFree();      // Start playing paused but do not free the player after stop.`\
181+`uos_RePlay();                // Resume playing after pause`\
182+`uos_Stop();                  // Stop playing and free thread`\
183+`uos_Pause();                 // Pause playing`\
184+`uos_FreePlayer();            // Free the player. Works only when PlayNoFree() was used.`
185+
186+DSP
187+
188+`uos_InputAddDSP()            // DSP procedure for input`\
189+`uos_OutputAddDSP()           // DSP procedure for output`\
190+`uos_InputSetDSP()            // Set DSP In`\
191+`uos_OutputSetDSP()           // Set DSP out`\
192+`uos_InputSetDSPVolume(...)   // Set Volume`\
193+`uos_InputAddFilter(...)      // Add filer`\
194+`uos_AddPlugin(...)           // Add pluggin`
195+
196+And much more other procedures/functions (see in uos.pas...)
197+
198+---
199+*From the Free Pascal wiki, page "uos", as it stood on 2021-08-08 after a change by Fredvs, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
200+Category: Audio
201+Category: Lazarus
202+Category: Libraries

Back to history