banner

Using Sine

Disclaimer: This page is not made for phones


1: Install the sine package

Currently, the package is not available in pypi, so to install, you have to type the command pip install .


2: Create your first .sine file

To create a sine file, you need to use the sinemake.py command. Below is the help for sinemake.py since it has a lot of arguments:

usage: sinemake.py [-h] notes output repeat samplerate wavetype

Create sine files by specifying frequencies with a specific syntax. (Sine is a file format for creating frequency-duration pairs)

positional arguments:
notes       The content of the sine file, use the syntax: '[frequency (hz)]-[duration (ms)] [frequency (hz)]-[duration (ms)] ...'
output      Name of the sine file
repeat      How many times will the audio repeat (if only once, just type 1)
samplerate  The audio's sample rate (usually 44100hz or 48000hz)
wavetype    Waveform used for the file (either sine, square, saw and tri)

options:
-h, --help show this help message and exit

For more help, please visit the documentation

And here's an example, the nokia tune:

sinemake.py "164-125 146-125 92-250 102-250 138-125 122-125 72-250 82-250 122-125 110-125 68-250 82-250 110-500 0-500" nokia.sine 2 48000 square

3: Read a .sine file

You can use the command line tool sineread.py or use the package:

Package:

import sine
file = sine.SineFile("path/to/your/sine_file.sine")
file.play()

CLI tool:

python sineread.py "path/to/your/sine_file.sine"

4: Convert a .sine file to a .wav file

Again, you can use the package or use sinesave.py

Package:

import sine
file = sine.SineFile("path/to/your/sine_file.sine")
file.save_to_wav("path/to/your/wav_file.wav")

CLI tool:

python sinesave.py "path/to/your/sine_file.sine" "path/to/your/wav_file.wav"