Command Line Audio Players/Recorders

Hi guys and gals...
22-01-2025.
Apologies for typos, etc...

It's your resident amateur here...
Those of you who know of me also know what I do, but those that don't here is a quick run down.

  1. My platform of choice is the stock AMIGA A1200(HD), with a 4MB expansion card.
  2. My code can be considered naive in some cases because of number 1).
  3. The stock AMIGA A1200(HD) only has Python Version 1.4.0, C compilers to C89, a g++ compiler C++98, Perl Version 5.7x and other oldies.
  4. ADE, the AMIGA A1200(HD) UNIX style emulator, has gcc/g++ Version 2.95.3 and ksh88 as its shell.
  5. My fully expanded AMIGA has Python Version 2.0.1, which makes life a little easier for Python code.
  6. I write the code to work, not only on the AMIGA but current platforms too, WITHOUT ANY MODIFICATION......
  7. ......hence its naivety. This is by far, FAR, more difficult than you can imagine.
  8. I will be posting some of my code for your usage on here...
  9. REMEMBER! The AMIGA does NOT have the luxuries of current libraries hence the long hand naivety of my code.
  10. And finally, I needed different command line audio players and recorders so I Have created a compilation of many and their command line usage all in one place.

Hope you all enjoy my coding escapades...
Bazza, wisecracker, G0LCU.

*****************************************************************************
Command line players and recorders for ".RAW and/or .WAV" files.
ALL are fully non-verbose unless otherwise stated...
*****************************************************************************
*****************************************************************************
AMIGA A1200(HD), OS3.0x, default shell, 4MB RAM with clock expansion minimum:

Play16, inside the C: VOLUME or path:
	[RUN >NIL:] Play16 [VOLUME:path/to/]wavefile.wav QUIET
	""" ANY single channel mono, 8 bit unsigned integer, 8000sps file. """
	[RUN >NIL:] Play16 RAW [VOLUME:path/to/]wavefile.wav TRACKS=1 BITS=8 UNSIGNED FREQ=8000 QUIET
	""" Play16 can do a limited number of other old file formats too. """
	""" Using ADE the *NIX emulator and ksh88 shell. """
	/C/Play16 RAW [/full/path/to/]wavefile.wav TRACKS=1 BITS=8 UNSIGNED FREQ=8000 QUIET [&]

*****************************************************************************
Windows 8.0, and above command line methods:

WMP:
	From at least Windows Vista:
	[start] wmplayer [C:\full\path\to\]wavefile.wav [> NUL]
VLC:
	Windows 8.0 and 8.1:
	cd "C:\Program Files\VideoLAN\VLC\"
	Windows 10 and up:
	cd "C:\Program Files (x86)\VideoLAN\VLC\"
	Windows 8.0 and above:
	[start] vlc.exe --verbose 0 --intf dummy --quiet [DRIVE_LETTER:\path\to\]wavefile.wav vlc://quit > NUL
FFMPEG Suite, ffplay, UNTESTED:
	[start] ffplay -autoexit -nodisp -loglevel quiet -stats [DRIVE_LETTER:\path\to\]wavefile.wav > NUL

*****************************************************************************
Apple terminal, up to and including OSX 10.15.7:

AFPLAY:
	""" This player CANNOT play '.raw' audio files! """
	afplay -q 1 [/full/path/to/]wavefile.wav > /dev/null 2>&1 [&]
VLC:
	(alias vlc='/Applications/VLC.app/Contents/MacOS/VLC')
	vlc --verbose 0 --intf dummy --quiet [/full/path/to/]wavefile.wav vlc://quit > /dev/null 2>&1 [&]
Sound eXchange, Version 14.4.2, "SoX":
	sox -q -V0 [/full/path/to/]wavefile.wav -d [> /dev/null 2>&1] [&]

*****************************************************************************
GNU/Linux Mint, and other "*NIX" type terminals:

ALSA:
	aplay -q [/full/path/to/]wavefile.wav [> /dev/null 2>&1] [&]
PulseAudio:
	""" There is no timeout option for 'paplay'! See IMPORTANT NOTES. """
	paplay [/full/path/to/]wavefile.wav [> /dev/null 2>&1] [&]
