I want to create simple tones from Python and identify exact frequencies, including microtonal pitches. Ideally, I'd like to specify the frequency directly in hertz, though using MIDI with cent-based detuning would also work. Reverb is optional. What libraries or approaches are suitable for generating these tones, either offline or in real time?
3 Answers
If you need immediate playback, simpleaudio can play NumPy-generated audio buffers. You can calculate the waveform using any frequency in hertz, so microtonal values are straightforward. Just keep in mind that Python may not be ideal for tightly timed, low-latency audio processing.
For real-time audio, you may want to use a dedicated audio tool or a language better suited to low-latency processing, with Python controlling it when necessary. For a basic project, though, generating tones with NumPy and playing or exporting them afterward should be plenty. MIDI is optional—you only need it if you want to integrate with MIDI hardware or software.
For offline sound generation, NumPy works well for calculating a sine wave at any exact frequency, and a library such as SoundFile can write the resulting samples to a WAV file. This gives you direct control over the frequency without involving MIDI.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically