Sponsored Content
Top Forums Shell Programming and Scripting IF $USER is not in this list of users, then do this Post 302361985 by glev2005 on Wednesday 14th of October 2009 03:36:21 PM
Old 10-14-2009
What does $? indicate? What is this the varible of?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

su - user... how to find out the list of users and their passwords..

hi, to do a su - user, we need to know what are the users... so in unix 1) which file to see the list of users, passwords? (2 Replies)
Discussion started by: yls177
2 Replies

2. AIX

Script allows user to kill other users: I'd like to know HOW...

Hello list, Have a problem that's highlighting gaps in my knowledge; can you assist? We have a script that's tacked onto our trading application which allows branch managers etc. to kill off the sessions of other users at their branch. A menu option in the application spawns a shell running... (8 Replies)
Discussion started by: alexop
8 Replies

3. AIX

cloning users access with different user name

Hi! this would be my first time to post here in this forums, hope you can help me with my queries. i would like to create a different user name but have the same access rights. Example: root > rootbaby. thanks (5 Replies)
Discussion started by: HPL1706
5 Replies

4. UNIX for Dummies Questions & Answers

User Name and Password List/adding and removing users.

Hello everyone and let me start off by thanking anyone who can help with this. I work for a company that uses Unix as one of their servers. I'm not at all familar with Unix beyond logging after I restart the server:rolleyes: I'm looking for some command that will bring me up a list of current... (3 Replies)
Discussion started by: disgracedsaint
3 Replies

5. Shell Programming and Scripting

script to ignore the user from list of users

Hi, I have a situation where I want to ignore few users from list of users and print rest of user in log file. say, I want to ignore aaa, bbb, ccc, ddd .. ppp from list of 20 user (do not want to include) What is the good command or any script? Thanks in advance. (1 Reply)
Discussion started by: sumit30
1 Replies

6. UNIX for Advanced & Expert Users

list of users

Hello!Does anybody know how to solve this script: ,,write a shell script which displays a list of names of users who have created files "*. c" in the last day."? (1 Reply)
Discussion started by: theodoraa
1 Replies

7. UNIX for Dummies Questions & Answers

Not able to switch to other users using su -user from root

Hi all, I have a small problem. When I log in as root and try to switch to any other user using su -user, then it is giving an error saying libncurses.so permission denied. Can you help me? Thank you in advance. Sai. (1 Reply)
Discussion started by: sai2krishna
1 Replies

8. UNIX for Advanced & Expert Users

Need to find the user id of all users in UNIX

I need to find all the unix user id's of all the users in unix... is there any such command... pl help out (6 Replies)
Discussion started by: Syed Imran
6 Replies

9. UNIX for Dummies Questions & Answers

Users list

Hi i would like to know were the folder that contain file with list of all users ? And were i can learn about what kind of folder i have and wheat they have inside? question 2. when i write ls -a i see all directories and then i choose for example Documents and inside Documents i typed again... (1 Reply)
Discussion started by: iliya24
1 Replies

10. Shell Programming and Scripting

List the Manager of Users in AD - Using list- Get-ADuser

Is there any command that can used in Linux that export usernames and their manager's name from AD using bash shell script? I know this can be done using powershell but I need to use Linux for this procedure. (2 Replies)
Discussion started by: dellanicholson
2 Replies
roartut(7)						System Manager's Manual: RoarAuido						roartut(7)

