GithubHelp home page GithubHelp logo

image-to-waveform's Introduction

Image To Waveform

This program is designed to superimpose an image mask on a waveform. Images should be drawn on a white (RGB(255, 255, 255)) canvas. An example image is included. Inspired by this YouTube video.

Requirements

Requires numpy, pillow, pysoundfile, e.g. through:

pip install numpy Pillow PySoundfile

Example usage

python3 image-to-waveform.py in/smile.png out/smile.wav

Parameters

-i INAUDIO, --inAudio INAUDIO
                    Input audio filename
-d DURATION, --duration DURATION
                    Length of generated audio in seconds
-f FREQUENCY, --frequency FREQUENCY
                    Generator frequency
-s SAMPLERATE, --samplerate SAMPLERATE
                    Generator sample rate
--interp {nn,lin}     Interpolation type

How it works

The program transforms each column of the image into DC offsets and amplitudes. The resulting parameters are then multiplied with the original waveform. Interpolation has to be done to smoothly convert from the x-axis of the image to the time-axis of the audio. As time only increases, the image also has to have certain properties in order to be fully representable in the audio (there should be no discontinuities in the y-axis).

The default waveform is a cosine wave at maximum amplitude with the Nyquist frequency. This frequency is chosen such that the resulting samples continuously alternate between -1 and +1, and thus provide most visible body to the resulting waveform. Of course, the user is free to choose any other frequency or even to load their own waveform. The default result is inaudible for the average human (22050 Hz), but should be readily visible through e.g. Audacity.

image-to-waveform's People

Contributors

teuncm avatar

Watchers

 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.