Coder Social home page Coder Social logo

leavie / audio-to-midi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nfjones/audio-to-midi

0.0 0.0 0.0 24.15 MB

A python program which performs an FFT on an audio file and produces a MIDI file from the results.

License: MIT License

Python 100.00%

audio-to-midi's Introduction

audio-to-midi

audio-to-midi takes in a sound file and converts it to a multichannel MIDI file. It accomplishes this by performing FFT's on all channels of the audio data at user specified time steps. It then separates the resulting frequency analysis into equivalence classes which correspond to the twelve tone scale; the volume of each class being the average volume of its constituent frequencies. It then formats this data for MIDI and writes it out to a user specified file. It has the ability to convert whichever audio file formats are supported by the soundfile module. libsndfile must be installed before running audio-to-midi

Installation

> python3 ./setup.py install

Usage

> audio-to-midi --help
usage: audio-to-midi [-h] [--output OUTPUT] [--time-window TIME_WINDOW] [--activation-level ACTIVATION_LEVEL] [--condense]
                     [--condense-max] [--single-note] [--note-count NOTE_COUNT] [--bpm BPM] [--beat BEAT] [--transpose TRANSPOSE]
                     [--pitch-set PITCH_SET [PITCH_SET ...]] [--pitch-range PITCH_RANGE PITCH_RANGE] [--no-progress]
                     infile

positional arguments:
  infile                The sound file to process.

optional arguments:
  -h, --help            show this help message and exit
  --output OUTPUT, -o OUTPUT
                        The MIDI file to output. Default: <infile>.mid
  --time-window TIME_WINDOW, -t TIME_WINDOW
                        The time span over which to compute the individual FFTs in milliseconds.
  --activation-level ACTIVATION_LEVEL, -a ACTIVATION_LEVEL
                        The amplitude threshold for notes to be added to the MIDI file. Must be between 0 and 1.
  --condense, -c        Combine contiguous notes at their average amplitude.
  --condense-max, -m    Write the maximum velocity for a condensed note segment rather than the rolling average.
  --single-note, -s     Only add the loudest note to the MIDI file for a given time window.
  --note-count NOTE_COUNT, -C NOTE_COUNT
                        Only add the loudest n notes to the MIDI file for a given time window.
  --bpm BPM, -b BPM     Beats per minute. Defaults: 60
  --beat BEAT, -B BEAT  Time window in terms of beats (1/4, 1/8, etc.). Supercedes the time window parameter.
  --transpose TRANSPOSE, -T TRANSPOSE
                        Transpose the MIDI pitches by a constant offset.
  --pitch-set PITCH_SET [PITCH_SET ...], -p PITCH_SET [PITCH_SET ...]
                        Map to a pitch set. Values must be in the range: [0, 11]. Ex: -p 0 2 4 5 7 9 11
  --pitch-range PITCH_RANGE PITCH_RANGE, -P PITCH_RANGE PITCH_RANGE
                        The minimumand maximum allowed MIDI notes. These may be superseded by the calculated FFT range.
  --no-progress, -n     Don't print the progress bar.

Example

>$ audio-to-midi ./this_is_a_test.wav -b 120 -t 30
./this_is_a_test.wav
samplerate: 44100 Hz
channels: 1
duration: 2.000 s
format: WAV (Microsoft) [WAV]
subtype: Signed 16 bit PCM [PCM_16]
window: 5.0 ms
frequencies: min = 200.0 Hz, max = 20000 Hz
100% (401 of 401) |##############################################################| Elapsed Time: 0:00:00 Time:  0:00:00
> ls ./*.mid
./this_is_a_test.wav.mid

audio-to-midi's People

Contributors

nfjones 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.