Giter Site home page Giter Site logo

chord2midi's Introduction

chord2midi

This Python script generates a MIDI file with a chord progression based on the specified parameters.

CLI usage

python generate_midi.py --scale-root C --chord-degrees 1 4 5 --output-file cmaj_145.midi

This command will generate a MIDI file named cmaj_145.midi with a chord progression of C major, F major, and G major chords.

Arguments

  • --scale-root: The root note of the scale (e.g., C, Cmaj). Default is C.
  • --chord-degrees: Chord degrees in the scale (e.g., 6 4 1 5).
  • --chord-types: Chord types corresponding to the degrees (e.g., minor major major major).
  • --output-file: Output MIDI file name. If skipped, filename will be generated automatically.
  • --chord-duration: Duration of each chord in ticks. Default is 960 ticks.

API usage

Start a server using: python app.py The server will be started on port 5000.

A sample request with curl to be saved on generated_midi.midi:

curl -G "http://127.0.0.1:5000/generate_midi" --data-urlencode "scale_root=C" --data-urlencode "chord_degrees=1" --data-urlencode "chord_degrees=4" --data-urlencode "chord_degrees=5" --data-urlencode "chord_duration=960" --output generated_midi.midi

Or directly via a browser with the following url: http://127.0.0.1:5000/generate_midi?scale_root=C&chord_degrees=1&chord_degrees=4&chord_degrees=5&chord_duration=960

Query Parameters

  • scale_root: The root note of the scale (e.g., C, Cmaj). Default is C.
  • chord_degrees: Chord degrees in the scale (e.g., 6, 4, 1, 5). Specify each degree as a separate parameter.
  • chord_types: (Optional) Chord types corresponding to the degrees (e.g., minor, major, major, major). Specify each type as a separate parameter.
  • output_file: (Optional) Output MIDI file name. If skipped, the filename will be generated automatically.
  • chord_duration: (Optional) Duration of each chord in ticks. Default is 960 ticks.

Dependencies

  • Python 3.x version
  • mido and flask libraries (Install using pip install -r requirements.txt)

Tested with Python 3.10.7

Acknowledgements

This project acknowledges ChatGPT's role in its creation. It aimed to check ChatGPT's coding capabilities for quick project creation.

chord2midi's People

Contributors

nojux-official 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.