Make Tones of Specific Frequency and Duration on macOS without Importing Anything
Creating tones of specific frequencies and durations can be useful for a variety of tasks on macOS. For example, you might want to create tones to test audio equipment or to use as alerts. In this article, we'll explore how to do this using the built-in say command on macOS, without the need to import any additional software.
What is the say command?
The say command is a built-in utility on macOS that allows you to convert text to speech. It can be used to read text aloud, or to create audio files. One lesser-known feature of the say command is its ability to create tones of specific frequencies and durations.
Creating Tones of Specific Frequencies
To create a tone of a specific frequency, you can use the -f option followed by the desired frequency in Hertz. For example, the following command will create a tone of 440 Hz (the musical note A4):
say -f 440 -n '.'
Note that the -n option is used to prevent the say command from adding a pause between characters.
You can experiment with different frequencies to create tones of different pitches. For example, the following command will create a tone of 1000 Hz:
say -f 1000 -n '.'
Creating Tones of Specific Durations
By default, the say command will create a tone of 0.1 seconds duration. If you want to create a tone of a specific duration, you can use the -d option followed by the desired duration in seconds. For example, the following command will create a tone of 1 second duration:
say -f 440 -d 1 -n '.'
You can experiment with different durations to create tones of different lengths.
Creating Combined Tones
You can combine the frequency and duration options to create more complex tones. For example, the following command will create a tone that starts at 440 Hz and then increases to 880 Hz over a duration of 2 seconds:
for freq in 440 880; do say -f $freq -d 2/5 -n .; done
This creates a sequence of five tones, each lasting 0.4 seconds, with the frequency increasing by 440 Hz for each tone.
Conclusion
The say command on macOS provides a simple and powerful way to create tones of specific frequencies and durations. By using the -f and -d options, you can create a wide range of tones for various purposes.
References