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

audio custom filter documentation? #267

Closed
mhfowler opened this issue Feb 16, 2016 · 2 comments
Closed

audio custom filter documentation? #267

mhfowler opened this issue Feb 16, 2016 · 2 comments
Labels
audio Related to AudioClip, or handling of audio in general. documentation Related to documentation in official project docs or individual docstrings.

Comments

@mhfowler
Copy link

I am trying to write my own custom audio filter.

I am looking at audio_fadein as an example, but I am having trouble understanding the expected type of (t) the input variable.

Could anyone explain what the expected type of t is? Or where in the moviepy code I can look to see what libraries this t comes from or is used by? Thank you for any help, it is greatly appreciated.

@audio_video_fx
def audio_fadein(clip, duration):
    """ Return an audio (or video) clip that is first mute, then the
        sound arrives progressively over ``duration`` seconds. """

    def fading(gf,t):
        gft = gf(t)

        if np.isscalar(t):
            factor = min(1.0 * t / duration, 1)
            factor = np.array([factor,factor])
        else:
            factor = np.minimum(1.0 * t / duration, 1)
            factor = np.vstack([factor,factor]).T
        return factor * gft
    return clip.fl(fading, keep_duration = True)
@Zulko
Copy link
Owner

Zulko commented Feb 16, 2016

t represents the time in second since the beginning of the clip. gf(t) is a function that represents the sound signal, for a given t it returns either a single value (for mono sound ) a pair [left, right](for stereo sound).

If you give me more infos on what you are trying to do I could help, but maybe it's better to ask the question on stackoverflow or reddit/moviepy and use Github just for issue tracking.

@mhfowler
Copy link
Author

Hi zulko, thanks for responding!

I ended up figuring it out -- I was just thrown off by the fact that the t values I was getting were actually an array of 2000 equidistant values. Once I realized that all of these values were time in seconds since the beginning of the clip then I was able to achieve the effect I wanted without a problem.

I also asked and answered this question on stack overflow here: http://stackoverflow.com/questions/35441672/how-do-you-make-a-custom-audio-filter-using-moviepy/35515807#35515807 but feel free to add more detail or corrections.

Have really been enjoying using moviepy. Thanks for the awesome work!

@keikoro keikoro added the documentation Related to documentation in official project docs or individual docstrings. label Feb 17, 2017
@keikoro keikoro added the audio Related to AudioClip, or handling of audio in general. label Nov 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio Related to AudioClip, or handling of audio in general. documentation Related to documentation in official project docs or individual docstrings.
Projects
None yet
Development

No branches or pull requests

4 participants