Sign in Join
Wiki copytemporary

uos: what changed

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

OldNewLine
11![](/wiki-images/6/62/Uoslogo.png)
22
33**uos** (United OpenLib of Sound) is a multi-platform package of audio handling routines that unifies the best open-source audio libraries.
44
55# Features
66
77- play .mp3, .ogg, .wav, .flac, .m4a, .opus and cdrom audio files.
88- 16, 32 or float 32 bit resolution
99- record all types of input into file, in 16 or 32 bit resolution, mono or stereo.
1010- add DSP effects and filters, however many you want and record it.
1111- play multiple inputs and outputs simultaneously
1212- internet audio streaming of mp3 and opus files.
1313- produce sound by the build-in synthesizer.
1414
1515Uos can use the [[SoundTouch]], [[PortAudio]], [[SndFile]], [[Mpg123]], [[Faad]], [[OpusFile]] and [[Mp4ff]] audio libraries.
1616
1717Included 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.
1818
1919# Download
2020
2121- <http://fredvs.github.io/uos/>
2222- <https://github.com/fredvs/uos/tree/main>
2323
2424# Forum
2525
2626- <http://uos-forum.108.s1.nabble.com>
2727
2828# uoslib
2929
3030Pascal users should use uos instead.
3131
3232**uoslib** is the Universal Library version of **uos** unit and is accessible from Pascal and all other languages (C, Java, ...).
3333
3434Some methods of uos are not accessible.
3535
3636Included in the package: Examples and binary libraries for Linux 32/64, Windows 32/64, macOS 32/64 and FreeBSD 32/64.
3737
3838- <http://fredvs.github.io/uoslib/>
3939- <http://github.com/fredvs/uoslib/>
4040
4141# Install
4242
4343The 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...
4444
4545Here some examples how to use uos :
4646
4747- Copy all the files in /uos/src/ into the directory of your project.
4848- add *uos_flat* or *uos* in your uses section. (for uoslib add *uoslib_h*)
4949 - *uos_flat* =\> All is done by the unit. The procedures are more "universal", same syntax as uoslib.
5050 - *uos* =\> The application must declare uos class and variables. The procedures can be used as oop way.
5151- All the examples in uos packages use *uos_flat*. There is a example using only *uos* =\> SimplePlayer_noflat
5252
5353Those libraries can be used by uos:
5454
5555- PortAudio for dealing with audio devices of sound card,
5656- SndFile for decoding wav, flac, org audio files,
5757- Mpg123 for decoding mp3 audio files,
5858- Faad and Mp4ff for decoding m4a audio files,
5959- OpusFile for decoding opus audio files,
6060- SoundTouch plugin for changing tempo of any type of audio files,
6161- bs2b plugin to apply stereo to binaural effect.
6262
6363You may load those libraries with:
6464
65-`uos_LoadLib( pchar(PortAudioFileName), pchar(SndFileFileName), pchar(Mpg123FileName),  pchar(Mp4ffFileName), pchar(FaadFileName), pchar(OpusFileFileName) );`
65+```text
66+uos_LoadLib( pchar(PortAudioFileName), pchar(SndFileFileName), pchar(Mpg123FileName), pchar(Mp4ffFileName), pchar(FaadFileName), pchar(OpusFileFileName) );
67+```
6668
6769If some libraries are not needed, just replace the filename with "nil".
6870
6971If you replace the filename with pchar('system'), the library of the system will be used (if exists).
7072
7173WARNING: Do not forget to call **uos_free()** when application terminates.
7274
7375Play a file 'MySong.mp3':
7476
7577``` pascal
7678begin
7779 uos_LoadLib( PortAudioFileName, nil, Mpg123FileName, nil, nil, nil); // only PortAudio and Mpg123 are needed.
7880 uos_CreatePlayer( 0 ); // you may create how many players you want, from 0 to to what you computer can do...
7981 uos_AddIntoDevOut( 0 ); // Add Output with default parameters
8082 uos_AddFromFile( 0, 'MySong.mp3' ); // Input from audio file
8183 // And let's play it...
8284 uos_Play(0); // Play the song...
8385end;
8486...
8587uos_free; // Call this at end of application.
8688```
8789
8890Play a sound file with some dsp effects (only for uos, in future for uoslib too):
8991
9092``` pascal
9193begin
9294 uos_LoadLib( pchar(PortAudioFileName), nil, pchar(Mpg123FileName), nil, nil, nil); // only PortAudio and Mpg123 are needed.
9395 uos_CreatePlayer( 0 ); // First create the player:
9496 uos_AddIntoDevOut( 0 ); // Add Output with default parameters
9597 uos_AddFromFile( 0, 'MySong.mp3' ); // Input from audio file
9698 uos_InputAddDSP( 0, 1 ); // Add as many dsp effects you want
9799 uos_InputAddDSP( 0, 2 );
98100 uos_Play( 0 ); // Play the song with DSP effect...
99101end;
100102...
101103uos_free; // Call this at end of application.
102104```
103105
104106Listen to your mic into your loudspeakers (for uoslib too) :
105107
106108``` pascal
107109begin
108110 uos_LoadLib( pchar(PortAudioFileName), nil, nil, nil, nil, nil); // only PortAudio is needed.
109111 uos_CreatePlayer( 0 );
110112 uos_AddIntoDevOut( 0 );
111113 uos_AddFromDevIn( 0 ); // Input from IN Device
112114 uos_Play( 0 ); // Listen to your mic in your loudspeakers...
113115end;
114116...
115117uos_free; // Call this at end of application.
116118```
117119
118120Now, listen to your mic, listen to a mp3, apply some effects and record the mic into wav file at same time:
119121
120122``` pascal
121123begin
122124 uos_LoadLib( pchar(PortAudioFileName), pchar(SndFileFileName), pchar(Mpg123FileName), nil, nil, nil);
123125 uos_CreatePlayer( 0 );
124126 uos_AddIntoDevOut( 0 ) ; // Output into OUT Device
125127 uos_AddIntoFile( 0, 'Myrecord.wav' ); // Output into wav file
126128 uos_AddFromDevIn( 0 ); // Input from IN Device
127129 uos_InputAddDSP( 0, 1 ); // Add as many dsp's you want
128130 uos_InputAddDSP( 0, 2 );
129131 uos_CreatePlayer( 1 );
130132 uos_AddFromFile( 1, 'MySong.mp3' ); // the background audio file
131133 uos_AddIntoDevOut( 1 ) ; // Output into OUT1 Device;
132134
133135 uos_Play(0); // Listen your mic with DSP effects and record it ...
134136 uos_Play(1); // Listen to mp3 while recording
135137end;
136138...
137139uos_free; // Call this at end of application.
138140```
139141
140142# Syntax
141143
142144Here are the basic uos methods. Each method has its equivalent with arguments for custom parameters.
143145
144146Initialization methods:
145147
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.`
148+```text
149+uos_LoadLib( ); // Load dynamic libraries for uos
150+uos_LoadLibs( ); // Load dynamic libraries for uoslibs
151+uos_UnLoadLib(); // To unload libraries.
152+uos_Free; // To use when application terminate.
153+```
150154
151155Output
152156
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`
157+```text
158+uos_AddIntoDevOut(); // Output into OUT Device
159+uos_AddIntoFile(); // Output into Wav File
160+uos_AddIntoMemoryBuffer() // Add a Output into memory buffer
161+uos_AddIntoMemoryStream() // Add a Output into memory stream
162+uos_AddIntoIceServer() // Add a Output into a IceCast server
163+uos_AddIntoFileFromMem() // Add a Output into audio wav file from TMemoryStream
164+```
159165
160166Input
161167
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`
168+```text
169+uos_AddFromDevIn(); // Input from IN device
170+uos_AddFromFile(); // Input from Audio File
171+uos_AddFromMemoryBuffer(); // Input from decoded pcm buffer
172+uos_AddFromMemoryStream(); // Input from a TMemoryStream of Audio File
173+uos_AddFromFileIntoMemory(); // Input from audio file and stored into memory buffer
174+uos_AddFromURL(); // Input from internet URL mp3/opus files
175+uos_AddFromSynth(; // Input form built-in Synthesizer
176+uos_InputLength(); // Length of Input in samples
177+uos_InputPosition(); // Get position
178+uos_InputSeek(); // Change position in byte
179+uos_InputSeekTime(); // Change position in time
180+uos_InputSeekSeconds(); // Change position in second
181+```
174182
175183Player
176184
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+```text
186+uos_Play(); // Start playing
187+uos_PlayPaused(); // Start playing paused.
188+uos_PlayNoFree(); // Start playing but do not free the player after stop.
189+uos_PlayPausedNoFree(); // Start playing paused but do not free the player after stop.
190+uos_RePlay(); // Resume playing after pause
191+uos_Stop(); // Stop playing and free thread
192+uos_Pause(); // Pause playing
193+uos_FreePlayer(); // Free the player. Works only when PlayNoFree() was used.
194+```
185195
186196DSP
187197
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`
198+``` pascal
199+uos_InputAddDSP() // DSP procedure for input
200+uos_OutputAddDSP() // DSP procedure for output
201+uos_InputSetDSP() // Set DSP In
202+uos_OutputSetDSP() // Set DSP out
203+uos_InputSetDSPVolume(...) // Set Volume
204+uos_InputAddFilter(...) // Add filer
205+uos_AddPlugin(...) // Add pluggin
206+```
195207
196208And much more other procedures/functions (see in uos.pas...)
197209
198210---
199211*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).*
200212Category: Audio
201213Category: Lazarus
202214Category: Libraries

Back to history