music123:
	""" A tiny Linux Mint package that does what it says on the tin! """
	music123 -q [/full/peth/to/]wavefile.wav [> /dev/null 2>&1] [&]
Sound eXchange, "SoX":
	""" Not been updated since 2016! """
	sox -q -V0 [/full/path/to/]wavefile.wav -d [> /dev/null 2>&1] [&]
FFMPEG Suite, ffplay:
	ffplay -autoexit -nodisp -loglevel quiet -stats [/full/path/to/]wavefile.wav > /dev/null 2>&1 [&]
VLC:
	""" NOT, fully non-verbose when in "run in background" mode! """
	vlc --verbose 0 --intf dummy --quiet [/full/path/to/]wavefile.wav vlc://quit > /dev/null 2>&1 [&]
OSS '/dev/dsp' and PulseAudio 'padsp' no timeout facility! See IMPORTANT NOTES:
	""" limited to unsigned 8 bit integer, 8000sps, single channel mono, ".RAW and .WAV" files ONLY! """
	cat [/full/path/to/]wavefile.wav > /dev/dsp [&]
	padsp cat [/full/path/to/]wavefile.wav | padsp tee /dev/dsp > /dev/null 2>&1 [&]

#############################################################################
#############################################################################

Command line recorders, almost any format, ".RAW and .WAV" examples.
--------------------------------------------------------------------

AMIGA, ANY Classic Version:
	Entirely dependent on a proprietary sound card or parallel port sound
	sampler.
	MONO sound samplers are/were available for AMIGA OS1.3x, STEREO for
	a stock AMIGA A1200(HD) OS3.0x.

*****************************************************************************
Windows command line methods:

Windows 7, and earlier:
SOUNDRECORDER:
	""" SoundRecorder.exe, CD quality ".WAV" format ONLY: """
	[start] SoundRecorder.exe /FILE [DRIVE_LETTER:\path\to\]wavefile.wav /DURATION HHHH:MM:SS [> NUL]
Windows 8.0 and up:
FFMPEG:
	"""
	The following captures 5 seconds of audio and saves it as a .WAV
	file, DEVICE_NAME is a placeholder for the name of the device
	reported by DirectShow, (dshow), found using:
	ffmpeg -list_devices true -f dshow -i dummy
	"""
	[start] ffmpeg -f dshow -i audio="DEVICE_NAME" -t 5 wavefile.wav [> NUL]

*****************************************************************************
GNU/Linux Mint, and other "*NIX" terminals:

ALSA:
	arecord -d 1 -c 1 -f U8 -r 8000 -t raw [/full/path/to/]wavefile.raw > /dev/null 2>&1 [&]
FFMPEG:
	""" ffmpeg; force alsa; input is default; 5 second timer... """
	ffmpeg -f alsa -i default -t 5 [/full/path/to]wavefile.wav [> /dev/null 2>&1] [&]
	""" ffmpeg -f alsa -i default -t 5 -ac 1 -ar 8000 -c:a pcm_u8 [/full/path/to/]wavefile.wav [> /dev/null 2>&1] [&] """
PulseAudio:
	parec --rate=8000 --format=u8 --channels=1 --raw > /path/to/file.raw [> /dev/null 2>&1] [&]
