Sign in Join
Wiki copytemporary

macOS Sound Utilities: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11*(macOS only)*
22
33## Sound Utilities
44
55Every Apple computer running macOS comes with several little-known, command-line sound utilities which can come in very handy when you are experimenting with audio files.
66
77### afinfo
88
99The Audio File Info utility prints out information about an audio file to stdout. It will display the file format, the data format, the bit rate and other useful information.
1010
1111Open an Applications \> Utilities \> Terminal and run the following command:
1212
1313``` bash
1414afinfo '/Applications/iPhoto.app/Contents/Resources/Music/Minuet in G.mp3'
1515```
1616
1717which should provide output similar to:
1818
19-` File:           /Applications/iPhoto.app/Contents/Resources/Music/Minuet in G.mp3 `\
20-` File type ID:   MPG3`\
21-` Num Tracks:     1`\
22-` ----`\
23-` Data format:     2 ch,  44100 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame`\
24-`               no channel layout.`\
25-` estimated duration: 90.357550 sec`\
26-` audio bytes: 1807151`\
27-` audio packets: 3459`\
28-` bit rate: 160000 bits per second`\
29-` packet size upper bound: 1052`\
30-` maximum packet size: 523`\
31-` audio data file offset: 0`\
32-` optimized`\
33-` ----`
19+``` pascal
20+ File: /Applications/iPhoto.app/Contents/Resources/Music/Minuet in G.mp3
21+ File type ID: MPG3
22+ Num Tracks: 1
23+ ----
24+ Data format: 2 ch, 44100 Hz, '.mp3' (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame
25+ no channel layout.
26+ estimated duration: 90.357550 sec
27+ audio bytes: 1807151
28+ audio packets: 3459
29+ bit rate: 160000 bits per second
30+ packet size upper bound: 1052
31+ maximum packet size: 523
32+ audio data file offset: 0
33+ optimized
34+ ----
35+```
3436
3537As you can see, the output of afinfo provides a wealth of information about the audio file.
3638
3739### afplay
3840
3941The Audio File Play utility plays an audio file to the default audio output. The volume, time, quality and playback rate can be set.
4042
4143Open an Applications \> Utilities \> Terminal and run the following command which sets the utility to play the specified file for 10 seconds at 50% volume and high quality:
4244
4345``` bash
4446afplay -t 10 -v 0.5 -q high '/Applications/iPhoto.app/Contents/Resources/Music/Minuet in G.mp3'
4547```
4648
4749The afplay utility is particularly useful when experimenting with compressing a file at different bit rates and listening to how the result sounds.
4850
4951### afconvert
5052
5153This perhaps the most useful of the three command-line utilities. Audio File Convert will convert a source audio file to a new audio file with the specified file and data types. These are the basic arguments:
5254
53-`afconvert -d [out data format] -f [out file format] [in file] [out file]`
55+```text
56+afconvert -d [out data format] -f [out file format] [in file] [out file]
57+```
5458
5559There are other possible arguments, open a Terminal and enter the following to detail the full list of arguments:
5660
57-`afconvert -h`
61+```text
62+afconvert -h
63+```
5864
5965It supports the following audio data and file formats:
6066
61-`   '3gpp' = 3GP Audio (.3gp)`\
62-`              data_formats: 'Qclp' 'aac ' 'aace' 'aacf' 'aacg' 'aach' `\
63-`                            'aacl' 'aacp' 'samr' `\
64-`   '3gp2' = 3GPP-2 Audio (.3g2)`\
65-`              data_formats: 'Qclp' 'aac ' 'aace' 'aacf' 'aacg' 'aach' `\
66-`                            'aacl' 'aacp' 'samr' `\
67-`   'adts' = AAC ADTS (.aac, .adts)`\
68-`              data_formats: 'aac ' 'aach' 'aacp' `\
69-`   'ac-3' = AC3 (.ac3)`\
70-`              data_formats: 'ac-3' `\
71-`   'AIFC' = AIFC (.aifc, .aiff, .aif)`\
72-`              data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 UI8 'ulaw' `\
73-`                            'alaw' 'MAC3' 'MAC6' 'ima4' 'QDMC' 'QDM2' `\
74-`                            'Qclp' 'agsm' `\
75-`   'AIFF' = AIFF (.aiff, .aif)`\
76-`              data_formats: I8 BEI16 BEI24 BEI32 `\
77-`   'amrf' = AMR (.amr)`\
78-`              data_formats: 'samr' 'sawb' `\
79-`   'm4af' = Apple MPEG-4 Audio (.m4a, .m4r)`\
80-`              data_formats: 'aac ' 'aace' 'aacf' 'aacg' 'aach' 'aacl' `\
81-`                            'aacp' 'ac-3' 'alac' 'ec-3' 'paac' 'pac3' `\
82-`                            'pec3' `\
83-`   'm4bf' = Apple MPEG-4 AudioBooks (.m4b)`\
84-`              data_formats: 'aac ' 'aace' 'aacf' 'aacg' 'aach' 'aacl' `\
85-`                            'aacp' 'paac' `\
86-`   'caff' = CAF (.caf)`\
87-`              data_formats: '.mp1' '.mp2' '.mp3' 'QDM2' 'QDMC' 'Qclp' `\
88-`                            'Qclq' 'aac ' 'aace' 'aacf' 'aacg' 'aach' `\
89-`                            'aacl' 'aacp' 'ac-3' 'alac' 'alaw' 'drms' `\
90-`                            'dvi8' 'ec-3' 'flac' 'ilbc' 'ima4' I8 BEI16 `\
91-`                            BEI24 BEI32 BEF32 BEF64 LEI16 LEI24 LEI32 `\
92-`                            LEF32 LEF64 'ms\x00\x02' 'ms\x00\x11' 'ms\x001' `\
93-`                            'opus' 'paac' 'pac3' 'pec3' 'qaac' 'qac3' `\
94-`                            'qach' 'qacp' 'qec3' 'samr' 'ulaw' 'zaac' `\
95-`                            'zac3' 'zach' 'zacp' 'zec3' `\
96-`   'ec-3' = EC3 (.ec3)`\
97-`              data_formats: 'ec-3' `\
98-`   'flac' = FLAC (.flac)`\
99-`              data_formats: 'flac' `\
100-`   'MPG1' = MPEG Layer 1 (.mp1, .mpeg, .mpa)`\
101-`              data_formats: '.mp1' `\
102-`   'MPG2' = MPEG Layer 2 (.mp2, .mpeg, .mpa)`\
103-`              data_formats: '.mp2' `\
104-`   'MPG3' = MPEG Layer 3 (.mp3, .mpeg, .mpa)`\
105-`              data_formats: '.mp3' `\
106-`   'mp4f' = MPEG-4 Audio (.mp4)`\
107-`              data_formats: 'aac ' 'aace' 'aacf' 'aacg' 'aach' 'aacl' `\
108-`                            'aacp' 'ac-3' 'ec-3' `\
109-`   'NeXT' = NeXT/Sun (.snd, .au)`\
110-`              data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 'ulaw' `\
111-`   'Sd2f' = Sound Designer II (.sd2)`\
112-`              data_formats: I8 BEI16 BEI24 BEI32 `\
113-`   'WAVE' = WAVE (.wav)`\
114-`              data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 'ulaw' `\
115-`                            'alaw' `\
116-`   'RF64' = WAVE (.wav)`\
117-`              data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 'ulaw' `\
118-`                            'alaw`
67+```text
68+ '3gpp' = 3GP Audio (.3gp)
69+ data_formats: 'Qclp' 'aac ' 'aace' 'aacf' 'aacg' 'aach'
70+ 'aacl' 'aacp' 'samr'
71+ '3gp2' = 3GPP-2 Audio (.3g2)
72+ data_formats: 'Qclp' 'aac ' 'aace' 'aacf' 'aacg' 'aach'
73+ 'aacl' 'aacp' 'samr'
74+ 'adts' = AAC ADTS (.aac, .adts)
75+ data_formats: 'aac ' 'aach' 'aacp'
76+ 'ac-3' = AC3 (.ac3)
77+ data_formats: 'ac-3'
78+ 'AIFC' = AIFC (.aifc, .aiff, .aif)
79+ data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 UI8 'ulaw'
80+ 'alaw' 'MAC3' 'MAC6' 'ima4' 'QDMC' 'QDM2'
81+ 'Qclp' 'agsm'
82+ 'AIFF' = AIFF (.aiff, .aif)
83+ data_formats: I8 BEI16 BEI24 BEI32
84+ 'amrf' = AMR (.amr)
85+ data_formats: 'samr' 'sawb'
86+ 'm4af' = Apple MPEG-4 Audio (.m4a, .m4r)
87+ data_formats: 'aac ' 'aace' 'aacf' 'aacg' 'aach' 'aacl'
88+ 'aacp' 'ac-3' 'alac' 'ec-3' 'paac' 'pac3'
89+ 'pec3'
90+ 'm4bf' = Apple MPEG-4 AudioBooks (.m4b)
91+ data_formats: 'aac ' 'aace' 'aacf' 'aacg' 'aach' 'aacl'
92+ 'aacp' 'paac'
93+ 'caff' = CAF (.caf)
94+ data_formats: '.mp1' '.mp2' '.mp3' 'QDM2' 'QDMC' 'Qclp'
95+ 'Qclq' 'aac ' 'aace' 'aacf' 'aacg' 'aach'
96+ 'aacl' 'aacp' 'ac-3' 'alac' 'alaw' 'drms'
97+ 'dvi8' 'ec-3' 'flac' 'ilbc' 'ima4' I8 BEI16
98+ BEI24 BEI32 BEF32 BEF64 LEI16 LEI24 LEI32
99+ LEF32 LEF64 'ms\x00\x02' 'ms\x00\x11' 'ms\x001'
100+ 'opus' 'paac' 'pac3' 'pec3' 'qaac' 'qac3'
101+ 'qach' 'qacp' 'qec3' 'samr' 'ulaw' 'zaac'
102+ 'zac3' 'zach' 'zacp' 'zec3'
103+ 'ec-3' = EC3 (.ec3)
104+ data_formats: 'ec-3'
105+ 'flac' = FLAC (.flac)
106+ data_formats: 'flac'
107+ 'MPG1' = MPEG Layer 1 (.mp1, .mpeg, .mpa)
108+ data_formats: '.mp1'
109+ 'MPG2' = MPEG Layer 2 (.mp2, .mpeg, .mpa)
110+ data_formats: '.mp2'
111+ 'MPG3' = MPEG Layer 3 (.mp3, .mpeg, .mpa)
112+ data_formats: '.mp3'
113+ 'mp4f' = MPEG-4 Audio (.mp4)
114+ data_formats: 'aac ' 'aace' 'aacf' 'aacg' 'aach' 'aacl'
115+ 'aacp' 'ac-3' 'ec-3'
116+ 'NeXT' = NeXT/Sun (.snd, .au)
117+ data_formats: I8 BEI16 BEI24 BEI32 BEF32 BEF64 'ulaw'
118+ 'Sd2f' = Sound Designer II (.sd2)
119+ data_formats: I8 BEI16 BEI24 BEI32
120+ 'WAVE' = WAVE (.wav)
121+ data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 'ulaw'
122+ 'alaw'
123+ 'RF64' = WAVE (.wav)
124+ data_formats: UI8 LEI16 LEI24 LEI32 LEF32 LEF64 'ulaw'
125+ 'alaw
126+```
119127
120128For example, this converts the .mp3 file into a .wav file using the Little Endian, 16 bit integer data format:
121129
122130``` bash
123131afconvert -f RF64 -d LEI16 '/Applications/iPhoto.app/Contents/Resources/Music/Minuet in G.mp3' test.wav
124132```
125133
126134## See also
127135
128136- [[macOS Audio Player]]
129137- [[macOS Audio Recorder]]
130138- [[macOS Play Alert Sound|macOS System Sound Services]]
131139- [[macOS NSSound]]
132140- [[Multimedia Programming]]
133141
134142---
135143*From the Free Pascal wiki, page "macOS Sound Utilities", as it stood on 2020-05-08 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
136144Category: Audio
137145Category: Multimedia
138146Category: macOS

Back to history