justinsalamon / scaper

A library for soundscape synthesis and augmentation
BSD 3-Clause "New" or "Revised" License
384 stars 56 forks source link

Adding default values for event parameters #51

Open beasteers opened 5 years ago

beasteers commented 5 years ago

Here is a summary of the defaults that I added:

# Background:
label: ('choose', [])
source_file: ('choose', [])
source_time: ('uniform', 0, source_duration - duration)
snr: ('const', 0)

# Foreground
label: ('choose', [])
source_file: ('choose', [])
source_time: ('const', 0)
event_time: ('uniform', 0, duration - event_duration)
event_duration: ('const', source_duration)
snr: ('const', 0)
pitch_shift: None
time_stretch: None

The ones that are most beneficial are the source_time, event_time, and the event_duration, as they can help sample evenly from recordings with differing lengths with fewer manually set values, but defaults in general seem like a nice convenience.


This change is Reviewable

beasteers commented 5 years ago

This is in reference to #41

coveralls commented 5 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 90e2f0002a54a0097a04f397a7139bfcd6d2d3f6 on bensteers:event_defaults into 3c83bba96c146025119516b4e1a6f3ef7ff5bfad on justinsalamon:master.

pseeth commented 5 years ago

This looks somewhat related to the changes in #53, if you want to take a look at that. Instead of hard-coding defaults for source_time, you can pass in something like ('uniform', 0, 100000), where the last number is just some number bigger than the duration of all your source files and it'll fall back to doing ('uniform', 0, source_duration - event_duration). Similar logic is implemented for the other supported distributions.

beasteers commented 5 years ago

Oh wow that's some timing lol. K, I'll look into it when I can get a minute. Hopefully we can merge them, because I still think having default values across the board is intuitive, like I think you should be able to do:

sc.add_background(label=('const', 'street'))
sc.add_event(label=('const', 'bird'))
sc.add_event(label=('const', 'car_honking'))
sc.add_event() # any random event

and have it generate valid soundscapes based on the limited information you give it.

justinsalamon commented 5 years ago

See my latest comment on #41