Sponsored Content
Operating Systems OS X (Apple) An Audio Function Generator... Post 302970163 by wisecracker on Sunday 3rd of April 2016 12:45:34 PM
Old 04-03-2016
Hi all...
This is the very start of all of the waveforms...

SINEWAVE16, SINEWAVE64, TRIANGLE16 and TRIANGLE64 have not yet been worked out WRT to correct values but this is the finished waveform generation variable and file section.
All file lengths are 524288 bytes in size.
During doing this I got the error:-
"""
/usr/bin/awk: /tmp/pulseplus64.raw makes too many open files
source line number <somenumber>
"""
And www.unix.com came to the rescue yet again:-
nawk - file limits
Code:
#!/usr/bin/awk -f
BEGIN \
{
	# General variables...
	LOOP = 1
	LOOPS = 16
	INTEGER = 32

	# Waveform variables...
	SINEWAVE4 = "O~O "
	SINEWAVE16 = "Op}pN- -Op}pN- -"
	SINEWAVE64 = "Op}pN- -Op}pN- -Op}pN- -Op}pN- -Op}pN- -Op}pN- -Op}pN- -Op}pN- -"
	SQUAREWAVE4 = "~~  "
	SQUAREWAVE16 = "~~~~~~~~        "
	SQUAREWAVE64 = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                "
	TRIANGLEWAVE4 = "O~O "
	TRIANGLEWAVE16 = "________--------"
	TRIANGLEWAVE64 = "________________________________--------------------------------"
	SAWTOOTHPLUS4 = " ?^~"
	SAWTOOTHPLUS16 = " &,29?EKRX^dkqw~"
	SAWTOOTHPLUS64 = " !#$&')*,-/0235689:<>?ABDEGHJKMNPQSTVWYZ\\^_abdeghjkmnpqstvwyz|}~"
	SAWTOOTHMINUS4 = "~^? "
	SAWTOOTHMINUS16 = "~wqkd^XRKE?92,& "
	SAWTOOTHMINUS64 = "~}|zywvtsqpnmkjhgedba_^\\ZYWVTSQPNMKJHGEDBA?><:9865320/-,*)'&$#! "
	PULSEPLUS4 = "~   "
	PULSEPLUS16 = "~               "
	PULSEPLUS64 = "~                                                               "
	PULSEMINUS4 = " ~~~"
	PULSEMINUS16 = " ~~~~~~~~~~~~~~~"
	PULSEMINUS64 = " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
	# ARBITRARY can be any length from 2 to 1024 bytes, sampling rate will be set to 96000 later...
	ARBITRARY = "Op}pN- -"
	NOISE = "$VER freq.awk_Version_0.00.01_B.Walker_G0LCU."

	# 4 byte waveforms, the sinewave and triangle wave are identical...
	for(LOOP = 1; LOOP <= 17; ++LOOP)
	{
		SINEWAVE4 = SINEWAVE4 SINEWAVE4
		SQUAREWAVE4 = SQUAREWAVE4 SQUAREWAVE4
		TRIANGLEWAVE4 = TRIANGLEWAVE4 TRIANGLEWAVE4
		SAWTOOTHPLUS4 = SAWTOOTHPLUS4 SAWTOOTHPLUS4
		SAWTOOTHMINUS4 = SAWTOOTHMINUS4 SAWTOOTHMINUS4
		PULSEPLUS4 = PULSEPLUS4 PULSEPLUS4
		PULSEMINUS4 = PULSEMINUS4 PULSEMINUS4
	}
	printf("%s", SINEWAVE4) > "/tmp/sinewave4.raw"
	close("/tmp/sinewave4.raw")
	printf("%s", SQUAREWAVE4) > "/tmp/squarewave4.raw"
	close("/tmp/squarewave4.raw")
	printf("%s", TRIANGLEWAVE4) > "/tmp/trianglewave4.raw"
	close("/tmp/trianglewave4.raw")
	printf("%s", SAWTOOTHPLUS4) > "/tmp/sawtoothplus4.raw"
	close("/tmp/sawtoothplus4.raw")
	printf("%s", SAWTOOTHMINUS4) > "/tmp/sawtoothminus4.raw"
	close("/tmp/sawtoothminus4.raw")
	printf("%s", PULSEPLUS4) > "/tmp/pulseplus4.raw"
	close("/tmp/pulseplus4.raw")
	printf("%s", PULSEMINUS4) > "/tmp/pulseminus4.raw"
	close("/tmp/pulseminus4.raw")

	# 16 byte waveforms...
	for(LOOP = 1; LOOP <= 15; ++LOOP)
	{
		SINEWAVE16 = SINEWAVE16 SINEWAVE16
		SQUAREWAVE16 = SQUAREWAVE16 SQUAREWAVE16
		TRIANGLEWAVE16 = TRIANGLEWAVE16 TRIANGLEWAVE16
		SAWTOOTHPLUS16 = SAWTOOTHPLUS16 SAWTOOTHPLUS16
		SAWTOOTHMINUS16 = SAWTOOTHMINUS16 SAWTOOTHMINUS16
		PULSEPLUS16 = PULSEPLUS16 PULSEPLUS16
		PULSEMINUS16 = PULSEMINUS16 PULSEMINUS16
	}
	printf("%s", SINEWAVE16) > "/tmp/sinewave16.raw"
	close("/tmp/sinewave16.raw")
	printf("%s", SQUAREWAVE16) > "/tmp/squarewave16.raw"
	close("/tmp/squarewave16.raw")
	printf("%s", TRIANGLEWAVE16) > "/tmp/trianglewave16.raw"
	close("/tmp/trianglewave16.raw")
	printf("%s", SAWTOOTHPLUS16) > "/tmp/sawtoothplus16.raw"
	close("/tmp/sawtoothplus16.raw")
	printf("%s", SAWTOOTHMINUS16) > "/tmp/sawtoothminus16.raw"
	close("/tmp/sawtoothminus16.raw")
	printf("%s", PULSEPLUS16) > "/tmp/pulseplus16.raw"
	close("/tmp/pulseplus16.raw")
	printf("%s", PULSEMINUS16) > "/tmp/pulseminus16.raw"
	close("/tmp/pulseminus16.raw")

	# 64 byte waveforms...
	for(LOOP = 1; LOOP <= 13; ++LOOP)
	{
		SINEWAVE64 = SINEWAVE64 SINEWAVE64
		SQUAREWAVE64 = SQUAREWAVE64 SQUAREWAVE64
		TRIANGLEWAVE64 = TRIANGLEWAVE64 TRIANGLEWAVE64
		SAWTOOTHPLUS64 = SAWTOOTHPLUS64 SAWTOOTHPLUS64
		SAWTOOTHMINUS64 = SAWTOOTHMINUS64 SAWTOOTHMINUS64
		PULSEPLUS64 = PULSEPLUS64 PULSEPLUS64
		PULSEMINUS64 = PULSEMINUS64 PULSEMINUS64
	}
	printf("%s", SINEWAVE64) > "/tmp/sinewave64.raw"
	close("/tmp/sinewave64.raw")
	printf("%s", SQUAREWAVE64) > "/tmp/squarewave64.raw"
	close("/tmp/squarewave64.raw")
	printf("%s", TRIANGLEWAVE64) > "/tmp/trianglewave64.raw"
	close("/tmp/trianglewave64.raw")
	printf("%s", SAWTOOTHPLUS64) > "/tmp/sawtoothplus64.raw"
	close("/tmp/sawtoothplus64.raw")
	printf("%s", SAWTOOTHMINUS64) > "/tmp/sawtoothminus64.raw"
	close("/tmp/sawtoothminus64.raw")
	printf("%s", PULSEPLUS64) > "/tmp/pulseplus64.raw"
	close("/tmp/pulseplus64.raw")
	printf("%s", PULSEMINUS64) > "/tmp/pulseminus64.raw"
	close("/tmp/pulseminus64.raw")

	# Generate the noise waveform...
	srand()
	for(LOOP = 1; LOOP <= 524288; ++LOOP)
	{
		INTEGER = 32 + rand() * 95
		printf("%c", INTEGER) > "/tmp/noise.raw"
	}
	close("/tmp/noise.raw")

	# Create a temporary ARBITRARY file...
	for(LOOP = 1; LOOP <= LOOPS; ++LOOP)
	{
		ARBITRARY = ARBITRARY ARBITRARY
	}
	printf("%s", ARBITRARY) > "/tmp/arbitrary.raw"
	close("/tmp/arbitrary.raw")
}

