Sponsored Content
Operating Systems OS X (Apple) Plotting A Sine Curve Inside A Bash Shell... Post 302914577 by Corona688 on Tuesday 26th of August 2014 06:14:48 PM
Old 08-26-2014
I was trying to output direct 8-bit binary in awk. It kept converting my ff's into two-byte sequences.

You can, in GNU awk, with -b, which I was missing before:

Code:
$ # F is frequency, R is samplerate, S is number of samples
$ awk -b -v F=4000 -v R=8000 -v S=20 'BEGIN { for(N=0; N<S; N++) printf("%c", int(255*(sin(3.14159/2+2*3.14159*N*(F/R))/2)+128)) }' /dev/null | hexdump -C

00000000  ff 00 ff 00 ff 00 ff 00  ff 00 ff 00 ff 00 ff 00  |................|
00000010  ff 00 ff 00                                       |....|
00000014

$

Ordinary awk should be able to manage 1-127 with %c, but no more.

Last edited by Corona688; 08-26-2014 at 07:22 PM..
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[BASH] redirect standard error and use it inside

Hi all, Maybe my question is too simple but till now i couldn't figure about a solution :( I have a bash script scheduled in cron: <cron time parameters> my_script.sh > result.log 2>&1 By this way i can have standard output and standard error in my result.log file Now i want my script... (2 Replies)
Discussion started by: Pescator
2 Replies

2. Shell Programming and Scripting

running bash command inside awk

Org file 192.168.1.10 d:\adir\xdir 192.168.1.11 d:\bdir\ydir want to covert it into robocopy \\192.168.1.10\d$\adir\xdir\log* some_localdir\adir robocopy \\192.168.1.10\d$\adir\ydir\log* some_localdir\bbdir (5 Replies)
Discussion started by: ydk
5 Replies

3. UNIX for Dummies Questions & Answers

using awk inside bash script?

Hello, I'm trying to write a bash script that will query the current system time (OS X 10.6.6) and then convert the output from HH:MM:SS into time in seconds. The output of the system time command (systemsetup -gettime) is returned as: Time: HH:MM:SS so I wanted to use awk -F: to grab... (5 Replies)
Discussion started by: xaiu
5 Replies

4. Shell Programming and Scripting

Learning curve to understand bash iteration

Hi Folks, I know on one side there is script and on another side there is smart script. I am able to achieve what I got but thought there has to be a code which doesn't require multiple lines. So if you guys can help me out than it will be awesome. Also I wrote in cshell but if can get both the... (4 Replies)
Discussion started by: dixits
4 Replies

5. Shell Programming and Scripting

Hide bash code which is inside C plus plus program

I am embedding bash in cpp. Can the bash code be hidden (when we cat the executable to not be able to see the bash code) The simple code I am using: #include <iostream> #include <cstdlib> using namespace std; #define test1 "\ #!/bin/sh --posix \n\ echo... (1 Reply)
Discussion started by: frad
1 Replies

6. Shell Programming and Scripting

Aliases NOT working inside bash shell script

i have defined a function ln_s() for customizing the ln command in script1.sh. more script1.sh echo "Starting Execution" ./script2.sh echo "End of Execution" ln_s(){ ] && return ln -s "$1" "$2" } My script1.sh executes another script2.sh which has the following entry more script2.sh... (12 Replies)
Discussion started by: mohtashims
12 Replies

7. Shell Programming and Scripting

Need Multiple checks inside if condition in a bash shell script

Hi, I need to perform the untar and rm operation if the file found is a .tar and does not have test.tar or hello.tar as the file names. Below is the loop to check the same. for tf in *.tar do if ] then found=1 ... (1 Reply)
Discussion started by: mohtashims
1 Replies
filter-mouse(7) 							GGI							   filter-mouse(7)

