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:
seconds (duration {int} -- Duration of sound in) –
- Keyword Arguments:
(default (y_resolution {int} -- Number of pixels to plot) – {44100})
spectrograph (max_freq {int} -- Maximal frequency in the) –
(default – {10000})
spectrograph –
(default – {17000})
(default – {1000})
pixel (num_tones {int} -- Number of tones to use to fill out each) –
(default – {3})
pixels (contrast {float} -- Contrast between loud and quiet) –
(default – {5})
- gen_soundwall(column: ndarray)[source]¶
Takes a column of pixels and generates the sound wall.
[description]
- Parameters:
of (column {np.ndarray} -- Y_RESOLUTION long 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:
top. (y {int} -- position of pixel in column from the) –
- Keyword Arguments:
(default (intensity {float} -- [description]) – {1})
- Returns:
np.ndarray – sound array
- Raises:
ValueError –
- class spectrographic.base.SpectroGraphic(path: 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:
(default (sample_rate {int} -- Sample rate) – {100})
(default – {20})
(default – {1000})
(default – {8000})
(default – {44100})
pixel (num_tones {int} -- Number of tones to used to fill in each) –
(default – {3})
pixels (contrast {float} -- Contrast between loud and quiet) –
(default – {5})
- save(wav_file: 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