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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Generate 10000 unique audio file of 2MB each using shell script.
# 8  
Old 09-28-2015
If you have CygWin installed then:-

Code:
 cat /full/unix/like/path/to/audio1.raw > /dev/dsp

'/dev/dsp' DOES exist in a CygWin install...

All files are white noise samples at 8000Hz sample speed, 8 bit depth, unsigned integer, mono, interpolation unknown, (that is dependent on the platform).

Ensure you have the global volume turned up!
# 9  
Old 09-28-2015
So, on Linux, it's playing in principle. Mayhap sth is wrong with your virtual sound? I don't know about windows systems; how about just trying a different extension?
# 10  
Old 09-28-2015
Quote:
Originally Posted by RudiC
.........how about just trying a different extension?
Sadly one can't. The header _block_ of each audio recorded format contains the information to set up the audio card through a codec, raw files REQUIRE hard coded parameters to play.

Changing an extension to AIFF for example could cause a system crash when an incorrect codec is applied to a raw file...

---------- Post updated at 08:58 PM ---------- Previous update was at 01:44 PM ----------

Quote:
Originally Posted by sushil.kumar
Can i winscp and hear these audio files with any other audio player at windows machine if not "VLC Media player"
This is probably the best command line audio recorder, player and manipulator around......

SoX - Sound eXchange | HomePage

It is ported to nearly every type of platform available...
# 11  
Old 09-29-2015
Thanks Wisecracker,

I have just changed raw file to ".wav" file and i am able to play the audio. The audio is plain white noise smooth sound, No variation.

sox -r 44100 -e unsigned -b 8 -c 1 audio1.raw audio1.wav
sox -r 8000 -e unsigned -b 8 -c 1 audio2.raw audio2.wav
sox -r 16000 -e unsigned -b 8 -c 1 audio3.raw audio3.wav

Can we have some variable noise with some high and low pitch sound. If so then what option shall i use for some music/tone/beep or some random asynchronoss noise.

Other case,

Suppose i download a movie music at UNIX terminal then can i split the whole music file in frames and create multiple files by snuffling these frames? Is any such utility package available for this or any such command to split music audio file in frames?

Regards,
Sushil Kumar
# 12  
Old 09-29-2015
Apologies for any typos...

Talk about changing the goalposts...

Here is an example of using my bash executable as a raw file, (genius mode is not a requirement)...
Code:
Last login: Tue Sep 29 11:49:18 on ttys000
AMIGA:barrywalker~> cp /bin/bash ~/bash.raw
AMIGA:barrywalker~> ls -l bash.raw-r-xr-xr-x  1 barrywalker  staff  1371648 29 Sep 11:50 bash.raw
AMIGA:barrywalker~> ls -l /bin/bash-r-xr-xr-x  1 root  wheel  1371648 28 Mar  2013 /bin/bash
AMIGA:barrywalker~> /Users/barrywalker/sox-14.4.0/sox -q -b 8 -r 44100 -e unsigned-integer bash.raw -d
AMIGA:barrywalker~> _

ANY file can act as an audio file so long as you give it an extension of '.raw' INCLUDING shell scripts...
Each file will have its own characteristic sound according to the sample rate, number of channels to be played, bit depth, signed or unsigned, etc...
As you only required basic audio sounds then just experiment.
It is surprisingly easy to generate waveforms, (e.g. sine and square waveforms), WITHOUT the need for sophisticated sound editors. Simple shell scripts can do it...

Take a look at my AudioScope.sh:-
The Start Of A Simple Audio Scope Shell Script...
When run and then exited extract the files from the '/tmp' drawer these are all created entirely from the script.

Read the script for more info and see how easy it is to create any type waveform...

As for exctracting audio from a movie frame by frame then I have no idea...

EDIT:-
An example of a bomb out error beep in pure shell scripting...
Code:
#!/bin/bash --posix
#
# Generate a fun bomb-out sound using SOX and /dev/dsp...
# $VER: bomb.sh_Version_1.00.00_(C)2013_B.Walker_G0LCU.
#
# This is now Public Domain and ypu may do with as you please...
#
# Tested on a Macbook Pro 13" OSX 10.7.5, using SOX.
# Tested on Debian Linux 6.0.x, using /dev/dsp
# Tesetd on PCLinuxOS 2009, using /dev/dsp.
m=0
n=0
waveform="\\xA0\\xA0\\xA0\\x60\\x60\\x60"
# Initialise the waveform.raw file length to zero.
> /tmp/waveform.raw
# Generate the high start sound.
for m in $( seq 0 1 50 )
do
	printf "$waveform" >> /tmp/waveform.raw