NAME
filter-mouse - Generic mouse event translator SYNOPSIS
filter-mouse: [<file>] DESCRIPTION
This filter translates mouse events according to a set of translation rules. OPTIONS
file The name of the configuration file. If none given, the filter will first look for the file filter/mouse in the user GGI directory ($HOME/.ggi/ on UNIX), then in the base GGI directory if not found. CONFIGURATION
The translation rules are specified through a simple text file. The following example gives a good idea of the mouse filter usage. A # marks the rest of the line as a comment. EXAMPLE
A set of mouse translation rules: # Syntax is: # incoming-type [type-specifics] TO outgoing type [type-specifics] # # Simulated mouse buttons on the keyboard # #KEY modmask modvalue button label symbol TO BUT buttonnumber KEY 0x0004 0x0004 0xffff 0x000d 0xffff TO BUT 1 # Alt-Enter KEY 0x0004 0x0004 0xffff 0x0020 0xffff TO BUT 2 # Alt-Space KEY 0x0004 0x0004 0xffff 0x0008 0xffff TO BUT 3 # Alt-BackSpace # # Keyboard-Mouse on the Cursors # #KEY modmask modval button label symbol TO REL axis value KEY 0x0004 0x0004 0xffff 0xe034 0xffff TO REL X -5 # Alt-Left KEY 0x0004 0x0004 0xffff 0xe035 0xffff TO REL X 5 # Alt-Right KEY 0x0004 0x0004 0xffff 0xe032 0xffff TO REL Y -5 # Alt-Up KEY 0x0004 0x0004 0xffff 0xe033 0xffff TO REL Y 5 # Alt-Down # # Keyboard mouse on the Numpad # KEY 0x0004 0x0004 0xffff 0xe231 0xffff TO REL X -5 # Alt-Num1 KEY 0x0004 0x0004 0xffff 0xe231 0xffff TO REL Y 5 # Alt-Num1 KEY 0x0004 0x0004 0xffff 0xe232 0xffff TO REL Y 5 # Alt-Num2 KEY 0x0004 0x0004 0xffff 0xe233 0xffff TO REL X 5 # Alt-Num3 KEY 0x0004 0x0004 0xffff 0xe233 0xffff TO REL Y 5 # Alt-Num3 KEY 0x0004 0x0004 0xffff 0xe234 0xffff TO REL X -5 # Alt-Num4 KEY 0x0004 0x0004 0xffff 0xe235 0xffff TO BUT 1 # Alt-Num5 - Button KEY 0x0004 0x0004 0xffff 0xe236 0xffff TO REL X 5 # Alt-Num6 KEY 0x0004 0x0004 0xffff 0xe237 0xffff TO REL X -5 # Alt-Num7 KEY 0x0004 0x0004 0xffff 0xe237 0xffff TO REL Y -5 # Alt-Num7 KEY 0x0004 0x0004 0xffff 0xe238 0xffff TO REL Y -5 # Alt-Num8 KEY 0x0004 0x0004 0xffff 0xe239 0xffff TO REL X 5 # Alt-Num9 KEY 0x0004 0x0004 0xffff 0xe239 0xffff TO REL Y -5 # Alt-Num9 # # Home the cursor ... # KEY 0x0004 0x0004 0xffff 0xE038 0xffff TO ABS X 0 # Alt-Home KEY 0x0004 0x0004 0xffff 0xE038 0xffff TO ABS Y 0 # Alt-Home # # Invert mouse axis # #REL modmsk modval axis TO REL axis multiplier REL 0x0004 0x0004 X TO REL Y -1 REL 0x0004 0x0004 Y TO REL X -1 # # Accelerate mouse # # multiplier treshold higher-speed REL 0x0004 0x0004 X TO REL X 1 5 4 REL 0x0004 0x0004 Y TO REL Y 1 5 4 # # # Invert mouse buttons BUT 0x0004 0x0004 1 TO BUT 2 BUT 0x0004 0x0004 2 TO BUT 1 libgii-1.0.x 2003-08-11 filter-mouse(7)
All times are GMT -4. The time now is 11:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy