I want to create a series of a low- and high-pitch beeps at fixed times. For example:
- High-pitch beep at 150 ms
- Low-pitch beep at 151 ms
- Low-pitch beep at 200 ms
- High-pitch beep at 250 ms
Is there a way to do this in Ruby or Python? I don't really care what the output encoding is (.wav, .mp3, .ogg, whatever), but I do want to create an output file.
Python:
Looks like you need the winsound module.
Specifically, the function:
Which does what you want. But this is specific to Windows only.
There is a package called beep that allows you to do the same on Linux. So call
beep
usingsubprocess
in case you want to have a Linux based solution to this.Here's some help for Ruby: Adding Sound to Your Ruby Apps. For actually recording a beep from the pc's speaker to a wav/mp3 -- I don't know if that's possible.
For a beep from your sound card (not speaker), in case you ever need that, simply use the Win32API module that comes with Ruby :
Here's a function in Python that makes a file with a single sine wave:
Not the fastest code...But if you don't need speed, it will work fine!
For windows users: use the gem win32-sound
Try out the Ruby Audio File Library (RAFL). It supports:
Here's the GitHub source for the project.