The Start Of A Simple Audio Scope Shell Script...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting The Start Of A Simple Audio Scope Shell Script...
# 29  
Old 04-02-2013
Actually, there are some obvious things still.

Code:
	printf "CURRENT COMMANDS AVAILABLE:-\n\n"
	printf "<CR> ................................................. Reruns the scan(s) again.\n"
	printf "RUN<CR> ......................... Reruns the scan(s), always with real captures.\n"
	printf "QUIT<CR> .................................................... Quits the program.\n"
	printf "HELP<CR> ................................................ This help as required.\n"
	printf "HOLD<CR> ........................................ Switch to pseudo-storage mode.\n"
	printf "DEMO<CR> .................................. Switch capture to default DEMO mode.\n"
	printf "DSP<CR> ................................. Switch capture to Linux /dev/dsp mode.\n"
	printf "SOX<CR> .................. Switch capture to multi-platform SOund eXchange mode.\n"
	printf "ONE<CR> ......................................... Sets the number of scans to 1.\n"
	printf "TEN<CR> ........................................ Sets the number of scans to 10.\n"
	printf "HUNDRED<CR> ................................... Sets the number of scans to 100.\n"
	printf "VER<CR> ................. Displays the version number inside the status windows.\n"
	printf "TBVAR<CR> ............ Set up uncalibrated user timebase offset and jump points.\n"
	printf "FASTEST<CR> .................. Set all modes to the fastest possible scan speed.\n"
	printf "1mS<CR> ............ (Not available in DEMO mode.) Set scanning rate to 1mS/DIV.\n"
	printf "10mS<CR> ............. (Inaccurate in DEMO mode.) Set scanning rate to 10mS/DIV.\n"
	printf "100mS<CR> ...................................... Set scanning rate to 100mS/DIV.\n"
	printf "SHIFT<CR> ............ Set the vertical position from -4 to +4 to the mid-point.\n"
	printf "DRAW<CR> .......... Connect up each vertical plot to give a fully lined display.\n"
	printf "\n"

can become:

Code:
cat <<EOF
CURRENT COMMANDS AVAILABLE:-

<CR> ................................................. Reruns the scan(s) again.
RUN<CR> ......................... Reruns the scan(s), always with real captures.
QUIT<CR> .................................................... Quits the program.
HELP<CR> ................................................ This help as required.
HOLD<CR> ........................................ Switch to pseudo-storage mode.
DEMO<CR> .................................. Switch capture to default DEMO mode.
DSP<CR> ................................. Switch capture to Linux /dev/dsp mode.
SOX<CR> .................. Switch capture to multi-platform SOund eXchange mode.
ONE<CR> ......................................... Sets the number of scans to 1.
TEN<CR> ........................................ Sets the number of scans to 10.
HUNDRED<CR> ................................... Sets the number of scans to 100.
VER<CR> ................. Displays the version number inside the status windows.
TBVAR<CR> ............ Set up uncalibrated user timebase offset and jump points.
FASTEST<CR> .................. Set all modes to the fastest possible scan speed.
1mS<CR> ............ (Not available in DEMO mode.) Set scanning rate to 1mS/DIV.
10mS<CR> ............. (Inaccurate in DEMO mode.) Set scanning rate to 10mS/DIV.
100mS<CR> ...................................... Set scanning rate to 100mS/DIV.
SHIFT<CR> ............ Set the vertical position from -4 to +4 to the mid-point.
DRAW<CR> .......... Connect up each vertical plot to give a fully lined display.

EOF

And the same for your graticule, nearly:


Code:
GRAT_HEADER=$'\x1B'"[0;37;44mDISPLAY"$'\x1B'"[0;36;44m"

cat <<EOF
       +-------+-------+-------+---[${GRAT_HEADER}]---+-------+-------+--------+       
       |       |       |       |       +       |       |       |        |       
       |       |       |       |       +       |       |       |        |       
       |       |       |       |       +       |       |       |        |       
       +-------+-------+-------+-------+-------+-------+-------+--------+ <     
       |       |       |       |       +       |       |       |        |       
       |       |       |       |       +       |       |       |        |       
       |       |       |       |       +       |       |       |        |       
     0 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--+ <     
       |       |       |       |       +       |       |       |        |       
       |       |       |       |       +       |       |       |        |       
       |       |       |       |       +       |       |       |        |       
       +-------+-------+-------+-------+-------+-------+-------+--------+ <     
       |       |       |       |       +       |       |       |        |       
       |       |       |       |       +       |       |       |        |       
       |       |       |       |       +       |       |       |        |       
       |       |       |       |       +       |       |       |        |       
       +-------+-------+-------+-------+-------+-------+-------+--------+ 
EOF

Note that you cannot indent the ending EOF, it must be at the very beginning of the line. Don't put comments on the same line after it either.

And the same thing again to create your entire config file in one command instead of 9.

Also, you might find it interesting to know you can put multiple lines in a string.

Code:
A="b
c
d
e
f"
echo "$A"

No more 'printf \n' needed.

Also, there are two different places in your code where you write an entire config file. Why not make a function, and just call it in two places?

Last edited by Corona688; 04-02-2013 at 03:22 PM..
# 30  
Old 04-02-2013
Hi Corona688...

I like the function idea for the config file. Why didn't I think of it...

As for the others, let me get the status lines cleaned up and if need be Trigger/Sync points first... Then I will experiment.

Thanks a lot matey...

Still working out how to get DC in on ONE input only...

I have a simple method of relay switching AC to DC and back using the 1KHz generator but even with the chopper I have no means, AFAIK, whether the DC is +ve or -ve.

This is the idea I have gotten, use the chopper to get the relative DC level, and on exactly the same multivib use the VFO section to detect whether the signal is +ve or -ve, a low freq being -ve and a high freq being +ve... FM and AM in 1 swoop... ;oD

Remember I have only ONE input...

The code should be easy...

BTW, tested on this Macbook Pro OSX 10.7.5 in DEMO and SOX modes and my Gnome Debian 6.0.x in DEMO and DSP modes...
# 31  
Old 04-07-2013
The DRAW command now works immediately after a REAL scan...
(On the first run it defaults to OFF for slow machines.)
It can be turned off using the HOLD command...

The config file is now a function as Corona688 suggested.

The two images are the SOX sinewave generator auto-running from
the script with the earphone output connected to the mic input using the home
built hardware previously shown and the levels set using the output volume
and mic input controls.

The TBVAR set at 3 in and 3 jump for easy viewing, equvalent to 500uS/DIV,
proving the horizontal calibration is correct, 2 divisions per cycle...

Set to 1mS/DIV and you will see the calibrtaion is correct.

EDIT: Removed one small block, it does not affect the running but was a
copy and paste error on my part... Sorry.

Last edited by wisecracker; 07-14-2013 at 07:23 AM.. Reason: Code now an attachment.
# 32  
Old 04-08-2013
Well in the last day or so this thread has been given 5 stars. To those following in AND who voted for it I say - Thank You. It was a wonderful surprise to come to with this next upload.

This upload now has all the deliberate slowing down "sleep 1" lines removed and placed into the correct positions and a general cleanup.

The start of the internal synchronisation code is started and an auto-save facility added.

This auto-save is _volatile_ so use with caution. By volatile I mean, when enabled it WILL save a copy of EVERY scan whether it is a capture or a replay.

It is easy to code for capture only but I decided to do every scan because it is easier to delete files than try to get them back again. The filemanes are _numeric_ using EPOCH values and saved to /tmp ATM...

The new commands are SAVEON, SAVEOFF, TIRG with unfinished subcommands of SYNCEQ, SYNCGT and SYNCLT. I am working on these in the evenings, UK local time and should be ready by the weekend.

Last edited by wisecracker; 07-14-2013 at 07:30 AM.. Reason: Code now an attachment.
# 33  
Old 04-10-2013
A few updates along with a pointer inside the builtin help file to am Manual:-

http://wisecracker.host22.com/public..._Manual.readme

This Manual includes the first construction.
It is NOT finished but fully enough for the present stage...

The pseudo trigger and sync modes should be ready by the week end...

Writing manuals takes hours...

Last edited by wisecracker; 07-14-2013 at 07:30 AM.. Reason: Code now an attachment.
# 34  
Old 04-28-2013
Well, back again after a holiday...

Found 2 bugs and 1 programming error, yup there are bugs... ;oO
The bugs are esoteric but the error is stupidity on my part... ;oD

I suspect none have been found by yourselves who are trying this out however...

Removed the bash RANDOM call and used /dev/urandom instead. It is _infinitely_ quicker for the DEMO capture mode...

The first of the _internal_sync_ routines done.
Help file updated, etc, etc...

From Command mode:-

TRIG<CR>
SYNCEQ<CR>
Caps shift u or caps shift d to decide a sync point from 15 to 240. Then <CR>...
This starts the display from the value set.
Do all this again and the trace will start from another point with the value chosen...
If the value is not found then the trace runs from the start of the waveform.raw file at the FASTEST timebase speed...

Working on neagtive going SYNCLT and positive going SYNCGT ATM...