NAME
roartut - RoarAudio sound library developer tutorial DESCRIPTION
This tutorial descipes some basics with working with libroar. We will create a simple application that can play a file and one that can play some sines. A lot of other examples can be found in RoarAudio's sources in the roarclients directory. This tutorial will cover some basics of the so called VS API. The VS API is a abstract layer ontop of the normal API. It is designed to be simple yet powerful. The VS API is all you need for most applications. If you need more control over what you do you must use the normal. If you need only a little of those extra power you can mix VS API and normal API. PLAYING A FILE
Playing back a file is a easy task with libroar. The VS API has some special support to play back files in a very simple way. This is shown here. First of all we need to include the needed header files: #include <roaraudio.h> /* libroar */ This main header already includes all we need to use the VS API. Now we can start our main(). We need to declare a object for the VS API as it is object oriented. This object is used to interact with the server and send all audio data to it: roar_vs_t * vss; int err; /* see later */ Next we need to open the connection to the server. The most simple function to do this is roar_vs_new_from_file(3) if we are going to play a file. It takes the folloing arguments: server address This is the address of the server. In general case This should be set to NULL. program name This is the name of our program. This should be set to some name the user will recognize like "some App", "some Game". It should not contain the filename of the process like "/usr/bin/someapp.bin". file name This is the name of the file we want to play. In fact this is a URL. VS API uses so called DSTR API to open files. DSTR API sup- ports local files as well as for example HTTP. Examples include: "somefile.ogg", "file:///data/bla.wav", "http://radiosta- tion.org:8000/bla.ogg". error var This is a pointer to a int used to store the error value in case of error. This can be set to NULL but should not. The function roar_vs_strerr(3) can be used to get a lion readable string of the error. Our call to roar_vs_new_from_file(3) will look like this: vss = roar_vs_new_from_file(NULL, "some App", "somefile.ogg", &err); if ( vss == NULL ) { roar_vio_printf(roar_stderr, "Error: Can not connect to server: %s0, roar_vs_strerr(err)); return 1; } Next we need to continuously feed in the data so the server can do the playback. Again most simple way is to use roar_vs_run(3). if ( roar_vs_run(vss, &err) == -1 ) { roar_vio_printf(roar_stderr, "Error: can not loop: %s0, roar_vs_strerr(err)); } This will block untill all of the file is played. After it returned must close the VS object. This should be done directly after roar_vs_run(3) returned. This is done this way: if ( roar_vs_close(vss, ROAR_VS_FALSE, &err) == -1 ) { roar_vio_printf(roar_stderr, "Error: Can not close connection to server: %s0, roar_vs_strerr(err)); return 1; } After adding some standard main() construct we should have something like this: //vsfile.c: #include <roaraudio.h> int main (void) { roar_vs_t * vss; int err; /* see later */ vss = roar_vs_new_from_file(NULL, "some App", "somefile.ogg", &err); if ( vss == NULL ) { roar_vio_printf(roar_stderr, "Error: Can not connect to server: %s0, roar_vs_strerr(err)); return 1; } if ( roar_vs_run(vss, &err) == -1 ) { roar_vio_printf(roar_stderr, "Error: can not loop: %s0, roar_vs_strerr(err)); } if ( roar_vs_close(vss, ROAR_VS_FALSE, &err) == -1 ) { roar_vio_printf(roar_stderr, "Error: Can not close connection to server: %s0, roar_vs_strerr(err)); return 1; } return 0; } //ll To compile and link we can use a command like this one: cc -o vsfile vsfile.c `roar-config --libs --cflags` The tool roar-config(1) will keep care for us about all flags needed for libroar. PLAYING A SINE
Now we want to write a application playing a sine for some secs. We start the same way by including the correct header files: #include <math.h> /* sin() */ #include <roaraudio.h> /* libroar */ After that we need some basic varibales with data about the audio we want to play back: int rate = ROAR_RATE_DEFAULT; int bits = 16; int channels = 1; /* mono */ Next we need to set the 'codec'. The codec is how the data is encoded. We want PCM as signed ints in the native byte order of our machine. int codec = ROAR_CODEC_DEFAULT; Now we need to store the frequency of our sine: float freq = 523.2; /* middle C */ float step = M_PI*2*freq/rate; /* how much time per sample we have to encode ... */ In addition we need some variables to store the current time and the length of time sine: float t = 0; /* current time */ float length = 5; /* 5 sec */ Next we need the buffer to hold the data as well as a varible used to go thru the buffer on generation of data. int16_t out[1024]; int i; last we need the VS object again as well as our error var: roar_vs_t * vss; int err; This time we open the connection to the server using roar_vs_new_playback(3). It is similar to roar_vs_new_from_file(3) but takes some other options: server address Same as above. program name same as above. sample rate The number of audio frames per sec. channels The number of samples (one per channel) per audio frame. codec The codec to be used. This is one of ROAR_CODEC_*. In our case we use ROAR_CODEC_DEFAULT which is signed PCM in CPU native format. bits The number of bits per sample. error var same as above. The call looks like this: vss = roar_vs_new_playback(NULL, "vssin", rate, channels, codec, bits, &err); if ( vss == NULL ) { roar_vio_printf(roar_stderr, "Error: Can not connect to server: %s0, roar_vs_strerr(err)); return 1; } Now we want to loop for length seconds: while (t < 2*M_PI*freq*length) { } In this loop we need to calculate our samples: for (i = 0; i < (sizeof(out)/sizeof(*out)); i++) { out[i] = 32767.f*sin(t); t += step; } The sine is multiplyed by 32767 as our amplitude range for 16 bit signed int is from -32768 to +32767. After we have our current data in out we want to write them to the server: if ( roar_vs_write(vss, out, sizeof(out), &err) == -1 ) { roar_vio_printf(roar_stderr, "Error: Can not write audio data to server: %s0, roar_vs_strerr(err)); break; } NOTE: In a real application you may want to check the return value for short writes: Those are writes shorter than the requested amount of data to be written. If you got any short writes you should try to rewrite the rest of your buffer later. This is not a error case. After we are finished with our main loop we have to close the connection to the server. This is done by roar_vs_close(3) as we already done in the file playback example: if ( roar_vs_close(vss, ROAR_VS_FALSE, &err) == -1 ) { roar_vio_printf(roar_stderr, "Error: Can not close connection to server: %s0, roar_vs_strerr(err)); return 1; } After adding some standard main() construct we should have something like this: //vssin.c: #include <roaraudio.h> #include <math.h> int main (void) { roar_vs_t * vss; int rate = ROAR_RATE_DEFAULT; int bits = 16; int channels = 1; /* mono */ int codec = ROAR_CODEC_DEFAULT; float freq = 523.2; /* middle C */ float step = M_PI*2*freq/rate; /* how much time per sample we have to encode ... */ float t = 0; /* current time */ float length = 5; /* 5 sec */ int16_t out[1024]; size_t i; int err; vss = roar_vs_new_playback(NULL, "vssin", rate, channels, codec, bits, &err); if ( vss == NULL ) { roar_vio_printf(roar_stderr, "Error: Can not connect to server: %s0, roar_vs_strerr(err)); return 1; } while (t < 2*M_PI*freq*length) { for (i = 0; i < (sizeof(out)/sizeof(*out)); i++) { out[i] = 32768.f*sin(t); t += step; } if ( roar_vs_write(vss, out, sizeof(out), &err) == -1 ) { roar_vio_printf(roar_stderr, "Error: Can not write audio data to server: %s0, roar_vs_strerr(err)); break; } } if ( roar_vs_close(vss, ROAR_VS_FALSE, &err) == -1 ) { roar_vio_printf(roar_stderr, "Error: Can not close connection to server: %s0, roar_vs_strerr(err)); return 1; } return 0; } //ll To compile and link we can use a command like this one: cc -o vssin vssin.c -lm `roar-config --libs --cflags` We need to use -lm to link the math library for sin(). The tool roar-config(1) will keep care for us about all flags needed for libroar. Now we should have a working binary vssin playing a sin() for 5 sec. Happy hacking! SEE ALSO
roar-config(1), roarcat(1), libroar(7). RoarAudio(7). RoarAudio November 2010 roartut(7)
All times are GMT -4. The time now is 11:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy