Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes required to enable FOA #55

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"datasets/rir_datasets" # Directory containing Room Impulse Response (RIR) files
)
ROOM = "bomb_shelter" # Initial room setting, change according to available rooms listed below
FORMAT = "mic" # Output format specifier
FORMAT = "foa" # Output format specifier: could be 'mic' or 'foa'
N_EVENTS_MEAN = 15 # Mean number of foreground events in a soundscape
N_EVENTS_STD = 6 # Standard deviation of the number of foreground events
DURATION = 60.0 # Duration in seconds of each soundscape, customizable by the user
Expand Down
26 changes: 15 additions & 11 deletions spatialscaper/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@
__ROOM_RIR_FILE__ = {
"metu": "metu_sparg_em32.sofa",
"arni": "arni_mic.sofa",
"bomb_shelter": "bomb_shelter_mic.sofa",
"gym": "gym_mic.sofa",
"pb132": "pb132_mic.sofa",
"pc226": "pc226_mic.sofa",
"sa203": "sa203_mic.sofa",
"sc203": "sc203_mic.sofa",
"se203": "se203_mic.sofa",
"tb103": "tb103_mic.sofa",
"tc352": "tc352_mic.sofa",
"bomb_shelter": "bomb_shelter_{fmt}.sofa",
"gym": "gym_{fmt}.sofa",
"pb132": "pb132_{fmt}.sofa",
"pc226": "pc226_{fmt}.sofa",
"sa203": "sa203_{fmt}.sofa",
"sc203": "sc203_{fmt}.sofa",
"se203": "se203_{fmt}.sofa",
"tb103": "tb103_{fmt}.sofa",
"tc352": "tc352_{fmt}.sofa",
}


Expand Down Expand Up @@ -547,8 +547,10 @@ def get_room_irs_xyz(self):
Returns:
numpy.ndarray: An array of XYZ coordinates for the impulse response positions.
"""
if self.format == 'foa' and self.room in ['metu','arni']:
raise ValueError('"metu" and "arni" rooms are currently only supported in mic (tetrahedral) format. please check again soon.')
room_sofa_path = os.path.join(
self.rir_dir, __SPATIAL_SCAPER_RIRS_DIR__, __ROOM_RIR_FILE__[self.room]
self.rir_dir, __SPATIAL_SCAPER_RIRS_DIR__, __ROOM_RIR_FILE__[self.room].format(fmt=self.format)
)
return load_pos(room_sofa_path, doas=False)

Expand All @@ -563,8 +565,10 @@ def get_room_irs_wav_xyz(self, wav=True, pos=True):
Returns:
tuple: A tuple containing the impulse responses, their sampling rate, and their XYZ positions.
"""
if self.format == 'foa' and self.room in ['metu','arni']:
raise ValueError('"metu" and "arni" rooms are currently only supported in mic (tetrahedral) format. please check again soon.')
room_sofa_path = os.path.join(
self.rir_dir, __SPATIAL_SCAPER_RIRS_DIR__, __ROOM_RIR_FILE__[self.room]
self.rir_dir, __SPATIAL_SCAPER_RIRS_DIR__, __ROOM_RIR_FILE__[self.room].format(fmt=self.format)
)
all_irs, ir_sr, all_ir_xyzs = load_rir_pos(room_sofa_path, doas=False)
ir_sr = ir_sr.data[0]
Expand Down