banner

Package Documentation

Disclaimer: This page is not made for phones

Please note that the documentation is just a prettier (and maybe better) version of the docstrings of the following classes


Here you will learn about the specifications of the sine python package's provided functions and classes


The SineFile Class

sine.SineFile

A class representing a .sine file containing the properties as declared by the file and ways to play, and save the file


Constructor arguments:

sine.SineFile(path: str)
  • path: The path to your .sine file

Properties:

  • text_content: str : The file's raw content
  • reapeat: int : How many times the file will repeat
  • wave_type: str : The type of wave that's being played
  • sample_rate: int : The sample rate of the file
  • notes: list[tuple] : The frequency-duration pairs
  • audio: WaveForm : The raw audio in a WaveForm object

Methods:

  • play(self) : Play the file
  • save_to_wav(self, filename: str) : Save the audio to a .wav file
  • save_to_sine(self, filename: str) : Save the text content to a .sine file

The WaveForm class

sine.WaveForm

A class that stores audio waves such as sine, square, and others, containing the raw audio data, where you can save and play the wave.

Note: The class isn't mean't to be used unless you know what you are doing


Constructor's arguments:

sine.WaveForm(wave_type: str, *args: Any, sample_rate: int)
  • wave_type: Either "sine", "square", "saw", "tri" or "custom", it's the waveform that is being played.
  • *args: If the wave type is not "custom", the arguments are: frequency (in hz) and duration (in ms), if it is "custom", then the argument is just the audo data.
  • sample_rate: Sets the sample rate attribute (the sample rate is the number of samples played by second)

Properties:

  • audio_data: NDArray : The audio of the waveform
  • sample_rate: int : The number of audio samples per second (usually 48 000 or 44 100)

Methods:

  • play_audio(self) : Play the audio
  • save_audio(self, filename: str) : Save the audio to a .wav file

Dependencies: numpy, scipy, sounddeice