justinsalamon / scaper

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

Return API for Scaper.generate #114

Closed pseeth closed 4 years ago

pseeth commented 4 years ago

The sequence of changes discussed in #105 contains in it an option to return something from Scaper.generate. After offline discussion, we realized this would be better served in its own issue, and in a PR that get's merged post #105.

justinsalamon commented 4 years ago

Pulling in latest relevant comment so we can continue here:

Regarding return API, it should be the same regardless of how the options are set.

Focusing on the most common use case, I'd start with:

  • soundscape_audio, soundscape_jam

But we also have the text file... I wonder if we should return the list that's used to create it. Then we's return:

  • soundscape_audio, soundscape_jam, soundscape_list

Only then would I return isolated events, so now we get:

  • soundscape_audio, soundscape_jam, soundscape_list, event_audio_list

thoughts @pseeth ?

justinsalamon commented 4 years ago

Based on offline discussion:

This also means we'll probably have up update the call API, which is currently this:

In particular, we'll have to think about audio_path, jams_path and no_audio.

The least disruptive would be to change the first two into option args with defaults=None, same as txt_path. This way if the user provides them everything works the same as before. If the user doesn't, then nothing gets saved to disk. We could, in theory, leave no_audio the same, in which case the function returns None for the soundscape audio and the event audio list.

@pseeth thoughts/comments?

pseeth commented 4 years ago

I like turning everything into an optional arg with =None as the default. Returns look good!

justinsalamon commented 4 years ago

Hmm, on second thought, if we make audio_path optional it suggests that if it's left set to None then the audio should not be generated, at which point no_audio becomes redundant and it'd make sense to remove it, which in turn would break the API.

Options:

  1. keep audio_path and jams_path positional (non-optional), and just update what the function returns
  2. Make audio_path and jams_path optional and keep the redundant no_audio option such that if audio_path is None then no audio is returned, if it's not None but no_audio is True then still no audio is return. Feels messy to me.
  3. Make audio_path and jams_path optional, remove no_audio, and only integrate this change as part of a new, API-breaking release.

It may sound "extreme", but I am actually partial to option 3. You?

pseeth commented 4 years ago

Hmm, I think audio_path=None implies that the audio won't be saved, rather than be generated. Whereas no_audio implies it's not going to be generated at all. So I think they should co-exist. When no_audio is True, then, what should the return API be? Return soundscape_audio = None, and event_audio_list = None?

justinsalamon commented 4 years ago

When no_audio is True, then, what should the return API be? Return soundscape_audio = None, and event_audio_list = None?

Yes, I think when no_audio is True we should return None for all items that are expected to contain audio.

Given this API though, I don't love the term "no_audio", because it's a little vague. But I can live with that and then when we break the API we can consider renaming this too.

OK, I think we have a path forward for this now. I'll work on a PR.

pseeth commented 4 years ago

Awesome, yeah I agree that no_audio should be changed to something else in a future release.

justinsalamon commented 4 years ago

Addressed via #121. Some missing functionality moved over to new issue #122. Closing this one out.