All criticisms welcome...
 

8 More Discussions You Might Find Interesting

1. Programming

Python, Platform Independent, Pure Audio Sinewave Generator...

IKHz_SW_OSX.py A DEMO mono _pure_ sinewave generator using standard text mode Python 2.6.7 to at least 2.7.3. This code is EASILY modifyable to Python version 3.x.x... This DEMO kids level 1KHz generator is mainly for a MacBook Pro, (13 inch in my case), OSX 10.7.5 and above. See below...... (0 Replies)
Discussion started by: wisecracker
0 Replies

2. Shell Programming and Scripting

A Crude 1KHz Audio Sinewave Generator Demo...

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... (5 Replies)
Discussion started by: wisecracker
5 Replies

3. Shell Programming and Scripting

Sequence generator

Thanks Guys This really helped (5 Replies)
Discussion started by: robert89
5 Replies

4. Slackware

Problems with audio recording in Audacity 2.0.5. Slackware64 14.1; Intel HD Audio.

I'm trying to record audio using Audacity 2.0.5 installed from SlackBuilds. My system is 64-bit Slackware 14.1 and a sound card is Intel HD Audio. I didn't change my sound system to OSS. (Default sound system in Slackware 14.1 is ALSA, isn't it?) First, I set Internal Microphone slider in KMix... (2 Replies)
Discussion started by: qzxcvbnm
2 Replies

5. OS X (Apple)

A Bash Audio Sweep Generator...

This is a small program as a tester for a basic sweep generator for bandwidth testing of AudioScope.sh. This DEMO is only capable of 4KHz down to about 85Hz and back due to the low bit rate, but it is proof of concept for a much wider variant using a much higher bit rate. The file generated... (4 Replies)
Discussion started by: wisecracker
4 Replies

6. OS X (Apple)

Variable frequency audio generator...

Hi all... I intend to do an Audio Function Generator using Awk, (already started thanks to Don), but the biggest thing I have struggled with was variable frequency. I was going to generate differing sized waveforms on the fly but that would that would mean the frequencies are dependent on any... (2 Replies)
Discussion started by: wisecracker
2 Replies

7. 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

8. Shell Programming and Scripting

Hostsfile generator

Hello I use a bash script to creating the hosts file /etc/hosts But there is a bug inside my output and I want to fix this. My Array looks like this: 205,IP 111.122.133.20 205,HOST2 unas 205,HOST1 unas15533 205,COMMENT # UNAS 775,IP ... (9 Replies)
Discussion started by: Marti95
9 Replies
All times are GMT -4. The time now is 01:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy