AC to DC trigger pulse for AudioScope.sh.

 
Thread Tools Search this Thread
Operating Systems OS X (Apple) AC to DC trigger pulse for AudioScope.sh.
# 1  
Old 03-21-2014
AC to DC trigger pulse for AudioScope.sh.

Hi all...
Has _below_ ever been done in UNIX shell scripting before?
(I have done this easily in Python but this is using purely the shell.)
The DEMO version IS built and has been tested.

Pre-amble...
I now need at least one control pulse for the AudioScope.sh when in PURELY audio I/O mode, NOT using Arduino...
There are in fact two of them, the L & R earphone outputs.
This is a simple test version that converts a crude 2KHz squarewave into a DC trigger voltage,
in this case +ve going, using the earphone output(s) in MONO mode in this DEMO. It generates
over +3V DC which can be used to switch a transistor (OFF/)ON/OFF for one second.
If the transistor is connected across a 5V rail with a collector load of say 4.7 KilOhms
then +ve logic TTL level switching is made easy. TTL level is NOT needed in my case but
this working and tested idea is needed however.
Hard coding for it looks dead easy and with two possible outputs from the L & R connections,
2 off +ve going pulses AND/OR -ve going pulses are easily possible...

Enjoy finding simple solutions to often very difficult problems...

Bazza...
Code:
#!/bin/bash
# ac2dc.sh
# *********************************************************
# Generate a 1 second squarewave pulse and _voltage_double_ the output to DC.
# This is to be used as a set/reset pulse for the AudioScope.sh.
# Issued as Public Domain, CC0. You may do with it as you please.
# *********************************************************
if [ ! -e "/tmp/squarewave.wav" ]
then
	> /tmp/squarewave.wav
	printf "\x52\x49\x46\x46\x64\x1F\x00\x00\x57\x41\x56\x45\x66\x6D\x74\x20\x10\x00\x00\x00\x01\x00\x01\x00\x40\x1F\x00\x00\x40\x1F\x00\x00\x01\x00\x08\x00\x64\x61\x74\x61\x40\x1F\x00\x00" >> /tmp/squarewave.wav
	for n in {0..1999}
	do
		printf "\x00\x00\xFF\xFF" >> /tmp/squarewave.wav
	
	done
fi
# *********************************************************
# The line below uses various Linux flavours, "aplay"...
# aplay /tmp/squarewave.wav
# *********************************************************
# Use the OSX default basic command line audio player, "/usr/bin/afplay".
afplay /tmp/squarewave.wav
# *********************************************************
exit 0
# *********************************************************
# A very simple voltage doubler and passive filter for a control output.
# This will be used to set and reset a microphone input Analogue to Digital Converter, (ADC).
# Two ARE available and MIGHT be needed, but only ONE for definite.
# (Connect DC OUT & GND to a DC coupled oscilloscope to see it working.)
#
# Headset O/P. C1              |\|D2 
#  O--------o--||--o-------o---| +---o-------o-------O +VE DC OUT.
#           |      |       |   |/| + |       |
#  O        \      | +     \         |       \
#  |        /    --+--     /         | +     /
#  |   * R1 \     / \ D1   \ R2     === C2   \ R3
#  |        /    '---'     /        -+-      /
#  |        \      |       \         |       \
#  |        /      |       /         |       /
#  |        |      |       |         |       |
#  +--------o------o-------o---------o---o---o-------O -VE.
#                                      __|__
#                                      /////
# Parts List:-
# C1 ......... 1.0 uF, 50V.
# C2 ......... 10 uF, electrolytic, 10V.
# R1 ......... 47 KilOhms, (* this can be ommitted), 1/8W, 5% tolerence resistor.
# R2 ......... 1 MegOhm, 1/8W, 5% tolerence resistor.
# R3 ......... 100 KilOhms, 1/8W, 5% tolerence resistor.
# D1, D2 ..... OA90 or any similar germanium diode.
# 3.2 mm stereo jack plug for headset socket.
# Coaxial connecting cable.
# Sundries as required, stripboard, etc, (similar to above).
# *********************************************************
# I'll bet no one thought that the shell would become the basis of a testgear suite...

