uos: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 |  | |
| 2 | 2 | ||
| 3 | 3 | **uos** (United OpenLib of Sound) is a multi-platform package of audio handling routines that unifies the best open-source audio libraries. | |
| 4 | 4 | ||
| 5 | 5 | # Features | |
| 6 | 6 | ||
| 7 | 7 | - play .mp3, .ogg, .wav, .flac, .m4a, .opus and cdrom audio files. | |
| 8 | 8 | - 16, 32 or float 32 bit resolution | |
| 9 | 9 | - record all types of input into file, in 16 or 32 bit resolution, mono or stereo. | |
| 10 | 10 | - add DSP effects and filters, however many you want and record it. | |
| 11 | 11 | - play multiple inputs and outputs simultaneously | |
| 12 | 12 | - internet audio streaming of mp3 and opus files. | |
| 13 | 13 | - produce sound by the build-in synthesizer. | |
| 14 | 14 | ||
| 15 | 15 | Uos can use the [[SoundTouch]], [[PortAudio]], [[SndFile]], [[Mpg123]], [[Faad]], [[OpusFile]] and [[Mp4ff]] audio libraries. | |
| 16 | 16 | ||
| 17 | 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 | 18 | ||
| 19 | 19 | # Download | |
| 20 | 20 | ||
| 21 | 21 | - <http://fredvs.github.io/uos/> | |
| 22 | 22 | - <https://github.com/fredvs/uos/tree/main> | |
| 23 | 23 | ||
| 24 | 24 | # Forum | |
| 25 | 25 | ||
| 26 | 26 | - <http://uos-forum.108.s1.nabble.com> | |
| 27 | 27 | ||
| 28 | 28 | # uoslib | |
| 29 | 29 | ||
| 30 | 30 | Pascal users should use uos instead. | |
| 31 | 31 | ||
| 32 | 32 | **uoslib** is the Universal Library version of **uos** unit and is accessible from Pascal and all other languages (C, Java, ...). | |
| 33 | 33 | ||
| 34 | 34 | Some methods of uos are not accessible. | |
| 35 | 35 | ||
| 36 | 36 | Included in the package: Examples and binary libraries for Linux 32/64, Windows 32/64, macOS 32/64 and FreeBSD 32/64. | |
| 37 | 37 | ||
| 38 | 38 | - <http://fredvs.github.io/uoslib/> | |
| 39 | 39 | - <http://github.com/fredvs/uoslib/> | |
| 40 | 40 | ||
| 41 | 41 | # Install | |
| 42 | 42 | ||
| 43 | 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 | 44 | ||
| 45 | 45 | Here some examples how to use uos : | |
| 46 | 46 | ||
| 47 | 47 | - Copy all the files in /uos/src/ into the directory of your project. | |
| 48 | 48 | - add *uos_flat* or *uos* in your uses section. (for uoslib add *uoslib_h*) | |
| 49 | 49 | - *uos_flat* =\> All is done by the unit. The procedures are more "universal", same syntax as uoslib. | |
| 50 | 50 | - *uos* =\> The application must declare uos class and variables. The procedures can be used as oop way. | |
| 51 | 51 | - All the examples in uos packages use *uos_flat*. There is a example using only *uos* =\> SimplePlayer_noflat | |
| 52 | 52 | ||
| 53 | 53 | Those libraries can be used by uos: | |
| 54 | 54 | ||
| 55 | 55 | - PortAudio for dealing with audio devices of sound card, | |
| 56 | 56 | - SndFile for decoding wav, flac, org audio files, | |
| 57 | 57 | - Mpg123 for decoding mp3 audio files, | |
| 58 | 58 | - Faad and Mp4ff for decoding m4a audio files, | |
| 59 | 59 | - OpusFile for decoding opus audio files, | |
| 60 | 60 | - SoundTouch plugin for changing tempo of any type of audio files, | |
| 61 | 61 | - bs2b plugin to apply stereo to binaural effect. | |
| 62 | 62 | ||
| 63 | 63 | You may load those libraries with: | |
| 64 | 64 | ||
| 65 | - | ||
| 65 | + | ```text | |
| 66 | + | uos_LoadLib( pchar(PortAudioFileName), pchar(SndFileFileName), pchar(Mpg123FileName), pchar(Mp4ffFileName), pchar(FaadFileName), pchar(OpusFileFileName) ); | |
| 67 | + | ``` | |
| 66 | 68 | ||
| 67 | 69 | If some libraries are not needed, just replace the filename with "nil". | |
| 68 | 70 | ||
| 69 | 71 | If you replace the filename with pchar('system'), the library of the system will be used (if exists). | |
| 70 | 72 | ||
| 71 | 73 | WARNING: Do not forget to call **uos_free()** when application terminates. | |
| 72 | 74 | ||
| 73 | 75 | Play a file 'MySong.mp3': | |
| 74 | 76 | ||
| 75 | 77 | ``` pascal | |
| 76 | 78 | begin | |
| 77 | 79 | uos_LoadLib( PortAudioFileName, nil, Mpg123FileName, nil, nil, nil); // only PortAudio and Mpg123 are needed. | |
| 78 | 80 | uos_CreatePlayer( 0 ); // you may create how many players you want, from 0 to to what you computer can do... | |
| 79 | 81 | uos_AddIntoDevOut( 0 ); // Add Output with default parameters | |
| 80 | 82 | uos_AddFromFile( 0, 'MySong.mp3' ); // Input from audio file | |
| 81 | 83 | // And let's play it... | |
| 82 | 84 | uos_Play(0); // Play the song... | |
| 83 | 85 | end; | |
| 84 | 86 | ... | |
| 85 | 87 | uos_free; // Call this at end of application. | |
| 86 | 88 | ``` | |
| 87 | 89 | ||
| 88 | 90 | Play a sound file with some dsp effects (only for uos, in future for uoslib too): | |
| 89 | 91 | ||
| 90 | 92 | ``` pascal | |
| 91 | 93 | begin | |
| 92 | 94 | uos_LoadLib( pchar(PortAudioFileName), nil, pchar(Mpg123FileName), nil, nil, nil); // only PortAudio and Mpg123 are needed. | |
| 93 | 95 | uos_CreatePlayer( 0 ); // First create the player: | |
| 94 | 96 | uos_AddIntoDevOut( 0 ); // Add Output with default parameters | |
| 95 | 97 | uos_AddFromFile( 0, 'MySong.mp3' ); // Input from audio file | |
| 96 | 98 | uos_InputAddDSP( 0, 1 ); // Add as many dsp effects you want | |
| 97 | 99 | uos_InputAddDSP( 0, 2 ); | |
| 98 | 100 | uos_Play( 0 ); // Play the song with DSP effect... | |
| 99 | 101 | end; | |
| 100 | 102 | ... | |
| 101 | 103 | uos_free; // Call this at end of application. | |
| 102 | 104 | ``` | |
| 103 | 105 | ||
| 104 | 106 | Listen to your mic into your loudspeakers (for uoslib too) : | |
| 105 | 107 | ||
| 106 | 108 | ``` pascal | |
| 107 | 109 | begin | |
| 108 | 110 | uos_LoadLib( pchar(PortAudioFileName), nil, nil, nil, nil, nil); // only PortAudio is needed. | |
| 109 | 111 | uos_CreatePlayer( 0 ); | |
| 110 | 112 | uos_AddIntoDevOut( 0 ); | |
| 111 | 113 | uos_AddFromDevIn( 0 ); // Input from IN Device | |
| 112 | 114 | uos_Play( 0 ); // Listen to your mic in your loudspeakers... | |
| 113 | 115 | end; | |
| 114 | 116 | ... | |
| 115 | 117 | uos_free; // Call this at end of application. | |
| 116 | 118 | ``` | |
| 117 | 119 | ||
| 118 | 120 | Now, listen to your mic, listen to a mp3, apply some effects and record the mic into wav file at same time: | |
| 119 | 121 | ||
| 120 | 122 | ``` pascal | |
| 121 | 123 | begin | |
| 122 | 124 | uos_LoadLib( pchar(PortAudioFileName), pchar(SndFileFileName), pchar(Mpg123FileName), nil, nil, nil); | |
| 123 | 125 | uos_CreatePlayer( 0 ); | |
| 124 | 126 | uos_AddIntoDevOut( 0 ) ; // Output into OUT Device | |
| 125 | 127 | uos_AddIntoFile( 0, 'Myrecord.wav' ); // Output into wav file | |
| 126 | 128 | uos_AddFromDevIn( 0 ); // Input from IN Device | |
| 127 | 129 | uos_InputAddDSP( 0, 1 ); // Add as many dsp's you want | |
| 128 | 130 | uos_InputAddDSP( 0, 2 ); | |
| 129 | 131 | uos_CreatePlayer( 1 ); | |
| 130 | 132 | uos_AddFromFile( 1, 'MySong.mp3' ); // the background audio file | |
| 131 | 133 | uos_AddIntoDevOut( 1 ) ; // Output into OUT1 Device; | |
| 132 | 134 | ||
| 133 | 135 | uos_Play(0); // Listen your mic with DSP effects and record it ... | |
| 134 | 136 | uos_Play(1); // Listen to mp3 while recording | |
| 135 | 137 | end; | |
| 136 | 138 | ... | |
| 137 | 139 | uos_free; // Call this at end of application. | |
| 138 | 140 | ``` | |
| 139 | 141 | ||
| 140 | 142 | # Syntax | |
| 141 | 143 | ||
| 142 | 144 | Here are the basic uos methods. Each method has its equivalent with arguments for custom parameters. | |
| 143 | 145 | ||
| 144 | 146 | Initialization methods: | |
| 145 | 147 | ||
| 146 | - | ||
| 147 | - | ||
| 148 | - | ||
| 149 | - | ||
| 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 | + | ``` | |
| 150 | 154 | ||
| 151 | 155 | Output | |
| 152 | 156 | ||
| 153 | - | ||
| 154 | - | ||
| 155 | - | ||
| 156 | - | ||
| 157 | - | ||
| 158 | - | ||
| 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 | + | ``` | |
| 159 | 165 | ||
| 160 | 166 | Input | |
| 161 | 167 | ||
| 162 | - | ||
| 163 | - | ||
| 164 | - | ||
| 165 | - | ||
| 166 | - | ||
| 167 | - | ||
| 168 | - | ||
| 169 | - | ||
| 170 | - | ||
| 171 | - | ||
| 172 | - | ||
| 173 | - | ||
| 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 | + | ``` | |
| 174 | 182 | ||
| 175 | 183 | Player | |
| 176 | 184 | ||
| 177 | - | ||
| 178 | - | ||
| 179 | - | ||
| 180 | - | ||
| 181 | - | ||
| 182 | - | ||
| 183 | - | ||
| 184 | - | ||
| 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 | + | ``` | |
| 185 | 195 | ||
| 186 | 196 | DSP | |
| 187 | 197 | ||
| 188 | - | ||
| 189 | - | ||
| 190 | - | ||
| 191 | - | ||
| 192 | - | ||
| 193 | - | ||
| 194 | - | ||
| 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 | + | ``` | |
| 195 | 207 | ||
| 196 | 208 | And much more other procedures/functions (see in uos.pas...) | |
| 197 | 209 | ||
| 198 | 210 | --- | |
| 199 | 211 | *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 | 212 | Category: Audio | |
| 201 | 213 | Category: Lazarus | |
| 202 | 214 | Category: Libraries |