FFMPEG:
	""" '-f force pulse' in this version. """
	ffmpeg -f pulse -i default -t 5 [/full/path/to/wavefile.wav [> /dev/null 2>&1] [&]
	""" ffmpeg -f pulse -i default -t 5 -ac 1 -ar 8000 -c:a pcm_u8 [/full/path/to/]wavefile.wav [> /dev/null 2>&1] [&] """

*****************************************************************************
Apple terminal, up to and including OSX 10.15.7, Intel silicon:

""" ALL three methods have file lengths that are five seconds long! """ 
Sound eXchange, Version 14.4.2, "SoX":
	sox  -q -V0 -d -t raw -r 8000 -b 8 -c 1 -e unsigned-integer -> [/full/path/to/]wavefile.raw trim 0 00:05
FFMPEG:
	ffmpeg -f avfoundation -i ":0" -t 5 [/full/path/to/]wavefile.wav
Quicktime Player, OPTIONAL, crude and slow, but it KIND OF works:
"""
osascript << AppleSampler
	tell application "QuickTime Player"
		activate
		set savePath to "Macintosh HD:Users:" & "${USER}" & ":Music:" & "Untitled.m4a"
		set recording to new audio recording
		set visible of front window to false
		delay 2
		start recording
		delay 5
		stop recording
		export document "Untitled" in file savePath using settings preset "Audio Only"
		close (every document whose name contains "Untitled") saving no
		tell application "System Events" to click menu item "Hide Export Progress" of menu "Window" of menu bar 1 of process "QuickTime Player"
		delay 1
		quit
	end tell
AppleSampler
"""

*****************************************************************************
*****************************************************************************

                          !!! IMPORTANT NOTES. !!!
                          ------------------------

1) There may be typos and errors so I apologise for any.
   I have checked and rechecked to make sure everything is correct.
2) Developers of serious applications can and often do get 'application
   fatigue' and can abandon their prize pieces because OS updates and
   upgrades can break their applications.
   So as of January 2025, all of these are working up to the OS Versions
   shown OR CURRENT as of the above date.
3) SoX looks like it has not been updated since Version 14.4.2.
4) QuickTime Player was a hack for AudioScope.sh, and was SSLLOOWW.
5) 'ffmpeg|ffplay' could be used for just about any current platform and the
   main command line flags/switches for a recorded '.wav' file should be
   enough information.
6) Some of the commands will NOT have a timeout limit facility so a 'timeout'
   command will need to be used, especially when recording.
   If there is no 'timeout' command this is an alternative, limited, POSIX
   version:
   """
   # A timeout function for OSes that don't have it, like APPLE OSX and
   # 'paplay'; for example:
   # time_out 4 'paplay [/full/path/to/]WAVEFILE.wav'
   # NOTE: the single quotes in the line above.
   time_out()
   {
	eval "${2} &"; sleep "${1}"; kill $! > /dev/null 2>&1;
   }
   """
   Otherwise you will have to rely on Ctrl-C to escape as normal.
7) 'cvlc', (command vlc), is basically no different to vlc itself so I stayed
   with vlc. I have not successfully worked out how to play a RAW audio file
   so you will have to work that out for yourselves.
8) 'ffmpeg' CANNOT do an audio filename with a '.raw' extension! The closest
   for a file with a single channel mono, 8000sps, unsigned 8 bit integer, is
   a '.wav' and will play on a machine with the OSS '/dev/dsp' or PulseAudio
   'padsp'. There are others - '.8svx', '.iff', '.aiff' are but a few of
   AMIGA and APPLE ones.
9) ALL are capable of other formats, so refer to their relevant manuals for
   the codecs they can encode/decode.
10) EXCEPT for the AppleScript version the examples are for RAW and/or WAV
    files; mono, 8000sps, unsigned integer, 1 channel ONLY.
    It doesn't take much effort to change to other formats as you desire.
11) Finally, as an addendum there are also dedicated 'mp3' only players:
    A) AMIGA A1200(HD) with 68040 or higher expansion card, and lots of RAM,
       this is remarkably good for such an ancient platform:
       < https://aminet.net/package/mus/play/MPEGA35 >
       < https://aminet.net/package/util/libs/mpega_library >
    B) Various GNU/Linux favours and both work well, may need to be
       downloaded from the relevant repository:
       mpg123
       mpg321
    C) Also for '.ogg' format, downloaded from the relevant repository:
       ogg123
    D) The above three may be available for other *NIX style platforms too!

*****************************************************************************

				IMPORTANT LEGAL:
				----------------

      This information is issued under the Creative Commons CC0 licence.
                                 PUBLIC DOMAIN.

This site, < https://community.unix.com/ >, and the author will not be held
responsible for any damage to, or loss of, or failure of equipment or data
caused in any way by the use of this information.

There is NO warranty with the use of this information release, and..
             !!! YOU USE THIS INFORMATION AT YOUR OWN RISK !!!

*****************************************************************************
Enjoy...
2022-2025, B.Walker, G0LCU.
Block Code
1 Like