Giter Site home page Giter Site logo

musickbd's Introduction

Musical Keyboard

Use your computer's keyboard like a piano! Just run this python3 script and press some keys of your keyboard to try it out.

You can also use it to play files, like this:

cat samples/jingle.txt | ./music_kbd.py -q -t 0.2

Advanced usage

Run ./music_kbd.py --help to see the command-line arguments accepted by this program.

You can also pipe output of a program into this script and it will play it. You can either control the timing yourself by flushing output at exactly the right times, or you can dump all output together and the script will play characters one-by-one if you pass it the -q switch.

You can control the duration for which a character is played by using the -t flag. By default, underscores, uppercase characters and other characters which require the shift key to be typed will be played for twice the duration. You can switch this behavior off by using the --no-double-upper flag.

Map file

A map file is used to specify what frequency each key maps to. By default default_map.json is used. You can specify a custom map file by using the -m or --mapfile command-line argument.

The mapfile is a dictionary where keys are strings and values are frequencies. All characters in a key will be mapped to the corresponding frequency. Characters mapped to null will not be played, but will take up time when using the -q mode. Characters which have not been mapped to anything will not be played and will not take up time in -q mode.

How it works

This python 3 script uses ALSA's speaker-test to produce sound. speaker-test comes pre-installed in Ubuntu 16.04.

speaker-test plays sound for either a very long time or indefinately. Therefore, I kill it after waiting for the desired time. This leads to bad sound quality (a tick sound at the end of keypress).

If you know of a better way to play sound, feel free to contribute!

musickbd's People

Contributors

sharmaeklavya2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jksuk12345

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.