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

Hi,

I want 10000+ unique Audio file of approx 2MB each. How can i generate numerous audio files using shell script. Any tool, command or suggestions are welcome.

If i give one audio seed file then can we create numerous unique files with same seed file?

Any help is highly appreciable. Thanks in advance.

Regards,
Sushil Kumar

Eh?

!0000 audio files?

In what format, RAW, WAVE, etc?
Pure waveforms, various noises for bandpass tests, voice, music, etc?
What audio bandwidth, (in other words what sampling rates)?
Stereo, mono, multichannel, etc?
Digitally and/or analogue compressed or not?
Which interpolation, assuming that computer sound systems can have interpolation switched from the command line?
Two tone test frequencies with known fixed output levels?

I could go on but these are enough for you to go and do some research...

1 Like

Thanks for reply,
I do not bother about audio quality of these files as it is not in scope.

  • Any audio file format either raw, wav, AIFF, MP3 etc. is fine.
  • Any type of audio either voice, music, noise or bandpass tests.
  • Sampling rates should be between 44.1kHz or 48kHz.
  • It can be anything among Stereo, mono, multichannel, etc?
  • Anything either digitally and/or analogue compressed or not?

I need to use these file to testing software with unique file every time at unix command line so do not bother to listen any file. My requirement is to have almost same size audio file(10% +- is file size).

Regards,
Sushil Kumar

Here you go two 2MiB raw 8 bit files inside the /tmp/ directory...
Longhand OSX 10.7.5, default bash terminal...

Last login: Fri Sep 25 18:13:54 on ttys000
AMIGA:barrywalker~> n=1
AMIGA:barrywalker~> dd if=/dev/urandom of=/tmp/audio$n.raw bs=65536 count=32
32+0 records in
32+0 records out
2097152 bytes transferred in 0.139460 secs (15037650 bytes/sec)
AMIGA:barrywalker~> ls -l /tmp/
total 4096
-rw-r--r--  1 barrywalker  wheel  2097152 25 Sep 18:19 audio1.raw
drwx------  3 barrywalker  wheel      102 25 Sep 17:59 launch-3cbyC8
drwx------  3 barrywalker  wheel      102 25 Sep 17:59 launch-AW6HFF
drwx------  3 barrywalker  wheel      102 25 Sep 17:59 launch-tIudW3
drwx------  3 barrywalker  wheel      102 25 Sep 17:59 launch-vbq4iY
drwx------  3 barrywalker  wheel      102 25 Sep 17:59 launchd-115.cw4TfC
drwx------  3 _spotlight   wheel      102 25 Sep 18:14 launchd-204.CisNkR
AMIGA:barrywalker~> n=2
AMIGA:barrywalker~> dd if=/dev/urandom of=/tmp/audio$n.raw bs=65536 count=32
32+0 records in
32+0 records out
2097152 bytes transferred in 0.137951 secs (15202137 bytes/sec)
AMIGA:barrywalker~> ls -l /tmp/
total 8192
-rw-r--r--  1 barrywalker  wheel  2097152 25 Sep 18:19 audio1.raw
-rw-r--r--  1 barrywalker  wheel  2097152 25 Sep 18:23 audio2.raw
drwx------  3 barrywalker  wheel      102 25 Sep 17:59 launch-3cbyC8
drwx------  3 barrywalker  wheel      102 25 Sep 17:59 launch-AW6HFF
drwx------  3 barrywalker  wheel      102 25 Sep 17:59 launch-tIudW3
drwx------  3 barrywalker  wheel      102 25 Sep 17:59 launch-vbq4iY
drwx------  3 barrywalker  wheel      102 25 Sep 17:59 launchd-115.cw4TfC
drwx------  3 _spotlight   wheel      102 25 Sep 18:14 launchd-204.CisNkR
AMIGA:barrywalker~> _

I have no idea what kind of disk thrashing would occur with 20GiB worth of junk data being written to it, nor how long it would take, HOWEVER......
You use this method at your own risk and myself this site hold no responsibility for any adverse effects using this method...

Thanks for your prompt reply,

I have created 4 sample ".raw" file with n={1,2,3,4} at my unix box and copy it using winscp to windows machine. i tried to listen the ".raw" file but it is not audible. I used vlc media player to listen the ".raw" file.

suk@pabet-xmdevc105:~/audio$ ls -ltr
total 8192
-rw-r--r-- 1 root root 2097152 Sep 28 09:51 audio1.raw
-rw-r--r-- 1 root root 2097152 Sep 28 09:51 audio2.raw
-rw-r--r-- 1 root root 2097152 Sep 28 09:51 audio3.raw
-rw-r--r-- 1 root root 2097152 Sep 28 09:51 audio4.raw

Is their anything i have to do to make it audible. I just want to make sure the file is "audio" file.

With Thanks & Regards,
Sushil Kumar

Do you have e.g. aplay on your *nix machine? What happens if you aplay audio1.raw ?

Hi RudiC,
I only use terminal@Ubuntu Linux Virtual Machine. I tried to run at the terminal and it showed "Playing raw data 'audio1.raw' : Unsigned 8 bit, Rate 8000 Hz, Mono" as output.

suk@pabet-xmdevc105:~/audio$ aplay audio1.raw
Playing raw data 'audio1.raw' : Unsigned 8 bit, Rate 8000 Hz, Mono

Can i winscp and hear these audio files with any other audio player at windows machine if not "VLC Media player"

Regards,
Sushil kumar

If you have CygWin installed then:-

 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!

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?

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

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

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

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

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

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

#!/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...