Audio¶
Audio handling and conversion.
- komoog.audio.convert_distance_and_elevation_to_audio(distance, elevation, max_elevation_difference=0, tune='C', sampling_rate=44100, approximate_length_in_seconds=1)[source]¶
Convert a distance/elevation profile to an audio signal.
- Parameters
distance (numpy.ndarray) -- Contains the covered 2D distance in meters.
elevation (numpy.ndarray) -- Contains the corresponding elevation profile in meters
max_elevation_difference (float, default = 0) -- Used to control the level of the audio signal. If this value is
<= 0
, the audio level will always be maximized. If given a positive value, this value will represent the maximum scale of the audio signal. If the elevation profile's elevation difference is larger than this value, the signal will simply be maximized. A good value ismax_elevation_difference = 2000
.Desired frequency of the sound. Can be any of
[ 'C', 'C#', 'Db', 'D', 'D#', 'Eb', 'E', 'F', 'F#', 'Gb', 'G', 'G#', 'Ab', 'A', 'A#', 'Bb', 'B' ]
where
'A'
corresponds to 440Hz.Can also be a frequency in Hz.
sampling_rate (int, default = 44100) -- Sampling rate in Hz
approximate_length_in_seconds (float, default = 1.) -- The desired length of the audio signal in seconds If equal to zero, will return a single loop.
- Returns
audio (numpy.ndarray of numpy.int16) -- The transformed audio signal
sampling_rate (int) -- The sampling rate of the audio signal.
- komoog.audio.convert_distance_and_elevation_to_profile_audio(distance, elevation, max_elevation_difference=0, tune='C', sampling_rate=44100, approximate_length_in_seconds=1)[source]¶
Convert a distance/elevation profile to an audio signal that mimicks the elevation profile.
- Parameters
distance (numpy.ndarray) -- Contains the covered 2D distance in meters.
elevation (numpy.ndarray) -- Contains the corresponding elevation profile in meters
max_elevation_difference (float, default = 0) -- Used to control the level of the audio signal. If this value is
<= 0
, the audio level will always be maximized. If given a positive value, this value will represent the maximum scale of the audio signal. If the elevation profile's elevation difference is larger than this value, the signal will simply be maximized. A good value ismax_elevation_difference = 2000
.Desired frequency of the sound. Can be any of
[ 'C', 'C#', 'Db', 'D', 'D#', 'Eb', 'E', 'F', 'F#', 'Gb', 'G', 'G#', 'Ab', 'A', 'A#', 'Bb', 'B' ]
where
'A'
corresponds to 440Hz.Can also be a frequency in Hz.
sampling_rate (int, default = 44100) -- Sampling rate in Hz
approximate_length_in_seconds (float, default = 1.) -- The desired length of the audio signal in seconds If equal to zero, will return a single loop.
- Returns
audio (numpy.ndarray of numpy.int16) -- The transformed audio signal
sampling_rate (int) -- The sampling rate of the audio signal.
- komoog.audio.convert_distance_and_elevation_to_signal(distance, elevation, max_elevation_difference=0)[source]¶
Convert a distance/elevation profile to a signal, i.e. normalize distance to range [0,1] and y to range [-1,1].
- Parameters
distance (numpy.ndarray) -- Contains the covered 2D distance in meters.
elevation (numpy.ndarray) -- Contains the corresponding elevation profile in meters
max_elevation_difference (float, default = 0) -- Used to control the level of the audio signal. If this value is
<= 0
, the audio level will always be maximized. If given a positive value, this value will represent the maximum scale of the audio signal. If the elevation profile's elevation difference is larger than this value, the signal will simply be maximized. A good value ismax_elevation_difference = 2000
.
- Returns
x (numpy.ndarray) -- covered distance in range [0,1]
y (numpy.ndarray) -- signal in range [-1,1]
- komoog.audio.convert_signal_to_audio(x, y, tune='C', sampling_rate=44100, approximate_length_in_seconds=1)[source]¶
Convert a normalized distance/elevation signal to an audio signal.
- Parameters
distance (numpy.ndarray) -- Contains the covered 2D distance in meters.
elevation (numpy.ndarray) -- Contains the corresponding elevation profile in meters
Desired frequency of the sound. Can be any of
[ 'C', 'C#', 'Db', 'D', 'D#', 'Eb', 'E', 'F', 'F#', 'Gb', 'G', 'G#', 'Ab', 'A', 'A#', 'Bb', 'B' ]
where
'A'
corresponds to 440Hz.Can also be a frequency in Hz.
sampling_rate (int, default = 44100) -- Sampling rate in Hz
approximate_length_in_seconds (float, default = 1.) -- The desired length of the audio signal in seconds If equal to zero, will return a single loop.
- Returns
audio (numpy.ndarray of numpy.int16) -- The transformed audio signal
sampling_rate (int) -- The sampling rate of the audio signal.
- komoog.audio.convert_tour_to_audio(tour, max_elevation_difference=0, tune='C', sampling_rate=44100, approximate_length_in_seconds=1, set_tune_to_follow_tour_profile=False)[source]¶
Convert a hiking tour to audio.
- Parameters
tour (dict) -- A komoot tour item as provided by e.g.
komoog.io.read_tours()
.max_elevation_difference (float, default = 0) -- Used to control the level of the audio signal. If this value is
<= 0
, the audio level will always be maximized. If given a positive value, this value will represent the maximum scale of the audio signal. If the elevation profile's elevation difference is larger than this value, the signal will simply be maximized. A good value ismax_elevation_difference = 2000
.Desired frequency of the sound. Can be any of
[ 'C', 'C#', 'Db', 'D', 'D#', 'Eb', 'E', 'F', 'F#', 'Gb', 'G', 'G#', 'Ab', 'A', 'A#', 'Bb', 'B' ]
where
'A'
corresponds to 440Hz.Can also be a frequency in Hz.
sampling_rate (int, default = 44100) -- Sampling rate in Hz
approximate_length_in_seconds (float, default = 1.) -- The desired length of the audio signal in seconds If equal to zero, will return a single loop.
set_tune_to_follow_tour_profile (bool, defaukt = False) -- If set to
True
the tune of the returned audio signal will follow the tour profile.
- Returns
audio (numpy.ndarray of numpy.int16) -- The transformed audio signal
sampling_rate (int) -- The sampling rate of the audio signal.