The code has now had extensive testing on an ACER Aspire One netbook using PCLinuxOS 2009 in DEMO and DSP modes also...

Before running delete your existing /default/full/path/to/AudioScope.config file so that the
changes can take place correctly... Also manually change the zero_offset value to give a centre straight line with 0 input voltage. It is now -2 on my Macbook Pro machine...

Feedback would be welcome, TIA...

Enjoy...

Bazza...

Last edited by wisecracker; 07-14-2013 at 07:35 AM.. Reason: Code now an attachment.
# 35  
Old 06-23-2013
Well the positive going and negative going sync is done although IMHO they are not of much use.

The EXT trigger is on hold until a calibrated Y amp, at least AC coupled, is finished. A starter piece of home brew hardware is under construction.

I am now working on a low signal level ZOOM facility.

This is for signal levels that are actually inside 4 bits of depth instead of the quantised 4 bit depth used for the actual display of large signals inside the terminal window...

Also the simple Y amp and vertical calibration circuits to be added to the end of the script too.

Last edited by wisecracker; 07-14-2013 at 07:38 AM.. Reason: Code now an attachment.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. OS X (Apple)

A simple variable frequency sinewave audio generator.

Hi all... Well I have not been inactive but working out how to make OSX 10.14.x command line audio player have a variable sample rate. This is a back door as afplay does not have a sample rate flag unlike aplay for ALSA, in Linux flavours. This is a DEMO only but a derivative of it will... (2 Replies)
Discussion started by: wisecracker
2 Replies

2. Shell Programming and Scripting

Generate 10000 unique audio file of 2MB each using shell script.

Hi, I want 10000+ unique Audio file of approx 2MB each. How can i generate numerous audio files using shell script. Any tool, command or suggestions are welcome. If i give one audio seed file then can we create numerous unique files with same seed file? Any help is highly appreciable.... (11 Replies)
Discussion started by: sushil.kumar
11 Replies

3. OS X (Apple)

Python script to do simple audio capture...

This site is the first to get this snippet. It will capture an audio recording of any time length within the limits of OSX's QuickTime Player's capablility... A shell script derivative of this will be used as a further capture for CygWin's AudioScope.sh. Thoroughly read ALL the comments in... (0 Replies)
Discussion started by: wisecracker
0 Replies

4. UNIX for Dummies Questions & Answers

unable to start shell script

Hi, Pleasse could someone advise why i'm getting this error below - No such file or directory dev6:$ ls -ltr ReleaseManagement.sh -rwxr-xr-x 1 dev fix 4830 Aug 22 11:13 ReleaseManagement.sh dev6:$ ./ReleaseManagement.sh : No such file or directory dev6:$ thank you (2 Replies)
Discussion started by: venhart
2 Replies

5. Shell Programming and Scripting

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each certificate and send the mail to the user. The user takes action to add the new certificate to the storage file and user owns the responsibility to update the input text file with the new certificate... (5 Replies)
Discussion started by: casmo
5 Replies

6. What is on Your Mind?

Scope of Shell Programming and scripting

Hi all, I want to know what is the scope and job status of shell Programming and scripting. Does it have any attractive jobs? (2 Replies)
Discussion started by: malikshahid85
2 Replies

7. Shell Programming and Scripting

Help with stop/start Shell Script.

Hi All, I would like to develop a shell script for stop & start an application server (1-4) on Solaris box. Here are the user requirements for this task. 1. User will input the option which server they wish to stop. 2. Will clear cache files from specific location. 3. ... (1 Reply)
Discussion started by: venga
1 Replies

8. Shell Programming and Scripting

scope of a Variable inside shell script

hi all, i'm using the following script, Status=1 Function_do () { while read line; do if ; then #echo $line if ; then Status=0 echo " LINKINK ERROR " fi fi done < ldd.log } Function_do (4 Replies)
Discussion started by: vij_krr
4 Replies

9. Shell Programming and Scripting

simple shell - how to get a parameter typed in a shell script

Hi, I am new to unix and using linux 7.2. I would like to create a script that would make it easyer for me to run my java programms. At the moment I have to type java myJavaprogram I am trying to write a script that will allow me to type something like this "myscript myJavaprogram" or maybe... (4 Replies)
Discussion started by: cmitulescu
4 Replies

10. Shell Programming and Scripting

problem with shell variable's scope

Hi, I am stuck while developing a shell sub-routine which checks the log file for "success" or "failure". The subroutine reads the log file and checks for key word "success", if found it set the variable (found=1). It returns success or failure based on this variable. My problem is, I can... (2 Replies)
Discussion started by: cjjoy
2 Replies
Login or Register to Ask a Question