done
# Now build up the waveform by adding the correct byte values at the end first then the beginning last.
for n in $( seq 0 1 15 )
do
	# Add the correct byte at the end, append the file, looping a few times...
	waveform="$waveform\\x60"
	for m in $( seq 0 1 10 )
	do
		printf "$waveform" >> /tmp/waveform.raw
	done
	# Now add the correct byte at the beginning, append the file, looping a few times...
	waveform="\\xA0$waveform"
	for m in $( seq 0 1 5 )
	do
		printf "$waveform" >> /tmp/waveform.raw
	done
done
# Now generate a crude explosion...
dd if=/dev/urandom of=/tmp/explosion.raw bs=8000 count=1
# Append to the waveform.raw file...
cat /tmp/explosion.raw >> /tmp/waveform.raw
# Now play back a single run of the raw data using SOX.
# IMPORTANT! Change the path to suit your SOX path...
/Users/barrywalker/sox-14.4.0/sox -q -b 8 -r 8000 -e unsigned-integer /tmp/waveform.raw -d
# A version for /dev/dsp too.
# cat /tmp/waveform.raw > /dev/dsp
#
# DEMO bomb.sh end.
# Enjoy finding simple solutions to often very difficult problems...


Last edited by wisecracker; 09-29-2015 at 09:13 AM.. Reason: Added some simple code.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script newbie- how to generate service log from shell script

Hi, I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service) lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Discussion started by: xiaogeji
3 Replies

2. Shell Programming and Scripting

Parameterizing to dynamically generate the extract file from Oracle table using Shell Script

I have below 2 requirements for parameterize the generate the extract file from Oracle table using Shell Script. Could you please help me by modifying the script and show me how to execute it. First Requirement: I have a requirement where I need to parameterize to generate one... (0 Replies)
Discussion started by: hareshvikram
0 Replies

3. Shell Programming and Scripting

Shell script to compare and generate a new file

Requirement is I have two files their format is File1 - input_file ----- tmp_value|3|number|| tmp_value1|3|alpha|| tmp_value2|6|alpha|AA AA| tmp_value3|15|number|000000005| tmp_value4|15|number|000000000000000| tmp_value5|11|alpha|bbbbbbbbbbb| tmp_value6|11|alpha|bb bb| input_file ... (4 Replies)
Discussion started by: greenworld123
4 Replies

4. Shell Programming and Scripting

Generate unique mac address

Hi, I want to generate 2000 mac address. Please let me know how to do so. Perl script or there is some tool availlable wherein i can give the count and it will generate that many mac-address Thanks, Kriti (4 Replies)
Discussion started by: kriti
4 Replies

5. Linux

Shell Script to generate Dynamic Param file Using SQL Plus Quey

Hi All, Can anyone give me Shell script sample script to generate Param file by Reading Values from SQL Plus query and it should assign those values to variables like.. $$SChema_Name='ORCL' Thanks in Advance... Srav... (4 Replies)
Discussion started by: Sravana Kumar
4 Replies

6. Shell Programming and Scripting

a shell script to generate an excel sheet from a text file..

hi, i have a text file that looks like this! i want to generate an excel sheet out of it, removing all the junk data except the addresses that look like . Arrow Electrical Services Rotating Machinery, Electrical Contracting & Mining Specialists Onsite maintenance, breakdown... (8 Replies)
Discussion started by: vemkiran
8 Replies

7. Shell Programming and Scripting

Create shell script to extract unique information from one file to a new file.

Hi to all, I got this content/pattern from file http.log.20110808.gz mail1 httpd: Account Notice: close igchung@abc.com 2011/8/7 7:37:36 0:00:03 0 0 1 mail1 httpd: Account Information: login sastria9@abc.com proxy sid=gFp4DLm5HnU mail1 httpd: Account Notice: close sastria9@abc.com... (16 Replies)
Discussion started by: Mr_47
16 Replies

8. Shell Programming and Scripting

How to generate 10.000 unique numbers?

hello, does anybody can give me a hint on how to generate a lot of numbers which are not identically via scripting etc? (7 Replies)
Discussion started by: xrays
7 Replies

9. Shell Programming and Scripting

Urgent: selecting unique specific content of a file using shell script

Hi, I have a file whose content and format at places is as given below. print coloumn .... coloumn .... coloumn .... skip 1 line print coloumn ... skip 1 line I need to select the following : print coloumn .... coloumn .... coloumn... (2 Replies)
Discussion started by: jisha
2 Replies

10. Shell Programming and Scripting

need to generate unique id from constant sid

Hello I have multiple accounts that running application that uses unique port number I want to generate this port from some sid number that stays constant for every user account , is there any place in the system that generate number that is unique to the account ? thanks (0 Replies)
Discussion started by: umen
0 Replies
Login or Register to Ask a Question