# 2  
Old 04-14-2014
I thought about asking this back in your Audioscope post, why do you need this line?
Code:
printf "\x52\x49\x46\x46\x64\x1F\x00\x00\x57\x41\x56\x45\x66\x6D\x74\x20\x10\x00\x00\x00\x01\x00\x01\x00\x40\x1F\x00\x00\x40\x1F\x00\x00\x01\x00\x08\x00\x64\x61\x74\x61\x40\x1F\x00\x00" >> /tmp/squarewave.wav

Thanks
# 3  
Old 04-14-2014
That part is the 44 byte header to make the waveform a ".WAV" file, otherwise it would be a ".RAW" file instead.

There is/are reams of info on the ".WAV" format and it is dead easy to create all sorts of waveforms, (within limits of course), and generate differing headers for the differing ".WAV" formats; e.g. 16 bit, stereo, various sample rates, ect, etc...

Hope this helps...
This User Gave Thanks to wisecracker For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. OS X (Apple)

AudioScope Project.

AudioScope Project. (Apologies for any typos.) For the few following...... AudioScope.sh... Now at Version 0.60.00. Well this baby has come a long way since its inception in January 2013. It is now at Version 0.60.00. It is MUCH more Apple centric now with a new OSX Sierra minimum _silent_... (7 Replies)
Discussion started by: wisecracker
7 Replies

2. UNIX for Advanced & Expert Users

Has AudioScope found a bug in bash 4.4.5?

Using AudioScope.sh on Ubuntu 17.04 from a live DVD disc I came across an error. Consider the code below it is a MUCH shortened version of the KEYBOARD input in AudioScope. #!/bin/bash bash --version uname -a status=0 KEYBOARD() { read -r -p "Enter QUIT or EXIT to quit:- " kbinput if ||... (11 Replies)
Discussion started by: wisecracker
11 Replies

3. OS X (Apple)

The DC Control and Timer boards for AudioScope.sh...

Hi all... Apologies for any typos... For those intersted in the AudioScope the next construction is finished. I have not been totally idle but working out the hard stuff to be able to be very simple to build. It is a single transistor simple timer that lasts for about 1.2 to 1.8 seconds.... (2 Replies)
Discussion started by: wisecracker
2 Replies

4. What is on Your Mind?

AudioScope...

Boy oh boy, with only a MONO mic input to use AudioScope gets much more difficult when the ALTDC board is included. It needs, so far, two hits at the MIC input with a single hit at the HEADPHONE audio output. The first at the highest practical resolution for the AC component and the second... (0 Replies)
Discussion started by: wisecracker
0 Replies

5. OS X (Apple)

The Alternate DC board for AudioScope.sh.

Hi guys... Well I have entered an area of partial insnity... ;o) Below is a photo of the 'ALTDC' board for AudioScope.sh... I have decided to incorporate all three methods for obtaining DC into this MBP via the MIC input. 1) VFO. 2) CHOPPER. 3) COUNTER. The controller for the COUNTER... (9 Replies)
Discussion started by: wisecracker
9 Replies

6. Shell Programming and Scripting

Experimental awk audio converter for CygWin and AudioScope.sh

Development machine:- Standard MBP 13 inch, OSX 10.7.5... GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11) Copyright (C) 2007 Free Software Foundation, Inc. Scenario:- Audio capture for AudioScope.sh for CygWin without ANY third party installs. I am trying my hardest to get a... (6 Replies)
Discussion started by: wisecracker
6 Replies

7. What is on Your Mind?

AudioScope has had a magazine review. <shock>

Hi Admin and Staff... Thanks for hosting AudioScope.sh on this site. I have had the biggest surprise of my life today. This months issue of the UK Linux magazine "Linux Format" have done a small piece on the project. Issue April 2014, LXF 182, page 65... This I never expected and I... (1 Reply)
Discussion started by: wisecracker
1 Replies
Login or Register to Ask a Question