scaper icon indicating copy to clipboard operation
scaper copied to clipboard

Explicit control over sound event overlap

Open justinsalamon opened this issue 4 years ago • 5 comments

Certain scenarios require limiting the amount of overlapping sound events (or prohibiting it altogether). Right now there is no way to explicitly control for sound overlap.

Proposed solution: add a max_overlap kwarg to generate(), which by default is set to None, meaning any overlap is allowed. If set to 1, it basically means no overlap is allowed, 2 means 2 overlapping sounds, etc. 0 would be an invalid value.

(This would address #62)

justinsalamon avatar Aug 13 '19 01:08 justinsalamon

To tag on a bit, a min_overlap could also be nice, to make sure that generated scenes aren't trivial for source separation networks to solve, if using Scaper for the purposes of training separation networks.

pseeth avatar Aug 13 '19 01:08 pseeth

Sure! The logic for the two is quite different though - max_overlap just needs to find a place to locate each event such that the constraint isn't violated. min_overlap would basically require adding more and more events until the minimum overlap is reached everywhere. Will probably implement max_overlap first and then min_overlap in a separate PR (once pending PRs are finally merged.. sheesh! this fall hopefully!)

justinsalamon avatar Aug 13 '19 02:08 justinsalamon

Hi @pseeth @justinsalamon , I was wondering if the max_overlap is already implemented in any branc/version of Scaper already?

If not could you guide me to get it done? Thanks !

sreenivasaupadhyaya avatar Feb 18 '21 11:02 sreenivasaupadhyaya

@sreenivasaupadhyaya it’s not implemented yet. The feature requires a couple of delicate design decisions. We’re currently blocked on higher priorities, but will try to get to this soon, thanks

justinsalamon avatar Mar 10 '21 00:03 justinsalamon

@sreenivasaupadhyaya it’s not implemented yet. The feature requires a couple of delicate design decisions. We’re currently blocked on higher priorities, but will try to get to this soon, thanks

@justinsalamon is this tool already implemented? I am trying to create thousands of audio samples in which they have from 1 to 3 events without overlapping. I managed to implement a for loop that cover the "for _ in range(n_events):" part and it kind of works but still not what I want to do. In the documentation I also couldn't find a way to make it work by setting the onset of each event. I tried with a list, but it stills overlap the sounds.

In this example I created soundscapes with three events, the implementation for creating 1 and 2 events samples is commented.

# """ 1 event"""
# time1 = round(random.uniform(0, 14), 1)
# time_plus = [time1]
# """ """

# """ 2 events """
# time1 = round(random.uniform(0, 4), 1)
# time2 = round(random.uniform(10, 14), 1)
# time_plus = [time1, time2]
# """ """

"""3 events"""
time1 = round(random.uniform(0, 4), 1)
time2 = round(random.uniform(10, 14), 1)
time3 = round(random.uniform(20, 24), 1)
time_plus = [time1, time2, time3]
""" """

# time_plus = [time1, time2, time3]
for event_time in time_plus:
    print('event time is: ', event_time)

    # add random number of foreground events
    n_events = np.random.randint(min_events, max_events+1)
    for _ in range(n_events):
        sc.add_event(label=('choose', []),
                 source_file=('choose', []),
                 source_time=(source_time_dist, source_time),
                 # event_time=(event_time_dist, event_time_mean, event_time_std, event_time_min, event_time_max),
                 # event_time=(event_time_dist, event_time_min, event_time_max),
                 event_time=(event_time_dist, event_time),
                 # event_duration=(event_duration_dist, event_duration_min, event_duration_max),
                 event_duration=(event_duration_dist, event_duration),
                 snr=(snr_dist, snr_min, snr_max),
                 pitch_shift= None, #it accepts None value
                 time_stretch= None) #it accepts None value
pass

Thanks in advance.

Kovalt0 avatar Mar 30 '22 19:03 Kovalt0