spectrographic package¶
Submodules¶
spectrographic.base module¶
-
class
spectrographic.base.
ColumnToSound
(duration: int, sample_rate: int = 44100, min_freq: int = 10000, max_freq: int = 17000, y_resolution: int = 1000, num_tones: int = 3, contrast: float = 5)[source]¶ Bases:
object
Class to turn grey-scale image columns into a sound.
It takes a numpy array of grey intensities (in the range 0 to 1) of length Y_RESOLUTION and turns them into a DURATION seconds long sound in the frequency range between MIN_FREQ and MAX_FREQ.
- Parameters
{int} -- Duration of sound in seconds (duration) –
- Keyword Arguments
{int} -- Sample rate of sound (default (sample_rate) – {44100})
{int} -- Minimal frequency in the spectrograph (min_freq) –
(default – {10000})
{int} -- Maximal frequency in the spectrograph (max_freq) –
(default – {17000})
{int} -- Number of pixels to plot (default (y_resolution) – {1000})
{int} -- Number of tones to use to fill out each pixel (num_tones) –
(default – {3})
{float} -- Contrast between loud and quiet pixels (contrast) –
(default – {5})
-
gen_soundwall
(column: numpy.ndarray)[source]¶ Takes a column of pixels and generates the sound wall.
[description]
- Parameters
{np.ndarray} -- Y_RESOLUTION long column of (column) –
pixels (values between 0 and 1) –
- Returns
np.ndarray – soundwall
-
pixel_to_sound
(y: int, intensity: float = 1)[source]¶ Takes a pixel in a imagae column at the y’th position from the top and turns it into a sound at a corresponding position in the spectrum.
[description]
- Parameters
{int} -- position of pixel in column from the top. (y) –
- Keyword Arguments
{float} -- [description] (default (intensity) – {1})
- Returns
np.ndarray – sound array
- Raises
ValueError –
-
class
spectrographic.base.
SpectroGraphic
(path: pathlib.Path, height: int = 100, duration: int = 20, min_freq: int = 1000, max_freq: int = 8000, sample_rate: int = 44100, num_tones: int = 3, contrast: float = 5, use_black_and_white: bool = False)[source]¶ Bases:
object
Takes an image file and creates a sound that draws that image on a spectrogram.
[description] :param path {Path} – Path to file (e.g.: {“./data/python.png”})
- Keyword Arguments
{int} -- y-resolution in spectrogram (default (height) – {100})
{int} -- duration of sound in seconds (default (duration) – {20})
{int} -- minimal freq. for image (default (min_freq) – {1000})
{int} -- maximal freq. for image (default (max_freq) – {8000})
{int} -- Sample rate (default (sample_rate) – {44100})
{int} -- Number of tones to used to fill in each pixel (num_tones) –
(default – {3})
{float} -- Contrast between loud and quiet pixels (contrast) –
(default – {5})
-
save
(wav_file: pathlib.Path = 'SpectroGraphic.wav')[source]¶ saves the spectrographic to a .wav file
We use the wavio module
-
property
sound_array
¶
spectrographic.cli module¶
This is a skeleton file that can serve as a starting point for a Python console script. To run this script uncomment the following lines in the [options.entry_points] section in setup.cfg:
- console_scripts =
spectrographic = spectrographic.cli:run
Then run python setup.py install which will install the command spectrographic inside your current environment.
-
spectrographic.cli.
main
(args)[source]¶ Main entry point allowing external calls
- Parameters
args ([str]) – command line parameter list