Soundscape¶
Bridge to ambiscape: soundscape features on the MGT time base.
MGT owns pixels, ambiscape owns samples; this adapter is the one crossing point. It runs
(or reuses) ambiscape's cached feature extraction and returns the 1 Hz series as an
MgFeatures container whose metadata carries the absolute start time, so motion and audio
series join on the wall clock. Requires pip install "musicalgestures[soundscape]".
A video is a valid input. The original adapter took an ambiscape session folder --- several WAVs on one clock --- which is right when somebody recorded a place on purpose and wrong when what you have is a video, which is what this toolbox is for. ambiscape opens a single file as a one-take session, so a video needs only its audio pulling out first.
The part with a right answer is which of the three a path is, and audio_source_for is
that decision on its own so it can be tested without ffmpeg or ambiscape present. Getting
it wrong silently is how a video ends up analysed as a folder containing one thing.
features_from_ambiscape ¶
features_from_ambiscape(F)
ambiscape's feature dict as named 1 Hz series.
Level, the shape of the spectrum, how tonal or noisy it is, and where the energy sits by octave band --- which is a soundscape vocabulary, where level alone is only loud or quiet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
F
|
the mapping ambiscape's |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
name to series, all the same length, all on the 1 Hz grid. |
Raises:
| Type | Description |
|---|---|
KeyError
|
if |
Source code in musicalgestures/_soundscape.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
audio_source_for ¶
audio_source_for(source, audio=None)
What kind of input this is, and what to hand ambiscape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
a directory (an ambiscape session), an audio file, or a video. |
required | |
audio
|
an audio file to use instead of extracting one. The caller often already has it, and extracting it again is waste. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
|
|
For |
||
|
exist yet, and it is deliberately not the source's own name with the suffix |
||
|
swapped, so a source that is already an audio file cannot be overwritten by its |
||
|
own extraction. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
if |
ValueError
|
if it is a file of a kind this cannot open. |
Source code in musicalgestures/_soundscape.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
soundscape_features ¶
soundscape_features(source, features_dir=None, audio=None, sr=48000)
Soundscape features as an MgFeatures (1 Hz, wall-clocked).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
an ambiscape session folder, an audio file, or a video, whose audio is extracted once and reused. |
required | |
features_dir
|
cache directory for ambiscape's .npz features
(default: |
None
|
|
audio
|
an audio file to use instead of extracting one from |
None
|
|
sr
|
int
|
Sample rate for the extraction. Defaults to 48000, which is what ambiscape's band measures expect; downsampling first would move the noise floor it reports. |
48000
|
Source code in musicalgestures/_soundscape.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
merge_into_summary ¶
merge_into_summary(features, summary_json, prefix='mot_')
Fold feature medians/IQRs into an analysis summary.json.
The mirror of ambiscape's vision --merge (which uses vis_):
each feature contributes <prefix><name>_median and
<prefix><name>_iqr so one summary file describes the whole
audio–video session. Existing keys are preserved.
Source code in musicalgestures/_soundscape.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |