macOS Sound Utilities: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: macOS Sound Utilities
| Old | New | Line | |
|---|---|---|---|
| 1 | + | *(macOS only)* | |
| 2 | + | ||
| 3 | + | ## Sound Utilities | |
| 4 | + | ||
| 5 | + | Every 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. | |
| 6 | + | ||
| 7 | + | ### afinfo | |
| 8 | + | ||
| 9 | + | The 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. | |
| 10 | + | ||
| 11 | + | Open an Applications \> Utilities \> Terminal and run the following command: | |
| 12 | + | ||
| 13 | + | ``` bash | |
| 14 | + | afinfo '/Applications/iPhoto.app/Contents/Resources/Music/Minuet in G.mp3' | |
| 15 | + | ``` | |
| 16 | + | ||
| 17 | + | which should provide output similar to: | |
| 18 | + | ||
| 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 | + | ` ----` | |
| 34 | + | ||
| 35 | + | As you can see, the output of afinfo provides a wealth of information about the audio file. | |
| 36 | + | ||
| 37 | + | ### afplay | |
| 38 | + | ||
| 39 | + | The Audio File Play utility plays an audio file to the default audio output. The volume, time, quality and playback rate can be set. | |
| 40 | + | ||
| 41 | + | Open 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: | |
| 42 | + | ||
| 43 | + | ``` bash | |
| 44 | + | afplay -t 10 -v 0.5 -q high '/Applications/iPhoto.app/Contents/Resources/Music/Minuet in G.mp3' | |
| 45 | + | ``` | |
| 46 | + | ||
| 47 | + | The afplay utility is particularly useful when experimenting with compressing a file at different bit rates and listening to how the result sounds. | |
| 48 | + | ||
| 49 | + | ### afconvert | |
| 50 | + | ||
| 51 | + | This 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: | |
| 52 | + | ||
| 53 | + | `afconvert -d [out data format] -f [out file format] [in file] [out file]` | |
| 54 | + | ||
| 55 | + | There are other possible arguments, open a Terminal and enter the following to detail the full list of arguments: | |
| 56 | + | ||
| 57 | + | `afconvert -h` | |
| 58 | + | ||
| 59 | + | It supports the following audio data and file formats: | |
| 60 | + | ||
| 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` | |
| 119 | + | ||
| 120 | + | For example, this converts the .mp3 file into a .wav file using the Little Endian, 16 bit integer data format: | |
| 121 | + | ||
| 122 | + | ``` bash | |
| 123 | + | afconvert -f RF64 -d LEI16 '/Applications/iPhoto.app/Contents/Resources/Music/Minuet in G.mp3' test.wav | |
| 124 | + | ``` | |
| 125 | + | ||
| 126 | + | ## See also | |
| 127 | + | ||
| 128 | + | - [[macOS Audio Player]] | |
| 129 | + | - [[macOS Audio Recorder]] | |
| 130 | + | - [[macOS Play Alert Sound|macOS System Sound Services]] | |
| 131 | + | - [[macOS NSSound]] | |
| 132 | + | - [[Multimedia Programming]] | |
| 133 | + | ||
| 134 | + | --- | |
| 135 | + | *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).* | |
| 136 | + | Category: Audio | |
| 137 | + | Category: Multimedia | |
| 138 | + | Category: macOS |
