Giter Club home page Giter Club logo

elasticlerp's Introduction

Elerp

This WL script reads a MIDI file containing a sequence of K events (notes) and it creates an elastic path between K points in an N-Dimensional space (e.g. the latent space of a GAN). The returned sequence of vectors will be such that the corresponding outputs of the generator will form a movie with a swift dynamic near the MIDI events, and a slowly changing content in between. The final movie will be as if created at variable frame-rate, with accelerated and decelerated playback speed in pace with the MIDI track.

Usage

wolframscript -f Elerp.wl

You will be asked to insert the MIDI filename, a valid frame-rate r for the final video and the latent space dimension. Given that r cannot be smaller than the inverse of the minimum distance (in seconds) between two MIDI events, a non-valid frame-rate will be automatically replaced with the minimum valid one.

The output is a CSV file nameed elasticLatents.dat. Use this file as input of your generator!

Discussion

A linear interpolation between two latent vectors v1 and v2 can be written as

where 0 < ft < 1 is a parametric curve of the parameter 0 < t < 1. In particular, for ft = t we have the standard definition of lerp (linear interpolation).

An Elastic Lerp (Elerp) is a lerp defined by the following non-linear parametric curve:

that is a shifted and rescaled tangent with a time-warping parameter a. In the script, a is set to 0.77.

Note that the standard linear interpolation is the limit of the Elerp for zero time-warp.

The effect of the time-warping parameter is to slow down the pace of the interpolation between v1 and v2 and to accelerate it in their proximity.

Time Synchronization

Let's say that in the MIDI file there are K events occurring at tk. In this case, we need to define K latent vectors vk that are going to be interpolated. The script default is to generate K vectors with normal random components and order these vectors by finding the shortest tour. As an alternative, you can define or import your own latents.

Once we have all these K latents, we want the image generated from the vk vector to appear at time tk in the movie, the latent vk+1 at time tk+1 and so on. We achieve this by sampling the elastic path between vk and vk+1 with a number of interpolated vectors equal to r (tk+1 - tk)

elasticlerp's People

Contributors

ludwiggle avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.