Bazza LXF regular

Joined: Sat Mar 21, 2009 11:16 am Posts: 1381 Location: Loughborough
|
Posted: Tue Mar 12, 2013 1:37 pm Post subject: A crude 1KHz sinewave generator using bash... |
|
|
A very simple crude sinewave generator.
The file required is generated inside the code, is linear interpolated and requires /dev/audio to work. Ensure you have this device, if not the download oss-compat from your OS's repository...
It lasts for about 8 seconds before exiting and saves a 65536 byte file to your working directory/drawer/folder as sinewave.raw. Use an oscilloscope to check the waveform generated...
This will be the test waveform soon for the AudioScope when the timebase of the scope is finished...
It is entirely Public Domain and you may do with it as you please...
Bazza, G0LCU...
| Code: | #!/bin/bash
#
# 1KHz.sh
#
# A very simple DEMO crude sinewave generator using the device /dev/audio.
# It is an eight second burst and generates an approximation of a pure sinewave using linear interpolation.
# The "sinewave.raw" file length is 65536 bytes in size...
# Zero the raw file...
> sinewave.raw
# This is the b byte data list for the crude sinewave.
data="\\x0f\\x2d\\x3f\\x2d\\x0f\\x03\\x00\\x03"
# Generate the file as an eight second burst...
for waveform in {0..8191}
do
printf "$data" >> sinewave.raw
done
# Now play back a single run of the raw data for about eight seconds.
cat sinewave.raw > /dev/audio
# End of 1KHz.sh DEMO...
# Enjoy finding simple solutions to often very simple problems... ;o) |
_________________ 73...
Bazza, G0LCU...
Team AMIGA... |
|